From 49d0408c1985d050bc7fead14a7fafc66c776828 Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Wed, 8 Mar 2023 15:57:53 +0100 Subject: [PATCH 01/30] Create CI.yml --- .github/workflows/CI.yml | 150 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 .github/workflows/CI.yml diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 0000000..8055985 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,150 @@ +name: CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + workflow_dispatch: + +jobs: + + build: + strategy: + matrix: + board: + - esp32:esp32@1.0.6 + - esp32:esp32:esp32:DebugLevel=none + - esp32:esp32:esp32:DebugLevel=verbose + - esp32:esp32:firebeetle32 + #- esp32:esp32:ttgo-lora32:Revision=TTGO_LoRa32_V1 + #- esp32:esp32:ttgo-lora32:Revision=TTGO_LoRa32_V2 + - esp32:esp32:ttgo-lora32:Revision=TTGO_LoRa32_v21new + - esp32:esp32:heltec_wireless_stick:PSRAM=disabled + - esp32:esp32:featheresp32 + - esp32:esp32:adafruit_feather_esp32s2 + + runs-on: ubuntu-latest + name: ${{ matrix.board }} + env: + GH_TOKEN: ${{ github.token }} + run-build: ${{ contains(matrix.board, 'esp32:esp32') || contains(github.event.head_commit.message, 'CI_BUILD_ALL') || contains(github.event.head_commit.message, 'Bump version to') || contains(github.event.head_commit.message, format('{0}', matrix.board)) }} + + steps: + - name: Install arduino-cli + if: ${{ env.run-build == 'true' }} + run: + | + mkdir -p ~/.local/bin + echo "~/.local/bin" >> $GITHUB_PATH + curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=~/.local/bin sh + + - name: Get platform name + if: ${{ env.run-build == 'true' }} + uses: jungwinter/split@v2 + id: split + with: + msg: ${{ matrix.board }} + separator: ':' + + - name: Prepare platform-specific settings + if: ${{ env.run-build == 'true' }} + id: prep + run: + | + # common settings - no extra options, skip nothing, all warnings + echo "skip-pattern=''" >> $GITHUB_OUTPUT + echo "warnings='all'" >> $GITHUB_OUTPUT + + # platform-dependent settings - extra board options, board index URLs, skip patterns etc. + if [[ "${{ contains(matrix.board, 'esp32:esp32') }}" == "true" ]]; then + # ESP32 + python -m pip install pyserial + echo "index-url=--additional-urls https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json" >> $GITHUB_OUTPUT + fi + + - name: Install libraries + if: ${{ env.run-build == 'true' }} + run: + | + #declare -a required_libs=("https://github.com/matthias-bs/BresserWeatherSensorReceiver.git" + declare -a required_libs=( + "RadioLib@5.7.0" + "BresserWeatherSensorReceiver@0.6.0" + "MCCI LoRaWAN LMIC library@4.1.1" + "MCCI Arduino LoRaWAN Library@0.9.2" + "MCCI Arduino Development Kit ADK@0.2.2" + "LoRa Serialization@3.2.1" + "ESP32Time@2.0.0" + "ESP32AnalogRead@0.2.1" + "OneWireNg@0.13.0" + "DallasTemperature@3.9.0" + "NimBLE-Arduino@1.4.1" + "ATC_MiThermometer@0.2.1" + "TheengsDecoder@1.2.0") + #"OneWire@2.3.7" + for i in "${required_libs[@]}" + do + arduino-cli lib install "$i" + done + gh repo clone matthias-bs/DistanceSensor_A02YYUW + cp -r DistanceSensor_A02YYUW /home/runner/Arduino/libraries/ + # OneWire is installed due to dependency in DallasTemperature, but OneWireNg shall be used instead + echo "Removing Arduino/libraries/OneWire (installed automatically, but shall be replaced by OneWireNg)" + rm -r /home/runner/Arduino/libraries/OneWire + + - name: Install platform + if: ${{ env.run-build == 'true' }} + run: + | + arduino-cli core update-index ${{ format('{0}', steps.prep.outputs.index-url) }} + arduino-cli core install ${{ format('{0}:{1} {2}', steps.split.outputs._0, steps.split.outputs._1, steps.prep.outputs.index-url) }} + + - name: Checkout repository + if: ${{ env.run-build == 'true' }} + uses: actions/checkout@v3 + + - name: Copy WeatherSensorCfg.h + if: ${{ env.run-build == 'true' }} + run: + | + cp /home/runner/work/BresserWeatherSensorTTN/BresserWeatherSensorTTN/WeatherSensorCfg.h.template \ + /home/runner/Arduino/libraries/BresserWeatherSensorReceiver/src/WeatherSensorCfg.h + + - name: Customizing lmic_project_config.h (LMIC_ENABLE_DeviceTimeReq) + if: ${{ env.run-build == 'true' }} + run: + | + echo "#define LMIC_ENABLE_DeviceTimeReq 1" >> /home/runner/Arduino/libraries/MCCI_LoRaWAN_LMIC_library/project_config/lmic_project_config.h + # Fix for linker error with Arduino core for ESP32 v2.0.x as suggested in https://github.com/mcci-catena/arduino-lmic/issues/714#issuecomment-822051171 + echo "#define hal_init LMICHAL_init" >> /home/runner/Arduino/libraries/MCCI_LoRaWAN_LMIC_library/project_config/lmic_project_config.h + + - name: Build sketch + if: ${{ env.run-build == 'true' }} + run: + | + #for example in $(find $PWD/examples -name '*.ino' | sort); do + # modified to compile a singe sketch (instead of a library's examples) + for example in $(find $PWD -name '*.ino' | sort); do + # check whether to skip this sketch + if [ ! -z '${{ steps.prep.outputs.skip-pattern }}' ] && [[ ${example} =~ ${{ steps.prep.outputs.skip-pattern }} ]]; then + # skip sketch + echo -e "\n\033[1;33mSkipped ${example##*/} (matched with ${{ steps.prep.outputs.skip-pattern }})\033[0m"; + else + # build sketch + echo -e "\n\033[1;33mBuilding ${example##*/} ... \033[0m"; + if [[ "${{ contains(matrix.board, '@1.0.6') }}" == "true" ]]; then + # hardcoded fqbn, because 'esp32:esp32@1.0.6' did not work + arduino-cli compile --libraries /home/runner/work/BresserWeatherSensorReceiver --fqbn esp32:esp32:esp32${{ steps.prep.outputs.options }} $example --warnings=${{ steps.prep.outputs.warnings }} + else + arduino-cli compile --libraries /home/runner/work/BresserWeatherSensorReceiver --fqbn ${{ matrix.board }}${{ steps.prep.outputs.options }} $example --warnings=${{ steps.prep.outputs.warnings }} + fi + + if [ $? -ne 0 ]; then + echo -e "\033[1;31m${example##*/} build FAILED\033[0m\n"; + exit 1; + else + echo -e "\033[1;32m${example##*/} build PASSED\033[0m\n"; + fi + fi + done From edc59a186a673b170c2bea11e2ec565a9a10b78a Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Wed, 8 Mar 2023 16:29:37 +0100 Subject: [PATCH 02/30] Added option for setting RTC from LoRaWAN network time --- .../arduino_lorawan_esp32_example.ino | 155 +++++++++++++++++- 1 file changed, 151 insertions(+), 4 deletions(-) diff --git a/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino b/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino index 463a970..f044035 100644 --- a/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino +++ b/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino @@ -61,6 +61,7 @@ // 20230307 Changed cMyLoRaWAN to inherit from Arduino_LoRaWAN_network // instead of Arduino_LoRaWAN_ttn // Added Pin mappings for some common ESP32 LoRaWAN boards +// 20230308 Added option for setting RTC from LoRaWAN network time // // Notes: // - After a successful transmission, the controller can go into deep sleep @@ -73,6 +74,11 @@ // - The ESP32's RTC RAM is used to store information about the LoRaWAN // network session; this speeds up the connection after a restart // significantly +// - To enable Network Time Requests: +// #define LMIC_ENABLE_DeviceTimeReq 1 +// - settimeofday()/gettimeofday() must be used to access the ESP32's RTC time +// - Arduino ESP32 package has built-in time zone handling, see +// https://github.com/SensorsIot/NTP-time-for-ESP8266-and-ESP32/blob/master/NTP_Example/NTP_Example.ino // /////////////////////////////////////////////////////////////////////////////// @@ -92,6 +98,12 @@ #include #include +// NOTE: Add #define LMIC_ENABLE_DeviceTimeReq 1 +// in ~/Arduino/libraries/MCCI_LoRaWAN_LMIC_library/project_config/lmic_project_config.h +#if (not(LMIC_ENABLE_DeviceTimeReq)) + #warning "LMIC_ENABLE_DeviceTimeReq is not set - will not be able to retrieve network time!" +#endif + //----------------------------------------------------------------------------- // // User Configuration @@ -103,6 +115,14 @@ // Enable sleep mode - sleep after successful transmission to TTN (recommended!) #define SLEEP_EN +// Enable setting RTC from LoRaWAN network time +#define GET_NETWORKTIME + +#if defined(GET_NETWORKTIME) + // Enter your time zone (https://remotemonitoringsystems.ca/time-zone-abbreviations.php) + const char* TZ_INFO = "CET-1CEST-2,M3.5.0/02:00:00,M10.5.0/03:00:00"; +#endif + // If SLEEP_EN is defined, MCU will sleep for SLEEP_INTERVAL seconds after succesful transmission #define SLEEP_INTERVAL 360 @@ -117,6 +137,10 @@ //----------------------------------------------------------------------------- +#if defined(GET_NETWORKTIME) + #include +#endif + // LoRa_Serialization #include @@ -194,11 +218,14 @@ const uint8_t PAYLOAD_SIZE = 8; #define DEBUG_PRINTF_TS(...) { DEBUG_PORT.printf("%d ms: ", osticks2ms(os_getTime())); \ DEBUG_PORT.printf(__VA_ARGS__); } #else - #define DEBUG_PRINTF(...) {} - #define DEBUG_PRINTF_TS(...) {} + #define DEBUG_PRINTF(...) {} + #define DEBUG_PRINTF_TS(...) {} +#endif + +#if defined(GET_NETWORKTIME) + void printDateTime(void); #endif - /****************************************************************************\ | | The LoRaWAN object @@ -211,6 +238,15 @@ public: using Super = Arduino_LoRaWAN_network; void setup(); + #if defined(GET_NETWORKTIME) + /*! + * \fn requestNetworkTime + * + * \brief Wrapper function for LMIC_requestNetworkTime() + */ + void requestNetworkTime(void); + #endif + protected: // you'll need to provide implementation for this. virtual bool GetOtaaProvisioningInfo(Arduino_LoRaWAN::OtaaProvisioningInfo*) override; @@ -327,12 +363,26 @@ RTC_DATA_ATTR size_t rtcSavedNExtraInfo; RTC_DATA_ATTR uint8_t rtcSavedExtraInfo[EXTRA_INFO_MEM_SIZE]; RTC_DATA_ATTR bool runtimeExpired = 0; +#if defined(GET_NETWORKTIME) + RTC_DATA_ATTR time_t rtcLastClockSync = 0; //!< timestamp of last RTC synchonization to network time +#endif + // Uplink payload buffer static uint8_t loraData[PAYLOAD_SIZE]; // Force sleep mode after has been reached (if FORCE_SLEEP is defined) ostime_t sleepTimeout; +/// RTC sync request flag - set (if due) in setup() / cleared in UserRequestNetworkTimeCb() +bool rtcSyncReq = false; + +#if defined(GET_NETWORKTIME) + /// Seconds since the UTC epoch + uint32_t userUTCTime; + + /// Real time clock + ESP32Time rtc; +#endif /****************************************************************************\ | @@ -397,6 +447,18 @@ void setup() { DEBUG_PRINTF_TS("setup()\n"); + #if defined(GET_NETWORKTIME) + // Set time zone + setenv("TZ", TZ_INFO, 1); + printDateTime(); + + // Check if clock was never synchronized or sync interval has expired + if ((rtcLastClockSync == 0) || ((rtc.getLocalEpoch() - rtcLastClockSync) > (CLOCK_SYNC_INTERVAL * 60))) { + DEBUG_PRINTF("RTC sync required"); + rtcSyncReq = true; + } + #endif + // set up the log; do this first. myEventLog.setup(); DEBUG_PRINTF("myEventlog.setup() - done\n"); @@ -425,7 +487,7 @@ void loop() { myEventLog.loop(); #ifdef FORCE_SLEEP - if (os_getTime() > sleepTimeout) { + if (os_getTime() > sleepTimeout & !rtcSyncReq) { DEBUG_PRINTF_TS("Sleep timer expired!\n"); DEBUG_PRINTF("Shutdown()\n"); runtimeExpired = true; @@ -712,6 +774,82 @@ cMyLoRaWAN::GetAbpProvisioningInfo(AbpProvisioningInfo *pAbpInfo) { return true; } +#if defined(GET_NETWORKTIME) + /// Print date and time (i.e. local time) + void printDateTime(void) { + struct tm timeinfo; + char tbuf[26]; + + time_t tnow = rtc.getLocalEpoch(); + localtime_r(&tnow, &timeinfo); + strftime(tbuf, 25, "%Y-%m-%d %H:%M:%S", &timeinfo); + DEBUG_PRINTF("%s", tbuf); + } + + /** + * \fn UserRequestNetworkTimeCb + * + * \brief Callback function for setting RTC from LoRaWAN network time + * + * \param pVoidUserUTCTime user supplied buffer for UTC time + * + * \param flagSuccess flag indicating if network time request was succesful + */ + void UserRequestNetworkTimeCb(void *pVoidUserUTCTime, int flagSuccess) { + // Explicit conversion from void* to uint32_t* to avoid compiler errors + uint32_t *pUserUTCTime = (uint32_t *) pVoidUserUTCTime; + + // A struct that will be populated by LMIC_getNetworkTimeReference. + // It contains the following fields: + // - tLocal: the value returned by os_GetTime() when the time + // request was sent to the gateway, and + // - tNetwork: the seconds between the GPS epoch and the time + // the gateway received the time request + lmic_time_reference_t lmicTimeReference; + + if (flagSuccess != 1) { + // Most likely the service is not provided by the gateway. No sense in trying again... + DEBUG_PRINTF_TS("didn't succeed"); + rtcSyncReq = false; + return; + } + + // Populate "lmic_time_reference" + flagSuccess = LMIC_getNetworkTimeReference(&lmicTimeReference); + if (flagSuccess != 1) { + DEBUG_PRINTF_TS("LMIC_getNetworkTimeReference didn't succeed"); + return; + } + + // Update userUTCTime, considering the difference between the GPS and UTC + // epoch, and the leap seconds + *pUserUTCTime = lmicTimeReference.tNetwork + 315964800; + + // Add the delay between the instant the time was transmitted and + // the current time + + // Current time, in ticks + ostime_t ticksNow = os_getTime(); + // Time when the request was sent, in ticks + ostime_t ticksRequestSent = lmicTimeReference.tLocal; + uint32_t requestDelaySec = osticks2ms(ticksNow - ticksRequestSent) / 1000; + *pUserUTCTime += requestDelaySec; + + // Update the system time with the time read from the network + rtc.setTime(*pUserUTCTime); + + // Save clock sync timestamp and clear flag + rtcLastClockSync = rtc.getLocalEpoch(); + rtcSyncReq = false; + DEBUG_PRINTF_TS("RTC sync completed"); + printDateTime(); + } + + void + cMyLoRaWAN::requestNetworkTime(void) { + LMIC_requestNetworkTime(UserRequestNetworkTimeCb, &userUTCTime); + } +#endif /****************************************************************************\ | @@ -818,6 +956,15 @@ cSensor::doUplink(void) { return; } + #if defined(GET_NETWORKTIME) + // + // Request time and date + // + if (rtcSyncReq) { + myLoRaWAN.requestNetworkTime(); + } + #endif + // Call sensor data function stubs temperature_deg_c = getTemperature(); humidity_percent = getHumidity(); From f3987e73b46b0ef324ba72f5983b64ea478978d9 Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Wed, 8 Mar 2023 16:34:36 +0100 Subject: [PATCH 03/30] Update CI.yml --- .github/workflows/CI.yml | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 8055985..37203ab 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -67,31 +67,16 @@ jobs: if: ${{ env.run-build == 'true' }} run: | - #declare -a required_libs=("https://github.com/matthias-bs/BresserWeatherSensorReceiver.git" declare -a required_libs=( - "RadioLib@5.7.0" - "BresserWeatherSensorReceiver@0.6.0" "MCCI LoRaWAN LMIC library@4.1.1" "MCCI Arduino LoRaWAN Library@0.9.2" "MCCI Arduino Development Kit ADK@0.2.2" "LoRa Serialization@3.2.1" - "ESP32Time@2.0.0" - "ESP32AnalogRead@0.2.1" - "OneWireNg@0.13.0" - "DallasTemperature@3.9.0" - "NimBLE-Arduino@1.4.1" - "ATC_MiThermometer@0.2.1" - "TheengsDecoder@1.2.0") - #"OneWire@2.3.7" + "ESP32Time@2.0.0") for i in "${required_libs[@]}" do arduino-cli lib install "$i" done - gh repo clone matthias-bs/DistanceSensor_A02YYUW - cp -r DistanceSensor_A02YYUW /home/runner/Arduino/libraries/ - # OneWire is installed due to dependency in DallasTemperature, but OneWireNg shall be used instead - echo "Removing Arduino/libraries/OneWire (installed automatically, but shall be replaced by OneWireNg)" - rm -r /home/runner/Arduino/libraries/OneWire - name: Install platform if: ${{ env.run-build == 'true' }} @@ -104,13 +89,6 @@ jobs: if: ${{ env.run-build == 'true' }} uses: actions/checkout@v3 - - name: Copy WeatherSensorCfg.h - if: ${{ env.run-build == 'true' }} - run: - | - cp /home/runner/work/BresserWeatherSensorTTN/BresserWeatherSensorTTN/WeatherSensorCfg.h.template \ - /home/runner/Arduino/libraries/BresserWeatherSensorReceiver/src/WeatherSensorCfg.h - - name: Customizing lmic_project_config.h (LMIC_ENABLE_DeviceTimeReq) if: ${{ env.run-build == 'true' }} run: From be0b5d1daf807931c5e5bc545bcb22c53bfac68b Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Wed, 8 Mar 2023 16:35:46 +0100 Subject: [PATCH 04/30] Update CI.yml --- .github/workflows/CI.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 37203ab..579f941 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -2,9 +2,9 @@ name: CI on: push: - branches: [ "main" ] + branches: [ "master" ] pull_request: - branches: [ "main" ] + branches: [ "master" ] workflow_dispatch: jobs: @@ -16,13 +16,13 @@ jobs: - esp32:esp32@1.0.6 - esp32:esp32:esp32:DebugLevel=none - esp32:esp32:esp32:DebugLevel=verbose - - esp32:esp32:firebeetle32 + #- esp32:esp32:firebeetle32 #- esp32:esp32:ttgo-lora32:Revision=TTGO_LoRa32_V1 #- esp32:esp32:ttgo-lora32:Revision=TTGO_LoRa32_V2 - - esp32:esp32:ttgo-lora32:Revision=TTGO_LoRa32_v21new - - esp32:esp32:heltec_wireless_stick:PSRAM=disabled - - esp32:esp32:featheresp32 - - esp32:esp32:adafruit_feather_esp32s2 + #- esp32:esp32:ttgo-lora32:Revision=TTGO_LoRa32_v21new + #- esp32:esp32:heltec_wireless_stick:PSRAM=disabled + #- esp32:esp32:featheresp32 + #- esp32:esp32:adafruit_feather_esp32s2 runs-on: ubuntu-latest name: ${{ matrix.board }} From f2be7bacf21a1fa28be4d9d335233322bcf3ca05 Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Wed, 8 Mar 2023 16:55:57 +0100 Subject: [PATCH 05/30] Update arduino_lorawan_esp32_example.ino --- .../arduino_lorawan_esp32_example.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino b/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino index f044035..5300aaa 100644 --- a/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino +++ b/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino @@ -284,7 +284,7 @@ public: uint16_t getVoltageBattery(void); uint16_t getVoltageSupply(void); - bool uplinkRequest(void) { + void uplinkRequest(void) { m_fUplinkRequest = true; }; /// From 2dddb0a4c456614e38535424e600b3425cc32878 Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Wed, 8 Mar 2023 17:00:08 +0100 Subject: [PATCH 06/30] Update CI.yml --- .github/workflows/CI.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 579f941..81858a1 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -96,7 +96,16 @@ jobs: echo "#define LMIC_ENABLE_DeviceTimeReq 1" >> /home/runner/Arduino/libraries/MCCI_LoRaWAN_LMIC_library/project_config/lmic_project_config.h # Fix for linker error with Arduino core for ESP32 v2.0.x as suggested in https://github.com/mcci-catena/arduino-lmic/issues/714#issuecomment-822051171 echo "#define hal_init LMICHAL_init" >> /home/runner/Arduino/libraries/MCCI_LoRaWAN_LMIC_library/project_config/lmic_project_config.h - + + - name: Copy secrets.h from secrets.h.template + if: ${{ env.run-build == 'true' }} + run: + | + pwd + ls + cp /home/runner/work/arduino-lorawan/arduino-lorawan/examples/arduino_lorawan_esp32_example/secrets.h.template \ + /home/runner/work/arduino-lorawan/arduino-lorawan/examples/arduino_lorawan_esp32_example/secrets.h + - name: Build sketch if: ${{ env.run-build == 'true' }} run: @@ -113,9 +122,9 @@ jobs: echo -e "\n\033[1;33mBuilding ${example##*/} ... \033[0m"; if [[ "${{ contains(matrix.board, '@1.0.6') }}" == "true" ]]; then # hardcoded fqbn, because 'esp32:esp32@1.0.6' did not work - arduino-cli compile --libraries /home/runner/work/BresserWeatherSensorReceiver --fqbn esp32:esp32:esp32${{ steps.prep.outputs.options }} $example --warnings=${{ steps.prep.outputs.warnings }} + arduino-cli compile --libraries /home/runner/work/arduino-lorawan --fqbn esp32:esp32:esp32${{ steps.prep.outputs.options }} $example --warnings=${{ steps.prep.outputs.warnings }} else - arduino-cli compile --libraries /home/runner/work/BresserWeatherSensorReceiver --fqbn ${{ matrix.board }}${{ steps.prep.outputs.options }} $example --warnings=${{ steps.prep.outputs.warnings }} + arduino-cli compile --libraries /home/runner/work/arduino-lorawan --fqbn ${{ matrix.board }}${{ steps.prep.outputs.options }} $example --warnings=${{ steps.prep.outputs.warnings }} fi if [ $? -ne 0 ]; then From 23d7abbda82ad09ff20c9d4dbdba6d0b25d8a4f9 Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Wed, 8 Mar 2023 17:04:48 +0100 Subject: [PATCH 07/30] Update CI.yml --- .github/workflows/CI.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 81858a1..cee678c 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -103,8 +103,7 @@ jobs: | pwd ls - cp /home/runner/work/arduino-lorawan/arduino-lorawan/examples/arduino_lorawan_esp32_example/secrets.h.template \ - /home/runner/work/arduino-lorawan/arduino-lorawan/examples/arduino_lorawan_esp32_example/secrets.h + cp examples/arduino_lorawan_esp32_example/secrets.h.template examples/arduino_lorawan_esp32_example/secrets.h - name: Build sketch if: ${{ env.run-build == 'true' }} From 237cdeadf9a93c9ac0bad7f20f68373a696df36b Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Wed, 8 Mar 2023 17:08:53 +0100 Subject: [PATCH 08/30] Update arduino_lorawan_esp32_example.ino --- .../arduino_lorawan_esp32_example.ino | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino b/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino index 5300aaa..8fe7ac2 100644 --- a/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino +++ b/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino @@ -121,6 +121,9 @@ #if defined(GET_NETWORKTIME) // Enter your time zone (https://remotemonitoringsystems.ca/time-zone-abbreviations.php) const char* TZ_INFO = "CET-1CEST-2,M3.5.0/02:00:00,M10.5.0/03:00:00"; + + // RTC to network time sync interval (in minutes) + #define CLOCK_SYNC_INTERVAL 24 * 60 #endif // If SLEEP_EN is defined, MCU will sleep for SLEEP_INTERVAL seconds after succesful transmission @@ -201,6 +204,15 @@ #define PIN_LMIC_DIO2 cMyLoRaWAN::lmic_pinmap::LMIC_UNUSED_PIN #pragma message("ARDUINO_ADAFRUIT_FEATHER_ESP32 defined; assuming RFM95W FeatherWing will be used") #pragma message("Required wiring: A to RST, B to DIO1, D to DIO0, E to CS") +#else + // LoRaWAN_Node board + // https://github.com/matthias-bs/LoRaWAN_Node + #define PIN_LMIC_NSS 14 + #define PIN_LMIC_RST 12 + #define PIN_LMIC_DIO0 4 + #define PIN_LMIC_DIO1 16 + #define PIN_LMIC_DIO2 17 + #endif // Uplink message payload size (calculate from assignments to 'encoder' object) @@ -511,9 +523,7 @@ void cMyLoRaWAN::setup() { // simply call begin() w/o parameters, and the LMIC's built-in // configuration for this board will be used. - bool res = this->Super::begin(myPinMap); - DEBUG_PRINTF("Arduino_LoRaWAN::begin(): %d\n", res); - + this->Super::begin(myPinMap); // LMIC_selectSubBand(0); LMIC_setClockError(MAX_CLOCK_ERROR * 1 / 100); From c18d372d20508138ff7ad6097d4a123d80d233d7 Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Wed, 8 Mar 2023 17:11:34 +0100 Subject: [PATCH 09/30] Update arduino_lorawan_esp32_example.ino --- .../arduino_lorawan_esp32_example.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino b/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino index 8fe7ac2..039a27b 100644 --- a/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino +++ b/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino @@ -499,7 +499,7 @@ void loop() { myEventLog.loop(); #ifdef FORCE_SLEEP - if (os_getTime() > sleepTimeout & !rtcSyncReq) { + if ((os_getTime() > sleepTimeout) & !rtcSyncReq) { DEBUG_PRINTF_TS("Sleep timer expired!\n"); DEBUG_PRINTF("Shutdown()\n"); runtimeExpired = true; From f042580b1a3f07990f82ed765ce2ae4581ee1d4d Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Wed, 8 Mar 2023 17:20:33 +0100 Subject: [PATCH 10/30] Update CI.yml --- .github/workflows/CI.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index cee678c..c2547a3 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -52,8 +52,8 @@ jobs: id: prep run: | - # common settings - no extra options, skip nothing, all warnings - echo "skip-pattern=''" >> $GITHUB_OUTPUT + # common settings - no extra options, all warnings + echo "skip-pattern='simple_sensor_bme280'" >> $GITHUB_OUTPUT echo "warnings='all'" >> $GITHUB_OUTPUT # platform-dependent settings - extra board options, board index URLs, skip patterns etc. From 5ffb73384a422d36c6610e7d7f2238a06069ff67 Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Wed, 8 Mar 2023 22:11:14 +0100 Subject: [PATCH 11/30] Update arduino_lorawan_esp32_example.ino --- .../arduino_lorawan_esp32_example.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino b/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino index 039a27b..76f0918 100644 --- a/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino +++ b/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino @@ -116,7 +116,7 @@ #define SLEEP_EN // Enable setting RTC from LoRaWAN network time -#define GET_NETWORKTIME +//#define GET_NETWORKTIME #if defined(GET_NETWORKTIME) // Enter your time zone (https://remotemonitoringsystems.ca/time-zone-abbreviations.php) From 179d2eb1c8a9df95bf989b98dae40a37333bf5d3 Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Wed, 8 Mar 2023 22:35:56 +0100 Subject: [PATCH 12/30] Update arduino_lorawan_esp32_example.ino --- .../arduino_lorawan_esp32_example.ino | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino b/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino index 76f0918..277642e 100644 --- a/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino +++ b/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino @@ -10,6 +10,7 @@ // - implements fast re-joining after sleep by storing network session data // in the ESP32 RTC RAM // - LoRa_Serialization is used for encoding various data types into bytes +// - internal Real-Time Clock (RTC) set from LoRaWAN network time (optional) // // // Based on: @@ -27,6 +28,7 @@ // MCCI LoRaWAN LMIC library 4.1.1 // MCCI Arduino LoRaWAN Library 0.9.2 // LoRa_Serialization 3.2.1 +// ESP32Time 2.0.0 // // // created: 07/2022 @@ -116,7 +118,7 @@ #define SLEEP_EN // Enable setting RTC from LoRaWAN network time -//#define GET_NETWORKTIME +#define GET_NETWORKTIME #if defined(GET_NETWORKTIME) // Enter your time zone (https://remotemonitoringsystems.ca/time-zone-abbreviations.php) From 367f46aeb0eb930d836aede80c8823e7a708c0d8 Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Thu, 9 Mar 2023 08:01:41 +0100 Subject: [PATCH 13/30] Fixed debug output --- .../arduino_lorawan_esp32_example.ino | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino b/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino index 277642e..8ff38ea 100644 --- a/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino +++ b/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino @@ -988,10 +988,10 @@ cSensor::doUplink(void) { battery_ok = true; // sensor battery status DEBUG_PRINTF("--- Uplink Data ---\n"); - DEBUG_PRINTF("Air Temperature: % 3.1f °C\n", weatherSensor.temp_c); - DEBUG_PRINTF("Humidity: %2d %%\n", weatherSensor.humidity); - DEBUG_PRINTF("Supply Voltage: %4d mV\n", supply_voltage); - DEBUG_PRINTF("Battery Voltage: %4d mV\n", battery_voltage); + DEBUG_PRINTF("Air Temperature: % 3.1f °C\n", temperature_deg_c); + DEBUG_PRINTF("Humidity: %2d %%\n", humidity_percent); + DEBUG_PRINTF("Supply Voltage: %4d mV\n", supply_voltage_v); + DEBUG_PRINTF("Battery Voltage: %4d mV\n", battery_voltage_v); DEBUG_PRINTF("Status:\n"); DEBUG_PRINTF(" battery_ok: %d\n", battery_ok); DEBUG_PRINTF(" data_ok: %d\n", data_ok); From 7659680e9e5823c1d7079e9736965d50b3c34bb1 Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Thu, 9 Mar 2023 08:21:10 +0100 Subject: [PATCH 14/30] Update arduino_lorawan_esp32_example.ino --- .../arduino_lorawan_esp32_example.ino | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino b/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino index 8ff38ea..7e5bd87 100644 --- a/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino +++ b/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino @@ -468,7 +468,7 @@ void setup() { // Check if clock was never synchronized or sync interval has expired if ((rtcLastClockSync == 0) || ((rtc.getLocalEpoch() - rtcLastClockSync) > (CLOCK_SYNC_INTERVAL * 60))) { - DEBUG_PRINTF("RTC sync required"); + DEBUG_PRINTF("RTC sync required\n"); rtcSyncReq = true; } #endif @@ -794,7 +794,7 @@ cMyLoRaWAN::GetAbpProvisioningInfo(AbpProvisioningInfo *pAbpInfo) { time_t tnow = rtc.getLocalEpoch(); localtime_r(&tnow, &timeinfo); - strftime(tbuf, 25, "%Y-%m-%d %H:%M:%S", &timeinfo); + strftime(tbuf, 25, "%Y-%m-%d %H:%M:%S\n", &timeinfo); DEBUG_PRINTF("%s", tbuf); } @@ -821,7 +821,7 @@ cMyLoRaWAN::GetAbpProvisioningInfo(AbpProvisioningInfo *pAbpInfo) { if (flagSuccess != 1) { // Most likely the service is not provided by the gateway. No sense in trying again... - DEBUG_PRINTF_TS("didn't succeed"); + DEBUG_PRINTF_TS("didn't succeed\n"); rtcSyncReq = false; return; } @@ -829,7 +829,7 @@ cMyLoRaWAN::GetAbpProvisioningInfo(AbpProvisioningInfo *pAbpInfo) { // Populate "lmic_time_reference" flagSuccess = LMIC_getNetworkTimeReference(&lmicTimeReference); if (flagSuccess != 1) { - DEBUG_PRINTF_TS("LMIC_getNetworkTimeReference didn't succeed"); + DEBUG_PRINTF_TS("LMIC_getNetworkTimeReference didn't succeed\n"); return; } @@ -853,7 +853,7 @@ cMyLoRaWAN::GetAbpProvisioningInfo(AbpProvisioningInfo *pAbpInfo) { // Save clock sync timestamp and clear flag rtcLastClockSync = rtc.getLocalEpoch(); rtcSyncReq = false; - DEBUG_PRINTF_TS("RTC sync completed"); + DEBUG_PRINTF_TS("RTC sync completed\n"); printDateTime(); } From 66fdcc2bdb18f96e6f78f2aedab8429e5fa5665d Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Thu, 9 Mar 2023 21:55:27 +0100 Subject: [PATCH 15/30] Update arduino_lorawan_esp32_example.ino --- .../arduino_lorawan_esp32_example.ino | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino b/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino index 7e5bd87..661d005 100644 --- a/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino +++ b/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino @@ -209,6 +209,7 @@ #else // LoRaWAN_Node board // https://github.com/matthias-bs/LoRaWAN_Node + // (or anything else) #define PIN_LMIC_NSS 14 #define PIN_LMIC_RST 12 #define PIN_LMIC_DIO0 4 From fcc09585fbc1fc0cf9482559a9456a8dd1c7d08a Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Thu, 9 Mar 2023 21:56:49 +0100 Subject: [PATCH 16/30] Update arduino_lorawan_esp32_example.ino --- .../arduino_lorawan_esp32_example.ino | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino b/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino index 661d005..641282b 100644 --- a/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino +++ b/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino @@ -206,6 +206,7 @@ #define PIN_LMIC_DIO2 cMyLoRaWAN::lmic_pinmap::LMIC_UNUSED_PIN #pragma message("ARDUINO_ADAFRUIT_FEATHER_ESP32 defined; assuming RFM95W FeatherWing will be used") #pragma message("Required wiring: A to RST, B to DIO1, D to DIO0, E to CS") + #else // LoRaWAN_Node board // https://github.com/matthias-bs/LoRaWAN_Node From a135fafa3567da9b7524e7556373ae28f5878591 Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Thu, 9 Mar 2023 21:58:32 +0100 Subject: [PATCH 17/30] Update library.properties --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index f871188..d1dbbab 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=MCCI Arduino LoRaWAN Library -version=0.10.0-pre1 +version=0.10.0-pre2 author=Terry Moore, ChaeHee Won maintainer=Terry Moore sentence=High-level library for LoRaWAN-based Arduino end-devices. From cf836c8fb7b7734eafad6c6a0452752f2418d56b Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Thu, 9 Mar 2023 21:59:12 +0100 Subject: [PATCH 18/30] Update library.json --- library.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.json b/library.json index c1b7789..5258a8c 100644 --- a/library.json +++ b/library.json @@ -31,7 +31,7 @@ "authors": ["Terry Moore "] } ], - "version": "0.9.2", + "version": "0.10.0-pre2", "frameworks": "arduino", "platforms": "*" } From 29539850831a6c311271d7efbb8b9f5c1f46b007 Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Thu, 9 Mar 2023 22:00:18 +0100 Subject: [PATCH 19/30] Update Arduino_LoRaWAN.h --- src/Arduino_LoRaWAN.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Arduino_LoRaWAN.h b/src/Arduino_LoRaWAN.h index 3ef11db..22af5a9 100644 --- a/src/Arduino_LoRaWAN.h +++ b/src/Arduino_LoRaWAN.h @@ -34,7 +34,7 @@ Copyright notice: /// \ref ARDUINO_LORAWAN_VERSION_COMPARE_LT() to compare relative versions. /// #define ARDUINO_LORAWAN_VERSION \ - ARDUINO_LORAWAN_VERSION_CALC(0, 10, 0, 1) /* v0.10.0-pre1 */ + ARDUINO_LORAWAN_VERSION_CALC(0, 10, 0, 2) /* v0.10.0-pre2 */ #define ARDUINO_LORAWAN_VERSION_GET_MAJOR(v) \ (((v) >> 24u) & 0xFFu) From 39c443039a18b7729f548b6fdd3b561b97e3e6a2 Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Thu, 9 Mar 2023 22:03:24 +0100 Subject: [PATCH 20/30] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 64b3cf3..de3a864 100644 --- a/README.md +++ b/README.md @@ -428,6 +428,10 @@ Much more elaborate uses can be found in the MCCI [Catena-Arduino-Platform](http ## Release History +- v0.10.0-pre2 includes the following changes. + + - examples/arduino_lorawan_esp32_example: @matthias-bs Added option for setting ESP32 internal RTC from LoRaWAN network time + - v0.10.0-pre1 includes the following changes. - examples/arduino_lorawan_esp32_example: @matthias-bs Added pin mappings for some common ESP32 LoRaWAN boards From 656dd949c67bc7f05ca90fd21d7d2f597038ad8e Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Thu, 9 Mar 2023 22:05:15 +0100 Subject: [PATCH 21/30] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index de3a864..3c08237 100644 --- a/README.md +++ b/README.md @@ -430,11 +430,11 @@ Much more elaborate uses can be found in the MCCI [Catena-Arduino-Platform](http - v0.10.0-pre2 includes the following changes. - - examples/arduino_lorawan_esp32_example: @matthias-bs Added option for setting ESP32 internal RTC from LoRaWAN network time + - examples/arduino_lorawan_esp32_example: [@matthias-bs](https://github.com/matthias-bs) Added option for setting ESP32 internal RTC from LoRaWAN network time - v0.10.0-pre1 includes the following changes. - - examples/arduino_lorawan_esp32_example: @matthias-bs Added pin mappings for some common ESP32 LoRaWAN boards + - examples/arduino_lorawan_esp32_example: [@matthias-bs](https://github.com/matthias-bs) Added pin mappings for some common ESP32 LoRaWAN boards - v0.9.2 includes the following changes. From b4425d160cf945e178088dfe4a5d59ec7f9168f5 Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Thu, 9 Mar 2023 22:50:09 +0100 Subject: [PATCH 22/30] Update CI.yml --- .github/workflows/CI.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index c2547a3..e7e15db 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -67,6 +67,7 @@ jobs: if: ${{ env.run-build == 'true' }} run: | + declare -a required_libs=( "MCCI LoRaWAN LMIC library@4.1.1" "MCCI Arduino LoRaWAN Library@0.9.2" @@ -77,6 +78,9 @@ jobs: do arduino-cli lib install "$i" done + // Clone mcci-catena's fork of Adafruit_BME280_Library used in the example simple_sensor_bme280 + gh repo clone mcci-catena/Adafruit_BME280_Library + cp -r Adafruit_BME280_Library /home/runner/Arduino/libraries/ - name: Install platform if: ${{ env.run-build == 'true' }} From 430753198bc7885292ccec73f41f7cc2768aeeb4 Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Thu, 9 Mar 2023 22:56:40 +0100 Subject: [PATCH 23/30] Update CI.yml --- .github/workflows/CI.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index e7e15db..742737e 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -67,7 +67,6 @@ jobs: if: ${{ env.run-build == 'true' }} run: | - declare -a required_libs=( "MCCI LoRaWAN LMIC library@4.1.1" "MCCI Arduino LoRaWAN Library@0.9.2" From e2d6148731a86b94f78181319c8cead373f05c07 Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Thu, 9 Mar 2023 23:16:05 +0100 Subject: [PATCH 24/30] Update CI.yml --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 742737e..02e0f63 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -77,7 +77,7 @@ jobs: do arduino-cli lib install "$i" done - // Clone mcci-catena's fork of Adafruit_BME280_Library used in the example simple_sensor_bme280 + # Clone mcci-catena's fork of Adafruit_BME280_Library used in the example simple_sensor_bme280 gh repo clone mcci-catena/Adafruit_BME280_Library cp -r Adafruit_BME280_Library /home/runner/Arduino/libraries/ From c42bbdcf24123be6b46778bf6368319f06bd3491 Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Thu, 9 Mar 2023 23:25:44 +0100 Subject: [PATCH 25/30] Update CI.yml --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 02e0f63..ae9c893 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -53,7 +53,7 @@ jobs: run: | # common settings - no extra options, all warnings - echo "skip-pattern='simple_sensor_bme280'" >> $GITHUB_OUTPUT + echo "skip-pattern=''" >> $GITHUB_OUTPUT echo "warnings='all'" >> $GITHUB_OUTPUT # platform-dependent settings - extra board options, board index URLs, skip patterns etc. From 7f704626a3783fbfb57dcd2f19edacc44471c667 Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Thu, 9 Mar 2023 23:40:41 +0100 Subject: [PATCH 26/30] Update CI.yml --- .github/workflows/CI.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index ae9c893..cb04ab5 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -78,7 +78,8 @@ jobs: arduino-cli lib install "$i" done # Clone mcci-catena's fork of Adafruit_BME280_Library used in the example simple_sensor_bme280 - gh repo clone mcci-catena/Adafruit_BME280_Library + #gh repo clone mcci-catena/Adafruit_BME280_Library + gh clone https://github.com/mcci-catena/Adafruit_BME280_Library.git cp -r Adafruit_BME280_Library /home/runner/Arduino/libraries/ - name: Install platform From e481d5f2de7a8da1f4bad7d09f3de4f2183ba3a6 Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Thu, 9 Mar 2023 23:42:49 +0100 Subject: [PATCH 27/30] Update CI.yml --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index cb04ab5..494776a 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -79,7 +79,7 @@ jobs: done # Clone mcci-catena's fork of Adafruit_BME280_Library used in the example simple_sensor_bme280 #gh repo clone mcci-catena/Adafruit_BME280_Library - gh clone https://github.com/mcci-catena/Adafruit_BME280_Library.git + gh repo clone https://github.com/mcci-catena/Adafruit_BME280_Library.git cp -r Adafruit_BME280_Library /home/runner/Arduino/libraries/ - name: Install platform From d50c6a547f2031bdd5f5d8105b816b8f9dbae833 Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Thu, 9 Mar 2023 23:45:53 +0100 Subject: [PATCH 28/30] Update CI.yml --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 494776a..c87a95c 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -79,7 +79,7 @@ jobs: done # Clone mcci-catena's fork of Adafruit_BME280_Library used in the example simple_sensor_bme280 #gh repo clone mcci-catena/Adafruit_BME280_Library - gh repo clone https://github.com/mcci-catena/Adafruit_BME280_Library.git + git clone https://github.com/mcci-catena/Adafruit_BME280_Library.git cp -r Adafruit_BME280_Library /home/runner/Arduino/libraries/ - name: Install platform From 60fc7f8a8df90e5a91ebaf9383f7e2b3121a0817 Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Fri, 10 Mar 2023 07:06:29 +0100 Subject: [PATCH 29/30] Update CI.yml --- .github/workflows/CI.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index c87a95c..22a51dd 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -53,7 +53,7 @@ jobs: run: | # common settings - no extra options, all warnings - echo "skip-pattern=''" >> $GITHUB_OUTPUT + echo "skip-pattern='simple_sensor_bme280'" >> $GITHUB_OUTPUT echo "warnings='all'" >> $GITHUB_OUTPUT # platform-dependent settings - extra board options, board index URLs, skip patterns etc. @@ -78,9 +78,8 @@ jobs: arduino-cli lib install "$i" done # Clone mcci-catena's fork of Adafruit_BME280_Library used in the example simple_sensor_bme280 - #gh repo clone mcci-catena/Adafruit_BME280_Library - git clone https://github.com/mcci-catena/Adafruit_BME280_Library.git - cp -r Adafruit_BME280_Library /home/runner/Arduino/libraries/ + #git clone https://github.com/mcci-catena/Adafruit_BME280_Library.git + #cp -r Adafruit_BME280_Library /home/runner/Arduino/libraries/ - name: Install platform if: ${{ env.run-build == 'true' }} From d7292725a7b8335d1d1e6eb6d8163a7188038b62 Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Mon, 13 Mar 2023 07:03:35 +0100 Subject: [PATCH 30/30] Improved payload size handling --- .../arduino_lorawan_esp32_example.ino | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino b/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino index 641282b..170896e 100644 --- a/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino +++ b/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino @@ -219,8 +219,9 @@ #endif -// Uplink message payload size (calculate from assignments to 'encoder' object) -const uint8_t PAYLOAD_SIZE = 8; +// Uplink message payload size +// The maximum allowed for all data rates is 51 bytes. +const uint8_t PAYLOAD_SIZE = 51; // RTC Memory Handling #define MAGIC1 (('m' << 24) | ('g' < 16) | ('c' << 8) | '1') @@ -1000,7 +1001,7 @@ cSensor::doUplink(void) { DEBUG_PRINTF(" runtimeExpired: %d\n", runtimeExpired); DEBUG_PRINTF("\n"); - // Serialize data into byte array + // Serialize data into byte array (max. PAYLOAD_SIZE) // NOTE: // For TTN MQTT integration, ttn_decoder.js must be adjusted accordingly LoraEncoder encoder(loraData); @@ -1017,7 +1018,7 @@ cSensor::doUplink(void) { this->m_fBusy = true; if (! myLoRaWAN.SendBuffer( - loraData, sizeof(loraData), + loraData, encoder.getLength(), // this is the completion function: [](void *pClientData, bool fSucccess) -> void { auto const pThis = (cSensor *)pClientData;