Factory firmware for the MultiTech Dotbox (MTDOT-BOX) and EVB (MTDOT-EVB) products.

Dependencies:   NCP5623B GpsParser ISL29011 libmDot-mbed5 MTS-Serial MMA845x DOGS102 MPL3115A2

MTDOT-BOX/EVB Firmware Description

This Firmware is what ships on DotBox and EVB devices. It is intended to be used as a proof of concept and site survey tool for planning LoRa deployments. The firmware provides a number of different modes of operation:

  • Configuration - Use AT commands to configure network credentials, TX power, TX data rate, view the survey data file, etc.
  • Survey Single - Test network connectivity at current location at a specific TX power and TX data rate. Uplink information, downlink information, and GPS information are saved to the survey data file and can also be sent to the gateway.
  • Survey Sweep - Test network connectivity at current location across a range of TX powers and TX data rates. Uplink information, downlink information, and GPS information for each survey in the sweep are saved to the survey data file and can also be sent to the gateway.
  • LoRa Demo - Gather data from onboard sensors and display it on the screen in real time. Send packets containing sensor data to the gateway either on an interval or when triggered by the user. GPS data is not transmitted.
  • Survey GPS - Gather sensor and GPS data and transmit it to the gateway either on an interval or when triggered by the user. Add padding to packets, switch frequency sub bands, TX power, TX data rate, and more all without exiting Survey GPS Mode.
  • View Data - View the survey data file on the screen one survey at a time.

Additional documentation and information for the MTDOT-BOX/EVB Factory Firmware can be found here.


Dot Libraries

Dot Library Limitations

The commit messages in libmDot-mbed5 and libmDot-dev-mbed5 specify the version of the Dot library the commit contains and the version of mbed-os it was compiled against. We recommend building your application with the version of mbed-os specified in the commit message of the version of the Dot library you're using. This will ensure that you don't run into any runtime issues caused by differences in the mbed-os versions.

Development library for mDot.

[Repository '/teams/MultiTech/code/libmDot-dev-mbed5/' not found]

Stable library for mDot.

Import librarylibmDot-mbed5

Stable version of the mDot library for mbed 5. This version of the library is suitable for deployment scenarios. See lastest commit message for version of mbed-os library that has been tested against.

