sanitze libpax integration (volatile vars removed)

This commit is contained in:
cyberman54 2022-02-13 16:00:01 +01:00
parent 2dd9a4701b
commit 8e4fe93069
7 changed files with 21 additions and 24 deletions

View File

@ -8,6 +8,6 @@
void init_libpax(void); 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 #endif

View File

@ -7,6 +7,8 @@
#include <esp_coexist.h> // needed for coex version display #include <esp_coexist.h> // needed for coex version display
#include <esp_wifi.h> // needed for wifi init / deinit #include <esp_wifi.h> // needed for wifi init / deinit
#include <libpax_helpers.h>
#include "globals.h" #include "globals.h"
#include "reset.h" #include "reset.h"
#include "i2c.h" #include "i2c.h"
@ -19,7 +21,6 @@
#include "lorawan.h" #include "lorawan.h"
#include "timekeeper.h" #include "timekeeper.h"
#include "boot.h" #include "boot.h"
#include "libpax_helpers.h"
#include "power.h" #include "power.h"
#include "antenna.h" #include "antenna.h"

View File

@ -3,6 +3,7 @@
#include <rom/rtc.h> #include <rom/rtc.h>
#include "libpax_helpers.h"
#include "senddata.h" #include "senddata.h"
#include "cyclic.h" #include "cyclic.h"
#include "configmanager.h" #include "configmanager.h"

View File

@ -1,7 +1,6 @@
#ifndef _SENDDATA_H #ifndef _SENDDATA_H
#define _SENDDATA_H #define _SENDDATA_H
#include "libpax_helpers.h"
#include "spislave.h" #include "spislave.h"
#include "mqttclient.h" #include "mqttclient.h"
#include "cyclic.h" #include "cyclic.h"
@ -18,6 +17,7 @@ void checkSendQueues(void);
void flushQueues(void); void flushQueues(void);
bool allQueuesEmtpy(void); bool allQueuesEmtpy(void);
void setSendIRQ(TimerHandle_t xTimer = NULL); void setSendIRQ(TimerHandle_t xTimer = NULL);
void setSendIRQ(void);
void initSendDataTimer(uint8_t sendcycle); void initSendDataTimer(uint8_t sendcycle);
#endif // _SENDDATA_H_ #endif // _SENDDATA_H_

View File

@ -5,18 +5,9 @@ static const char TAG[] = __FILE__;
// libpax payload // libpax payload
struct count_payload_t count_from_libpax; 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) { 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); cfg.countermode);
libpax_counter_start(); libpax_counter_start();
} }

View File

@ -1,7 +1,6 @@
// Basic Config // Basic Config
#include "globals.h" #include "globals.h"
#include "rcommand.h" #include "rcommand.h"
#include "libpax_helpers.h"
// Local logging tag // Local logging tag
static const char TAG[] = __FILE__; static const char TAG[] = __FILE__;

View File

@ -5,6 +5,10 @@ void setSendIRQ(TimerHandle_t xTimer) {
xTaskNotify(irqHandlerTask, SENDCYCLE_IRQ, eSetBits); xTaskNotify(irqHandlerTask, SENDCYCLE_IRQ, eSetBits);
} }
#if ((WIFICOUNTER) || (BLECOUNTER))
void setSendIRQ(void) { setSendIRQ(NULL); }
#endif
void initSendDataTimer(uint8_t sendcycle) { void initSendDataTimer(uint8_t sendcycle) {
static TimerHandle_t SendDataTimer = NULL; static TimerHandle_t SendDataTimer = NULL;
@ -79,6 +83,10 @@ void sendData() {
sdsStatus_t sds_status; sdsStatus_t sds_status;
#endif #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) { while (bitmask) {
switch (bitmask & mask) { switch (bitmask & mask) {
@ -86,11 +94,9 @@ void sendData() {
case COUNT_DATA: case COUNT_DATA:
payload.reset(); payload.reset();
#if !(PAYLOAD_OPENSENSEBOX) #if !(PAYLOAD_OPENSENSEBOX)
ESP_LOGI(TAG, "Sending libpax wifi count: %d", libpax_macs_wifi); payload.addCount(count_from_libpax.wifi_count, MAC_SNIFF_WIFI);
payload.addCount(libpax_macs_wifi, MAC_SNIFF_WIFI);
if (cfg.blescan) { if (cfg.blescan) {
ESP_LOGI(TAG, "Sending libpax ble count: %d", libpax_macs_ble); payload.addCount(count_from_libpax.ble_count, MAC_SNIFF_BLE);
payload.addCount(libpax_macs_ble, MAC_SNIFF_BLE);
} }
#endif #endif
#if (HAS_GPS) #if (HAS_GPS)
@ -104,11 +110,9 @@ void sendData() {
} }
#endif #endif
#if (PAYLOAD_OPENSENSEBOX) #if (PAYLOAD_OPENSENSEBOX)
ESP_LOGI(TAG, "Sending libpax wifi count: %d", libpax_macs_wifi); payload.addCount(count_from_libpax.wifi_count, MAC_SNIFF_WIFI);
payload.addCount(libpax_macs_wifi, MAC_SNIFF_WIFI);
if (cfg.blescan) { if (cfg.blescan) {
ESP_LOGI(TAG, "Sending libpax ble count: %d", libpax_macs_ble); payload.addCount(count_from_libpax.ble_count, MAC_SNIFF_BLE);
payload.addCount(libpax_macs_ble, MAC_SNIFF_BLE);
#endif #endif
#if (HAS_SDS011) #if (HAS_SDS011)
sds011_store(&sds_status); sds011_store(&sds_status);
@ -116,10 +120,11 @@ void sendData() {
#endif #endif
SendPayload(COUNTERPORT); SendPayload(COUNTERPORT);
#ifdef HAS_DISPLAY #ifdef HAS_DISPLAY
dp_plotCurve(libpax_macs_ble + libpax_macs_wifi, true); dp_plotCurve(count_from_libpax.pax, true);
#endif #endif
#if (HAS_SDCARD) #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) #if (defined BAT_MEASURE_ADC || defined HAS_PMU)
, ,
read_voltage() read_voltage()