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
Parent:
1:71125aa00e33
Child:
12:05435282f899
update from git revision 2.1.2

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Mike Fiore 1:71125aa00e33 1 /* Copyright (c) <2016> <MultiTech Systems>, MIT License
Mike Fiore 1:71125aa00e33 2 *
Mike Fiore 1:71125aa00e33 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
Mike Fiore 1:71125aa00e33 4 * and associated documentation files (the "Software"), to deal in the Software without restriction,
Mike Fiore 1:71125aa00e33 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
Mike Fiore 1:71125aa00e33 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
Mike Fiore 1:71125aa00e33 7 * furnished to do so, subject to the following conditions:
Mike Fiore 1:71125aa00e33 8 *
Mike Fiore 1:71125aa00e33 9 * The above copyright notice and this permission notice shall be included in all copies or
Mike Fiore 1:71125aa00e33 10 * substantial portions of the Software.
Mike Fiore 1:71125aa00e33 11 *
Mike Fiore 1:71125aa00e33 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
Mike Fiore 1:71125aa00e33 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Mike Fiore 1:71125aa00e33 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
Mike Fiore 1:71125aa00e33 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Mike Fiore 1:71125aa00e33 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Mike Fiore 1:71125aa00e33 17 */
Mike Fiore 1:71125aa00e33 18
Mike Fiore 1:71125aa00e33 19 // mbed headers
Mike Fiore 1:71125aa00e33 20 #include "mbed.h"
Mike Fiore 1:71125aa00e33 21 #include "rtos.h"
Mike Fiore 1:71125aa00e33 22 // MTS headers
Mike Fiore 1:71125aa00e33 23 #include "mDot.h"
Mike Fiore 1:71125aa00e33 24 #include "MTSLog.h"
Mike Fiore 1:71125aa00e33 25 // display headers
Mike Fiore 1:71125aa00e33 26 #include "DOGS102.h"
Mike Fiore 1:71125aa00e33 27 #include "NCP5623B.h"
Mike Fiore 1:71125aa00e33 28 #include "LayoutStartup.h"
Mike Fiore 1:71125aa00e33 29 #include "LayoutScrollSelect.h"
Mike Fiore 1:71125aa00e33 30 #include "LayoutConfig.h"
Mike Fiore 1:71125aa00e33 31 #include "LayoutHelp.h"
Mike Fiore 1:71125aa00e33 32 // button header
Mike Fiore 1:71125aa00e33 33 #include "ButtonHandler.h"
Mike Fiore 1:71125aa00e33 34 // LoRa header
Mike Fiore 1:71125aa00e33 35 #include "LoRaHandler.h"
Mike Fiore 1:71125aa00e33 36 // Sensor header
Mike Fiore 1:71125aa00e33 37 #include "SensorHandler.h"
Mike Fiore 1:71125aa00e33 38 // mode objects
Mike Fiore 1:71125aa00e33 39 #include "ModeJoin.h"
Mike Fiore 1:71125aa00e33 40 #include "ModeSingle.h"
Mike Fiore 1:71125aa00e33 41 #include "ModeSweep.h"
Mike Fiore 1:71125aa00e33 42 #include "ModeDemo.h"
Mike Fiore 1:71125aa00e33 43 #include "ModeConfig.h"
Mike Fiore 7:a31236c2e75c 44 #include "ModeGps.h"
Mike Fiore 7:a31236c2e75c 45 #include "ModeData.h"
Mike Fiore 1:71125aa00e33 46 // misc heders
Mike Fiore 1:71125aa00e33 47 #include "FileName.h"
Mike Fiore 1:71125aa00e33 48 #include <string>
Mike Fiore 1:71125aa00e33 49
Mike Fiore 7:a31236c2e75c 50 #define DISABLE_DUTY_CYCLE true
Mike Fiore 7:a31236c2e75c 51
Mike Fiore 7:a31236c2e75c 52
Mike Fiore 1:71125aa00e33 53 // LCD and LED controllers
Mike Fiore 1:71125aa00e33 54 SPI lcd_spi(SPI1_MOSI, SPI1_MISO, SPI1_SCK);
Mike Fiore 1:71125aa00e33 55 I2C led_i2c(I2C_SDA, I2C_SCL);
Mike Fiore 1:71125aa00e33 56 DigitalOut lcd_spi_cs(SPI1_CS, 1);
Mike Fiore 1:71125aa00e33 57 DigitalOut lcd_cd(XBEE_ON_SLEEP, 1);
Mike Fiore 1:71125aa00e33 58 DOGS102* lcd;
Mike Fiore 1:71125aa00e33 59 NCP5623B* led_cont;
Mike Fiore 1:71125aa00e33 60
Mike Fiore 1:71125aa00e33 61 // Thread informaiton
Mike Fiore 1:71125aa00e33 62 osThreadId main_id;
Mike Fiore 1:71125aa00e33 63
Mike Fiore 1:71125aa00e33 64 // Button controller
Mike Fiore 1:71125aa00e33 65 ButtonHandler* buttons;
Mike Fiore 1:71125aa00e33 66
Mike Fiore 1:71125aa00e33 67 // LoRa controller
Mike Fiore 7:a31236c2e75c 68 LoRaHandler* lora_handler;
Mike Fiore 7:a31236c2e75c 69
Mike Fiore 1:71125aa00e33 70 mDot* dot;
Mike Fiore 1:71125aa00e33 71
Mike Fiore 1:71125aa00e33 72 // GPS
Mike Fiore 1:71125aa00e33 73 GPSPARSER* gps;
Mike Fiore 1:71125aa00e33 74 MTSSerial gps_serial(XBEE_DOUT, XBEE_DIN, 256, 2048);
Mike Fiore 1:71125aa00e33 75
Mike Fiore 1:71125aa00e33 76 // Sensors
Mike Fiore 1:71125aa00e33 77 SensorHandler* sensors;
Mike Fiore 1:71125aa00e33 78
Mike Fiore 1:71125aa00e33 79 // Modes
Mike Fiore 1:71125aa00e33 80 ModeJoin* modeJoin;
Mike Fiore 1:71125aa00e33 81 ModeSingle* modeSingle;
Mike Fiore 1:71125aa00e33 82 ModeSweep* modeSweep;
Mike Fiore 1:71125aa00e33 83 ModeDemo* modeDemo;
Mike Fiore 1:71125aa00e33 84 ModeConfig* modeConfig;
Mike Fiore 7:a31236c2e75c 85 ModeGps* modeGps;
Mike Fiore 7:a31236c2e75c 86 ModeData* modeData;
Mike Fiore 1:71125aa00e33 87
Mike Fiore 1:71125aa00e33 88 // Serial debug port
Mike Fiore 1:71125aa00e33 89 Serial debug(USBTX, USBRX);
Mike Fiore 1:71125aa00e33 90
Mike Fiore 1:71125aa00e33 91 // Survey Data File
Mike Fiore 7:a31236c2e75c 92 char file_name[] = "SurveyData.txt";
Mike Fiore 1:71125aa00e33 93
Mike Fiore 1:71125aa00e33 94 // Prototypes
Mike Fiore 1:71125aa00e33 95 void mainMenu();
Mike Fiore 1:71125aa00e33 96
Mike Fiore 1:71125aa00e33 97 int main() {
Mike Fiore 1:71125aa00e33 98 debug.baud(115200);
Mike Fiore 1:71125aa00e33 99
Mike Fiore 1:71125aa00e33 100 lcd = new DOGS102(lcd_spi, lcd_spi_cs, lcd_cd);
Mike Fiore 1:71125aa00e33 101 // NCP5623B::LEDs 1 & 2 are the screen backlight - not used on default build
Mike Fiore 1:71125aa00e33 102 // NCP5623B::LED3 is EVB LED2
Mike Fiore 1:71125aa00e33 103 led_cont = new NCP5623B(led_i2c);
Mike Fiore 1:71125aa00e33 104
Mike Fiore 1:71125aa00e33 105 main_id = Thread::gettid();
Mike Fiore 1:71125aa00e33 106 buttons = new ButtonHandler(main_id);
Mike Fiore 1:71125aa00e33 107 dot = mDot::getInstance();
Mike Fiore 7:a31236c2e75c 108 lora_handler = new LoRaHandler(main_id);
Mike Fiore 7:a31236c2e75c 109
Mike Fiore 7:a31236c2e75c 110 dot->setDisableDutyCycle(DISABLE_DUTY_CYCLE);
Mike Fiore 7:a31236c2e75c 111 dot->setLinkCheckThreshold(0);
Mike Fiore 7:a31236c2e75c 112 dot->setLinkCheckCount(0);
Mike Fiore 7:a31236c2e75c 113
Mike Fiore 7:a31236c2e75c 114 // Seed the RNG
Mike Fiore 7:a31236c2e75c 115 srand(dot->getRadioRandom());
Mike Fiore 7:a31236c2e75c 116
Mike Fiore 1:71125aa00e33 117 gps = new GPSPARSER(&gps_serial, led_cont);
Mike Fiore 1:71125aa00e33 118 sensors = new SensorHandler();
Mike Fiore 1:71125aa00e33 119
Mike Fiore 1:71125aa00e33 120 led_cont->setLEDCurrent(16);
Mike Fiore 1:71125aa00e33 121
Mike Fiore 1:71125aa00e33 122 MTSLog::setLogLevel(MTSLog::TRACE_LEVEL);
Mike Fiore 1:71125aa00e33 123
Mike Fiore 7:a31236c2e75c 124 modeJoin = new ModeJoin(lcd, buttons, dot, lora_handler, gps, sensors);
Mike Fiore 7:a31236c2e75c 125 modeSingle = new ModeSingle(lcd, buttons, dot, lora_handler, gps, sensors);
Mike Fiore 7:a31236c2e75c 126 modeSweep = new ModeSweep(lcd, buttons, dot, lora_handler, gps, sensors);
Mike Fiore 7:a31236c2e75c 127 modeDemo = new ModeDemo(lcd, buttons, dot, lora_handler, gps, sensors);
Mike Fiore 7:a31236c2e75c 128 modeConfig = new ModeConfig(lcd, buttons, dot, lora_handler, gps, sensors);
Mike Fiore 7:a31236c2e75c 129 modeGps = new ModeGps(lcd, buttons, dot, lora_handler, gps, sensors, modeJoin);
Mike Fiore 7:a31236c2e75c 130 modeData = new ModeData(lcd, buttons, dot, lora_handler, gps, sensors);
Mike Fiore 7:a31236c2e75c 131
Mike Fiore 1:71125aa00e33 132
Mike Fiore 1:71125aa00e33 133 osDelay(1000);
Mike Fiore 1:71125aa00e33 134 logInfo("%sGPS detected", gps->gpsDetected() ? "" : "no ");
Mike Fiore 1:71125aa00e33 135
Mike Fiore 1:71125aa00e33 136 // display startup screen for 3 seconds
Mike Fiore 1:71125aa00e33 137 LayoutStartup ls(lcd, dot);
Mike Fiore 1:71125aa00e33 138 ls.display();
Mike Fiore 1:71125aa00e33 139 ls.updateGPS(gps->gpsDetected());
Mike Fiore 1:71125aa00e33 140 osDelay(3000);
Mike Fiore 1:71125aa00e33 141
Mike Fiore 1:71125aa00e33 142 logInfo("displaying main menu");
Mike Fiore 1:71125aa00e33 143 mainMenu();
Mike Fiore 1:71125aa00e33 144
Mike Fiore 1:71125aa00e33 145 return 0;
Mike Fiore 1:71125aa00e33 146 }
Mike Fiore 1:71125aa00e33 147
Mike Fiore 1:71125aa00e33 148 void mainMenu() {
Mike Fiore 1:71125aa00e33 149 bool mode_selected = false;
Mike Fiore 1:71125aa00e33 150 std::string selected;
Mike Fiore 1:71125aa00e33 151 std::string product;
Mike Fiore 1:71125aa00e33 152
Mike Fiore 1:71125aa00e33 153 typedef enum {
Mike Fiore 1:71125aa00e33 154 demo = 1,
Mike Fiore 1:71125aa00e33 155 config,
Mike Fiore 1:71125aa00e33 156 single,
Mike Fiore 7:a31236c2e75c 157 sweep,
Mike Fiore 7:a31236c2e75c 158 gps,
Mike Fiore 7:a31236c2e75c 159 data
Mike Fiore 7:a31236c2e75c 160
Mike Fiore 1:71125aa00e33 161 } menu_items;
Mike Fiore 1:71125aa00e33 162
Mike Fiore 1:71125aa00e33 163 std::string menu_strings[] = {
Mike Fiore 1:71125aa00e33 164 "Select Mode",
Mike Fiore 1:71125aa00e33 165 "LoRa Demo",
Mike Fiore 1:71125aa00e33 166 "Configuration",
Mike Fiore 1:71125aa00e33 167 "Survey Single",
Mike Fiore 7:a31236c2e75c 168 "Survey Sweep",
Mike Fiore 7:a31236c2e75c 169 "Survey GPS",
Mike Fiore 7:a31236c2e75c 170 "View Data"
Mike Fiore 1:71125aa00e33 171 };
Mike Fiore 1:71125aa00e33 172 std::vector<std::string> items;
Mike Fiore 1:71125aa00e33 173 items.push_back(menu_strings[demo]);
Mike Fiore 1:71125aa00e33 174 items.push_back(menu_strings[config]);
Mike Fiore 1:71125aa00e33 175 items.push_back(menu_strings[single]);
Mike Fiore 1:71125aa00e33 176 items.push_back(menu_strings[sweep]);
Mike Fiore 7:a31236c2e75c 177 items.push_back(menu_strings[gps]);
Mike Fiore 7:a31236c2e75c 178 items.push_back(menu_strings[data]);
Mike Fiore 1:71125aa00e33 179
Mike Fiore 1:71125aa00e33 180 while (true) {
Mike Fiore 7:a31236c2e75c 181 product = "DOT-BOX/EVB ";
Mike Fiore 7:a31236c2e75c 182 product += mDot::FrequencyBandStr(dot->getFrequencyBand());
Mike Fiore 1:71125aa00e33 183
Mike Fiore 1:71125aa00e33 184 // reset session between modes
Mike Fiore 1:71125aa00e33 185 dot->resetNetworkSession();
Mike Fiore 7:a31236c2e75c 186 lora_handler->resetActivityLed();
Mike Fiore 7:a31236c2e75c 187
Mike Fiore 1:71125aa00e33 188 LayoutScrollSelect menu(lcd, items, product, menu_strings[0]);
Mike Fiore 1:71125aa00e33 189 menu.display();
Mike Fiore 1:71125aa00e33 190
Mike Fiore 1:71125aa00e33 191 while (! mode_selected) {
Mike Fiore 1:71125aa00e33 192 osEvent e = Thread::signal_wait(buttonSignal);
Mike Fiore 1:71125aa00e33 193 if (e.status == osEventSignal) {
Mike Fiore 1:71125aa00e33 194 ButtonHandler::ButtonEvent ev = buttons->getButtonEvent();
Mike Fiore 1:71125aa00e33 195 switch (ev) {
Mike Fiore 1:71125aa00e33 196 case ButtonHandler::sw1_press:
Mike Fiore 1:71125aa00e33 197 selected = menu.select();
Mike Fiore 1:71125aa00e33 198 mode_selected = true;
Mike Fiore 1:71125aa00e33 199 break;
Mike Fiore 1:71125aa00e33 200 case ButtonHandler::sw2_press:
Mike Fiore 1:71125aa00e33 201 menu.scroll();
Mike Fiore 1:71125aa00e33 202 break;
Mike Fiore 1:71125aa00e33 203 case ButtonHandler::sw1_hold:
Mike Fiore 1:71125aa00e33 204 break;
Mike Fiore 1:71125aa00e33 205 default:
Mike Fiore 1:71125aa00e33 206 break;
Mike Fiore 1:71125aa00e33 207 }
Mike Fiore 1:71125aa00e33 208 }
Mike Fiore 1:71125aa00e33 209 }
Mike Fiore 1:71125aa00e33 210 if (selected == menu_strings[demo]) {
Mike Fiore 1:71125aa00e33 211 if (modeJoin->start())
Mike Fiore 1:71125aa00e33 212 modeDemo->start();
Mike Fiore 1:71125aa00e33 213 } else if (selected == menu_strings[config]) {
Mike Fiore 1:71125aa00e33 214 modeConfig->start();
Mike Fiore 1:71125aa00e33 215 } else if (selected == menu_strings[single]) {
Mike Fiore 1:71125aa00e33 216 if (modeJoin->start())
Mike Fiore 1:71125aa00e33 217 modeSingle->start();
Mike Fiore 1:71125aa00e33 218 } else if (selected == menu_strings[sweep]) {
Mike Fiore 1:71125aa00e33 219 if (modeJoin->start())
Mike Fiore 1:71125aa00e33 220 modeSweep->start();
Mike Fiore 7:a31236c2e75c 221 } else if (selected == menu_strings[gps]) {
Mike Fiore 7:a31236c2e75c 222 if(dot->getFrequencyBand() == mDot::FB_EU868) {
Mike Fiore 7:a31236c2e75c 223 modeJoin->start();
Mike Fiore 7:a31236c2e75c 224 }
Mike Fiore 7:a31236c2e75c 225 modeGps->start();
Mike Fiore 7:a31236c2e75c 226 } else if (selected == menu_strings[data]) {
Mike Fiore 7:a31236c2e75c 227 modeData->start();
Mike Fiore 7:a31236c2e75c 228 }
Mike Fiore 1:71125aa00e33 229
Mike Fiore 1:71125aa00e33 230 mode_selected = false;
Mike Fiore 1:71125aa00e33 231 }
Mike Fiore 1:71125aa00e33 232 }
Mike Fiore 1:71125aa00e33 233
Mike Fiore 7:a31236c2e75c 234
Mike Fiore 7:a31236c2e75c 235