lmic fixups

This commit is contained in:
Verkehrsrot 2019-03-23 11:01:49 +01:00
parent 11af4e1f14
commit ab5525d565
2 changed files with 38 additions and 26 deletions

View File

@ -19,7 +19,7 @@
// LMIC LORAWAN STACK SETTINGS // LMIC LORAWAN STACK SETTINGS
// --> adapt to your device only if necessary // --> adapt to your device only if necessary
//#define LMIC_USE_INTERRUPTS //#define LMIC_USE_INTERRUPTS 1
//time sync via LoRaWAN network, is not yet supported by TTN (LoRaWAN spec v1.0.3) //time sync via LoRaWAN network, is not yet supported by TTN (LoRaWAN spec v1.0.3)
#define LMIC_ENABLE_DeviceTimeReq 1 #define LMIC_ENABLE_DeviceTimeReq 1

View File

@ -182,19 +182,19 @@ void onEvent(ev_t ev) {
switch (ev) { switch (ev) {
case EV_SCAN_TIMEOUT: case EV_SCAN_TIMEOUT:
strcpy_P(buff, PSTR("SCAN_TIMEOUT")); strcpy_P(buff, PSTR("SCAN TIMEOUT"));
break; break;
case EV_BEACON_FOUND: case EV_BEACON_FOUND:
strcpy_P(buff, PSTR("BEACON_FOUND")); strcpy_P(buff, PSTR("BEACON FOUND"));
break; break;
case EV_BEACON_MISSED: case EV_BEACON_MISSED:
strcpy_P(buff, PSTR("BEACON_MISSED")); strcpy_P(buff, PSTR("BEACON MISSED"));
break; break;
case EV_BEACON_TRACKED: case EV_BEACON_TRACKED:
strcpy_P(buff, PSTR("BEACON_TRACKED")); strcpy_P(buff, PSTR("BEACON TRACKED"));
break; break;
case EV_JOINING: case EV_JOINING:
@ -219,12 +219,16 @@ void onEvent(ev_t ev) {
cfg.txpower); cfg.txpower);
break; break;
case EV_RFU1:
strcpy_P(buff, PSTR("RFU1"));
break;
case EV_JOIN_FAILED: case EV_JOIN_FAILED:
strcpy_P(buff, PSTR("JOIN_FAILED")); strcpy_P(buff, PSTR("JOIN FAILED"));
break; break;
case EV_REJOIN_FAILED: case EV_REJOIN_FAILED:
strcpy_P(buff, PSTR("REJOIN_FAILED")); strcpy_P(buff, PSTR("REJOIN FAILED"));
break; break;
case EV_TXCOMPLETE: case EV_TXCOMPLETE:
@ -236,8 +240,8 @@ void onEvent(ev_t ev) {
} }
#endif #endif
strcpy_P(buff, (LMIC.txrxFlags & TXRX_ACK) ? PSTR("RECEIVED_ACK") strcpy_P(buff, (LMIC.txrxFlags & TXRX_ACK) ? PSTR("RECEIVED ACK")
: PSTR("TX_COMPLETE")); : PSTR("TX COMPLETE"));
sprintf(display_line6, " "); // clear previous lmic status sprintf(display_line6, " "); // clear previous lmic status
if (LMIC.dataLen) { // did we receive payload data -> display info if (LMIC.dataLen) { // did we receive payload data -> display info
@ -265,7 +269,7 @@ void onEvent(ev_t ev) {
break; break;
case EV_LOST_TSYNC: case EV_LOST_TSYNC:
strcpy_P(buff, PSTR("LOST_TSYNC")); strcpy_P(buff, PSTR("LOST TSYNC"));
break; break;
case EV_RESET: case EV_RESET:
@ -274,38 +278,46 @@ void onEvent(ev_t ev) {
case EV_RXCOMPLETE: case EV_RXCOMPLETE:
// data received in ping slot // data received in ping slot
strcpy_P(buff, PSTR("RX_COMPLETE")); strcpy_P(buff, PSTR("RX COMPLETE"));
break; break;
case EV_LINK_DEAD: case EV_LINK_DEAD:
strcpy_P(buff, PSTR("LINK_DEAD")); strcpy_P(buff, PSTR("LINK DEAD"));
break; break;
case EV_LINK_ALIVE: case EV_LINK_ALIVE:
strcpy_P(buff, PSTR("LINK_ALIVE")); strcpy_P(buff, PSTR("LINK_ALIVE"));
break; break;
case EV_SCAN_FOUND:
strcpy_P(buff, PSTR("SCAN FOUND"));
break;
case EV_TXSTART: case EV_TXSTART:
if (!(LMIC.opmode & OP_JOINING)) if (!(LMIC.opmode & OP_JOINING))
strcpy_P(buff, PSTR("TX_START")); strcpy_P(buff, PSTR("TX START"));
break; break;
case EV_SCAN_FOUND: case EV_TXCANCELED:
strcpy_P(buff, PSTR("SCAN_FOUND")); strcpy_P(buff, PSTR("TX CANCELLED"));
break; break;
case EV_RFU1: case EV_RXSTART:
strcpy_P(buff, PSTR("RFU1")); strcpy_P(buff, PSTR("RX START"));
break;
case EV_JOIN_TXCOMPLETE:
strcpy_P(buff, PSTR("JOIN TXCOMPLT"));
break; break;
default: default:
sprintf_P(buff, PSTR("UNKNOWN_EVENT_%d"), ev); sprintf_P(buff, PSTR("LMIC EV %d"), ev);
break; break;
} }
// Log & Display if asked // Log & Display if asked
if (*buff) { if (*buff) {
ESP_LOGI(TAG, "EV_%s", buff); ESP_LOGI(TAG, "%s", buff);
sprintf(display_line7, buff); sprintf(display_line7, buff);
} }
} }
@ -491,13 +503,13 @@ void user_request_network_time_callback(void *pVoidUserUTCTime,
if (timeIsValid(*pUserUTCTime)) { if (timeIsValid(*pUserUTCTime)) {
setTime(*pUserUTCTime); setTime(*pUserUTCTime);
#ifdef HAS_RTC #ifdef HAS_RTC
set_rtctime(*pUserUTCTime); // calibrate RTC if we have one set_rtctime(*pUserUTCTime); // calibrate RTC if we have one
#endif #endif
timeSource = _lora; timeSource = _lora;
timesyncer.attach(TIME_SYNC_INTERVAL * 60, timeSync); // regular repeat timesyncer.attach(TIME_SYNC_INTERVAL * 60, timeSync); // regular repeat
ESP_LOGI(TAG, "Received recent time from LoRa"); ESP_LOGI(TAG, "Received recent time from LoRa");
} else } else
ESP_LOGI(TAG, "Invalid time received from LoRa"); ESP_LOGI(TAG, "Invalid time received from LoRa");
} // user_request_network_time_callback } // user_request_network_time_callback
#endif // HAS_LORA #endif // HAS_LORA