diff --git a/include/libpax_helpers.h b/include/libpax_helpers.h index 74be26a4..aee1e1c4 100644 --- a/include/libpax_helpers.h +++ b/include/libpax_helpers.h @@ -8,6 +8,6 @@ void init_libpax(void); -extern uint16_t volatile libpax_macs_ble, libpax_macs_wifi; // libpax values +extern struct count_payload_t count_from_libpax; // libpax count storage #endif \ No newline at end of file diff --git a/include/main.h b/include/main.h index 6fa72b11..824b020e 100644 --- a/include/main.h +++ b/include/main.h @@ -7,6 +7,8 @@ #include // needed for coex version display #include // needed for wifi init / deinit +#include + #include "globals.h" #include "reset.h" #include "i2c.h" @@ -19,7 +21,6 @@ #include "lorawan.h" #include "timekeeper.h" #include "boot.h" -#include "libpax_helpers.h" #include "power.h" #include "antenna.h" diff --git a/include/rcommand.h b/include/rcommand.h index 0cdb23c6..d842fdef 100644 --- a/include/rcommand.h +++ b/include/rcommand.h @@ -3,6 +3,7 @@ #include +#include "libpax_helpers.h" #include "senddata.h" #include "cyclic.h" #include "configmanager.h" diff --git a/include/senddata.h b/include/senddata.h index 6c44dfa7..94392c42 100644 --- a/include/senddata.h +++ b/include/senddata.h @@ -1,7 +1,6 @@ #ifndef _SENDDATA_H #define _SENDDATA_H -#include "libpax_helpers.h" #include "spislave.h" #include "mqttclient.h" #include "cyclic.h" @@ -18,6 +17,7 @@ void checkSendQueues(void); void flushQueues(void); bool allQueuesEmtpy(void); void setSendIRQ(TimerHandle_t xTimer = NULL); +void setSendIRQ(void); void initSendDataTimer(uint8_t sendcycle); #endif // _SENDDATA_H_ diff --git a/src/libpax_helpers.cpp b/src/libpax_helpers.cpp index 9883648c..937dfd04 100644 --- a/src/libpax_helpers.cpp +++ b/src/libpax_helpers.cpp @@ -5,18 +5,9 @@ static const char TAG[] = __FILE__; // libpax payload struct count_payload_t count_from_libpax; -uint16_t volatile libpax_macs_ble, libpax_macs_wifi; - -void process_count(void) { - ESP_LOGD(TAG, "pax: %d / %d / %d", count_from_libpax.pax, - count_from_libpax.wifi_count, count_from_libpax.ble_count); - libpax_macs_ble = count_from_libpax.ble_count; - libpax_macs_wifi = count_from_libpax.wifi_count; - setSendIRQ(); -} void init_libpax(void) { - libpax_counter_init(process_count, &count_from_libpax, cfg.sendcycle * 2, + libpax_counter_init(setSendIRQ, &count_from_libpax, cfg.sendcycle * 2, cfg.countermode); libpax_counter_start(); } \ No newline at end of file diff --git a/src/rcommand.cpp b/src/rcommand.cpp index fe333b1f..71c6f453 100644 --- a/src/rcommand.cpp +++ b/src/rcommand.cpp @@ -1,7 +1,6 @@ // Basic Config #include "globals.h" #include "rcommand.h" -#include "libpax_helpers.h" // Local logging tag static const char TAG[] = __FILE__; diff --git a/src/senddata.cpp b/src/senddata.cpp index 9b7a5e57..0016f11b 100644 --- a/src/senddata.cpp +++ b/src/senddata.cpp @@ -5,6 +5,10 @@ void setSendIRQ(TimerHandle_t xTimer) { xTaskNotify(irqHandlerTask, SENDCYCLE_IRQ, eSetBits); } +#if ((WIFICOUNTER) || (BLECOUNTER)) +void setSendIRQ(void) { setSendIRQ(NULL); } +#endif + void initSendDataTimer(uint8_t sendcycle) { static TimerHandle_t SendDataTimer = NULL; @@ -79,6 +83,10 @@ void sendData() { sdsStatus_t sds_status; #endif + ESP_LOGD(TAG, "Sending count results: pax=%d / wifi=%d / ble=%d", + count_from_libpax.pax, count_from_libpax.wifi_count, + count_from_libpax.ble_count); + while (bitmask) { switch (bitmask & mask) { @@ -86,11 +94,9 @@ void sendData() { case COUNT_DATA: payload.reset(); #if !(PAYLOAD_OPENSENSEBOX) - ESP_LOGI(TAG, "Sending libpax wifi count: %d", libpax_macs_wifi); - payload.addCount(libpax_macs_wifi, MAC_SNIFF_WIFI); + payload.addCount(count_from_libpax.wifi_count, MAC_SNIFF_WIFI); if (cfg.blescan) { - ESP_LOGI(TAG, "Sending libpax ble count: %d", libpax_macs_ble); - payload.addCount(libpax_macs_ble, MAC_SNIFF_BLE); + payload.addCount(count_from_libpax.ble_count, MAC_SNIFF_BLE); } #endif #if (HAS_GPS) @@ -104,11 +110,9 @@ void sendData() { } #endif #if (PAYLOAD_OPENSENSEBOX) - ESP_LOGI(TAG, "Sending libpax wifi count: %d", libpax_macs_wifi); - payload.addCount(libpax_macs_wifi, MAC_SNIFF_WIFI); + payload.addCount(count_from_libpax.wifi_count, MAC_SNIFF_WIFI); if (cfg.blescan) { - ESP_LOGI(TAG, "Sending libpax ble count: %d", libpax_macs_ble); - payload.addCount(libpax_macs_ble, MAC_SNIFF_BLE); + payload.addCount(count_from_libpax.ble_count, MAC_SNIFF_BLE); #endif #if (HAS_SDS011) sds011_store(&sds_status); @@ -116,10 +120,11 @@ void sendData() { #endif SendPayload(COUNTERPORT); #ifdef HAS_DISPLAY - dp_plotCurve(libpax_macs_ble + libpax_macs_wifi, true); + dp_plotCurve(count_from_libpax.pax, true); #endif #if (HAS_SDCARD) - sdcardWriteData(libpax_macs_wifi, libpax_macs_ble + sdcardWriteData(count_from_libpax.wifi_count, + count_from_libpax.ble_count #if (defined BAT_MEASURE_ADC || defined HAS_PMU) , read_voltage()