Committer:
Mike Fiore
Date:
Fri Nov 04 17:27:05 2016 -0500
Revision:
7:a31236c2e75c
update from git revision 2.1.2

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Mike Fiore 7:a31236c2e75c 1 /* Copyright (c) <2016> <MultiTech Systems>, MIT License
Mike Fiore 7:a31236c2e75c 2 *
Mike Fiore 7:a31236c2e75c 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
Mike Fiore 7:a31236c2e75c 4 * and associated documentation files (the "Software"), to deal in the Software without restriction,
Mike Fiore 7:a31236c2e75c 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
Mike Fiore 7:a31236c2e75c 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
Mike Fiore 7:a31236c2e75c 7 * furnished to do so, subject to the following conditions:
Mike Fiore 7:a31236c2e75c 8 *
Mike Fiore 7:a31236c2e75c 9 * The above copyright notice and this permission notice shall be included in all copies or
Mike Fiore 7:a31236c2e75c 10 * substantial portions of the Software.
Mike Fiore 7:a31236c2e75c 11 *
Mike Fiore 7:a31236c2e75c 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
Mike Fiore 7:a31236c2e75c 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Mike Fiore 7:a31236c2e75c 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
Mike Fiore 7:a31236c2e75c 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Mike Fiore 7:a31236c2e75c 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Mike Fiore 7:a31236c2e75c 17 */
Mike Fiore 7:a31236c2e75c 18
Mike Fiore 7:a31236c2e75c 19 #include "ModeData.h"
Mike Fiore 7:a31236c2e75c 20 #include "MTSText.h"
Mike Fiore 7:a31236c2e75c 21 #define ONELINEMAX 93
Mike Fiore 7:a31236c2e75c 22
Mike Fiore 7:a31236c2e75c 23 ModeData::ModeData(DOGS102* lcd, ButtonHandler* _buttons, mDot* _dot, LoRaHandler* lora, GPSPARSER* gps, SensorHandler* sensors)
Mike Fiore 7:a31236c2e75c 24 :Mode(lcd,_buttons,_dot,lora,gps,sensors),
Mike Fiore 7:a31236c2e75c 25 _data(lcd),
Mike Fiore 7:a31236c2e75c 26 _help(lcd),
Mike Fiore 7:a31236c2e75c 27 _buf_size(ONELINEMAX)
Mike Fiore 7:a31236c2e75c 28 {}
Mike Fiore 7:a31236c2e75c 29
Mike Fiore 7:a31236c2e75c 30 ModeData::~ModeData() {}
Mike Fiore 7:a31236c2e75c 31
Mike Fiore 7:a31236c2e75c 32 bool ModeData::checkFile(){
Mike Fiore 7:a31236c2e75c 33 bool exists = false;
Mike Fiore 7:a31236c2e75c 34 //get all files and see if file exists
Mike Fiore 7:a31236c2e75c 35 vector<mDot::mdot_file> files = _dot->listUserFiles();
Mike Fiore 7:a31236c2e75c 36 for (vector<mDot::mdot_file>::iterator it = files.begin(); it != files.end(); it++) {
Mike Fiore 7:a31236c2e75c 37 if (strcmp(file_name,it->name)==0) {
Mike Fiore 7:a31236c2e75c 38 exists = true;
Mike Fiore 7:a31236c2e75c 39 break;
Mike Fiore 7:a31236c2e75c 40 }
Mike Fiore 7:a31236c2e75c 41 }
Mike Fiore 7:a31236c2e75c 42 //if file doesnt exist exit to main menu
Mike Fiore 7:a31236c2e75c 43 if(!exists) {
Mike Fiore 7:a31236c2e75c 44 _data.noData();
Mike Fiore 7:a31236c2e75c 45 osDelay(3000);
Mike Fiore 7:a31236c2e75c 46 return true;
Mike Fiore 7:a31236c2e75c 47 }
Mike Fiore 7:a31236c2e75c 48 _file = _dot->openUserFile(file_name, mDot::FM_RDONLY);
Mike Fiore 7:a31236c2e75c 49 //if nothing is in file exit to main menu
Mike Fiore 7:a31236c2e75c 50 if (_file.fd < 0) {
Mike Fiore 7:a31236c2e75c 51 _data.errorData();
Mike Fiore 7:a31236c2e75c 52 osDelay(3000);
Mike Fiore 7:a31236c2e75c 53 _dot->closeUserFile(_file);
Mike Fiore 7:a31236c2e75c 54 return true;
Mike Fiore 7:a31236c2e75c 55 }
Mike Fiore 7:a31236c2e75c 56 return false;
Mike Fiore 7:a31236c2e75c 57 }
Mike Fiore 7:a31236c2e75c 58
Mike Fiore 7:a31236c2e75c 59 bool ModeData::start(){
Mike Fiore 7:a31236c2e75c 60 if(checkFile())
Mike Fiore 7:a31236c2e75c 61 return true;
Mike Fiore 7:a31236c2e75c 62 _help.display();
Mike Fiore 7:a31236c2e75c 63 osDelay(3000);
Mike Fiore 7:a31236c2e75c 64 readFile();
Mike Fiore 7:a31236c2e75c 65 }
Mike Fiore 7:a31236c2e75c 66
Mike Fiore 7:a31236c2e75c 67 void ModeData::displayData(){
Mike Fiore 7:a31236c2e75c 68 std::vector<std::string> data = mts::Text::split(_str, ',');
Mike Fiore 7:a31236c2e75c 69 _line.id = data.at(0);
Mike Fiore 7:a31236c2e75c 70 _line.status = data.at(1);
Mike Fiore 7:a31236c2e75c 71 _line.lock = data.at(2);
Mike Fiore 7:a31236c2e75c 72 _line.lat = data.at(3);
Mike Fiore 7:a31236c2e75c 73 _line.lng = data.at(4);
Mike Fiore 7:a31236c2e75c 74 _line.alt = data.at(5);
Mike Fiore 7:a31236c2e75c 75 _line.time = data.at(6);
Mike Fiore 7:a31236c2e75c 76 _line.gateways = data.at(7);
Mike Fiore 7:a31236c2e75c 77 _line.margin = data.at(8);
Mike Fiore 7:a31236c2e75c 78 _line.rssiD = data.at(9);
Mike Fiore 7:a31236c2e75c 79 _line.snrD = data.at(10);
Mike Fiore 7:a31236c2e75c 80 _line.dataRate = data.at(11);
Mike Fiore 7:a31236c2e75c 81 _line.power = data.at(12);
Mike Fiore 7:a31236c2e75c 82 _data.updateAll(_line);
Mike Fiore 7:a31236c2e75c 83 }
Mike Fiore 7:a31236c2e75c 84
Mike Fiore 7:a31236c2e75c 85 //get the current line out of the buffer into str
Mike Fiore 7:a31236c2e75c 86 void ModeData::getLine(){
Mike Fiore 7:a31236c2e75c 87 _prev = 0;
Mike Fiore 7:a31236c2e75c 88 _indexUpdate = 0;
Mike Fiore 7:a31236c2e75c 89 _str = "";
Mike Fiore 7:a31236c2e75c 90 _dot->readUserFile(_file, (void*)_buf, _buf_size);
Mike Fiore 7:a31236c2e75c 91 //only gets called when going back
Mike Fiore 7:a31236c2e75c 92 if(_last) {
Mike Fiore 7:a31236c2e75c 93 //-3 puts it back to one before new line
Mike Fiore 7:a31236c2e75c 94 _indexUpdate = _buf_size - 3;
Mike Fiore 7:a31236c2e75c 95 //check from back of buffer for new line
Mike Fiore 7:a31236c2e75c 96 while(_buf[_indexUpdate] != '\n' && _indexUpdate >= 0){
Mike Fiore 7:a31236c2e75c 97 _indexUpdate--;
Mike Fiore 7:a31236c2e75c 98 }
Mike Fiore 7:a31236c2e75c 99 _indexUpdate++;
Mike Fiore 7:a31236c2e75c 100 }
Mike Fiore 7:a31236c2e75c 101 //go from indexUpdate to new line to ge the line
Mike Fiore 7:a31236c2e75c 102 //prev keeps track of how long line read was
Mike Fiore 7:a31236c2e75c 103 while(_buf[_indexUpdate]!='\n') {
Mike Fiore 7:a31236c2e75c 104 _str += _buf[_indexUpdate];
Mike Fiore 7:a31236c2e75c 105 _indexUpdate++;
Mike Fiore 7:a31236c2e75c 106 _prev++;
Mike Fiore 7:a31236c2e75c 107 }
Mike Fiore 7:a31236c2e75c 108 //push index past newline
Mike Fiore 7:a31236c2e75c 109 _index += _indexUpdate + 1;
Mike Fiore 7:a31236c2e75c 110 displayData();
Mike Fiore 7:a31236c2e75c 111 }
Mike Fiore 7:a31236c2e75c 112
Mike Fiore 7:a31236c2e75c 113 void ModeData::back(){
Mike Fiore 7:a31236c2e75c 114 if(_index >= (_buf_size + _prev)) {
Mike Fiore 7:a31236c2e75c 115 _index -= (_prev + _buf_size);
Mike Fiore 7:a31236c2e75c 116 } else {
Mike Fiore 7:a31236c2e75c 117 //special case for beginning of file
Mike Fiore 7:a31236c2e75c 118 if(_index > 0){
Mike Fiore 7:a31236c2e75c 119 _buf_size = _index-1;
Mike Fiore 7:a31236c2e75c 120 }
Mike Fiore 7:a31236c2e75c 121 _buf_size -= _prev;
Mike Fiore 7:a31236c2e75c 122 _index = 0;
Mike Fiore 7:a31236c2e75c 123 }
Mike Fiore 7:a31236c2e75c 124 _last = true;
Mike Fiore 7:a31236c2e75c 125 _dot->seekUserFile(_file, _index, SEEK_SET);
Mike Fiore 7:a31236c2e75c 126 getLine();
Mike Fiore 7:a31236c2e75c 127 }
Mike Fiore 7:a31236c2e75c 128
Mike Fiore 7:a31236c2e75c 129 void ModeData::forward(){
Mike Fiore 7:a31236c2e75c 130 _last = false;
Mike Fiore 7:a31236c2e75c 131 if(_index < _file.size) {
Mike Fiore 7:a31236c2e75c 132 _buf_size = ONELINEMAX;
Mike Fiore 7:a31236c2e75c 133 _dot->seekUserFile(_file, _index, SEEK_SET);
Mike Fiore 7:a31236c2e75c 134 getLine();
Mike Fiore 7:a31236c2e75c 135 }
Mike Fiore 7:a31236c2e75c 136 }
Mike Fiore 7:a31236c2e75c 137
Mike Fiore 7:a31236c2e75c 138 //update switch labels
Mike Fiore 7:a31236c2e75c 139 void ModeData::configSw(){
Mike Fiore 7:a31236c2e75c 140 if(_index - (_prev+1) <= 0){
Mike Fiore 7:a31236c2e75c 141 _data.updateSw2("");
Mike Fiore 7:a31236c2e75c 142 } else {
Mike Fiore 7:a31236c2e75c 143 _data.updateSw2("Back");
Mike Fiore 7:a31236c2e75c 144 }
Mike Fiore 7:a31236c2e75c 145 if(_index<_file.size){
Mike Fiore 7:a31236c2e75c 146 _data.updateSw1("Next");
Mike Fiore 7:a31236c2e75c 147 } else {
Mike Fiore 7:a31236c2e75c 148 _data.updateSw1("");
Mike Fiore 7:a31236c2e75c 149 }
Mike Fiore 7:a31236c2e75c 150 }
Mike Fiore 7:a31236c2e75c 151
Mike Fiore 7:a31236c2e75c 152 bool ModeData::readFile(){
Mike Fiore 7:a31236c2e75c 153 _index = 0;
Mike Fiore 7:a31236c2e75c 154 _last = false;
Mike Fiore 7:a31236c2e75c 155 _prev = 0;
Mike Fiore 7:a31236c2e75c 156 _indexUpdate = 0;
Mike Fiore 7:a31236c2e75c 157 //called to start on page one
Mike Fiore 7:a31236c2e75c 158 forward();
Mike Fiore 7:a31236c2e75c 159 configSw();
Mike Fiore 7:a31236c2e75c 160 ButtonHandler::ButtonEvent be;
Mike Fiore 7:a31236c2e75c 161 while (true) {
Mike Fiore 7:a31236c2e75c 162 be = _buttons->getButtonEvent();
Mike Fiore 7:a31236c2e75c 163 switch(be) {
Mike Fiore 7:a31236c2e75c 164 case ButtonHandler::sw1_press:
Mike Fiore 7:a31236c2e75c 165 if(_index!=_file.size) {
Mike Fiore 7:a31236c2e75c 166 forward();
Mike Fiore 7:a31236c2e75c 167 configSw();
Mike Fiore 7:a31236c2e75c 168 }
Mike Fiore 7:a31236c2e75c 169 break;
Mike Fiore 7:a31236c2e75c 170
Mike Fiore 7:a31236c2e75c 171 case ButtonHandler::sw2_press:
Mike Fiore 7:a31236c2e75c 172 if(_index - (_prev+1) > 0) {
Mike Fiore 7:a31236c2e75c 173 back();
Mike Fiore 7:a31236c2e75c 174 configSw();
Mike Fiore 7:a31236c2e75c 175 }
Mike Fiore 7:a31236c2e75c 176 break;
Mike Fiore 7:a31236c2e75c 177
Mike Fiore 7:a31236c2e75c 178 case ButtonHandler::sw1_hold:
Mike Fiore 7:a31236c2e75c 179 _dot->closeUserFile(_file);
Mike Fiore 7:a31236c2e75c 180 return true;
Mike Fiore 7:a31236c2e75c 181
Mike Fiore 7:a31236c2e75c 182 default:
Mike Fiore 7:a31236c2e75c 183 break;
Mike Fiore 7:a31236c2e75c 184 }
Mike Fiore 7:a31236c2e75c 185 }
Mike Fiore 7:a31236c2e75c 186 }
Mike Fiore 7:a31236c2e75c 187