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:
jenkins@jenkinsdm1
Date:
Tue Oct 09 13:49:30 2018 -0500
Revision:
12:05435282f899
Parent:
7:a31236c2e75c
Child:
16:e76cec0eec43
dotbox-firmware revision 3.1.1

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"
jenkins@jenkinsdm1 12:05435282f899 46 #include "ModeRegion.h"
Mike Fiore 1:71125aa00e33 47 // misc heders
Mike Fiore 1:71125aa00e33 48 #include "FileName.h"
Mike Fiore 1:71125aa00e33 49 #include <string>
Mike Fiore 1:71125aa00e33 50
jenkins@jenkinsdm1 12:05435282f899 51 #ifndef CHANNEL_PLAN
jenkins@jenkinsdm1 12:05435282f899 52 #define CHANNEL_PLAN CP_US915
jenkins@jenkinsdm1 12:05435282f899 53 #endif
jenkins@jenkinsdm1 12:05435282f899 54
Mike Fiore 7:a31236c2e75c 55 #define DISABLE_DUTY_CYCLE true
Mike Fiore 7:a31236c2e75c 56
Mike Fiore 1:71125aa00e33 57 // LCD and LED controllers
Mike Fiore 1:71125aa00e33 58 SPI lcd_spi(SPI1_MOSI, SPI1_MISO, SPI1_SCK);
Mike Fiore 1:71125aa00e33 59 DigitalOut lcd_spi_cs(SPI1_CS, 1);
Mike Fiore 1:71125aa00e33 60 DigitalOut lcd_cd(XBEE_ON_SLEEP, 1);
Mike Fiore 1:71125aa00e33 61 DOGS102* lcd;
jenkins@jenkinsdm1 12:05435282f899 62
jenkins@jenkinsdm1 12:05435282f899 63 I2C i2c(I2C_SDA, I2C_SCL);
jenkins@jenkinsdm1 12:05435282f899 64 static const int i2c_freq = 400000; // i2c bus frequency in Hz
jenkins@jenkinsdm1 12:05435282f899 65
Mike Fiore 1:71125aa00e33 66 NCP5623B* led_cont;
Mike Fiore 1:71125aa00e33 67
Mike Fiore 1:71125aa00e33 68 // Thread informaiton
Mike Fiore 1:71125aa00e33 69 osThreadId main_id;
Mike Fiore 1:71125aa00e33 70
Mike Fiore 1:71125aa00e33 71 // Button controller
Mike Fiore 1:71125aa00e33 72 ButtonHandler* buttons;
Mike Fiore 1:71125aa00e33 73
Mike Fiore 1:71125aa00e33 74 // LoRa controller
Mike Fiore 7:a31236c2e75c 75 LoRaHandler* lora_handler;
Mike Fiore 7:a31236c2e75c 76
jenkins@jenkinsdm1 12:05435282f899 77 lora::ChannelPlan* plan;
Mike Fiore 1:71125aa00e33 78 mDot* dot;
Mike Fiore 1:71125aa00e33 79
Mike Fiore 1:71125aa00e33 80 // GPS
Mike Fiore 1:71125aa00e33 81 GPSPARSER* gps;
jenkins@jenkinsdm1 12:05435282f899 82 MTSSerial gps_serial(XBEE_DOUT, XBEE_DIN, 256, 2048);
Mike Fiore 1:71125aa00e33 83
Mike Fiore 1:71125aa00e33 84 // Sensors
Mike Fiore 1:71125aa00e33 85 SensorHandler* sensors;
Mike Fiore 1:71125aa00e33 86
Mike Fiore 1:71125aa00e33 87 // Modes
Mike Fiore 1:71125aa00e33 88 ModeJoin* modeJoin;
Mike Fiore 1:71125aa00e33 89 ModeSingle* modeSingle;
Mike Fiore 1:71125aa00e33 90 ModeSweep* modeSweep;
Mike Fiore 1:71125aa00e33 91 ModeDemo* modeDemo;
Mike Fiore 1:71125aa00e33 92 ModeConfig* modeConfig;
Mike Fiore 7:a31236c2e75c 93 ModeGps* modeGps;
Mike Fiore 7:a31236c2e75c 94 ModeData* modeData;
jenkins@jenkinsdm1 12:05435282f899 95 ModeRegion* modeRegion;
Mike Fiore 1:71125aa00e33 96
Mike Fiore 1:71125aa00e33 97 // Serial debug port
jenkins@jenkinsdm1 12:05435282f899 98 Serial debug_port(USBTX, USBRX);
Mike Fiore 1:71125aa00e33 99
Mike Fiore 1:71125aa00e33 100 // Survey Data File
Mike Fiore 7:a31236c2e75c 101 char file_name[] = "SurveyData.txt";
Mike Fiore 1:71125aa00e33 102
jenkins@jenkinsdm1 12:05435282f899 103 // Channel plan file
jenkins@jenkinsdm1 12:05435282f899 104 char file_cp[] = "ChannelPlan";
jenkins@jenkinsdm1 12:05435282f899 105
Mike Fiore 1:71125aa00e33 106 // Prototypes
Mike Fiore 1:71125aa00e33 107 void mainMenu();
Mike Fiore 1:71125aa00e33 108
Mike Fiore 1:71125aa00e33 109 int main() {
jenkins@jenkinsdm1 12:05435282f899 110 debug_port.baud(115200);
jenkins@jenkinsdm1 12:05435282f899 111
jenkins@jenkinsdm1 12:05435282f899 112 i2c.frequency(i2c_freq);
Mike Fiore 1:71125aa00e33 113
Mike Fiore 1:71125aa00e33 114 lcd = new DOGS102(lcd_spi, lcd_spi_cs, lcd_cd);
Mike Fiore 1:71125aa00e33 115 // NCP5623B::LEDs 1 & 2 are the screen backlight - not used on default build
Mike Fiore 1:71125aa00e33 116 // NCP5623B::LED3 is EVB LED2
jenkins@jenkinsdm1 12:05435282f899 117 led_cont = new NCP5623B(i2c);
jenkins@jenkinsdm1 12:05435282f899 118 gps = new GPSPARSER(&gps_serial, led_cont);
jenkins@jenkinsdm1 12:05435282f899 119 sensors = new SensorHandler(i2c);
Mike Fiore 1:71125aa00e33 120
Mike Fiore 1:71125aa00e33 121 main_id = Thread::gettid();
Mike Fiore 1:71125aa00e33 122 buttons = new ButtonHandler(main_id);
jenkins@jenkinsdm1 12:05435282f899 123 MTSLog::setLogLevel(MTSLog::TRACE_LEVEL);
jenkins@jenkinsdm1 12:05435282f899 124
jenkins@jenkinsdm1 12:05435282f899 125 logDebug("Loading default plan");
jenkins@jenkinsdm1 12:05435282f899 126
jenkins@jenkinsdm1 12:05435282f899 127 #if CHANNEL_PLAN == CP_AS923
jenkins@jenkinsdm1 12:05435282f899 128 plan = new lora::ChannelPlan_AS923();
jenkins@jenkinsdm1 12:05435282f899 129 #elif CHANNEL_PLAN == CP_US915
jenkins@jenkinsdm1 12:05435282f899 130 plan = new lora::ChannelPlan_US915();
jenkins@jenkinsdm1 12:05435282f899 131 #elif CHANNEL_PLAN == CP_AU915
jenkins@jenkinsdm1 12:05435282f899 132 plan = new lora::ChannelPlan_AU915();
jenkins@jenkinsdm1 12:05435282f899 133 #elif CHANNEL_PLAN == CP_EU868
jenkins@jenkinsdm1 12:05435282f899 134 plan = new lora::ChannelPlan_EU868();
jenkins@jenkinsdm1 12:05435282f899 135 #elif CHANNEL_PLAN == CP_KR920
jenkins@jenkinsdm1 12:05435282f899 136 plan = new lora::ChannelPlan_KR920();
jenkins@jenkinsdm1 12:05435282f899 137 #elif CHANNEL_PLAN == CP_IN865
jenkins@jenkinsdm1 12:05435282f899 138 plan = new lora::ChannelPlan_IN865();
jenkins@jenkinsdm1 12:05435282f899 139 #elif CHANNEL_PLAN == CP_AS923_JAPAN
jenkins@jenkinsdm1 12:05435282f899 140 plan = new lora::ChannelPlan_AS923_Japan();
jenkins@jenkinsdm1 12:05435282f899 141 #endif
jenkins@jenkinsdm1 12:05435282f899 142 mDot* dot = mDot::getInstance(plan);
jenkins@jenkinsdm1 12:05435282f899 143
jenkins@jenkinsdm1 12:05435282f899 144 uint8_t cplan[] = { 0 };
jenkins@jenkinsdm1 12:05435282f899 145 mDot::mdot_file file;
jenkins@jenkinsdm1 12:05435282f899 146 vector<mDot::mdot_file> files = dot->listUserFiles();
jenkins@jenkinsdm1 12:05435282f899 147
jenkins@jenkinsdm1 12:05435282f899 148 for (vector<mDot::mdot_file>::iterator it = files.begin(); it != files.end(); it++) {
jenkins@jenkinsdm1 12:05435282f899 149 if (strcmp(file_cp,it->name)==0) {
jenkins@jenkinsdm1 12:05435282f899 150 file = dot->openUserFile(it->name, mDot::FM_RDWR);
jenkins@jenkinsdm1 12:05435282f899 151 dot->seekUserFile(file, 0, SEEK_SET);
jenkins@jenkinsdm1 12:05435282f899 152 dot->readUserFile(file, cplan, 1);
jenkins@jenkinsdm1 12:05435282f899 153 dot->closeUserFile(file);
jenkins@jenkinsdm1 12:05435282f899 154 }
jenkins@jenkinsdm1 12:05435282f899 155 }
jenkins@jenkinsdm1 12:05435282f899 156
jenkins@jenkinsdm1 12:05435282f899 157 if(cplan[0]) {
jenkins@jenkinsdm1 12:05435282f899 158 if(cplan[0] != CHANNEL_PLAN){
jenkins@jenkinsdm1 12:05435282f899 159 logDebug("Loading saved channel plan");
jenkins@jenkinsdm1 12:05435282f899 160 switch (cplan[0]){
jenkins@jenkinsdm1 12:05435282f899 161 case CP_AS923:
jenkins@jenkinsdm1 12:05435282f899 162 delete plan;
jenkins@jenkinsdm1 12:05435282f899 163 plan = new lora::ChannelPlan_AS923();
jenkins@jenkinsdm1 12:05435282f899 164 break;
jenkins@jenkinsdm1 12:05435282f899 165
jenkins@jenkinsdm1 12:05435282f899 166 case CP_US915:
jenkins@jenkinsdm1 12:05435282f899 167 delete plan;
jenkins@jenkinsdm1 12:05435282f899 168 plan = new lora::ChannelPlan_US915();
jenkins@jenkinsdm1 12:05435282f899 169 break;
jenkins@jenkinsdm1 12:05435282f899 170
jenkins@jenkinsdm1 12:05435282f899 171 case CP_AU915:
jenkins@jenkinsdm1 12:05435282f899 172 delete plan;
jenkins@jenkinsdm1 12:05435282f899 173 plan = new lora::ChannelPlan_AU915();
jenkins@jenkinsdm1 12:05435282f899 174 break;
jenkins@jenkinsdm1 12:05435282f899 175
jenkins@jenkinsdm1 12:05435282f899 176 case CP_EU868:
jenkins@jenkinsdm1 12:05435282f899 177 delete plan;
jenkins@jenkinsdm1 12:05435282f899 178 plan = new lora::ChannelPlan_EU868();
jenkins@jenkinsdm1 12:05435282f899 179 break;
jenkins@jenkinsdm1 12:05435282f899 180
jenkins@jenkinsdm1 12:05435282f899 181 case CP_KR920:
jenkins@jenkinsdm1 12:05435282f899 182 delete plan;
jenkins@jenkinsdm1 12:05435282f899 183 plan = new lora::ChannelPlan_KR920();
jenkins@jenkinsdm1 12:05435282f899 184 break;
jenkins@jenkinsdm1 12:05435282f899 185
jenkins@jenkinsdm1 12:05435282f899 186 case CP_AS923_JAPAN:
jenkins@jenkinsdm1 12:05435282f899 187 delete plan;
jenkins@jenkinsdm1 12:05435282f899 188 plan = new lora::ChannelPlan_AS923_Japan();
jenkins@jenkinsdm1 12:05435282f899 189 break;
jenkins@jenkinsdm1 12:05435282f899 190
jenkins@jenkinsdm1 12:05435282f899 191 default:
jenkins@jenkinsdm1 12:05435282f899 192 logInfo("Saved channel plan not valid Defaulting US915");
jenkins@jenkinsdm1 12:05435282f899 193 delete plan;
jenkins@jenkinsdm1 12:05435282f899 194 plan = new lora::ChannelPlan_US915();
jenkins@jenkinsdm1 12:05435282f899 195 break;
jenkins@jenkinsdm1 12:05435282f899 196 }
jenkins@jenkinsdm1 12:05435282f899 197 dot->setChannelPlan(plan);
jenkins@jenkinsdm1 12:05435282f899 198 }
jenkins@jenkinsdm1 12:05435282f899 199 }
jenkins@jenkinsdm1 12:05435282f899 200 lora_handler = new LoRaHandler(main_id, dot);
Mike Fiore 7:a31236c2e75c 201
Mike Fiore 7:a31236c2e75c 202 dot->setDisableDutyCycle(DISABLE_DUTY_CYCLE);
Mike Fiore 7:a31236c2e75c 203 dot->setLinkCheckThreshold(0);
Mike Fiore 7:a31236c2e75c 204 dot->setLinkCheckCount(0);
jenkins@jenkinsdm1 12:05435282f899 205 //Adr off to make sure modes work, auto sleep off seems to cause issues, haven't looked into it yet
jenkins@jenkinsdm1 12:05435282f899 206 dot->setAdr(false);
jenkins@jenkinsdm1 12:05435282f899 207 dot->setLogLevel(MTSLog::DEBUG_LEVEL);
jenkins@jenkinsdm1 12:05435282f899 208 dot->setAutoSleep(false);
Mike Fiore 7:a31236c2e75c 209 // Seed the RNG
Mike Fiore 7:a31236c2e75c 210 srand(dot->getRadioRandom());
Mike Fiore 7:a31236c2e75c 211
Mike Fiore 1:71125aa00e33 212 led_cont->setLEDCurrent(16);
Mike Fiore 1:71125aa00e33 213
Mike Fiore 7:a31236c2e75c 214 modeJoin = new ModeJoin(lcd, buttons, dot, lora_handler, gps, sensors);
Mike Fiore 7:a31236c2e75c 215 modeSingle = new ModeSingle(lcd, buttons, dot, lora_handler, gps, sensors);
Mike Fiore 7:a31236c2e75c 216 modeSweep = new ModeSweep(lcd, buttons, dot, lora_handler, gps, sensors);
Mike Fiore 7:a31236c2e75c 217 modeDemo = new ModeDemo(lcd, buttons, dot, lora_handler, gps, sensors);
Mike Fiore 7:a31236c2e75c 218 modeConfig = new ModeConfig(lcd, buttons, dot, lora_handler, gps, sensors);
Mike Fiore 7:a31236c2e75c 219 modeGps = new ModeGps(lcd, buttons, dot, lora_handler, gps, sensors, modeJoin);
Mike Fiore 7:a31236c2e75c 220 modeData = new ModeData(lcd, buttons, dot, lora_handler, gps, sensors);
jenkins@jenkinsdm1 12:05435282f899 221 modeRegion = new ModeRegion(lcd, buttons, dot, lora_handler, gps, sensors, file_cp);
Mike Fiore 1:71125aa00e33 222
Mike Fiore 1:71125aa00e33 223 osDelay(1000);
Mike Fiore 1:71125aa00e33 224 logInfo("%sGPS detected", gps->gpsDetected() ? "" : "no ");
Mike Fiore 1:71125aa00e33 225
jenkins@jenkinsdm1 12:05435282f899 226 if(!cplan[0]) {
jenkins@jenkinsdm1 12:05435282f899 227 dot->saveUserFile(file_cp, cplan, 1);
jenkins@jenkinsdm1 12:05435282f899 228 modeRegion->start();
jenkins@jenkinsdm1 12:05435282f899 229 }
jenkins@jenkinsdm1 12:05435282f899 230
Mike Fiore 1:71125aa00e33 231 // display startup screen for 3 seconds
Mike Fiore 1:71125aa00e33 232 LayoutStartup ls(lcd, dot);
Mike Fiore 1:71125aa00e33 233 ls.display();
Mike Fiore 1:71125aa00e33 234 ls.updateGPS(gps->gpsDetected());
Mike Fiore 1:71125aa00e33 235 osDelay(3000);
Mike Fiore 1:71125aa00e33 236 logInfo("displaying main menu");
Mike Fiore 1:71125aa00e33 237 mainMenu();
Mike Fiore 1:71125aa00e33 238
Mike Fiore 1:71125aa00e33 239 return 0;
Mike Fiore 1:71125aa00e33 240 }
Mike Fiore 1:71125aa00e33 241
Mike Fiore 1:71125aa00e33 242 void mainMenu() {
Mike Fiore 1:71125aa00e33 243 bool mode_selected = false;
Mike Fiore 1:71125aa00e33 244 std::string selected;
Mike Fiore 1:71125aa00e33 245 std::string product;
jenkins@jenkinsdm1 12:05435282f899 246
Mike Fiore 1:71125aa00e33 247 typedef enum {
Mike Fiore 1:71125aa00e33 248 demo = 1,
Mike Fiore 1:71125aa00e33 249 config,
Mike Fiore 1:71125aa00e33 250 single,
Mike Fiore 7:a31236c2e75c 251 sweep,
Mike Fiore 7:a31236c2e75c 252 gps,
jenkins@jenkinsdm1 12:05435282f899 253 data,
jenkins@jenkinsdm1 12:05435282f899 254 region
Mike Fiore 1:71125aa00e33 255 } menu_items;
Mike Fiore 1:71125aa00e33 256
Mike Fiore 1:71125aa00e33 257 std::string menu_strings[] = {
Mike Fiore 1:71125aa00e33 258 "Select Mode",
Mike Fiore 1:71125aa00e33 259 "LoRa Demo",
Mike Fiore 1:71125aa00e33 260 "Configuration",
Mike Fiore 1:71125aa00e33 261 "Survey Single",
Mike Fiore 7:a31236c2e75c 262 "Survey Sweep",
Mike Fiore 7:a31236c2e75c 263 "Survey GPS",
jenkins@jenkinsdm1 12:05435282f899 264 "View Data",
jenkins@jenkinsdm1 12:05435282f899 265 "Select Region"
Mike Fiore 1:71125aa00e33 266 };
jenkins@jenkinsdm1 12:05435282f899 267
Mike Fiore 1:71125aa00e33 268 std::vector<std::string> items;
Mike Fiore 1:71125aa00e33 269 items.push_back(menu_strings[demo]);
Mike Fiore 1:71125aa00e33 270 items.push_back(menu_strings[config]);
Mike Fiore 1:71125aa00e33 271 items.push_back(menu_strings[single]);
Mike Fiore 1:71125aa00e33 272 items.push_back(menu_strings[sweep]);
Mike Fiore 7:a31236c2e75c 273 items.push_back(menu_strings[gps]);
Mike Fiore 7:a31236c2e75c 274 items.push_back(menu_strings[data]);
jenkins@jenkinsdm1 12:05435282f899 275 items.push_back(menu_strings[region]);
Mike Fiore 1:71125aa00e33 276
Mike Fiore 1:71125aa00e33 277 while (true) {
Mike Fiore 1:71125aa00e33 278 // reset session between modes
Mike Fiore 1:71125aa00e33 279 dot->resetNetworkSession();
jenkins@jenkinsdm1 12:05435282f899 280 selected = "";
jenkins@jenkinsdm1 12:05435282f899 281 //dot->getChannelPlanName causes hard faults, not sure why.
jenkins@jenkinsdm1 12:05435282f899 282 product = "DOT-BOX/EVB " + plan->GetPlanName();
jenkins@jenkinsdm1 12:05435282f899 283 if(product.size() > 17)
jenkins@jenkinsdm1 12:05435282f899 284 product = "DOT-BOX/EVB JAPAN";
Mike Fiore 1:71125aa00e33 285 LayoutScrollSelect menu(lcd, items, product, menu_strings[0]);
Mike Fiore 1:71125aa00e33 286 menu.display();
Mike Fiore 1:71125aa00e33 287
Mike Fiore 1:71125aa00e33 288 while (! mode_selected) {
jenkins@jenkinsdm1 12:05435282f899 289 lora_handler->resetActivityLed();
Mike Fiore 1:71125aa00e33 290 osEvent e = Thread::signal_wait(buttonSignal);
Mike Fiore 1:71125aa00e33 291 if (e.status == osEventSignal) {
Mike Fiore 1:71125aa00e33 292 ButtonHandler::ButtonEvent ev = buttons->getButtonEvent();
Mike Fiore 1:71125aa00e33 293 switch (ev) {
Mike Fiore 1:71125aa00e33 294 case ButtonHandler::sw1_press:
Mike Fiore 1:71125aa00e33 295 selected = menu.select();
Mike Fiore 1:71125aa00e33 296 mode_selected = true;
Mike Fiore 1:71125aa00e33 297 break;
Mike Fiore 1:71125aa00e33 298 case ButtonHandler::sw2_press:
Mike Fiore 1:71125aa00e33 299 menu.scroll();
Mike Fiore 1:71125aa00e33 300 break;
Mike Fiore 1:71125aa00e33 301 case ButtonHandler::sw1_hold:
Mike Fiore 1:71125aa00e33 302 break;
Mike Fiore 1:71125aa00e33 303 default:
Mike Fiore 1:71125aa00e33 304 break;
Mike Fiore 1:71125aa00e33 305 }
Mike Fiore 1:71125aa00e33 306 }
Mike Fiore 1:71125aa00e33 307 }
Mike Fiore 1:71125aa00e33 308 if (selected == menu_strings[demo]) {
Mike Fiore 1:71125aa00e33 309 if (modeJoin->start())
Mike Fiore 1:71125aa00e33 310 modeDemo->start();
Mike Fiore 1:71125aa00e33 311 } else if (selected == menu_strings[config]) {
Mike Fiore 1:71125aa00e33 312 modeConfig->start();
Mike Fiore 1:71125aa00e33 313 } else if (selected == menu_strings[single]) {
Mike Fiore 1:71125aa00e33 314 if (modeJoin->start())
Mike Fiore 1:71125aa00e33 315 modeSingle->start();
Mike Fiore 1:71125aa00e33 316 } else if (selected == menu_strings[sweep]) {
Mike Fiore 1:71125aa00e33 317 if (modeJoin->start())
Mike Fiore 1:71125aa00e33 318 modeSweep->start();
Mike Fiore 7:a31236c2e75c 319 } else if (selected == menu_strings[gps]) {
jenkins@jenkinsdm1 12:05435282f899 320 if (plan->IsPlanDynamic()) {
jenkins@jenkinsdm1 12:05435282f899 321 if(modeJoin->start())
jenkins@jenkinsdm1 12:05435282f899 322 modeGps->start();
Mike Fiore 7:a31236c2e75c 323 }
jenkins@jenkinsdm1 12:05435282f899 324 else {
jenkins@jenkinsdm1 12:05435282f899 325 modeGps->start();
jenkins@jenkinsdm1 12:05435282f899 326 }
Mike Fiore 7:a31236c2e75c 327 } else if (selected == menu_strings[data]) {
Mike Fiore 7:a31236c2e75c 328 modeData->start();
jenkins@jenkinsdm1 12:05435282f899 329 } else if (selected == menu_strings[region]) {
jenkins@jenkinsdm1 12:05435282f899 330 modeRegion->start();
jenkins@jenkinsdm1 12:05435282f899 331 }
jenkins@jenkinsdm1 12:05435282f899 332 lora_handler->resetActivityLed();
Mike Fiore 1:71125aa00e33 333 mode_selected = false;
Mike Fiore 1:71125aa00e33 334 }
Mike Fiore 1:71125aa00e33 335 }