From 4d3390383ea353f9836ecbb339c3df058dc4b9f9 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Tue, 3 Mar 2020 12:53:30 +0100 Subject: [PATCH 1/5] lorawan.cpp: enhance RX/TX callback functions --- src/lorawan.cpp | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/lorawan.cpp b/src/lorawan.cpp index e07abacb..80bd768a 100644 --- a/src/lorawan.cpp +++ b/src/lorawan.cpp @@ -264,9 +264,17 @@ void lora_send(void *pvParameters) { // switch (LMIC_sendWithCallback_strict( switch (LMIC_sendWithCallback( SendBuffer.MessagePort, SendBuffer.Message, SendBuffer.MessageSize, - (cfg.countermode & 0x02), myTxCallback, NULL)) { + (cfg.countermode & 0x02), myTxCallback, &SendBuffer.MessagePort)) { case LMIC_ERROR_SUCCESS: + +#if (TIME_SYNC_LORASERVER) + // if last packet sent was a timesync request, store TX timestamp + if (SendBuffer.MessagePort == TIMEPORT) + // store LMIC time when we started transmit of timesync request + store_timestamp(osticks2ms(os_getTime()), timesync_tx); +#endif + ESP_LOGI(TAG, "%d byte(s) sent to LORA", SendBuffer.MessageSize); break; case LMIC_ERROR_TX_BUSY: // LMIC already has a tx message pending @@ -544,6 +552,9 @@ void myRxCallback(void *pUserData, uint8_t port, const uint8_t *pMsg, #if (TIME_SYNC_LORASERVER) // valid timesync answer -> call timesync processor if (port == TIMEPORT) { + // store LMIC time when we received the timesync answer + store_timestamp(osticks2ms(os_getTime()), timesync_rx); + // get and store gwtime from payload recv_timesync_ans(pMsg, nMsg); break; } @@ -558,11 +569,13 @@ void myRxCallback(void *pUserData, uint8_t port, const uint8_t *pMsg, // transmit complete message handler void myTxCallback(void *pUserData, int fSuccess) { -#if (TIME_SYNC_LORASERVER) - // if last packet sent was a timesync request, store TX timestamp - if (LMIC.pendTxPort == TIMEPORT) - store_time_sync_req(osticks2ms(LMIC.txend)); // milliseconds -#endif + uint8_t *const sendport = (uint8_t *)pUserData; + + if (fSuccess) { + // LMIC did tx on *sendport -> nothing yet to do here + } else { + // LMIC could not tx on *sendport -> error handling yet to come + } } // decode LORAWAN MAC message @@ -618,7 +631,7 @@ const char *getCrName(rps_t rps) { /* u1_t os_getBattLevel() { - + //return values: //MCMD_DEVS_EXT_POWER = 0x00, // external power supply //MCMD_DEVS_BATT_MIN = 0x01, // min battery value From 0f2e48f39c69943b7a121b5c1a7caf0843c00bbc Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Tue, 3 Mar 2020 12:54:00 +0100 Subject: [PATCH 2/5] timekeeper.h: bugfix time source debug log --- src/timekeeper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/timekeeper.cpp b/src/timekeeper.cpp index 85f62864..0558a156 100644 --- a/src/timekeeper.cpp +++ b/src/timekeeper.cpp @@ -104,11 +104,11 @@ void IRAM_ATTR setMyTime(uint32_t t_sec, uint16_t t_msec, timeSource = mytimesource; // set global variable timesyncer.attach(TIME_SYNC_INTERVAL * 60, timeSync); ESP_LOGI(TAG, "[%0.3f] Timesync finished, time was set | source: %c", - millis() / 1000.0, timeSetSymbols[timeSource]); + millis() / 1000.0, timeSetSymbols[mytimesource]); } else { timesyncer.attach(TIME_SYNC_INTERVAL_RETRY * 60, timeSync); ESP_LOGI(TAG, "[%0.3f] Timesync failed, invalid time fetched | source: %c", - millis() / 1000.0, timeSetSymbols[timeSource]); + millis() / 1000.0, timeSetSymbols[mytimesource]); } } From 1516d710186b4f9100f683bac9ee55602af8c552 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Tue, 3 Mar 2020 12:54:42 +0100 Subject: [PATCH 3/5] reworked lora appserver timesync logic (part 1) --- include/timesync.h | 12 +++-- src/timesync.cpp | 108 +++++++++++++++++++-------------------------- 2 files changed, 54 insertions(+), 66 deletions(-) diff --git a/include/timesync.h b/include/timesync.h index bf74700e..e1283352 100644 --- a/include/timesync.h +++ b/include/timesync.h @@ -11,12 +11,18 @@ #define TIME_SYNC_FIXUP 4 // calibration to fixup processing time [milliseconds] #define TIMEREQUEST_MAX_SEQNO 0xf0 // threshold for wrap around seqno +enum timesync_t { + timesync_tx, + timesync_rx, + gwtime_sec, + gwtime_msec, + no_of_timestamps +}; + void timesync_init(void); void send_timesync_req(void); - int recv_timesync_ans(const uint8_t buf[], uint8_t buf_len); - void process_timesync_req(void *taskparameter); -void store_time_sync_req(uint32_t t_millisec); +void store_timestamp(uint32_t timestamp, timesync_t timestamp_type); #endif diff --git a/src/timesync.cpp b/src/timesync.cpp index 43093bb4..5eef2f80 100644 --- a/src/timesync.cpp +++ b/src/timesync.cpp @@ -16,19 +16,11 @@ algorithm in applications without granted license by the patent holder. // Local logging tag static const char TAG[] = __FILE__; -using namespace std::chrono; - -typedef std::chrono::system_clock myClock; -typedef myClock::time_point myClock_timepoint; -typedef std::chrono::duration> - myClock_msecTick; - TaskHandle_t timeSyncReqTask = NULL; static uint8_t time_sync_seqNo = (uint8_t)random(TIMEREQUEST_MAX_SEQNO); static bool timeSyncPending = false; -static myClock_timepoint time_sync_tx[TIME_SYNC_SAMPLES]; -static myClock_timepoint time_sync_rx[TIME_SYNC_SAMPLES]; +static uint32_t timesync_timestamp[TIME_SYNC_SAMPLES][no_of_timestamps] = {0}; // send time request message void send_timesync_req() { @@ -46,18 +38,13 @@ void send_timesync_req() { // task for sending time sync requests void process_timesync_req(void *taskparameter) { - uint8_t k; - uint16_t time_to_set_fraction_msec; - uint32_t seq_no = 0, time_to_set; - auto time_offset_ms = myClock_msecTick::zero(); + uint8_t i; + uint32_t seq_no, time_offset_ms; + + // --- asnychronous part: generate and collect timestamps from gateway --- while (1) { - // reset all timestamps before next sync run - time_offset_ms = myClock_msecTick::zero(); - for (uint8_t i = 0; i < TIME_SYNC_SAMPLES; i++) - time_sync_tx[i] = time_sync_rx[i] = myClock_timepoint(); - // wait for kickoff ulTaskNotifyTake(pdFALSE, portMAX_DELAY); timeSyncPending = true; @@ -67,8 +54,8 @@ void process_timesync_req(void *taskparameter) { vTaskDelay(pdMS_TO_TICKS(3000)); } - // collect timestamp samples - for (uint8_t i = 0; i < TIME_SYNC_SAMPLES; i++) { + // generate and collect timestamp samples + for (i = 0; i < TIME_SYNC_SAMPLES; i++) { // send sync request to server payload.reset(); payload.addByte(time_sync_seqNo); @@ -85,13 +72,6 @@ void process_timesync_req(void *taskparameter) { } } - // process answer - k = seq_no % TIME_SYNC_SAMPLES; - - // calculate time diff from collected timestamps - time_offset_ms += time_point_cast(time_sync_rx[k]) - - time_point_cast(time_sync_tx[k]); - // wrap around seqNo, keeping it in time port range time_sync_seqNo++; if (time_sync_seqNo > TIMEREQUEST_MAX_SEQNO) { @@ -109,32 +89,36 @@ void process_timesync_req(void *taskparameter) { // ...send a alive open a receive window for last time_sync_answer LMIC_sendAlive(); } + } // end of for loop to collect timestamp samples + // --- time critial part: evaluate timestamps and calculate time --- + // mask application irq to ensure accurate timing mask_user_IRQ(); - // average time offset over all collected diffs + time_offset_ms = 0; + + for (i = 0; i < TIME_SYNC_SAMPLES; i++) { + // calculate time diff from collected timestamps and apply + // a compensation constant TIME_SYNC_FIXUP for processing time + + time_offset_ms += timesync_timestamp[i][timesync_rx] - + timesync_timestamp[i][timesync_tx] + TIME_SYNC_FIXUP; + } + + // decrement i for subscription to latest element in timestamp array + i--; + + // average time offset over all collected diffs and add gateway time msec time_offset_ms /= TIME_SYNC_SAMPLES; + time_offset_ms += timesync_timestamp[i][gwtime_msec]; - // --------- do we need this? --------- - // calculate time offset with millisecond precision using LMIC's time base, - // since we use LMIC's ostime_t txEnd as tx timestamp. - // - // time_offset_ms += milliseconds(osticks2ms(os_getTime())) - - // milliseconds(millis()); - // --------- not sure ----------------- + // calculate absolute time in UTC epoch: take latest time received from + // gateway, convert to whole seconds, round to ceil, add fraction seconds - // Apply calibration const to compensate processing time. - time_offset_ms += milliseconds(TIME_SYNC_FIXUP); - - // calculate absolute time in UTC epoch: convert to whole seconds, round - // to ceil, and calculate fraction milliseconds - time_to_set = (uint32_t)(time_offset_ms.count() / 1000) + 1; - // calculate fraction milliseconds - time_to_set_fraction_msec = (uint16_t)(time_offset_ms.count() % 1000); - - setMyTime(time_to_set, time_to_set_fraction_msec, _lora); + setMyTime(timesync_timestamp[i][gwtime_sec] + time_offset_ms / 1000, + time_offset_ms % 1000, _lora); finish: // end of time critical section: release app irq lock @@ -144,19 +128,14 @@ void process_timesync_req(void *taskparameter) { } // infinite while(1) } -// called from lorawan.cpp after time_sync_req was sent -void store_time_sync_req(uint32_t timestamp) { +// called from lorawan.cpp +void store_timestamp(uint32_t timestamp, timesync_t timestamp_type) { - // if no timesync handshake is pending then exit - if (!timeSyncPending) - return; + uint8_t seq = time_sync_seqNo % TIME_SYNC_SAMPLES; + timesync_timestamp[seq][timestamp_type] = timestamp; - uint8_t k = time_sync_seqNo % TIME_SYNC_SAMPLES; - time_sync_tx[k] += milliseconds(timestamp); - - ESP_LOGD(TAG, "[%0.3f] Timesync request #%d of %d sent at %d.%03d", - millis() / 1000.0, k + 1, TIME_SYNC_SAMPLES, timestamp / 1000, - timestamp % 1000); + ESP_LOGD(TAG, "[%0.3f] Timesync seq#%d: timestamp(%d) %d stored", + millis() / 1000.0, seq, timestamp_type, timestamp); } // process timeserver timestamp answer, called by myRxCallback() in lorawan.cpp @@ -211,15 +190,18 @@ int recv_timesync_ans(const uint8_t buf[], const uint8_t buf_len) { // extract 1 byte fractional seconds in 2^-8 second steps // (= 1/250th sec), we convert this to ms uint16_t timestamp_msec = 4 * buf[0]; - - // construct the timepoint when message was seen on gateway - time_sync_rx[k] += seconds(timestamp_sec) + milliseconds(timestamp_msec); + // calculate absolute time received from gateway + time_t t = timestamp_sec + timestamp_msec / 1000; // we guess timepoint is recent if it is newer than code compile date - if (timeIsValid(myClock::to_time_t(time_sync_rx[k]))) { - ESP_LOGD(TAG, "[%0.3f] Timesync request #%d of %d rcvd at %d.%03d", - millis() / 1000.0, k + 1, TIME_SYNC_SAMPLES, timestamp_sec, - timestamp_msec); + if (timeIsValid(t)) { + ESP_LOGD(TAG, "[%0.3f] Timesync request #%d of %d rcvd at %0.3f", + millis() / 1000.0, k + 1, TIME_SYNC_SAMPLES, + osticks2ms(os_getTime()) / 1000.0); + + // store time received from gateway + store_timestamp(timestamp_sec, gwtime_sec); + store_timestamp(timestamp_msec, gwtime_msec); // inform processing task xTaskNotify(timeSyncReqTask, seq_no, eSetBits); From c17bfa02af17d94cfa19ab62707097832343f410 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Tue, 3 Mar 2020 16:38:29 +0100 Subject: [PATCH 4/5] reworked lora appserver timesync logic (part 2) --- include/timesync.h | 6 ++- src/timesync.cpp | 97 ++++++++++++++++++++++++---------------------- 2 files changed, 54 insertions(+), 49 deletions(-) diff --git a/include/timesync.h b/include/timesync.h index e1283352..8e8a5f1d 100644 --- a/include/timesync.h +++ b/include/timesync.h @@ -8,8 +8,10 @@ //#define TIME_SYNC_TRIGGER 100 // threshold for time sync [milliseconds] #define TIME_SYNC_FRAME_LENGTH 0x07 // timeserver answer frame length [bytes] -#define TIME_SYNC_FIXUP 4 // calibration to fixup processing time [milliseconds] -#define TIMEREQUEST_MAX_SEQNO 0xf0 // threshold for wrap around seqno +#define TIME_SYNC_FIXUP 16 // empirical calibration to fixup processing time [milliseconds] +#define TIMEREQUEST_MAX_SEQNO 0xfe // threshold for wrap around seqno +#define TIMEREQUEST_FINISH \ + (TIMEREQUEST_MAX_SEQNO + 1) // marker for end of timesync handshake enum timesync_t { timesync_tx, diff --git a/src/timesync.cpp b/src/timesync.cpp index 5eef2f80..46bf8f8c 100644 --- a/src/timesync.cpp +++ b/src/timesync.cpp @@ -19,6 +19,7 @@ static const char TAG[] = __FILE__; TaskHandle_t timeSyncReqTask = NULL; static uint8_t time_sync_seqNo = (uint8_t)random(TIMEREQUEST_MAX_SEQNO); +static uint8_t sample_idx = 0; static bool timeSyncPending = false; static uint32_t timesync_timestamp[TIME_SYNC_SAMPLES][no_of_timestamps] = {0}; @@ -38,8 +39,12 @@ void send_timesync_req() { // task for sending time sync requests void process_timesync_req(void *taskparameter) { - uint8_t i; - uint32_t seq_no, time_offset_ms; + uint32_t rcv_seq_no = TIMEREQUEST_FINISH, time_offset_ms; + + // this task is an endless loop, waiting in blocked mode, until it is + // unblocked by send_timesync_req(). It then waits to be notified from + // recv_timesync_ans(), which is called from RX callback in lorawan.cpp, each + // time a timestamp from timeserver arrived. // --- asnychronous part: generate and collect timestamps from gateway --- @@ -48,22 +53,23 @@ void process_timesync_req(void *taskparameter) { // wait for kickoff ulTaskNotifyTake(pdFALSE, portMAX_DELAY); timeSyncPending = true; + time_offset_ms = 0; // wait until we are joined if we are not while (!LMIC.devaddr) { - vTaskDelay(pdMS_TO_TICKS(3000)); + vTaskDelay(pdMS_TO_TICKS(5000)); } - // generate and collect timestamp samples - for (i = 0; i < TIME_SYNC_SAMPLES; i++) { - // send sync request to server + // trigger and collect timestamp samples + for (uint8_t i = 0; i < TIME_SYNC_SAMPLES; i++) { + // send timesync request to timeserver payload.reset(); payload.addByte(time_sync_seqNo); SendPayload(TIMEPORT, prio_high); - // wait for a valid timestamp from recv_timesync_ans() - while (seq_no != time_sync_seqNo) { - if (xTaskNotifyWait(0x00, ULONG_MAX, &seq_no, + // wait until recv_timesync_ans() signals a timestamp was received + while (rcv_seq_no != time_sync_seqNo) { + if (xTaskNotifyWait(0x00, ULONG_MAX, &rcv_seq_no, pdMS_TO_TICKS(TIME_SYNC_TIMEOUT * 1000)) == pdFALSE) { ESP_LOGW(TAG, "[%0.3f] Timesync handshake error: timeout", @@ -72,21 +78,30 @@ void process_timesync_req(void *taskparameter) { } } - // wrap around seqNo, keeping it in time port range + ESP_LOGD(TAG, "sample_idx = %d", sample_idx); + + // calculate time diff from collected timestamps + time_offset_ms += timesync_timestamp[sample_idx][timesync_rx] - + timesync_timestamp[sample_idx][timesync_tx]; + + // increment and maybe wrap around seqNo, keeping it in time port range time_sync_seqNo++; if (time_sync_seqNo > TIMEREQUEST_MAX_SEQNO) { time_sync_seqNo = 0; } - if (i < TIME_SYNC_SAMPLES - 1) { - // wait until next cycle + // increment index for timestamp array + sample_idx++; + + // if last cycle, send finish char for closing timesync handshake, + // else wait until time has come for next cycle + if (i < TIME_SYNC_SAMPLES - 1) { // wait for next cycle vTaskDelay(pdMS_TO_TICKS(TIME_SYNC_CYCLE * 1000)); - } else { // before sending last time sample... - // ...send flush to open a receive window for last time_sync_answer + } else { // finish timesync handshake payload.reset(); - payload.addByte(0x99); + payload.addByte(TIMEREQUEST_FINISH); SendPayload(RCMDPORT, prio_high); - // ...send a alive open a receive window for last time_sync_answer + // open a receive window to get last time_sync_answer instantly LMIC_sendAlive(); } @@ -97,45 +112,36 @@ void process_timesync_req(void *taskparameter) { // mask application irq to ensure accurate timing mask_user_IRQ(); - time_offset_ms = 0; - - for (i = 0; i < TIME_SYNC_SAMPLES; i++) { - // calculate time diff from collected timestamps and apply - // a compensation constant TIME_SYNC_FIXUP for processing time - - time_offset_ms += timesync_timestamp[i][timesync_rx] - - timesync_timestamp[i][timesync_tx] + TIME_SYNC_FIXUP; - } - - // decrement i for subscription to latest element in timestamp array - i--; - - // average time offset over all collected diffs and add gateway time msec + // average time offset over the summed up difference + // + add msec from recent gateway time, found with last sample_idx + // + apply a compensation constant TIME_SYNC_FIXUP for processing time time_offset_ms /= TIME_SYNC_SAMPLES; - time_offset_ms += timesync_timestamp[i][gwtime_msec]; + time_offset_ms += + timesync_timestamp[sample_idx - 1][gwtime_msec] + TIME_SYNC_FIXUP; // calculate absolute time in UTC epoch: take latest time received from // gateway, convert to whole seconds, round to ceil, add fraction seconds - - setMyTime(timesync_timestamp[i][gwtime_sec] + time_offset_ms / 1000, + setMyTime(timesync_timestamp[sample_idx - 1][gwtime_sec] + + time_offset_ms / 1000, time_offset_ms % 1000, _lora); - finish: // end of time critical section: release app irq lock - timeSyncPending = false; unmask_user_IRQ(); + finish: + timeSyncPending = false; + } // infinite while(1) } // called from lorawan.cpp void store_timestamp(uint32_t timestamp, timesync_t timestamp_type) { - uint8_t seq = time_sync_seqNo % TIME_SYNC_SAMPLES; - timesync_timestamp[seq][timestamp_type] = timestamp; + ESP_LOGD(TAG, "[%0.3f] seq#%d[%d]: timestamp(t%d)=%d", + millis() / 1000.0, time_sync_seqNo, sample_idx, timestamp_type, + timestamp); - ESP_LOGD(TAG, "[%0.3f] Timesync seq#%d: timestamp(%d) %d stored", - millis() / 1000.0, seq, timestamp_type, timestamp); + timesync_timestamp[sample_idx][timestamp_type] = timestamp; } // process timeserver timestamp answer, called by myRxCallback() in lorawan.cpp @@ -155,7 +161,7 @@ int recv_timesync_ans(const uint8_t buf[], const uint8_t buf_len) { if (!timeSyncPending) return 0; // failure - // extract 1 byte timerequest sequence number from buffer + // extract 1 byte timerequest sequence number from payload uint8_t seq_no = buf[0]; buf++; @@ -172,16 +178,14 @@ int recv_timesync_ans(const uint8_t buf[], const uint8_t buf_len) { else { // we received a probably valid time frame - uint8_t k = seq_no % TIME_SYNC_SAMPLES; - // pointers to 4 bytes containing UTC seconds since unix epoch, msb uint32_t timestamp_sec, *timestamp_ptr; - // extract 1 byte timezone from buffer (one step being 15min * 60s = 900s) + // extract 1 byte timezone from payload (one step being 15min * 60s = 900s) // uint32_t timezone_sec = buf[0] * 900; // for future use buf++; - // extract 4 bytes timestamp from buffer + // extract 4 bytes timestamp from payload // and convert it to uint32_t, octet order is big endian timestamp_ptr = (uint32_t *)buf; // swap byte order from msb to lsb, note: this is platform dependent @@ -195,9 +199,8 @@ int recv_timesync_ans(const uint8_t buf[], const uint8_t buf_len) { // we guess timepoint is recent if it is newer than code compile date if (timeIsValid(t)) { - ESP_LOGD(TAG, "[%0.3f] Timesync request #%d of %d rcvd at %0.3f", - millis() / 1000.0, k + 1, TIME_SYNC_SAMPLES, - osticks2ms(os_getTime()) / 1000.0); + ESP_LOGD(TAG, "[%0.3f] Timesync request seq#%d rcvd at %0.3f", + millis() / 1000.0, seq_no, osticks2ms(os_getTime()) / 1000.0); // store time received from gateway store_timestamp(timestamp_sec, gwtime_sec); From efd0cc3819850ab034d744aef8154da0aa05d762 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Tue, 3 Mar 2020 16:52:29 +0100 Subject: [PATCH 5/5] lorawan.cpp: code sanitizations --- include/lorawan.h | 2 +- src/lorawan.cpp | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/include/lorawan.h b/include/lorawan.h index 4afc5982..90a7db56 100644 --- a/include/lorawan.h +++ b/include/lorawan.h @@ -46,7 +46,7 @@ void lora_queuereset(void); void IRAM_ATTR myEventCallback(void *pUserData, ev_t ev); void IRAM_ATTR myRxCallback(void *pUserData, uint8_t port, const uint8_t *pMsg, size_t nMsg); -void IRAM_ATTR myTxCallback(void *pUserData, int fSuccess); +//void IRAM_ATTR myTxCallback(void *pUserData, int fSuccess); void mac_decode(const uint8_t cmd[], const uint8_t cmdlen, const mac_t table[], const uint8_t tablesize); //u1_t os_getBattLevel(void); diff --git a/src/lorawan.cpp b/src/lorawan.cpp index 80bd768a..5c9ab138 100644 --- a/src/lorawan.cpp +++ b/src/lorawan.cpp @@ -261,10 +261,14 @@ void lora_send(void *pvParameters) { // attempt to transmit payload else { - // switch (LMIC_sendWithCallback_strict( - switch (LMIC_sendWithCallback( - SendBuffer.MessagePort, SendBuffer.Message, SendBuffer.MessageSize, - (cfg.countermode & 0x02), myTxCallback, &SendBuffer.MessagePort)) { + switch (LMIC_setTxData2_strict(SendBuffer.MessagePort, SendBuffer.Message, + SendBuffer.MessageSize, + (cfg.countermode & 0x02))) { + + // switch (LMIC_sendWithCallback_strict( + // SendBuffer.MessagePort, SendBuffer.Message, + // SendBuffer.MessageSize, (cfg.countermode & 0x02), myTxCallback, + // &SendBuffer.MessagePort)) { case LMIC_ERROR_SUCCESS: @@ -566,7 +570,8 @@ void myRxCallback(void *pUserData, uint8_t port, const uint8_t *pMsg, } // switch } -// transmit complete message handler +/* +// event TRANSMIT COMPLETE message handler void myTxCallback(void *pUserData, int fSuccess) { uint8_t *const sendport = (uint8_t *)pUserData; @@ -577,6 +582,7 @@ void myTxCallback(void *pUserData, int fSuccess) { // LMIC could not tx on *sendport -> error handling yet to come } } +*/ // decode LORAWAN MAC message void mac_decode(const uint8_t cmd[], const uint8_t cmdlen, const mac_t table[],