From cab5e7eeed15f54717ab6af37c5a63fe53bfa047 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 May 2025 05:17:39 +0000 Subject: [PATCH 01/19] Bump codecov/codecov-action from 3 to 5 Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 3 to 5. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/v3...v5) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-version: '5' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/unit-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index e69308f..3587d65 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -49,7 +49,7 @@ jobs: echo "CODECOV_TOKEN=$CODECOV_TOKEN" >> "$GITHUB_ENV" - name: Upload coverage report to Codecov - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v5 with: file: "${{ env.COVERAGE_DATA_PATH }}" fail_ci_if_error: true From 7f5410d63ae3c2cf3dd5e4074b05d66f28bd9257 Mon Sep 17 00:00:00 2001 From: fabik111 Date: Tue, 13 May 2025 11:08:12 +0200 Subject: [PATCH 02/19] fix the first frame of snake animation --- src/utility/LEDFeedback.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/utility/LEDFeedback.cpp b/src/utility/LEDFeedback.cpp index ca670b5..0264dbd 100644 --- a/src/utility/LEDFeedback.cpp +++ b/src/utility/LEDFeedback.cpp @@ -194,6 +194,9 @@ void LEDFeedbackClass::setMode(LEDFeedbackMode mode) { _framePtr = nullptr; matrix.loadSequence(snake); matrix.play(true); + /* For fixing the issue that the first + * frame of the first run is not shown */ + matrix.loadSequence(snake); #endif _ledChangeInterval = HEARTBEAT_INTERVAL; _count = 0; From c7c6f9d4973222c1126ac3e73959e20870102c1f Mon Sep 17 00:00:00 2001 From: fabik111 Date: Tue, 13 May 2025 11:09:38 +0200 Subject: [PATCH 03/19] set the duration of first frame of snake animation at 2000 ms --- src/utility/LEDFeedback.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utility/LEDFeedback.cpp b/src/utility/LEDFeedback.cpp index 0264dbd..bcbf864 100644 --- a/src/utility/LEDFeedback.cpp +++ b/src/utility/LEDFeedback.cpp @@ -48,7 +48,7 @@ const uint32_t cloud[][4] = { }; const uint32_t snake[][4] = { - { 0xffffffff, 0xffffffff, 0xffffffff, 1300 }, + { 0xffffffff, 0xffffffff, 0xffffffff, 2000 }, { 0x7fffffff, 0xffffffff, 0xfffff7ff, 66 }, { 0x3fe7ffff, 0xffffffff, 0xff7ff3fe, 66 }, { 0x1fc3fe7f, 0xfffffff7, 0xff3fe1fc, 66 }, From 5e3933d47a19dbf2807aafd09ef01f90c8dc46bf Mon Sep 17 00:00:00 2001 From: Fabio C Date: Tue, 20 May 2025 11:02:29 +0200 Subject: [PATCH 04/19] bump cloud-utils to 1.1.0: use copyCBORStringToArray from cloud-utils (#11) --- .../cbor/Decoder.cpp | 69 ++++++++----------- 1 file changed, 30 insertions(+), 39 deletions(-) diff --git a/src/configuratorAgents/agents/boardConfigurationProtocol/cbor/Decoder.cpp b/src/configuratorAgents/agents/boardConfigurationProtocol/cbor/Decoder.cpp index bac0846..9bc5c40 100644 --- a/src/configuratorAgents/agents/boardConfigurationProtocol/cbor/Decoder.cpp +++ b/src/configuratorAgents/agents/boardConfigurationProtocol/cbor/Decoder.cpp @@ -10,35 +10,11 @@ #include "Decoder.h" #include +#include #if defined(BOARD_HAS_ETHERNET) #include #endif -// FIXME move this utility functions -static bool copyCBORStringToArray(CborValue * param, char * dest, size_t dest_size) { - if (cbor_value_is_text_string(param)) { - // NOTE: keep in mind that _cbor_value_copy_string tries to put a \0 at the end of the string - if(_cbor_value_copy_string(param, dest, &dest_size, NULL) == CborNoError) { - return true; - } - } - - return false; -} - -// FIXME dest_size should be also returned, the copied byte array can have a different size from the starting one -// for the time being we need this on SHA256 only -static bool copyCBORByteToArray(CborValue * param, uint8_t * dest, size_t dest_size) { - if (cbor_value_is_byte_string(param)) { - // NOTE: keep in mind that _cbor_value_copy_string tries to put a \0 at the end of the string - if(_cbor_value_copy_string(param, dest, &dest_size, NULL) == CborNoError) { - return true; - } - } - - return false; -} - MessageDecoder::Status TimestampProvisioningMessageDecoder::decode(CborValue* param, Message* message) { TimestampProvisioningMessage* ts = (TimestampProvisioningMessage*) message; @@ -56,8 +32,9 @@ MessageDecoder::Status TimestampProvisioningMessageDecoder::decode(CborValue* pa MessageDecoder::Status WifiConfigProvisioningMessageDecoder::decode(CborValue* param, Message* message) { NetworkConfigProvisioningMessage* provisioningNetworkConfig = (NetworkConfigProvisioningMessage*) message; memset(&provisioningNetworkConfig->networkSetting, 0x00, sizeof(models::NetworkSetting)); + size_t ssidSize = sizeof(provisioningNetworkConfig->networkSetting.wifi.ssid); // Message is composed of 2 parameters: ssid and password - if (!copyCBORStringToArray(param, provisioningNetworkConfig->networkSetting.wifi.ssid, sizeof(provisioningNetworkConfig->networkSetting.wifi.ssid))) { + if (cbor::utils::copyCBORStringToArray(param, provisioningNetworkConfig->networkSetting.wifi.ssid, ssidSize) == MessageDecoder::Status::Error) { return MessageDecoder::Status::Error; } @@ -66,7 +43,8 @@ MessageDecoder::Status WifiConfigProvisioningMessageDecoder::decode(CborValue* p return MessageDecoder::Status::Error; } - if (!copyCBORStringToArray(param, provisioningNetworkConfig->networkSetting.wifi.pwd, sizeof(provisioningNetworkConfig->networkSetting.wifi.pwd))) { + size_t pwdSize = sizeof(provisioningNetworkConfig->networkSetting.wifi.pwd); + if (cbor::utils::copyCBORStringToArray(param, provisioningNetworkConfig->networkSetting.wifi.pwd, pwdSize) == MessageDecoder::Status::Error) { return MessageDecoder::Status::Error; } provisioningNetworkConfig->networkSetting.type = NetworkAdapter::WIFI; @@ -92,8 +70,9 @@ MessageDecoder::Status CommandsProvisioningMessageDecoder::decode(CborValue* par MessageDecoder::Status LoRaConfigProvisioningMessageDecoder::decode(CborValue* param, Message* message) { NetworkConfigProvisioningMessage* provisioningNetworkConfig = (NetworkConfigProvisioningMessage*) message; memset(&provisioningNetworkConfig->networkSetting, 0x00, sizeof(models::NetworkSetting)); + size_t appeuiSize = sizeof(provisioningNetworkConfig->networkSetting.lora.appeui); // Message is composed of 5 parameters: app_eui, app_key, band, channel_mask, device_class - if (!copyCBORStringToArray(param, provisioningNetworkConfig->networkSetting.lora.appeui, sizeof(provisioningNetworkConfig->networkSetting.lora.appeui))) { + if (cbor::utils::copyCBORStringToArray(param, provisioningNetworkConfig->networkSetting.lora.appeui, appeuiSize) == MessageDecoder::Status::Error) { return MessageDecoder::Status::Error; } @@ -102,7 +81,8 @@ MessageDecoder::Status LoRaConfigProvisioningMessageDecoder::decode(CborValue* p return MessageDecoder::Status::Error; } - if (!copyCBORStringToArray(param, provisioningNetworkConfig->networkSetting.lora.appkey, sizeof(provisioningNetworkConfig->networkSetting.lora.appkey))) { + size_t appkeySize = sizeof(provisioningNetworkConfig->networkSetting.lora.appkey); + if (cbor::utils::copyCBORStringToArray(param, provisioningNetworkConfig->networkSetting.lora.appkey, appkeySize) == MessageDecoder::Status::Error) { return MessageDecoder::Status::Error; } @@ -127,7 +107,8 @@ MessageDecoder::Status LoRaConfigProvisioningMessageDecoder::decode(CborValue* p return MessageDecoder::Status::Error; } - if(!copyCBORStringToArray(param, provisioningNetworkConfig->networkSetting.lora.channelMask, sizeof(provisioningNetworkConfig->networkSetting.lora.channelMask))) { + size_t channelMaskSize = sizeof(provisioningNetworkConfig->networkSetting.lora.channelMask); + if(cbor::utils::copyCBORStringToArray(param, provisioningNetworkConfig->networkSetting.lora.channelMask, channelMaskSize) == MessageDecoder::Status::Error) { return MessageDecoder::Status::Error; } @@ -138,7 +119,9 @@ MessageDecoder::Status LoRaConfigProvisioningMessageDecoder::decode(CborValue* p char deviceClass[LORA_DEVICE_CLASS_SIZE]; memset(deviceClass, 0x00, sizeof(deviceClass)); - if (!copyCBORStringToArray(param, deviceClass, sizeof(deviceClass))) { + + size_t deviceClassSize = sizeof(deviceClass); + if (cbor::utils::copyCBORStringToArray(param, deviceClass, deviceClassSize) == MessageDecoder::Status::Error) { return MessageDecoder::Status::Error; } @@ -159,8 +142,9 @@ MessageDecoder::Status CATM1ConfigProvisioningMessageDecoder::decode(CborValue* CborValue array_iter; size_t arrayLength = 0; + size_t pinSize = sizeof(provisioningNetworkConfig->networkSetting.catm1.pin); // Message is composed of 5 parameters: pin, band, apn, login and password - if (!copyCBORStringToArray(param, provisioningNetworkConfig->networkSetting.catm1.pin, sizeof(provisioningNetworkConfig->networkSetting.catm1.pin))) { + if (cbor::utils::copyCBORStringToArray(param, provisioningNetworkConfig->networkSetting.catm1.pin, pinSize) == MessageDecoder::Status::Error) { return MessageDecoder::Status::Error; } @@ -208,7 +192,8 @@ MessageDecoder::Status CATM1ConfigProvisioningMessageDecoder::decode(CborValue* return MessageDecoder::Status::Error; } - if (!copyCBORStringToArray(param, provisioningNetworkConfig->networkSetting.catm1.apn, sizeof(provisioningNetworkConfig->networkSetting.catm1.apn))) { + size_t apnSize = sizeof(provisioningNetworkConfig->networkSetting.catm1.apn); + if (cbor::utils::copyCBORStringToArray(param, provisioningNetworkConfig->networkSetting.catm1.apn, apnSize) == MessageDecoder::Status::Error) { return MessageDecoder::Status::Error; } @@ -217,7 +202,8 @@ MessageDecoder::Status CATM1ConfigProvisioningMessageDecoder::decode(CborValue* return MessageDecoder::Status::Error; } - if (!copyCBORStringToArray(param, provisioningNetworkConfig->networkSetting.catm1.login, sizeof(provisioningNetworkConfig->networkSetting.catm1.login))) { + size_t loginSize = sizeof(provisioningNetworkConfig->networkSetting.catm1.login); + if (cbor::utils::copyCBORStringToArray(param, provisioningNetworkConfig->networkSetting.catm1.login, loginSize) == MessageDecoder::Status::Error) { return MessageDecoder::Status::Error; } @@ -226,7 +212,8 @@ MessageDecoder::Status CATM1ConfigProvisioningMessageDecoder::decode(CborValue* return MessageDecoder::Status::Error; } - if (!copyCBORStringToArray(param, provisioningNetworkConfig->networkSetting.catm1.pass, sizeof(provisioningNetworkConfig->networkSetting.catm1.pass))) { + size_t passSize = sizeof(provisioningNetworkConfig->networkSetting.catm1.pass); + if (cbor::utils::copyCBORStringToArray(param, provisioningNetworkConfig->networkSetting.catm1.pass, passSize) == MessageDecoder::Status::Error) { return MessageDecoder::Status::Error; } @@ -343,8 +330,9 @@ MessageDecoder::Status EthernetConfigProvisioningMessageDecoder::decode(CborValu #if defined(BOARD_HAS_NB) || defined(BOARD_HAS_GSM) ||defined(BOARD_HAS_CELLULAR) static inline MessageDecoder::Status extractCellularFields(CborValue* param, models::CellularSetting* cellSetting) { + size_t pinSize = sizeof(cellSetting->pin); // Message is composed of 4 parameters: pin, apn, login and password - if (!copyCBORStringToArray(param, cellSetting->pin, sizeof(cellSetting->pin))) { + if (cbor::utils::copyCBORStringToArray(param, cellSetting->pin, pinSize) == MessageDecoder::Status::Error) { return MessageDecoder::Status::Error; } @@ -353,7 +341,8 @@ static inline MessageDecoder::Status extractCellularFields(CborValue* param, mod return MessageDecoder::Status::Error; } - if (!copyCBORStringToArray(param, cellSetting->apn, sizeof(cellSetting->apn))) { + size_t apnSize = sizeof(cellSetting->apn); + if (cbor::utils::copyCBORStringToArray(param, cellSetting->apn, apnSize) == MessageDecoder::Status::Error) { return MessageDecoder::Status::Error; } @@ -362,7 +351,8 @@ static inline MessageDecoder::Status extractCellularFields(CborValue* param, mod return MessageDecoder::Status::Error; } - if (!copyCBORStringToArray(param, cellSetting->login, sizeof(cellSetting->login))) { + size_t loginSize = sizeof(cellSetting->login); + if (cbor::utils::copyCBORStringToArray(param, cellSetting->login, loginSize) == MessageDecoder::Status::Error) { return MessageDecoder::Status::Error; } @@ -371,7 +361,8 @@ static inline MessageDecoder::Status extractCellularFields(CborValue* param, mod return MessageDecoder::Status::Error; } - if (!copyCBORStringToArray(param, cellSetting->pass, sizeof(cellSetting->pass))) { + size_t passSize = sizeof(cellSetting->pass); + if (cbor::utils::copyCBORStringToArray(param, cellSetting->pass, passSize) == MessageDecoder::Status::Error) { return MessageDecoder::Status::Error; } From f5184f79cfc5a2ff39162ce2612a3f16c1c45ea7 Mon Sep 17 00:00:00 2001 From: Fabio C Date: Tue, 20 May 2025 11:11:14 +0200 Subject: [PATCH 05/19] Fix for updating credential when AgentsManagerClass is not polled only by NetworkConfigurator(#10) --- src/Arduino_NetworkConfigurator.cpp | 23 +++++++++++++---------- src/Arduino_NetworkConfigurator.h | 1 + 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/Arduino_NetworkConfigurator.cpp b/src/Arduino_NetworkConfigurator.cpp index 85bf4a0..f448b1f 100644 --- a/src/Arduino_NetworkConfigurator.cpp +++ b/src/Arduino_NetworkConfigurator.cpp @@ -33,6 +33,7 @@ NetworkConfiguratorClass::NetworkConfiguratorClass(ConnectionHandler &connection _state{ NetworkConfiguratorStates::END }, _connectionHandler{ &connectionHandler }, _connectionHandlerIstantiated{ false }, + _configInProgress{ false }, _kvstore{ nullptr }, _connectionTimeout{ NC_CONNECTION_TIMEOUT_ms, NC_CONNECTION_TIMEOUT_ms }, _connectionRetryTimer{ NC_CONNECTION_RETRY_TIMER_ms, NC_CONNECTION_RETRY_TIMER_ms }, @@ -547,8 +548,11 @@ NetworkConfiguratorStates NetworkConfiguratorClass::handleConnecting() { _agentsManager->update(); //To keep alive the connection with the configurator StatusMessage err; ConnectionResult res = connectToNetwork(&err); - + _configInProgress = _agentsManager->isConfigInProgress(); if (res == ConnectionResult::SUCCESS) { + if (_configInProgress) { + _ledFeedback->setMode(LEDFeedbackClass::LEDFeedbackMode::PEER_CONNECTED); + } return NetworkConfiguratorStates::CONFIGURED; } else if (res == ConnectionResult::FAILED) { sendStatus(err); @@ -560,17 +564,16 @@ NetworkConfiguratorStates NetworkConfiguratorClass::handleConnecting() { } NetworkConfiguratorStates NetworkConfiguratorClass::handleConfigured() { - bool configInprogress = _agentsManager->isConfigInProgress(); - - if (configInprogress) { - _ledFeedback->setMode(LEDFeedbackClass::LEDFeedbackMode::PEER_CONNECTED); - } - _agentsManager->update(); + const bool updatedConfigInprogress = _agentsManager->isConfigInProgress(); + // If the agent manager changes state, it means that user is trying to configure the network, so the network configurator should change state - if (_agentsManager->isConfigInProgress() && !configInprogress) { - scanNetworkOptions(); - return NetworkConfiguratorStates::UPDATING_CONFIG; + if (_configInProgress != updatedConfigInprogress) { + _configInProgress = updatedConfigInprogress; + if (_configInProgress) { + scanNetworkOptions(); + return NetworkConfiguratorStates::UPDATING_CONFIG; + } } return NetworkConfiguratorStates::CONFIGURED; diff --git a/src/Arduino_NetworkConfigurator.h b/src/Arduino_NetworkConfigurator.h index e22bf1c..d68bbdb 100644 --- a/src/Arduino_NetworkConfigurator.h +++ b/src/Arduino_NetworkConfigurator.h @@ -162,6 +162,7 @@ class NetworkConfiguratorClass { ConnectionHandler *_connectionHandler; static inline models::NetworkSetting _networkSetting; bool _connectionHandlerIstantiated; + bool _configInProgress; ResetInput *_resetInput; LEDFeedbackClass *_ledFeedback; /* Timeout instances */ From b349c5d162884a53c96ca6a1324d70c1f2b9b51d Mon Sep 17 00:00:00 2001 From: fabik111 Date: Tue, 20 May 2025 12:07:21 +0200 Subject: [PATCH 06/19] Release version 0.1.3 --- library.properties | 2 +- src/ANetworkConfigurator_Config.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library.properties b/library.properties index a90f9ad..7792473 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Arduino_NetworkConfigurator -version=0.1.2 +version=0.1.3 author=Arduino maintainer=Arduino sentence=This library allows to configure and update the network settings of a ConnectionHandler instance. diff --git a/src/ANetworkConfigurator_Config.h b/src/ANetworkConfigurator_Config.h index 9b474ba..315ce41 100644 --- a/src/ANetworkConfigurator_Config.h +++ b/src/ANetworkConfigurator_Config.h @@ -7,7 +7,7 @@ */ #pragma once -#define ANetworkConfigurator_LIB_VERSION "0.1.2" +#define ANetworkConfigurator_LIB_VERSION "0.1.3" #if defined(ARDUINO_SAMD_MKRWIFI1010) #define NETWORK_CONFIGURATOR_COMPATIBLE 1 From 92176b0118b0be4fdcc36489d89d3c10048204e3 Mon Sep 17 00:00:00 2001 From: Fabio C Date: Tue, 27 May 2025 11:17:00 +0200 Subject: [PATCH 07/19] Rename variable matrix to ledMatrixAnimationHandler (#12) --- src/utility/LEDFeedback.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/utility/LEDFeedback.cpp b/src/utility/LEDFeedback.cpp index bcbf864..10abfe7 100644 --- a/src/utility/LEDFeedback.cpp +++ b/src/utility/LEDFeedback.cpp @@ -18,7 +18,7 @@ #ifdef BOARD_HAS_LED_MATRIX #include "Arduino_LED_Matrix.h" -ArduinoLEDMatrix matrix; +ArduinoLEDMatrix ledMatrixAnimationHandler; const uint32_t bluetooth[3] = { 0x401600d, @@ -158,7 +158,7 @@ void LEDFeedbackClass::begin() { #endif #ifdef BOARD_HAS_LED_MATRIX - matrix.begin(); + ledMatrixAnimationHandler.begin(); #endif } @@ -179,7 +179,7 @@ void LEDFeedbackClass::setMode(LEDFeedbackMode mode) { { _ledChangeInterval = 0; #ifdef BOARD_HAS_LED_MATRIX - matrix.clear(); + ledMatrixAnimationHandler.clear(); #endif } break; @@ -192,11 +192,11 @@ void LEDFeedbackClass::setMode(LEDFeedbackMode mode) { #endif #ifdef BOARD_HAS_LED_MATRIX _framePtr = nullptr; - matrix.loadSequence(snake); - matrix.play(true); + ledMatrixAnimationHandler.loadSequence(snake); + ledMatrixAnimationHandler.play(true); /* For fixing the issue that the first * frame of the first run is not shown */ - matrix.loadSequence(snake); + ledMatrixAnimationHandler.loadSequence(snake); #endif _ledChangeInterval = HEARTBEAT_INTERVAL; _count = 0; @@ -211,7 +211,7 @@ void LEDFeedbackClass::setMode(LEDFeedbackMode mode) { _ledPin = GREEN_LED; #endif #ifdef BOARD_HAS_LED_MATRIX - matrix.loadFrame(bluetooth); + ledMatrixAnimationHandler.loadFrame(bluetooth); _framePtr = (uint32_t*)bluetooth; #endif _ledChangeInterval = ALWAYS_ON_INTERVAL; @@ -225,8 +225,8 @@ void LEDFeedbackClass::setMode(LEDFeedbackMode mode) { _ledPin = GREEN_LED; #ifdef BOARD_HAS_LED_MATRIX _framePtr = nullptr; - matrix.loadSequence(LEDMATRIX_ANIMATION_WIFI_SEARCH); - matrix.play(true); + ledMatrixAnimationHandler.loadSequence(LEDMATRIX_ANIMATION_WIFI_SEARCH); + ledMatrixAnimationHandler.play(true); #endif _ledChangeInterval = ALWAYS_ON_INTERVAL; @@ -239,8 +239,8 @@ void LEDFeedbackClass::setMode(LEDFeedbackMode mode) { #endif #ifdef BOARD_HAS_LED_MATRIX _framePtr = nullptr; - matrix.loadSequence(cloud); - matrix.play(true); + ledMatrixAnimationHandler.loadSequence(cloud); + ledMatrixAnimationHandler.play(true); #endif _ledPin = GREEN_LED; _ledChangeInterval = SLOWBLINK_INTERVAL; @@ -258,7 +258,7 @@ void LEDFeedbackClass::setMode(LEDFeedbackMode mode) { #endif #ifdef BOARD_HAS_LED_MATRIX _framePtr = (uint32_t*)LEDMATRIX_EMOJI_SAD; - matrix.loadFrame(LEDMATRIX_EMOJI_SAD); + ledMatrixAnimationHandler.loadFrame(LEDMATRIX_EMOJI_SAD); #endif } break; @@ -327,7 +327,7 @@ void LEDFeedbackClass::turnOFF() { #endif #ifdef BOARD_HAS_LED_MATRIX if(_framePtr != nullptr){ - matrix.clear(); + ledMatrixAnimationHandler.clear(); } #endif @@ -342,7 +342,7 @@ void LEDFeedbackClass::turnON() { #endif #ifdef BOARD_HAS_LED_MATRIX if(_framePtr != nullptr){ - matrix.loadFrame(_framePtr); + ledMatrixAnimationHandler.loadFrame(_framePtr); } #endif _ledState = true; From 30febb26388a751e66d41d1e3adf3a4756b34c6a Mon Sep 17 00:00:00 2001 From: fabik111 Date: Tue, 27 May 2025 13:32:40 +0200 Subject: [PATCH 08/19] Release version 0.1.4 --- library.properties | 2 +- src/ANetworkConfigurator_Config.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library.properties b/library.properties index 7792473..d960065 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Arduino_NetworkConfigurator -version=0.1.3 +version=0.1.4 author=Arduino maintainer=Arduino sentence=This library allows to configure and update the network settings of a ConnectionHandler instance. diff --git a/src/ANetworkConfigurator_Config.h b/src/ANetworkConfigurator_Config.h index 315ce41..e1ca4cd 100644 --- a/src/ANetworkConfigurator_Config.h +++ b/src/ANetworkConfigurator_Config.h @@ -7,7 +7,7 @@ */ #pragma once -#define ANetworkConfigurator_LIB_VERSION "0.1.3" +#define ANetworkConfigurator_LIB_VERSION "0.1.4" #if defined(ARDUINO_SAMD_MKRWIFI1010) #define NETWORK_CONFIGURATOR_COMPATIBLE 1 From 2352608d87e03a44c5603e571804b0beb9d37fe5 Mon Sep 17 00:00:00 2001 From: Fabio C Date: Wed, 25 Jun 2025 11:50:05 +0200 Subject: [PATCH 09/19] update unit test ci dep of Arduino_ConnectionHandler (#13) --- extras/test/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extras/test/CMakeLists.txt b/extras/test/CMakeLists.txt index b4c0898..b3736e9 100644 --- a/extras/test/CMakeLists.txt +++ b/extras/test/CMakeLists.txt @@ -24,8 +24,8 @@ FetchContent_Declare( FetchContent_Declare( connectionhandler - GIT_REPOSITORY https://github.com/andreagilardoni/Arduino_ConnectionHandler.git - GIT_TAG connectionhandler-settings + GIT_REPOSITORY https://github.com/arduino-libraries/Arduino_ConnectionHandler.git + GIT_TAG master CONFIGURE_COMMAND "" BUILD_COMMAND "" ) From c00467a0f9e4ab42c6aa1e47f3db83b218f3d864 Mon Sep 17 00:00:00 2001 From: Fabio C Date: Wed, 25 Jun 2025 11:51:36 +0200 Subject: [PATCH 10/19] Change reset pin of Portenta boards for clashing with Portenta Carriers and Shields (#15) * change reset pin for portenta h7 and disable the reset procedure for machine control * change reset pin for portenta c33 to 0 --- README.md | 16 ++++++++++ .../NetworkConfiguratorDemo.ino | 3 ++ src/ANetworkConfigurator_Config.h | 6 ++-- src/Arduino_NetworkConfigurator.cpp | 3 ++ src/Arduino_NetworkConfigurator.h | 3 ++ src/utility/ResetInput.cpp | 29 ++++++++++++++++++- 6 files changed, 57 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0546307..48b1085 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,23 @@ The procedure: * `Arduino MKR WiFi 1010`: short the pin 7 to GND until the led turns off * `Arduino GIGA R1 WiFi`: short the pin 7 to GND until the led turns off * `Arduino Nano RP2040 Connect`: short the pin 2 to 3.3V until the led turns off +* `Arduino Portenta H7`: short the pin 0 to GND until the led turns off +* `Arduino Portenta C33`: short the pin 0 to GND until the led turns off * Other boards: short the pin 2 to GND until the led turns off +* `Portenta Machine Control`: currently the reset procedure is not available + +### More on the reconfiguration pin +Internally, the pin indicated in the procedure is set as `INPUT_PULLUP` (except for `Arduino Opta` ) and it's attached to an ISR fired on every change of the pin's status. + +In order to be notified when the ISR is fired, it's possible to register a callback function using the function `NetworkConfigurator.addReconfigurePinCallback(callback)`. Please take the example as reference. + +### Change the reconfiguration pin +In order to change the default pin for resetting the board, it's possible to use the function `NetworkConfigurator.setReconfigurePin(your_pin)` specifying the new pin. +The pin must be in the list of digital pins usable for interrupts. Please refer to the Arduino documentation for more details: https://docs.arduino.cc/language-reference/en/functions/external-interrupts/attachInterrupt/ + +### Disable the reconfiguration feature +In order to disable the reconfiguration procedure, use this function in the sketch `NetworkConfigurator.setReconfigurePin(DISABLE_PIN)` + ## Configurator Agents The library provides a set of *Configurator Agents* that added as plug-in to the sketch handle the communication between the Arduino Network Configurator and an external client ([*Arduino IoT App*](https://cloud.arduino.cc/iot-remote-app/) and Arduino IoT Cloud) for configuring the board. diff --git a/examples/NetworkConfiguratorDemo/NetworkConfiguratorDemo.ino b/examples/NetworkConfiguratorDemo/NetworkConfiguratorDemo.ino index 1bb8e6c..bc03b42 100644 --- a/examples/NetworkConfiguratorDemo/NetworkConfiguratorDemo.ino +++ b/examples/NetworkConfiguratorDemo/NetworkConfiguratorDemo.ino @@ -21,6 +21,9 @@ * - Arduino MKR WiFi 1010: short the pin 7 to GND until the led turns off * - Arduino GIGA R1 WiFi: short the pin 7 to GND until the led turns off * - Arduino Nano RP2040 Connect: short the pin 2 to 3.3V until the led turns off + * - Portenta H7: short the pin 0 to GND until the led turns off + * - Portenta C33: short the pin 0 to GND until the led turns off + * - Portenta Machine Control: the reset is not available * - Other boards: short the pin 2 to GND until the led turns off * * In this sketch the BLE and Serial interfaces are always enabled and ready for accepting diff --git a/src/ANetworkConfigurator_Config.h b/src/ANetworkConfigurator_Config.h index e1ca4cd..b6e3593 100644 --- a/src/ANetworkConfigurator_Config.h +++ b/src/ANetworkConfigurator_Config.h @@ -57,7 +57,9 @@ #if defined(ARDUINO_PORTENTA_H7_M7) #define NETWORK_CONFIGURATOR_COMPATIBLE 1 #define ZERO_TOUCH_ENABLED 1 - #define PIN_RECONFIGURE 2 + #define I2C_ADD_DETECT_MACHINE_CONTROL_1 0x23 + #define I2C_ADD_DETECT_MACHINE_CONTROL_2 0x22 + #define PIN_RECONFIGURE 0 #define LED_RECONFIGURE LED_BUILTIN #define BOARD_HAS_RGB #define GREEN_LED LEDG @@ -108,7 +110,7 @@ #if defined(ARDUINO_PORTENTA_C33) #define NETWORK_CONFIGURATOR_COMPATIBLE 1 #define ZERO_TOUCH_ENABLED 1 - #define PIN_RECONFIGURE 2 + #define PIN_RECONFIGURE 0 #define LED_RECONFIGURE LEDG #define BOARD_HAS_RGB #define GREEN_LED LEDG diff --git a/src/Arduino_NetworkConfigurator.cpp b/src/Arduino_NetworkConfigurator.cpp index f448b1f..40c33c4 100644 --- a/src/Arduino_NetworkConfigurator.cpp +++ b/src/Arduino_NetworkConfigurator.cpp @@ -122,6 +122,9 @@ NetworkConfiguratorStates NetworkConfiguratorClass::update() { * - Arduino MKR WiFi 1010: short the pin 7 to GND until the led turns off * - Arduino GIGA R1 WiFi: short the pin 7 to GND until the led turns off * - Arduino Nano RP2040 Connect: short the pin 2 to 3.3V until the led turns off + * - Portenta H7: short the pin 0 to GND until the led turns off + * - Portenta C33: short the pin 0 to GND until the led turns off + * - Portenta Machine Control: the reset is not available * - Other boards: short the pin 2 to GND until the led turns off */ diff --git a/src/Arduino_NetworkConfigurator.h b/src/Arduino_NetworkConfigurator.h index d68bbdb..fafe125 100644 --- a/src/Arduino_NetworkConfigurator.h +++ b/src/Arduino_NetworkConfigurator.h @@ -58,6 +58,9 @@ enum class NetworkConfiguratorStates { ZERO_TOUCH_CONFIG, * - Arduino MKR WiFi 1010: short the pin 7 to GND until the led turns off * - Arduino GIGA R1 WiFi: short the pin 7 to GND until the led turns off * - Arduino Nano RP2040 Connect: short the pin 2 to 3.3V until the led turns off + * - Portenta H7: short the pin 0 to GND until the led turns off + * - Portenta C33: short the pin 0 to GND until the led turns off + * - Portenta Machine Control: the reset is not available * - Other boards: short the pin 2 to GND until the led turns off * */ diff --git a/src/utility/ResetInput.cpp b/src/utility/ResetInput.cpp index 0df5fc0..70d322e 100644 --- a/src/utility/ResetInput.cpp +++ b/src/utility/ResetInput.cpp @@ -11,6 +11,28 @@ #include "ResetInput.h" #include "utility/LEDFeedback.h" +#if defined(ARDUINO_PORTENTA_H7_M7) +#include + + +bool isPortentaMachineControlAttached() { + Wire.begin(); + Wire.beginTransmission(I2C_ADD_DETECT_MACHINE_CONTROL_1); + if (Wire.endTransmission() != 0) { + return false; + } + + Wire.beginTransmission(I2C_ADD_DETECT_MACHINE_CONTROL_2); + if (Wire.endTransmission() != 0) { + return false; + } + + Wire.end(); + return true; +} + +#endif + ResetInput &ResetInput::getInstance() { static ResetInput instance; return instance; @@ -25,6 +47,12 @@ ResetInput::ResetInput() { } void ResetInput::begin() { +#if defined(ARDUINO_PORTENTA_H7_M7) + if(isPortentaMachineControlAttached()) { + return; // Portenta Machine Control is not supported + } +#endif + if(_pin == DISABLE_PIN){ return; } @@ -35,7 +63,6 @@ void ResetInput::begin() { #endif pinMode(LED_RECONFIGURE, OUTPUT); digitalWrite(LED_RECONFIGURE, LED_OFF); - attachInterrupt(digitalPinToInterrupt(_pin),_pressedCallback, CHANGE); } From 7bf56c8c07c3c4c4ffcd95bd2583d9123f6b46e7 Mon Sep 17 00:00:00 2001 From: fabik111 Date: Thu, 26 Jun 2025 11:03:28 +0200 Subject: [PATCH 11/19] Release version 0.2.0 --- library.properties | 2 +- src/ANetworkConfigurator_Config.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library.properties b/library.properties index d960065..14cbfa0 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Arduino_NetworkConfigurator -version=0.1.4 +version=0.2.0 author=Arduino maintainer=Arduino sentence=This library allows to configure and update the network settings of a ConnectionHandler instance. diff --git a/src/ANetworkConfigurator_Config.h b/src/ANetworkConfigurator_Config.h index b6e3593..465659f 100644 --- a/src/ANetworkConfigurator_Config.h +++ b/src/ANetworkConfigurator_Config.h @@ -7,7 +7,7 @@ */ #pragma once -#define ANetworkConfigurator_LIB_VERSION "0.1.4" +#define ANetworkConfigurator_LIB_VERSION "0.2.0" #if defined(ARDUINO_SAMD_MKRWIFI1010) #define NETWORK_CONFIGURATOR_COMPATIBLE 1 From 4bcfe6a6f09a942b7f68015ad526119dcbc3ca11 Mon Sep 17 00:00:00 2001 From: Fabio C Date: Thu, 3 Jul 2025 11:13:06 +0200 Subject: [PATCH 12/19] use wifi cbor encoder of cloud utils (#14) --- .../src/test_provisioning_command_encode.cpp | 27 ------------------- .../CBORAdapter.cpp | 6 ++--- .../cbor/CBORInstances.h | 1 - .../cbor/Encoder.cpp | 19 ------------- .../boardConfigurationProtocol/cbor/Encoder.h | 8 ------ .../cbor/ProvisioningMessage.h | 10 +------ 6 files changed, 4 insertions(+), 67 deletions(-) diff --git a/extras/test/src/test_provisioning_command_encode.cpp b/extras/test/src/test_provisioning_command_encode.cpp index 64872fc..529df0c 100644 --- a/extras/test/src/test_provisioning_command_encode.cpp +++ b/extras/test/src/test_provisioning_command_encode.cpp @@ -209,33 +209,6 @@ } } - WHEN("Encode a message with provisioning wifi fw version ") - { - WiFiFWVersionProvisioningMessage command; - command.c.id = ProvisioningMessageId::WiFiFWVersionProvisioningMessageId; - command.wifiFwVersion = "1.6.0"; - uint8_t buffer[512]; - size_t bytes_encoded = sizeof(buffer); - - CBORMessageEncoder encoder; - MessageEncoder::Status err = encoder.encode((Message*)&command, buffer, bytes_encoded); - - uint8_t expected_result[] = { - 0xda, 0x00, 0x01, 0x20, 0x14, 0x81, 0x65, 0x31, 0x2E, 0x36, 0x2E, 0x30 - }; - - // Test the encoding is - //DA 00012014 # tag(73748) - // 81 # array(1) - // 65 # text(5) - // 312E362E30 # "1.6.0" - THEN("The encoding is successful") { - REQUIRE(err == MessageEncoder::Status::Complete); - REQUIRE(bytes_encoded == sizeof(expected_result)); - REQUIRE(memcmp(buffer, expected_result, sizeof(expected_result)) == 0); - } - } - WHEN("Encode a message with provisioning sketch version ") { ProvSketchVersionProvisioningMessage command; diff --git a/src/configuratorAgents/agents/boardConfigurationProtocol/CBORAdapter.cpp b/src/configuratorAgents/agents/boardConfigurationProtocol/CBORAdapter.cpp index 96fcbf5..5442932 100644 --- a/src/configuratorAgents/agents/boardConfigurationProtocol/CBORAdapter.cpp +++ b/src/configuratorAgents/agents/boardConfigurationProtocol/CBORAdapter.cpp @@ -87,9 +87,9 @@ bool CBORAdapter::wifiFWVersionToCBOR(const char *wifiFWVersion, uint8_t *data, if(*len < CBOR_MIN_WIFI_FW_VERSION_LEN + strlen(wifiFWVersion)) { return false; } - WiFiFWVersionProvisioningMessage wifiFWVersionMsg; - wifiFWVersionMsg.c.id = ProvisioningMessageId::WiFiFWVersionProvisioningMessageId; - wifiFWVersionMsg.wifiFwVersion = wifiFWVersion; + VersionMessage wifiFWVersionMsg; + wifiFWVersionMsg.c.id = StandardMessageId::WiFiFWVersionMessageId; + wifiFWVersionMsg.params.version = wifiFWVersion; MessageEncoder::Status status = encoder.encode((Message *)&wifiFWVersionMsg, data, *len); diff --git a/src/configuratorAgents/agents/boardConfigurationProtocol/cbor/CBORInstances.h b/src/configuratorAgents/agents/boardConfigurationProtocol/cbor/CBORInstances.h index b726e0f..dbca315 100644 --- a/src/configuratorAgents/agents/boardConfigurationProtocol/cbor/CBORInstances.h +++ b/src/configuratorAgents/agents/boardConfigurationProtocol/cbor/CBORInstances.h @@ -8,7 +8,6 @@ static ListWifiNetworksProvisioningMessageEncoder listWifiNetworksProvisioning static UniqueHardwareIdProvisioningMessageEncoder uniqueHardwareIdProvisioningMessageEncoder; static JWTProvisioningMessageEncoder jWTProvisioningMessageEncoder; static BLEMacAddressProvisioningMessageEncoder bLEMacAddressProvisioningMessageEncoder; -static WiFiFWVersionProvisioningMessageEncoder wiFiFWVersionProvisioningMessageEncoder; static ProvSketchVersionProvisioningMessageEncoder provSketchVersionProvisioningMessageEncoder; static NetConfigLibVersProvisioningMessageEncoder netConfigLibVersProvisioningMessageEncoder; diff --git a/src/configuratorAgents/agents/boardConfigurationProtocol/cbor/Encoder.cpp b/src/configuratorAgents/agents/boardConfigurationProtocol/cbor/Encoder.cpp index fd0bb07..6c501f9 100644 --- a/src/configuratorAgents/agents/boardConfigurationProtocol/cbor/Encoder.cpp +++ b/src/configuratorAgents/agents/boardConfigurationProtocol/cbor/Encoder.cpp @@ -116,25 +116,6 @@ MessageEncoder::Status BLEMacAddressProvisioningMessageEncoder::encode(CborEncod return MessageEncoder::Status::Complete; } -MessageEncoder::Status WiFiFWVersionProvisioningMessageEncoder::encode(CborEncoder* encoder, Message *msg) { - WiFiFWVersionProvisioningMessage * provisioningWiFiFWVersion = (WiFiFWVersionProvisioningMessage*) msg; - CborEncoder array_encoder; - - if(cbor_encoder_create_array(encoder, &array_encoder, 1) != CborNoError) { - return MessageEncoder::Status::Error; - } - - if(cbor_encode_text_stringz(&array_encoder, provisioningWiFiFWVersion->wifiFwVersion) != CborNoError) { - return MessageEncoder::Status::Error; - } - - if(cbor_encoder_close_container(encoder, &array_encoder) != CborNoError) { - return MessageEncoder::Status::Error; - } - - return MessageEncoder::Status::Complete; -} - MessageEncoder::Status ProvSketchVersionProvisioningMessageEncoder::encode(CborEncoder* encoder, Message *msg) { ProvSketchVersionProvisioningMessage * provisioningSketchVersion = (ProvSketchVersionProvisioningMessage*) msg; CborEncoder array_encoder; diff --git a/src/configuratorAgents/agents/boardConfigurationProtocol/cbor/Encoder.h b/src/configuratorAgents/agents/boardConfigurationProtocol/cbor/Encoder.h index fd02dfa..25934f4 100644 --- a/src/configuratorAgents/agents/boardConfigurationProtocol/cbor/Encoder.h +++ b/src/configuratorAgents/agents/boardConfigurationProtocol/cbor/Encoder.h @@ -52,14 +52,6 @@ class BLEMacAddressProvisioningMessageEncoder: public CBORMessageEncoderInterfac MessageEncoder::Status encode(CborEncoder* encoder, Message *msg) override; }; -class WiFiFWVersionProvisioningMessageEncoder: public CBORMessageEncoderInterface { -public: - WiFiFWVersionProvisioningMessageEncoder() - : CBORMessageEncoderInterface(CBORWiFiFWVersionProvisioningMessage, WiFiFWVersionProvisioningMessageId) {} -protected: - MessageEncoder::Status encode(CborEncoder* encoder, Message *msg) override; -}; - class ProvSketchVersionProvisioningMessageEncoder: public CBORMessageEncoderInterface { public: ProvSketchVersionProvisioningMessageEncoder() diff --git a/src/configuratorAgents/agents/boardConfigurationProtocol/cbor/ProvisioningMessage.h b/src/configuratorAgents/agents/boardConfigurationProtocol/cbor/ProvisioningMessage.h index 240a7b5..d48800d 100644 --- a/src/configuratorAgents/agents/boardConfigurationProtocol/cbor/ProvisioningMessage.h +++ b/src/configuratorAgents/agents/boardConfigurationProtocol/cbor/ProvisioningMessage.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -47,7 +48,6 @@ enum CBORProvisioningMessageTag: CBORTag { CBORUniqueHardwareIdProvisioningMessage = 0x012010, CBORJWTProvisioningMessage = 0x012011, CBORBLEMacAddressProvisioningMessage = 0x012013, - CBORWiFiFWVersionProvisioningMessage = 0x012014, CBORProvSketchVersionProvisioningMessage = 0x012015, CBORNetConfigLibVersProvisioningMessage = 0x012016, }; @@ -58,7 +58,6 @@ enum ProvisioningMessageId: MessageId { ListWifiNetworksProvisioningMessageId, UniqueHardwareIdProvisioningMessageId, BLEMacAddressProvisioningMessageId, - WiFiFWVersionProvisioningMessageId, ProvSketchVersionProvisioningMessageId, NetConfigLibVersProvisioningMessageId, JWTProvisioningMessageId, @@ -116,13 +115,6 @@ struct BLEMacAddressProvisioningMessage { }; }; -struct WiFiFWVersionProvisioningMessage { - ProvisioningMessage c; - struct { - const char *wifiFwVersion; //The payload is a string. - }; -}; - struct ProvSketchVersionProvisioningMessage { ProvisioningMessage c; struct { From bede629b56b108116daca7d084d975cfdde87457 Mon Sep 17 00:00:00 2001 From: Fabio C Date: Thu, 3 Jul 2025 16:26:22 +0200 Subject: [PATCH 13/19] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 48b1085..57199a7 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ In order to disable the reconfiguration procedure, use this function in the sket ## Configurator Agents -The library provides a set of *Configurator Agents* that added as plug-in to the sketch handle the communication between the Arduino Network Configurator and an external client ([*Arduino IoT App*](https://cloud.arduino.cc/iot-remote-app/) and Arduino IoT Cloud) for configuring the board. +The library provides a set of *Configurator Agents* that added as plug-in to the sketch handle the communication between the Arduino Network Configurator and an external client ([*Arduino IoT App*](https://cloud.arduino.cc/iot-remote-app/), Arduino IoT Cloud, [*Arduino Cloud CLI from v0.3.4*](https://github.com/arduino/arduino-cloud-cli)) for configuring the board. Out-of-the box there are 2 Configurator Agents * `BLEAgent`: manage the BLE interface From 899af0a38ea7bab2dddaa5018e3ff8706b06d136 Mon Sep 17 00:00:00 2001 From: Fabio C Date: Fri, 4 Jul 2025 09:18:17 +0200 Subject: [PATCH 14/19] Add new animation for board connected with Serial or BLE Agent(#16) --- src/configuratorAgents/AgentsManager.cpp | 10 +++- src/utility/LEDFeedback.cpp | 62 ++++++++++++++++-------- src/utility/LEDFeedback.h | 3 ++ 3 files changed, 53 insertions(+), 22 deletions(-) diff --git a/src/configuratorAgents/AgentsManager.cpp b/src/configuratorAgents/AgentsManager.cpp index 71f8f34..bff98ee 100644 --- a/src/configuratorAgents/AgentsManager.cpp +++ b/src/configuratorAgents/AgentsManager.cpp @@ -239,7 +239,15 @@ AgentsManagerStates AgentsManagerClass::handleInit() { (*agent)->end(); } } - LEDFeedbackClass::getInstance().setMode(LEDFeedbackClass::LEDFeedbackMode::PEER_CONNECTED); + + if(_selectedAgent->getAgentType() == ConfiguratorAgent::AgentTypes::BLE) { + LEDFeedbackClass::getInstance().setMode(LEDFeedbackClass::LEDFeedbackMode::PEER_CONNECTED_BLE); + } else if(_selectedAgent->getAgentType() == ConfiguratorAgent::AgentTypes::USB_SERIAL) { + LEDFeedbackClass::getInstance().setMode(LEDFeedbackClass::LEDFeedbackMode::PEER_CONNECTED_SERIAL); + } else { + LEDFeedbackClass::getInstance().setMode(LEDFeedbackClass::LEDFeedbackMode::PEER_CONNECTED); + } + } return nextState; } diff --git a/src/utility/LEDFeedback.cpp b/src/utility/LEDFeedback.cpp index 10abfe7..2ae9dc7 100644 --- a/src/utility/LEDFeedback.cpp +++ b/src/utility/LEDFeedback.cpp @@ -19,6 +19,14 @@ #include "Arduino_LED_Matrix.h" ArduinoLEDMatrix ledMatrixAnimationHandler; + +const uint32_t usb_image[3] = { + 0x3c, + 0x267fe0, + 0x160e0000, + +}; + const uint32_t bluetooth[3] = { 0x401600d, @@ -28,22 +36,16 @@ const uint32_t bluetooth[3] = { const uint32_t cloud[][4] = { { - 0xc013, - 0x82644424, - 0x24023fc, - 66 - }, - { - 0xc013, - 0x82644424, - 0x24023fc, - 66 + 0x1c023, + 0x4484044, + 0x43f8000, + 500 }, { - 0xc013, - 0x82644824, - 0x24023fc, - 66 + 0xe011, + 0x82242022, + 0x21fc000, + 500 } }; @@ -204,17 +206,25 @@ void LEDFeedbackClass::setMode(LEDFeedbackMode mode) { break; case LEDFeedbackMode::PEER_CONNECTED: { - #ifdef BOARD_HAS_RGB - turnOFF(); - _ledPin = BLUE_LED; - #else - _ledPin = GREEN_LED; - #endif + configurePeerConnectedMode(); + } + break; + case LEDFeedbackMode::PEER_CONNECTED_BLE: + { + configurePeerConnectedMode(); #ifdef BOARD_HAS_LED_MATRIX ledMatrixAnimationHandler.loadFrame(bluetooth); _framePtr = (uint32_t*)bluetooth; #endif - _ledChangeInterval = ALWAYS_ON_INTERVAL; + } + break; + case LEDFeedbackMode::PEER_CONNECTED_SERIAL: + { + configurePeerConnectedMode(); + #ifdef BOARD_HAS_LED_MATRIX + ledMatrixAnimationHandler.loadFrame(usb_image); + _framePtr = (uint32_t*)usb_image; + #endif } break; case LEDFeedbackMode::CONNECTING_TO_NETWORK: @@ -348,4 +358,14 @@ void LEDFeedbackClass::turnON() { _ledState = true; } +void LEDFeedbackClass::configurePeerConnectedMode() { + #ifdef BOARD_HAS_RGB + turnOFF(); + _ledPin = BLUE_LED; + #else + _ledPin = GREEN_LED; + #endif + _ledChangeInterval = ALWAYS_ON_INTERVAL; +} + #endif // NETWORK_CONFIGURATOR_COMPATIBLE diff --git a/src/utility/LEDFeedback.h b/src/utility/LEDFeedback.h index 2360e04..46d08ba 100644 --- a/src/utility/LEDFeedback.h +++ b/src/utility/LEDFeedback.h @@ -16,6 +16,8 @@ class LEDFeedbackClass { NONE, BLE_AVAILABLE, PEER_CONNECTED, + PEER_CONNECTED_BLE, + PEER_CONNECTED_SERIAL, CONNECTING_TO_NETWORK, CONNECTED_TO_CLOUD, ERROR @@ -30,6 +32,7 @@ class LEDFeedbackClass { LEDFeedbackClass() {}; void turnON(); void turnOFF(); + void configurePeerConnectedMode(); LEDFeedbackMode _mode = LEDFeedbackMode::NONE; uint32_t _lastUpdate = 0; uint32_t _count = 0; From bd82bd621a03b7963a842613fb93ba301b15c1c3 Mon Sep 17 00:00:00 2001 From: fabik111 Date: Mon, 7 Jul 2025 09:28:42 +0200 Subject: [PATCH 15/19] Release version 0.2.1 --- library.properties | 2 +- src/ANetworkConfigurator_Config.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library.properties b/library.properties index 14cbfa0..89fcfba 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Arduino_NetworkConfigurator -version=0.2.0 +version=0.2.1 author=Arduino maintainer=Arduino sentence=This library allows to configure and update the network settings of a ConnectionHandler instance. diff --git a/src/ANetworkConfigurator_Config.h b/src/ANetworkConfigurator_Config.h index 465659f..6fb9ec0 100644 --- a/src/ANetworkConfigurator_Config.h +++ b/src/ANetworkConfigurator_Config.h @@ -7,7 +7,7 @@ */ #pragma once -#define ANetworkConfigurator_LIB_VERSION "0.2.0" +#define ANetworkConfigurator_LIB_VERSION "0.2.1" #if defined(ARDUINO_SAMD_MKRWIFI1010) #define NETWORK_CONFIGURATOR_COMPATIBLE 1 From 82b10578dfe912e040daaf1e09e5741d0cb7e079 Mon Sep 17 00:00:00 2001 From: Fabio C Date: Fri, 18 Jul 2025 11:04:36 +0200 Subject: [PATCH 16/19] Handle migration from Provisioning 1.0 to Provisioning 2.0 (#6) * add public key message * for zero-touch enabled boards read the storage before run zero-touch procedure * in read_storage state added a check if a peer is connected for configuration * update version 0.3.0 --- .../src/test_provisioning_command_encode.cpp | 61 ++++++++++++++++++- library.properties | 2 +- src/ANetworkConfigurator_Config.h | 2 +- src/Arduino_NetworkConfigurator.cpp | 37 ++++++----- src/configuratorAgents/AgentsManager.cpp | 3 +- src/configuratorAgents/MessagesDefinitions.h | 2 + .../BoardConfigurationProtocol.cpp | 20 ++++++ .../BoardConfigurationProtocol.h | 1 + .../CBORAdapter.cpp | 14 +++++ .../boardConfigurationProtocol/CBORAdapter.h | 2 + .../cbor/CBORInstances.h | 1 + .../cbor/Encoder.cpp | 19 ++++++ .../boardConfigurationProtocol/cbor/Encoder.h | 8 +++ .../cbor/ProvisioningMessage.h | 9 +++ 14 files changed, 161 insertions(+), 20 deletions(-) diff --git a/extras/test/src/test_provisioning_command_encode.cpp b/extras/test/src/test_provisioning_command_encode.cpp index 529df0c..2211ee7 100644 --- a/extras/test/src/test_provisioning_command_encode.cpp +++ b/extras/test/src/test_provisioning_command_encode.cpp @@ -181,6 +181,66 @@ } } + WHEN("Encode a message with provisioning public key") + { + ProvPublicKeyProvisioningMessage command; + command.c.id = ProvisioningMessageId::ProvPublicKeyProvisioningMessageId; + command.provPublicKey = "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE7JxCtXl5SvIrHmiasqyN4pyoXRlm44d5WXNpqmvJ\nk0tH8UpmIeHG7YPAkKLaqid95v/wLVoWeX5EbjxmlCkFtw==\n-----END PUBLIC KEY-----\n"; + uint8_t buffer[512]; + size_t bytes_encoded = sizeof(buffer); + + CBORMessageEncoder encoder; + MessageEncoder::Status err = encoder.encode((Message*)&command, buffer, bytes_encoded); + + // Test the encoding is + // DA 00012017 # tag(73751) + // 81 # array(1) + // 78 B4 # text(180) + // 2D 2D 2D 2D 2D 4245 47 49 4E 20 50 55 42 4C 49 43204B45592D2D2D2D2D0A0A4D466B77457759484B6F5A497A6A3043415159494B6F5A497A6A3044415163445167414537 + // 4A784374586C3553764972486D69617371794E3470796F58526C6D3434643557584E70716D764A0A6B3074483855706D49654847375950416B4B4C617169643935762F774C566F5765583545626A786D6C436B4674773D3D0A0A2D2D2D2D2D454E44205055424C4943204B45592D2D2D2D2D0A + + uint8_t expected_result[] = { + 0xDA, 0x00, 0x01, 0x20, 0x17, 0x81, 0x78, 0xB2, + 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x42, 0x45, 0x47, 0x49, 0x4E, 0x20, 0x50, 0x55, 0x42, 0x4C, 0x49, + 0x43, 0x20, 0x4B, 0x45, 0x59, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x0A, 0x4D, 0x46, 0x6B, 0x77, + 0x45, 0x77, 0x59, 0x48, 0x4B, 0x6F, 0x5A, 0x49, + 0x7A, 0x6A, 0x30, 0x43, 0x41, 0x51, 0x59, 0x49, 0x4B, 0x6F, 0x5A, 0x49, + 0x7A, 0x6A, 0x30, 0x44, 0x41, 0x51, 0x63, 0x44, 0x51, 0x67, 0x41, 0x45, + 0x37, 0x4A, 0x78, 0x43, 0x74, 0x58, 0x6C, 0x35, 0x53, 0x76, 0x49, 0x72, + 0x48, 0x6D, 0x69, 0x61, 0x73, 0x71, 0x79, 0x4E, 0x34, 0x70, 0x79, 0x6F, + 0x58, 0x52, 0x6C, 0x6D, 0x34, 0x34, 0x64, 0x35, 0x57, 0x58, 0x4E, 0x70, + 0x71, 0x6D, 0x76, 0x4A, 0x0A, 0x6B, 0x30, 0x74, 0x48, 0x38, 0x55, 0x70, + 0x6D, 0x49, 0x65, 0x48, 0x47, 0x37, 0x59, 0x50, 0x41, 0x6B, 0x4B, 0x4C, + 0x61, 0x71, 0x69, 0x64, 0x39, 0x35, 0x76, 0x2F, 0x77, 0x4C, 0x56, 0x6F, + 0x57, 0x65, 0x58, 0x35, 0x45, 0x62, 0x6A, 0x78, 0x6D, 0x6C, 0x43, 0x6B, + 0x46, 0x74, 0x77, 0x3D, 0x3D, 0x0A, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, + 0x45, 0x4E, 0x44, 0x20, 0x50, 0x55, 0x42, 0x4C, 0x49, 0x43, 0x20, 0x4B, + 0x45, 0x59, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x0A + }; + + THEN("The encoding is successful") { + REQUIRE(err == MessageEncoder::Status::Complete); + REQUIRE(bytes_encoded == sizeof(expected_result)); + REQUIRE(memcmp(buffer, expected_result, sizeof(expected_result)) == 0); + } + } + + WHEN("Encode a message with provisioning public key") + { + ProvPublicKeyProvisioningMessage command; + command.c.id = ProvisioningMessageId::ProvPublicKeyProvisioningMessageId; + command.provPublicKey = "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE7JxCtXl5SvIrHmiasqyN4pyoXRlm44d5WXNpqmvJ\nk0tH8UpmIeHG7YPAkKLaqid95v/wLVoWeX5EbjxmlCkFtw==\n-----END PUBLIC KEY-----\n"; + uint8_t buffer[50]; + size_t bytes_encoded = sizeof(buffer); + + CBORMessageEncoder encoder; + MessageEncoder::Status err = encoder.encode((Message*)&command, buffer, bytes_encoded); + + THEN("The encoding is failing") { + REQUIRE(err == MessageEncoder::Status::Error); + } + } + WHEN("Encode a message with provisioning ble mac Address ") { BLEMacAddressProvisioningMessage command; @@ -256,7 +316,6 @@ // 81 # array(1) // 65 # text(5) // 312E362E30 # "1.6.0" - printf("res %d\n", (int)err); THEN("The encoding is successful") { REQUIRE(err == MessageEncoder::Status::Complete); REQUIRE(bytes_encoded == sizeof(expected_result)); diff --git a/library.properties b/library.properties index 89fcfba..2605e46 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Arduino_NetworkConfigurator -version=0.2.1 +version=0.3.0 author=Arduino maintainer=Arduino sentence=This library allows to configure and update the network settings of a ConnectionHandler instance. diff --git a/src/ANetworkConfigurator_Config.h b/src/ANetworkConfigurator_Config.h index 6fb9ec0..979e5ef 100644 --- a/src/ANetworkConfigurator_Config.h +++ b/src/ANetworkConfigurator_Config.h @@ -7,7 +7,7 @@ */ #pragma once -#define ANetworkConfigurator_LIB_VERSION "0.2.1" +#define ANetworkConfigurator_LIB_VERSION "0.3.0" #if defined(ARDUINO_SAMD_MKRWIFI1010) #define NETWORK_CONFIGURATOR_COMPATIBLE 1 diff --git a/src/Arduino_NetworkConfigurator.cpp b/src/Arduino_NetworkConfigurator.cpp index 40c33c4..ee7d3cc 100644 --- a/src/Arduino_NetworkConfigurator.cpp +++ b/src/Arduino_NetworkConfigurator.cpp @@ -49,19 +49,9 @@ bool NetworkConfiguratorClass::begin() { if(_state != NetworkConfiguratorStates::END) { return true; } - /* - * If the board is zero touch capable, starts with zero touch configuration mode - * In this state the board will try to connect to the network using a set of - * default network settings ex. Ethernet with DHCP - * This mode will fail if the provided ConnectionHandler is not GenericConnectionHandler type - * falling back to read the network settings from the storage - */ - #if ZERO_TOUCH_ENABLED - _state = NetworkConfiguratorStates::ZERO_TOUCH_CONFIG; - #else _state = NetworkConfiguratorStates::READ_STORED_CONFIG; - #endif + _connectionHandler->enableCheckInternetAvailability(true); memset(&_networkSetting, 0x00, sizeof(models::NetworkSetting)); @@ -98,10 +88,10 @@ NetworkConfiguratorStates NetworkConfiguratorClass::update() { _ledFeedback->update(); switch (_state) { + case NetworkConfiguratorStates::READ_STORED_CONFIG: nextState = handleReadStorage (); break; #if ZERO_TOUCH_ENABLED case NetworkConfiguratorStates::ZERO_TOUCH_CONFIG: nextState = handleZeroTouchConfig(); break; #endif - case NetworkConfiguratorStates::READ_STORED_CONFIG: nextState = handleReadStorage (); break; case NetworkConfiguratorStates::WAITING_FOR_CONFIG: nextState = handleWaitingForConf (); break; case NetworkConfiguratorStates::CONNECTING: nextState = handleConnecting (); break; case NetworkConfiguratorStates::CONFIGURED: nextState = handleConfigured (); break; @@ -459,7 +449,7 @@ NetworkConfiguratorStates NetworkConfiguratorClass::handleZeroTouchConfig() { defaultEthernetSettings(); #endif if (!_connectionHandler->updateSetting(_networkSetting)) { - return NetworkConfiguratorStates::READ_STORED_CONFIG; + return NetworkConfiguratorStates::WAITING_FOR_CONFIG; } _connectionHandlerIstantiated = true; _connectionTimeout.reload(); @@ -475,9 +465,10 @@ NetworkConfiguratorStates NetworkConfiguratorClass::handleZeroTouchConfig() { sendStatus(StatusMessage::ERROR); } _connectionHandlerIstantiated = false; - return NetworkConfiguratorStates::READ_STORED_CONFIG; + return NetworkConfiguratorStates::WAITING_FOR_CONFIG; } - return NetworkConfiguratorStates::ZERO_TOUCH_CONFIG; + + return handleWaitingForConf(); } #endif @@ -512,13 +503,26 @@ NetworkConfiguratorStates NetworkConfiguratorClass::handleReadStorage() { if(credFound && _connectionHandler->updateSetting(_networkSetting)) { _connectionHandlerIstantiated = true; + _configInProgress = _agentsManager->isConfigInProgress(); + if (_configInProgress) { + return NetworkConfiguratorStates::UPDATING_CONFIG; + } return NetworkConfiguratorStates::CONFIGURED; } if (_optionUpdateTimer.getWaitTime() == 0) { scanNetworkOptions(); } + /* + * If the board is zero touch capable and without network configuration, it starts the zero touch configuration mode + * In this state the board will try to connect to the network using a set of + * default network settings ex. Ethernet with DHCP + */ + #if ZERO_TOUCH_ENABLED + return NetworkConfiguratorStates::ZERO_TOUCH_CONFIG; + #else return NetworkConfiguratorStates::WAITING_FOR_CONFIG; + #endif } NetworkConfiguratorStates NetworkConfiguratorClass::handleWaitingForConf() { @@ -583,7 +587,8 @@ NetworkConfiguratorStates NetworkConfiguratorClass::handleConfigured() { } NetworkConfiguratorStates NetworkConfiguratorClass::handleUpdatingConfig() { - if (_agentsManager->isConfigInProgress() == false) { + _configInProgress = _agentsManager->isConfigInProgress(); + if (_configInProgress == false) { //If peer disconnects without updating the network settings, go to connecting state for check the connection sendStatus(StatusMessage::CONNECTING); return NetworkConfiguratorStates::CONNECTING; diff --git a/src/configuratorAgents/AgentsManager.cpp b/src/configuratorAgents/AgentsManager.cpp index bff98ee..edc3d14 100644 --- a/src/configuratorAgents/AgentsManager.cpp +++ b/src/configuratorAgents/AgentsManager.cpp @@ -316,6 +316,7 @@ void AgentsManagerClass::updateProgressRequest(MessageOutputType type) { case MessageOutputType::WIFI_FW_VERSION: key = RequestType::GET_WIFI_FW_VERSION ; break; case MessageOutputType::PROV_SKETCH_VERSION: key = RequestType::GET_PROVISIONING_SKETCH_VERSION; break; case MessageOutputType::NETCONFIG_LIB_VERSION: key = RequestType::GET_NETCONFIG_LIB_VERSION ; break; + case MessageOutputType::PROV_PUBLIC_KEY: key = RequestType::GET_ID ; break; } if (key == RequestType::NONE) { @@ -324,7 +325,7 @@ void AgentsManagerClass::updateProgressRequest(MessageOutputType type) { if( key == RequestType::GET_ID && _statusRequest.key == key && _statusRequest.pending){ _statusRequest.completion++; - if(_statusRequest.completion == 2){ + if(_statusRequest.completion == 3){ _statusRequest.reset(); } return; diff --git a/src/configuratorAgents/MessagesDefinitions.h b/src/configuratorAgents/MessagesDefinitions.h index 2f2d460..de456c8 100644 --- a/src/configuratorAgents/MessagesDefinitions.h +++ b/src/configuratorAgents/MessagesDefinitions.h @@ -61,6 +61,7 @@ enum class MessageOutputType { STATUS, WIFI_FW_VERSION, PROV_SKETCH_VERSION, NETCONFIG_LIB_VERSION, + PROV_PUBLIC_KEY }; /* Types of ingoing messages */ @@ -86,6 +87,7 @@ struct ProvisioningOutputMessage { const char *wifiFwVersion; const char *provSketchVersion; const char *netConfigLibVersion; + const char *provPublicKey; } m; }; diff --git a/src/configuratorAgents/agents/boardConfigurationProtocol/BoardConfigurationProtocol.cpp b/src/configuratorAgents/agents/boardConfigurationProtocol/BoardConfigurationProtocol.cpp index e0d856f..764c5ce 100644 --- a/src/configuratorAgents/agents/boardConfigurationProtocol/BoardConfigurationProtocol.cpp +++ b/src/configuratorAgents/agents/boardConfigurationProtocol/BoardConfigurationProtocol.cpp @@ -75,6 +75,9 @@ bool BoardConfigurationProtocol::sendMsg(ProvisioningOutputMessage &msg) { case MessageOutputType::NETCONFIG_LIB_VERSION: res = sendVersion(msg.m.netConfigLibVersion, msg.type); break; + case MessageOutputType::PROV_PUBLIC_KEY: + res = sendProvPublicKey(msg.m.provPublicKey, strlen(msg.m.provPublicKey)); + break; default: break; } @@ -294,6 +297,23 @@ bool BoardConfigurationProtocol::sendJwt(const char *jwt, size_t len) { return res; } +bool BoardConfigurationProtocol::sendProvPublicKey(const char *provPublicKey, size_t len) { + + size_t cborDataLen = CBOR_MIN_PROV_PUBIC_KEY_LEN + len; + uint8_t data[cborDataLen]; + + if (!CBORAdapter::provPublicKeyToCBOR(provPublicKey, data, &cborDataLen)) { + return false; + } + + if (!sendData(PacketManager::MessageType::DATA, data, cborDataLen)) { + DEBUG_WARNING("BoardConfigurationProtocol::%s failed to send JWT", __FUNCTION__); + return false; + } + + return true; +} + bool BoardConfigurationProtocol::sendBleMacAddress(const uint8_t *mac, size_t len) { bool res = false; if (len != BLE_MAC_ADDRESS_SIZE) { diff --git a/src/configuratorAgents/agents/boardConfigurationProtocol/BoardConfigurationProtocol.h b/src/configuratorAgents/agents/boardConfigurationProtocol/BoardConfigurationProtocol.h index 3a82291..e206f62 100644 --- a/src/configuratorAgents/agents/boardConfigurationProtocol/BoardConfigurationProtocol.h +++ b/src/configuratorAgents/agents/boardConfigurationProtocol/BoardConfigurationProtocol.h @@ -96,6 +96,7 @@ class BoardConfigurationProtocol { bool sendNetworkOptions(const NetworkOptions *netOptions); bool sendUhwid(const byte *uhwid); bool sendJwt(const char *jwt, size_t len); + bool sendProvPublicKey(const char *provPublicKey, size_t len); bool sendBleMacAddress(const uint8_t *mac, size_t len); bool sendVersion(const char *version, MessageOutputType type); TransmissionResult transmitStream(); diff --git a/src/configuratorAgents/agents/boardConfigurationProtocol/CBORAdapter.cpp b/src/configuratorAgents/agents/boardConfigurationProtocol/CBORAdapter.cpp index 5442932..0f7a5a4 100644 --- a/src/configuratorAgents/agents/boardConfigurationProtocol/CBORAdapter.cpp +++ b/src/configuratorAgents/agents/boardConfigurationProtocol/CBORAdapter.cpp @@ -68,6 +68,20 @@ bool CBORAdapter::BLEMacAddressToCBOR(const uint8_t *mac, uint8_t *data, size_t return status == MessageEncoder::Status::Complete ? true : false; } +bool CBORAdapter::provPublicKeyToCBOR(const char *provPublicKey, uint8_t *data, size_t *len) { + CBORMessageEncoder encoder; + if(*len < CBOR_MIN_PROV_PUBIC_KEY_LEN + strlen(provPublicKey)) { + return false; + } + ProvPublicKeyProvisioningMessage provPublicKeyMsg; + provPublicKeyMsg.c.id = ProvisioningMessageId::ProvPublicKeyProvisioningMessageId; + provPublicKeyMsg.provPublicKey = provPublicKey; + + MessageEncoder::Status status = encoder.encode((Message *)&provPublicKeyMsg, data, *len); + + return status == MessageEncoder::Status::Complete ? true : false; +} + bool CBORAdapter::statusToCBOR(StatusMessage msg, uint8_t *data, size_t *len) { bool result = false; diff --git a/src/configuratorAgents/agents/boardConfigurationProtocol/CBORAdapter.h b/src/configuratorAgents/agents/boardConfigurationProtocol/CBORAdapter.h index 09aeef8..5ec177b 100644 --- a/src/configuratorAgents/agents/boardConfigurationProtocol/CBORAdapter.h +++ b/src/configuratorAgents/agents/boardConfigurationProtocol/CBORAdapter.h @@ -21,11 +21,13 @@ #define CBOR_MIN_WIFI_FW_VERSION_LEN CBOR_DATA_HEADER_LEN + 1 // CBOR_DATA_HEADER_LEN + 1 byte for the length of the string #define CBOR_MIN_PROV_SKETCH_VERSION_LEN CBOR_DATA_HEADER_LEN + 1 // CBOR_DATA_HEADER_LEN + 1 byte for the length of the string #define CBOR_MIN_NETCONFIG_LIB_VERSION_LEN CBOR_DATA_HEADER_LEN + 1 // CBOR_DATA_HEADER_LEN + 1 byte for the length of the string +#define CBOR_MIN_PROV_PUBIC_KEY_LEN CBOR_DATA_HEADER_LEN + 3 // CBOR_DATA_HEADER_LEN + 2 bytes for the length of the string + 1 byte for the type of the string class CBORAdapter { public: static bool uhwidToCBOR(const byte *uhwid, uint8_t *data, size_t *len); static bool jwtToCBOR(const char *jwt, uint8_t *data, size_t *len); + static bool provPublicKeyToCBOR(const char *provPublicKey, uint8_t *data, size_t *len); static bool BLEMacAddressToCBOR(const uint8_t *mac, uint8_t *data, size_t *len); static bool wifiFWVersionToCBOR(const char *wifiFWVersion, uint8_t *data, size_t *len); static bool provSketchVersionToCBOR(const char *provSketchVersion, uint8_t *data, size_t *len); diff --git a/src/configuratorAgents/agents/boardConfigurationProtocol/cbor/CBORInstances.h b/src/configuratorAgents/agents/boardConfigurationProtocol/cbor/CBORInstances.h index dbca315..2442db1 100644 --- a/src/configuratorAgents/agents/boardConfigurationProtocol/cbor/CBORInstances.h +++ b/src/configuratorAgents/agents/boardConfigurationProtocol/cbor/CBORInstances.h @@ -7,6 +7,7 @@ static StatusProvisioningMessageEncoder statusProvisioningMessageEnc static ListWifiNetworksProvisioningMessageEncoder listWifiNetworksProvisioningMessageEncoder; static UniqueHardwareIdProvisioningMessageEncoder uniqueHardwareIdProvisioningMessageEncoder; static JWTProvisioningMessageEncoder jWTProvisioningMessageEncoder; +static ProvPublicKeyProvisioningMessageEncoder provPublicKeyProvisioningMessageEncoder; static BLEMacAddressProvisioningMessageEncoder bLEMacAddressProvisioningMessageEncoder; static ProvSketchVersionProvisioningMessageEncoder provSketchVersionProvisioningMessageEncoder; static NetConfigLibVersProvisioningMessageEncoder netConfigLibVersProvisioningMessageEncoder; diff --git a/src/configuratorAgents/agents/boardConfigurationProtocol/cbor/Encoder.cpp b/src/configuratorAgents/agents/boardConfigurationProtocol/cbor/Encoder.cpp index 6c501f9..c688de2 100644 --- a/src/configuratorAgents/agents/boardConfigurationProtocol/cbor/Encoder.cpp +++ b/src/configuratorAgents/agents/boardConfigurationProtocol/cbor/Encoder.cpp @@ -154,4 +154,23 @@ MessageEncoder::Status NetConfigLibVersProvisioningMessageEncoder::encode(CborEn return MessageEncoder::Status::Complete; } +MessageEncoder::Status ProvPublicKeyProvisioningMessageEncoder::encode(CborEncoder *encoder, Message *msg) { + ProvPublicKeyProvisioningMessage * provisioningProvPublicKey = (ProvPublicKeyProvisioningMessage*) msg; + CborEncoder array_encoder; + + if(cbor_encoder_create_array(encoder, &array_encoder, 1) != CborNoError) { + return MessageEncoder::Status::Error; + } + + if(cbor_encode_text_stringz(&array_encoder, provisioningProvPublicKey->provPublicKey) != CborNoError) { + return MessageEncoder::Status::Error; + } + + if(cbor_encoder_close_container(encoder, &array_encoder) != CborNoError) { + return MessageEncoder::Status::Error; + } + + return MessageEncoder::Status::Complete; +} + #endif // NETWORK_CONFIGURATOR_COMPATIBLE diff --git a/src/configuratorAgents/agents/boardConfigurationProtocol/cbor/Encoder.h b/src/configuratorAgents/agents/boardConfigurationProtocol/cbor/Encoder.h index 25934f4..03ca489 100644 --- a/src/configuratorAgents/agents/boardConfigurationProtocol/cbor/Encoder.h +++ b/src/configuratorAgents/agents/boardConfigurationProtocol/cbor/Encoder.h @@ -67,3 +67,11 @@ class NetConfigLibVersProvisioningMessageEncoder: public CBORMessageEncoderInter protected: MessageEncoder::Status encode(CborEncoder* encoder, Message *msg) override; }; + +class ProvPublicKeyProvisioningMessageEncoder: public CBORMessageEncoderInterface { + public: + ProvPublicKeyProvisioningMessageEncoder() + : CBORMessageEncoderInterface(CBORProvPublicKeyProvisioningMessage, ProvPublicKeyProvisioningMessageId) {} + protected: + MessageEncoder::Status encode(CborEncoder* encoder, Message *msg) override; + }; diff --git a/src/configuratorAgents/agents/boardConfigurationProtocol/cbor/ProvisioningMessage.h b/src/configuratorAgents/agents/boardConfigurationProtocol/cbor/ProvisioningMessage.h index d48800d..51d2395 100644 --- a/src/configuratorAgents/agents/boardConfigurationProtocol/cbor/ProvisioningMessage.h +++ b/src/configuratorAgents/agents/boardConfigurationProtocol/cbor/ProvisioningMessage.h @@ -50,6 +50,7 @@ enum CBORProvisioningMessageTag: CBORTag { CBORBLEMacAddressProvisioningMessage = 0x012013, CBORProvSketchVersionProvisioningMessage = 0x012015, CBORNetConfigLibVersProvisioningMessage = 0x012016, + CBORProvPublicKeyProvisioningMessage = 0x012017, }; enum ProvisioningMessageId: MessageId { @@ -61,6 +62,7 @@ enum ProvisioningMessageId: MessageId { ProvSketchVersionProvisioningMessageId, NetConfigLibVersProvisioningMessageId, JWTProvisioningMessageId, + ProvPublicKeyProvisioningMessageId, TimestampProvisioningMessageId, CommandsProvisioningMessageId, WifiConfigProvisioningMessageId, @@ -108,6 +110,13 @@ struct JWTProvisioningMessage { }; }; +struct ProvPublicKeyProvisioningMessage { + ProvisioningMessage c; + struct { + const char *provPublicKey; //The payload is a string. + }; +}; + struct BLEMacAddressProvisioningMessage { ProvisioningMessage c; struct { From 315b031317bec4b11ab4a76a4fcfa6d30baac74d Mon Sep 17 00:00:00 2001 From: Fabio C Date: Fri, 18 Jul 2025 11:44:25 +0200 Subject: [PATCH 17/19] Use timeout duration of connection attempt according to connection type (#17) --- src/Arduino_NetworkConfigurator.cpp | 59 +++++++++++++++++++++++++++-- src/Arduino_NetworkConfigurator.h | 3 ++ 2 files changed, 59 insertions(+), 3 deletions(-) diff --git a/src/Arduino_NetworkConfigurator.cpp b/src/Arduino_NetworkConfigurator.cpp index ee7d3cc..e4e2bfd 100644 --- a/src/Arduino_NetworkConfigurator.cpp +++ b/src/Arduino_NetworkConfigurator.cpp @@ -76,7 +76,6 @@ bool NetworkConfiguratorClass::begin() { DEBUG_ERROR("NetworkConfiguratorClass::%s Failed to initialize the AgentsManagerClass", __FUNCTION__); } - _connectionTimeout.begin(NC_CONNECTION_TIMEOUT_ms); _connectionRetryTimer.begin(NC_CONNECTION_RETRY_TIMER_ms); _resetInput->begin(); @@ -102,7 +101,7 @@ NetworkConfiguratorStates NetworkConfiguratorClass::update() { if(_state != nextState){ if(nextState == NetworkConfiguratorStates::CONNECTING){ - _connectionTimeout.reload(); + setConnectionTimeoutTimer(); } _state = nextState; } @@ -385,6 +384,60 @@ bool NetworkConfiguratorClass::handleConnectRequest() { return true; } +void NetworkConfiguratorClass::setConnectionTimeoutTimer() { + uint32_t timeout = 0; + switch (_networkSetting.type) { +#if defined(BOARD_HAS_WIFI) + case NetworkAdapter::WIFI: + timeout = NC_CONNECTION_TIMEOUT_ms; // 15 seconds + break; +#endif + +#if defined(BOARD_HAS_ETHERNET) + case NetworkAdapter::ETHERNET: + timeout = NC_CONNECTION_TIMEOUT_ms; // 15 seconds + break; +#endif + +#if defined(BOARD_HAS_NB) + case NetworkAdapter::NB: + timeout = 2 * NC_CONNECTION_TIMEOUT_ms; // 30 seconds + break; +#endif + +#if defined(BOARD_HAS_GSM) + case NetworkAdapter::GSM: + timeout = 2 * NC_CONNECTION_TIMEOUT_ms; // 30 seconds + break; +#endif + +#if defined(BOARD_HAS_CATM1_NBIOT) + case NetworkAdapter::CATM1: + timeout = 2 * NC_CONNECTION_TIMEOUT_ms; // 30 seconds + break; +#endif + +#if defined(BOARD_HAS_CELLULAR) + case NetworkAdapter::CELL: + timeout = 2 * NC_CONNECTION_TIMEOUT_ms; // 30 seconds + break; +#endif + +#if defined(BOARD_HAS_LORA) + case NetworkAdapter::LORA: + timeout = NC_CONNECTION_TIMEOUT_ms; // 15 seconds + break; +#endif + default: + timeout = NC_CONNECTION_TIMEOUT_ms; // Default to 15 seconds for other adapters + break; + } + + _connectionTimeout.begin(timeout); + _connectionTimeout.reload(); + return; +} + String NetworkConfiguratorClass::decodeConnectionErrorMessage(NetworkConnectionState err, StatusMessage *errorCode) { switch (err) { case NetworkConnectionState::ERROR: @@ -452,7 +505,7 @@ NetworkConfiguratorStates NetworkConfiguratorClass::handleZeroTouchConfig() { return NetworkConfiguratorStates::WAITING_FOR_CONFIG; } _connectionHandlerIstantiated = true; - _connectionTimeout.reload(); + setConnectionTimeoutTimer(); } StatusMessage err; diff --git a/src/Arduino_NetworkConfigurator.h b/src/Arduino_NetworkConfigurator.h index fafe125..207e5ea 100644 --- a/src/Arduino_NetworkConfigurator.h +++ b/src/Arduino_NetworkConfigurator.h @@ -207,6 +207,9 @@ class NetworkConfiguratorClass { void startReconfigureProcedure(); + // Returns the connection timeout in milliseconds according to the set network type + void setConnectionTimeoutTimer(); + String decodeConnectionErrorMessage(NetworkConnectionState err, StatusMessage *errorCode); ConnectionResult connectToNetwork(StatusMessage *err); ConnectionResult disconnectFromNetwork(); From 1b4ad0ff12feccf1e327ae21f845276e105c4da2 Mon Sep 17 00:00:00 2001 From: fabik111 Date: Fri, 18 Jul 2025 12:01:22 +0200 Subject: [PATCH 18/19] Release version 0.3.1 --- library.properties | 2 +- src/ANetworkConfigurator_Config.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library.properties b/library.properties index 2605e46..8e8e484 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Arduino_NetworkConfigurator -version=0.3.0 +version=0.3.1 author=Arduino maintainer=Arduino sentence=This library allows to configure and update the network settings of a ConnectionHandler instance. diff --git a/src/ANetworkConfigurator_Config.h b/src/ANetworkConfigurator_Config.h index 979e5ef..db539f2 100644 --- a/src/ANetworkConfigurator_Config.h +++ b/src/ANetworkConfigurator_Config.h @@ -7,7 +7,7 @@ */ #pragma once -#define ANetworkConfigurator_LIB_VERSION "0.3.0" +#define ANetworkConfigurator_LIB_VERSION "0.3.1" #if defined(ARDUINO_SAMD_MKRWIFI1010) #define NETWORK_CONFIGURATOR_COMPATIBLE 1 From 031dc54c863979ab88a5ff8c7190b102adbe261b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 7 Aug 2025 10:26:29 +0200 Subject: [PATCH 19/19] Bump actions/download-artifact from 4 to 5 (#19) Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 4 to 5. - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](https://github.com/actions/download-artifact/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/download-artifact dependency-version: '5' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/sync-labels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml index f12e267..48a5532 100644 --- a/.github/workflows/sync-labels.yml +++ b/.github/workflows/sync-labels.yml @@ -112,7 +112,7 @@ jobs: uses: actions/checkout@v4 - name: Download configuration file artifacts - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v5 with: merge-multiple: true pattern: ${{ env.CONFIGURATIONS_ARTIFACT_PREFIX }}* pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy