commit
39d7c7a24b
@ -436,7 +436,7 @@ Send for example `8386` as Downlink on Port 2 to get battery status and time/dat
|
|||||||
0x09 reset functions (send this command UNconfirmed only to avoid boot loops!)
|
0x09 reset functions (send this command UNconfirmed only to avoid boot loops!)
|
||||||
|
|
||||||
0 = restart device (coldstart)
|
0 = restart device (coldstart)
|
||||||
1 = zeroize MAC counter
|
1 = (reserved, currently does nothing)
|
||||||
2 = reset device to factory settings and restart device
|
2 = reset device to factory settings and restart device
|
||||||
3 = flush send queues
|
3 = flush send queues
|
||||||
4 = restart device (warmstart)
|
4 = restart device (warmstart)
|
||||||
|
@ -18,7 +18,6 @@ extern Ticker cyclicTimer;
|
|||||||
|
|
||||||
void setCyclicIRQ(void);
|
void setCyclicIRQ(void);
|
||||||
void doHousekeeping(void);
|
void doHousekeeping(void);
|
||||||
void reset_counters(void);
|
|
||||||
uint32_t getFreeRAM();
|
uint32_t getFreeRAM();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#ifndef _DISPLAY_H
|
#ifndef _DISPLAY_H
|
||||||
#define _DISPLAY_H
|
#define _DISPLAY_H
|
||||||
|
|
||||||
|
#include <libpax_api.h>
|
||||||
#include "cyclic.h"
|
#include "cyclic.h"
|
||||||
#include "qrcode.h"
|
#include "qrcode.h"
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
|
|
||||||
#define _seconds() millis() / 1000.0
|
#define _seconds() millis() / 1000.0
|
||||||
|
|
||||||
enum timesource_t { _gps, _rtc, _lora, _unsynced };
|
enum timesource_t { _gps, _rtc, _lora, _set, _unsynced };
|
||||||
enum snifftype_t { MAC_SNIFF_WIFI, MAC_SNIFF_BLE, MAC_SNIFF_BLE_ENS };
|
enum snifftype_t { MAC_SNIFF_WIFI, MAC_SNIFF_BLE, MAC_SNIFF_BLE_ENS };
|
||||||
enum runmode_t {
|
enum runmode_t {
|
||||||
RUNMODE_POWERCYCLE,
|
RUNMODE_POWERCYCLE,
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <esp_spi_flash.h> // needed for reading ESP32 chip attributes
|
#include <esp_spi_flash.h> // needed for reading ESP32 chip attributes
|
||||||
#include <esp_event_loop.h> // needed for Wifi event handler
|
#include <esp_event_loop.h> // needed for Wifi event handler
|
||||||
#include <esp32-hal-timer.h> // needed for timers
|
#include <esp32-hal-timer.h> // needed for timers
|
||||||
|
#include <esp_coexist.h> // needed for coex version display
|
||||||
|
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "reset.h"
|
#include "reset.h"
|
||||||
|
@ -89,24 +89,18 @@ void doHousekeeping() {
|
|||||||
|
|
||||||
// check free heap memory
|
// check free heap memory
|
||||||
if (ESP.getMinFreeHeap() <= MEM_LOW) {
|
if (ESP.getMinFreeHeap() <= MEM_LOW) {
|
||||||
ESP_LOGI(TAG,
|
ESP_LOGW(TAG,
|
||||||
"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.getMinFreeHeap(), ESP.getFreeHeap());
|
ESP.getMinFreeHeap(), ESP.getFreeHeap());
|
||||||
reset_counters(); // clear macs container and reset all counters
|
do_reset(true); // memory leak, reset device
|
||||||
|
|
||||||
if (ESP.getMinFreeHeap() <= MEM_LOW) // check again
|
|
||||||
do_reset(true); // memory leak, reset device
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// check free PSRAM memory
|
// check free PSRAM memory
|
||||||
#ifdef BOARD_HAS_PSRAM
|
#ifdef BOARD_HAS_PSRAM
|
||||||
if (ESP.getMinFreePsram() <= MEM_LOW) {
|
if (ESP.getMinFreePsram() <= MEM_LOW) {
|
||||||
ESP_LOGI(TAG, "PSRAM full, counter cleared");
|
ESP_LOGW(TAG, "PSRAM full, counter cleared");
|
||||||
reset_counters(); // clear macs container and reset all counters
|
do_reset(true); // memory leak, reset device
|
||||||
|
|
||||||
if (ESP.getMinFreePsram() <= MEM_LOW) // check again
|
|
||||||
do_reset(true); // memory leak, reset device
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -128,14 +122,4 @@ uint32_t getFreeRAM() {
|
|||||||
#else
|
#else
|
||||||
return ESP.getFreePsram();
|
return ESP.getFreePsram();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset_counters() {
|
|
||||||
|
|
||||||
#if ((WIFICOUNTER) || (BLECOUNTER))
|
|
||||||
#ifdef HAS_DISPLAY
|
|
||||||
dp_plotCurve(0, true);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
|
@ -159,7 +159,7 @@ void dp_init(bool verbose) {
|
|||||||
#if !(BOOTMENU)
|
#if !(BOOTMENU)
|
||||||
delay(8000);
|
delay(8000);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // HAS_LORA
|
#endif // HAS_LORA
|
||||||
|
|
||||||
} // verbose
|
} // verbose
|
||||||
@ -175,12 +175,15 @@ void dp_init(bool verbose) {
|
|||||||
|
|
||||||
void dp_refresh(bool nextPage) {
|
void dp_refresh(bool nextPage) {
|
||||||
|
|
||||||
|
// update counter values from libpax
|
||||||
|
libpax_counter_count(&count_from_libpax);
|
||||||
|
|
||||||
#ifndef HAS_BUTTON
|
#ifndef HAS_BUTTON
|
||||||
static uint32_t framecounter = 0;
|
static uint32_t framecounter = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// update histogram
|
// update histogram
|
||||||
dp_plotCurve(macs.size(), false);
|
dp_plotCurve(count_from_libpax.pax, false);
|
||||||
|
|
||||||
// if display is switched off we don't refresh it to relax cpu
|
// if display is switched off we don't refresh it to relax cpu
|
||||||
if (!DisplayIsOn && (DisplayIsOn == cfg.screenon))
|
if (!DisplayIsOn && (DisplayIsOn == cfg.screenon))
|
||||||
@ -238,7 +241,7 @@ void dp_drawPage(time_t t, bool nextpage) {
|
|||||||
// display number of unique macs total Wifi + BLE
|
// display number of unique macs total Wifi + BLE
|
||||||
if (DisplayPage < 5) {
|
if (DisplayPage < 5) {
|
||||||
dp_setFont(MY_FONT_STRETCHED);
|
dp_setFont(MY_FONT_STRETCHED);
|
||||||
dp_printf("%-5d", macs.size());
|
dp_printf("%-5d", count_from_libpax.pax);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (DisplayPage) {
|
switch (DisplayPage) {
|
||||||
@ -262,7 +265,7 @@ void dp_drawPage(time_t t, bool nextpage) {
|
|||||||
|
|
||||||
#if ((WIFICOUNTER) && (BLECOUNTER))
|
#if ((WIFICOUNTER) && (BLECOUNTER))
|
||||||
if (cfg.wifiscan)
|
if (cfg.wifiscan)
|
||||||
dp_printf("WIFI:%-5d", libpax_macs_wifi);
|
dp_printf("WIFI:%-5d", count_from_libpax.wifi_count);
|
||||||
else
|
else
|
||||||
dp_printf("WIFI:off");
|
dp_printf("WIFI:off");
|
||||||
if (cfg.blescan)
|
if (cfg.blescan)
|
||||||
@ -271,17 +274,17 @@ void dp_drawPage(time_t t, bool nextpage) {
|
|||||||
dp_printf(" CWA:%-5d", cwa_report());
|
dp_printf(" CWA:%-5d", cwa_report());
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
dp_printf("BLTH:%-5d", libpax_macs_ble);
|
dp_printf("BLTH:%-5d", count_from_libpax.ble_count);
|
||||||
else
|
else
|
||||||
dp_printf(" BLTH:off");
|
dp_printf(" BLTH:off");
|
||||||
#elif ((WIFICOUNTER) && (!BLECOUNTER))
|
#elif ((WIFICOUNTER) && (!BLECOUNTER))
|
||||||
if (cfg.wifiscan)
|
if (cfg.wifiscan)
|
||||||
dp_printf("WIFI:%-5d", libpax_macs_wifi);
|
dp_printf("WIFI:%-5d", count_from_libpax.wifi_count);
|
||||||
else
|
else
|
||||||
dp_printf("WIFI:off");
|
dp_printf("WIFI:off");
|
||||||
#elif ((!WIFICOUNTER) && (BLECOUNTER))
|
#elif ((!WIFICOUNTER) && (BLECOUNTER))
|
||||||
if (cfg.blescan)
|
if (cfg.blescan)
|
||||||
dp_printf("BLTH:%-5d", libpax_macs_ble);
|
dp_printf("BLTH:%-5d", count_from_libpax.ble_count);
|
||||||
#if (COUNT_ENS)
|
#if (COUNT_ENS)
|
||||||
if (cfg.enscount)
|
if (cfg.enscount)
|
||||||
dp_printf("(CWA:%d)", cwa_report());
|
dp_printf("(CWA:%d)", cwa_report());
|
||||||
@ -719,6 +722,7 @@ void dp_plotCurve(uint16_t count, bool reset) {
|
|||||||
static uint16_t last_count = 0, col = 0, row = 0;
|
static uint16_t last_count = 0, col = 0, row = 0;
|
||||||
uint16_t v_scroll = 0;
|
uint16_t v_scroll = 0;
|
||||||
|
|
||||||
|
// nothing new to plot? -> then exit early
|
||||||
if ((last_count == count) && !reset)
|
if ((last_count == count) && !reset)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ time_t get_gpstime(uint16_t *msec) {
|
|||||||
t = makeTime(tm);
|
t = makeTime(tm);
|
||||||
|
|
||||||
ESP_LOGD(TAG, "GPS time/date = %02d:%02d:%02d / %02d.%02d.%2d", tm.Hour,
|
ESP_LOGD(TAG, "GPS time/date = %02d:%02d:%02d / %02d.%02d.%2d", tm.Hour,
|
||||||
tm.Minute, tm.Second, tm.Day, tm.Month, tm.Year + 1970);
|
tm.Minute, tm.Second, tm.Day, tm.Month, tm.Year + 1970);
|
||||||
|
|
||||||
// add protocol delay with millisecond precision
|
// add protocol delay with millisecond precision
|
||||||
t += delay_ms / 1000 - 1; // whole seconds
|
t += delay_ms / 1000 - 1; // whole seconds
|
||||||
@ -163,7 +163,8 @@ void gps_loop(void *pvParameters) {
|
|||||||
|
|
||||||
// (only) while device time is not set or unsynched, and we have a valid
|
// (only) while device time is not set or unsynched, and we have a valid
|
||||||
// GPS time, we trigger a device time update to poll time from GPS
|
// GPS time, we trigger a device time update to poll time from GPS
|
||||||
if (timeSource == _unsynced && gpstime.isUpdated()) {
|
if ((timeSource == _unsynced || timeSource == _set) &&
|
||||||
|
gpstime.isUpdated()) {
|
||||||
now();
|
now();
|
||||||
calibrateTime();
|
calibrateTime();
|
||||||
}
|
}
|
||||||
|
@ -76,9 +76,12 @@ void refreshTheMatrixDisplay(bool nextPage) {
|
|||||||
|
|
||||||
if (cfg.countermode == 1)
|
if (cfg.countermode == 1)
|
||||||
|
|
||||||
|
// update counter values from libpax
|
||||||
|
libpax_counter_count(&count_from_libpax);
|
||||||
|
|
||||||
{ // cumulative counter mode -> display total number of pax
|
{ // cumulative counter mode -> display total number of pax
|
||||||
if (ulLastNumMacs != macs.size()) {
|
if (ulLastNumMacs != count_from_libpax.pax) {
|
||||||
ulLastNumMacs = macs.size();
|
ulLastNumMacs = count_from_libpax.pax;
|
||||||
matrix.clear();
|
matrix.clear();
|
||||||
DrawNumber(String(ulLastNumMacs));
|
DrawNumber(String(ulLastNumMacs));
|
||||||
}
|
}
|
||||||
@ -86,10 +89,10 @@ void refreshTheMatrixDisplay(bool nextPage) {
|
|||||||
|
|
||||||
else { // cyclic counter mode -> plot a line diagram
|
else { // cyclic counter mode -> plot a line diagram
|
||||||
|
|
||||||
if (ulLastNumMacs != macs.size()) {
|
if (ulLastNumMacs != count_from_libpax.pax) {
|
||||||
|
|
||||||
// next count cycle?
|
// next count cycle?
|
||||||
if (macs.size() == 0) {
|
if (count_from_libpax.pax == 0) {
|
||||||
|
|
||||||
// matrix full? then scroll left 1 dot, else increment column
|
// matrix full? then scroll left 1 dot, else increment column
|
||||||
if (col < (LED_MATRIX_WIDTH - 1))
|
if (col < (LED_MATRIX_WIDTH - 1))
|
||||||
@ -101,7 +104,7 @@ void refreshTheMatrixDisplay(bool nextPage) {
|
|||||||
matrix.drawPoint(col, row, 0); // clear current dot
|
matrix.drawPoint(col, row, 0); // clear current dot
|
||||||
|
|
||||||
// scale and set new dot
|
// scale and set new dot
|
||||||
ulLastNumMacs = macs.size();
|
ulLastNumMacs = count_from_libpax.pax;
|
||||||
level = ulLastNumMacs / LINE_DIAGRAM_DIVIDER;
|
level = ulLastNumMacs / LINE_DIAGRAM_DIVIDER;
|
||||||
row = level <= LED_MATRIX_HEIGHT
|
row = level <= LED_MATRIX_HEIGHT
|
||||||
? LED_MATRIX_HEIGHT - 1 - level % LED_MATRIX_HEIGHT
|
? LED_MATRIX_HEIGHT - 1 - level % LED_MATRIX_HEIGHT
|
||||||
|
@ -16,9 +16,8 @@ void set_reset(uint8_t val[]) {
|
|||||||
ESP_LOGI(TAG, "Remote command: restart device cold");
|
ESP_LOGI(TAG, "Remote command: restart device cold");
|
||||||
do_reset(false);
|
do_reset(false);
|
||||||
break;
|
break;
|
||||||
case 1: // reset MAC counter
|
case 1: // reserved
|
||||||
ESP_LOGI(TAG, "Remote command: reset MAC counter");
|
// reset MAC counter deprecated by libpax integration
|
||||||
reset_counters(); // clear macs
|
|
||||||
break;
|
break;
|
||||||
case 2: // reset device to factory settings
|
case 2: // reset device to factory settings
|
||||||
ESP_LOGI(TAG,
|
ESP_LOGI(TAG,
|
||||||
@ -132,7 +131,6 @@ void set_countmode(uint8_t val[]) {
|
|||||||
"Remote command: set counter mode called with invalid parameter(s)");
|
"Remote command: set counter mode called with invalid parameter(s)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
reset_counters(); // clear macs
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_screensaver(uint8_t val[]) {
|
void set_screensaver(uint8_t val[]) {
|
||||||
@ -378,7 +376,7 @@ void set_time(uint8_t val[]) {
|
|||||||
// swap byte order from msb to lsb, note: this is a platform dependent hack
|
// swap byte order from msb to lsb, note: this is a platform dependent hack
|
||||||
uint32_t t = __builtin_bswap32(*(uint32_t *)(val));
|
uint32_t t = __builtin_bswap32(*(uint32_t *)(val));
|
||||||
ESP_LOGI(TAG, "Remote command: set time to %d", t);
|
ESP_LOGI(TAG, "Remote command: set time to %d", t);
|
||||||
setMyTime(t, 0, _unsynced);
|
setMyTime(t, 0, _set);
|
||||||
};
|
};
|
||||||
|
|
||||||
void set_flush(uint8_t val[]) {
|
void set_flush(uint8_t val[]) {
|
||||||
|
@ -88,7 +88,8 @@ void sendData() {
|
|||||||
ESP_LOGI(TAG, "Sending libpax wifi count: %d", libpax_macs_wifi);
|
ESP_LOGI(TAG, "Sending libpax wifi count: %d", libpax_macs_wifi);
|
||||||
payload.addCount(libpax_macs_wifi, 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);
|
ESP_LOGI(TAG, "Sending libpax ble count: %d",
|
||||||
|
libpax_macs_ble);
|
||||||
payload.addCount(libpax_macs_ble, MAC_SNIFF_BLE);
|
payload.addCount(libpax_macs_ble, MAC_SNIFF_BLE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -114,14 +115,8 @@ void sendData() {
|
|||||||
payload.addSDS(sds_status);
|
payload.addSDS(sds_status);
|
||||||
#endif
|
#endif
|
||||||
SendPayload(COUNTERPORT);
|
SendPayload(COUNTERPORT);
|
||||||
// clear counter if not in cumulative counter mode
|
|
||||||
if (cfg.countermode != 1) {
|
|
||||||
reset_counters(); // clear macs container and reset all counters
|
|
||||||
ESP_LOGI(TAG, "Counter cleared");
|
|
||||||
}
|
|
||||||
#ifdef HAS_DISPLAY
|
#ifdef HAS_DISPLAY
|
||||||
else
|
dp_plotCurve(libpax_macs_ble + libpax_macs_wifi, true);
|
||||||
dp_plotCurve(macs.size(), true);
|
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
static const char TAG[] = __FILE__;
|
static const char TAG[] = __FILE__;
|
||||||
|
|
||||||
// symbol to display current time source
|
// symbol to display current time source
|
||||||
const char timeSetSymbols[] = {'G', 'R', 'L', '?'};
|
const char timeSetSymbols[] = {'G', 'R', 'L', 'S', '?'};
|
||||||
|
|
||||||
#ifdef HAS_IF482
|
#ifdef HAS_IF482
|
||||||
#if (HAS_SDS011)
|
#if (HAS_SDS011)
|
||||||
|
Loading…
Reference in New Issue
Block a user