From 4ef3ebb0bf667d0fa27e25e0a74dabc2ae0060ad Mon Sep 17 00:00:00 2001 From: Davide Nesi Date: Thu, 7 Mar 2019 14:57:21 +0100 Subject: [PATCH 1/7] Update paxcounter.conf --- src/paxcounter.conf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/paxcounter.conf b/src/paxcounter.conf index ccf18ca1..e6c71df7 100644 --- a/src/paxcounter.conf +++ b/src/paxcounter.conf @@ -7,14 +7,14 @@ #define PRODUCTNAME "PAXCNT" // Verbose enables serial output -#define VERBOSE 1 // comment out to silence the device, for mute use build option +#define VERBOSE 1 // set to 0 to silence the device, for mute use build option // Payload send cycle and encoding #define SENDCYCLE 30 // payload send cycle [seconds/2], 0 .. 255 #define PAYLOAD_ENCODER 2 // payload encoder: 1=Plain, 2=Packed, 3=Cayenne LPP dynamic, 4=Cayenne LPP packed // Set this to include BLE counting and vendor filter functions -#define VENDORFILTER 1 // comment out if you want to count things, not people +#define VENDORFILTER 1 // set to 0 if you want to count things, not people #define BLECOUNTER 1 // activate if you want to use BLE count, at expense of memory // BLE scan parameters @@ -59,7 +59,7 @@ #define STATE_SAVE_PERIOD UINT32_C(360 * 60 * 1000) // update every 360 minutes = 4 times a day // OTA settings -#define USE_OTA 1 // Comment out to disable OTA update +#define USE_OTA 1 // set to 0 to disable OTA update #define WIFI_MAX_TRY 5 // maximum number of wifi connect attempts for OTA update [default = 20] #define OTA_MAX_TRY 5 // maximum number of attempts for OTA download and write to flash [default = 3] #define OTA_MIN_BATT 3600 // minimum battery level for OTA [millivolt] From 67073577e6df51765bafe76ae0995c23dc6c1fe8 Mon Sep 17 00:00:00 2001 From: Davide Nesi Date: Thu, 7 Mar 2019 14:58:28 +0100 Subject: [PATCH 2/7] Update cyclic.cpp --- src/cyclic.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cyclic.cpp b/src/cyclic.cpp index 26f86eb4..85caef4e 100644 --- a/src/cyclic.cpp +++ b/src/cyclic.cpp @@ -117,7 +117,7 @@ void reset_counters() { macs_ble = 0; } -#ifndef VERBOSE +#if(VERBOSE) int redirect_log(const char *fmt, va_list args) { // do nothing return 0; From fba9529844ca4e65dc2ad0f7546a99767d8a8a15 Mon Sep 17 00:00:00 2001 From: Davide Nesi Date: Thu, 7 Mar 2019 14:59:11 +0100 Subject: [PATCH 3/7] Update display.cpp --- src/display.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/display.cpp b/src/display.cpp index 4abed281..9eaed50e 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -89,7 +89,7 @@ void init_display(const char *Productname, const char *Version) { #endif // Display chip information -#ifdef VERBOSE +#if(VERBOSE) esp_chip_info_t chip_info; esp_chip_info(&chip_info); u8x8.printf("ESP32 %d cores\nWiFi%s%s\n", chip_info.cores, @@ -240,4 +240,4 @@ void refreshtheDisplay() { } // mutex } // refreshDisplay() -#endif // HAS_DISPLAY \ No newline at end of file +#endif // HAS_DISPLAY From 4e81e572a82bf72d49946f126e4db2751b550dd9 Mon Sep 17 00:00:00 2001 From: Davide Nesi Date: Thu, 7 Mar 2019 14:59:34 +0100 Subject: [PATCH 4/7] Update lorawan.cpp --- src/lorawan.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lorawan.cpp b/src/lorawan.cpp index 0de146d8..a249ac05 100644 --- a/src/lorawan.cpp +++ b/src/lorawan.cpp @@ -155,7 +155,7 @@ void get_hard_deveui(uint8_t *pdeveui) { #endif // MCP 24AA02E64 } -#ifdef VERBOSE +#if(VERBOSE) // Display OTAA keys void showLoraKeys(void) { @@ -479,4 +479,4 @@ void user_request_network_time_callback(void *pVoidUserUTCTime, ESP_LOGI(TAG, "Invalid time received from LoRa"); } // user_request_network_time_callback -#endif // HAS_LORA \ No newline at end of file +#endif // HAS_LORA From 3f4583286446dacb02c05b42087f9234192bffec Mon Sep 17 00:00:00 2001 From: Davide Nesi Date: Thu, 7 Mar 2019 15:00:11 +0100 Subject: [PATCH 5/7] Update main.cpp --- src/main.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 8c9bb371..a44982cb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -124,7 +124,7 @@ void setup() { #endif // setup debug output or silence device -#ifdef VERBOSE +#if(VERBOSE) Serial.begin(115200); esp_log_level_set("*", ESP_LOG_VERBOSE); #else @@ -136,7 +136,7 @@ void setup() { ESP_LOGI(TAG, "Starting %s v%s", PRODUCTNAME, PROGVERSION); // print chip information on startup if in verbose mode -#ifdef VERBOSE +#if(VERBOSE) esp_chip_info_t chip_info; esp_chip_info(&chip_info); ESP_LOGI(TAG, @@ -230,7 +230,7 @@ void setup() { batt_voltage = read_voltage(); #endif -#ifdef USE_OTA +#if(USE_OTA) strcat_P(features, " OTA"); // reboot to firmware update mode if ota trigger switch is set if (cfg.runmode == 1) { @@ -307,7 +307,7 @@ void setup() { assert(spi_init() == ESP_OK); #endif -#ifdef VENDORFILTER +#if(VENDORFILTER) strcat_P(features, " OUIFLT"); #endif @@ -348,7 +348,7 @@ void setup() { #ifdef HAS_LORA // output LoRaWAN keys to console -#ifdef VERBOSE +#if(VERBOSE) showLoraKeys(); #endif #endif @@ -441,4 +441,4 @@ void loop() { } vTaskDelete(NULL); // shoud never be reached -} \ No newline at end of file +} From 16eb8faaa8f3e12761818f15d4598fd52ad1d0b5 Mon Sep 17 00:00:00 2001 From: Davide Nesi Date: Thu, 7 Mar 2019 15:05:52 +0100 Subject: [PATCH 6/7] Add files via upload --- src/blecsan.cpp | 8 ++++---- src/display.cpp | 6 +++--- src/lorawan.cpp | 2 +- src/macsniff.cpp | 10 +++++----- src/main.cpp | 4 ++-- src/paxcounter.conf | 2 +- src/rcommand.cpp | 2 +- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/blecsan.cpp b/src/blecsan.cpp index 1e3d0d2d..1931c788 100644 --- a/src/blecsan.cpp +++ b/src/blecsan.cpp @@ -146,7 +146,7 @@ IRAM_ATTR void gap_callback_handler(esp_gap_ble_cb_event_t event, break; } -#ifdef VENDORFILTER +#if(VENDORFILTER) if ((p->scan_rst.ble_addr_type == BLE_ADDR_TYPE_RANDOM) || (p->scan_rst.ble_addr_type == BLE_ADDR_TYPE_RPA_RANDOM)) { @@ -210,7 +210,7 @@ esp_err_t register_ble_callback(void) { .scan_type = BLE_SCAN_TYPE_PASSIVE, .own_addr_type = BLE_ADDR_TYPE_RANDOM, -#ifdef VENDORFILTER +#if(VENDORFILTER) .scan_filter_policy = BLE_SCAN_FILTER_ALLOW_WLIST_PRA_DIR, // ADV_IND, ADV_NONCONN_IND, ADV_SCAN_IND packets are used for broadcasting // data in broadcast applications (e.g., Beacons), so we don't want them in @@ -234,7 +234,7 @@ esp_err_t register_ble_callback(void) { } // register_ble_callback void start_BLEscan(void) { -#ifdef BLECOUNTER +#if(BLECOUNTER) ESP_LOGI(TAG, "Initializing bluetooth scanner ..."); ESP_ERROR_CHECK(esp_coex_preference_set( @@ -254,7 +254,7 @@ void start_BLEscan(void) { } // start_BLEscan void stop_BLEscan(void) { -#ifdef BLECOUNTER +#if(BLECOUNTER) ESP_LOGI(TAG, "Shutting down bluetooth scanner ..."); ESP_ERROR_CHECK(esp_ble_gap_register_callback(NULL)); ESP_ERROR_CHECK(esp_bluedroid_disable()); diff --git a/src/display.cpp b/src/display.cpp index 9eaed50e..80d206e7 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -114,7 +114,7 @@ void init_display(const char *Productname, const char *Version) { u8x8.clear(); u8x8.setPowerSave(!cfg.screenon); // set display off if disabled u8x8.draw2x2String(0, 0, "PAX:0"); -#ifdef BLECOUNTER +#if(BLECOUNTER) u8x8.setCursor(0, 3); u8x8.printf("BLTH:0"); #endif @@ -178,7 +178,7 @@ void refreshtheDisplay() { #endif // update bluetooth counter + LoRa SF (line 3) -#ifdef BLECOUNTER +#if(BLECOUNTER) u8x8.setCursor(0, 3); if (cfg.blescan) u8x8.printf("BLTH:%-5d", macs_ble); @@ -240,4 +240,4 @@ void refreshtheDisplay() { } // mutex } // refreshDisplay() -#endif // HAS_DISPLAY +#endif // HAS_DISPLAY \ No newline at end of file diff --git a/src/lorawan.cpp b/src/lorawan.cpp index a249ac05..5d11a79e 100644 --- a/src/lorawan.cpp +++ b/src/lorawan.cpp @@ -479,4 +479,4 @@ void user_request_network_time_callback(void *pVoidUserUTCTime, ESP_LOGI(TAG, "Invalid time received from LoRa"); } // user_request_network_time_callback -#endif // HAS_LORA +#endif // HAS_LORA \ No newline at end of file diff --git a/src/macsniff.cpp b/src/macsniff.cpp index c98761cb..cd20e39a 100644 --- a/src/macsniff.cpp +++ b/src/macsniff.cpp @@ -2,7 +2,7 @@ // Basic Config #include "globals.h" -#ifdef VENDORFILTER +#if(VENDORFILTER) #include "vendor_array.h" #endif @@ -49,7 +49,7 @@ bool mac_add(uint8_t *paddr, int8_t rssi, bool sniff_type) { int8_t beaconID; // beacon number in test monitor mode uint16_t hashedmac; // temporary buffer for generated hash value uint32_t addr2int; // temporary buffer for shortened MAC -#ifdef VENDORFILTER +#if(VENDORFILTER) uint32_t vendor2int; // temporary buffer for Vendor OUI #endif @@ -58,7 +58,7 @@ bool mac_add(uint8_t *paddr, int8_t rssi, bool sniff_type) { addr2int = ((uint32_t)paddr[2]) | ((uint32_t)paddr[3] << 8) | ((uint32_t)paddr[4] << 16) | ((uint32_t)paddr[5] << 24); -#ifdef VENDORFILTER +#if(VENDORFILTER) vendor2int = ((uint32_t)paddr[2]) | ((uint32_t)paddr[1] << 8) | ((uint32_t)paddr[0] << 16); // use OUI vendor filter list only on Wifi, not on BLE @@ -88,7 +88,7 @@ bool mac_add(uint8_t *paddr, int8_t rssi, bool sniff_type) { blink_LED(COLOR_GREEN, 50); #endif } -#ifdef BLECOUNTER +#if(BLECOUNTER) else if (sniff_type == MAC_SNIFF_BLE) { macs_ble++; // increment BLE Macs counter #if (HAS_LED != NOT_A_PIN) || defined(HAS_RGB_LED) @@ -121,7 +121,7 @@ bool mac_add(uint8_t *paddr, int8_t rssi, bool sniff_type) { sniff_type == MAC_SNIFF_WIFI ? "WiFi" : "BLTH", rssi, buff, hashedmac, macs_wifi, macs_ble, getFreeRAM()); -#ifdef VENDORFILTER +#if(VENDORFILTER) } else { // Very noisy // ESP_LOGD(TAG, "Filtered MAC %02X:%02X:%02X:%02X:%02X:%02X", diff --git a/src/main.cpp b/src/main.cpp index a44982cb..d23eb286 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -242,7 +242,7 @@ void setup() { // start BLE scan callback if BLE function is enabled in NVRAM configuration // or switch off bluetooth, if not compiled -#ifdef BLECOUNTER +#if(BLECOUNTER) strcat_P(features, " BLE"); if (cfg.blescan) { ESP_LOGI(TAG, "Starting Bluetooth..."); @@ -441,4 +441,4 @@ void loop() { } vTaskDelete(NULL); // shoud never be reached -} +} \ No newline at end of file diff --git a/src/paxcounter.conf b/src/paxcounter.conf index e6c71df7..f8265eb6 100644 --- a/src/paxcounter.conf +++ b/src/paxcounter.conf @@ -15,7 +15,7 @@ // Set this to include BLE counting and vendor filter functions #define VENDORFILTER 1 // set to 0 if you want to count things, not people -#define BLECOUNTER 1 // activate if you want to use BLE count, at expense of memory +#define BLECOUNTER 1 // set it to 1 if you want to use BLE count, at expense of memory // BLE scan parameters #define BLESCANTIME 0 // [seconds] scan duration, 0 means infinite [default], see note below diff --git a/src/rcommand.cpp b/src/rcommand.cpp index 5a4718cf..df793445 100644 --- a/src/rcommand.cpp +++ b/src/rcommand.cpp @@ -38,7 +38,7 @@ void set_reset(uint8_t val[]) { break; case 9: // reset and ask for software update via Wifi OTA ESP_LOGI(TAG, "Remote command: software update via Wifi"); -#ifdef USE_OTA +#if(USE_OTA) sprintf(display_line6, "Software update"); cfg.runmode = 1; #else From 9fcf374de01527172677de7730bac28c01ff790d Mon Sep 17 00:00:00 2001 From: Verkehrsrot Date: Thu, 7 Mar 2019 21:30:09 +0100 Subject: [PATCH 7/7] v1.7.36 (issue #250) --- include/cyclic.h | 1 - include/lorawan.h | 2 +- include/rcommand.h | 2 +- platformio.ini | 2 +- src/cyclic.cpp | 9 +-------- src/lorawan.cpp | 2 +- src/main.cpp | 19 +++---------------- src/paxcounter.conf | 6 +++--- src/rcommand.cpp | 2 +- src/timekeeper.cpp | 4 ++-- 10 files changed, 14 insertions(+), 35 deletions(-) diff --git a/include/cyclic.h b/include/cyclic.h index c4234c38..ffdee8f5 100644 --- a/include/cyclic.h +++ b/include/cyclic.h @@ -17,7 +17,6 @@ void housekeeping(void); void doHousekeeping(void); uint64_t uptime(void); void reset_counters(void); -int redirect_log(const char *fmt, va_list args); uint32_t getFreeRAM(); #endif \ No newline at end of file diff --git a/include/lorawan.h b/include/lorawan.h index 3726f030..58aa362c 100644 --- a/include/lorawan.h +++ b/include/lorawan.h @@ -4,7 +4,7 @@ #include "globals.h" #include "rcommand.h" #include "timekeeper.h" -#ifdef DBTIMESYNC +#if(DBTIMESYNC) #include "DBtimesync.h" #endif diff --git a/include/rcommand.h b/include/rcommand.h index 68227755..9eb06384 100644 --- a/include/rcommand.h +++ b/include/rcommand.h @@ -9,7 +9,7 @@ #include #include "cyclic.h" #include "timekeeper.h" -#ifdef DBTIMESYNC +#if(DBTIMESYNC) #include "DBtimesync.h" #endif diff --git a/platformio.ini b/platformio.ini index 180e110f..47ca6e73 100644 --- a/platformio.ini +++ b/platformio.ini @@ -30,7 +30,7 @@ description = Paxcounter is a proof-of-concept ESP32 device for metering passeng [common] ; for release_version use max. 10 chars total, use any decimal format like "a.b.c" -release_version = 1.7.35 +release_version = 1.7.36 ; DEBUG LEVEL: For production run set to 0, otherwise device will leak RAM while running! ; 0=None, 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Verbose debug_level = 3 diff --git a/src/cyclic.cpp b/src/cyclic.cpp index 85caef4e..8899d05b 100644 --- a/src/cyclic.cpp +++ b/src/cyclic.cpp @@ -115,11 +115,4 @@ void reset_counters() { macs_total = 0; // reset all counters macs_wifi = 0; macs_ble = 0; -} - -#if(VERBOSE) -int redirect_log(const char *fmt, va_list args) { - // do nothing - return 0; -} -#endif +} \ No newline at end of file diff --git a/src/lorawan.cpp b/src/lorawan.cpp index 5d11a79e..04fb0fb6 100644 --- a/src/lorawan.cpp +++ b/src/lorawan.cpp @@ -225,7 +225,7 @@ void onEvent(ev_t ev) { case EV_TXCOMPLETE: -#ifdef DBTIMESYNC +#if(DBTIMESYNC) if (!(LMIC.txrxFlags & TXRX_ACK) && time_sync_seqNo) time_sync_messages[time_sync_seqNo - 1] = LMIC.txend; #endif diff --git a/src/main.cpp b/src/main.cpp index d23eb286..559f7139 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -105,9 +105,6 @@ static const char TAG[] = __FILE__; void setup() { - // disable the default wifi logging - esp_log_level_set("wifi", ESP_LOG_NONE); - char features[100] = ""; // create some semaphores for syncing / mutexing tasks @@ -130,7 +127,6 @@ void setup() { #else // mute logs completely by redirecting them to silence function esp_log_level_set("*", ESP_LOG_NONE); - esp_log_set_vprintf(redirect_log); #endif ESP_LOGI(TAG, "Starting %s v%s", PRODUCTNAME, PROGVERSION); @@ -162,13 +158,14 @@ void setup() { #ifdef HAS_LORA ESP_LOGI(TAG, "IBM LMIC version %d.%d.%d", LMIC_VERSION_MAJOR, LMIC_VERSION_MINOR, LMIC_VERSION_BUILD); - ESP_LOGI(TAG, "Arduino LMIC version %d.%d.%d.%d", ARDUINO_LMIC_VERSION_GET_MAJOR(ARDUINO_LMIC_VERSION), ARDUINO_LMIC_VERSION_GET_MINOR(ARDUINO_LMIC_VERSION), ARDUINO_LMIC_VERSION_GET_PATCH(ARDUINO_LMIC_VERSION), ARDUINO_LMIC_VERSION_GET_LOCAL(ARDUINO_LMIC_VERSION)); -#endif + ESP_LOGI(TAG, "DEVEUI: "); + showLoraKeys(); +#endif // HAS_LORA #ifdef HAS_GPS ESP_LOGI(TAG, "TinyGPS+ version %s", TinyGPSPlus::libraryVersion()); @@ -251,10 +248,7 @@ void setup() { btStop(); #else // remove bluetooth stack to gain more free memory - ESP_ERROR_CHECK(esp_bluedroid_disable()); - ESP_ERROR_CHECK(esp_bluedroid_deinit()); btStop(); - ESP_ERROR_CHECK(esp_bt_controller_deinit()); ESP_ERROR_CHECK(esp_bt_mem_release(ESP_BT_MODE_BTDM)); ESP_ERROR_CHECK(esp_coex_preference_set(( esp_coex_prefer_t)ESP_COEX_PREFER_WIFI)); // configure Wifi/BT coexist lib @@ -346,13 +340,6 @@ void setup() { // show compiled features ESP_LOGI(TAG, "Features:%s", features); -#ifdef HAS_LORA -// output LoRaWAN keys to console -#if(VERBOSE) - showLoraKeys(); -#endif -#endif - // start wifi in monitor mode and start channel rotation timer ESP_LOGI(TAG, "Starting Wifi..."); wifi_sniffer_init(); diff --git a/src/paxcounter.conf b/src/paxcounter.conf index f8265eb6..9f275469 100644 --- a/src/paxcounter.conf +++ b/src/paxcounter.conf @@ -15,7 +15,7 @@ // Set this to include BLE counting and vendor filter functions #define VENDORFILTER 1 // set to 0 if you want to count things, not people -#define BLECOUNTER 1 // set it to 1 if you want to use BLE count, at expense of memory +#define BLECOUNTER 0 // set it to 1 if you want to use BLE count, at expense of memory // BLE scan parameters #define BLESCANTIME 0 // [seconds] scan duration, 0 means infinite [default], see note below @@ -67,8 +67,8 @@ // settings for syncing time of node with external time source #define TIME_SYNC_INTERVAL 2 // sync time attempt each .. minutes from time source (GPS/LORA/RTC) [default = 60], comment out means off -//#define TIME_SYNC_LORA 1 // use LORA network as time source, comment out means off [default = off] -//#define DBTIMESYNC 1 // use DB LORA timeserver with patented sync algorithm [default = off] +#define TIME_SYNC_LORA 0 // set to 1 to use LORA network as time source, comment out means off [default = off] +#define DBTIMESYNC 0 // set to 1 to use DB LORA timeserver with patented sync algorithm [default = off] // time zone, see https://github.com/JChristensen/Timezone/blob/master/examples/WorldClock/WorldClock.ino #define DAYLIGHT_TIME {"CEST", Last, Sun, Mar, 2, 120} // Central European Summer Time diff --git a/src/rcommand.cpp b/src/rcommand.cpp index df793445..34054bc2 100644 --- a/src/rcommand.cpp +++ b/src/rcommand.cpp @@ -306,7 +306,7 @@ cmd_t table[] = {{0x01, set_rssi, 1, true}, {0x84, get_gps, 0, false}, {0x85, get_bme, 0, false}, {0x86, get_time, 0, false} -#ifdef DBTIMESYNC +#if(DBTIMESYNC) , {TIME_ANS_OPCODE, recv_DBtime_ans, 0, false}, {TIME_SYNC_OPCODE, force_DBtime_sync, 0, false} diff --git a/src/timekeeper.cpp b/src/timekeeper.cpp index 0c1c232c..21259b21 100644 --- a/src/timekeeper.cpp +++ b/src/timekeeper.cpp @@ -36,10 +36,10 @@ time_t timeProvider(void) { #endif // kick off asychronous DB timesync if we have -#ifdef DBTIMESYNC +#if(DBTIMESYNC) send_DBtime_req(); // kick off asychronous lora sync if we have -#elif defined HAS_LORA && defined TIME_SYNC_LORA +#elif defined HAS_LORA && (TIME_SYNC_LORA) LMIC_requestNetworkTime(user_request_network_time_callback, &userUTCTime); #endif