MTDOT-BOX-EVB-Factory-Firmware

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

Committer:
Mike Fiore
Date:
Fri Nov 04 17:27:05 2016 -0500
Revision:
7:a31236c2e75c
Child:
12:05435282f899
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 "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){
Mike Fiore 7:a31236c2e75c 35 char buf[3];
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();
Mike Fiore 7:a31236c2e75c 51 _data_rate = mDot::DR0;
Mike Fiore 7:a31236c2e75c 52 _max_padding = _dot->getMaxPacketLength() - PACKETSIZE;
Mike Fiore 7:a31236c2e75c 53 _Sw2 = "Power";
Mike Fiore 7:a31236c2e75c 54 _Sw1 = intToString(_power);
Mike Fiore 7:a31236c2e75c 55 _help.display();
Mike Fiore 7:a31236c2e75c 56 osDelay(2000);
Mike Fiore 7:a31236c2e75c 57
Mike Fiore 7:a31236c2e75c 58 if(_band == mDot::FB_EU868){
Mike Fiore 7:a31236c2e75c 59 _sem.display(_link_check, _snr, _rssi, _power, _sub_band, _padding, _data_rate);
Mike Fiore 7:a31236c2e75c 60 _sem.initial();
Mike Fiore 7:a31236c2e75c 61 _state = PARAMETERS;
Mike Fiore 7:a31236c2e75c 62 _send_timer.start();
Mike Fiore 7:a31236c2e75c 63 } else { _state = BAND_CHANGE;
Mike Fiore 7:a31236c2e75c 64 _sem_join.displayEditFsb(_data_rate, _power, _sub_band, _dot->getNetworkName(), _dot->getNetworkPassphrase());
Mike Fiore 7:a31236c2e75c 65 }
Mike Fiore 7:a31236c2e75c 66 }
Mike Fiore 7:a31236c2e75c 67
Mike Fiore 7:a31236c2e75c 68 void ModeGps::drIncrement(){
Mike Fiore 7:a31236c2e75c 69 _data_rate++;
Mike Fiore 7:a31236c2e75c 70 if ((_data_rate > mDot::DR4 && (_band == mDot::FB_US915 || _band == mDot::FB_AU915)) || _data_rate > mDot::DR6) {
Mike Fiore 7:a31236c2e75c 71 _drAll = true;
Mike Fiore 7:a31236c2e75c 72 _data_rate = 0;
Mike Fiore 7:a31236c2e75c 73 }
Mike Fiore 7:a31236c2e75c 74 _dot->setTxDataRate(_data_rate);
Mike Fiore 7:a31236c2e75c 75 logInfo("new data rate %s, POWER %lu", mDot::DataRateStr(_data_rate).c_str(), _power);
Mike Fiore 7:a31236c2e75c 76 _max_padding = _dot->getMaxPacketLength() - PACKETSIZE;
Mike Fiore 7:a31236c2e75c 77 }
Mike Fiore 7:a31236c2e75c 78
Mike Fiore 7:a31236c2e75c 79 void ModeGps::changeDataRate(){
Mike Fiore 7:a31236c2e75c 80 if(_drAll) {
Mike Fiore 7:a31236c2e75c 81 _data_rate = -1;
Mike Fiore 7:a31236c2e75c 82 _drAll = false;
Mike Fiore 7:a31236c2e75c 83 }
Mike Fiore 7:a31236c2e75c 84 drIncrement();
Mike Fiore 7:a31236c2e75c 85 }
Mike Fiore 7:a31236c2e75c 86
Mike Fiore 7:a31236c2e75c 87 void ModeGps::changeParameter(){
Mike Fiore 7:a31236c2e75c 88 _parameter++;
Mike Fiore 7:a31236c2e75c 89 if(_band == mDot::FB_EU868 && _parameter == FSB){
Mike Fiore 7:a31236c2e75c 90 _parameter++;
Mike Fiore 7:a31236c2e75c 91 }
Mike Fiore 7:a31236c2e75c 92 if(_parameter>INTERVAL){
Mike Fiore 7:a31236c2e75c 93 _parameter = 0;
Mike Fiore 7:a31236c2e75c 94 }
Mike Fiore 7:a31236c2e75c 95 switch(_parameter) {
Mike Fiore 7:a31236c2e75c 96 case DATA_RATE:
Mike Fiore 7:a31236c2e75c 97 _Sw2 = "Data Rate";
Mike Fiore 7:a31236c2e75c 98 _Sw1 = intToString(_data_rate);
Mike Fiore 7:a31236c2e75c 99 if(_drAll){
Mike Fiore 7:a31236c2e75c 100 _Sw1 = "All";
Mike Fiore 7:a31236c2e75c 101 }
Mike Fiore 7:a31236c2e75c 102 break;
Mike Fiore 7:a31236c2e75c 103 case FSB:
Mike Fiore 7:a31236c2e75c 104 _Sw2 = "FSB";
Mike Fiore 7:a31236c2e75c 105 _Sw1 = intToString(_sub_band);
Mike Fiore 7:a31236c2e75c 106 break;
Mike Fiore 7:a31236c2e75c 107 case PADDING:
Mike Fiore 7:a31236c2e75c 108 _Sw2 = "Padding";
Mike Fiore 7:a31236c2e75c 109 _Sw1 = intToString(_padding);
Mike Fiore 7:a31236c2e75c 110 break;
Mike Fiore 7:a31236c2e75c 111 case POWER:
Mike Fiore 7:a31236c2e75c 112 _Sw2 = "Power";
Mike Fiore 7:a31236c2e75c 113 _Sw1 = intToString(_power);
Mike Fiore 7:a31236c2e75c 114 break;
Mike Fiore 7:a31236c2e75c 115 case INTERVAL:
Mike Fiore 7:a31236c2e75c 116 _Sw2 = "Interval";
Mike Fiore 7:a31236c2e75c 117 _Sw1 = intToString(_interval);
Mike Fiore 7:a31236c2e75c 118 break;
Mike Fiore 7:a31236c2e75c 119 default:
Mike Fiore 7:a31236c2e75c 120 break;
Mike Fiore 7:a31236c2e75c 121 }
Mike Fiore 7:a31236c2e75c 122 }
Mike Fiore 7:a31236c2e75c 123
Mike Fiore 7:a31236c2e75c 124 void ModeGps::editParameter(){
Mike Fiore 7:a31236c2e75c 125 switch(_parameter) {
Mike Fiore 7:a31236c2e75c 126 case POWER:
Mike Fiore 7:a31236c2e75c 127 if(_power<20){
Mike Fiore 7:a31236c2e75c 128 _power+=3;
Mike Fiore 7:a31236c2e75c 129 } else {
Mike Fiore 7:a31236c2e75c 130 _power = 2;
Mike Fiore 7:a31236c2e75c 131 }
Mike Fiore 7:a31236c2e75c 132 _Sw1 = intToString(_power);
Mike Fiore 7:a31236c2e75c 133 _dot->setTxPower(_power);
Mike Fiore 7:a31236c2e75c 134 break;
Mike Fiore 7:a31236c2e75c 135
Mike Fiore 7:a31236c2e75c 136 case DATA_RATE:
Mike Fiore 7:a31236c2e75c 137 changeDataRate();
Mike Fiore 7:a31236c2e75c 138 if(_drAll) {
Mike Fiore 7:a31236c2e75c 139 _Sw1="All";
Mike Fiore 7:a31236c2e75c 140 } else {
Mike Fiore 7:a31236c2e75c 141 _Sw1 = intToString(_data_rate);
Mike Fiore 7:a31236c2e75c 142 }
Mike Fiore 7:a31236c2e75c 143 break;
Mike Fiore 7:a31236c2e75c 144
Mike Fiore 7:a31236c2e75c 145 case FSB:
Mike Fiore 7:a31236c2e75c 146 _send_timer.stop();
Mike Fiore 7:a31236c2e75c 147 _send_timer.reset();
Mike Fiore 7:a31236c2e75c 148 _state = BAND_CHANGE;
Mike Fiore 7:a31236c2e75c 149 _dot->resetNetworkSession();
Mike Fiore 7:a31236c2e75c 150 _lora->resetActivityLed();
Mike Fiore 7:a31236c2e75c 151 _sem_join.displayEditFsb(mDot::DR0, 20, _sub_band, _dot->getNetworkName(), _dot->getNetworkPassphrase());
Mike Fiore 7:a31236c2e75c 152 break;
Mike Fiore 7:a31236c2e75c 153
Mike Fiore 7:a31236c2e75c 154 case PADDING:
Mike Fiore 7:a31236c2e75c 155 if(_padding<_max_padding){
Mike Fiore 7:a31236c2e75c 156 _padding += 10 - (_padding % 10);
Mike Fiore 7:a31236c2e75c 157 } else {
Mike Fiore 7:a31236c2e75c 158 _padding = 0;
Mike Fiore 7:a31236c2e75c 159 }
Mike Fiore 7:a31236c2e75c 160 if(_padding>_max_padding){
Mike Fiore 7:a31236c2e75c 161 _padding = _max_padding;
Mike Fiore 7:a31236c2e75c 162 }
Mike Fiore 7:a31236c2e75c 163 _Sw1 = intToString(_padding);
Mike Fiore 7:a31236c2e75c 164 break;
Mike Fiore 7:a31236c2e75c 165
Mike Fiore 7:a31236c2e75c 166 default:
Mike Fiore 7:a31236c2e75c 167 if(_interval<60){
Mike Fiore 7:a31236c2e75c 168 _interval += 5;
Mike Fiore 7:a31236c2e75c 169 } else {
Mike Fiore 7:a31236c2e75c 170 _interval = 5;
Mike Fiore 7:a31236c2e75c 171 }
Mike Fiore 7:a31236c2e75c 172 _Sw1 = intToString(_interval);
Mike Fiore 7:a31236c2e75c 173 break;
Mike Fiore 7:a31236c2e75c 174 }
Mike Fiore 7:a31236c2e75c 175 }
Mike Fiore 7:a31236c2e75c 176
Mike Fiore 7:a31236c2e75c 177 void ModeGps::formatData(){
Mike Fiore 7:a31236c2e75c 178 _send_data.clear();
Mike Fiore 7:a31236c2e75c 179 uint32_t lat = 0;
Mike Fiore 7:a31236c2e75c 180 uint32_t lng = 0;
Mike Fiore 7:a31236c2e75c 181 double degrees = 0;
Mike Fiore 7:a31236c2e75c 182 double minutes = 0;
Mike Fiore 7:a31236c2e75c 183 double seconds = 0;
Mike Fiore 7:a31236c2e75c 184 _temp_C += 0.5;
Mike Fiore 7:a31236c2e75c 185
Mike Fiore 7:a31236c2e75c 186 if(_GPS) {
Mike Fiore 7:a31236c2e75c 187 degrees = _latitude.degrees;
Mike Fiore 7:a31236c2e75c 188 minutes = _latitude.minutes;
Mike Fiore 7:a31236c2e75c 189 seconds = _latitude.seconds;
Mike Fiore 7:a31236c2e75c 190 if(degrees<0) {
Mike Fiore 7:a31236c2e75c 191 lat = ~(int)((degrees - minutes/60.0 - seconds/600000.0)*(-INT_MAX/90.0 + 1.5));
Mike Fiore 7:a31236c2e75c 192 } else {
Mike Fiore 7:a31236c2e75c 193 lat = (int)((degrees + minutes/60.0 + seconds/600000.0)*(INT_MAX/90.0 + 0.5));
Mike Fiore 7:a31236c2e75c 194 }
Mike Fiore 7:a31236c2e75c 195 degrees = _longitude.degrees;
Mike Fiore 7:a31236c2e75c 196 minutes = _longitude.minutes;
Mike Fiore 7:a31236c2e75c 197 seconds = _longitude.seconds;
Mike Fiore 7:a31236c2e75c 198 if(degrees<0) {
Mike Fiore 7:a31236c2e75c 199 lng = ~(int)((degrees - minutes/60.0 - seconds/600000.0)*(-INT_MAX/180.0 + 1.5));
Mike Fiore 7:a31236c2e75c 200 } else {
Mike Fiore 7:a31236c2e75c 201 lng = (int)((degrees + minutes/60.0 + seconds/600000.0)*(INT_MAX/180.0 + 0.5));
Mike Fiore 7:a31236c2e75c 202 }
Mike Fiore 7:a31236c2e75c 203 }
Mike Fiore 7:a31236c2e75c 204 _send_data.push_back(0);
Mike Fiore 7:a31236c2e75c 205 _send_data.push_back((int8_t) _temp_C);
Mike Fiore 7:a31236c2e75c 206 _send_data.push_back(0);
Mike Fiore 7:a31236c2e75c 207 for(int i=24; i>=0; i-=8){
Mike Fiore 7:a31236c2e75c 208 _send_data.push_back((lat>>i)&0xFF);
Mike Fiore 7:a31236c2e75c 209 }
Mike Fiore 7:a31236c2e75c 210 for(int i=24; i>=0; i-=8){
Mike Fiore 7:a31236c2e75c 211 _send_data.push_back((lng>>i)&0xFF);
Mike Fiore 7:a31236c2e75c 212 }
Mike Fiore 7:a31236c2e75c 213 for(int i=0; i<(_padding>_max_padding ? _max_padding:_padding); i++){
Mike Fiore 7:a31236c2e75c 214 _send_data.push_back(0);
Mike Fiore 7:a31236c2e75c 215 }
Mike Fiore 7:a31236c2e75c 216 }
Mike Fiore 7:a31236c2e75c 217
Mike Fiore 7:a31236c2e75c 218 void ModeGps::setBand(){
Mike Fiore 7:a31236c2e75c 219 _sub_band++;
Mike Fiore 7:a31236c2e75c 220 if(_sub_band > mDot::FSB_8) _sub_band = mDot::FSB_ALL;
Mike Fiore 7:a31236c2e75c 221 _dot->setFrequencySubBand(_sub_band);
Mike Fiore 7:a31236c2e75c 222 }
Mike Fiore 7:a31236c2e75c 223
Mike Fiore 7:a31236c2e75c 224 void ModeGps::updateScreen(){
Mike Fiore 7:a31236c2e75c 225 _temp_C = _sensors->getTemp(SensorHandler::CELSIUS);
Mike Fiore 7:a31236c2e75c 226 if(_gps->getLockStatus() && _gps_available) {
Mike Fiore 7:a31236c2e75c 227 _GPS = true;
Mike Fiore 7:a31236c2e75c 228 _latitude = _gps->getLatitude();
Mike Fiore 7:a31236c2e75c 229 _longitude = _gps->getLongitude();
Mike Fiore 7:a31236c2e75c 230 _time = _gps->getTimestamp();
Mike Fiore 7:a31236c2e75c 231 } else {
Mike Fiore 7:a31236c2e75c 232 _GPS = false;
Mike Fiore 7:a31236c2e75c 233 }
Mike Fiore 7:a31236c2e75c 234 _sem.updateStats( _GPS, _longitude, _latitude, _time, _temp_C);
Mike Fiore 7:a31236c2e75c 235 _sem.updateSw1(_Sw1, _Sw2);
Mike Fiore 7:a31236c2e75c 236 _sem.updateSw2(_Sw2);
Mike Fiore 7:a31236c2e75c 237 }
Mike Fiore 7:a31236c2e75c 238
Mike Fiore 7:a31236c2e75c 239 void ModeGps::send(){
Mike Fiore 7:a31236c2e75c 240 _state = SENDING;
Mike Fiore 7:a31236c2e75c 241 _send_timer.stop();
Mike Fiore 7:a31236c2e75c 242 if(_band == mDot::FB_EU868) {
Mike Fiore 7:a31236c2e75c 243 while(_dot->getNextTxMs()>0) {
Mike Fiore 7:a31236c2e75c 244 _sem.updateNextCh((int)(_dot->getNextTxMs()/1000));
Mike Fiore 7:a31236c2e75c 245 osDelay(250);
Mike Fiore 7:a31236c2e75c 246 }
Mike Fiore 7:a31236c2e75c 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;
Mike Fiore 7:a31236c2e75c 260 osSignalClear(_main_id, buttonSignal | loraSignal);
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 }
Mike Fiore 7:a31236c2e75c 265 osEvent e = Thread::signal_wait(0, 250);
Mike Fiore 7:a31236c2e75c 266 if (e.status == osEventSignal) {
Mike Fiore 7:a31236c2e75c 267 if (e.value.signals & buttonSignal) {
Mike Fiore 7:a31236c2e75c 268 _button_timer.reset();
Mike Fiore 7:a31236c2e75c 269 be = _buttons->getButtonEvent();
Mike Fiore 7:a31236c2e75c 270
Mike Fiore 7:a31236c2e75c 271 switch(be) {
Mike Fiore 7:a31236c2e75c 272 case ButtonHandler::sw1_press:
Mike Fiore 7:a31236c2e75c 273 switch(_state) {
Mike Fiore 7:a31236c2e75c 274 case BAND_CHANGE:
Mike Fiore 7:a31236c2e75c 275 setBand();
Mike Fiore 7:a31236c2e75c 276 _sem_join.updateJoinFsb(_sub_band);
Mike Fiore 7:a31236c2e75c 277 break;
Mike Fiore 7:a31236c2e75c 278
Mike Fiore 7:a31236c2e75c 279 case PARAMETERS:
Mike Fiore 7:a31236c2e75c 280 editParameter();
Mike Fiore 7:a31236c2e75c 281 break;
Mike Fiore 7:a31236c2e75c 282
Mike Fiore 7:a31236c2e75c 283 default:
Mike Fiore 7:a31236c2e75c 284 break;
Mike Fiore 7:a31236c2e75c 285 }
Mike Fiore 7:a31236c2e75c 286 break;
Mike Fiore 7:a31236c2e75c 287 case ButtonHandler::sw2_press:
Mike Fiore 7:a31236c2e75c 288 switch(_state) {
Mike Fiore 7:a31236c2e75c 289 case BAND_CHANGE:
Mike Fiore 7:a31236c2e75c 290 if(_join->start()){
Mike Fiore 7:a31236c2e75c 291 _state = PARAMETERS;
Mike Fiore 7:a31236c2e75c 292 _send_timer.start();
Mike Fiore 7:a31236c2e75c 293 _sem.display(_link_check, _snr, _rssi, _power, _sub_band, _padding, DATA_RATE);
Mike Fiore 7:a31236c2e75c 294 _sem.initial();
Mike Fiore 7:a31236c2e75c 295 _dot->setTxDataRate(_data_rate);
Mike Fiore 7:a31236c2e75c 296 } else _sem_join.displayEditFsb(mDot::DR0, 20, _sub_band, _dot->getNetworkName(), _dot->getNetworkPassphrase());
Mike Fiore 7:a31236c2e75c 297 break;
Mike Fiore 7:a31236c2e75c 298
Mike Fiore 7:a31236c2e75c 299 case PARAMETERS:
Mike Fiore 7:a31236c2e75c 300 changeParameter();
Mike Fiore 7:a31236c2e75c 301 break;
Mike Fiore 7:a31236c2e75c 302
Mike Fiore 7:a31236c2e75c 303 default:
Mike Fiore 7:a31236c2e75c 304 break;
Mike Fiore 7:a31236c2e75c 305 }
Mike Fiore 7:a31236c2e75c 306 break;
Mike Fiore 7:a31236c2e75c 307
Mike Fiore 7:a31236c2e75c 308 case ButtonHandler::sw1_hold:
Mike Fiore 7:a31236c2e75c 309 _send_timer.stop();
Mike Fiore 7:a31236c2e75c 310 _send_timer.reset();
Mike Fiore 7:a31236c2e75c 311 return true;
Mike Fiore 7:a31236c2e75c 312
Mike Fiore 7:a31236c2e75c 313 default:
Mike Fiore 7:a31236c2e75c 314 break;
Mike Fiore 7:a31236c2e75c 315 }
Mike Fiore 7:a31236c2e75c 316 }
Mike Fiore 7:a31236c2e75c 317 }
Mike Fiore 7:a31236c2e75c 318 if (e.value.signals & loraSignal) {
Mike Fiore 7:a31236c2e75c 319 _ls = _lora->getStatus();
Mike Fiore 7:a31236c2e75c 320 switch (_ls) {
Mike Fiore 7:a31236c2e75c 321
Mike Fiore 7:a31236c2e75c 322 case LoRaHandler::send_success:
Mike Fiore 7:a31236c2e75c 323 _sem.sendResult(" Send Sucess!");
Mike Fiore 7:a31236c2e75c 324 osDelay(500);
Mike Fiore 7:a31236c2e75c 325 _link_check = true;
Mike Fiore 7:a31236c2e75c 326 _snr = _dot->getSnrStats();
Mike Fiore 7:a31236c2e75c 327 _rssi = _dot->getRssiStats();
Mike Fiore 7:a31236c2e75c 328 _button_timer.reset();
Mike Fiore 7:a31236c2e75c 329 _state = PARAMETERS;
Mike Fiore 7:a31236c2e75c 330 _sem.display(_link_check, _snr, _rssi, _power, _sub_band, _padding, _data_rate);
Mike Fiore 7:a31236c2e75c 331 if(_drAll){
Mike Fiore 7:a31236c2e75c 332 drIncrement();
Mike Fiore 7:a31236c2e75c 333 }
Mike Fiore 7:a31236c2e75c 334 break;
Mike Fiore 7:a31236c2e75c 335
Mike Fiore 7:a31236c2e75c 336 case LoRaHandler::send_failure:
Mike Fiore 7:a31236c2e75c 337 _sem.sendResult(" Send Failed.");
Mike Fiore 7:a31236c2e75c 338 osDelay(500);
Mike Fiore 7:a31236c2e75c 339 _link_check = false;
Mike Fiore 7:a31236c2e75c 340 _button_timer.reset();
Mike Fiore 7:a31236c2e75c 341 _state = PARAMETERS;
Mike Fiore 7:a31236c2e75c 342 _sem.display(_link_check, _snr, _rssi, _power, _sub_band, _padding, _data_rate);
Mike Fiore 7:a31236c2e75c 343 if(_drAll){
Mike Fiore 7:a31236c2e75c 344 drIncrement();
Mike Fiore 7:a31236c2e75c 345 }
Mike Fiore 7:a31236c2e75c 346 break;
Mike Fiore 7:a31236c2e75c 347
Mike Fiore 7:a31236c2e75c 348 default:
Mike Fiore 7:a31236c2e75c 349 break;
Mike Fiore 7:a31236c2e75c 350 }
Mike Fiore 7:a31236c2e75c 351 }
Mike Fiore 7:a31236c2e75c 352 if(_send_timer.read_ms() > _interval*1000 && _button_timer.read_ms() > 3000){
Mike Fiore 7:a31236c2e75c 353 send();
Mike Fiore 7:a31236c2e75c 354 }
Mike Fiore 7:a31236c2e75c 355 }
Mike Fiore 7:a31236c2e75c 356 }