Send Queues (testing)

This commit is contained in:
Klaus K Wilting 2018-08-04 15:27:58 +02:00
parent 03ca7d4a37
commit 88ab6251f6
9 changed files with 26 additions and 32 deletions

View File

@ -44,8 +44,8 @@ build_flags =
; ---> NOTE: For production run set DEBUG_LEVEL level to NONE! <--- ; ---> NOTE: For production run set DEBUG_LEVEL level to NONE! <---
; otherwise device may crash in dense environments due to serial buffer overflow ; 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_NONE
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_INFO ; -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_INFO
; -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG ; -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
; -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE ; -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE
; ;

View File

@ -16,7 +16,7 @@ void readButton() {
ESP_LOGI(TAG, "Button pressed"); ESP_LOGI(TAG, "Button pressed");
payload.reset(); payload.reset();
payload.addButton(0x01); payload.addButton(0x01);
EnqueueSendData(BUTTONPORT, payload.getBuffer(), payload.getSize()); SendData(BUTTONPORT);
} }
} }
#endif #endif

View File

@ -37,7 +37,7 @@ void doHomework() {
"Memory full, counter cleared (heap low water mark = %d Bytes / " "Memory full, counter cleared (heap low water mark = %d Bytes / "
"free heap = %d bytes)", "free heap = %d bytes)",
esp_get_minimum_free_heap_size(), ESP.getFreeHeap()); 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_counters(); // clear macs container and reset all counters
reset_salt(); // get new salt for salting hashes reset_salt(); // get new salt for salting hashes
} }

View File

@ -91,19 +91,19 @@ void init_display(const char *Productname, const char *Version) {
void refreshtheDisplay() { void refreshtheDisplay() {
uint8_t msgWaiting = 0;
char buff[16];
// set display on/off according to current device configuration // set display on/off according to current device configuration
if (DisplayState != cfg.screenon) { if (DisplayState != cfg.screenon) {
DisplayState = cfg.screenon; DisplayState = cfg.screenon;
u8x8.setPowerSave(!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) if (!DisplayState)
return; return;
uint8_t msgWaiting = 0;
char buff[16]; // 16 chars line buffer
// update counter (lines 0-1) // update counter (lines 0-1)
snprintf( snprintf(
buff, sizeof(buff), "PAX:%-4d", buff, sizeof(buff), "PAX:%-4d",
@ -164,11 +164,11 @@ void refreshtheDisplay() {
#ifdef HAS_LORA #ifdef HAS_LORA
// update LoRa status display (line 6) // update LoRa status display (line 6)
u8x8.setCursor(0, 6); u8x8.setCursor(0, 6);
u8x8.printf("%-14s", display_line6); u8x8.printf("%-16s", display_line6);
// update LMiC event display (line 7) // update LMiC event display (line 7)
u8x8.setCursor(0, 7); u8x8.setCursor(0, 7);
u8x8.printf("%-14s", display_line7); u8x8.printf("%-16s", display_line7);
// update LoRa send queue display (line 7) // update LoRa send queue display (line 7)
msgWaiting = uxQueueMessagesWaiting(LoraSendQueue); msgWaiting = uxQueueMessagesWaiting(LoraSendQueue);
@ -178,10 +178,10 @@ void refreshtheDisplay() {
u8x8.setInverseFont(1); u8x8.setInverseFont(1);
u8x8.printf("%-2s", msgWaiting == SEND_QUEUE_SIZE ? "<>" : buff); u8x8.printf("%-2s", msgWaiting == SEND_QUEUE_SIZE ? "<>" : buff);
u8x8.setInverseFont(0); u8x8.setInverseFont(0);
} else }
u8x8.print(" "); // clear queue display
#endif // HAS_LORA #endif // HAS_LORA
} // refreshDisplay() } // refreshDisplay()
void IRAM_ATTR DisplayIRQ() { void IRAM_ATTR DisplayIRQ() {

View File

@ -106,7 +106,7 @@ bool mac_add(uint8_t *paddr, int8_t rssi, bool sniff_type) {
#endif #endif
payload.reset(); payload.reset();
payload.addAlarm(rssi, beaconID); payload.addAlarm(rssi, beaconID);
EnqueueSendData(BEACONPORT, payload.getBuffer(), payload.getSize()); SendData(BEACONPORT);
} }
}; };

View File

@ -333,8 +333,6 @@ void loop() {
// reset watchdog // reset watchdog
vTaskDelay(1 / portTICK_PERIOD_MS); vTaskDelay(1 / portTICK_PERIOD_MS);
//ESP_LOGI(TAG, "%d Bytes left", ESP.getFreeHeap());
} // loop() } // loop()
} }

View File

@ -293,7 +293,7 @@ void get_config(uint8_t val[]) {
ESP_LOGI(TAG, "Remote command: get device configuration"); ESP_LOGI(TAG, "Remote command: get device configuration");
payload.reset(); payload.reset();
payload.addConfig(cfg); payload.addConfig(cfg);
EnqueueSendData(CONFIGPORT, payload.getBuffer(), payload.getSize()); SendData(CONFIGPORT);
}; };
void get_status(uint8_t val[]) { void get_status(uint8_t val[]) {
@ -305,7 +305,7 @@ void get_status(uint8_t val[]) {
#endif #endif
payload.reset(); payload.reset();
payload.addStatus(voltage, uptime() / 1000, temperatureRead()); payload.addStatus(voltage, uptime() / 1000, temperatureRead());
EnqueueSendData(STATUSPORT, payload.getBuffer(), payload.getSize()); SendData(STATUSPORT);
}; };
void get_gps(uint8_t val[]) { void get_gps(uint8_t val[]) {
@ -314,7 +314,7 @@ void get_gps(uint8_t val[]) {
gps_read(); gps_read();
payload.reset(); payload.reset();
payload.addGPS(gps_status); payload.addGPS(gps_status);
EnqueueSendData(GPSPORT, payload.getBuffer(), payload.getSize()); SendData(GPSPORT);
#else #else
ESP_LOGW(TAG, "GPS function not supported"); ESP_LOGW(TAG, "GPS function not supported");
#endif #endif

View File

@ -2,26 +2,26 @@
#include "globals.h" #include "globals.h"
// put data to send in RTos Queues used for transmit over channels Lora and SPI // 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; MessageBuffer_t MySendBuffer;
MySendBuffer.MessageSize = size; MySendBuffer.MessageSize = payload.getSize();
MySendBuffer.MessagePort = PAYLOAD_ENCODER <= 2 MySendBuffer.MessagePort = PAYLOAD_ENCODER <= 2
? port ? port
: (PAYLOAD_ENCODER == 4 ? LPP2PORT : LPP1PORT); : (PAYLOAD_ENCODER == 4 ? LPP2PORT : LPP1PORT);
memcpy(MySendBuffer.Message, data, size); memcpy(MySendBuffer.Message, payload.getBuffer(), payload.getSize());
// enqueue message in LoRa send queue // enqueue message in LoRa send queue
#ifdef HAS_LORA #ifdef HAS_LORA
if (xQueueSendToBack(LoraSendQueue, (void *)&MySendBuffer, (TickType_t)0)) 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 #endif
// enqueue message in SPI send queue // enqueue message in SPI send queue
#ifdef HAS_SPI #ifdef HAS_SPI
if (xQueueSendToBack(SPISendQueue, (void *)&MySendBuffer, (TickType_t)0)) 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 #endif
// clear counter if not in cumulative counter mode // 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, "Counter cleared");
} }
ESP_LOGI(TAG, "%d Bytes left", ESP.getFreeHeap()); } // SendData
} // senddata
// cyclic called function to prepare payload to send // cyclic called function to prepare payload to send
void sendPayload() { void sendPayload() {
@ -65,7 +63,7 @@ void sendPayload() {
ESP_LOGD(TAG, "No valid GPS position or GPS data mode disabled"); ESP_LOGD(TAG, "No valid GPS position or GPS data mode disabled");
} }
#endif #endif
EnqueueSendData(COUNTERPORT, payload.getBuffer(), payload.getSize()); SendData(COUNTERPORT);
} }
} // sendpayload() } // sendpayload()
@ -102,8 +100,6 @@ void processSendBuffer() {
} }
#endif #endif
ESP_LOGI(TAG, "%d Bytes left", ESP.getFreeHeap());
} // processSendBuffer } // processSendBuffer
/* old version with pointers /* old version with pointers
@ -112,7 +108,7 @@ void processSendBuffer() {
#include "globals.h" #include "globals.h"
// put data to send in RTos Queues used for transmit over channels Lora and SPI // 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; MessageBuffer_t *xMsg = &SendBuffer;
@ -179,7 +175,7 @@ void sendPayload() {
ESP_LOGD(TAG, "No valid GPS position or GPS data mode disabled"); ESP_LOGD(TAG, "No valid GPS position or GPS data mode disabled");
} }
#endif #endif
EnqueueSendData(COUNTERPORT, payload.getBuffer(), payload.getSize()); SendData(COUNTERPORT, payload.getBuffer(), payload.getSize());
} }
} // sendpayload() } // sendpayload()

View File

@ -8,7 +8,7 @@ typedef struct {
uint8_t Message[PAYLOAD_BUFFER_SIZE]; uint8_t Message[PAYLOAD_BUFFER_SIZE];
} MessageBuffer_t; } MessageBuffer_t;
void EnqueueSendData(uint8_t port, uint8_t data[], uint8_t size); void SendData(uint8_t port);
void sendPayload(void); void sendPayload(void);
void SendCycleIRQ(void); void SendCycleIRQ(void);
void processSendBuffer(void); void processSendBuffer(void);