diff --git a/platformio.ini b/platformio.ini index 54991dc8..5ac72033 100644 --- a/platformio.ini +++ b/platformio.ini @@ -44,8 +44,8 @@ build_flags = ; ---> NOTE: For production run set DEBUG_LEVEL level to NONE! <--- ; otherwise device may crash in dense environments due to serial buffer overflow ; -; -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_NONE - -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_INFO + -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_NONE +; -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_INFO ; -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG ; -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE ; diff --git a/src/button.cpp b/src/button.cpp index 4ca25638..3f75674a 100644 --- a/src/button.cpp +++ b/src/button.cpp @@ -16,7 +16,7 @@ void readButton() { ESP_LOGI(TAG, "Button pressed"); payload.reset(); payload.addButton(0x01); - EnqueueSendData(BUTTONPORT, payload.getBuffer(), payload.getSize()); + SendData(BUTTONPORT); } } #endif \ No newline at end of file diff --git a/src/cyclic.cpp b/src/cyclic.cpp index b182a2c5..2fdbee03 100644 --- a/src/cyclic.cpp +++ b/src/cyclic.cpp @@ -37,7 +37,7 @@ void doHomework() { "Memory full, counter cleared (heap low water mark = %d Bytes / " "free heap = %d bytes)", esp_get_minimum_free_heap_size(), ESP.getFreeHeap()); - EnqueueSendData(COUNTERPORT, payload.getBuffer(), payload.getSize()); // send data before clearing counters + SendData(COUNTERPORT); // send data before clearing counters reset_counters(); // clear macs container and reset all counters reset_salt(); // get new salt for salting hashes } diff --git a/src/display.cpp b/src/display.cpp index 498e38d8..e43efcd5 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -91,19 +91,19 @@ void init_display(const char *Productname, const char *Version) { void refreshtheDisplay() { - uint8_t msgWaiting = 0; - char buff[16]; - // set display on/off according to current device configuration if (DisplayState != cfg.screenon) { DisplayState = cfg.screenon; u8x8.setPowerSave(!cfg.screenon); } - // if display is switched off we don't need to refresh it and save time + // if display is switched off we don't refresh it and save time if (!DisplayState) return; + uint8_t msgWaiting = 0; + char buff[16]; // 16 chars line buffer + // update counter (lines 0-1) snprintf( buff, sizeof(buff), "PAX:%-4d", @@ -164,11 +164,11 @@ void refreshtheDisplay() { #ifdef HAS_LORA // update LoRa status display (line 6) u8x8.setCursor(0, 6); - u8x8.printf("%-14s", display_line6); + u8x8.printf("%-16s", display_line6); // update LMiC event display (line 7) u8x8.setCursor(0, 7); - u8x8.printf("%-14s", display_line7); + u8x8.printf("%-16s", display_line7); // update LoRa send queue display (line 7) msgWaiting = uxQueueMessagesWaiting(LoraSendQueue); @@ -178,10 +178,10 @@ void refreshtheDisplay() { u8x8.setInverseFont(1); u8x8.printf("%-2s", msgWaiting == SEND_QUEUE_SIZE ? "<>" : buff); u8x8.setInverseFont(0); - } else - u8x8.print(" "); // clear queue display + } #endif // HAS_LORA + } // refreshDisplay() void IRAM_ATTR DisplayIRQ() { diff --git a/src/macsniff.cpp b/src/macsniff.cpp index 73d606b1..29b1f1ad 100644 --- a/src/macsniff.cpp +++ b/src/macsniff.cpp @@ -106,7 +106,7 @@ bool mac_add(uint8_t *paddr, int8_t rssi, bool sniff_type) { #endif payload.reset(); payload.addAlarm(rssi, beaconID); - EnqueueSendData(BEACONPORT, payload.getBuffer(), payload.getSize()); + SendData(BEACONPORT); } }; diff --git a/src/main.cpp b/src/main.cpp index 2ce4b6ef..dd826c2e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -333,8 +333,6 @@ void loop() { // reset watchdog vTaskDelay(1 / portTICK_PERIOD_MS); - //ESP_LOGI(TAG, "%d Bytes left", ESP.getFreeHeap()); - } // loop() } diff --git a/src/rcommand.cpp b/src/rcommand.cpp index 74608501..03068848 100644 --- a/src/rcommand.cpp +++ b/src/rcommand.cpp @@ -293,7 +293,7 @@ void get_config(uint8_t val[]) { ESP_LOGI(TAG, "Remote command: get device configuration"); payload.reset(); payload.addConfig(cfg); - EnqueueSendData(CONFIGPORT, payload.getBuffer(), payload.getSize()); + SendData(CONFIGPORT); }; void get_status(uint8_t val[]) { @@ -305,7 +305,7 @@ void get_status(uint8_t val[]) { #endif payload.reset(); payload.addStatus(voltage, uptime() / 1000, temperatureRead()); - EnqueueSendData(STATUSPORT, payload.getBuffer(), payload.getSize()); + SendData(STATUSPORT); }; void get_gps(uint8_t val[]) { @@ -314,7 +314,7 @@ void get_gps(uint8_t val[]) { gps_read(); payload.reset(); payload.addGPS(gps_status); - EnqueueSendData(GPSPORT, payload.getBuffer(), payload.getSize()); + SendData(GPSPORT); #else ESP_LOGW(TAG, "GPS function not supported"); #endif diff --git a/src/senddata.cpp b/src/senddata.cpp index 84fd90ad..bf811fab 100644 --- a/src/senddata.cpp +++ b/src/senddata.cpp @@ -2,26 +2,26 @@ #include "globals.h" // put data to send in RTos Queues used for transmit over channels Lora and SPI -void EnqueueSendData(uint8_t port, uint8_t data[], uint8_t size) { +void SendData(uint8_t port) { MessageBuffer_t MySendBuffer; - MySendBuffer.MessageSize = size; + MySendBuffer.MessageSize = payload.getSize(); MySendBuffer.MessagePort = PAYLOAD_ENCODER <= 2 ? port : (PAYLOAD_ENCODER == 4 ? LPP2PORT : LPP1PORT); - memcpy(MySendBuffer.Message, data, size); + memcpy(MySendBuffer.Message, payload.getBuffer(), payload.getSize()); // enqueue message in LoRa send queue #ifdef HAS_LORA if (xQueueSendToBack(LoraSendQueue, (void *)&MySendBuffer, (TickType_t)0)) - ESP_LOGI(TAG, "%d bytes enqueued to send on LoRa", size); + ESP_LOGI(TAG, "%d bytes enqueued to send on LoRa", payload.getSize()); #endif // enqueue message in SPI send queue #ifdef HAS_SPI if (xQueueSendToBack(SPISendQueue, (void *)&MySendBuffer, (TickType_t)0)) - ESP_LOGI(TAG, "%d bytes enqueued to send on SPI", size); + ESP_LOGI(TAG, "%d bytes enqueued to send on SPI", payload.getSize()); #endif // clear counter if not in cumulative counter mode @@ -31,9 +31,7 @@ void EnqueueSendData(uint8_t port, uint8_t data[], uint8_t size) { ESP_LOGI(TAG, "Counter cleared"); } - ESP_LOGI(TAG, "%d Bytes left", ESP.getFreeHeap()); - -} // senddata +} // SendData // cyclic called function to prepare payload to send void sendPayload() { @@ -65,7 +63,7 @@ void sendPayload() { ESP_LOGD(TAG, "No valid GPS position or GPS data mode disabled"); } #endif - EnqueueSendData(COUNTERPORT, payload.getBuffer(), payload.getSize()); + SendData(COUNTERPORT); } } // sendpayload() @@ -102,8 +100,6 @@ void processSendBuffer() { } #endif - ESP_LOGI(TAG, "%d Bytes left", ESP.getFreeHeap()); - } // processSendBuffer /* old version with pointers @@ -112,7 +108,7 @@ void processSendBuffer() { #include "globals.h" // put data to send in RTos Queues used for transmit over channels Lora and SPI -void EnqueueSendData(uint8_t port, uint8_t data[], uint8_t size) { +void SendData(uint8_t port, uint8_t data[], uint8_t size) { MessageBuffer_t *xMsg = &SendBuffer; @@ -179,7 +175,7 @@ void sendPayload() { ESP_LOGD(TAG, "No valid GPS position or GPS data mode disabled"); } #endif - EnqueueSendData(COUNTERPORT, payload.getBuffer(), payload.getSize()); + SendData(COUNTERPORT, payload.getBuffer(), payload.getSize()); } } // sendpayload() diff --git a/src/senddata.h b/src/senddata.h index 18dbc427..07fc477d 100644 --- a/src/senddata.h +++ b/src/senddata.h @@ -8,7 +8,7 @@ typedef struct { uint8_t Message[PAYLOAD_BUFFER_SIZE]; } MessageBuffer_t; -void EnqueueSendData(uint8_t port, uint8_t data[], uint8_t size); +void SendData(uint8_t port); void sendPayload(void); void SendCycleIRQ(void); void processSendBuffer(void);