From b4cbf8bdd95b035fc87f71eb6fdc6d126d5bfdca Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Wed, 24 Oct 2018 18:07:41 +0200 Subject: [PATCH 1/8] LED control improved --- include/led.h | 3 +++ include/main.h | 1 + src/led.cpp | 41 +++++++++++++++++++++++++++++------------ src/main.cpp | 5 +++++ 4 files changed, 38 insertions(+), 12 deletions(-) diff --git a/include/led.h b/include/led.h index 2631563c..6527e879 100644 --- a/include/led.h +++ b/include/led.h @@ -37,5 +37,8 @@ extern TaskHandle_t ledLoopTask; void rgb_set_color(uint16_t hue); void blink_LED(uint16_t set_color, uint16_t set_blinkduration); void ledLoop(void *parameter); +#if (HAS_LED != NOT_A_PIN) +void switch_LED(uint8_t state); +#endif #endif \ No newline at end of file diff --git a/include/main.h b/include/main.h index 9c74aef5..f7284720 100644 --- a/include/main.h +++ b/include/main.h @@ -12,5 +12,6 @@ #include "beacon_array.h" #include "ota.h" #include "irqhandler.h" +#include "led.h" #endif \ No newline at end of file diff --git a/src/led.cpp b/src/led.cpp index 76195523..8e3b7ed8 100644 --- a/src/led.cpp +++ b/src/led.cpp @@ -87,6 +87,28 @@ void rgb_set_color(uint16_t hue) {} #endif +#if (HAS_LED != NOT_A_PIN) + +void switch_LED(uint8_t state) { + if (state == LED_ON) { + // switch LED on +#ifdef LED_ACTIVE_LOW + digitalWrite(HAS_LED, LOW); +#else + digitalWrite(HAS_LED, HIGH); +#endif + } else if (state == LED_OFF) { + // switch LED off +#ifdef LED_ACTIVE_LOW + digitalWrite(HAS_LED, HIGH); +#else + digitalWrite(HAS_LED, LOW); +#endif + } +} + +#endif + #if (HAS_LED != NOT_A_PIN) || defined(HAS_RGB_LED) void blink_LED(uint16_t set_color, uint16_t set_blinkduration) { @@ -98,7 +120,8 @@ void blink_LED(uint16_t set_color, uint16_t set_blinkduration) { void ledLoop(void *parameter) { while (1) { - // Custom blink running always have priority other LoRaWAN led management + // Custom blink running always have priority other LoRaWAN led + // management if (LEDBlinkStarted && LEDBlinkDuration) { // Custom blink is finished, let this order, avoid millis() overflow if ((millis() - LEDBlinkStarted) >= LEDBlinkDuration) { @@ -154,20 +177,14 @@ void ledLoop(void *parameter) { if (LEDState != previousLEDState) { if (LEDState == LED_ON) { rgb_set_color(LEDColor); - -#ifdef LED_ACTIVE_LOW - digitalWrite(HAS_LED, LOW); -#else - digitalWrite(HAS_LED, HIGH); + // if we have only single LED we use it to blink for status +#ifndef HAS_RGB_LED + switch_LED(LED_ON); #endif - } else { rgb_set_color(COLOR_NONE); - -#ifdef LED_ACTIVE_LOW - digitalWrite(HAS_LED, HIGH); -#else - digitalWrite(HAS_LED, LOW); +#ifndef HAS_RGB_LED + switch_LED(LED_OFF); #endif } previousLEDState = LEDState; diff --git a/src/main.cpp b/src/main.cpp index 1cceb71f..af5fdd4c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -96,7 +96,12 @@ void setup() { #if (HAS_LED != NOT_A_PIN) pinMode(HAS_LED, OUTPUT); strcat_P(features, " LED"); +// switch on power LED if we have 2 LEDs, else use it for status +#ifdef HAS_RGB_LED + switch_LED(LED_ON); #endif +#endif + #ifdef HAS_RGB_LED rgb_set_color(COLOR_PINK); strcat_P(features, " RGB"); From 41bec2714dc983208a18b14b3c57501f7c6d6b4d Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Sat, 27 Oct 2018 11:50:46 +0200 Subject: [PATCH 2/8] renamed lmic library --- .../.gitignore | 0 .../.hgignore | 0 .../HOWTO-ADD-REGION.md | 0 .../LICENSE | 0 .../README.md | 0 .../doc/LMiC-v1.6.docx | Bin .../doc/LMiC-v1.6.pdf | Bin .../doc/README.txt | 0 .../doc/release-notes.txt | 0 .../library.properties | 0 .../src/aes/ideetron/AES-128_V10.cpp | 0 .../src/aes/lmic.c | 0 .../src/aes/other.c | 0 .../src/hal/hal.cpp | 0 .../src/hal/hal.h | 0 .../src/lmic.h | 0 .../src/lmic/config.h | 0 .../src/lmic/hal.h | 0 .../src/lmic/lmic.c | 0 .../src/lmic/lmic.h | 0 .../src/lmic/lmic_as923.c | 0 .../src/lmic/lmic_au921.c | 0 .../src/lmic/lmic_bandplan.h | 0 .../src/lmic/lmic_bandplan_as923.h | 0 .../src/lmic/lmic_bandplan_au921.h | 0 .../src/lmic/lmic_bandplan_eu868.h | 0 .../src/lmic/lmic_bandplan_in866.h | 0 .../src/lmic/lmic_bandplan_us915.h | 0 .../src/lmic/lmic_config_preconditions.h | 0 .../src/lmic/lmic_eu868.c | 0 .../src/lmic/lmic_eu_like.c | 0 .../src/lmic/lmic_eu_like.h | 0 .../src/lmic/lmic_in866.c | 0 .../src/lmic/lmic_us915.c | 0 .../src/lmic/lmic_us_like.c | 0 .../src/lmic/lmic_us_like.h | 0 .../src/lmic/lmic_util.c | 0 .../src/lmic/lmic_util.h | 0 .../src/lmic/lorabase.h | 0 .../src/lmic/lorabase_as923.h | 0 .../src/lmic/lorabase_au921.h | 0 .../src/lmic/lorabase_eu868.h | 0 .../src/lmic/lorabase_in866.h | 0 .../src/lmic/lorabase_us915.h | 0 .../src/lmic/oslmic.c | 0 .../src/lmic/oslmic.h | 0 .../src/lmic/radio.c | 0 47 files changed, 0 insertions(+), 0 deletions(-) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/.gitignore (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/.hgignore (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/HOWTO-ADD-REGION.md (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/LICENSE (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/README.md (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/doc/LMiC-v1.6.docx (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/doc/LMiC-v1.6.pdf (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/doc/README.txt (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/doc/release-notes.txt (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/library.properties (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/src/aes/ideetron/AES-128_V10.cpp (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/src/aes/lmic.c (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/src/aes/other.c (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/src/hal/hal.cpp (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/src/hal/hal.h (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/src/lmic.h (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/src/lmic/config.h (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/src/lmic/hal.h (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/src/lmic/lmic.c (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/src/lmic/lmic.h (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/src/lmic/lmic_as923.c (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/src/lmic/lmic_au921.c (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/src/lmic/lmic_bandplan.h (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/src/lmic/lmic_bandplan_as923.h (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/src/lmic/lmic_bandplan_au921.h (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/src/lmic/lmic_bandplan_eu868.h (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/src/lmic/lmic_bandplan_in866.h (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/src/lmic/lmic_bandplan_us915.h (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/src/lmic/lmic_config_preconditions.h (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/src/lmic/lmic_eu868.c (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/src/lmic/lmic_eu_like.c (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/src/lmic/lmic_eu_like.h (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/src/lmic/lmic_in866.c (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/src/lmic/lmic_us915.c (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/src/lmic/lmic_us_like.c (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/src/lmic/lmic_us_like.h (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/src/lmic/lmic_util.c (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/src/lmic/lmic_util.h (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/src/lmic/lorabase.h (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/src/lmic/lorabase_as923.h (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/src/lmic/lorabase_au921.h (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/src/lmic/lorabase_eu868.h (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/src/lmic/lorabase_in866.h (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/src/lmic/lorabase_us915.h (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/src/lmic/oslmic.c (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/src/lmic/oslmic.h (100%) rename lib/{arduino-lmic-master => arduino-lmic-mcci-v2.2.2}/src/lmic/radio.c (100%) diff --git a/lib/arduino-lmic-master/.gitignore b/lib/arduino-lmic-mcci-v2.2.2/.gitignore similarity index 100% rename from lib/arduino-lmic-master/.gitignore rename to lib/arduino-lmic-mcci-v2.2.2/.gitignore diff --git a/lib/arduino-lmic-master/.hgignore b/lib/arduino-lmic-mcci-v2.2.2/.hgignore similarity index 100% rename from lib/arduino-lmic-master/.hgignore rename to lib/arduino-lmic-mcci-v2.2.2/.hgignore diff --git a/lib/arduino-lmic-master/HOWTO-ADD-REGION.md b/lib/arduino-lmic-mcci-v2.2.2/HOWTO-ADD-REGION.md similarity index 100% rename from lib/arduino-lmic-master/HOWTO-ADD-REGION.md rename to lib/arduino-lmic-mcci-v2.2.2/HOWTO-ADD-REGION.md diff --git a/lib/arduino-lmic-master/LICENSE b/lib/arduino-lmic-mcci-v2.2.2/LICENSE similarity index 100% rename from lib/arduino-lmic-master/LICENSE rename to lib/arduino-lmic-mcci-v2.2.2/LICENSE diff --git a/lib/arduino-lmic-master/README.md b/lib/arduino-lmic-mcci-v2.2.2/README.md similarity index 100% rename from lib/arduino-lmic-master/README.md rename to lib/arduino-lmic-mcci-v2.2.2/README.md diff --git a/lib/arduino-lmic-master/doc/LMiC-v1.6.docx b/lib/arduino-lmic-mcci-v2.2.2/doc/LMiC-v1.6.docx similarity index 100% rename from lib/arduino-lmic-master/doc/LMiC-v1.6.docx rename to lib/arduino-lmic-mcci-v2.2.2/doc/LMiC-v1.6.docx diff --git a/lib/arduino-lmic-master/doc/LMiC-v1.6.pdf b/lib/arduino-lmic-mcci-v2.2.2/doc/LMiC-v1.6.pdf similarity index 100% rename from lib/arduino-lmic-master/doc/LMiC-v1.6.pdf rename to lib/arduino-lmic-mcci-v2.2.2/doc/LMiC-v1.6.pdf diff --git a/lib/arduino-lmic-master/doc/README.txt b/lib/arduino-lmic-mcci-v2.2.2/doc/README.txt similarity index 100% rename from lib/arduino-lmic-master/doc/README.txt rename to lib/arduino-lmic-mcci-v2.2.2/doc/README.txt diff --git a/lib/arduino-lmic-master/doc/release-notes.txt b/lib/arduino-lmic-mcci-v2.2.2/doc/release-notes.txt similarity index 100% rename from lib/arduino-lmic-master/doc/release-notes.txt rename to lib/arduino-lmic-mcci-v2.2.2/doc/release-notes.txt diff --git a/lib/arduino-lmic-master/library.properties b/lib/arduino-lmic-mcci-v2.2.2/library.properties similarity index 100% rename from lib/arduino-lmic-master/library.properties rename to lib/arduino-lmic-mcci-v2.2.2/library.properties diff --git a/lib/arduino-lmic-master/src/aes/ideetron/AES-128_V10.cpp b/lib/arduino-lmic-mcci-v2.2.2/src/aes/ideetron/AES-128_V10.cpp similarity index 100% rename from lib/arduino-lmic-master/src/aes/ideetron/AES-128_V10.cpp rename to lib/arduino-lmic-mcci-v2.2.2/src/aes/ideetron/AES-128_V10.cpp diff --git a/lib/arduino-lmic-master/src/aes/lmic.c b/lib/arduino-lmic-mcci-v2.2.2/src/aes/lmic.c similarity index 100% rename from lib/arduino-lmic-master/src/aes/lmic.c rename to lib/arduino-lmic-mcci-v2.2.2/src/aes/lmic.c diff --git a/lib/arduino-lmic-master/src/aes/other.c b/lib/arduino-lmic-mcci-v2.2.2/src/aes/other.c similarity index 100% rename from lib/arduino-lmic-master/src/aes/other.c rename to lib/arduino-lmic-mcci-v2.2.2/src/aes/other.c diff --git a/lib/arduino-lmic-master/src/hal/hal.cpp b/lib/arduino-lmic-mcci-v2.2.2/src/hal/hal.cpp similarity index 100% rename from lib/arduino-lmic-master/src/hal/hal.cpp rename to lib/arduino-lmic-mcci-v2.2.2/src/hal/hal.cpp diff --git a/lib/arduino-lmic-master/src/hal/hal.h b/lib/arduino-lmic-mcci-v2.2.2/src/hal/hal.h similarity index 100% rename from lib/arduino-lmic-master/src/hal/hal.h rename to lib/arduino-lmic-mcci-v2.2.2/src/hal/hal.h diff --git a/lib/arduino-lmic-master/src/lmic.h b/lib/arduino-lmic-mcci-v2.2.2/src/lmic.h similarity index 100% rename from lib/arduino-lmic-master/src/lmic.h rename to lib/arduino-lmic-mcci-v2.2.2/src/lmic.h diff --git a/lib/arduino-lmic-master/src/lmic/config.h b/lib/arduino-lmic-mcci-v2.2.2/src/lmic/config.h similarity index 100% rename from lib/arduino-lmic-master/src/lmic/config.h rename to lib/arduino-lmic-mcci-v2.2.2/src/lmic/config.h diff --git a/lib/arduino-lmic-master/src/lmic/hal.h b/lib/arduino-lmic-mcci-v2.2.2/src/lmic/hal.h similarity index 100% rename from lib/arduino-lmic-master/src/lmic/hal.h rename to lib/arduino-lmic-mcci-v2.2.2/src/lmic/hal.h diff --git a/lib/arduino-lmic-master/src/lmic/lmic.c b/lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic.c similarity index 100% rename from lib/arduino-lmic-master/src/lmic/lmic.c rename to lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic.c diff --git a/lib/arduino-lmic-master/src/lmic/lmic.h b/lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic.h similarity index 100% rename from lib/arduino-lmic-master/src/lmic/lmic.h rename to lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic.h diff --git a/lib/arduino-lmic-master/src/lmic/lmic_as923.c b/lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic_as923.c similarity index 100% rename from lib/arduino-lmic-master/src/lmic/lmic_as923.c rename to lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic_as923.c diff --git a/lib/arduino-lmic-master/src/lmic/lmic_au921.c b/lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic_au921.c similarity index 100% rename from lib/arduino-lmic-master/src/lmic/lmic_au921.c rename to lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic_au921.c diff --git a/lib/arduino-lmic-master/src/lmic/lmic_bandplan.h b/lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic_bandplan.h similarity index 100% rename from lib/arduino-lmic-master/src/lmic/lmic_bandplan.h rename to lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic_bandplan.h diff --git a/lib/arduino-lmic-master/src/lmic/lmic_bandplan_as923.h b/lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic_bandplan_as923.h similarity index 100% rename from lib/arduino-lmic-master/src/lmic/lmic_bandplan_as923.h rename to lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic_bandplan_as923.h diff --git a/lib/arduino-lmic-master/src/lmic/lmic_bandplan_au921.h b/lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic_bandplan_au921.h similarity index 100% rename from lib/arduino-lmic-master/src/lmic/lmic_bandplan_au921.h rename to lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic_bandplan_au921.h diff --git a/lib/arduino-lmic-master/src/lmic/lmic_bandplan_eu868.h b/lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic_bandplan_eu868.h similarity index 100% rename from lib/arduino-lmic-master/src/lmic/lmic_bandplan_eu868.h rename to lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic_bandplan_eu868.h diff --git a/lib/arduino-lmic-master/src/lmic/lmic_bandplan_in866.h b/lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic_bandplan_in866.h similarity index 100% rename from lib/arduino-lmic-master/src/lmic/lmic_bandplan_in866.h rename to lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic_bandplan_in866.h diff --git a/lib/arduino-lmic-master/src/lmic/lmic_bandplan_us915.h b/lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic_bandplan_us915.h similarity index 100% rename from lib/arduino-lmic-master/src/lmic/lmic_bandplan_us915.h rename to lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic_bandplan_us915.h diff --git a/lib/arduino-lmic-master/src/lmic/lmic_config_preconditions.h b/lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic_config_preconditions.h similarity index 100% rename from lib/arduino-lmic-master/src/lmic/lmic_config_preconditions.h rename to lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic_config_preconditions.h diff --git a/lib/arduino-lmic-master/src/lmic/lmic_eu868.c b/lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic_eu868.c similarity index 100% rename from lib/arduino-lmic-master/src/lmic/lmic_eu868.c rename to lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic_eu868.c diff --git a/lib/arduino-lmic-master/src/lmic/lmic_eu_like.c b/lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic_eu_like.c similarity index 100% rename from lib/arduino-lmic-master/src/lmic/lmic_eu_like.c rename to lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic_eu_like.c diff --git a/lib/arduino-lmic-master/src/lmic/lmic_eu_like.h b/lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic_eu_like.h similarity index 100% rename from lib/arduino-lmic-master/src/lmic/lmic_eu_like.h rename to lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic_eu_like.h diff --git a/lib/arduino-lmic-master/src/lmic/lmic_in866.c b/lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic_in866.c similarity index 100% rename from lib/arduino-lmic-master/src/lmic/lmic_in866.c rename to lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic_in866.c diff --git a/lib/arduino-lmic-master/src/lmic/lmic_us915.c b/lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic_us915.c similarity index 100% rename from lib/arduino-lmic-master/src/lmic/lmic_us915.c rename to lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic_us915.c diff --git a/lib/arduino-lmic-master/src/lmic/lmic_us_like.c b/lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic_us_like.c similarity index 100% rename from lib/arduino-lmic-master/src/lmic/lmic_us_like.c rename to lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic_us_like.c diff --git a/lib/arduino-lmic-master/src/lmic/lmic_us_like.h b/lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic_us_like.h similarity index 100% rename from lib/arduino-lmic-master/src/lmic/lmic_us_like.h rename to lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic_us_like.h diff --git a/lib/arduino-lmic-master/src/lmic/lmic_util.c b/lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic_util.c similarity index 100% rename from lib/arduino-lmic-master/src/lmic/lmic_util.c rename to lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic_util.c diff --git a/lib/arduino-lmic-master/src/lmic/lmic_util.h b/lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic_util.h similarity index 100% rename from lib/arduino-lmic-master/src/lmic/lmic_util.h rename to lib/arduino-lmic-mcci-v2.2.2/src/lmic/lmic_util.h diff --git a/lib/arduino-lmic-master/src/lmic/lorabase.h b/lib/arduino-lmic-mcci-v2.2.2/src/lmic/lorabase.h similarity index 100% rename from lib/arduino-lmic-master/src/lmic/lorabase.h rename to lib/arduino-lmic-mcci-v2.2.2/src/lmic/lorabase.h diff --git a/lib/arduino-lmic-master/src/lmic/lorabase_as923.h b/lib/arduino-lmic-mcci-v2.2.2/src/lmic/lorabase_as923.h similarity index 100% rename from lib/arduino-lmic-master/src/lmic/lorabase_as923.h rename to lib/arduino-lmic-mcci-v2.2.2/src/lmic/lorabase_as923.h diff --git a/lib/arduino-lmic-master/src/lmic/lorabase_au921.h b/lib/arduino-lmic-mcci-v2.2.2/src/lmic/lorabase_au921.h similarity index 100% rename from lib/arduino-lmic-master/src/lmic/lorabase_au921.h rename to lib/arduino-lmic-mcci-v2.2.2/src/lmic/lorabase_au921.h diff --git a/lib/arduino-lmic-master/src/lmic/lorabase_eu868.h b/lib/arduino-lmic-mcci-v2.2.2/src/lmic/lorabase_eu868.h similarity index 100% rename from lib/arduino-lmic-master/src/lmic/lorabase_eu868.h rename to lib/arduino-lmic-mcci-v2.2.2/src/lmic/lorabase_eu868.h diff --git a/lib/arduino-lmic-master/src/lmic/lorabase_in866.h b/lib/arduino-lmic-mcci-v2.2.2/src/lmic/lorabase_in866.h similarity index 100% rename from lib/arduino-lmic-master/src/lmic/lorabase_in866.h rename to lib/arduino-lmic-mcci-v2.2.2/src/lmic/lorabase_in866.h diff --git a/lib/arduino-lmic-master/src/lmic/lorabase_us915.h b/lib/arduino-lmic-mcci-v2.2.2/src/lmic/lorabase_us915.h similarity index 100% rename from lib/arduino-lmic-master/src/lmic/lorabase_us915.h rename to lib/arduino-lmic-mcci-v2.2.2/src/lmic/lorabase_us915.h diff --git a/lib/arduino-lmic-master/src/lmic/oslmic.c b/lib/arduino-lmic-mcci-v2.2.2/src/lmic/oslmic.c similarity index 100% rename from lib/arduino-lmic-master/src/lmic/oslmic.c rename to lib/arduino-lmic-mcci-v2.2.2/src/lmic/oslmic.c diff --git a/lib/arduino-lmic-master/src/lmic/oslmic.h b/lib/arduino-lmic-mcci-v2.2.2/src/lmic/oslmic.h similarity index 100% rename from lib/arduino-lmic-master/src/lmic/oslmic.h rename to lib/arduino-lmic-mcci-v2.2.2/src/lmic/oslmic.h diff --git a/lib/arduino-lmic-master/src/lmic/radio.c b/lib/arduino-lmic-mcci-v2.2.2/src/lmic/radio.c similarity index 100% rename from lib/arduino-lmic-master/src/lmic/radio.c rename to lib/arduino-lmic-mcci-v2.2.2/src/lmic/radio.c From 16759c4dd55abecc6f51539ba00dffcffc1e29d0 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Sat, 27 Oct 2018 13:51:59 +0200 Subject: [PATCH 3/8] SPI code added (experimental) --- include/spisend.h | 25 ++++++++++++++++++++++++ src/spisend.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 72 insertions(+), 3 deletions(-) diff --git a/include/spisend.h b/include/spisend.h index 750a3c20..70cc4437 100644 --- a/include/spisend.h +++ b/include/spisend.h @@ -1,9 +1,34 @@ #ifndef _SPISEND_H #define _SPISEND_H +#include "globals.h" +#include "spi.h" + extern TaskHandle_t SpiTask; extern QueueHandle_t SPISendQueue; +/* + * Process data in SPI send queue + */ void spi_loop(void *pvParameters); +/* +* initialize local SPI wire interface +*/ +void hal_spi_init(); + +/* + * Perform SPI write transaction on local SPI wire interface + * - write the command byte 'cmd' + * - write 'len' bytes out of 'buf' + */ +void hal_spi_write(uint8_t cmd, const uint8_t* buf, int len); + +/* + * Perform SPI read transaction on local SPI wire interface + * - read the command byte 'cmd' + * - read 'len' bytes into 'buf' + */ +void hal_spi_read(uint8_t cmd, uint8_t* buf, int len); + #endif \ No newline at end of file diff --git a/src/spisend.cpp b/src/spisend.cpp index 57da9287..c778a887 100644 --- a/src/spisend.cpp +++ b/src/spisend.cpp @@ -1,6 +1,6 @@ #ifdef HAS_SPI -#include "globals.h" +#include "spisend.h" // Local logging tag static const char TAG[] = "main"; @@ -13,18 +13,62 @@ TaskHandle_t SpiTask; // SPI feed Task void spi_loop(void *pvParameters) { + uint8_t buf[32]; + configASSERT(((uint32_t)pvParameters) == 1); // FreeRTOS check while (1) { + // check if data to send on SPI interface if (xQueueReceive(SPISendQueue, &SendBuffer, (TickType_t)0) == pdTRUE) { + hal_spi_write(SendBuffer.MessagePort, SendBuffer.Message, + SendBuffer.MessageSize); ESP_LOGI(TAG, "%d bytes sent to SPI", SendBuffer.MessageSize); } - vTaskDelay(2 / portTICK_PERIOD_MS); // yield to CPU - } // end of infinite loop + // check if command is received on SPI command port, then call interpreter + hal_spi_read(RCMDPORT, buf, 32); + if (buf[0]) + rcommand(buf, sizeof(buf)); + + vTaskDelay(2 / portTICK_PERIOD_MS); // yield to CPU + } // end of infinite loop vTaskDelete(NULL); // shoud never be reached } // spi_loop() +// SPI hardware abstraction layer + +void hal_spi_init() { SPI.begin(SCK, MISO, MOSI, SS); } + +void hal_spi_trx(u1_t cmd, u1_t *buf, int len, u1_t is_read) { + + u1_t nss = SS; + SPISettings settings(1E6, MSBFIRST, SPI_MODE0); + SPI.beginTransaction(settings); + + digitalWrite(nss, 0); + + SPI.transfer(cmd); + + for (u1_t i = 0; i < len; i++) { + u1_t *p = buf + i; + u1_t data = is_read ? 0x00 : *p; + data = SPI.transfer(data); + if (is_read) + *p = data; + } + + digitalWrite(nss, 1); + SPI.endTransaction(); +} + +void hal_spi_write(u1_t cmd, const u1_t *buf, int len) { + hal_spi_trx(cmd, (u1_t *)buf, len, 0); +} + +void hal_spi_read(u1_t cmd, u1_t *buf, int len) { + hal_spi_trx(cmd, buf, len, 1); +} + #endif // HAS_SPI \ No newline at end of file From 00b1faab8358d1575e4567d462a5329201023bc2 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Sat, 27 Oct 2018 21:38:08 +0200 Subject: [PATCH 4/8] SPI wire interface (experimental) --- src/spisend.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/spisend.cpp b/src/spisend.cpp index c778a887..6d28f5a8 100644 --- a/src/spisend.cpp +++ b/src/spisend.cpp @@ -41,34 +41,32 @@ void spi_loop(void *pvParameters) { void hal_spi_init() { SPI.begin(SCK, MISO, MOSI, SS); } -void hal_spi_trx(u1_t cmd, u1_t *buf, int len, u1_t is_read) { +void hal_spi_trx(uint8_t port, uint8_t *buf, int len, uint8_t is_read) { - u1_t nss = SS; SPISettings settings(1E6, MSBFIRST, SPI_MODE0); SPI.beginTransaction(settings); + digitalWrite(SS, 0); - digitalWrite(nss, 0); + SPI.transfer(port); - SPI.transfer(cmd); - - for (u1_t i = 0; i < len; i++) { - u1_t *p = buf + i; - u1_t data = is_read ? 0x00 : *p; + for (uint8_t i = 0; i < len; i++) { + uint8_t *p = buf + i; + uint8_t data = is_read ? 0x00 : *p; data = SPI.transfer(data); if (is_read) *p = data; } - digitalWrite(nss, 1); + digitalWrite(SS, 1); SPI.endTransaction(); } -void hal_spi_write(u1_t cmd, const u1_t *buf, int len) { - hal_spi_trx(cmd, (u1_t *)buf, len, 0); +void hal_spi_write(uint8_t port, const uint8_t *buf, int len) { + hal_spi_trx(port, (uint8_t *)buf, len, 0); } -void hal_spi_read(u1_t cmd, u1_t *buf, int len) { - hal_spi_trx(cmd, buf, len, 1); +void hal_spi_read(uint8_t port, uint8_t *buf, int len) { + hal_spi_trx(port, buf, len, 1); } #endif // HAS_SPI \ No newline at end of file From 88c1dd4e0cce14a29141be617c7d38e4dc1a5e9d Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Sat, 27 Oct 2018 22:40:17 +0200 Subject: [PATCH 5/8] rcommand.cpp: bugfix set_countmode() --- src/rcommand.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/rcommand.cpp b/src/rcommand.cpp index ab82deaa..37460d86 100644 --- a/src/rcommand.cpp +++ b/src/rcommand.cpp @@ -105,7 +105,10 @@ void set_countmode(uint8_t val[]) { ESP_LOGW( TAG, "Remote command: set counter mode called with invalid parameter(s)"); + return; } + reset_counters(); // clear macs + get_salt(); // get new salt } void set_screensaver(uint8_t val[]) { From 07991515eabd46f2e0b4c8f346180ffdebdb70d3 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Sat, 27 Oct 2018 22:48:05 +0200 Subject: [PATCH 6/8] v1.6.53 --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index e0ccb21c..839cb135 100644 --- a/platformio.ini +++ b/platformio.ini @@ -29,7 +29,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.51 +release_version = 1.6.53 ; 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 From e8c5b1b478a4ad3ae015d55f5f988f0b67cc21b2 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Wed, 31 Oct 2018 19:49:01 +0100 Subject: [PATCH 7/8] payload.cpp: bugfix monitormode in config status --- platformio.ini | 2 +- src/payload.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 839cb135..a21e5d4a 100644 --- a/platformio.ini +++ b/platformio.ini @@ -29,7 +29,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.53 +release_version = 1.6.54 ; 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 diff --git a/src/payload.cpp b/src/payload.cpp index 38c2df76..a1d6e580 100644 --- a/src/payload.cpp +++ b/src/payload.cpp @@ -48,6 +48,7 @@ void PayloadConvert::addConfig(configData_t value) { buffer[cursor++] = value.vendorfilter; buffer[cursor++] = value.rgblum; buffer[cursor++] = value.gpsmode; + buffer[cursor++] = value.monitormode; memcpy(buffer + cursor, value.version, 10); cursor += 10; } From dbb91b1a40228f0a45e051aa669db4a56165e634 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Fri, 2 Nov 2018 08:39:45 +0100 Subject: [PATCH 8/8] heltecv2.h: pinout corrected --- src/hal/heltecv2.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hal/heltecv2.h b/src/hal/heltecv2.h index a97a6d3c..6d48f05f 100644 --- a/src/hal/heltecv2.h +++ b/src/hal/heltecv2.h @@ -25,7 +25,7 @@ #define LORA_MOSI (27) #define LORA_RST (14) #define LORA_IO0 (26) -#define LORA_IO1 (34) -#define LORA_IO2 (35) +#define LORA_IO1 (35) +#define LORA_IO2 (34) #endif \ No newline at end of file