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:
Thu Mar 14 08:23:20 2019 -0500
Revision:
16:e76cec0eec43
Parent:
12:05435282f899
dotbox-firmware revision 3.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 #include "LoRaHandler.h"
Mike Fiore 1:71125aa00e33 20
Mike Fiore 1:71125aa00e33 21 #define signal (int32_t)0xA0
Mike Fiore 1:71125aa00e33 22
Mike Fiore 1:71125aa00e33 23 typedef enum {
Mike Fiore 1:71125aa00e33 24 l_none = 0,
Mike Fiore 1:71125aa00e33 25 l_link_check,
Mike Fiore 1:71125aa00e33 26 l_send,
Mike Fiore 1:71125aa00e33 27 l_join
Mike Fiore 1:71125aa00e33 28 } InternalLoRa;
Mike Fiore 1:71125aa00e33 29
Mike Fiore 1:71125aa00e33 30 uint8_t cmd = l_none;
Mike Fiore 1:71125aa00e33 31 std::vector<uint8_t> send_data;
Mike Fiore 1:71125aa00e33 32
Mike Fiore 1:71125aa00e33 33 void l_worker(void const* argument) {
Mike Fiore 1:71125aa00e33 34 LoRaHandler* l = (LoRaHandler*)argument;
Mike Fiore 1:71125aa00e33 35 osEvent e;
Mike Fiore 1:71125aa00e33 36
Mike Fiore 1:71125aa00e33 37 int32_t ret;
Mike Fiore 1:71125aa00e33 38 mDot::link_check lc;
Mike Fiore 1:71125aa00e33 39 mDot::rssi_stats rs;
Mike Fiore 1:71125aa00e33 40 mDot::snr_stats ss;
Mike Fiore 1:71125aa00e33 41
Mike Fiore 1:71125aa00e33 42 while (true) {
Mike Fiore 1:71125aa00e33 43 e = Thread::signal_wait(signal);
Mike Fiore 1:71125aa00e33 44 if (e.status == osEventSignal) {
Mike Fiore 1:71125aa00e33 45 l->_status = LoRaHandler::busy;
Mike Fiore 1:71125aa00e33 46 l->_tick.attach(l, &LoRaHandler::blinker, 0.05);
Mike Fiore 1:71125aa00e33 47 switch (cmd) {
Mike Fiore 1:71125aa00e33 48 case l_link_check:
Mike Fiore 1:71125aa00e33 49 l->_mutex.lock();
Mike Fiore 1:71125aa00e33 50 lc = l->_dot->networkLinkCheck();
Mike Fiore 1:71125aa00e33 51 l->_mutex.unlock();
Mike Fiore 1:71125aa00e33 52 if (lc.status) {
Mike Fiore 1:71125aa00e33 53 l->_link.up = lc;
Mike Fiore 1:71125aa00e33 54 l->_mutex.lock();
Mike Fiore 1:71125aa00e33 55 rs = l->_dot->getRssiStats();
Mike Fiore 1:71125aa00e33 56 ss = l->_dot->getSnrStats();
Mike Fiore 1:71125aa00e33 57 l->_mutex.unlock();
Mike Fiore 1:71125aa00e33 58 l->_link.down.rssi = rs.last;
Mike Fiore 1:71125aa00e33 59 l->_link.down.snr = ss.last;
Mike Fiore 1:71125aa00e33 60 l->_status = LoRaHandler::link_check_success;
Mike Fiore 1:71125aa00e33 61 } else {
Mike Fiore 1:71125aa00e33 62 l->_status = LoRaHandler::link_check_failure;
Mike Fiore 1:71125aa00e33 63 }
Mike Fiore 1:71125aa00e33 64 osSignalSet(l->_main, loraSignal);
Mike Fiore 1:71125aa00e33 65 l->_tick.detach();
Mike Fiore 1:71125aa00e33 66 l->_activity_led = LoRaHandler::green;
Mike Fiore 1:71125aa00e33 67 break;
jenkins@jenkinsdm1 12:05435282f899 68
Mike Fiore 1:71125aa00e33 69 case l_send:
Mike Fiore 1:71125aa00e33 70 l->_mutex.lock();
Mike Fiore 1:71125aa00e33 71 ret = l->_dot->send(send_data);
Mike Fiore 1:71125aa00e33 72 l->_mutex.unlock();
Mike Fiore 1:71125aa00e33 73 if (ret == mDot::MDOT_OK)
Mike Fiore 1:71125aa00e33 74 l->_status = LoRaHandler::send_success;
jenkins@jenkinsdm1 12:05435282f899 75 else if(ret == mDot::MDOT_MAX_PAYLOAD_EXCEEDED)
jenkins@jenkinsdm1 12:05435282f899 76 l->_status = LoRaHandler::send_failure_payload;
Mike Fiore 1:71125aa00e33 77 else
Mike Fiore 1:71125aa00e33 78 l->_status = LoRaHandler::send_failure;
Mike Fiore 1:71125aa00e33 79 osSignalSet(l->_main, loraSignal);
Mike Fiore 1:71125aa00e33 80 l->_tick.detach();
Mike Fiore 1:71125aa00e33 81 l->_activity_led = LoRaHandler::green;
Mike Fiore 1:71125aa00e33 82 break;
Mike Fiore 1:71125aa00e33 83
Mike Fiore 1:71125aa00e33 84 case l_join:
Mike Fiore 1:71125aa00e33 85 l->_mutex.lock();
Mike Fiore 1:71125aa00e33 86 ret = l->_dot->joinNetworkOnce();
Mike Fiore 1:71125aa00e33 87 l->_join_attempts++;
Mike Fiore 1:71125aa00e33 88 l->_mutex.unlock();
Mike Fiore 1:71125aa00e33 89 if (ret == mDot::MDOT_OK) {
jenkins@jenkinsdm1 12:05435282f899 90 send_data.clear();
jenkins@jenkinsdm1 12:05435282f899 91 l->_mutex.lock();
jenkins@jenkinsdm1 12:05435282f899 92 l->_dot->send(send_data);
jenkins@jenkinsdm1 12:05435282f899 93 l->_dot->send(send_data);
jenkins@jenkinsdm1 12:05435282f899 94 while(l->_dot->getDataPending()) {
jenkins@jenkinsdm1 12:05435282f899 95 l->_dot->send(send_data);
jenkins@jenkinsdm1 12:05435282f899 96 }
jenkins@jenkinsdm1 12:05435282f899 97 l->_dot->send(send_data);
jenkins@jenkinsdm1 12:05435282f899 98 l->_mutex.unlock();
Mike Fiore 1:71125aa00e33 99 l->_status = LoRaHandler::join_success;
Mike Fiore 7:a31236c2e75c 100 osSignalSet(l->_main, loraSignal);
Mike Fiore 7:a31236c2e75c 101 l->_tick.detach();
Mike Fiore 7:a31236c2e75c 102 l->_activity_led = LoRaHandler::green;
Mike Fiore 1:71125aa00e33 103 } else {
Mike Fiore 1:71125aa00e33 104 l->_status = LoRaHandler::join_failure;
Mike Fiore 7:a31236c2e75c 105 osSignalSet(l->_main, loraSignal);
Mike Fiore 7:a31236c2e75c 106 l->_tick.detach();
Mike Fiore 7:a31236c2e75c 107 l->_activity_led = LoRaHandler::red;
Mike Fiore 1:71125aa00e33 108 }
jenkins@jenkinsdm1 12:05435282f899 109
Mike Fiore 1:71125aa00e33 110 break;
Mike Fiore 1:71125aa00e33 111
Mike Fiore 1:71125aa00e33 112 default:
Mike Fiore 1:71125aa00e33 113 l->_status = LoRaHandler::none;
Mike Fiore 1:71125aa00e33 114 break;
Mike Fiore 1:71125aa00e33 115 }
Mike Fiore 1:71125aa00e33 116 }
Mike Fiore 1:71125aa00e33 117 }
Mike Fiore 1:71125aa00e33 118 }
Mike Fiore 1:71125aa00e33 119
jenkins@jenkinsdm1 12:05435282f899 120 LoRaHandler::LoRaHandler(osThreadId main, mDot* dot)
jenkins@jenkinsdm1 12:05435282f899 121 : _main(main),
Mike Fiore 1:71125aa00e33 122 _thread(l_worker, (void*)this),
Mike Fiore 1:71125aa00e33 123 _status(none),
Mike Fiore 1:71125aa00e33 124 _join_attempts(1),
jenkins@jenkinsdm1 12:05435282f899 125 _activity_led(XBEE_DIO1, PIN_OUTPUT, PullNone, red),
jenkins@jenkinsdm1 12:05435282f899 126 _dot(dot)
Mike Fiore 1:71125aa00e33 127 {
Mike Fiore 1:71125aa00e33 128 _link.status = false;
Mike Fiore 1:71125aa00e33 129 _activity_led = red;
Mike Fiore 1:71125aa00e33 130 }
Mike Fiore 1:71125aa00e33 131
Mike Fiore 1:71125aa00e33 132 bool LoRaHandler::linkCheck() {
Mike Fiore 1:71125aa00e33 133 return action(l_link_check);
Mike Fiore 1:71125aa00e33 134 }
Mike Fiore 1:71125aa00e33 135
Mike Fiore 1:71125aa00e33 136 bool LoRaHandler::send(std::vector<uint8_t> data) {
Mike Fiore 1:71125aa00e33 137 send_data = data;
Mike Fiore 1:71125aa00e33 138 return action(l_send);
Mike Fiore 1:71125aa00e33 139 }
Mike Fiore 1:71125aa00e33 140
Mike Fiore 1:71125aa00e33 141 bool LoRaHandler::join() {
jenkins@jenkinsdm1 12:05435282f899 142 return action(l_join);
Mike Fiore 1:71125aa00e33 143 }
Mike Fiore 1:71125aa00e33 144
Mike Fiore 1:71125aa00e33 145 bool LoRaHandler::action(uint8_t c) {
Mike Fiore 1:71125aa00e33 146 if (_status != busy) {
Mike Fiore 1:71125aa00e33 147 cmd = c;
Mike Fiore 1:71125aa00e33 148 _thread.signal_set(signal);
Mike Fiore 1:71125aa00e33 149 _thread.signal_clr(signal);
Mike Fiore 1:71125aa00e33 150 return true;
Mike Fiore 1:71125aa00e33 151 }
Mike Fiore 1:71125aa00e33 152
Mike Fiore 1:71125aa00e33 153 return false;
Mike Fiore 1:71125aa00e33 154 }
Mike Fiore 1:71125aa00e33 155
Mike Fiore 1:71125aa00e33 156 LoRaHandler::LoRaStatus LoRaHandler::getStatus() {
Mike Fiore 1:71125aa00e33 157 LoRaStatus status;
Mike Fiore 1:71125aa00e33 158 _mutex.lock();
Mike Fiore 1:71125aa00e33 159 status = _status;
Mike Fiore 1:71125aa00e33 160 _mutex.unlock();
Mike Fiore 1:71125aa00e33 161
Mike Fiore 1:71125aa00e33 162 return status;
Mike Fiore 1:71125aa00e33 163 }
Mike Fiore 1:71125aa00e33 164
Mike Fiore 1:71125aa00e33 165 LoRaHandler::LoRaLink LoRaHandler::getLinkCheckResults() {
Mike Fiore 1:71125aa00e33 166 LoRaLink link;
Mike Fiore 1:71125aa00e33 167 _mutex.lock();
Mike Fiore 1:71125aa00e33 168 link = _link;
Mike Fiore 1:71125aa00e33 169 _mutex.unlock();
Mike Fiore 1:71125aa00e33 170
Mike Fiore 1:71125aa00e33 171 return link;
Mike Fiore 1:71125aa00e33 172 }
Mike Fiore 1:71125aa00e33 173
Mike Fiore 1:71125aa00e33 174 uint32_t LoRaHandler::getJoinAttempts() {
Mike Fiore 1:71125aa00e33 175 uint32_t val;
Mike Fiore 1:71125aa00e33 176
Mike Fiore 1:71125aa00e33 177 _mutex.lock();
Mike Fiore 1:71125aa00e33 178 val = _join_attempts;
Mike Fiore 1:71125aa00e33 179 _mutex.unlock();
Mike Fiore 1:71125aa00e33 180
Mike Fiore 1:71125aa00e33 181 return val;
Mike Fiore 1:71125aa00e33 182 }
Mike Fiore 1:71125aa00e33 183
Mike Fiore 1:71125aa00e33 184 void LoRaHandler::resetJoinAttempts() {
Mike Fiore 1:71125aa00e33 185 _mutex.lock();
Mike Fiore 1:71125aa00e33 186 _join_attempts = 1;
Mike Fiore 1:71125aa00e33 187 _mutex.unlock();
Mike Fiore 1:71125aa00e33 188 }
Mike Fiore 1:71125aa00e33 189
Mike Fiore 1:71125aa00e33 190 void LoRaHandler::blinker() {
Mike Fiore 1:71125aa00e33 191 _activity_led = !_activity_led;
Mike Fiore 1:71125aa00e33 192 }
Mike Fiore 1:71125aa00e33 193
Mike Fiore 1:71125aa00e33 194 void LoRaHandler::resetActivityLed() {
Mike Fiore 1:71125aa00e33 195 _activity_led = red;
Mike Fiore 1:71125aa00e33 196 }
Mike Fiore 1:71125aa00e33 197
Mike Fiore 7:a31236c2e75c 198