From ebfc16219b324d568d12c3a82db5d6765239ad11 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Tue, 16 Oct 2018 08:48:09 +0200 Subject: [PATCH 1/3] LED color change --- src/led.cpp | 13 ++++++++++++- src/paxcounter.conf | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/led.cpp b/src/led.cpp index 59965dce..76195523 100644 --- a/src/led.cpp +++ b/src/led.cpp @@ -122,7 +122,18 @@ void ledLoop(void *parameter) { LEDState = ((millis() % 200) < 20) ? LED_ON : LED_OFF; // TX data pending } else if (LMIC.opmode & (OP_TXDATA | OP_TXRXPEND)) { - LEDColor = COLOR_BLUE; + // select color to blink by message port + switch (LMIC.pendTxPort) { + case STATUSPORT: + LEDColor = COLOR_RED; + break; + case CONFIGPORT: + LEDColor = COLOR_CYAN; + break; + default: + LEDColor = COLOR_BLUE; + break; + } // small blink 10ms on each 1/2sec (not when joining) LEDState = ((millis() % 500) < 10) ? LED_ON : LED_OFF; // This should not happen so indicate a problem diff --git a/src/paxcounter.conf b/src/paxcounter.conf index 28264cb8..8c5749d5 100644 --- a/src/paxcounter.conf +++ b/src/paxcounter.conf @@ -53,7 +53,7 @@ #define COUNTERPORT 1 // Port on which device sends counts #define RCMDPORT 2 // Port on which device listenes for remote commands #define STATUSPORT 2 // Port on which device sends remote command results -#define CONFIGPORT 3 // Port on which device sends gps query results +#define CONFIGPORT 3 // Port on which device sends config query results #define GPSPORT 4 // Port on which device sends gps query results #define BUTTONPORT 5 // Port on which device sends button pressed signal #define LPP1PORT 1 // Port for Cayenne LPP 1.0 dynamic sensor encoding From 6d1d358a56de9829b6d204945dc040a7e386d537 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Wed, 17 Oct 2018 07:10:37 +0200 Subject: [PATCH 2/3] call LMIC_shutdown before ESP.restart --- include/rcommand.h | 1 + src/cyclic.cpp | 4 ++-- src/rcommand.cpp | 12 ++++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/include/rcommand.h b/include/rcommand.h index c656c9fd..bde9a151 100644 --- a/include/rcommand.h +++ b/include/rcommand.h @@ -16,5 +16,6 @@ typedef struct { } cmd_t; void rcommand(uint8_t cmd[], uint8_t cmdlength); +void do_reset(); #endif \ No newline at end of file diff --git a/src/cyclic.cpp b/src/cyclic.cpp index 06d45b62..f75daacf 100644 --- a/src/cyclic.cpp +++ b/src/cyclic.cpp @@ -15,7 +15,7 @@ void doHousekeeping() { // check if update mode trigger switch was set if (cfg.runmode == 1) - ESP.restart(); + do_reset(); // task storage debugging // ESP_LOGD(TAG, "Wifiloop %d bytes left", @@ -60,7 +60,7 @@ void doHousekeeping() { get_salt(); // get new salt for salting hashes if (esp_get_minimum_free_heap_size() <= MEM_LOW) // check again - esp_restart(); // memory leak, reset device + do_reset(); // memory leak, reset device } } // doHousekeeping() diff --git a/src/rcommand.cpp b/src/rcommand.cpp index 42e855a9..ab82deaa 100644 --- a/src/rcommand.cpp +++ b/src/rcommand.cpp @@ -5,15 +5,19 @@ // Local logging tag static const char TAG[] = "main"; +// helper function +void do_reset() { + ESP_LOGI(TAG, "Remote command: restart device"); + LMIC_shutdown(); + esp_restart(); +} + // set of functions that can be triggered by remote commands void set_reset(uint8_t val[]) { switch (val[0]) { case 0: // restart device - ESP_LOGI(TAG, "Remote command: restart device"); sprintf(display_line6, "Reset pending"); - vTaskDelay(10000 / portTICK_PERIOD_MS); // wait for LMIC to confirm LoRa - // downlink to server - esp_restart(); + do_reset(); break; case 1: // reset MAC counter ESP_LOGI(TAG, "Remote command: reset MAC counter"); From 19f576d61b6f68e301a9464010c125850f9f0379 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Wed, 17 Oct 2018 07:30:36 +0200 Subject: [PATCH 3/3] v1.6.1 --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index cfeb99df..e23b7612 100644 --- a/platformio.ini +++ b/platformio.ini @@ -27,7 +27,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.6.0 +release_version = 1.6.1 ; 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 = 0