MTDOT-BOX-EVB-Factory-Firmware

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

Committer:
jenkins@jenkinsdm1
Date:
Tue Oct 09 13:49:30 2018 -0500
Revision:
12:05435282f899
Parent:
7:a31236c2e75c
dotbox-firmware revision 3.1.1

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 "ModeGps.h"
Mike Fiore 7:a31236c2e75c 20 #include "MTSLog.h"
Mike Fiore 7:a31236c2e75c 21 #include "rtos.h"
Mike Fiore 7:a31236c2e75c 22 #include "mbed.h"
Mike Fiore 7:a31236c2e75c 23 #include "limits.h"
Mike Fiore 7:a31236c2e75c 24 #define PACKETSIZE 11
Mike Fiore 7:a31236c2e75c 25
Mike Fiore 7:a31236c2e75c 26 ModeGps::ModeGps(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora, GPSPARSER* gps, SensorHandler* sensors, ModeJoin* join)
Mike Fiore 7:a31236c2e75c 27 : Mode(lcd, buttons, dot, lora, gps, sensors),
Mike Fiore 7:a31236c2e75c 28 _help(lcd),
Mike Fiore 7:a31236c2e75c 29 _sem(lcd, _band),
Mike Fiore 7:a31236c2e75c 30 _sem_join(lcd, _band),
Mike Fiore 7:a31236c2e75c 31 _join(join)
Mike Fiore 7:a31236c2e75c 32 {}
Mike Fiore 7:a31236c2e75c 33
Mike Fiore 7:a31236c2e75c 34 string ModeGps::intToString(int num){
jenkins@jenkinsdm1 12:05435282f899 35 char buf[4];
Mike Fiore 7:a31236c2e75c 36 snprintf(buf, sizeof(buf), "%d", num);
Mike Fiore 7:a31236c2e75c 37 return buf;
Mike Fiore 7:a31236c2e75c 38 }
Mike Fiore 7:a31236c2e75c 39
Mike Fiore 7:a31236c2e75c 40 void ModeGps::init(){
Mike Fiore 7:a31236c2e75c 41 //resets all parameters when re-entering mode
Mike Fiore 7:a31236c2e75c 42 _interval = 5;
Mike Fiore 7:a31236c2e75c 43 _padding = 0;
Mike Fiore 7:a31236c2e75c 44 _power = 20;
Mike Fiore 7:a31236c2e75c 45 _band = _dot->getFrequencyBand();
Mike Fiore 7:a31236c2e75c 46 _parameter = POWER;
Mike Fiore 7:a31236c2e75c 47 _drAll = false;
Mike Fiore 7:a31236c2e75c 48 _link_check = false;
Mike Fiore 7:a31236c2e75c 49 _GPS = false;
Mike Fiore 7:a31236c2e75c 50 _sub_band = _dot->getFrequencySubBand();
jenkins@jenkinsdm1 12:05435282f899 51 _data_rate = _dot->getMinDatarate();
jenkins@jenkinsdm1 12:05435282f899 52 _dot->setTxDataRate(_data_rate);
Mike Fiore 7:a31236c2e75c 53 _max_padding = _dot->getMaxPacketLength() - PACKETSIZE;
Mike Fiore 7:a31236c2e75c 54 _Sw2 = "Power";
Mike Fiore 7:a31236c2e75c 55 _Sw1 = intToString(_power);
Mike Fiore 7:a31236c2e75c 56 _help.display();
Mike Fiore 7:a31236c2e75c 57 osDelay(2000);
Mike Fiore 7:a31236c2e75c 58
jenkins@jenkinsdm1 12:05435282f899 59 if (lora::ChannelPlan::IsPlanDynamic(_band)) {
Mike Fiore 7:a31236c2e75c 60 _sem.display(_link_check, _snr, _rssi, _power, _sub_band, _padding, _data_rate);
Mike Fiore 7:a31236c2e75c 61 _sem.initial();
Mike Fiore 7:a31236c2e75c 62 _state = PARAMETERS;
Mike Fiore 7:a31236c2e75c 63 _send_timer.start();
Mike Fiore 7:a31236c2e75c 64 } else { _state = BAND_CHANGE;
Mike Fiore 7:a31236c2e75c 65 _sem_join.displayEditFsb(_data_rate, _power, _sub_band, _dot->getNetworkName(), _dot->getNetworkPassphrase());
Mike Fiore 7:a31236c2e75c 66 }
Mike Fiore 7:a31236c2e75c 67 }
Mike Fiore 7:a31236c2e75c 68
Mike Fiore 7:a31236c2e75c 69 void ModeGps::drIncrement(){
Mike Fiore 7:a31236c2e75c 70 _data_rate++;
jenkins@jenkinsdm1 12:05435282f899 71 //no fsk and japan data rates are different
jenkins@jenkinsdm1 12:05435282f899 72 if (_data_rate > _dot->getMaxDatarate() || _data_rate > mDot::DR6) {
Mike Fiore 7:a31236c2e75c 73 _drAll = true;
jenkins@jenkinsdm1 12:05435282f899 74 _data_rate = _dot->getMinDatarate();
Mike Fiore 7:a31236c2e75c 75 }
Mike Fiore 7:a31236c2e75c 76 _dot->setTxDataRate(_data_rate);
Mike Fiore 7:a31236c2e75c 77 logInfo("new data rate %s, POWER %lu", mDot::DataRateStr(_data_rate).c_str(), _power);
Mike Fiore 7:a31236c2e75c 78 _max_padding = _dot->getMaxPacketLength() - PACKETSIZE;
Mike Fiore 7:a31236c2e75c 79 }
Mike Fiore 7:a31236c2e75c 80
Mike Fiore 7:a31236c2e75c 81 void ModeGps::changeDataRate(){
Mike Fiore 7:a31236c2e75c 82 if(_drAll) {
jenkins@jenkinsdm1 12:05435282f899 83 _data_rate = _dot->getMinDatarate() - 1;
Mike Fiore 7:a31236c2e75c 84 _drAll = false;
Mike Fiore 7:a31236c2e75c 85 }
Mike Fiore 7:a31236c2e75c 86 drIncrement();
Mike Fiore 7:a31236c2e75c 87 }
Mike Fiore 7:a31236c2e75c 88
Mike Fiore 7:a31236c2e75c 89 void ModeGps::changeParameter(){
Mike Fiore 7:a31236c2e75c 90 _parameter++;
jenkins@jenkinsdm1 12:05435282f899 91 if(lora::ChannelPlan::IsPlanDynamic(_band) && _parameter == FSB){
Mike Fiore 7:a31236c2e75c 92 _parameter++;
Mike Fiore 7:a31236c2e75c 93 }
Mike Fiore 7:a31236c2e75c 94 if(_parameter>INTERVAL){
Mike Fiore 7:a31236c2e75c 95 _parameter = 0;
Mike Fiore 7:a31236c2e75c 96 }
Mike Fiore 7:a31236c2e75c 97 switch(_parameter) {
Mike Fiore 7:a31236c2e75c 98 case DATA_RATE:
Mike Fiore 7:a31236c2e75c 99 _Sw2 = "Data Rate";
Mike Fiore 7:a31236c2e75c 100 _Sw1 = intToString(_data_rate);
Mike Fiore 7:a31236c2e75c 101 if(_drAll){
Mike Fiore 7:a31236c2e75c 102 _Sw1 = "All";
Mike Fiore 7:a31236c2e75c 103 }
Mike Fiore 7:a31236c2e75c 104 break;
Mike Fiore 7:a31236c2e75c 105 case FSB:
Mike Fiore 7:a31236c2e75c 106 _Sw2 = "FSB";
Mike Fiore 7:a31236c2e75c 107 _Sw1 = intToString(_sub_band);
Mike Fiore 7:a31236c2e75c 108 break;
Mike Fiore 7:a31236c2e75c 109 case PADDING:
Mike Fiore 7:a31236c2e75c 110 _Sw2 = "Padding";
Mike Fiore 7:a31236c2e75c 111 _Sw1 = intToString(_padding);
Mike Fiore 7:a31236c2e75c 112 break;
Mike Fiore 7:a31236c2e75c 113 case POWER:
Mike Fiore 7:a31236c2e75c 114 _Sw2 = "Power";
Mike Fiore 7:a31236c2e75c 115 _Sw1 = intToString(_power);
Mike Fiore 7:a31236c2e75c 116 break;
Mike Fiore 7:a31236c2e75c 117 case INTERVAL:
Mike Fiore 7:a31236c2e75c 118 _Sw2 = "Interval";
Mike Fiore 7:a31236c2e75c 119 _Sw1 = intToString(_interval);
Mike Fiore 7:a31236c2e75c 120 break;
Mike Fiore 7:a31236c2e75c 121 default:
Mike Fiore 7:a31236c2e75c 122 break;
Mike Fiore 7:a31236c2e75c 123 }
Mike Fiore 7:a31236c2e75c 124 }
Mike Fiore 7:a31236c2e75c 125
Mike Fiore 7:a31236c2e75c 126 void ModeGps::editParameter(){
Mike Fiore 7:a31236c2e75c 127 switch(_parameter) {
Mike Fiore 7:a31236c2e75c 128 case POWER:
Mike Fiore 7:a31236c2e75c 129 if(_power<20){
Mike Fiore 7:a31236c2e75c 130 _power+=3;
Mike Fiore 7:a31236c2e75c 131 } else {
Mike Fiore 7:a31236c2e75c 132 _power = 2;
Mike Fiore 7:a31236c2e75c 133 }
Mike Fiore 7:a31236c2e75c 134 _Sw1 = intToString(_power);
Mike Fiore 7:a31236c2e75c 135 _dot->setTxPower(_power);
Mike Fiore 7:a31236c2e75c 136 break;
Mike Fiore 7:a31236c2e75c 137
Mike Fiore 7:a31236c2e75c 138 case DATA_RATE:
Mike Fiore 7:a31236c2e75c 139 changeDataRate();
Mike Fiore 7:a31236c2e75c 140 if(_drAll) {
Mike Fiore 7:a31236c2e75c 141 _Sw1="All";
Mike Fiore 7:a31236c2e75c 142 } else {
Mike Fiore 7:a31236c2e75c 143 _Sw1 = intToString(_data_rate);
Mike Fiore 7:a31236c2e75c 144 }
Mike Fiore 7:a31236c2e75c 145 break;
Mike Fiore 7:a31236c2e75c 146
Mike Fiore 7:a31236c2e75c 147 case FSB:
Mike Fiore 7:a31236c2e75c 148 _send_timer.stop();
Mike Fiore 7:a31236c2e75c 149 _send_timer.reset();
Mike Fiore 7:a31236c2e75c 150 _state = BAND_CHANGE;
Mike Fiore 7:a31236c2e75c 151 _dot->resetNetworkSession();
Mike Fiore 7:a31236c2e75c 152 _lora->resetActivityLed();
Mike Fiore 7:a31236c2e75c 153 _sem_join.displayEditFsb(mDot::DR0, 20, _sub_band, _dot->getNetworkName(), _dot->getNetworkPassphrase());
Mike Fiore 7:a31236c2e75c 154 break;
Mike Fiore 7:a31236c2e75c 155
Mike Fiore 7:a31236c2e75c 156 case PADDING:
Mike Fiore 7:a31236c2e75c 157 if(_padding<_max_padding){
Mike Fiore 7:a31236c2e75c 158 _padding += 10 - (_padding % 10);
Mike Fiore 7:a31236c2e75c 159 } else {
Mike Fiore 7:a31236c2e75c 160 _padding = 0;
Mike Fiore 7:a31236c2e75c 161 }
Mike Fiore 7:a31236c2e75c 162 if(_padding>_max_padding){
Mike Fiore 7:a31236c2e75c 163 _padding = _max_padding;
Mike Fiore 7:a31236c2e75c 164 }
Mike Fiore 7:a31236c2e75c 165 _Sw1 = intToString(_padding);
Mike Fiore 7:a31236c2e75c 166 break;
Mike Fiore 7:a31236c2e75c 167
Mike Fiore 7:a31236c2e75c 168 default:
Mike Fiore 7:a31236c2e75c 169 if(_interval<60){
Mike Fiore 7:a31236c2e75c 170 _interval += 5;
Mike Fiore 7:a31236c2e75c 171 } else {
Mike Fiore 7:a31236c2e75c 172 _interval = 5;
Mike Fiore 7:a31236c2e75c 173 }
Mike Fiore 7:a31236c2e75c 174 _Sw1 = intToString(_interval);
Mike Fiore 7:a31236c2e75c 175 break;
Mike Fiore 7:a31236c2e75c 176 }
Mike Fiore 7:a31236c2e75c 177 }
Mike Fiore 7:a31236c2e75c 178
Mike Fiore 7:a31236c2e75c 179 void ModeGps::formatData(){
Mike Fiore 7:a31236c2e75c 180 _send_data.clear();
Mike Fiore 7:a31236c2e75c 181 uint32_t lat = 0;
Mike Fiore 7:a31236c2e75c 182 uint32_t lng = 0;
Mike Fiore 7:a31236c2e75c 183 double degrees = 0;
Mike Fiore 7:a31236c2e75c 184 double minutes = 0;
Mike Fiore 7:a31236c2e75c 185 double seconds = 0;
Mike Fiore 7:a31236c2e75c 186 _temp_C += 0.5;
Mike Fiore 7:a31236c2e75c 187
Mike Fiore 7:a31236c2e75c 188 if(_GPS) {
Mike Fiore 7:a31236c2e75c 189 degrees = _latitude.degrees;
Mike Fiore 7:a31236c2e75c 190 minutes = _latitude.minutes;
Mike Fiore 7:a31236c2e75c 191 seconds = _latitude.seconds;
Mike Fiore 7:a31236c2e75c 192 if(degrees<0) {
Mike Fiore 7:a31236c2e75c 193 lat = ~(int)((degrees - minutes/60.0 - seconds/600000.0)*(-INT_MAX/90.0 + 1.5));
Mike Fiore 7:a31236c2e75c 194 } else {
Mike Fiore 7:a31236c2e75c 195 lat = (int)((degrees + minutes/60.0 + seconds/600000.0)*(INT_MAX/90.0 + 0.5));
Mike Fiore 7:a31236c2e75c 196 }
Mike Fiore 7:a31236c2e75c 197 degrees = _longitude.degrees;
Mike Fiore 7:a31236c2e75c 198 minutes = _longitude.minutes;
Mike Fiore 7:a31236c2e75c 199 seconds = _longitude.seconds;
Mike Fiore 7:a31236c2e75c 200 if(degrees<0) {
Mike Fiore 7:a31236c2e75c 201 lng = ~(int)((degrees - minutes/60.0 - seconds/600000.0)*(-INT_MAX/180.0 + 1.5));
Mike Fiore 7:a31236c2e75c 202 } else {
Mike Fiore 7:a31236c2e75c 203 lng = (int)((degrees + minutes/60.0 + seconds/600000.0)*(INT_MAX/180.0 + 0.5));
Mike Fiore 7:a31236c2e75c 204 }
Mike Fiore 7:a31236c2e75c 205 }
Mike Fiore 7:a31236c2e75c 206 _send_data.push_back(0);
Mike Fiore 7:a31236c2e75c 207 _send_data.push_back((int8_t) _temp_C);
Mike Fiore 7:a31236c2e75c 208 _send_data.push_back(0);
Mike Fiore 7:a31236c2e75c 209 for(int i=24; i>=0; i-=8){
Mike Fiore 7:a31236c2e75c 210 _send_data.push_back((lat>>i)&0xFF);
Mike Fiore 7:a31236c2e75c 211 }
Mike Fiore 7:a31236c2e75c 212 for(int i=24; i>=0; i-=8){
Mike Fiore 7:a31236c2e75c 213 _send_data.push_back((lng>>i)&0xFF);
Mike Fiore 7:a31236c2e75c 214 }
Mike Fiore 7:a31236c2e75c 215 for(int i=0; i<(_padding>_max_padding ? _max_padding:_padding); i++){
Mike Fiore 7:a31236c2e75c 216 _send_data.push_back(0);
Mike Fiore 7:a31236c2e75c 217 }
Mike Fiore 7:a31236c2e75c 218 }
Mike Fiore 7:a31236c2e75c 219
Mike Fiore 7:a31236c2e75c 220 void ModeGps::setBand(){
Mike Fiore 7:a31236c2e75c 221 _sub_band++;
Mike Fiore 7:a31236c2e75c 222 if(_sub_band > mDot::FSB_8) _sub_band = mDot::FSB_ALL;
Mike Fiore 7:a31236c2e75c 223 _dot->setFrequencySubBand(_sub_band);
Mike Fiore 7:a31236c2e75c 224 }
Mike Fiore 7:a31236c2e75c 225
Mike Fiore 7:a31236c2e75c 226 void ModeGps::updateScreen(){
Mike Fiore 7:a31236c2e75c 227 _temp_C = _sensors->getTemp(SensorHandler::CELSIUS);
Mike Fiore 7:a31236c2e75c 228 if(_gps->getLockStatus() && _gps_available) {
Mike Fiore 7:a31236c2e75c 229 _GPS = true;
Mike Fiore 7:a31236c2e75c 230 _latitude = _gps->getLatitude();
Mike Fiore 7:a31236c2e75c 231 _longitude = _gps->getLongitude();
Mike Fiore 7:a31236c2e75c 232 _time = _gps->getTimestamp();
Mike Fiore 7:a31236c2e75c 233 } else {
Mike Fiore 7:a31236c2e75c 234 _GPS = false;
Mike Fiore 7:a31236c2e75c 235 }
Mike Fiore 7:a31236c2e75c 236 _sem.updateStats( _GPS, _longitude, _latitude, _time, _temp_C);
Mike Fiore 7:a31236c2e75c 237 _sem.updateSw1(_Sw1, _Sw2);
Mike Fiore 7:a31236c2e75c 238 _sem.updateSw2(_Sw2);
Mike Fiore 7:a31236c2e75c 239 }
Mike Fiore 7:a31236c2e75c 240
Mike Fiore 7:a31236c2e75c 241 void ModeGps::send(){
Mike Fiore 7:a31236c2e75c 242 _state = SENDING;
Mike Fiore 7:a31236c2e75c 243 _send_timer.stop();
jenkins@jenkinsdm1 12:05435282f899 244 while(_dot->getNextTxMs()>0) {
jenkins@jenkinsdm1 12:05435282f899 245 _sem.updateNextCh((int)(_dot->getNextTxMs()/1000));
jenkins@jenkinsdm1 12:05435282f899 246 osDelay(250);
jenkins@jenkinsdm1 12:05435282f899 247 }
Mike Fiore 7:a31236c2e75c 248 formatData();
Mike Fiore 7:a31236c2e75c 249 _sem.sending();
Mike Fiore 7:a31236c2e75c 250 _send_timer.reset();
Mike Fiore 7:a31236c2e75c 251 _send_timer.start();
Mike Fiore 7:a31236c2e75c 252 _lora->send(_send_data);
Mike Fiore 7:a31236c2e75c 253 osDelay(500);
Mike Fiore 7:a31236c2e75c 254 }
Mike Fiore 7:a31236c2e75c 255
Mike Fiore 7:a31236c2e75c 256 bool ModeGps::start(){
Mike Fiore 7:a31236c2e75c 257 init();
Mike Fiore 7:a31236c2e75c 258 _button_timer.start();
Mike Fiore 7:a31236c2e75c 259 ButtonHandler::ButtonEvent be;
jenkins@jenkinsdm1 12:05435282f899 260 uint32_t e;
Mike Fiore 7:a31236c2e75c 261 while (true) {
Mike Fiore 7:a31236c2e75c 262 if(_state==PARAMETERS){
Mike Fiore 7:a31236c2e75c 263 updateScreen();
Mike Fiore 7:a31236c2e75c 264 }
jenkins@jenkinsdm1 12:05435282f899 265 e = osThreadFlagsWait(loraSignal | buttonSignal, osFlagsWaitAny, 250);
jenkins@jenkinsdm1 12:05435282f899 266 if (e == buttonSignal) {
jenkins@jenkinsdm1 12:05435282f899 267 be = _buttons->getButtonEvent();
Mike Fiore 7:a31236c2e75c 268
jenkins@jenkinsdm1 12:05435282f899 269 switch(be) {
jenkins@jenkinsdm1 12:05435282f899 270 case ButtonHandler::sw1_press:
jenkins@jenkinsdm1 12:05435282f899 271 switch(_state) {
jenkins@jenkinsdm1 12:05435282f899 272 case BAND_CHANGE:
Mike Fiore 7:a31236c2e75c 273 setBand();
Mike Fiore 7:a31236c2e75c 274 _sem_join.updateJoinFsb(_sub_band);
Mike Fiore 7:a31236c2e75c 275 break;
Mike Fiore 7:a31236c2e75c 276
Mike Fiore 7:a31236c2e75c 277 case PARAMETERS:
Mike Fiore 7:a31236c2e75c 278 editParameter();
Mike Fiore 7:a31236c2e75c 279 break;
Mike Fiore 7:a31236c2e75c 280
Mike Fiore 7:a31236c2e75c 281 default:
Mike Fiore 7:a31236c2e75c 282 break;
Mike Fiore 7:a31236c2e75c 283 }
Mike Fiore 7:a31236c2e75c 284 break;
Mike Fiore 7:a31236c2e75c 285 case ButtonHandler::sw2_press:
Mike Fiore 7:a31236c2e75c 286 switch(_state) {
Mike Fiore 7:a31236c2e75c 287 case BAND_CHANGE:
Mike Fiore 7:a31236c2e75c 288 if(_join->start()){
Mike Fiore 7:a31236c2e75c 289 _state = PARAMETERS;
Mike Fiore 7:a31236c2e75c 290 _send_timer.start();
Mike Fiore 7:a31236c2e75c 291 _sem.display(_link_check, _snr, _rssi, _power, _sub_band, _padding, DATA_RATE);
Mike Fiore 7:a31236c2e75c 292 _sem.initial();
Mike Fiore 7:a31236c2e75c 293 _dot->setTxDataRate(_data_rate);
Mike Fiore 7:a31236c2e75c 294 } else _sem_join.displayEditFsb(mDot::DR0, 20, _sub_band, _dot->getNetworkName(), _dot->getNetworkPassphrase());
Mike Fiore 7:a31236c2e75c 295 break;
Mike Fiore 7:a31236c2e75c 296
Mike Fiore 7:a31236c2e75c 297 case PARAMETERS:
Mike Fiore 7:a31236c2e75c 298 changeParameter();
Mike Fiore 7:a31236c2e75c 299 break;
Mike Fiore 7:a31236c2e75c 300
Mike Fiore 7:a31236c2e75c 301 default:
Mike Fiore 7:a31236c2e75c 302 break;
Mike Fiore 7:a31236c2e75c 303 }
Mike Fiore 7:a31236c2e75c 304 break;
Mike Fiore 7:a31236c2e75c 305
Mike Fiore 7:a31236c2e75c 306 case ButtonHandler::sw1_hold:
Mike Fiore 7:a31236c2e75c 307 _send_timer.stop();
Mike Fiore 7:a31236c2e75c 308 _send_timer.reset();
Mike Fiore 7:a31236c2e75c 309 return true;
Mike Fiore 7:a31236c2e75c 310
Mike Fiore 7:a31236c2e75c 311 default:
Mike Fiore 7:a31236c2e75c 312 break;
Mike Fiore 7:a31236c2e75c 313 }
Mike Fiore 7:a31236c2e75c 314 }
jenkins@jenkinsdm1 12:05435282f899 315 if (e == loraSignal) {
Mike Fiore 7:a31236c2e75c 316 _ls = _lora->getStatus();
Mike Fiore 7:a31236c2e75c 317 switch (_ls) {
Mike Fiore 7:a31236c2e75c 318
Mike Fiore 7:a31236c2e75c 319 case LoRaHandler::send_success:
Mike Fiore 7:a31236c2e75c 320 _sem.sendResult(" Send Sucess!");
Mike Fiore 7:a31236c2e75c 321 osDelay(500);
Mike Fiore 7:a31236c2e75c 322 _link_check = true;
Mike Fiore 7:a31236c2e75c 323 _snr = _dot->getSnrStats();
Mike Fiore 7:a31236c2e75c 324 _rssi = _dot->getRssiStats();
Mike Fiore 7:a31236c2e75c 325 _button_timer.reset();
Mike Fiore 7:a31236c2e75c 326 _state = PARAMETERS;
Mike Fiore 7:a31236c2e75c 327 _sem.display(_link_check, _snr, _rssi, _power, _sub_band, _padding, _data_rate);
Mike Fiore 7:a31236c2e75c 328 if(_drAll){
Mike Fiore 7:a31236c2e75c 329 drIncrement();
Mike Fiore 7:a31236c2e75c 330 }
Mike Fiore 7:a31236c2e75c 331 break;
Mike Fiore 7:a31236c2e75c 332
Mike Fiore 7:a31236c2e75c 333 case LoRaHandler::send_failure:
Mike Fiore 7:a31236c2e75c 334 _sem.sendResult(" Send Failed.");
Mike Fiore 7:a31236c2e75c 335 osDelay(500);
Mike Fiore 7:a31236c2e75c 336 _link_check = false;
Mike Fiore 7:a31236c2e75c 337 _button_timer.reset();
Mike Fiore 7:a31236c2e75c 338 _state = PARAMETERS;
Mike Fiore 7:a31236c2e75c 339 _sem.display(_link_check, _snr, _rssi, _power, _sub_band, _padding, _data_rate);
Mike Fiore 7:a31236c2e75c 340 if(_drAll){
Mike Fiore 7:a31236c2e75c 341 drIncrement();
Mike Fiore 7:a31236c2e75c 342 }
Mike Fiore 7:a31236c2e75c 343 break;
jenkins@jenkinsdm1 12:05435282f899 344
jenkins@jenkinsdm1 12:05435282f899 345 case LoRaHandler::send_failure_payload:
jenkins@jenkinsdm1 12:05435282f899 346 _sem.sendResult("Payload too large");
jenkins@jenkinsdm1 12:05435282f899 347 osDelay(1000);
jenkins@jenkinsdm1 12:05435282f899 348 _sem.sendResult("Change Datarate");
jenkins@jenkinsdm1 12:05435282f899 349 osDelay(1000);
jenkins@jenkinsdm1 12:05435282f899 350 _link_check = false;
jenkins@jenkinsdm1 12:05435282f899 351 _button_timer.reset();
jenkins@jenkinsdm1 12:05435282f899 352 _state = PARAMETERS;
jenkins@jenkinsdm1 12:05435282f899 353 _sem.display(_link_check, _snr, _rssi, _power, _sub_band, _padding, _data_rate);
jenkins@jenkinsdm1 12:05435282f899 354 if(_drAll){
jenkins@jenkinsdm1 12:05435282f899 355 drIncrement();
jenkins@jenkinsdm1 12:05435282f899 356 }
jenkins@jenkinsdm1 12:05435282f899 357 break;
jenkins@jenkinsdm1 12:05435282f899 358
Mike Fiore 7:a31236c2e75c 359 default:
Mike Fiore 7:a31236c2e75c 360 break;
Mike Fiore 7:a31236c2e75c 361 }
Mike Fiore 7:a31236c2e75c 362 }
Mike Fiore 7:a31236c2e75c 363 if(_send_timer.read_ms() > _interval*1000 && _button_timer.read_ms() > 3000){
Mike Fiore 7:a31236c2e75c 364 send();
Mike Fiore 7:a31236c2e75c 365 }
Mike Fiore 7:a31236c2e75c 366 }
Mike Fiore 7:a31236c2e75c 367 }