From 3c23a40012edd3cc9584a262780ae43c518e35d5 Mon Sep 17 00:00:00 2001 From: busticated Date: Thu, 29 Sep 2022 12:09:10 -0700 Subject: [PATCH 001/112] increase timeout for test-build-system ci workflow on windows --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 29c7c64388..d91d276dd2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -353,7 +353,7 @@ commands: steps: - run: name: "Test Local Compilation Tasks" - no_output_timeout: "20m" + no_output_timeout: "30m" command: pwsh ci/test-build-tasks.ps1 $home\project "<< parameters.platform >>" "<< parameters.tasks >>" environment: PRTCL_DISABLE_AUTOUPDATE: "1" From 418de53f2f55b8ae56e0196d455411b4b1f36628 Mon Sep 17 00:00:00 2001 From: James Wilson Date: Thu, 8 Sep 2022 16:08:27 -0700 Subject: [PATCH 002/112] Pinmap for Tracker M FF --- hal/src/trackerm/pinmap_defines.cpp | 27 ++++++++++++++----------- hal/src/trackerm/pinmap_defines.h | 31 ++++++++++++++++------------- 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/hal/src/trackerm/pinmap_defines.cpp b/hal/src/trackerm/pinmap_defines.cpp index f89a773765..d23193a2b3 100644 --- a/hal/src/trackerm/pinmap_defines.cpp +++ b/hal/src/trackerm/pinmap_defines.cpp @@ -57,24 +57,27 @@ static hal_pin_info_t pinmap[TOTAL_PINS] = { /* LOW_BAT_UC - 27 */ { MCP23S17_PORT_A, 0, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_IO_EXPANDER, 0}, /* DCDC_EN - 28 */ { MCP23S17_PORT_A, 1, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_IO_EXPANDER, 0}, /* GNSS_PWR_EN - 29 */ { MCP23S17_PORT_A, 2, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_IO_EXPANDER, 0}, -/* P2_CELL_STATUS- 30 */ { MCP23S17_PORT_A, 3, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_IO_EXPANDER, 0}, -/* GNSS_GEOFENCE - 31 */ { MCP23S17_PORT_A, 4, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_IO_EXPANDER, 0}, +/* IO_2V8_EN - 30 */ { MCP23S17_PORT_A, 3, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_IO_EXPANDER, 0}, +/* SHT_ALERT - 31 */ { MCP23S17_PORT_A, 4, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_IO_EXPANDER, 0}, /* GNSS_RST - 32 */ { MCP23S17_PORT_A, 5, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_IO_EXPANDER, 0}, /* PGOOD - 33 */ { MCP23S17_PORT_A, 6, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_IO_EXPANDER, 0}, /* P2_CELL_DIR - 34 */ { MCP23S17_PORT_A, 7, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_IO_EXPANDER, 0}, -/* CAN_VDD_EN - 35 */ { MCP23S17_PORT_B, 0, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_IO_EXPANDER, 0}, -/* CAN_STBY - 36 */ { MCP23S17_PORT_B, 1, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_IO_EXPANDER, 0}, -/* CAN_INT - 37 */ { MCP23S17_PORT_B, 2, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_IO_EXPANDER, 0}, -/* P2_CELL_PWR - 38 */ { MCP23S17_PORT_B, 3, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_IO_EXPANDER, 0}, +/* IO_EXP_B0 - 35 */ { MCP23S17_PORT_B, 0, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_IO_EXPANDER, 0}, +/* IO_EXP_B1 - 36 */ { MCP23S17_PORT_B, 1, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_IO_EXPANDER, 0}, +/* IO_EXP_B2 - 37 */ { MCP23S17_PORT_B, 2, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_IO_EXPANDER, 0}, +/* IO_EXP_B3 - 38 */ { MCP23S17_PORT_B, 3, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_IO_EXPANDER, 0}, /* P2_CELL_RST - 39 */ { MCP23S17_PORT_B, 4, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_IO_EXPANDER, 0}, -/* SENSOR_INT1 - 40 */ { MCP23S17_PORT_B, 5, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_IO_EXPANDER, 0}, -/* SHT_ALERT - 41 */ { MCP23S17_PORT_B, 6, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_IO_EXPANDER, 0}, -/* IO_2V8_EN - 42 */ { MCP23S17_PORT_B, 7, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_IO_EXPANDER, 0}, +/* P2_CELL_PWR - 40 */ { MCP23S17_PORT_B, 5, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_IO_EXPANDER, 0}, +/* P2_CELL_STATUS- 41 */ { MCP23S17_PORT_B, 6, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_IO_EXPANDER, 0}, +/* GNSS_GEOFENCE - 42 */ { MCP23S17_PORT_B, 7, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_IO_EXPANDER, 0}, /* IOE_RST - 43 */ { DEMUX_PORT, 1, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_DEMUX, 0}, -/* SENSOR_CS - 44 */ { DEMUX_PORT, 2, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_DEMUX, 0}, -/* IOE_CS - 45 */ { DEMUX_PORT, 5, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_DEMUX, 0}, -/* CAN_CS - 46 */ { DEMUX_PORT, 7, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_DEMUX, 0}, +/* IOE_CS - 44 */ { DEMUX_PORT, 2, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_DEMUX, 0}, +/* Y3 - 45 */ { DEMUX_PORT, 3, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_DEMUX, 0}, +/* Y4 - 46 */ { DEMUX_PORT, 4, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_DEMUX, 0}, +/* Y5 - 47 */ { DEMUX_PORT, 5, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_DEMUX, 0}, +/* Y6 - 48 */ { DEMUX_PORT, 6, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_DEMUX, 0}, +/* Y7 - 49 */ { DEMUX_PORT, 7, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_DEMUX, 0}, }; diff --git a/hal/src/trackerm/pinmap_defines.h b/hal/src/trackerm/pinmap_defines.h index ef5a730fd2..229bc52b3b 100644 --- a/hal/src/trackerm/pinmap_defines.h +++ b/hal/src/trackerm/pinmap_defines.h @@ -17,7 +17,7 @@ #pragma once -#define TOTAL_PINS 47 +#define TOTAL_PINS 50 #define TOTAL_ANALOG_PINS 6 #define FIRST_ANALOG_PIN 11 @@ -81,7 +81,7 @@ // IO Expander #define IOE_INT D10 #define IOE_RST 43 -#define IOE_CS 45 +#define IOE_CS 44 #define CS0 S3 #define CS1 S5 @@ -120,22 +120,25 @@ #define LOW_BAT_UC 27 #define DCDC_EN 28 #define GNSS_PWR_EN 29 -#define P2_CELL_STATUS 30 -#define GNSS_GEOFENCE 31 +#define IO_2V8_EN 30 +#define SHT_ALERT 31 #define GNSS_RST 32 #define PGOOD 33 #define P2_CELL_DTR 34 -#define CAN_VDD_EN 35 -#define CAN_STBY 36 -#define CAN_INT 37 -#define P2_CELL_PWR 38 +#define IO_EXP_B0 35 +#define IO_EXP_B1 36 +#define IO_EXP_B2 37 +#define IO_EXP_B3 38 #define P2_CELL_RST 39 -#define SENSOR_INT1 40 -#define SHT_ALERT 41 -#define IO_2V8_EN 42 - -#define SENSOR_CS 44 -#define CAN_CS 46 +#define P2_CELL_PWR 40 +#define P2_CELL_STATUS 41 +#define GNSS_GEOFENCE 42 + +#define Y3 45 +#define Y4 46 +#define Y5 47 +#define Y6 48 +#define Y7 49 // Cellular #define BGRST P2_CELL_PWR From bfd9e070afc01ca7e136f9d69da6b7e86c81477b Mon Sep 17 00:00:00 2001 From: James Wilson Date: Thu, 29 Sep 2022 15:51:09 -0700 Subject: [PATCH 003/112] Remove commented-out flags in hal_platform_config.h --- hal/src/trackerm/hal_platform_config.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/hal/src/trackerm/hal_platform_config.h b/hal/src/trackerm/hal_platform_config.h index de84a92697..0090057cef 100644 --- a/hal/src/trackerm/hal_platform_config.h +++ b/hal/src/trackerm/hal_platform_config.h @@ -8,14 +8,12 @@ #define HAL_PLATFORM_CELLULAR (1) #define HAL_PLATFORM_CELLULAR_SERIAL (HAL_USART_SERIAL2) #define HAL_PLATFORM_SETUP_BUTTON_UX (1) -// #define HAL_PLATFORM_MUXER_MAY_NEED_DELAY_IN_TX (1) #define HAL_PLATFORM_SPI_NUM (2) #define HAL_PLATFORM_I2C_NUM (2) #define HAL_PLATFORM_USART_NUM (3) #define HAL_PLATFORM_NCP_COUNT (2) #define HAL_PLATFORM_WIFI (1) #define HAL_PLATFORM_WIFI_COMPAT (0) -// #define HAL_PLATFORM_WIFI_NCP_SDIO (1) #define HAL_PLATFORM_WIFI_SCAN_ONLY (1) #define HAL_PLATFORM_RADIO_ANTENNA_INTERNAL (1) From a73403edba186550203a1d7d0408e6f96e59d2f2 Mon Sep 17 00:00:00 2001 From: XuGuohui Date: Tue, 11 Oct 2022 21:50:05 +0800 Subject: [PATCH 004/112] [rtl872x] hal: fix potential BLE issue that it may timeout establishing connection. --- hal/src/rtl872x/ble_hal.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/hal/src/rtl872x/ble_hal.cpp b/hal/src/rtl872x/ble_hal.cpp index c965f4c53c..cca34aa658 100644 --- a/hal/src/rtl872x/ble_hal.cpp +++ b/hal/src/rtl872x/ble_hal.cpp @@ -2066,21 +2066,18 @@ void BleGap::handleConnectionStateChanged(uint8_t connHandle, T_GAP_CONN_STATE n case GAP_CONN_STATE_DISCONNECTED: { LOG_DEBUG(TRACE, "GAP_CONN_STATE_DISCONNECTED"); BleConnection* connection = fetchConnection(connHandle); - if (!connection) { - LOG(TRACE, "Connection not found."); + if (!connection || (connection && addressEqual(connectingAddr_, connection->info.address))) { if (connecting_) { connecting_ = false; // Central failed to connect os_semaphore_give(connectSemaphore_, false); } - return; + if (!connection) { + return; + } } if ((discCause != (HCI_ERR | HCI_ERR_REMOTE_USER_TERMINATE)) && (discCause != (HCI_ERR | HCI_ERR_LOCAL_HOST_TERMINATE))) { - LOG_DEBUG(TRACE, "handleConnectionStateChanged: connection lost cause 0x%x", discCause); - hal_ble_addr_t addr = {}; - if (!addressEqual(connectingAddr_, addr)) { - LOG(ERROR, "Central gets disconnected while connecting....."); - } + LOG(TRACE, "handleConnectionStateChanged: connection lost cause 0x%x", discCause); } LOG_DEBUG(TRACE, "Disconnected, handle:%d, cause:0x%x", connHandle, discCause); // If the disconnection is initiated by application. From a34b3c5e5db04699368e2c9aa7b102292a8aa723 Mon Sep 17 00:00:00 2001 From: Scott Brust Date: Wed, 12 Oct 2022 13:48:33 -0700 Subject: [PATCH 005/112] bump module version to 4.0.0 (4003) --- CHANGELOG.md | 58 +++++++++++++++++++++++++++++++++++++ system/inc/system_version.h | 3 ++ system/system-versions.md | 1 + 3 files changed, 62 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ee3b2b21e..4876dc3451 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -136,6 +136,64 @@ - [tests] Fix broken tone and servo tests for p2 platform, also EEPROM_03 for all. [#2469](https://github.com/particle-iot/device-os/pull/2469) - [workbench] Stop ignoring device os scripts directory [#2471](https://github.com/particle-iot/device-os/pull/2471) +## 4.0.0 + +### DEPRECATION + +- [deprecation][gen2] supply secure [#2442](https://github.com/particle-iot/device-os/pull/2442) +- [deprecation] Adds warning to some deprecated API's that will be removed in Device OS 5.x [#2445](https://github.com/particle-iot/device-os/pull/2445) +- [deprecation] PRODUCT_ID macro [#2446](https://github.com/particle-iot/device-os/pull/2446) +- [deprecation] remove setup_done flag and add deprecation notice [#2447](https://github.com/particle-iot/device-os/pull/2447) + +### FEATURES + +- [ota] new API System.updateStatus() [#2344](https://github.com/particle-iot/device-os/pull/2344) +- [esomx] Adds support for new platform esomx [#2443](https://github.com/particle-iot/device-os/pull/2443) [#2459](https://github.com/particle-iot/device-os/pull/2459) [#2505](https://github.com/particle-iot/device-os/pull/2505) [#2495](https://github.com/particle-iot/device-os/pull/2495) +- [gen3] Determine flash part at runtime [#2456](https://github.com/particle-iot/device-os/pull/2456) +- [gen3][quectel] Adds support for BG95-M1, BG95-MF, BG77, and EG91-NAX [#2458](https://github.com/particle-iot/device-os/pull/2458) +- `System.hardwareInfo()` API [#2526](https://github.com/particle-iot/device-os/pull/2526) [#2529](https://github.com/particle-iot/device-os/pull/2529) + +### ENHANCEMENTS + +- [gen3] wifi: add dhcp dns info to wifi config [#2440](https://github.com/particle-iot/device-os/pull/2440) +- [ota] Additional state for firmware update checks [#2344](https://github.com/particle-iot/device-os/pull/2344) +- Use a custom content type with CID packets when resuming the session [#2441](https://github.com/particle-iot/device-os/pull/2441) + +### BUGFIXES + +- [gen3] fixes hardfault during low level USB peripheral initialization under an atomic section [#2448](https://github.com/particle-iot/device-os/pull/2448) +- [gen3] Device unable to enter listening mode with button press [#2451](https://github.com/particle-iot/device-os/pull/2451) +- Return relevant error from control request to enter listening mode [#2419](https://github.com/particle-iot/device-os/pull/2419) +- [gen3] hal: fix power leak on Boron [#2452](https://github.com/particle-iot/device-os/pull/2452) +- [gen3] port newlib stdin/stdout/stderr memory leak workaround [#2467](https://github.com/particle-iot/device-os/pull/2467) +- [gen3] fixes `interrupts()` API: should not clear pending interrupts [#2504](https://github.com/particle-iot/device-os/pull/2504) +- Ensure that RTOS context switch is performed in tight `delay(1)` loops [#2519](https://github.com/particle-iot/device-os/pull/2519) [#2520](https://github.com/particle-iot/device-os/pull/2520) [#2524](https://github.com/particle-iot/device-os/pull/2524) + +### INTERNAL + +- [ci] minor update sc-101315/device-os-manifest [#2449](https://github.com/particle-iot/device-os/pull/2449) +- [ci] chore/ci-less-frequent-cross-platform-build-checks [#2434](https://github.com/particle-iot/device-os/pull/2434) +- [docs] Update dependencies for ARM GCC 10.2.1 [#2431](https://github.com/particle-iot/device-os/pull/2431) +- [gen3] suppress certain reviewed GCC warnings [sc-100940] [#2420](https://github.com/particle-iot/device-os/pull/2420) +- [ci] feature/sc-100324/ci-build-cross-platform [#2418](https://github.com/particle-iot/device-os/pull/2418) +- [test] Wi-Fi resolve test improvements [#2454](https://github.com/particle-iot/device-os/pull/2454) +- [workbench] update-device-os-workbench-manifest-json [#2457](https://github.com/particle-iot/device-os/pull/2457) +- [ci] test-build-system-tune-timeouts [#2455](https://github.com/particle-iot/device-os/pull/2455) +- Allow overriding the platform ID on the GCC platform [#2462](https://github.com/particle-iot/device-os/pull/2462) +- Enable OTA updates on the GCC platform [#2464](https://github.com/particle-iot/device-os/pull/2464) +- Fix GCC platform on some versions of GCC; Fix building of wiring/api tests on CI [#2483](https://github.com/particle-iot/device-os/pull/2483) +- [workbench] Update workbench buildscripts to 1.11.0 [#2465](https://github.com/particle-iot/device-os/pull/2465) +- [workbench] Stop ignoring device os scripts directory [#2471](https://github.com/particle-iot/device-os/pull/2471) +- [workbench] Remove redundant toolchain overrides [#2489](https://github.com/particle-iot/device-os/pull/2489) +- [wifi] Add stubs to allow setting common country code and channel plan in P2 [#2473](https://github.com/particle-iot/device-os/pull/2473) [#2485](https://github.com/particle-iot/device-os/pull/2485) +- [tests] Change PWM pins to better match e-series pinout for E SoM X. Fix other tests [#2463](https://github.com/particle-iot/device-os/pull/2463) +- [tests] Misc changes to tests from 5.x [#2466](https://github.com/particle-iot/device-os/pull/2466) +- [tests][esomx] disable RGB pwm channel(s) when running pwm tests [#2494](https://github.com/particle-iot/device-os/pull/2494) +- Streamline `.bundleignore` between 5.x and 4.x codebases [#2496](https://github.com/particle-iot/device-os/pull/2496) +- branch pattern changes for `test-build-system` [#2510](https://github.com/particle-iot/device-os/pull/2510) +- [test] fixes race condition with `wiring/no_fixture` `TIME_17` [#2514](https://github.com/particle-iot/device-os/pull/2514) +>>>>>>> cccaa6ca6 (bump module version to 4.0.0 (4003)) + ## 4.0.0-beta.1 > ## :warning: Please note this is an internal release, do not use on production devices! diff --git a/system/inc/system_version.h b/system/inc/system_version.h index 2bb3b1bdd4..db090048f2 100644 --- a/system/inc/system_version.h +++ b/system/inc/system_version.h @@ -191,6 +191,8 @@ extern "C" { #define SYSTEM_VERSION_v400ALPHA1 SYSTEM_VERSION_ALPHA(4, 0, 0, 1) #define SYSTEM_VERSION_v400ALPHA2 SYSTEM_VERSION_ALPHA(4, 0, 0, 2) #define SYSTEM_VERSION_v400BETA1 SYSTEM_VERSION_BETA(4, 0, 0, 1) +#define SYSTEM_VERSION_v400 SYSTEM_VERSION_DEFAULT(4, 0, 0) +// These are required for some of the dynalib checks #define SYSTEM_VERSION_v500ALPHA1 SYSTEM_VERSION_ALPHA(5, 0, 0, 1) #define SYSTEM_VERSION_v500ALPHA2 SYSTEM_VERSION_ALPHA(5, 0, 0, 2) #define SYSTEM_VERSION_v500 SYSTEM_VERSION_DEFAULT(5, 0, 0) @@ -352,6 +354,7 @@ extern "C" { #define SYSTEM_VERSION_400ALPHA1 #define SYSTEM_VERSION_400ALPHA2 #define SYSTEM_VERSION_400BETA1 +#define SYSTEM_VERSION_400 #define SYSTEM_VERSION_500ALPHA1 #define SYSTEM_VERSION_500ALPHA2 #define SYSTEM_VERSION_500 diff --git a/system/system-versions.md b/system/system-versions.md index 3cfa1eb5e7..598f8616d7 100644 --- a/system/system-versions.md +++ b/system/system-versions.md @@ -166,6 +166,7 @@ | 1100 | 4000 | 4.0.0-alpha.1 | Argon, Boron, B SoM, B5 SoM, Tracker | | 1101 | 4001 | 4.0.0-alpha.2 | Argon, Boron, B SoM, B5 SoM, Tracker, E Som X | | 1101 | 4002 | 4.0.0-beta.1 | Argon, Boron, B SoM, B5 SoM, Tracker, E Som X | +| 1101 | 4003 | 4.0.0 | Argon, Boron, B SoM, B5 SoM, Tracker, E Som X | | 2000 | 5000 | 5.0.0-alpha.1 | Argon, Boron, B SoM, B5 SoM, Tracker, E Som X, P2 | | 2000 | 5001 | 5.0.0-alpha.2 | Argon, Boron, B SoM, B5 SoM, Tracker, E Som X, P2 | | 2000 | 5002 | 5.0.0 | Argon, Boron, B SoM, B5 SoM, Tracker, Tracker M, E Som X, P2 | From 3f02d5abbc7eb72c540c7442700a9fd22d0ab4c7 Mon Sep 17 00:00:00 2001 From: Scott Brust Date: Wed, 12 Oct 2022 14:54:09 -0700 Subject: [PATCH 006/112] fixup --- CHANGELOG.md | 1 - system/inc/system_version.h | 1 - 2 files changed, 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4876dc3451..ead0e144e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -192,7 +192,6 @@ - Streamline `.bundleignore` between 5.x and 4.x codebases [#2496](https://github.com/particle-iot/device-os/pull/2496) - branch pattern changes for `test-build-system` [#2510](https://github.com/particle-iot/device-os/pull/2510) - [test] fixes race condition with `wiring/no_fixture` `TIME_17` [#2514](https://github.com/particle-iot/device-os/pull/2514) ->>>>>>> cccaa6ca6 (bump module version to 4.0.0 (4003)) ## 4.0.0-beta.1 diff --git a/system/inc/system_version.h b/system/inc/system_version.h index db090048f2..08662fc863 100644 --- a/system/inc/system_version.h +++ b/system/inc/system_version.h @@ -192,7 +192,6 @@ extern "C" { #define SYSTEM_VERSION_v400ALPHA2 SYSTEM_VERSION_ALPHA(4, 0, 0, 2) #define SYSTEM_VERSION_v400BETA1 SYSTEM_VERSION_BETA(4, 0, 0, 1) #define SYSTEM_VERSION_v400 SYSTEM_VERSION_DEFAULT(4, 0, 0) -// These are required for some of the dynalib checks #define SYSTEM_VERSION_v500ALPHA1 SYSTEM_VERSION_ALPHA(5, 0, 0, 1) #define SYSTEM_VERSION_v500ALPHA2 SYSTEM_VERSION_ALPHA(5, 0, 0, 2) #define SYSTEM_VERSION_v500 SYSTEM_VERSION_DEFAULT(5, 0, 0) From de387ddc28e6ffce1591c1d9b7547ef92701884f Mon Sep 17 00:00:00 2001 From: Scott Brust Date: Fri, 7 Oct 2022 16:33:55 -0700 Subject: [PATCH 007/112] [gen3][rtl872x]increase i2c buffer for tracker[m]. fix acquireWireBuffer --- hal/inc/hal_platform.h | 4 +++ hal/inc/i2c_hal.h | 6 ++-- hal/src/nRF52840/i2c_hal.cpp | 34 +++++++++++++++++++---- hal/src/rtl872x/i2c_hal.cpp | 9 ++++++ hal/src/tracker/hal_platform_config.h | 1 + hal/src/trackerm/hal_platform_config.h | 2 +- hal/src/tron/hal_platform_config.h | 1 - wiring_globals/src/wiring_globals_i2c.cpp | 5 ++-- 8 files changed, 50 insertions(+), 12 deletions(-) diff --git a/hal/inc/hal_platform.h b/hal/inc/hal_platform.h index 41aeafc300..182b7000bc 100644 --- a/hal/inc/hal_platform.h +++ b/hal/inc/hal_platform.h @@ -530,4 +530,8 @@ #define HAL_PLATFORM_BLE_ACTIVE_EVENT (0) #endif // HAL_PLATFORM_BLE_ACTIVE_EVENT +#ifndef HAL_PLATFORM_I2C_BUFFER_SIZE +#define HAL_PLATFORM_I2C_BUFFER_SIZE (32) +#endif // HAL_PLATFORM_I2C_BUFFER_SIZE + #endif /* HAL_PLATFORM_H */ diff --git a/hal/inc/i2c_hal.h b/hal/inc/i2c_hal.h index d3c352b26d..90bfa58b64 100644 --- a/hal/inc/i2c_hal.h +++ b/hal/inc/i2c_hal.h @@ -42,7 +42,8 @@ typedef enum hal_i2c_interface_t { /*! I2c Config Structure Version */ typedef enum hal_i2c_config_version_t { HAL_I2C_CONFIG_VERSION_1 = 0, - HAL_I2C_CONFIG_VERSION_LATEST = HAL_I2C_CONFIG_VERSION_1, + HAL_I2C_CONFIG_VERSION_2 = 1, + HAL_I2C_CONFIG_VERSION_LATEST = HAL_I2C_CONFIG_VERSION_2, } hal_i2c_config_version_t; typedef struct hal_i2c_config_t { @@ -52,6 +53,7 @@ typedef struct hal_i2c_config_t { uint32_t rx_buffer_size; uint8_t* tx_buffer; uint32_t tx_buffer_size; + uint8_t freeable; } hal_i2c_config_t; typedef enum hal_i2c_transmission_flag_t { @@ -79,7 +81,7 @@ typedef enum hal_i2c_state_t { #define CLOCK_SPEED_100KHZ (uint32_t)100000 #define CLOCK_SPEED_400KHZ (uint32_t)400000 #define HAL_I2C_DEFAULT_TIMEOUT_MS (100) -#define I2C_BUFFER_LENGTH (uint8_t)32 +#define I2C_BUFFER_LENGTH (uint32_t)HAL_PLATFORM_I2C_BUFFER_SIZE /* Exported functions --------------------------------------------------------*/ #ifdef __cplusplus diff --git a/hal/src/nRF52840/i2c_hal.cpp b/hal/src/nRF52840/i2c_hal.cpp index 0fa41dbf75..c3b2afb856 100644 --- a/hal/src/nRF52840/i2c_hal.cpp +++ b/hal/src/nRF52840/i2c_hal.cpp @@ -32,6 +32,7 @@ #include "timer_hal.h" #include #include "check.h" +#include #if PLATFORM_ID == PLATFORM_TRACKER #include "usart_hal.h" @@ -110,6 +111,8 @@ typedef struct nrf5x_i2c_info_t { size_t tx_index_tail; os_mutex_recursive_t mutex; + bool configured; + bool heapBuffer; void (*callback_on_request)(void); void (*callback_on_receive)(int); @@ -310,28 +313,46 @@ int hal_i2c_init(hal_i2c_interface_t i2c, const hal_i2c_config_t* config) { os_thread_scheduling(false, nullptr); if (i2cMap[i2c].mutex == nullptr) { os_mutex_recursive_create(&i2cMap[i2c].mutex); - } else { - // Already initialized - os_thread_scheduling(true, nullptr); - return SYSTEM_ERROR_NONE; - } + } // Capture the mutex and re-enable threading I2cLock lk(i2c); os_thread_scheduling(true, nullptr); - // Initialize internal data structure + if (i2cMap[i2c].configured) { + // Configured, but new buffers are invalid + if (!isConfigValid(config)){ + return SYSTEM_ERROR_INVALID_ARGUMENT; + } + // Configured, but new buffers are smaller + if (config->rx_buffer_size < i2cMap[i2c].rx_buf_size || + config->tx_buffer_size < i2cMap[i2c].tx_buf_size) { + return SYSTEM_ERROR_NOT_ENOUGH_DATA; + } + // Free current buffers if needed + if (i2cMap[i2c].heapBuffer) { + free(i2cMap[i2c].rx_buf); + free(i2cMap[i2c].tx_buf); + } + } + if (isConfigValid(config)) { i2cMap[i2c].rx_buf = config->rx_buffer; i2cMap[i2c].rx_buf_size = config->rx_buffer_size; i2cMap[i2c].tx_buf = config->tx_buffer; i2cMap[i2c].tx_buf_size = config->tx_buffer_size; + if(config->version >= HAL_I2C_CONFIG_VERSION_2 && config->freeable) { + i2cMap[i2c].heapBuffer = true; + } else { + i2cMap[i2c].heapBuffer = false; + } } else { // Allocate default buffers i2cMap[i2c].rx_buf = new (std::nothrow) uint8_t[I2C_BUFFER_LENGTH]; i2cMap[i2c].rx_buf_size = I2C_BUFFER_LENGTH; i2cMap[i2c].tx_buf = new (std::nothrow) uint8_t[I2C_BUFFER_LENGTH]; i2cMap[i2c].tx_buf_size = I2C_BUFFER_LENGTH; + i2cMap[i2c].heapBuffer = true; SPARK_ASSERT(i2cMap[i2c].rx_buf && i2cMap[i2c].tx_buf); } @@ -348,6 +369,7 @@ int hal_i2c_init(hal_i2c_interface_t i2c, const hal_i2c_config_t* config) { i2cMap[i2c].rx_index_tail = 0; i2cMap[i2c].tx_index_head = 0; i2cMap[i2c].tx_index_tail = 0; + i2cMap[i2c].configured = true; memset((void *)i2cMap[i2c].rx_buf, 0, i2cMap[i2c].rx_buf_size); memset((void *)i2cMap[i2c].tx_buf, 0, i2cMap[i2c].tx_buf_size); diff --git a/hal/src/rtl872x/i2c_hal.cpp b/hal/src/rtl872x/i2c_hal.cpp index 05e5a9a687..1cec572835 100644 --- a/hal/src/rtl872x/i2c_hal.cpp +++ b/hal/src/rtl872x/i2c_hal.cpp @@ -94,6 +94,15 @@ class I2cClass { lock(); os_thread_scheduling(true, nullptr); if (isConfigured()) { + // Configured, but new buffers are invalid + if (!isConfigValid(conf)){ + return SYSTEM_ERROR_INVALID_ARGUMENT; + } + // Configured, but new buffers are smaller + if (conf->rx_buffer_size < rxBuffer_.size() || + conf->tx_buffer_size < txBuffer_.size()) { + return SYSTEM_ERROR_NOT_ENOUGH_DATA; + } CHECK(deInit()); } if (isConfigValid(conf)) { diff --git a/hal/src/tracker/hal_platform_config.h b/hal/src/tracker/hal_platform_config.h index b0bdf872ad..65b5135726 100644 --- a/hal/src/tracker/hal_platform_config.h +++ b/hal/src/tracker/hal_platform_config.h @@ -10,6 +10,7 @@ #define HAL_PLATFORM_SETUP_BUTTON_UX (1) #define HAL_PLATFORM_SPI_NUM (2) #define HAL_PLATFORM_I2C_NUM (3) +#define HAL_PLATFORM_I2C_BUFFER_SIZE (512) #define HAL_PLATFORM_USART_NUM (2) #define HAL_PLATFORM_NCP_UPDATABLE (1) #define HAL_PLATFORM_ESP32_NCP (1) diff --git a/hal/src/trackerm/hal_platform_config.h b/hal/src/trackerm/hal_platform_config.h index 0090057cef..994e8c87ae 100644 --- a/hal/src/trackerm/hal_platform_config.h +++ b/hal/src/trackerm/hal_platform_config.h @@ -9,7 +9,7 @@ #define HAL_PLATFORM_CELLULAR_SERIAL (HAL_USART_SERIAL2) #define HAL_PLATFORM_SETUP_BUTTON_UX (1) #define HAL_PLATFORM_SPI_NUM (2) -#define HAL_PLATFORM_I2C_NUM (2) +#define HAL_PLATFORM_I2C_BUFFER_SIZE (512) #define HAL_PLATFORM_USART_NUM (3) #define HAL_PLATFORM_NCP_COUNT (2) #define HAL_PLATFORM_WIFI (1) diff --git a/hal/src/tron/hal_platform_config.h b/hal/src/tron/hal_platform_config.h index 3b42735c38..654d4779ea 100644 --- a/hal/src/tron/hal_platform_config.h +++ b/hal/src/tron/hal_platform_config.h @@ -11,7 +11,6 @@ #define HAL_PLATFORM_SETUP_BUTTON_UX (1) // #define HAL_PLATFORM_MUXER_MAY_NEED_DELAY_IN_TX (1) #define HAL_PLATFORM_SPI_NUM (2) -#define HAL_PLATFORM_I2C_NUM (2) #define HAL_PLATFORM_USART_NUM (3) #define HAL_PLATFORM_NCP_COUNT (1) #define HAL_PLATFORM_BROKEN_MTU (1) diff --git a/wiring_globals/src/wiring_globals_i2c.cpp b/wiring_globals/src/wiring_globals_i2c.cpp index 6d5216beb5..a95105d81d 100644 --- a/wiring_globals/src/wiring_globals_i2c.cpp +++ b/wiring_globals/src/wiring_globals_i2c.cpp @@ -14,11 +14,12 @@ namespace { hal_i2c_config_t defaultWireConfig() { hal_i2c_config_t config = { .size = sizeof(hal_i2c_config_t), - .version = HAL_I2C_CONFIG_VERSION_1, + .version = HAL_I2C_CONFIG_VERSION_2, .rx_buffer = new (std::nothrow) uint8_t[I2C_BUFFER_LENGTH], .rx_buffer_size = I2C_BUFFER_LENGTH, .tx_buffer = new (std::nothrow) uint8_t[I2C_BUFFER_LENGTH], - .tx_buffer_size = I2C_BUFFER_LENGTH + .tx_buffer_size = I2C_BUFFER_LENGTH, + .freeable = 1 }; return config; From 2823cd03e46611b60a3e8e658dde8df72c0bbbf2 Mon Sep 17 00:00:00 2001 From: Scott Brust Date: Tue, 11 Oct 2022 11:53:22 -0700 Subject: [PATCH 008/112] Review feedback --- hal/inc/hal_platform.h | 6 +++++- hal/inc/i2c_hal.h | 9 ++++++-- hal/src/nRF52840/i2c_hal.cpp | 25 ++++++++++------------- hal/src/rtl872x/i2c_hal.cpp | 10 +++++---- hal/src/tracker/hal_platform_config.h | 2 +- hal/src/trackerm/hal_platform_config.h | 2 +- wiring_globals/src/wiring_globals_i2c.cpp | 19 +++++++++-------- 7 files changed, 41 insertions(+), 32 deletions(-) diff --git a/hal/inc/hal_platform.h b/hal/inc/hal_platform.h index 182b7000bc..6fbf73d808 100644 --- a/hal/inc/hal_platform.h +++ b/hal/inc/hal_platform.h @@ -530,8 +530,12 @@ #define HAL_PLATFORM_BLE_ACTIVE_EVENT (0) #endif // HAL_PLATFORM_BLE_ACTIVE_EVENT +#ifndef HAL_PLATFORM_I2C_BUFFER_SIZE_DEFAULT +#define HAL_PLATFORM_I2C_BUFFER_SIZE_DEFAULT (32) +#endif // HAL_PLATFORM_I2C_BUFFER_SIZE_DEFAULT + #ifndef HAL_PLATFORM_I2C_BUFFER_SIZE -#define HAL_PLATFORM_I2C_BUFFER_SIZE (32) +#define HAL_PLATFORM_I2C_BUFFER_SIZE(x) (HAL_PLATFORM_I2C_BUFFER_SIZE_DEFAULT) #endif // HAL_PLATFORM_I2C_BUFFER_SIZE #endif /* HAL_PLATFORM_H */ diff --git a/hal/inc/i2c_hal.h b/hal/inc/i2c_hal.h index 90bfa58b64..3cf7d88d44 100644 --- a/hal/inc/i2c_hal.h +++ b/hal/inc/i2c_hal.h @@ -53,9 +53,14 @@ typedef struct hal_i2c_config_t { uint32_t rx_buffer_size; uint8_t* tx_buffer; uint32_t tx_buffer_size; - uint8_t freeable; + uint32_t flags; } hal_i2c_config_t; +typedef enum hal_i2c_config_flag_t { + HAL_I2C_CONFIG_FLAG_NONE = 0x00, + HAL_I2C_CONFIG_FLAG_FREEABLE = 0x01 +} hal_i2c_config_flag_t; + typedef enum hal_i2c_transmission_flag_t { HAL_I2C_TRANSMISSION_FLAG_NONE = 0x00, HAL_I2C_TRANSMISSION_FLAG_STOP = 0x01 @@ -81,7 +86,7 @@ typedef enum hal_i2c_state_t { #define CLOCK_SPEED_100KHZ (uint32_t)100000 #define CLOCK_SPEED_400KHZ (uint32_t)400000 #define HAL_I2C_DEFAULT_TIMEOUT_MS (100) -#define I2C_BUFFER_LENGTH (uint32_t)HAL_PLATFORM_I2C_BUFFER_SIZE +#define I2C_BUFFER_LENGTH (uint32_t)HAL_PLATFORM_I2C_BUFFER_SIZE_DEFAULT /* Exported functions --------------------------------------------------------*/ #ifdef __cplusplus diff --git a/hal/src/nRF52840/i2c_hal.cpp b/hal/src/nRF52840/i2c_hal.cpp index c3b2afb856..6d2267a457 100644 --- a/hal/src/nRF52840/i2c_hal.cpp +++ b/hal/src/nRF52840/i2c_hal.cpp @@ -112,7 +112,7 @@ typedef struct nrf5x_i2c_info_t { os_mutex_recursive_t mutex; bool configured; - bool heapBuffer; + bool heap_buffer; void (*callback_on_request)(void); void (*callback_on_receive)(int); @@ -325,12 +325,12 @@ int hal_i2c_init(hal_i2c_interface_t i2c, const hal_i2c_config_t* config) { return SYSTEM_ERROR_INVALID_ARGUMENT; } // Configured, but new buffers are smaller - if (config->rx_buffer_size < i2cMap[i2c].rx_buf_size || - config->tx_buffer_size < i2cMap[i2c].tx_buf_size) { + if (config->rx_buffer_size <= i2cMap[i2c].rx_buf_size || + config->tx_buffer_size <= i2cMap[i2c].tx_buf_size) { return SYSTEM_ERROR_NOT_ENOUGH_DATA; } // Free current buffers if needed - if (i2cMap[i2c].heapBuffer) { + if (i2cMap[i2c].heap_buffer) { free(i2cMap[i2c].rx_buf); free(i2cMap[i2c].tx_buf); } @@ -341,18 +341,15 @@ int hal_i2c_init(hal_i2c_interface_t i2c, const hal_i2c_config_t* config) { i2cMap[i2c].rx_buf_size = config->rx_buffer_size; i2cMap[i2c].tx_buf = config->tx_buffer; i2cMap[i2c].tx_buf_size = config->tx_buffer_size; - if(config->version >= HAL_I2C_CONFIG_VERSION_2 && config->freeable) { - i2cMap[i2c].heapBuffer = true; - } else { - i2cMap[i2c].heapBuffer = false; - } + i2cMap[i2c].heap_buffer = ((config->version >= HAL_I2C_CONFIG_VERSION_2) && (config->flags & HAL_I2C_CONFIG_FLAG_FREEABLE)); } else { + int buffer_size = HAL_PLATFORM_I2C_BUFFER_SIZE(i2c); // Allocate default buffers - i2cMap[i2c].rx_buf = new (std::nothrow) uint8_t[I2C_BUFFER_LENGTH]; - i2cMap[i2c].rx_buf_size = I2C_BUFFER_LENGTH; - i2cMap[i2c].tx_buf = new (std::nothrow) uint8_t[I2C_BUFFER_LENGTH]; - i2cMap[i2c].tx_buf_size = I2C_BUFFER_LENGTH; - i2cMap[i2c].heapBuffer = true; + i2cMap[i2c].rx_buf = new (std::nothrow) uint8_t[buffer_size]; + i2cMap[i2c].rx_buf_size = buffer_size; + i2cMap[i2c].tx_buf = new (std::nothrow) uint8_t[buffer_size]; + i2cMap[i2c].tx_buf_size = buffer_size; + i2cMap[i2c].heap_buffer = true; SPARK_ASSERT(i2cMap[i2c].rx_buf && i2cMap[i2c].tx_buf); } diff --git a/hal/src/rtl872x/i2c_hal.cpp b/hal/src/rtl872x/i2c_hal.cpp index 1cec572835..5dceb37129 100644 --- a/hal/src/rtl872x/i2c_hal.cpp +++ b/hal/src/rtl872x/i2c_hal.cpp @@ -99,8 +99,8 @@ class I2cClass { return SYSTEM_ERROR_INVALID_ARGUMENT; } // Configured, but new buffers are smaller - if (conf->rx_buffer_size < rxBuffer_.size() || - conf->tx_buffer_size < txBuffer_.size()) { + if (conf->rx_buffer_size <= rxBuffer_.size() || + conf->tx_buffer_size <= txBuffer_.size()) { return SYSTEM_ERROR_NOT_ENOUGH_DATA; } CHECK(deInit()); @@ -108,9 +108,11 @@ class I2cClass { if (isConfigValid(conf)) { rxBuffer_.init((uint8_t*)conf->rx_buffer, conf->rx_buffer_size); txBuffer_.init((uint8_t*)conf->tx_buffer, conf->tx_buffer_size); + heapBuffer_ = ((conf->version >= HAL_I2C_CONFIG_VERSION_2) && (conf->flags & HAL_I2C_CONFIG_FLAG_FREEABLE)); } else { - rxBuffer_.init((uint8_t*)malloc(I2C_BUFFER_LENGTH), I2C_BUFFER_LENGTH); - txBuffer_.init((uint8_t*)malloc(I2C_BUFFER_LENGTH), I2C_BUFFER_LENGTH); + int buffer_size = HAL_PLATFORM_I2C_BUFFER_SIZE(HAL_I2C_INTERFACE1); + rxBuffer_.init((uint8_t*)malloc(buffer_size), buffer_size); + txBuffer_.init((uint8_t*)malloc(buffer_size), buffer_size); SPARK_ASSERT(txBuffer_.buffer_ && rxBuffer_.buffer_); heapBuffer_ = true; } diff --git a/hal/src/tracker/hal_platform_config.h b/hal/src/tracker/hal_platform_config.h index 65b5135726..eaed773148 100644 --- a/hal/src/tracker/hal_platform_config.h +++ b/hal/src/tracker/hal_platform_config.h @@ -10,7 +10,7 @@ #define HAL_PLATFORM_SETUP_BUTTON_UX (1) #define HAL_PLATFORM_SPI_NUM (2) #define HAL_PLATFORM_I2C_NUM (3) -#define HAL_PLATFORM_I2C_BUFFER_SIZE (512) +#define HAL_PLATFORM_I2C_BUFFER_SIZE(x) (x == HAL_I2C_INTERFACE2 ? 512 : HAL_PLATFORM_I2C_BUFFER_SIZE_DEFAULT) #define HAL_PLATFORM_USART_NUM (2) #define HAL_PLATFORM_NCP_UPDATABLE (1) #define HAL_PLATFORM_ESP32_NCP (1) diff --git a/hal/src/trackerm/hal_platform_config.h b/hal/src/trackerm/hal_platform_config.h index 994e8c87ae..301bd389b5 100644 --- a/hal/src/trackerm/hal_platform_config.h +++ b/hal/src/trackerm/hal_platform_config.h @@ -9,7 +9,7 @@ #define HAL_PLATFORM_CELLULAR_SERIAL (HAL_USART_SERIAL2) #define HAL_PLATFORM_SETUP_BUTTON_UX (1) #define HAL_PLATFORM_SPI_NUM (2) -#define HAL_PLATFORM_I2C_BUFFER_SIZE (512) +#define HAL_PLATFORM_I2C_BUFFER_SIZE(x) (512) #define HAL_PLATFORM_USART_NUM (3) #define HAL_PLATFORM_NCP_COUNT (2) #define HAL_PLATFORM_WIFI (1) diff --git a/wiring_globals/src/wiring_globals_i2c.cpp b/wiring_globals/src/wiring_globals_i2c.cpp index a95105d81d..cabdbe6827 100644 --- a/wiring_globals/src/wiring_globals_i2c.cpp +++ b/wiring_globals/src/wiring_globals_i2c.cpp @@ -11,15 +11,16 @@ namespace { -hal_i2c_config_t defaultWireConfig() { +hal_i2c_config_t defaultWireConfig(hal_i2c_interface_t i2c) { + uint32_t i2c_buffer_size = HAL_PLATFORM_I2C_BUFFER_SIZE(i2c); hal_i2c_config_t config = { .size = sizeof(hal_i2c_config_t), .version = HAL_I2C_CONFIG_VERSION_2, - .rx_buffer = new (std::nothrow) uint8_t[I2C_BUFFER_LENGTH], - .rx_buffer_size = I2C_BUFFER_LENGTH, - .tx_buffer = new (std::nothrow) uint8_t[I2C_BUFFER_LENGTH], - .tx_buffer_size = I2C_BUFFER_LENGTH, - .freeable = 1 + .rx_buffer = new (std::nothrow) uint8_t[i2c_buffer_size], + .rx_buffer_size = i2c_buffer_size, + .tx_buffer = new (std::nothrow) uint8_t[i2c_buffer_size], + .tx_buffer_size = i2c_buffer_size, + .flags = HAL_I2C_CONFIG_FLAG_FREEABLE }; return config; @@ -29,20 +30,20 @@ hal_i2c_config_t defaultWireConfig() { hal_i2c_config_t __attribute__((weak)) acquireWireBuffer() { - return defaultWireConfig(); + return defaultWireConfig(HAL_I2C_INTERFACE1); } #if Wiring_Wire1 hal_i2c_config_t __attribute__((weak)) acquireWire1Buffer() { - return defaultWireConfig(); + return defaultWireConfig(HAL_I2C_INTERFACE2); } #endif #if Wiring_Wire3 hal_i2c_config_t __attribute__((weak)) acquireWire3Buffer() { - return defaultWireConfig(); + return defaultWireConfig(HAL_I2C_INTERFACE3); } #endif From 4beea199de650c85b7b394933eda095967c95274 Mon Sep 17 00:00:00 2001 From: Scott Brust Date: Tue, 11 Oct 2022 16:01:54 -0700 Subject: [PATCH 009/112] Feedback, wiring/no_fixture_i2c test app WIP --- hal/src/trackerm/hal_platform_config.h | 1 + hal/src/tron/hal_platform_config.h | 1 + .../wiring/no_fixture_i2c/application.cpp | 40 +++++++++++++ .../integration/wiring/no_fixture_i2c/i2c.cpp | 57 +++++++++++++++++++ .../no_fixture_i2c/no_fixture_i2c.spec.js | 3 + .../integration/wiring/no_fixture_i2c/test.mk | 18 ++++++ wiring/src/spark_wiring_i2c.cpp | 8 ++- 7 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 user/tests/integration/wiring/no_fixture_i2c/application.cpp create mode 100644 user/tests/integration/wiring/no_fixture_i2c/i2c.cpp create mode 100644 user/tests/integration/wiring/no_fixture_i2c/no_fixture_i2c.spec.js create mode 100644 user/tests/integration/wiring/no_fixture_i2c/test.mk diff --git a/hal/src/trackerm/hal_platform_config.h b/hal/src/trackerm/hal_platform_config.h index 301bd389b5..2eea5cc1c4 100644 --- a/hal/src/trackerm/hal_platform_config.h +++ b/hal/src/trackerm/hal_platform_config.h @@ -9,6 +9,7 @@ #define HAL_PLATFORM_CELLULAR_SERIAL (HAL_USART_SERIAL2) #define HAL_PLATFORM_SETUP_BUTTON_UX (1) #define HAL_PLATFORM_SPI_NUM (2) +#define HAL_PLATFORM_I2C_NUM (1) #define HAL_PLATFORM_I2C_BUFFER_SIZE(x) (512) #define HAL_PLATFORM_USART_NUM (3) #define HAL_PLATFORM_NCP_COUNT (2) diff --git a/hal/src/tron/hal_platform_config.h b/hal/src/tron/hal_platform_config.h index 654d4779ea..2e4b36fdba 100644 --- a/hal/src/tron/hal_platform_config.h +++ b/hal/src/tron/hal_platform_config.h @@ -11,6 +11,7 @@ #define HAL_PLATFORM_SETUP_BUTTON_UX (1) // #define HAL_PLATFORM_MUXER_MAY_NEED_DELAY_IN_TX (1) #define HAL_PLATFORM_SPI_NUM (2) +#define HAL_PLATFORM_I2C_NUM (1) #define HAL_PLATFORM_USART_NUM (3) #define HAL_PLATFORM_NCP_COUNT (1) #define HAL_PLATFORM_BROKEN_MTU (1) diff --git a/user/tests/integration/wiring/no_fixture_i2c/application.cpp b/user/tests/integration/wiring/no_fixture_i2c/application.cpp new file mode 100644 index 0000000000..187139a131 --- /dev/null +++ b/user/tests/integration/wiring/no_fixture_i2c/application.cpp @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2022 Particle Industries, Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef PARTICLE_TEST_RUNNER + +#include "application.h" +#include "unit-test/unit-test.h" + +// make clean all TEST=wiring/no_fixture PLATFORM=boron -s COMPILE_LTO=n program-dfu DEBUG_BUILD=y +// make clean all TEST=wiring/no_fixture PLATFORM=boron -s COMPILE_LTO=n program-dfu DEBUG_BUILD=y USE_THREADING=y +// +// Serial1LogHandler logHandler(115200, LOG_LEVEL_ALL, { + // { "comm", LOG_LEVEL_NONE }, // filter out comm messages + // { "system", LOG_LEVEL_INFO } // only info level for system messages +// }); + +UNIT_TEST_APP(); + +// Enable threading if compiled with "USE_THREADING=y" +#if PLATFORM_THREADING == 1 && USE_THREADING == 1 +SYSTEM_THREAD(ENABLED); +#endif + +SYSTEM_MODE(MANUAL); + +#endif // PARTICLE_TEST_RUNNER diff --git a/user/tests/integration/wiring/no_fixture_i2c/i2c.cpp b/user/tests/integration/wiring/no_fixture_i2c/i2c.cpp new file mode 100644 index 0000000000..18c81d8a76 --- /dev/null +++ b/user/tests/integration/wiring/no_fixture_i2c/i2c.cpp @@ -0,0 +1,57 @@ + +#include "application.h" +#include "unit-test/unit-test.h" + +SerialLogHandler g_logSerial(LOG_LEVEL_ALL); + +static void init_i2c(){ + Wire1.begin(); +} + +// TODO: Test aquireWireBuffer behavior, on systems with and without i2c peripherals used by the system + +#ifdef HAL_PLATFORM_EXTERNAL_RTC + +// Test > 32 byte reads by reading from AM18x5 RTC peripheral +test(I2C_00_long_read) +{ + init_i2c(); + + // read full register range + const uint8_t REGISTER_RANGE = 64; + uint8_t long_read_buffer[REGISTER_RANGE] = {}; + uint8_t read_length = REGISTER_RANGE; + + // Check read values against ID registers + const uint8_t ID0_REGISTER = 0x28; + const uint8_t ID0_REGISTER_VALUE = 0x18; + const uint8_t ID1_REGISTER = 0x29; + const uint8_t ID1_REGISTER_VALUE = 0x05; + + hal_i2c_interface_t wire_interface = HAL_PLATFORM_EXTERNAL_RTC_I2C; + uint8_t wire_rtc_address = HAL_PLATFORM_EXTERNAL_RTC_I2C_ADDR; + uint8_t start_rtc_register = 0x00; + + hal_i2c_begin_transmission(wire_interface, wire_rtc_address, nullptr); + hal_i2c_write(wire_interface, static_cast(start_rtc_register), nullptr); + hal_i2c_end_transmission(wire_interface, false, nullptr); + assertMore(hal_i2c_request(wire_interface, wire_rtc_address, read_length, true, nullptr), 0); + + int32_t size = hal_i2c_available(wire_interface, nullptr); + assertEqual(size, read_length); + + for (int32_t i = 0; i < size; i++) { + long_read_buffer[i] = hal_i2c_read(wire_interface, nullptr); + } + + Log.info("I2C_00_long_read result %d\n", size); + Log.dump(long_read_buffer, read_length); + Log.info(" \n"); + + assertEqual(long_read_buffer[ID0_REGISTER], ID0_REGISTER_VALUE); + assertEqual(long_read_buffer[ID1_REGISTER], ID1_REGISTER_VALUE); + + assertTrue(true); +} + +#endif // HAL_PLATFORM_EXTERNAL_RTC diff --git a/user/tests/integration/wiring/no_fixture_i2c/no_fixture_i2c.spec.js b/user/tests/integration/wiring/no_fixture_i2c/no_fixture_i2c.spec.js new file mode 100644 index 0000000000..642d693bea --- /dev/null +++ b/user/tests/integration/wiring/no_fixture_i2c/no_fixture_i2c.spec.js @@ -0,0 +1,3 @@ +suite('No fixture I2C'); + +platform('gen3'); diff --git a/user/tests/integration/wiring/no_fixture_i2c/test.mk b/user/tests/integration/wiring/no_fixture_i2c/test.mk new file mode 100644 index 0000000000..b680973e45 --- /dev/null +++ b/user/tests/integration/wiring/no_fixture_i2c/test.mk @@ -0,0 +1,18 @@ +INCLUDE_DIRS += $(SOURCE_PATH)/$(USRSRC) # add user sources to include path +# add C and CPP files - if USRSRC is not empty, then add a slash +CPPSRC += $(call target_files,$(USRSRC_SLASH),*.cpp) +CSRC += $(call target_files,$(USRSRC_SLASH),*.c) + +APPSOURCES=$(call target_files,$(USRSRC_SLASH),*.cpp) +APPSOURCES+=$(call target_files,$(USRSRC_SLASH),*.c) +ifeq ($(strip $(APPSOURCES)),) +$(error "No sources found in $(SOURCE_PATH)/$(USRSRC)") +endif + +ifeq ("${USE_THREADING}","y") +USE_THREADING_VALUE=1 +else +USE_THREADING_VALUE=0 +endif + +CFLAGS += -DUSE_THREADING=${USE_THREADING_VALUE} diff --git a/wiring/src/spark_wiring_i2c.cpp b/wiring/src/spark_wiring_i2c.cpp index f092efcaf0..283fc72da5 100644 --- a/wiring/src/spark_wiring_i2c.cpp +++ b/wiring/src/spark_wiring_i2c.cpp @@ -33,7 +33,13 @@ TwoWire::TwoWire(hal_i2c_interface_t i2c, const hal_i2c_config_t& conf) { _i2c = i2c; - hal_i2c_init(_i2c, &conf); + int result = hal_i2c_init(_i2c, &conf); + if (result == SYSTEM_ERROR_NOT_ENOUGH_DATA && + (conf.version >= HAL_I2C_CONFIG_VERSION_2) && + (conf.flags & HAL_I2C_CONFIG_FLAG_FREEABLE)) { + free(conf.rx_buffer); + free(conf.tx_buffer); + } } // Public Methods ////////////////////////////////////////////////////////////// From 7ee08544ecf23c3a0547e1ecb60965abad41393d Mon Sep 17 00:00:00 2001 From: Scott Brust Date: Wed, 12 Oct 2022 10:46:53 -0700 Subject: [PATCH 010/112] Fixes, more i2c tests --- .../rtl872x/hal_platform_rtl8721x_config.h | 2 - .../integration/wiring/no_fixture_i2c/i2c.cpp | 114 +++++++++++++++--- wiring/src/spark_wiring_i2c.cpp | 1 + 3 files changed, 95 insertions(+), 22 deletions(-) diff --git a/hal/src/rtl872x/hal_platform_rtl8721x_config.h b/hal/src/rtl872x/hal_platform_rtl8721x_config.h index 6c61fb68bc..a2807cbbe8 100644 --- a/hal/src/rtl872x/hal_platform_rtl8721x_config.h +++ b/hal/src/rtl872x/hal_platform_rtl8721x_config.h @@ -51,8 +51,6 @@ // Allow detection of ethernet on SPI #define HAL_PLATFORM_ETHERNET (1) -#define HAL_PLATFORM_I2C2 (1) - #define HAL_PLATFORM_USART3 (1) #define HAL_PLATFORM_USB_VENDOR_REQUEST (1) diff --git a/user/tests/integration/wiring/no_fixture_i2c/i2c.cpp b/user/tests/integration/wiring/no_fixture_i2c/i2c.cpp index 18c81d8a76..deee0368ce 100644 --- a/user/tests/integration/wiring/no_fixture_i2c/i2c.cpp +++ b/user/tests/integration/wiring/no_fixture_i2c/i2c.cpp @@ -2,22 +2,97 @@ #include "application.h" #include "unit-test/unit-test.h" -SerialLogHandler g_logSerial(LOG_LEVEL_ALL); +//SerialLogHandler g_logSerial(LOG_LEVEL_ALL); -static void init_i2c(){ - Wire1.begin(); +static const int WIRE_ACQUIRE_BUFFER_SIZE = HAL_PLATFORM_I2C_BUFFER_SIZE(HAL_I2C_INTERFACE1) + 1; +static const int WIRE1_ACQUIRE_BUFFER_SIZE = HAL_PLATFORM_I2C_BUFFER_SIZE(HAL_I2C_INTERFACE2) + 1; +static const int WIRE1_TRACKER_MINIMUM_BUFFER_SIZE = 512; + +static hal_i2c_config_t allocateWireConfig(uint32_t bufferSize) { + hal_i2c_config_t config = { + .size = sizeof(hal_i2c_config_t), + .version = HAL_I2C_CONFIG_VERSION_2, + .rx_buffer = new (std::nothrow) uint8_t[bufferSize], + .rx_buffer_size = bufferSize, + .tx_buffer = new (std::nothrow) uint8_t[bufferSize], + .tx_buffer_size = bufferSize, + .flags = HAL_I2C_CONFIG_FLAG_FREEABLE + }; + return config; +} + +static void freeWireBuffers(hal_i2c_config_t * config){ + free(config->tx_buffer); + free(config->rx_buffer); +} + +hal_i2c_config_t acquireWireBuffer() +{ + return allocateWireConfig(WIRE_ACQUIRE_BUFFER_SIZE); +} + +#if Wiring_Wire1 +hal_i2c_config_t acquireWire1Buffer() +{ + return allocateWireConfig(WIRE1_ACQUIRE_BUFFER_SIZE); +} +#endif + +test(I2C_00_hal_init_default_buffer) +{ + // Initializing the HAL with a null config is allowed and should allocate system defaults + assertEqual(hal_i2c_init(HAL_I2C_INTERFACE1, nullptr), (int)SYSTEM_ERROR_NONE); + +#if (PLATFORM_ID == PLATFORM_TRACKER) || (PLATFORM_ID == PLATFORM_TRACKERM) + // Tracker platforms should have buffers at least 512 bytes large, allocated by the system on startup + // IE trying to re-initialize the HAL with same size should fail + hal_i2c_config_t wire1_small_buffers = allocateWireConfig(WIRE1_TRACKER_MINIMUM_BUFFER_SIZE); + assertEqual(hal_i2c_init(HAL_I2C_INTERFACE2, &wire1_small_buffers), (int)SYSTEM_ERROR_NOT_ENOUGH_DATA); +#endif } -// TODO: Test aquireWireBuffer behavior, on systems with and without i2c peripherals used by the system +test(I2C_01_test_acquire_wire_buffer) { + // Construct TwoWire object with user acquireWireBuffer() configuration structures, which should re-initialize the I2C HAL + Wire.begin(); + + // Attempt to re-initialize the HAL with different sized buffers to implicitly determine if the user buffers were used by the HAL + // System Defaults < User values from acquireWireBuffer < Values used here to re-initialize the HAL + + // Equal size buffers should fail + hal_i2c_config_t wire_smaller_buffers = allocateWireConfig(WIRE_ACQUIRE_BUFFER_SIZE); + assertEqual(hal_i2c_init(HAL_I2C_INTERFACE1, &wire_smaller_buffers), (int)SYSTEM_ERROR_NOT_ENOUGH_DATA); + freeWireBuffers(&wire_smaller_buffers); + + // Larger sized buffers should succeed + hal_i2c_config_t wire_larger_buffers = allocateWireConfig(WIRE_ACQUIRE_BUFFER_SIZE + 1); + assertEqual(hal_i2c_init(HAL_I2C_INTERFACE1, &wire_larger_buffers), (int)SYSTEM_ERROR_NONE); + freeWireBuffers(&wire_larger_buffers); + + // Reinitializing with a NULL config is not allowed + assertEqual(hal_i2c_init(HAL_I2C_INTERFACE1, nullptr), (int)SYSTEM_ERROR_INVALID_ARGUMENT); -#ifdef HAL_PLATFORM_EXTERNAL_RTC + #if Wiring_Wire1 + Wire1.begin(); + hal_i2c_config_t wire1_smaller_buffers = allocateWireConfig(WIRE1_ACQUIRE_BUFFER_SIZE); + assertEqual(hal_i2c_init(HAL_I2C_INTERFACE2, &wire1_smaller_buffers), (int)SYSTEM_ERROR_NOT_ENOUGH_DATA); + freeWireBuffers(&wire1_smaller_buffers); + + hal_i2c_config_t wire1_larger_buffers = allocateWireConfig(WIRE1_ACQUIRE_BUFFER_SIZE + 1); + assertEqual(hal_i2c_init(HAL_I2C_INTERFACE2, &wire1_larger_buffers), (int)SYSTEM_ERROR_NONE); + freeWireBuffers(&wire1_larger_buffers); + + assertEqual(hal_i2c_init(HAL_I2C_INTERFACE2, nullptr), (int)SYSTEM_ERROR_INVALID_ARGUMENT); + #endif +} + +#if HAL_PLATFORM_EXTERNAL_RTC -// Test > 32 byte reads by reading from AM18x5 RTC peripheral -test(I2C_00_long_read) +test(I2C_02_long_read) { - init_i2c(); + // Test > 32 byte reads by reading from AM18x5 RTC peripheral + Wire1.begin(); - // read full register range + // Read full register range const uint8_t REGISTER_RANGE = 64; uint8_t long_read_buffer[REGISTER_RANGE] = {}; uint8_t read_length = REGISTER_RANGE; @@ -32,21 +107,20 @@ test(I2C_00_long_read) uint8_t wire_rtc_address = HAL_PLATFORM_EXTERNAL_RTC_I2C_ADDR; uint8_t start_rtc_register = 0x00; - hal_i2c_begin_transmission(wire_interface, wire_rtc_address, nullptr); - hal_i2c_write(wire_interface, static_cast(start_rtc_register), nullptr); - hal_i2c_end_transmission(wire_interface, false, nullptr); - assertMore(hal_i2c_request(wire_interface, wire_rtc_address, read_length, true, nullptr), 0); + Wire1.beginTransmission(wire_rtc_address); + Wire1.write(&start_rtc_register, sizeof(start_rtc_register)); + Wire1.endTransmission(); + Wire1.requestFrom(wire_rtc_address, read_length); + int32_t size = Wire1.available(); + assertMore(Wire1.available(), 0); - int32_t size = hal_i2c_available(wire_interface, nullptr); - assertEqual(size, read_length); - for (int32_t i = 0; i < size; i++) { - long_read_buffer[i] = hal_i2c_read(wire_interface, nullptr); + long_read_buffer[i] = (uint8_t)Wire1.read(); } - Log.info("I2C_00_long_read result %d\n", size); - Log.dump(long_read_buffer, read_length); - Log.info(" \n"); + // Log.info("I2C_02_long_read result %d\n", size); + // Log.dump(long_read_buffer, read_length); + // Log.info(" \n"); assertEqual(long_read_buffer[ID0_REGISTER], ID0_REGISTER_VALUE); assertEqual(long_read_buffer[ID1_REGISTER], ID1_REGISTER_VALUE); diff --git a/wiring/src/spark_wiring_i2c.cpp b/wiring/src/spark_wiring_i2c.cpp index 283fc72da5..21ed543a77 100644 --- a/wiring/src/spark_wiring_i2c.cpp +++ b/wiring/src/spark_wiring_i2c.cpp @@ -27,6 +27,7 @@ #include "spark_wiring_i2c.h" #include "i2c_hal.h" #include "spark_wiring_thread.h" +#include // Constructors //////////////////////////////////////////////////////////////// From ee1f74cf41bd887955affa78b62df020f3a98853 Mon Sep 17 00:00:00 2001 From: Scott Brust Date: Fri, 14 Oct 2022 09:54:45 -0700 Subject: [PATCH 011/112] Feedback --- .../wiring/no_fixture_i2c/application.cpp | 2 +- .../integration/wiring/no_fixture_i2c/i2c.cpp | 87 ++++++++++++------- wiring/src/spark_wiring_i2c.cpp | 3 +- 3 files changed, 56 insertions(+), 36 deletions(-) diff --git a/user/tests/integration/wiring/no_fixture_i2c/application.cpp b/user/tests/integration/wiring/no_fixture_i2c/application.cpp index 187139a131..80a20795de 100644 --- a/user/tests/integration/wiring/no_fixture_i2c/application.cpp +++ b/user/tests/integration/wiring/no_fixture_i2c/application.cpp @@ -35,6 +35,6 @@ UNIT_TEST_APP(); SYSTEM_THREAD(ENABLED); #endif -SYSTEM_MODE(MANUAL); +SYSTEM_MODE(SEMI_AUTOMATIC); #endif // PARTICLE_TEST_RUNNER diff --git a/user/tests/integration/wiring/no_fixture_i2c/i2c.cpp b/user/tests/integration/wiring/no_fixture_i2c/i2c.cpp index deee0368ce..02d49d4bfe 100644 --- a/user/tests/integration/wiring/no_fixture_i2c/i2c.cpp +++ b/user/tests/integration/wiring/no_fixture_i2c/i2c.cpp @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2022 Particle Industries, Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ #include "application.h" #include "unit-test/unit-test.h" @@ -6,7 +22,7 @@ static const int WIRE_ACQUIRE_BUFFER_SIZE = HAL_PLATFORM_I2C_BUFFER_SIZE(HAL_I2C_INTERFACE1) + 1; static const int WIRE1_ACQUIRE_BUFFER_SIZE = HAL_PLATFORM_I2C_BUFFER_SIZE(HAL_I2C_INTERFACE2) + 1; -static const int WIRE1_TRACKER_MINIMUM_BUFFER_SIZE = 512; +static const int TRACKER_MINIMUM_BUFFER_SIZE = 512; static hal_i2c_config_t allocateWireConfig(uint32_t bufferSize) { hal_i2c_config_t config = { @@ -46,9 +62,12 @@ test(I2C_00_hal_init_default_buffer) #if (PLATFORM_ID == PLATFORM_TRACKER) || (PLATFORM_ID == PLATFORM_TRACKERM) // Tracker platforms should have buffers at least 512 bytes large, allocated by the system on startup // IE trying to re-initialize the HAL with same size should fail - hal_i2c_config_t wire1_small_buffers = allocateWireConfig(WIRE1_TRACKER_MINIMUM_BUFFER_SIZE); - assertEqual(hal_i2c_init(HAL_I2C_INTERFACE2, &wire1_small_buffers), (int)SYSTEM_ERROR_NOT_ENOUGH_DATA); -#endif + hal_i2c_config_t smallBuffers = allocateWireConfig(TRACKER_MINIMUM_BUFFER_SIZE); + hal_i2c_interface_t largeBufferInterface = (PLATFORM_ID == PLATFORM_TRACKER) ? HAL_I2C_INTERFACE2 : HAL_I2C_INTERFACE1; + assertEqual(hal_i2c_init(largeBufferInterface, &smallBuffers), (int)SYSTEM_ERROR_NOT_ENOUGH_DATA); + freeWireBuffers(&smallBuffers); +#endif + } test(I2C_01_test_acquire_wire_buffer) { @@ -59,30 +78,30 @@ test(I2C_01_test_acquire_wire_buffer) { // System Defaults < User values from acquireWireBuffer < Values used here to re-initialize the HAL // Equal size buffers should fail - hal_i2c_config_t wire_smaller_buffers = allocateWireConfig(WIRE_ACQUIRE_BUFFER_SIZE); - assertEqual(hal_i2c_init(HAL_I2C_INTERFACE1, &wire_smaller_buffers), (int)SYSTEM_ERROR_NOT_ENOUGH_DATA); - freeWireBuffers(&wire_smaller_buffers); + hal_i2c_config_t wireSmallerBuffers = allocateWireConfig(WIRE_ACQUIRE_BUFFER_SIZE); + assertEqual(hal_i2c_init(HAL_I2C_INTERFACE1, &wireSmallerBuffers), (int)SYSTEM_ERROR_NOT_ENOUGH_DATA); + freeWireBuffers(&wireSmallerBuffers); // Larger sized buffers should succeed - hal_i2c_config_t wire_larger_buffers = allocateWireConfig(WIRE_ACQUIRE_BUFFER_SIZE + 1); - assertEqual(hal_i2c_init(HAL_I2C_INTERFACE1, &wire_larger_buffers), (int)SYSTEM_ERROR_NONE); - freeWireBuffers(&wire_larger_buffers); + hal_i2c_config_t wireLargerBuffers = allocateWireConfig(WIRE_ACQUIRE_BUFFER_SIZE + 1); + assertEqual(hal_i2c_init(HAL_I2C_INTERFACE1, &wireLargerBuffers), (int)SYSTEM_ERROR_NONE); + freeWireBuffers(&wireLargerBuffers); // Reinitializing with a NULL config is not allowed assertEqual(hal_i2c_init(HAL_I2C_INTERFACE1, nullptr), (int)SYSTEM_ERROR_INVALID_ARGUMENT); - #if Wiring_Wire1 +#if Wiring_Wire1 Wire1.begin(); - hal_i2c_config_t wire1_smaller_buffers = allocateWireConfig(WIRE1_ACQUIRE_BUFFER_SIZE); - assertEqual(hal_i2c_init(HAL_I2C_INTERFACE2, &wire1_smaller_buffers), (int)SYSTEM_ERROR_NOT_ENOUGH_DATA); - freeWireBuffers(&wire1_smaller_buffers); + hal_i2c_config_t wire1SmallerBuffers = allocateWireConfig(WIRE1_ACQUIRE_BUFFER_SIZE); + assertEqual(hal_i2c_init(HAL_I2C_INTERFACE2, &wire1SmallerBuffers), (int)SYSTEM_ERROR_NOT_ENOUGH_DATA); + freeWireBuffers(&wire1SmallerBuffers); - hal_i2c_config_t wire1_larger_buffers = allocateWireConfig(WIRE1_ACQUIRE_BUFFER_SIZE + 1); - assertEqual(hal_i2c_init(HAL_I2C_INTERFACE2, &wire1_larger_buffers), (int)SYSTEM_ERROR_NONE); - freeWireBuffers(&wire1_larger_buffers); + hal_i2c_config_t wire1LargerBuffers = allocateWireConfig(WIRE1_ACQUIRE_BUFFER_SIZE + 1); + assertEqual(hal_i2c_init(HAL_I2C_INTERFACE2, &wire1LargerBuffers), (int)SYSTEM_ERROR_NONE); + freeWireBuffers(&wire1LargerBuffers); assertEqual(hal_i2c_init(HAL_I2C_INTERFACE2, nullptr), (int)SYSTEM_ERROR_INVALID_ARGUMENT); - #endif +#endif } #if HAL_PLATFORM_EXTERNAL_RTC @@ -94,8 +113,8 @@ test(I2C_02_long_read) // Read full register range const uint8_t REGISTER_RANGE = 64; - uint8_t long_read_buffer[REGISTER_RANGE] = {}; - uint8_t read_length = REGISTER_RANGE; + uint8_t longReadBuffer[REGISTER_RANGE] = {}; + uint8_t readLength = REGISTER_RANGE; // Check read values against ID registers const uint8_t ID0_REGISTER = 0x28; @@ -103,27 +122,29 @@ test(I2C_02_long_read) const uint8_t ID1_REGISTER = 0x29; const uint8_t ID1_REGISTER_VALUE = 0x05; - hal_i2c_interface_t wire_interface = HAL_PLATFORM_EXTERNAL_RTC_I2C; - uint8_t wire_rtc_address = HAL_PLATFORM_EXTERNAL_RTC_I2C_ADDR; - uint8_t start_rtc_register = 0x00; + hal_i2c_interface_t wireInterface = HAL_PLATFORM_EXTERNAL_RTC_I2C; + uint8_t rtcAddress = HAL_PLATFORM_EXTERNAL_RTC_I2C_ADDR; + uint8_t rtcRegister = 0x00; + + hal_i2c_begin_transmission(wireInterface, rtcAddress, NULL); + hal_i2c_write(wireInterface, rtcRegister, NULL); + hal_i2c_end_transmission(wireInterface, true, NULL); + auto config = WireTransmission(rtcAddress).quantity(readLength).stop(true).halConfig(); + hal_i2c_request_ex(wireInterface, &config, nullptr); - Wire1.beginTransmission(wire_rtc_address); - Wire1.write(&start_rtc_register, sizeof(start_rtc_register)); - Wire1.endTransmission(); - Wire1.requestFrom(wire_rtc_address, read_length); - int32_t size = Wire1.available(); - assertMore(Wire1.available(), 0); + int32_t size = hal_i2c_available(wireInterface, NULL); + assertMore(size, 0); for (int32_t i = 0; i < size; i++) { - long_read_buffer[i] = (uint8_t)Wire1.read(); + longReadBuffer[i] = (uint8_t)hal_i2c_read(wireInterface, NULL); } // Log.info("I2C_02_long_read result %d\n", size); - // Log.dump(long_read_buffer, read_length); + // Log.dump(long_read_buffer, readLength); // Log.info(" \n"); - assertEqual(long_read_buffer[ID0_REGISTER], ID0_REGISTER_VALUE); - assertEqual(long_read_buffer[ID1_REGISTER], ID1_REGISTER_VALUE); + assertEqual(longReadBuffer[ID0_REGISTER], ID0_REGISTER_VALUE); + assertEqual(longReadBuffer[ID1_REGISTER], ID1_REGISTER_VALUE); assertTrue(true); } diff --git a/wiring/src/spark_wiring_i2c.cpp b/wiring/src/spark_wiring_i2c.cpp index 21ed543a77..afc5f0b2a2 100644 --- a/wiring/src/spark_wiring_i2c.cpp +++ b/wiring/src/spark_wiring_i2c.cpp @@ -36,8 +36,7 @@ TwoWire::TwoWire(hal_i2c_interface_t i2c, const hal_i2c_config_t& conf) _i2c = i2c; int result = hal_i2c_init(_i2c, &conf); if (result == SYSTEM_ERROR_NOT_ENOUGH_DATA && - (conf.version >= HAL_I2C_CONFIG_VERSION_2) && - (conf.flags & HAL_I2C_CONFIG_FLAG_FREEABLE)) { + (conf.flags & HAL_I2C_CONFIG_FLAG_FREEABLE)) { free(conf.rx_buffer); free(conf.tx_buffer); } From 7ce651162fe77df928275de963de82d36bcbf4ca Mon Sep 17 00:00:00 2001 From: Scott Brust Date: Mon, 17 Oct 2022 15:31:24 -0700 Subject: [PATCH 012/112] Feedback, test PMIC as well --- hal/src/nRF52840/i2c_hal.cpp | 3 +- .../integration/wiring/no_fixture_i2c/i2c.cpp | 72 ++++++++++++++++--- 2 files changed, 63 insertions(+), 12 deletions(-) diff --git a/hal/src/nRF52840/i2c_hal.cpp b/hal/src/nRF52840/i2c_hal.cpp index 6d2267a457..4e6f76b884 100644 --- a/hal/src/nRF52840/i2c_hal.cpp +++ b/hal/src/nRF52840/i2c_hal.cpp @@ -332,7 +332,8 @@ int hal_i2c_init(hal_i2c_interface_t i2c, const hal_i2c_config_t* config) { // Free current buffers if needed if (i2cMap[i2c].heap_buffer) { free(i2cMap[i2c].rx_buf); - free(i2cMap[i2c].tx_buf); + free(i2cMap[i2c].tx_buf); + i2cMap[i2c].configured = false; } } diff --git a/user/tests/integration/wiring/no_fixture_i2c/i2c.cpp b/user/tests/integration/wiring/no_fixture_i2c/i2c.cpp index 02d49d4bfe..5aea86c97c 100644 --- a/user/tests/integration/wiring/no_fixture_i2c/i2c.cpp +++ b/user/tests/integration/wiring/no_fixture_i2c/i2c.cpp @@ -18,7 +18,7 @@ #include "application.h" #include "unit-test/unit-test.h" -//SerialLogHandler g_logSerial(LOG_LEVEL_ALL); +// SerialLogHandler g_logSerial(LOG_LEVEL_ALL); static const int WIRE_ACQUIRE_BUFFER_SIZE = HAL_PLATFORM_I2C_BUFFER_SIZE(HAL_I2C_INTERFACE1) + 1; static const int WIRE1_ACQUIRE_BUFFER_SIZE = HAL_PLATFORM_I2C_BUFFER_SIZE(HAL_I2C_INTERFACE2) + 1; @@ -90,7 +90,11 @@ test(I2C_01_test_acquire_wire_buffer) { // Reinitializing with a NULL config is not allowed assertEqual(hal_i2c_init(HAL_I2C_INTERFACE1, nullptr), (int)SYSTEM_ERROR_INVALID_ARGUMENT); + hal_i2c_end(HAL_I2C_INTERFACE1, nullptr); +} + #if Wiring_Wire1 +test(I2C_02_test_acquire_wire1_buffer) { Wire1.begin(); hal_i2c_config_t wire1SmallerBuffers = allocateWireConfig(WIRE1_ACQUIRE_BUFFER_SIZE); assertEqual(hal_i2c_init(HAL_I2C_INTERFACE2, &wire1SmallerBuffers), (int)SYSTEM_ERROR_NOT_ENOUGH_DATA); @@ -101,12 +105,13 @@ test(I2C_01_test_acquire_wire_buffer) { freeWireBuffers(&wire1LargerBuffers); assertEqual(hal_i2c_init(HAL_I2C_INTERFACE2, nullptr), (int)SYSTEM_ERROR_INVALID_ARGUMENT); -#endif + + hal_i2c_end(HAL_I2C_INTERFACE2, nullptr); } +#endif #if HAL_PLATFORM_EXTERNAL_RTC - -test(I2C_02_long_read) +test(I2C_04_long_read_rtc) { // Test > 32 byte reads by reading from AM18x5 RTC peripheral Wire1.begin(); @@ -132,21 +137,66 @@ test(I2C_02_long_read) auto config = WireTransmission(rtcAddress).quantity(readLength).stop(true).halConfig(); hal_i2c_request_ex(wireInterface, &config, nullptr); - int32_t size = hal_i2c_available(wireInterface, NULL); - assertMore(size, 0); + int32_t bytesAvailable = hal_i2c_available(wireInterface, NULL); + assertEqual(bytesAvailable, readLength); - for (int32_t i = 0; i < size; i++) { + for (int32_t i = 0; i < bytesAvailable; i++) { longReadBuffer[i] = (uint8_t)hal_i2c_read(wireInterface, NULL); } - // Log.info("I2C_02_long_read result %d\n", size); - // Log.dump(long_read_buffer, readLength); + // Log.info("I2C_04_long_read_rtc result %d\n", bytesAvailable); + // Log.dump(long_read_buffer, bytesAvailable); // Log.info(" \n"); assertEqual(longReadBuffer[ID0_REGISTER], ID0_REGISTER_VALUE); assertEqual(longReadBuffer[ID1_REGISTER], ID1_REGISTER_VALUE); - - assertTrue(true); } #endif // HAL_PLATFORM_EXTERNAL_RTC + +#if (HAL_PLATFORM_POWER_MANAGEMENT_OPTIONAL == 0) && (HAL_PLATFORM_PMIC_BQ24195) + +test(I2C_05_long_read_pmic) +{ + // Test > 32 byte reads by reading from BQ24195 PMIC peripheral. + // The device only has 10 registers to read, but should not NAK reads for more data +#if HAL_PLATFORM_PMIC_BQ24195_I2C == HAL_I2C_INTERFACE1 + Wire.begin(); +#elif HAL_PLATFORM_PMIC_BQ24195_I2C == HAL_I2C_INTERFACE2 + Wire1.begin(); +#endif + + // Read full register range + const uint8_t REGISTER_RANGE = 64; + uint8_t longReadBuffer[REGISTER_RANGE] = {}; + uint8_t readLength = REGISTER_RANGE; + + // Check read values against ID register + const uint8_t ID_REGISTER = 0x0A; + const uint8_t ID_REGISTER_VALUE = 0x23; + + hal_i2c_interface_t wireInterface = HAL_PLATFORM_PMIC_BQ24195_I2C; + uint8_t pmicAddress = PMIC_ADDRESS; + uint8_t rtcRegister = 0x00; + + hal_i2c_begin_transmission(wireInterface, pmicAddress, NULL); + hal_i2c_write(wireInterface, rtcRegister, NULL); + hal_i2c_end_transmission(wireInterface, true, NULL); + auto config = WireTransmission(pmicAddress).quantity(readLength).stop(true).halConfig(); + hal_i2c_request_ex(wireInterface, &config, nullptr); + + int32_t bytesAvailable = hal_i2c_available(wireInterface, NULL); + assertEqual(bytesAvailable, readLength); + + for (int32_t i = 0; i < bytesAvailable; i++) { + longReadBuffer[i] = (uint8_t)hal_i2c_read(wireInterface, NULL); + } + + // Log.info("I2C_05_long_read_pmic result %ld\n", bytesAvailable); + // Log.dump(longReadBuffer, bytesAvailable); + // Log.info(" \n"); + + assertEqual(longReadBuffer[ID_REGISTER], ID_REGISTER_VALUE); +} + +#endif // HAL_PLATFORM_PMIC_BQ24195 From 1db24747e658e41b67c2aaae1bdf99d454c8bbc9 Mon Sep 17 00:00:00 2001 From: Scott Brust Date: Tue, 18 Oct 2022 11:22:09 -0700 Subject: [PATCH 013/112] Move no_fixture_i2c to correct dir and symlink to integration/wiring --- user/tests/integration/wiring/no_fixture_i2c | 1 + .../{integration => }/wiring/no_fixture_i2c/application.cpp | 0 user/tests/{integration => }/wiring/no_fixture_i2c/i2c.cpp | 0 .../wiring/no_fixture_i2c/no_fixture_i2c.spec.js | 0 user/tests/{integration => }/wiring/no_fixture_i2c/test.mk | 0 5 files changed, 1 insertion(+) create mode 120000 user/tests/integration/wiring/no_fixture_i2c rename user/tests/{integration => }/wiring/no_fixture_i2c/application.cpp (100%) rename user/tests/{integration => }/wiring/no_fixture_i2c/i2c.cpp (100%) rename user/tests/{integration => }/wiring/no_fixture_i2c/no_fixture_i2c.spec.js (100%) rename user/tests/{integration => }/wiring/no_fixture_i2c/test.mk (100%) diff --git a/user/tests/integration/wiring/no_fixture_i2c b/user/tests/integration/wiring/no_fixture_i2c new file mode 120000 index 0000000000..e3fc42d2b1 --- /dev/null +++ b/user/tests/integration/wiring/no_fixture_i2c @@ -0,0 +1 @@ +../../wiring/no_fixture_i2c \ No newline at end of file diff --git a/user/tests/integration/wiring/no_fixture_i2c/application.cpp b/user/tests/wiring/no_fixture_i2c/application.cpp similarity index 100% rename from user/tests/integration/wiring/no_fixture_i2c/application.cpp rename to user/tests/wiring/no_fixture_i2c/application.cpp diff --git a/user/tests/integration/wiring/no_fixture_i2c/i2c.cpp b/user/tests/wiring/no_fixture_i2c/i2c.cpp similarity index 100% rename from user/tests/integration/wiring/no_fixture_i2c/i2c.cpp rename to user/tests/wiring/no_fixture_i2c/i2c.cpp diff --git a/user/tests/integration/wiring/no_fixture_i2c/no_fixture_i2c.spec.js b/user/tests/wiring/no_fixture_i2c/no_fixture_i2c.spec.js similarity index 100% rename from user/tests/integration/wiring/no_fixture_i2c/no_fixture_i2c.spec.js rename to user/tests/wiring/no_fixture_i2c/no_fixture_i2c.spec.js diff --git a/user/tests/integration/wiring/no_fixture_i2c/test.mk b/user/tests/wiring/no_fixture_i2c/test.mk similarity index 100% rename from user/tests/integration/wiring/no_fixture_i2c/test.mk rename to user/tests/wiring/no_fixture_i2c/test.mk From 6bd2d844d5f38ad14477ef7727ab26622d2debee Mon Sep 17 00:00:00 2001 From: Andrey Tolstoy Date: Mon, 24 Oct 2022 03:02:38 +0700 Subject: [PATCH 014/112] [p2] fix race condition in getNetworkInfo(), fixes behavior with RTW_SECURITY_WPA2_WPA3_MIXED mode --- hal/network/ncp_client/realtek/rtl_ncp_client.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hal/network/ncp_client/realtek/rtl_ncp_client.cpp b/hal/network/ncp_client/realtek/rtl_ncp_client.cpp index a44e524504..262bc96619 100644 --- a/hal/network/ncp_client/realtek/rtl_ncp_client.cpp +++ b/hal/network/ncp_client/realtek/rtl_ncp_client.cpp @@ -129,7 +129,9 @@ int rtlSecurityToWifiSecurity(rtw_security_t rtlSec) { } case RTW_SECURITY_WPA2_AES_PSK: case RTW_SECURITY_WPA2_TKIP_PSK: - case RTW_SECURITY_WPA2_MIXED_PSK: { + case RTW_SECURITY_WPA2_MIXED_PSK: + // FIXME: + case RTW_SECURITY_WPA2_WPA3_MIXED: { return (int)WifiSecurity::WPA2_PSK; } case RTW_SECURITY_WPA_WPA2_TKIP_PSK: @@ -320,6 +322,9 @@ int RealtekNcpClient::connect(const char* ssid, const MacAddress& bssid, WifiSec } int RealtekNcpClient::getNetworkInfo(WifiNetworkInfo* info) { + const NcpClientLock lock(this); + CHECK_TRUE(connState_ == NcpConnectionState::CONNECTED, SYSTEM_ERROR_INVALID_STATE); + int rtlError = 0; // LOG(INFO, "RNCP getNetworkInfo"); From f178f8e052f4b4407c756ed3200097f2422b6bf5 Mon Sep 17 00:00:00 2001 From: Andrey Tolstoy Date: Wed, 19 Oct 2022 21:50:14 +0700 Subject: [PATCH 015/112] [ci] branch name markdown woes --- ci/cf_generate_message.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ci/cf_generate_message.sh b/ci/cf_generate_message.sh index 4fefd5fcf8..0fd499352b 100755 --- a/ci/cf_generate_message.sh +++ b/ci/cf_generate_message.sh @@ -21,6 +21,9 @@ fi REPOSITORY_URL="https://github.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}" COMMIT_URL="${REPOSITORY_URL}/commit/${CIRCLE_SHA1}" +# Underscores are treated as italic styling and seems to cause an error +export CIRCLE_BRANCH="${CIRCLE_BRANCH//_/\\_}" + BASE_BLOCK=$(cat < Date: Sun, 23 Oct 2022 21:03:22 +0700 Subject: [PATCH 016/112] [ci] split platform sections in slack report script into two parts to avoid hitting the limit of 10 fields in a section --- ci/cf_generate_message.sh | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/ci/cf_generate_message.sh b/ci/cf_generate_message.sh index 0fd499352b..50e3103758 100755 --- a/ci/cf_generate_message.sh +++ b/ci/cf_generate_message.sh @@ -21,9 +21,6 @@ fi REPOSITORY_URL="https://github.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}" COMMIT_URL="${REPOSITORY_URL}/commit/${CIRCLE_SHA1}" -# Underscores are treated as italic styling and seems to cause an error -export CIRCLE_BRANCH="${CIRCLE_BRANCH//_/\\_}" - BASE_BLOCK=$(cat < Date: Mon, 24 Oct 2022 02:43:26 +0700 Subject: [PATCH 017/112] [ci] fix release publish script --- build/release-publish.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/release-publish.sh b/build/release-publish.sh index 5045364265..8a48d17cf9 100755 --- a/build/release-publish.sh +++ b/build/release-publish.sh @@ -102,7 +102,7 @@ cd $RELEASE_DIRECTORY ABSOLUTE_RELEASE_DIRECTORY=$(pwd) # Make a working directory -TEMPORARY_DIRECTORY=${ABSOLUTE_RELEASE_DIRECTORY}/tmp +TEMPORARY_DIRECTORY=${ABSOLUTE_RELEASE_DIRECTORY}/.tmp rm -rf $TEMPORARY_DIRECTORY mkdir $TEMPORARY_DIRECTORY From 95d091a4f922dc813046269c478759857be68ee8 Mon Sep 17 00:00:00 2001 From: Scott Brust Date: Tue, 18 Oct 2022 15:34:39 -0700 Subject: [PATCH 018/112] Fix no_fixture_i2c for esomx,boron,bsom platforms --- user/tests/wiring/no_fixture_i2c/i2c.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/user/tests/wiring/no_fixture_i2c/i2c.cpp b/user/tests/wiring/no_fixture_i2c/i2c.cpp index 5aea86c97c..17443b07e7 100644 --- a/user/tests/wiring/no_fixture_i2c/i2c.cpp +++ b/user/tests/wiring/no_fixture_i2c/i2c.cpp @@ -57,7 +57,11 @@ hal_i2c_config_t acquireWire1Buffer() test(I2C_00_hal_init_default_buffer) { // Initializing the HAL with a null config is allowed and should allocate system defaults - assertEqual(hal_i2c_init(HAL_I2C_INTERFACE1, nullptr), (int)SYSTEM_ERROR_NONE); + if (!hal_i2c_is_enabled(HAL_I2C_INTERFACE1, nullptr)) { + assertEqual(hal_i2c_init(HAL_I2C_INTERFACE1, nullptr), (int)SYSTEM_ERROR_NONE); + } else { + assertEqual(hal_i2c_init(HAL_I2C_INTERFACE1, nullptr), (int)SYSTEM_ERROR_INVALID_ARGUMENT); + } #if (PLATFORM_ID == PLATFORM_TRACKER) || (PLATFORM_ID == PLATFORM_TRACKERM) // Tracker platforms should have buffers at least 512 bytes large, allocated by the system on startup @@ -166,8 +170,11 @@ test(I2C_05_long_read_pmic) Wire1.begin(); #endif - // Read full register range - const uint8_t REGISTER_RANGE = 64; + // Turn on PMIC + PMIC().begin(); + + // Read beyond full register range + const uint8_t REGISTER_RANGE = 34; uint8_t longReadBuffer[REGISTER_RANGE] = {}; uint8_t readLength = REGISTER_RANGE; From 65a3e6733624839ec2227545ce08526f988cd06e Mon Sep 17 00:00:00 2001 From: Scott Brust Date: Wed, 19 Oct 2022 10:04:36 -0700 Subject: [PATCH 019/112] Feedback, lock i2c interface when re-init / manually reading PMIC/RTC --- user/tests/wiring/no_fixture_i2c/i2c.cpp | 54 ++++++++++++++++-------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/user/tests/wiring/no_fixture_i2c/i2c.cpp b/user/tests/wiring/no_fixture_i2c/i2c.cpp index 17443b07e7..018c76f4bf 100644 --- a/user/tests/wiring/no_fixture_i2c/i2c.cpp +++ b/user/tests/wiring/no_fixture_i2c/i2c.cpp @@ -56,6 +56,10 @@ hal_i2c_config_t acquireWire1Buffer() test(I2C_00_hal_init_default_buffer) { + hal_i2c_lock(HAL_I2C_INTERFACE1, nullptr); + SCOPE_GUARD({ + hal_i2c_unlock(HAL_I2C_INTERFACE1, nullptr); + }); // Initializing the HAL with a null config is allowed and should allocate system defaults if (!hal_i2c_is_enabled(HAL_I2C_INTERFACE1, nullptr)) { assertEqual(hal_i2c_init(HAL_I2C_INTERFACE1, nullptr), (int)SYSTEM_ERROR_NONE); @@ -68,6 +72,11 @@ test(I2C_00_hal_init_default_buffer) // IE trying to re-initialize the HAL with same size should fail hal_i2c_config_t smallBuffers = allocateWireConfig(TRACKER_MINIMUM_BUFFER_SIZE); hal_i2c_interface_t largeBufferInterface = (PLATFORM_ID == PLATFORM_TRACKER) ? HAL_I2C_INTERFACE2 : HAL_I2C_INTERFACE1; + hal_i2c_lock(largeBufferInterface, nullptr); + SCOPE_GUARD({ + hal_i2c_unlock(largeBufferInterface, nullptr); + }); + assertEqual(hal_i2c_init(largeBufferInterface, &smallBuffers), (int)SYSTEM_ERROR_NOT_ENOUGH_DATA); freeWireBuffers(&smallBuffers); #endif @@ -77,6 +86,10 @@ test(I2C_00_hal_init_default_buffer) test(I2C_01_test_acquire_wire_buffer) { // Construct TwoWire object with user acquireWireBuffer() configuration structures, which should re-initialize the I2C HAL Wire.begin(); + hal_i2c_lock(HAL_I2C_INTERFACE1, nullptr); + SCOPE_GUARD({ + hal_i2c_unlock(HAL_I2C_INTERFACE1, nullptr); + }); // Attempt to re-initialize the HAL with different sized buffers to implicitly determine if the user buffers were used by the HAL // System Defaults < User values from acquireWireBuffer < Values used here to re-initialize the HAL @@ -93,13 +106,15 @@ test(I2C_01_test_acquire_wire_buffer) { // Reinitializing with a NULL config is not allowed assertEqual(hal_i2c_init(HAL_I2C_INTERFACE1, nullptr), (int)SYSTEM_ERROR_INVALID_ARGUMENT); - - hal_i2c_end(HAL_I2C_INTERFACE1, nullptr); } #if Wiring_Wire1 test(I2C_02_test_acquire_wire1_buffer) { Wire1.begin(); + hal_i2c_lock(HAL_I2C_INTERFACE2, nullptr); + SCOPE_GUARD({ + hal_i2c_unlock(HAL_I2C_INTERFACE2, nullptr); + }); hal_i2c_config_t wire1SmallerBuffers = allocateWireConfig(WIRE1_ACQUIRE_BUFFER_SIZE); assertEqual(hal_i2c_init(HAL_I2C_INTERFACE2, &wire1SmallerBuffers), (int)SYSTEM_ERROR_NOT_ENOUGH_DATA); freeWireBuffers(&wire1SmallerBuffers); @@ -109,13 +124,11 @@ test(I2C_02_test_acquire_wire1_buffer) { freeWireBuffers(&wire1LargerBuffers); assertEqual(hal_i2c_init(HAL_I2C_INTERFACE2, nullptr), (int)SYSTEM_ERROR_INVALID_ARGUMENT); - - hal_i2c_end(HAL_I2C_INTERFACE2, nullptr); } #endif #if HAL_PLATFORM_EXTERNAL_RTC -test(I2C_04_long_read_rtc) +test(I2C_03_long_read_rtc) { // Test > 32 byte reads by reading from AM18x5 RTC peripheral Wire1.begin(); @@ -135,6 +148,11 @@ test(I2C_04_long_read_rtc) uint8_t rtcAddress = HAL_PLATFORM_EXTERNAL_RTC_I2C_ADDR; uint8_t rtcRegister = 0x00; + hal_i2c_lock(wireInterface, nullptr); + SCOPE_GUARD({ + hal_i2c_unlock(wireInterface, nullptr); + }); + hal_i2c_begin_transmission(wireInterface, rtcAddress, NULL); hal_i2c_write(wireInterface, rtcRegister, NULL); hal_i2c_end_transmission(wireInterface, true, NULL); @@ -148,7 +166,7 @@ test(I2C_04_long_read_rtc) longReadBuffer[i] = (uint8_t)hal_i2c_read(wireInterface, NULL); } - // Log.info("I2C_04_long_read_rtc result %d\n", bytesAvailable); + // Log.info("I2C_03_long_read_rtc result %d\n", bytesAvailable); // Log.dump(long_read_buffer, bytesAvailable); // Log.info(" \n"); @@ -160,18 +178,10 @@ test(I2C_04_long_read_rtc) #if (HAL_PLATFORM_POWER_MANAGEMENT_OPTIONAL == 0) && (HAL_PLATFORM_PMIC_BQ24195) -test(I2C_05_long_read_pmic) +test(I2C_04_long_read_pmic) { // Test > 32 byte reads by reading from BQ24195 PMIC peripheral. // The device only has 10 registers to read, but should not NAK reads for more data -#if HAL_PLATFORM_PMIC_BQ24195_I2C == HAL_I2C_INTERFACE1 - Wire.begin(); -#elif HAL_PLATFORM_PMIC_BQ24195_I2C == HAL_I2C_INTERFACE2 - Wire1.begin(); -#endif - - // Turn on PMIC - PMIC().begin(); // Read beyond full register range const uint8_t REGISTER_RANGE = 34; @@ -184,10 +194,18 @@ test(I2C_05_long_read_pmic) hal_i2c_interface_t wireInterface = HAL_PLATFORM_PMIC_BQ24195_I2C; uint8_t pmicAddress = PMIC_ADDRESS; - uint8_t rtcRegister = 0x00; + uint8_t pmicRegister = 0x00; + + hal_i2c_lock(wireInterface, nullptr); + SCOPE_GUARD({ + hal_i2c_unlock(wireInterface, nullptr); + }); + + hal_i2c_begin(wireInterface, I2C_MODE_MASTER, 0x00, NULL); + assertTrue(hal_i2c_is_enabled(wireInterface, nullptr)); hal_i2c_begin_transmission(wireInterface, pmicAddress, NULL); - hal_i2c_write(wireInterface, rtcRegister, NULL); + hal_i2c_write(wireInterface, pmicRegister, NULL); hal_i2c_end_transmission(wireInterface, true, NULL); auto config = WireTransmission(pmicAddress).quantity(readLength).stop(true).halConfig(); hal_i2c_request_ex(wireInterface, &config, nullptr); @@ -199,7 +217,7 @@ test(I2C_05_long_read_pmic) longReadBuffer[i] = (uint8_t)hal_i2c_read(wireInterface, NULL); } - // Log.info("I2C_05_long_read_pmic result %ld\n", bytesAvailable); + // Log.info("I2C_04_long_read_pmic result %ld\n", bytesAvailable); // Log.dump(longReadBuffer, bytesAvailable); // Log.info(" \n"); From 7b44593209f14a2b78a9bfcb40a4adfbbaa268d9 Mon Sep 17 00:00:00 2001 From: Scott Brust Date: Mon, 24 Oct 2022 09:30:07 -0700 Subject: [PATCH 020/112] feedback --- user/tests/wiring/no_fixture_i2c/i2c.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/user/tests/wiring/no_fixture_i2c/i2c.cpp b/user/tests/wiring/no_fixture_i2c/i2c.cpp index 018c76f4bf..afd72c8615 100644 --- a/user/tests/wiring/no_fixture_i2c/i2c.cpp +++ b/user/tests/wiring/no_fixture_i2c/i2c.cpp @@ -131,9 +131,7 @@ test(I2C_02_test_acquire_wire1_buffer) { test(I2C_03_long_read_rtc) { // Test > 32 byte reads by reading from AM18x5 RTC peripheral - Wire1.begin(); - - // Read full register range + // Read beyond full register range const uint8_t REGISTER_RANGE = 64; uint8_t longReadBuffer[REGISTER_RANGE] = {}; uint8_t readLength = REGISTER_RANGE; @@ -148,6 +146,8 @@ test(I2C_03_long_read_rtc) uint8_t rtcAddress = HAL_PLATFORM_EXTERNAL_RTC_I2C_ADDR; uint8_t rtcRegister = 0x00; + hal_i2c_begin(wireInterface, I2C_MODE_MASTER, 0x00, NULL); + hal_i2c_lock(wireInterface, nullptr); SCOPE_GUARD({ hal_i2c_unlock(wireInterface, nullptr); From c5f79cdb9ec5ee6c0b661d1bdeea2f680a89e52c Mon Sep 17 00:00:00 2001 From: Sergey Polyakov Date: Thu, 15 Sep 2022 14:09:48 +0200 Subject: [PATCH 021/112] Upgrade to nanopb 0.4.5 --- hal/network/ncp/wifi/wifi_network_manager.cpp | 4 ++-- services/inc/file_util.h | 4 ++-- services/src/file_util.cpp | 8 ++++---- system/src/control/common.cpp | 17 +++++++++-------- system/src/control/common.h | 16 ++++++++-------- system/src/control/network.cpp | 6 +++--- system/src/control/storage.cpp | 4 ++-- system/src/control/wifi_new.cpp | 4 ++-- third_party/nanopb/nanopb | 2 +- 9 files changed, 33 insertions(+), 32 deletions(-) diff --git a/hal/network/ncp/wifi/wifi_network_manager.cpp b/hal/network/ncp/wifi/wifi_network_manager.cpp index 5f7df7b7cc..7d74f97c47 100644 --- a/hal/network/ncp/wifi/wifi_network_manager.cpp +++ b/hal/network/ncp/wifi/wifi_network_manager.cpp @@ -79,7 +79,7 @@ int loadConfig(Vector* networks) { // Parse configuration PB(WifiConfig) pbConf = {}; pbConf.networks.arg = networks; - pbConf.networks.funcs.decode = [](pb_istream_t* strm, const pb_field_t* field, void** arg) { + pbConf.networks.funcs.decode = [](pb_istream_t* strm, const pb_field_iter_t* field, void** arg) { const auto networks = (Vector*)*arg; PB(WifiConfig_Network) pbConf = {}; DecodedCString dSsid(&pbConf.ssid); @@ -133,7 +133,7 @@ int saveConfig(const Vector& networks) { // Serialize configuration PB(WifiConfig) pbConf = {}; pbConf.networks.arg = const_cast*>(&networks); - pbConf.networks.funcs.encode = [](pb_ostream_t* strm, const pb_field_t* field, void* const* arg) { + pbConf.networks.funcs.encode = [](pb_ostream_t* strm, const pb_field_iter_t* field, void* const* arg) { const auto networks = (const Vector*)*arg; for (const WifiNetworkConfig& conf: *networks) { PB(WifiConfig_Network) pbConf = {}; diff --git a/services/inc/file_util.h b/services/inc/file_util.h index 8e3100482f..2816c2e0a8 100644 --- a/services/inc/file_util.h +++ b/services/inc/file_util.h @@ -26,7 +26,7 @@ namespace particle { int openFile(lfs_file_t* file, const char* path, unsigned flags = LFS_O_RDWR); int dumpFile(const char* path); -int decodeMessageFromFile(lfs_file_t* file, const pb_field_t* fields, void* msg); -int encodeMessageToFile(lfs_file_t* file, const pb_field_t* fields, const void* msg); +int decodeMessageFromFile(lfs_file_t* file, const pb_msgdesc_t* desc, void* msg); +int encodeMessageToFile(lfs_file_t* file, const pb_msgdesc_t* desc, const void* msg); } // particle diff --git a/services/src/file_util.cpp b/services/src/file_util.cpp index 2fdb35b102..25a2a12644 100644 --- a/services/src/file_util.cpp +++ b/services/src/file_util.cpp @@ -125,25 +125,25 @@ int dumpFile(const char* path) { return 0; } -int decodeMessageFromFile(lfs_file_t* file, const pb_field_t* fields, void* msg) { +int decodeMessageFromFile(lfs_file_t* file, const pb_msgdesc_t* desc, void* msg) { const auto strm = pb_istream_init(nullptr); CHECK_TRUE(strm, SYSTEM_ERROR_NO_MEMORY); SCOPE_GUARD({ pb_istream_free(strm, nullptr); }); CHECK_TRUE(pb_istream_from_file(strm, file, nullptr), SYSTEM_ERROR_FILE); - CHECK_TRUE(pb_decode(strm, fields, msg), SYSTEM_ERROR_FILE); + CHECK_TRUE(pb_decode(strm, desc, msg), SYSTEM_ERROR_FILE); return 0; } -int encodeMessageToFile(lfs_file_t* file, const pb_field_t* fields, const void* msg) { +int encodeMessageToFile(lfs_file_t* file, const pb_msgdesc_t* desc, const void* msg) { const auto strm = pb_ostream_init(nullptr); CHECK_TRUE(strm, SYSTEM_ERROR_NO_MEMORY); SCOPE_GUARD({ pb_ostream_free(strm, nullptr); }); CHECK_TRUE(pb_ostream_from_file(strm, file, nullptr), SYSTEM_ERROR_FILE); - CHECK_TRUE(pb_encode(strm, fields, msg), SYSTEM_ERROR_FILE); + CHECK_TRUE(pb_encode(strm, desc, msg), SYSTEM_ERROR_FILE); return 0; } diff --git a/system/src/control/common.cpp b/system/src/control/common.cpp index beef80cb0b..3c8a7a4adb 100644 --- a/system/src/control/common.cpp +++ b/system/src/control/common.cpp @@ -34,9 +34,10 @@ namespace particle { namespace control { namespace common { -int appendReplySubmessage(ctrl_request* req, size_t offset, const pb_field_t* field, const pb_field_t* fields, const void* src) { +int appendReplySubmessage(ctrl_request* req, size_t offset, const pb_field_iter_t* field, const pb_msgdesc_t* desc, + const void* src) { size_t sz = 0; - CHECK_TRUE(pb_get_encoded_size(&sz, fields, src), SYSTEM_ERROR_UNKNOWN); + CHECK_TRUE(pb_get_encoded_size(&sz, desc, src), SYSTEM_ERROR_UNKNOWN); // Check whether the message fits into the current reply buffer // Worst case scenario, reserve 16 additional bytes @@ -62,20 +63,20 @@ int appendReplySubmessage(ctrl_request* req, size_t offset, const pb_field_t* fi // Encode tag CHECK_TRUE(pb_encode_tag_for_field(stream, field), SYSTEM_ERROR_UNKNOWN); // Encode submessage - CHECK_TRUE(pb_encode_submessage(stream, fields, src), SYSTEM_ERROR_UNKNOWN); + CHECK_TRUE(pb_encode_submessage(stream, desc, src), SYSTEM_ERROR_UNKNOWN); // Is this safe? const size_t written = stream->bytes_written; return written; } -int encodeReplyMessage(ctrl_request* req, const pb_field_t* fields, const void* src) { +int encodeReplyMessage(ctrl_request* req, const pb_msgdesc_t* desc, const void* src) { pb_ostream_t* stream = nullptr; size_t sz = 0; int ret = SYSTEM_ERROR_UNKNOWN; // Calculate size - bool res = pb_get_encoded_size(&sz, fields, src); + bool res = pb_get_encoded_size(&sz, desc, src); if (!res) { goto cleanup; } @@ -99,7 +100,7 @@ int encodeReplyMessage(ctrl_request* req, const pb_field_t* fields, const void* goto cleanup; } - res = pb_encode(stream, fields, src); + res = pb_encode(stream, desc, src); if (res) { ret = SYSTEM_ERROR_NONE; } @@ -114,7 +115,7 @@ int encodeReplyMessage(ctrl_request* req, const pb_field_t* fields, const void* return ret; } -int decodeRequestMessage(ctrl_request* req, const pb_field_t* fields, void* dst) { +int decodeRequestMessage(ctrl_request* req, const pb_msgdesc_t* desc, void* dst) { pb_istream_t* stream = nullptr; int ret = SYSTEM_ERROR_UNKNOWN; bool res = false; @@ -130,7 +131,7 @@ int decodeRequestMessage(ctrl_request* req, const pb_field_t* fields, void* dst) goto cleanup; } - res = pb_decode_noinit(stream, fields, dst); + res = pb_decode_noinit(stream, desc, dst); if (res) { ret = SYSTEM_ERROR_NONE; } else { diff --git a/system/src/control/common.h b/system/src/control/common.h index 88b031c5b2..72b78c5175 100644 --- a/system/src/control/common.h +++ b/system/src/control/common.h @@ -35,10 +35,10 @@ namespace particle { namespace control { namespace common { -int encodeReplyMessage(ctrl_request* req, const pb_field_t* fields, const void* src); -int decodeRequestMessage(ctrl_request* req, const pb_field_t* fields, void* dst); -int appendReplySubmessage(ctrl_request* req, size_t offset, const pb_field_t* field, - const pb_field_t* fields, const void* src); +int encodeReplyMessage(ctrl_request* req, const pb_msgdesc_t* desc, const void* src); +int decodeRequestMessage(ctrl_request* req, const pb_msgdesc_t* desc, void* dst); +int appendReplySubmessage(ctrl_request* req, size_t offset, const pb_field_iter_t* field, + const pb_msgdesc_t* desc, const void* src); int protoIpFromHal(particle_ctrl_IPAddress* ip, const HAL_IPAddress* sip); int halIpFromProto(particle_ctrl_IPAddress* ip, HAL_IPAddress* halip); @@ -49,7 +49,7 @@ struct ProtoDecodeBytesLengthHelper { : ptr_(ptr), size_(size) { cb->arg = this; - cb->funcs.decode = [](pb_istream_t* stream, const pb_field_t* field, void** arg) -> bool { + cb->funcs.decode = [](pb_istream_t* stream, const pb_field_iter_t* field, void** arg) -> bool { auto self = static_cast(*arg); self->fill(stream->state, stream->bytes_left); return pb_read(stream, nullptr, stream->bytes_left); @@ -74,7 +74,7 @@ struct EncodedString { data(data), size(size) { cb->arg = this; - cb->funcs.encode = [](pb_ostream_t* strm, const pb_field_t* field, void* const* arg) { + cb->funcs.encode = [](pb_ostream_t* strm, const pb_field_iter_t* field, void* const* arg) { const auto str = (const EncodedString*)*arg; if (str->data && str->size > 0 && (!pb_encode_tag_for_field(strm, field) || !pb_encode_string(strm, (const uint8_t*)str->data, str->size))) { @@ -94,7 +94,7 @@ struct DecodedString { data(nullptr), size(0) { cb->arg = this; - cb->funcs.decode = [](pb_istream_t* strm, const pb_field_t* field, void** arg) { + cb->funcs.decode = [](pb_istream_t* strm, const pb_field_iter_t* field, void** arg) { const size_t n = strm->bytes_left; if (n > 0) { const auto str = (DecodedString*)*arg; @@ -115,7 +115,7 @@ struct DecodedCString { data(nullptr), size(0) { cb->arg = this; - cb->funcs.decode = [](pb_istream_t* strm, const pb_field_t* field, void** arg) { + cb->funcs.decode = [](pb_istream_t* strm, const pb_field_iter_t* field, void** arg) { const size_t n = strm->bytes_left; const auto str = (DecodedCString*)*arg; str->data = (char*)malloc(n + 1); diff --git a/system/src/control/network.cpp b/system/src/control/network.cpp index 3ea3dd273e..fc96c81b31 100644 --- a/system/src/control/network.cpp +++ b/system/src/control/network.cpp @@ -90,7 +90,7 @@ int getInterfaceList(ctrl_request* req) { }); PB(GetInterfaceListReply) pbRep = {}; pbRep.interfaces.arg = ifList; - pbRep.interfaces.funcs.encode = [](pb_ostream_t* strm, const pb_field_t* field, void* const* arg) { + pbRep.interfaces.funcs.encode = [](pb_ostream_t* strm, const pb_field_iter_t* field, void* const* arg) { const auto ifList = (if_list*)*arg; for (if_list* i = ifList; i; i = i->next) { uint8_t index = 0; @@ -167,7 +167,7 @@ int getInterface(ctrl_request* req) { }); auto& pbIpv4Config = pbIface.ipv4_config; pbIpv4Config.addresses.arg = ifAddrList; - pbIpv4Config.addresses.funcs.encode = [](pb_ostream_t* strm, const pb_field_t* field, void* const* arg) { + pbIpv4Config.addresses.funcs.encode = [](pb_ostream_t* strm, const pb_field_iter_t* field, void* const* arg) { const auto ifAddrList = (if_addrs*)*arg; for (if_addrs* i = ifAddrList; i; i = i->next) { const auto ifAddr = i->if_addr; @@ -191,7 +191,7 @@ int getInterface(ctrl_request* req) { // IPv6 config auto& pbIpv6Config = pbIface.ipv6_config; pbIpv6Config.addresses.arg = ifAddrList; - pbIpv6Config.addresses.funcs.encode = [](pb_ostream_t* strm, const pb_field_t* field, void* const* arg) { + pbIpv6Config.addresses.funcs.encode = [](pb_ostream_t* strm, const pb_field_iter_t* field, void* const* arg) { const auto ifAddrList = (if_addrs*)*arg; for (if_addrs* i = ifAddrList; i; i = i->next) { const auto ifAddr = i->if_addr; diff --git a/system/src/control/storage.cpp b/system/src/control/storage.cpp index 3c7d1759e7..0fd7e83783 100644 --- a/system/src/control/storage.cpp +++ b/system/src/control/storage.cpp @@ -200,7 +200,7 @@ int getModuleInfo(ctrl_request* req) { }); PB(GetModuleInfoReply) pbRep = {}; pbRep.modules.arg = &info; - pbRep.modules.funcs.encode = [](pb_ostream_t* strm, const pb_field_t* field, void* const* arg) { + pbRep.modules.funcs.encode = [](pb_ostream_t* strm, const pb_field_iter_t* field, void* const* arg) { const auto info = (const hal_system_info_t*)*arg; for (size_t i = 0; i < info->module_count; ++i) { const hal_module_t& module = info->modules[i]; @@ -225,7 +225,7 @@ int getModuleInfo(ctrl_request* req) { } pbModule.validity = valid; pbModule.dependencies.arg = const_cast(&module.info); - pbModule.dependencies.funcs.encode = [](pb_ostream_t* strm, const pb_field_t* field, void* const* arg) { + pbModule.dependencies.funcs.encode = [](pb_ostream_t* strm, const pb_field_iter_t* field, void* const* arg) { const auto info = (const module_info_t*)*arg; for (unsigned i = 0; i < 2; ++i) { const module_dependency_t& dep = (i == 0) ? info->dependency : info->dependency2; diff --git a/system/src/control/wifi_new.cpp b/system/src/control/wifi_new.cpp index b55c5c5e21..fbbd2a2af8 100644 --- a/system/src/control/wifi_new.cpp +++ b/system/src/control/wifi_new.cpp @@ -190,7 +190,7 @@ int getKnownNetworks(ctrl_request* req) { // Encode a reply PB(GetKnownNetworksReply) pbRep = {}; pbRep.networks.arg = &networks; - pbRep.networks.funcs.encode = [](pb_ostream_t* strm, const pb_field_t* field, void* const* arg) { + pbRep.networks.funcs.encode = [](pb_ostream_t* strm, const pb_field_iter_t* field, void* const* arg) { const auto networks = (const Vector*)*arg; for (const WifiNetworkConfig& conf: *networks) { PB(GetKnownNetworksReply_Network) pbConf = {}; @@ -261,7 +261,7 @@ int scanNetworks(ctrl_request* req) { // Encode a reply PB(ScanNetworksReply) pbRep = {}; pbRep.networks.arg = &networks; - pbRep.networks.funcs.encode = [](pb_ostream_t* strm, const pb_field_t* field, void* const* arg) { + pbRep.networks.funcs.encode = [](pb_ostream_t* strm, const pb_field_iter_t* field, void* const* arg) { const auto networks = (const Vector*)*arg; for (const WifiScanResult& network: *networks) { PB(ScanNetworksReply_Network) pbNetwork = {}; diff --git a/third_party/nanopb/nanopb b/third_party/nanopb/nanopb index 6b91cc53df..4a4f79940f 160000 --- a/third_party/nanopb/nanopb +++ b/third_party/nanopb/nanopb @@ -1 +1 @@ -Subproject commit 6b91cc53dfb53ff5cd34bd2e057fbfc8ae7f12eb +Subproject commit 4a4f79940fa00aa0a1483a5ba3f5669c9087122e From 2b4a29065ab54470be40a4c2dfdc35eee3329711 Mon Sep 17 00:00:00 2001 From: Sergey Polyakov Date: Mon, 24 Oct 2022 15:52:45 +0400 Subject: [PATCH 022/112] Update submodule ref --- proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto b/proto index ce7a2fc964..0fa2944b52 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit ce7a2fc9643962994dd92a9cff5ae50db97447cc +Subproject commit 0fa2944b52b18d891ef3af2998bb5d0ad7ff2048 From 6689dec1ffd22bdc9f7ae38addc35d6efa7c40ae Mon Sep 17 00:00:00 2001 From: Sergey Polyakov Date: Mon, 24 Oct 2022 15:54:27 +0400 Subject: [PATCH 023/112] Ignore file timestamps when compiling protobuf files --- system/src/control/proto/build.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/system/src/control/proto/build.sh b/system/src/control/proto/build.sh index 48f68e111f..681ae19bf4 100755 --- a/system/src/control/proto/build.sh +++ b/system/src/control/proto/build.sh @@ -25,11 +25,7 @@ PROTOC_INCLUDE_PATH=" -I${NANOPB_PATH}/generator/proto" gen_proto() { - src_proto="$1" - dest_h=$(basename "$src_proto" .proto).pb.h - if [[ $src_proto -nt $DIR/$dest_h ]]; then - protoc ${PROTOC_INCLUDE_PATH} --plugin=protoc-gen-nanopb=${PROTOC_NANOPB_PLUGIN} --nanopb_out=${DIR} "$src_proto" - fi + protoc ${PROTOC_INCLUDE_PATH} --plugin=protoc-gen-nanopb=${PROTOC_NANOPB_PLUGIN} --nanopb_out=${DIR} "$1" } gen_proto "${PROTO_DIR}/extensions.proto" From 35c6a8f445963d62a440588e3696d22a9c99ede0 Mon Sep 17 00:00:00 2001 From: Sergey Polyakov Date: Mon, 24 Oct 2022 15:55:20 +0400 Subject: [PATCH 024/112] Regenerate protobuf files --- system/src/control/proto/cellular.pb.c | 115 +-- system/src/control/proto/cellular.pb.h | 249 +++-- system/src/control/proto/cloud.pb.c | 36 +- system/src/control/proto/cloud.pb.h | 127 ++- system/src/control/proto/common.pb.c | 51 +- system/src/control/proto/common.pb.h | 143 +-- system/src/control/proto/config.pb.c | 343 +++---- system/src/control/proto/config.pb.h | 874 +++++++++++------ system/src/control/proto/control.pb.c | 9 +- system/src/control/proto/control.pb.h | 10 +- system/src/control/proto/extensions.pb.c | 9 +- system/src/control/proto/extensions.pb.h | 14 +- system/src/control/proto/internal.pb.c | 54 +- system/src/control/proto/internal.pb.h | 97 +- system/src/control/proto/mesh.pb.c | 439 +++------ system/src/control/proto/mesh.pb.h | 1106 +++++++++++++++------- system/src/control/proto/network.pb.c | 201 ++-- system/src/control/proto/network.pb.h | 535 +++++++---- system/src/control/proto/storage.pb.c | 251 ++--- system/src/control/proto/storage.pb.h | 583 +++++++----- system/src/control/proto/wifi.pb.c | 151 +-- system/src/control/proto/wifi.pb.h | 362 ++++--- system/src/control/proto/wifi_new.pb.c | 170 +--- system/src/control/proto/wifi_new.pb.h | 371 +++++--- 24 files changed, 3485 insertions(+), 2815 deletions(-) diff --git a/system/src/control/proto/cellular.pb.c b/system/src/control/proto/cellular.pb.c index b09204b988..0e24702da1 100644 --- a/system/src/control/proto/cellular.pb.c +++ b/system/src/control/proto/cellular.pb.c @@ -1,94 +1,43 @@ /* Automatically generated nanopb constant definitions */ -/* Generated by nanopb-0.3.9 at Mon Jun 10 21:00:54 2019. */ +/* Generated by nanopb-0.4.5 */ #include "cellular.pb.h" - -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 +#if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif +PB_BIND(particle_ctrl_cellular_AccessPoint, particle_ctrl_cellular_AccessPoint, AUTO) -const pb_field_t particle_ctrl_cellular_AccessPoint_fields[5] = { - PB_FIELD( 1, STRING , SINGULAR, CALLBACK, FIRST, particle_ctrl_cellular_AccessPoint, apn, apn, 0), - PB_FIELD( 2, STRING , SINGULAR, CALLBACK, OTHER, particle_ctrl_cellular_AccessPoint, user, apn, 0), - PB_FIELD( 3, STRING , SINGULAR, CALLBACK, OTHER, particle_ctrl_cellular_AccessPoint, password, user, 0), - PB_FIELD( 4, BOOL , SINGULAR, STATIC , OTHER, particle_ctrl_cellular_AccessPoint, use_defaults, password, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_cellular_SetAccessPointRequest_fields[3] = { - PB_FIELD( 1, UENUM , SINGULAR, STATIC , FIRST, particle_ctrl_cellular_SetAccessPointRequest, sim_type, sim_type, 0), - PB_FIELD( 2, MESSAGE , SINGULAR, STATIC , OTHER, particle_ctrl_cellular_SetAccessPointRequest, access_point, sim_type, &particle_ctrl_cellular_AccessPoint_fields), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_cellular_SetAccessPointReply_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_cellular_GetAccessPointRequest_fields[2] = { - PB_FIELD( 1, UENUM , SINGULAR, STATIC , FIRST, particle_ctrl_cellular_GetAccessPointRequest, sim_type, sim_type, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_cellular_GetAccessPointReply_fields[2] = { - PB_FIELD( 1, MESSAGE , SINGULAR, STATIC , FIRST, particle_ctrl_cellular_GetAccessPointReply, access_point, access_point, &particle_ctrl_cellular_AccessPoint_fields), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_cellular_SetActiveSimRequest_fields[2] = { - PB_FIELD( 1, UENUM , SINGULAR, STATIC , FIRST, particle_ctrl_cellular_SetActiveSimRequest, sim_type, sim_type, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_cellular_SetActiveSimReply_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_cellular_GetActiveSimRequest_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_cellular_GetActiveSimReply_fields[2] = { - PB_FIELD( 1, UENUM , SINGULAR, STATIC , FIRST, particle_ctrl_cellular_GetActiveSimReply, sim_type, sim_type, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_cellular_GetIccidRequest_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_cellular_GetIccidReply_fields[2] = { - PB_FIELD( 1, STRING , SINGULAR, CALLBACK, FIRST, particle_ctrl_cellular_GetIccidReply, iccid, iccid, 0), - PB_LAST_FIELD -}; - - - -/* Check that field information fits in pb_field_t */ -#if !defined(PB_FIELD_32BIT) -/* If you get an error here, it means that you need to define PB_FIELD_32BIT - * compile-time option. You can do that in pb.h or on compiler command line. - * - * The reason you need to do this is that some of your messages contain tag - * numbers or field sizes that are larger than what can fit in 8 or 16 bit - * field descriptors. - */ -PB_STATIC_ASSERT((pb_membersize(particle_ctrl_cellular_SetAccessPointRequest, access_point) < 65536 && pb_membersize(particle_ctrl_cellular_GetAccessPointReply, access_point) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_particle_ctrl_cellular_AccessPoint_particle_ctrl_cellular_SetAccessPointRequest_particle_ctrl_cellular_SetAccessPointReply_particle_ctrl_cellular_GetAccessPointRequest_particle_ctrl_cellular_GetAccessPointReply_particle_ctrl_cellular_SetActiveSimRequest_particle_ctrl_cellular_SetActiveSimReply_particle_ctrl_cellular_GetActiveSimRequest_particle_ctrl_cellular_GetActiveSimReply_particle_ctrl_cellular_GetIccidRequest_particle_ctrl_cellular_GetIccidReply) -#endif +PB_BIND(particle_ctrl_cellular_SetAccessPointRequest, particle_ctrl_cellular_SetAccessPointRequest, AUTO) + + +PB_BIND(particle_ctrl_cellular_SetAccessPointReply, particle_ctrl_cellular_SetAccessPointReply, AUTO) + + +PB_BIND(particle_ctrl_cellular_GetAccessPointRequest, particle_ctrl_cellular_GetAccessPointRequest, AUTO) + + +PB_BIND(particle_ctrl_cellular_GetAccessPointReply, particle_ctrl_cellular_GetAccessPointReply, AUTO) + + +PB_BIND(particle_ctrl_cellular_SetActiveSimRequest, particle_ctrl_cellular_SetActiveSimRequest, AUTO) + + +PB_BIND(particle_ctrl_cellular_SetActiveSimReply, particle_ctrl_cellular_SetActiveSimReply, AUTO) + + +PB_BIND(particle_ctrl_cellular_GetActiveSimRequest, particle_ctrl_cellular_GetActiveSimRequest, AUTO) + + +PB_BIND(particle_ctrl_cellular_GetActiveSimReply, particle_ctrl_cellular_GetActiveSimReply, AUTO) + + +PB_BIND(particle_ctrl_cellular_GetIccidRequest, particle_ctrl_cellular_GetIccidRequest, AUTO) + + +PB_BIND(particle_ctrl_cellular_GetIccidReply, particle_ctrl_cellular_GetIccidReply, AUTO) + -#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT) -/* If you get an error here, it means that you need to define PB_FIELD_16BIT - * compile-time option. You can do that in pb.h or on compiler command line. - * - * The reason you need to do this is that some of your messages contain tag - * numbers or field sizes that are larger than what can fit in the default - * 8 bit descriptors. - */ -PB_STATIC_ASSERT((pb_membersize(particle_ctrl_cellular_SetAccessPointRequest, access_point) < 256 && pb_membersize(particle_ctrl_cellular_GetAccessPointReply, access_point) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_particle_ctrl_cellular_AccessPoint_particle_ctrl_cellular_SetAccessPointRequest_particle_ctrl_cellular_SetAccessPointReply_particle_ctrl_cellular_GetAccessPointRequest_particle_ctrl_cellular_GetAccessPointReply_particle_ctrl_cellular_SetActiveSimRequest_particle_ctrl_cellular_SetActiveSimReply_particle_ctrl_cellular_GetActiveSimRequest_particle_ctrl_cellular_GetActiveSimReply_particle_ctrl_cellular_GetIccidRequest_particle_ctrl_cellular_GetIccidReply) -#endif -/* @@protoc_insertion_point(eof) */ diff --git a/system/src/control/proto/cellular.pb.h b/system/src/control/proto/cellular.pb.h index ea4f6218b5..4a7389b18c 100644 --- a/system/src/control/proto/cellular.pb.h +++ b/system/src/control/proto/cellular.pb.h @@ -1,116 +1,126 @@ /* Automatically generated nanopb header */ -/* Generated by nanopb-0.3.9 at Mon Jun 10 21:00:54 2019. */ +/* Generated by nanopb-0.4.5 */ #ifndef PB_PARTICLE_CTRL_CELLULAR_CELLULAR_PB_H_INCLUDED #define PB_PARTICLE_CTRL_CELLULAR_CELLULAR_PB_H_INCLUDED #include - #include "extensions.pb.h" - #include "common.pb.h" -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 +#if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif -#ifdef __cplusplus -extern "C" { -#endif - /* Enum definitions */ -typedef enum _particle_ctrl_cellular_SimType { - particle_ctrl_cellular_SimType_INVALID_SIM_TYPE = 0, - particle_ctrl_cellular_SimType_INTERNAL = 1, - particle_ctrl_cellular_SimType_EXTERNAL = 2 +/* * + SIM card types. + + The Boron 2G/3G and Boron LTE can use either the built-in MFF2 embedded Particle SIM card or an external nano SIM card in the SIM card connector. + + Note: The values of this enum should match the values defined by the `SimType` enum in the firmware. */ +typedef enum _particle_ctrl_cellular_SimType { + particle_ctrl_cellular_SimType_INVALID_SIM_TYPE = 0, /* Invalid */ + particle_ctrl_cellular_SimType_INTERNAL = 1, /* Built-in MFF2 embedded Particle SIM */ + particle_ctrl_cellular_SimType_EXTERNAL = 2 /* External nano SIM card */ } particle_ctrl_cellular_SimType; -#define _particle_ctrl_cellular_SimType_MIN particle_ctrl_cellular_SimType_INVALID_SIM_TYPE -#define _particle_ctrl_cellular_SimType_MAX particle_ctrl_cellular_SimType_EXTERNAL -#define _particle_ctrl_cellular_SimType_ARRAYSIZE ((particle_ctrl_cellular_SimType)(particle_ctrl_cellular_SimType_EXTERNAL+1)) /* Struct definitions */ -typedef struct _particle_ctrl_cellular_GetActiveSimRequest { +/* * + Get active SIM card. */ +typedef struct _particle_ctrl_cellular_GetActiveSimRequest { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_cellular_GetActiveSimRequest) */ } particle_ctrl_cellular_GetActiveSimRequest; -typedef struct _particle_ctrl_cellular_GetIccidReply { - pb_callback_t iccid; -/* @@protoc_insertion_point(struct:particle_ctrl_cellular_GetIccidReply) */ +typedef struct _particle_ctrl_cellular_GetIccidReply { + pb_callback_t iccid; /* SIM ICCID */ } particle_ctrl_cellular_GetIccidReply; -typedef struct _particle_ctrl_cellular_GetIccidRequest { +/* * + Get ICCID. */ +typedef struct _particle_ctrl_cellular_GetIccidRequest { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_cellular_GetIccidRequest) */ } particle_ctrl_cellular_GetIccidRequest; -typedef struct _particle_ctrl_cellular_SetAccessPointReply { +typedef struct _particle_ctrl_cellular_SetAccessPointReply { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_cellular_SetAccessPointReply) */ } particle_ctrl_cellular_SetAccessPointReply; -typedef struct _particle_ctrl_cellular_SetActiveSimReply { +typedef struct _particle_ctrl_cellular_SetActiveSimReply { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_cellular_SetActiveSimReply) */ } particle_ctrl_cellular_SetActiveSimReply; -typedef struct _particle_ctrl_cellular_AccessPoint { - pb_callback_t apn; - pb_callback_t user; - pb_callback_t password; - bool use_defaults; -/* @@protoc_insertion_point(struct:particle_ctrl_cellular_AccessPoint) */ +/* * + Access point settings for 3rd party SIM credentials for the Cellular network. */ +typedef struct _particle_ctrl_cellular_AccessPoint { + pb_callback_t apn; /* APN */ + pb_callback_t user; /* Username */ + pb_callback_t password; /* Password */ + bool use_defaults; /* If `true`, it will restore the defaules */ } particle_ctrl_cellular_AccessPoint; -typedef struct _particle_ctrl_cellular_GetAccessPointRequest { - particle_ctrl_cellular_SimType sim_type; -/* @@protoc_insertion_point(struct:particle_ctrl_cellular_GetAccessPointRequest) */ +/* * + Get access point settings. */ +typedef struct _particle_ctrl_cellular_GetAccessPointRequest { + particle_ctrl_cellular_SimType sim_type; } particle_ctrl_cellular_GetAccessPointRequest; -typedef struct _particle_ctrl_cellular_GetActiveSimReply { - particle_ctrl_cellular_SimType sim_type; -/* @@protoc_insertion_point(struct:particle_ctrl_cellular_GetActiveSimReply) */ +typedef struct _particle_ctrl_cellular_GetActiveSimReply { + particle_ctrl_cellular_SimType sim_type; } particle_ctrl_cellular_GetActiveSimReply; -typedef struct _particle_ctrl_cellular_SetActiveSimRequest { - particle_ctrl_cellular_SimType sim_type; -/* @@protoc_insertion_point(struct:particle_ctrl_cellular_SetActiveSimRequest) */ +/* * + Set active SIM card. + + Note: The device needs to be reset in order for the settings to take effect. */ +typedef struct _particle_ctrl_cellular_SetActiveSimRequest { + particle_ctrl_cellular_SimType sim_type; } particle_ctrl_cellular_SetActiveSimRequest; -typedef struct _particle_ctrl_cellular_GetAccessPointReply { - particle_ctrl_cellular_AccessPoint access_point; -/* @@protoc_insertion_point(struct:particle_ctrl_cellular_GetAccessPointReply) */ +typedef struct _particle_ctrl_cellular_GetAccessPointReply { + bool has_access_point; + particle_ctrl_cellular_AccessPoint access_point; } particle_ctrl_cellular_GetAccessPointReply; -typedef struct _particle_ctrl_cellular_SetAccessPointRequest { - particle_ctrl_cellular_SimType sim_type; - particle_ctrl_cellular_AccessPoint access_point; -/* @@protoc_insertion_point(struct:particle_ctrl_cellular_SetAccessPointRequest) */ +/* * + Set access point settings. */ +typedef struct _particle_ctrl_cellular_SetAccessPointRequest { + particle_ctrl_cellular_SimType sim_type; + bool has_access_point; + particle_ctrl_cellular_AccessPoint access_point; } particle_ctrl_cellular_SetAccessPointRequest; -/* Default values for struct fields */ + +/* Helper constants for enums */ +#define _particle_ctrl_cellular_SimType_MIN particle_ctrl_cellular_SimType_INVALID_SIM_TYPE +#define _particle_ctrl_cellular_SimType_MAX particle_ctrl_cellular_SimType_EXTERNAL +#define _particle_ctrl_cellular_SimType_ARRAYSIZE ((particle_ctrl_cellular_SimType)(particle_ctrl_cellular_SimType_EXTERNAL+1)) + + +#ifdef __cplusplus +extern "C" { +#endif /* Initializer values for message structs */ #define particle_ctrl_cellular_AccessPoint_init_default {{{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, 0} -#define particle_ctrl_cellular_SetAccessPointRequest_init_default {(particle_ctrl_cellular_SimType)0, particle_ctrl_cellular_AccessPoint_init_default} +#define particle_ctrl_cellular_SetAccessPointRequest_init_default {_particle_ctrl_cellular_SimType_MIN, false, particle_ctrl_cellular_AccessPoint_init_default} #define particle_ctrl_cellular_SetAccessPointReply_init_default {0} -#define particle_ctrl_cellular_GetAccessPointRequest_init_default {(particle_ctrl_cellular_SimType)0} -#define particle_ctrl_cellular_GetAccessPointReply_init_default {particle_ctrl_cellular_AccessPoint_init_default} -#define particle_ctrl_cellular_SetActiveSimRequest_init_default {(particle_ctrl_cellular_SimType)0} +#define particle_ctrl_cellular_GetAccessPointRequest_init_default {_particle_ctrl_cellular_SimType_MIN} +#define particle_ctrl_cellular_GetAccessPointReply_init_default {false, particle_ctrl_cellular_AccessPoint_init_default} +#define particle_ctrl_cellular_SetActiveSimRequest_init_default {_particle_ctrl_cellular_SimType_MIN} #define particle_ctrl_cellular_SetActiveSimReply_init_default {0} #define particle_ctrl_cellular_GetActiveSimRequest_init_default {0} -#define particle_ctrl_cellular_GetActiveSimReply_init_default {(particle_ctrl_cellular_SimType)0} +#define particle_ctrl_cellular_GetActiveSimReply_init_default {_particle_ctrl_cellular_SimType_MIN} #define particle_ctrl_cellular_GetIccidRequest_init_default {0} #define particle_ctrl_cellular_GetIccidReply_init_default {{{NULL}, NULL}} #define particle_ctrl_cellular_AccessPoint_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, 0} -#define particle_ctrl_cellular_SetAccessPointRequest_init_zero {(particle_ctrl_cellular_SimType)0, particle_ctrl_cellular_AccessPoint_init_zero} +#define particle_ctrl_cellular_SetAccessPointRequest_init_zero {_particle_ctrl_cellular_SimType_MIN, false, particle_ctrl_cellular_AccessPoint_init_zero} #define particle_ctrl_cellular_SetAccessPointReply_init_zero {0} -#define particle_ctrl_cellular_GetAccessPointRequest_init_zero {(particle_ctrl_cellular_SimType)0} -#define particle_ctrl_cellular_GetAccessPointReply_init_zero {particle_ctrl_cellular_AccessPoint_init_zero} -#define particle_ctrl_cellular_SetActiveSimRequest_init_zero {(particle_ctrl_cellular_SimType)0} +#define particle_ctrl_cellular_GetAccessPointRequest_init_zero {_particle_ctrl_cellular_SimType_MIN} +#define particle_ctrl_cellular_GetAccessPointReply_init_zero {false, particle_ctrl_cellular_AccessPoint_init_zero} +#define particle_ctrl_cellular_SetActiveSimRequest_init_zero {_particle_ctrl_cellular_SimType_MIN} #define particle_ctrl_cellular_SetActiveSimReply_init_zero {0} #define particle_ctrl_cellular_GetActiveSimRequest_init_zero {0} -#define particle_ctrl_cellular_GetActiveSimReply_init_zero {(particle_ctrl_cellular_SimType)0} +#define particle_ctrl_cellular_GetActiveSimReply_init_zero {_particle_ctrl_cellular_SimType_MIN} #define particle_ctrl_cellular_GetIccidRequest_init_zero {0} #define particle_ctrl_cellular_GetIccidReply_init_zero {{{NULL}, NULL}} @@ -128,42 +138,107 @@ typedef struct _particle_ctrl_cellular_SetAccessPointRequest { #define particle_ctrl_cellular_SetAccessPointRequest_access_point_tag 2 /* Struct field encoding specification for nanopb */ -extern const pb_field_t particle_ctrl_cellular_AccessPoint_fields[5]; -extern const pb_field_t particle_ctrl_cellular_SetAccessPointRequest_fields[3]; -extern const pb_field_t particle_ctrl_cellular_SetAccessPointReply_fields[1]; -extern const pb_field_t particle_ctrl_cellular_GetAccessPointRequest_fields[2]; -extern const pb_field_t particle_ctrl_cellular_GetAccessPointReply_fields[2]; -extern const pb_field_t particle_ctrl_cellular_SetActiveSimRequest_fields[2]; -extern const pb_field_t particle_ctrl_cellular_SetActiveSimReply_fields[1]; -extern const pb_field_t particle_ctrl_cellular_GetActiveSimRequest_fields[1]; -extern const pb_field_t particle_ctrl_cellular_GetActiveSimReply_fields[2]; -extern const pb_field_t particle_ctrl_cellular_GetIccidRequest_fields[1]; -extern const pb_field_t particle_ctrl_cellular_GetIccidReply_fields[2]; +#define particle_ctrl_cellular_AccessPoint_FIELDLIST(X, a) \ +X(a, CALLBACK, SINGULAR, STRING, apn, 1) \ +X(a, CALLBACK, SINGULAR, STRING, user, 2) \ +X(a, CALLBACK, SINGULAR, STRING, password, 3) \ +X(a, STATIC, SINGULAR, BOOL, use_defaults, 4) +#define particle_ctrl_cellular_AccessPoint_CALLBACK pb_default_field_callback +#define particle_ctrl_cellular_AccessPoint_DEFAULT NULL + +#define particle_ctrl_cellular_SetAccessPointRequest_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, sim_type, 1) \ +X(a, STATIC, OPTIONAL, MESSAGE, access_point, 2) +#define particle_ctrl_cellular_SetAccessPointRequest_CALLBACK NULL +#define particle_ctrl_cellular_SetAccessPointRequest_DEFAULT NULL +#define particle_ctrl_cellular_SetAccessPointRequest_access_point_MSGTYPE particle_ctrl_cellular_AccessPoint + +#define particle_ctrl_cellular_SetAccessPointReply_FIELDLIST(X, a) \ + +#define particle_ctrl_cellular_SetAccessPointReply_CALLBACK NULL +#define particle_ctrl_cellular_SetAccessPointReply_DEFAULT NULL + +#define particle_ctrl_cellular_GetAccessPointRequest_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, sim_type, 1) +#define particle_ctrl_cellular_GetAccessPointRequest_CALLBACK NULL +#define particle_ctrl_cellular_GetAccessPointRequest_DEFAULT NULL + +#define particle_ctrl_cellular_GetAccessPointReply_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, MESSAGE, access_point, 1) +#define particle_ctrl_cellular_GetAccessPointReply_CALLBACK NULL +#define particle_ctrl_cellular_GetAccessPointReply_DEFAULT NULL +#define particle_ctrl_cellular_GetAccessPointReply_access_point_MSGTYPE particle_ctrl_cellular_AccessPoint + +#define particle_ctrl_cellular_SetActiveSimRequest_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, sim_type, 1) +#define particle_ctrl_cellular_SetActiveSimRequest_CALLBACK NULL +#define particle_ctrl_cellular_SetActiveSimRequest_DEFAULT NULL + +#define particle_ctrl_cellular_SetActiveSimReply_FIELDLIST(X, a) \ + +#define particle_ctrl_cellular_SetActiveSimReply_CALLBACK NULL +#define particle_ctrl_cellular_SetActiveSimReply_DEFAULT NULL + +#define particle_ctrl_cellular_GetActiveSimRequest_FIELDLIST(X, a) \ + +#define particle_ctrl_cellular_GetActiveSimRequest_CALLBACK NULL +#define particle_ctrl_cellular_GetActiveSimRequest_DEFAULT NULL + +#define particle_ctrl_cellular_GetActiveSimReply_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, sim_type, 1) +#define particle_ctrl_cellular_GetActiveSimReply_CALLBACK NULL +#define particle_ctrl_cellular_GetActiveSimReply_DEFAULT NULL + +#define particle_ctrl_cellular_GetIccidRequest_FIELDLIST(X, a) \ + +#define particle_ctrl_cellular_GetIccidRequest_CALLBACK NULL +#define particle_ctrl_cellular_GetIccidRequest_DEFAULT NULL + +#define particle_ctrl_cellular_GetIccidReply_FIELDLIST(X, a) \ +X(a, CALLBACK, SINGULAR, STRING, iccid, 1) +#define particle_ctrl_cellular_GetIccidReply_CALLBACK pb_default_field_callback +#define particle_ctrl_cellular_GetIccidReply_DEFAULT NULL + +extern const pb_msgdesc_t particle_ctrl_cellular_AccessPoint_msg; +extern const pb_msgdesc_t particle_ctrl_cellular_SetAccessPointRequest_msg; +extern const pb_msgdesc_t particle_ctrl_cellular_SetAccessPointReply_msg; +extern const pb_msgdesc_t particle_ctrl_cellular_GetAccessPointRequest_msg; +extern const pb_msgdesc_t particle_ctrl_cellular_GetAccessPointReply_msg; +extern const pb_msgdesc_t particle_ctrl_cellular_SetActiveSimRequest_msg; +extern const pb_msgdesc_t particle_ctrl_cellular_SetActiveSimReply_msg; +extern const pb_msgdesc_t particle_ctrl_cellular_GetActiveSimRequest_msg; +extern const pb_msgdesc_t particle_ctrl_cellular_GetActiveSimReply_msg; +extern const pb_msgdesc_t particle_ctrl_cellular_GetIccidRequest_msg; +extern const pb_msgdesc_t particle_ctrl_cellular_GetIccidReply_msg; + +/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ +#define particle_ctrl_cellular_AccessPoint_fields &particle_ctrl_cellular_AccessPoint_msg +#define particle_ctrl_cellular_SetAccessPointRequest_fields &particle_ctrl_cellular_SetAccessPointRequest_msg +#define particle_ctrl_cellular_SetAccessPointReply_fields &particle_ctrl_cellular_SetAccessPointReply_msg +#define particle_ctrl_cellular_GetAccessPointRequest_fields &particle_ctrl_cellular_GetAccessPointRequest_msg +#define particle_ctrl_cellular_GetAccessPointReply_fields &particle_ctrl_cellular_GetAccessPointReply_msg +#define particle_ctrl_cellular_SetActiveSimRequest_fields &particle_ctrl_cellular_SetActiveSimRequest_msg +#define particle_ctrl_cellular_SetActiveSimReply_fields &particle_ctrl_cellular_SetActiveSimReply_msg +#define particle_ctrl_cellular_GetActiveSimRequest_fields &particle_ctrl_cellular_GetActiveSimRequest_msg +#define particle_ctrl_cellular_GetActiveSimReply_fields &particle_ctrl_cellular_GetActiveSimReply_msg +#define particle_ctrl_cellular_GetIccidRequest_fields &particle_ctrl_cellular_GetIccidRequest_msg +#define particle_ctrl_cellular_GetIccidReply_fields &particle_ctrl_cellular_GetIccidReply_msg /* Maximum encoded size of messages (where known) */ /* particle_ctrl_cellular_AccessPoint_size depends on runtime parameters */ -#define particle_ctrl_cellular_SetAccessPointRequest_size (8 + particle_ctrl_cellular_AccessPoint_size) -#define particle_ctrl_cellular_SetAccessPointReply_size 0 +/* particle_ctrl_cellular_SetAccessPointRequest_size depends on runtime parameters */ +/* particle_ctrl_cellular_GetAccessPointReply_size depends on runtime parameters */ +/* particle_ctrl_cellular_GetIccidReply_size depends on runtime parameters */ #define particle_ctrl_cellular_GetAccessPointRequest_size 2 -#define particle_ctrl_cellular_GetAccessPointReply_size (6 + particle_ctrl_cellular_AccessPoint_size) -#define particle_ctrl_cellular_SetActiveSimRequest_size 2 -#define particle_ctrl_cellular_SetActiveSimReply_size 0 -#define particle_ctrl_cellular_GetActiveSimRequest_size 0 #define particle_ctrl_cellular_GetActiveSimReply_size 2 +#define particle_ctrl_cellular_GetActiveSimRequest_size 0 #define particle_ctrl_cellular_GetIccidRequest_size 0 -/* particle_ctrl_cellular_GetIccidReply_size depends on runtime parameters */ - -/* Message IDs (where set with "msgid" option) */ -#ifdef PB_MSGID - -#define CELLULAR_MESSAGES \ - - -#endif +#define particle_ctrl_cellular_SetAccessPointReply_size 0 +#define particle_ctrl_cellular_SetActiveSimReply_size 0 +#define particle_ctrl_cellular_SetActiveSimRequest_size 2 #ifdef __cplusplus } /* extern "C" */ #endif -/* @@protoc_insertion_point(eof) */ #endif diff --git a/system/src/control/proto/cloud.pb.c b/system/src/control/proto/cloud.pb.c index bb37386fe9..c398b532a3 100644 --- a/system/src/control/proto/cloud.pb.c +++ b/system/src/control/proto/cloud.pb.c @@ -1,40 +1,28 @@ /* Automatically generated nanopb constant definitions */ -/* Generated by nanopb-0.3.9 at Mon Jun 10 21:00:55 2019. */ +/* Generated by nanopb-0.4.5 */ #include "cloud.pb.h" - -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 +#if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif +PB_BIND(particle_ctrl_cloud_GetConnectionStatusRequest, particle_ctrl_cloud_GetConnectionStatusRequest, AUTO) + + +PB_BIND(particle_ctrl_cloud_GetConnectionStatusReply, particle_ctrl_cloud_GetConnectionStatusReply, AUTO) + + +PB_BIND(particle_ctrl_cloud_ConnectRequest, particle_ctrl_cloud_ConnectRequest, AUTO) -const pb_field_t particle_ctrl_cloud_GetConnectionStatusRequest_fields[1] = { - PB_LAST_FIELD -}; +PB_BIND(particle_ctrl_cloud_ConnectReply, particle_ctrl_cloud_ConnectReply, AUTO) -const pb_field_t particle_ctrl_cloud_GetConnectionStatusReply_fields[2] = { - PB_FIELD( 1, UENUM , SINGULAR, STATIC , FIRST, particle_ctrl_cloud_GetConnectionStatusReply, status, status, 0), - PB_LAST_FIELD -}; -const pb_field_t particle_ctrl_cloud_ConnectRequest_fields[1] = { - PB_LAST_FIELD -}; +PB_BIND(particle_ctrl_cloud_DisconnectRequest, particle_ctrl_cloud_DisconnectRequest, AUTO) -const pb_field_t particle_ctrl_cloud_ConnectReply_fields[1] = { - PB_LAST_FIELD -}; -const pb_field_t particle_ctrl_cloud_DisconnectRequest_fields[1] = { - PB_LAST_FIELD -}; +PB_BIND(particle_ctrl_cloud_DisconnectReply, particle_ctrl_cloud_DisconnectReply, AUTO) -const pb_field_t particle_ctrl_cloud_DisconnectReply_fields[1] = { - PB_LAST_FIELD -}; -/* @@protoc_insertion_point(eof) */ diff --git a/system/src/control/proto/cloud.pb.h b/system/src/control/proto/cloud.pb.h index e0a54ad726..aff2435af2 100644 --- a/system/src/control/proto/cloud.pb.h +++ b/system/src/control/proto/cloud.pb.h @@ -1,74 +1,72 @@ /* Automatically generated nanopb header */ -/* Generated by nanopb-0.3.9 at Mon Jun 10 21:00:55 2019. */ +/* Generated by nanopb-0.4.5 */ #ifndef PB_PARTICLE_CTRL_CLOUD_CLOUD_PB_H_INCLUDED #define PB_PARTICLE_CTRL_CLOUD_CLOUD_PB_H_INCLUDED #include - #include "extensions.pb.h" -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 +#if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif -#ifdef __cplusplus -extern "C" { -#endif - /* Enum definitions */ -typedef enum _particle_ctrl_cloud_ConnectionStatus { - particle_ctrl_cloud_ConnectionStatus_DISCONNECTED = 0, - particle_ctrl_cloud_ConnectionStatus_CONNECTING = 1, - particle_ctrl_cloud_ConnectionStatus_CONNECTED = 2, - particle_ctrl_cloud_ConnectionStatus_DISCONNECTING = 3 +/* Make sure values of this enum match the values defined for the diagnostic info */ +typedef enum _particle_ctrl_cloud_ConnectionStatus { + particle_ctrl_cloud_ConnectionStatus_DISCONNECTED = 0, + particle_ctrl_cloud_ConnectionStatus_CONNECTING = 1, + particle_ctrl_cloud_ConnectionStatus_CONNECTED = 2, + particle_ctrl_cloud_ConnectionStatus_DISCONNECTING = 3 } particle_ctrl_cloud_ConnectionStatus; -#define _particle_ctrl_cloud_ConnectionStatus_MIN particle_ctrl_cloud_ConnectionStatus_DISCONNECTED -#define _particle_ctrl_cloud_ConnectionStatus_MAX particle_ctrl_cloud_ConnectionStatus_DISCONNECTING -#define _particle_ctrl_cloud_ConnectionStatus_ARRAYSIZE ((particle_ctrl_cloud_ConnectionStatus)(particle_ctrl_cloud_ConnectionStatus_DISCONNECTING+1)) /* Struct definitions */ -typedef struct _particle_ctrl_cloud_ConnectReply { +typedef struct _particle_ctrl_cloud_ConnectReply { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_cloud_ConnectReply) */ } particle_ctrl_cloud_ConnectReply; -typedef struct _particle_ctrl_cloud_ConnectRequest { +/* Connect to the cloud */ +typedef struct _particle_ctrl_cloud_ConnectRequest { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_cloud_ConnectRequest) */ } particle_ctrl_cloud_ConnectRequest; -typedef struct _particle_ctrl_cloud_DisconnectReply { +typedef struct _particle_ctrl_cloud_DisconnectReply { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_cloud_DisconnectReply) */ } particle_ctrl_cloud_DisconnectReply; -typedef struct _particle_ctrl_cloud_DisconnectRequest { +/* Disconnect from the cloud */ +typedef struct _particle_ctrl_cloud_DisconnectRequest { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_cloud_DisconnectRequest) */ } particle_ctrl_cloud_DisconnectRequest; -typedef struct _particle_ctrl_cloud_GetConnectionStatusRequest { +/* Get the cloud connection status */ +typedef struct _particle_ctrl_cloud_GetConnectionStatusRequest { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_cloud_GetConnectionStatusRequest) */ } particle_ctrl_cloud_GetConnectionStatusRequest; -typedef struct _particle_ctrl_cloud_GetConnectionStatusReply { - particle_ctrl_cloud_ConnectionStatus status; -/* @@protoc_insertion_point(struct:particle_ctrl_cloud_GetConnectionStatusReply) */ +typedef struct _particle_ctrl_cloud_GetConnectionStatusReply { + particle_ctrl_cloud_ConnectionStatus status; } particle_ctrl_cloud_GetConnectionStatusReply; -/* Default values for struct fields */ + +/* Helper constants for enums */ +#define _particle_ctrl_cloud_ConnectionStatus_MIN particle_ctrl_cloud_ConnectionStatus_DISCONNECTED +#define _particle_ctrl_cloud_ConnectionStatus_MAX particle_ctrl_cloud_ConnectionStatus_DISCONNECTING +#define _particle_ctrl_cloud_ConnectionStatus_ARRAYSIZE ((particle_ctrl_cloud_ConnectionStatus)(particle_ctrl_cloud_ConnectionStatus_DISCONNECTING+1)) + + +#ifdef __cplusplus +extern "C" { +#endif /* Initializer values for message structs */ #define particle_ctrl_cloud_GetConnectionStatusRequest_init_default {0} -#define particle_ctrl_cloud_GetConnectionStatusReply_init_default {(particle_ctrl_cloud_ConnectionStatus)0} +#define particle_ctrl_cloud_GetConnectionStatusReply_init_default {_particle_ctrl_cloud_ConnectionStatus_MIN} #define particle_ctrl_cloud_ConnectRequest_init_default {0} #define particle_ctrl_cloud_ConnectReply_init_default {0} #define particle_ctrl_cloud_DisconnectRequest_init_default {0} #define particle_ctrl_cloud_DisconnectReply_init_default {0} #define particle_ctrl_cloud_GetConnectionStatusRequest_init_zero {0} -#define particle_ctrl_cloud_GetConnectionStatusReply_init_zero {(particle_ctrl_cloud_ConnectionStatus)0} +#define particle_ctrl_cloud_GetConnectionStatusReply_init_zero {_particle_ctrl_cloud_ConnectionStatus_MIN} #define particle_ctrl_cloud_ConnectRequest_init_zero {0} #define particle_ctrl_cloud_ConnectReply_init_zero {0} #define particle_ctrl_cloud_DisconnectRequest_init_zero {0} @@ -78,32 +76,61 @@ typedef struct _particle_ctrl_cloud_GetConnectionStatusReply { #define particle_ctrl_cloud_GetConnectionStatusReply_status_tag 1 /* Struct field encoding specification for nanopb */ -extern const pb_field_t particle_ctrl_cloud_GetConnectionStatusRequest_fields[1]; -extern const pb_field_t particle_ctrl_cloud_GetConnectionStatusReply_fields[2]; -extern const pb_field_t particle_ctrl_cloud_ConnectRequest_fields[1]; -extern const pb_field_t particle_ctrl_cloud_ConnectReply_fields[1]; -extern const pb_field_t particle_ctrl_cloud_DisconnectRequest_fields[1]; -extern const pb_field_t particle_ctrl_cloud_DisconnectReply_fields[1]; +#define particle_ctrl_cloud_GetConnectionStatusRequest_FIELDLIST(X, a) \ -/* Maximum encoded size of messages (where known) */ -#define particle_ctrl_cloud_GetConnectionStatusRequest_size 0 -#define particle_ctrl_cloud_GetConnectionStatusReply_size 2 -#define particle_ctrl_cloud_ConnectRequest_size 0 -#define particle_ctrl_cloud_ConnectReply_size 0 -#define particle_ctrl_cloud_DisconnectRequest_size 0 -#define particle_ctrl_cloud_DisconnectReply_size 0 +#define particle_ctrl_cloud_GetConnectionStatusRequest_CALLBACK NULL +#define particle_ctrl_cloud_GetConnectionStatusRequest_DEFAULT NULL -/* Message IDs (where set with "msgid" option) */ -#ifdef PB_MSGID +#define particle_ctrl_cloud_GetConnectionStatusReply_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, status, 1) +#define particle_ctrl_cloud_GetConnectionStatusReply_CALLBACK NULL +#define particle_ctrl_cloud_GetConnectionStatusReply_DEFAULT NULL -#define CLOUD_MESSAGES \ +#define particle_ctrl_cloud_ConnectRequest_FIELDLIST(X, a) \ +#define particle_ctrl_cloud_ConnectRequest_CALLBACK NULL +#define particle_ctrl_cloud_ConnectRequest_DEFAULT NULL -#endif +#define particle_ctrl_cloud_ConnectReply_FIELDLIST(X, a) \ + +#define particle_ctrl_cloud_ConnectReply_CALLBACK NULL +#define particle_ctrl_cloud_ConnectReply_DEFAULT NULL + +#define particle_ctrl_cloud_DisconnectRequest_FIELDLIST(X, a) \ + +#define particle_ctrl_cloud_DisconnectRequest_CALLBACK NULL +#define particle_ctrl_cloud_DisconnectRequest_DEFAULT NULL + +#define particle_ctrl_cloud_DisconnectReply_FIELDLIST(X, a) \ + +#define particle_ctrl_cloud_DisconnectReply_CALLBACK NULL +#define particle_ctrl_cloud_DisconnectReply_DEFAULT NULL + +extern const pb_msgdesc_t particle_ctrl_cloud_GetConnectionStatusRequest_msg; +extern const pb_msgdesc_t particle_ctrl_cloud_GetConnectionStatusReply_msg; +extern const pb_msgdesc_t particle_ctrl_cloud_ConnectRequest_msg; +extern const pb_msgdesc_t particle_ctrl_cloud_ConnectReply_msg; +extern const pb_msgdesc_t particle_ctrl_cloud_DisconnectRequest_msg; +extern const pb_msgdesc_t particle_ctrl_cloud_DisconnectReply_msg; + +/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ +#define particle_ctrl_cloud_GetConnectionStatusRequest_fields &particle_ctrl_cloud_GetConnectionStatusRequest_msg +#define particle_ctrl_cloud_GetConnectionStatusReply_fields &particle_ctrl_cloud_GetConnectionStatusReply_msg +#define particle_ctrl_cloud_ConnectRequest_fields &particle_ctrl_cloud_ConnectRequest_msg +#define particle_ctrl_cloud_ConnectReply_fields &particle_ctrl_cloud_ConnectReply_msg +#define particle_ctrl_cloud_DisconnectRequest_fields &particle_ctrl_cloud_DisconnectRequest_msg +#define particle_ctrl_cloud_DisconnectReply_fields &particle_ctrl_cloud_DisconnectReply_msg + +/* Maximum encoded size of messages (where known) */ +#define particle_ctrl_cloud_ConnectReply_size 0 +#define particle_ctrl_cloud_ConnectRequest_size 0 +#define particle_ctrl_cloud_DisconnectReply_size 0 +#define particle_ctrl_cloud_DisconnectRequest_size 0 +#define particle_ctrl_cloud_GetConnectionStatusReply_size 2 +#define particle_ctrl_cloud_GetConnectionStatusRequest_size 0 #ifdef __cplusplus } /* extern "C" */ #endif -/* @@protoc_insertion_point(eof) */ #endif diff --git a/system/src/control/proto/common.pb.c b/system/src/control/proto/common.pb.c index 42de49e306..46ed78907d 100644 --- a/system/src/control/proto/common.pb.c +++ b/system/src/control/proto/common.pb.c @@ -1,62 +1,23 @@ /* Automatically generated nanopb constant definitions */ -/* Generated by nanopb-0.3.9 at Tue Jan 29 21:26:45 2019. */ +/* Generated by nanopb-0.4.5 */ #include "common.pb.h" - -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 +#if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif +PB_BIND(particle_ctrl_Ipv4Address, particle_ctrl_Ipv4Address, AUTO) -const pb_field_t particle_ctrl_Ipv4Address_fields[2] = { - PB_FIELD( 1, FIXED32 , SINGULAR, STATIC , FIRST, particle_ctrl_Ipv4Address, address, address, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_Ipv6Address_fields[2] = { - PB_FIELD( 1, FIXED_LENGTH_BYTES, SINGULAR, STATIC , FIRST, particle_ctrl_Ipv6Address, address, address, 0), - PB_LAST_FIELD -}; +PB_BIND(particle_ctrl_Ipv6Address, particle_ctrl_Ipv6Address, AUTO) -const pb_field_t particle_ctrl_IpAddress_fields[3] = { - PB_ONEOF_FIELD(address, 1, MESSAGE , ONEOF, STATIC , FIRST, particle_ctrl_IpAddress, v4, v4, &particle_ctrl_Ipv4Address_fields), - PB_ONEOF_FIELD(address, 2, MESSAGE , ONEOF, STATIC , UNION, particle_ctrl_IpAddress, v6, v6, &particle_ctrl_Ipv6Address_fields), - PB_LAST_FIELD -}; -const pb_field_t particle_ctrl_IPAddress_fields[3] = { - PB_FIELD( 1, UENUM , SINGULAR, STATIC , FIRST, particle_ctrl_IPAddress, protocol, protocol, 0), - PB_FIELD( 2, BYTES , SINGULAR, STATIC , OTHER, particle_ctrl_IPAddress, address, protocol, 0), - PB_LAST_FIELD -}; +PB_BIND(particle_ctrl_IpAddress, particle_ctrl_IpAddress, AUTO) +PB_BIND(particle_ctrl_IPAddress, particle_ctrl_IPAddress, AUTO) -/* Check that field information fits in pb_field_t */ -#if !defined(PB_FIELD_32BIT) -/* If you get an error here, it means that you need to define PB_FIELD_32BIT - * compile-time option. You can do that in pb.h or on compiler command line. - * - * The reason you need to do this is that some of your messages contain tag - * numbers or field sizes that are larger than what can fit in 8 or 16 bit - * field descriptors. - */ -PB_STATIC_ASSERT((pb_membersize(particle_ctrl_IpAddress, address.v4) < 65536 && pb_membersize(particle_ctrl_IpAddress, address.v6) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_particle_ctrl_Ipv4Address_particle_ctrl_Ipv6Address_particle_ctrl_IpAddress_particle_ctrl_IPAddress) -#endif -#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT) -/* If you get an error here, it means that you need to define PB_FIELD_16BIT - * compile-time option. You can do that in pb.h or on compiler command line. - * - * The reason you need to do this is that some of your messages contain tag - * numbers or field sizes that are larger than what can fit in the default - * 8 bit descriptors. - */ -PB_STATIC_ASSERT((pb_membersize(particle_ctrl_IpAddress, address.v4) < 256 && pb_membersize(particle_ctrl_IpAddress, address.v6) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_particle_ctrl_Ipv4Address_particle_ctrl_Ipv6Address_particle_ctrl_IpAddress_particle_ctrl_IPAddress) -#endif -/* @@protoc_insertion_point(eof) */ diff --git a/system/src/control/proto/common.pb.h b/system/src/control/proto/common.pb.h index 7d3ddf613e..e7683877c2 100644 --- a/system/src/control/proto/common.pb.h +++ b/system/src/control/proto/common.pb.h @@ -1,83 +1,89 @@ /* Automatically generated nanopb header */ -/* Generated by nanopb-0.3.9 at Tue Jan 29 21:26:45 2019. */ +/* Generated by nanopb-0.4.5 */ #ifndef PB_PARTICLE_CTRL_COMMON_PB_H_INCLUDED #define PB_PARTICLE_CTRL_COMMON_PB_H_INCLUDED #include - #include "extensions.pb.h" -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 +#if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif -#ifdef __cplusplus -extern "C" { -#endif - /* Enum definitions */ -typedef enum _particle_ctrl_ResultCode { - particle_ctrl_ResultCode_OK = 0, - particle_ctrl_ResultCode_NOT_ALLOWED = 1, - particle_ctrl_ResultCode_TIMEOUT = 2, - particle_ctrl_ResultCode_NOT_FOUND = 3, - particle_ctrl_ResultCode_ALREADY_EXIST = 4, - particle_ctrl_ResultCode_INVALID_STATE = 5, - particle_ctrl_ResultCode_NO_MEMORY = 6, - particle_ctrl_ResultCode_INVALID_PARAM = 7 +/* The field numbers here are just protobuf details. The value to pay attention to + is the "int_value" option, which corresponds to the numeric value that will + be set in reply frames (which itself ultimately comes from the numeric values + in the system_error_t enum in the firmware code). */ +typedef enum _particle_ctrl_ResultCode { + particle_ctrl_ResultCode_OK = 0, + particle_ctrl_ResultCode_NOT_ALLOWED = 1, + particle_ctrl_ResultCode_TIMEOUT = 2, + particle_ctrl_ResultCode_NOT_FOUND = 3, + particle_ctrl_ResultCode_ALREADY_EXIST = 4, + particle_ctrl_ResultCode_INVALID_STATE = 5, + particle_ctrl_ResultCode_NO_MEMORY = 6, + particle_ctrl_ResultCode_INVALID_PARAM = 7 } particle_ctrl_ResultCode; -#define _particle_ctrl_ResultCode_MIN particle_ctrl_ResultCode_OK -#define _particle_ctrl_ResultCode_MAX particle_ctrl_ResultCode_INVALID_PARAM -#define _particle_ctrl_ResultCode_ARRAYSIZE ((particle_ctrl_ResultCode)(particle_ctrl_ResultCode_INVALID_PARAM+1)) -typedef enum _particle_ctrl_IPAddress_Protocol { - particle_ctrl_IPAddress_Protocol_NONE = 0, - particle_ctrl_IPAddress_Protocol_IPv4 = 1, - particle_ctrl_IPAddress_Protocol_IPv6 = 2 +/* The field numbers here are just protobuf details. The value to pay attention to + is the "int_value" option, which corresponds to the numeric value that will + be set in reply frames (which itself ultimately comes from the numeric values + in the system_error_t enum in the firmware code). */ +typedef enum _particle_ctrl_IPAddress_Protocol { + particle_ctrl_IPAddress_Protocol_NONE = 0, + particle_ctrl_IPAddress_Protocol_IPv4 = 1, + particle_ctrl_IPAddress_Protocol_IPv6 = 2 } particle_ctrl_IPAddress_Protocol; -#define _particle_ctrl_IPAddress_Protocol_MIN particle_ctrl_IPAddress_Protocol_NONE -#define _particle_ctrl_IPAddress_Protocol_MAX particle_ctrl_IPAddress_Protocol_IPv6 -#define _particle_ctrl_IPAddress_Protocol_ARRAYSIZE ((particle_ctrl_IPAddress_Protocol)(particle_ctrl_IPAddress_Protocol_IPv6+1)) /* Struct definitions */ typedef PB_BYTES_ARRAY_T(16) particle_ctrl_IPAddress_address_t; -typedef struct _particle_ctrl_IPAddress { - particle_ctrl_IPAddress_Protocol protocol; - particle_ctrl_IPAddress_address_t address; -/* @@protoc_insertion_point(struct:particle_ctrl_IPAddress) */ +/* Deprecated, IpAddress should be used instead */ +typedef struct _particle_ctrl_IPAddress { + particle_ctrl_IPAddress_Protocol protocol; + particle_ctrl_IPAddress_address_t address; } particle_ctrl_IPAddress; -typedef struct _particle_ctrl_Ipv4Address { - uint32_t address; -/* @@protoc_insertion_point(struct:particle_ctrl_Ipv4Address) */ +typedef struct _particle_ctrl_Ipv4Address { + uint32_t address; } particle_ctrl_Ipv4Address; -typedef struct _particle_ctrl_Ipv6Address { - pb_byte_t address[16]; -/* @@protoc_insertion_point(struct:particle_ctrl_Ipv6Address) */ +typedef struct _particle_ctrl_Ipv6Address { + pb_byte_t address[16]; } particle_ctrl_Ipv6Address; -typedef struct _particle_ctrl_IpAddress { +typedef struct _particle_ctrl_IpAddress { pb_size_t which_address; union { particle_ctrl_Ipv4Address v4; particle_ctrl_Ipv6Address v6; - } address; -/* @@protoc_insertion_point(struct:particle_ctrl_IpAddress) */ + } address; /* IP v4 address */ } particle_ctrl_IpAddress; -/* Default values for struct fields */ + +/* Helper constants for enums */ +#define _particle_ctrl_ResultCode_MIN particle_ctrl_ResultCode_OK +#define _particle_ctrl_ResultCode_MAX particle_ctrl_ResultCode_INVALID_PARAM +#define _particle_ctrl_ResultCode_ARRAYSIZE ((particle_ctrl_ResultCode)(particle_ctrl_ResultCode_INVALID_PARAM+1)) + +#define _particle_ctrl_IPAddress_Protocol_MIN particle_ctrl_IPAddress_Protocol_NONE +#define _particle_ctrl_IPAddress_Protocol_MAX particle_ctrl_IPAddress_Protocol_IPv6 +#define _particle_ctrl_IPAddress_Protocol_ARRAYSIZE ((particle_ctrl_IPAddress_Protocol)(particle_ctrl_IPAddress_Protocol_IPv6+1)) + + +#ifdef __cplusplus +extern "C" { +#endif /* Initializer values for message structs */ #define particle_ctrl_Ipv4Address_init_default {0} #define particle_ctrl_Ipv6Address_init_default {{0}} #define particle_ctrl_IpAddress_init_default {0, {particle_ctrl_Ipv4Address_init_default}} -#define particle_ctrl_IPAddress_init_default {(particle_ctrl_IPAddress_Protocol)0, {0, {0}}} +#define particle_ctrl_IPAddress_init_default {_particle_ctrl_IPAddress_Protocol_MIN, {0, {0}}} #define particle_ctrl_Ipv4Address_init_zero {0} #define particle_ctrl_Ipv6Address_init_zero {{0}} #define particle_ctrl_IpAddress_init_zero {0, {particle_ctrl_Ipv4Address_init_zero}} -#define particle_ctrl_IPAddress_init_zero {(particle_ctrl_IPAddress_Protocol)0, {0, {0}}} +#define particle_ctrl_IPAddress_init_zero {_particle_ctrl_IPAddress_Protocol_MIN, {0, {0}}} /* Field tags (for use in manual encoding/decoding) */ #define particle_ctrl_IPAddress_protocol_tag 1 @@ -88,28 +94,49 @@ typedef struct _particle_ctrl_IpAddress { #define particle_ctrl_IpAddress_v6_tag 2 /* Struct field encoding specification for nanopb */ -extern const pb_field_t particle_ctrl_Ipv4Address_fields[2]; -extern const pb_field_t particle_ctrl_Ipv6Address_fields[2]; -extern const pb_field_t particle_ctrl_IpAddress_fields[3]; -extern const pb_field_t particle_ctrl_IPAddress_fields[3]; +#define particle_ctrl_Ipv4Address_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, FIXED32, address, 1) +#define particle_ctrl_Ipv4Address_CALLBACK NULL +#define particle_ctrl_Ipv4Address_DEFAULT NULL + +#define particle_ctrl_Ipv6Address_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, FIXED_LENGTH_BYTES, address, 1) +#define particle_ctrl_Ipv6Address_CALLBACK NULL +#define particle_ctrl_Ipv6Address_DEFAULT NULL + +#define particle_ctrl_IpAddress_FIELDLIST(X, a) \ +X(a, STATIC, ONEOF, MESSAGE, (address,v4,address.v4), 1) \ +X(a, STATIC, ONEOF, MESSAGE, (address,v6,address.v6), 2) +#define particle_ctrl_IpAddress_CALLBACK NULL +#define particle_ctrl_IpAddress_DEFAULT NULL +#define particle_ctrl_IpAddress_address_v4_MSGTYPE particle_ctrl_Ipv4Address +#define particle_ctrl_IpAddress_address_v6_MSGTYPE particle_ctrl_Ipv6Address + +#define particle_ctrl_IPAddress_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, protocol, 1) \ +X(a, STATIC, SINGULAR, BYTES, address, 2) +#define particle_ctrl_IPAddress_CALLBACK NULL +#define particle_ctrl_IPAddress_DEFAULT NULL + +extern const pb_msgdesc_t particle_ctrl_Ipv4Address_msg; +extern const pb_msgdesc_t particle_ctrl_Ipv6Address_msg; +extern const pb_msgdesc_t particle_ctrl_IpAddress_msg; +extern const pb_msgdesc_t particle_ctrl_IPAddress_msg; + +/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ +#define particle_ctrl_Ipv4Address_fields &particle_ctrl_Ipv4Address_msg +#define particle_ctrl_Ipv6Address_fields &particle_ctrl_Ipv6Address_msg +#define particle_ctrl_IpAddress_fields &particle_ctrl_IpAddress_msg +#define particle_ctrl_IPAddress_fields &particle_ctrl_IPAddress_msg /* Maximum encoded size of messages (where known) */ +#define particle_ctrl_IPAddress_size 20 +#define particle_ctrl_IpAddress_size 20 #define particle_ctrl_Ipv4Address_size 5 #define particle_ctrl_Ipv6Address_size 18 -#define particle_ctrl_IpAddress_size 20 -#define particle_ctrl_IPAddress_size 20 - -/* Message IDs (where set with "msgid" option) */ -#ifdef PB_MSGID - -#define COMMON_MESSAGES \ - - -#endif #ifdef __cplusplus } /* extern "C" */ #endif -/* @@protoc_insertion_point(eof) */ #endif diff --git a/system/src/control/proto/config.pb.c b/system/src/control/proto/config.pb.c index 0bf123cb9d..31b54770d0 100644 --- a/system/src/control/proto/config.pb.c +++ b/system/src/control/proto/config.pb.c @@ -1,228 +1,160 @@ /* Automatically generated nanopb constant definitions */ -/* Generated by nanopb-0.3.9 at Mon Jun 10 21:00:54 2019. */ +/* Generated by nanopb-0.4.5 */ #include "config.pb.h" - -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 +#if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif +PB_BIND(particle_ctrl_GetDeviceIdRequest, particle_ctrl_GetDeviceIdRequest, AUTO) + + +PB_BIND(particle_ctrl_GetDeviceIdReply, particle_ctrl_GetDeviceIdReply, AUTO) + + +PB_BIND(particle_ctrl_GetSerialNumberRequest, particle_ctrl_GetSerialNumberRequest, AUTO) + + +PB_BIND(particle_ctrl_GetSerialNumberReply, particle_ctrl_GetSerialNumberReply, AUTO) + + +PB_BIND(particle_ctrl_GetSystemVersionRequest, particle_ctrl_GetSystemVersionRequest, AUTO) + + +PB_BIND(particle_ctrl_GetSystemVersionReply, particle_ctrl_GetSystemVersionReply, AUTO) + + +PB_BIND(particle_ctrl_GetNcpFirmwareVersionRequest, particle_ctrl_GetNcpFirmwareVersionRequest, AUTO) + + +PB_BIND(particle_ctrl_GetNcpFirmwareVersionReply, particle_ctrl_GetNcpFirmwareVersionReply, AUTO) + + +PB_BIND(particle_ctrl_GetSystemCapabilitiesRequest, particle_ctrl_GetSystemCapabilitiesRequest, AUTO) + + +PB_BIND(particle_ctrl_GetSystemCapabilitiesReply, particle_ctrl_GetSystemCapabilitiesReply, AUTO) + + +PB_BIND(particle_ctrl_SetClaimCodeRequest, particle_ctrl_SetClaimCodeRequest, AUTO) + + +PB_BIND(particle_ctrl_SetClaimCodeReply, particle_ctrl_SetClaimCodeReply, AUTO) + + +PB_BIND(particle_ctrl_IsClaimedRequest, particle_ctrl_IsClaimedRequest, AUTO) + + +PB_BIND(particle_ctrl_IsClaimedReply, particle_ctrl_IsClaimedReply, AUTO) + + +PB_BIND(particle_ctrl_SetSecurityKeyRequest, particle_ctrl_SetSecurityKeyRequest, AUTO) + + +PB_BIND(particle_ctrl_SetSecurityKeyReply, particle_ctrl_SetSecurityKeyReply, AUTO) + + +PB_BIND(particle_ctrl_GetSecurityKeyRequest, particle_ctrl_GetSecurityKeyRequest, AUTO) + + +PB_BIND(particle_ctrl_GetSecurityKeyReply, particle_ctrl_GetSecurityKeyReply, AUTO) + + +PB_BIND(particle_ctrl_SetServerAddressRequest, particle_ctrl_SetServerAddressRequest, AUTO) + + +PB_BIND(particle_ctrl_SetServerAddressReply, particle_ctrl_SetServerAddressReply, AUTO) + + +PB_BIND(particle_ctrl_GetServerAddressRequest, particle_ctrl_GetServerAddressRequest, AUTO) + + +PB_BIND(particle_ctrl_GetServerAddressReply, particle_ctrl_GetServerAddressReply, AUTO) + + +PB_BIND(particle_ctrl_SetServerProtocolRequest, particle_ctrl_SetServerProtocolRequest, AUTO) + + +PB_BIND(particle_ctrl_SetServerProtocolReply, particle_ctrl_SetServerProtocolReply, AUTO) + + +PB_BIND(particle_ctrl_GetServerProtocolRequest, particle_ctrl_GetServerProtocolRequest, AUTO) + + +PB_BIND(particle_ctrl_GetServerProtocolReply, particle_ctrl_GetServerProtocolReply, AUTO) + + +PB_BIND(particle_ctrl_SetSoftApSsidRequest, particle_ctrl_SetSoftApSsidRequest, AUTO) + + +PB_BIND(particle_ctrl_SetSoftApSsidReply, particle_ctrl_SetSoftApSsidReply, AUTO) + + +PB_BIND(particle_ctrl_StartListeningModeRequest, particle_ctrl_StartListeningModeRequest, AUTO) + + +PB_BIND(particle_ctrl_StartListeningModeReply, particle_ctrl_StartListeningModeReply, AUTO) + + +PB_BIND(particle_ctrl_StopListeningModeRequest, particle_ctrl_StopListeningModeRequest, AUTO) + + +PB_BIND(particle_ctrl_StopListeningModeReply, particle_ctrl_StopListeningModeReply, AUTO) + + +PB_BIND(particle_ctrl_GetDeviceModeRequest, particle_ctrl_GetDeviceModeRequest, AUTO) + + +PB_BIND(particle_ctrl_GetDeviceModeReply, particle_ctrl_GetDeviceModeReply, AUTO) + + +PB_BIND(particle_ctrl_SetDeviceSetupDoneRequest, particle_ctrl_SetDeviceSetupDoneRequest, AUTO) + + +PB_BIND(particle_ctrl_SetDeviceSetupDoneReply, particle_ctrl_SetDeviceSetupDoneReply, AUTO) + + +PB_BIND(particle_ctrl_IsDeviceSetupDoneRequest, particle_ctrl_IsDeviceSetupDoneRequest, AUTO) + + +PB_BIND(particle_ctrl_IsDeviceSetupDoneReply, particle_ctrl_IsDeviceSetupDoneReply, AUTO) + + +PB_BIND(particle_ctrl_SetStartupModeRequest, particle_ctrl_SetStartupModeRequest, AUTO) + + +PB_BIND(particle_ctrl_SetStartupModeReply, particle_ctrl_SetStartupModeReply, AUTO) + + +PB_BIND(particle_ctrl_SystemResetRequest, particle_ctrl_SystemResetRequest, AUTO) + + +PB_BIND(particle_ctrl_SystemResetReply, particle_ctrl_SystemResetReply, AUTO) + + +PB_BIND(particle_ctrl_SetFeatureRequest, particle_ctrl_SetFeatureRequest, AUTO) + +PB_BIND(particle_ctrl_SetFeatureReply, particle_ctrl_SetFeatureReply, AUTO) -const pb_field_t particle_ctrl_GetDeviceIdRequest_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_GetDeviceIdReply_fields[2] = { - PB_FIELD( 1, STRING , SINGULAR, STATIC , FIRST, particle_ctrl_GetDeviceIdReply, id, id, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_GetSerialNumberRequest_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_GetSerialNumberReply_fields[2] = { - PB_FIELD( 1, STRING , SINGULAR, STATIC , FIRST, particle_ctrl_GetSerialNumberReply, serial, serial, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_GetSystemVersionRequest_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_GetSystemVersionReply_fields[2] = { - PB_FIELD( 1, STRING , SINGULAR, CALLBACK, FIRST, particle_ctrl_GetSystemVersionReply, version, version, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_GetNcpFirmwareVersionRequest_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_GetNcpFirmwareVersionReply_fields[3] = { - PB_FIELD( 1, STRING , SINGULAR, CALLBACK, FIRST, particle_ctrl_GetNcpFirmwareVersionReply, version, version, 0), - PB_FIELD( 2, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_GetNcpFirmwareVersionReply, module_version, version, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_GetSystemCapabilitiesRequest_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_GetSystemCapabilitiesReply_fields[2] = { - PB_FIELD( 1, FIXED32 , SINGULAR, STATIC , FIRST, particle_ctrl_GetSystemCapabilitiesReply, flags, flags, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_SetClaimCodeRequest_fields[2] = { - PB_FIELD( 1, STRING , SINGULAR, STATIC , FIRST, particle_ctrl_SetClaimCodeRequest, code, code, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_SetClaimCodeReply_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_IsClaimedRequest_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_IsClaimedReply_fields[2] = { - PB_FIELD( 1, BOOL , SINGULAR, STATIC , FIRST, particle_ctrl_IsClaimedReply, claimed, claimed, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_SetSecurityKeyRequest_fields[3] = { - PB_FIELD( 1, UENUM , SINGULAR, STATIC , FIRST, particle_ctrl_SetSecurityKeyRequest, type, type, 0), - PB_FIELD( 2, BYTES , SINGULAR, CALLBACK, OTHER, particle_ctrl_SetSecurityKeyRequest, data, type, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_SetSecurityKeyReply_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_GetSecurityKeyRequest_fields[2] = { - PB_FIELD( 1, UENUM , SINGULAR, STATIC , FIRST, particle_ctrl_GetSecurityKeyRequest, type, type, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_GetSecurityKeyReply_fields[2] = { - PB_FIELD( 1, BYTES , SINGULAR, CALLBACK, FIRST, particle_ctrl_GetSecurityKeyReply, data, data, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_SetServerAddressRequest_fields[4] = { - PB_FIELD( 1, UENUM , SINGULAR, STATIC , FIRST, particle_ctrl_SetServerAddressRequest, protocol, protocol, 0), - PB_FIELD( 2, STRING , SINGULAR, STATIC , OTHER, particle_ctrl_SetServerAddressRequest, address, protocol, 0), - PB_FIELD( 3, INT32 , SINGULAR, STATIC , OTHER, particle_ctrl_SetServerAddressRequest, port, address, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_SetServerAddressReply_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_GetServerAddressRequest_fields[2] = { - PB_FIELD( 1, UENUM , SINGULAR, STATIC , FIRST, particle_ctrl_GetServerAddressRequest, protocol, protocol, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_GetServerAddressReply_fields[3] = { - PB_FIELD( 1, STRING , SINGULAR, CALLBACK, FIRST, particle_ctrl_GetServerAddressReply, address, address, 0), - PB_FIELD( 2, INT32 , SINGULAR, STATIC , OTHER, particle_ctrl_GetServerAddressReply, port, address, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_SetServerProtocolRequest_fields[2] = { - PB_FIELD( 1, UENUM , SINGULAR, STATIC , FIRST, particle_ctrl_SetServerProtocolRequest, protocol, protocol, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_SetServerProtocolReply_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_GetServerProtocolRequest_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_GetServerProtocolReply_fields[2] = { - PB_FIELD( 1, UENUM , SINGULAR, STATIC , FIRST, particle_ctrl_GetServerProtocolReply, protocol, protocol, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_SetSoftApSsidRequest_fields[3] = { - PB_FIELD( 1, STRING , SINGULAR, STATIC , FIRST, particle_ctrl_SetSoftApSsidRequest, prefix, prefix, 0), - PB_FIELD( 2, STRING , SINGULAR, STATIC , OTHER, particle_ctrl_SetSoftApSsidRequest, suffix, prefix, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_SetSoftApSsidReply_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_StartListeningModeRequest_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_StartListeningModeReply_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_StopListeningModeRequest_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_StopListeningModeReply_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_GetDeviceModeRequest_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_GetDeviceModeReply_fields[2] = { - PB_FIELD( 1, UENUM , SINGULAR, STATIC , FIRST, particle_ctrl_GetDeviceModeReply, mode, mode, 0), - PB_LAST_FIELD -}; -const pb_field_t particle_ctrl_SetDeviceSetupDoneRequest_fields[2] = { - PB_FIELD( 1, BOOL , SINGULAR, STATIC , FIRST, particle_ctrl_SetDeviceSetupDoneRequest, done, done, 0), - PB_LAST_FIELD -}; +PB_BIND(particle_ctrl_GetFeatureRequest, particle_ctrl_GetFeatureRequest, AUTO) -const pb_field_t particle_ctrl_SetDeviceSetupDoneReply_fields[1] = { - PB_LAST_FIELD -}; -const pb_field_t particle_ctrl_IsDeviceSetupDoneRequest_fields[1] = { - PB_LAST_FIELD -}; +PB_BIND(particle_ctrl_GetFeatureReply, particle_ctrl_GetFeatureReply, AUTO) -const pb_field_t particle_ctrl_IsDeviceSetupDoneReply_fields[2] = { - PB_FIELD( 1, BOOL , SINGULAR, STATIC , FIRST, particle_ctrl_IsDeviceSetupDoneReply, done, done, 0), - PB_LAST_FIELD -}; -const pb_field_t particle_ctrl_SetStartupModeRequest_fields[2] = { - PB_FIELD( 1, UENUM , SINGULAR, STATIC , FIRST, particle_ctrl_SetStartupModeRequest, mode, mode, 0), - PB_LAST_FIELD -}; +PB_BIND(particle_ctrl_StartNyanSignalRequest, particle_ctrl_StartNyanSignalRequest, AUTO) -const pb_field_t particle_ctrl_SetStartupModeReply_fields[1] = { - PB_LAST_FIELD -}; -const pb_field_t particle_ctrl_SystemResetRequest_fields[1] = { - PB_LAST_FIELD -}; +PB_BIND(particle_ctrl_StartNyanSignalReply, particle_ctrl_StartNyanSignalReply, AUTO) -const pb_field_t particle_ctrl_SystemResetReply_fields[1] = { - PB_LAST_FIELD -}; -const pb_field_t particle_ctrl_SetFeatureRequest_fields[3] = { - PB_FIELD( 1, UENUM , SINGULAR, STATIC , FIRST, particle_ctrl_SetFeatureRequest, feature, feature, 0), - PB_FIELD( 2, BOOL , SINGULAR, STATIC , OTHER, particle_ctrl_SetFeatureRequest, enabled, feature, 0), - PB_LAST_FIELD -}; +PB_BIND(particle_ctrl_StopNyanSignalRequest, particle_ctrl_StopNyanSignalRequest, AUTO) -const pb_field_t particle_ctrl_SetFeatureReply_fields[1] = { - PB_LAST_FIELD -}; -const pb_field_t particle_ctrl_GetFeatureRequest_fields[2] = { - PB_FIELD( 1, UENUM , SINGULAR, STATIC , FIRST, particle_ctrl_GetFeatureRequest, feature, feature, 0), - PB_LAST_FIELD -}; +PB_BIND(particle_ctrl_StopNyanSignalReply, particle_ctrl_StopNyanSignalReply, AUTO) -const pb_field_t particle_ctrl_GetFeatureReply_fields[2] = { - PB_FIELD( 1, BOOL , SINGULAR, STATIC , FIRST, particle_ctrl_GetFeatureReply, enabled, enabled, 0), - PB_LAST_FIELD -}; @@ -230,4 +162,3 @@ const pb_field_t particle_ctrl_GetFeatureReply_fields[2] = { -/* @@protoc_insertion_point(eof) */ diff --git a/system/src/control/proto/config.pb.h b/system/src/control/proto/config.pb.h index 322e58d551..c68bbbc881 100644 --- a/system/src/control/proto/config.pb.h +++ b/system/src/control/proto/config.pb.h @@ -1,309 +1,311 @@ /* Automatically generated nanopb header */ -/* Generated by nanopb-0.3.9 at Mon Jun 10 21:00:54 2019. */ +/* Generated by nanopb-0.4.5 */ #ifndef PB_PARTICLE_CTRL_CONFIG_PB_H_INCLUDED #define PB_PARTICLE_CTRL_CONFIG_PB_H_INCLUDED #include - #include "extensions.pb.h" - #include "common.pb.h" -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 +#if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif -#ifdef __cplusplus -extern "C" { -#endif - /* Enum definitions */ -typedef enum _particle_ctrl_SecurityKeyType { - particle_ctrl_SecurityKeyType_INVALID_SECURITY_KEY = 0, - particle_ctrl_SecurityKeyType_TCP_DEVICE_PRIVATE_KEY = 1, - particle_ctrl_SecurityKeyType_TCP_DEVICE_PUBLIC_KEY = 2, - particle_ctrl_SecurityKeyType_TCP_SERVER_PUBLIC_KEY = 3, - particle_ctrl_SecurityKeyType_UDP_DEVICE_PRIVATE_KEY = 4, - particle_ctrl_SecurityKeyType_UDP_DEVICE_PUBLIC_KEY = 5, - particle_ctrl_SecurityKeyType_UDP_SERVER_PUBLIC_KEY = 6 +/* Note: Use the same values as defined by the security_key_type enum */ +typedef enum _particle_ctrl_SecurityKeyType { + particle_ctrl_SecurityKeyType_INVALID_SECURITY_KEY = 0, /* Invalid key */ + particle_ctrl_SecurityKeyType_TCP_DEVICE_PRIVATE_KEY = 1, /* TCP device private key */ + particle_ctrl_SecurityKeyType_TCP_DEVICE_PUBLIC_KEY = 2, /* TCP device public key */ + particle_ctrl_SecurityKeyType_TCP_SERVER_PUBLIC_KEY = 3, /* TCP server public key */ + particle_ctrl_SecurityKeyType_UDP_DEVICE_PRIVATE_KEY = 4, /* UDP device private key */ + particle_ctrl_SecurityKeyType_UDP_DEVICE_PUBLIC_KEY = 5, /* UDP device public key */ + particle_ctrl_SecurityKeyType_UDP_SERVER_PUBLIC_KEY = 6 /* UDP server public key */ } particle_ctrl_SecurityKeyType; -#define _particle_ctrl_SecurityKeyType_MIN particle_ctrl_SecurityKeyType_INVALID_SECURITY_KEY -#define _particle_ctrl_SecurityKeyType_MAX particle_ctrl_SecurityKeyType_UDP_SERVER_PUBLIC_KEY -#define _particle_ctrl_SecurityKeyType_ARRAYSIZE ((particle_ctrl_SecurityKeyType)(particle_ctrl_SecurityKeyType_UDP_SERVER_PUBLIC_KEY+1)) -typedef enum _particle_ctrl_ServerProtocolType { - particle_ctrl_ServerProtocolType_INVALID_PROTOCOL = 0, - particle_ctrl_ServerProtocolType_TCP_PROTOCOL = 1, - particle_ctrl_ServerProtocolType_UDP_PROTOCOL = 2 +/* Note: Use the same values as defined by the server_protocol_type enum */ +typedef enum _particle_ctrl_ServerProtocolType { + particle_ctrl_ServerProtocolType_INVALID_PROTOCOL = 0, + particle_ctrl_ServerProtocolType_TCP_PROTOCOL = 1, /* TCP */ + particle_ctrl_ServerProtocolType_UDP_PROTOCOL = 2 /* UDP */ } particle_ctrl_ServerProtocolType; -#define _particle_ctrl_ServerProtocolType_MIN particle_ctrl_ServerProtocolType_INVALID_PROTOCOL -#define _particle_ctrl_ServerProtocolType_MAX particle_ctrl_ServerProtocolType_UDP_PROTOCOL -#define _particle_ctrl_ServerProtocolType_ARRAYSIZE ((particle_ctrl_ServerProtocolType)(particle_ctrl_ServerProtocolType_UDP_PROTOCOL+1)) -typedef enum _particle_ctrl_DeviceMode { - particle_ctrl_DeviceMode_NORMAL_MODE = 0, - particle_ctrl_DeviceMode_LISTENING_MODE = 1 +/* Device mode */ +typedef enum _particle_ctrl_DeviceMode { + particle_ctrl_DeviceMode_NORMAL_MODE = 0, /* Normal mode */ + particle_ctrl_DeviceMode_LISTENING_MODE = 1 /* Listening mode */ } particle_ctrl_DeviceMode; -#define _particle_ctrl_DeviceMode_MIN particle_ctrl_DeviceMode_NORMAL_MODE -#define _particle_ctrl_DeviceMode_MAX particle_ctrl_DeviceMode_LISTENING_MODE -#define _particle_ctrl_DeviceMode_ARRAYSIZE ((particle_ctrl_DeviceMode)(particle_ctrl_DeviceMode_LISTENING_MODE+1)) -typedef enum _particle_ctrl_SystemCapabilityFlag { - particle_ctrl_SystemCapabilityFlag_NO_SYSTEM_CAPABILITY_FLAGS = 0, - particle_ctrl_SystemCapabilityFlag_COMPRESSED_OTA = 1 +/* System capability flags */ +typedef enum _particle_ctrl_SystemCapabilityFlag { + particle_ctrl_SystemCapabilityFlag_NO_SYSTEM_CAPABILITY_FLAGS = 0, + particle_ctrl_SystemCapabilityFlag_COMPRESSED_OTA = 1 } particle_ctrl_SystemCapabilityFlag; -#define _particle_ctrl_SystemCapabilityFlag_MIN particle_ctrl_SystemCapabilityFlag_NO_SYSTEM_CAPABILITY_FLAGS -#define _particle_ctrl_SystemCapabilityFlag_MAX particle_ctrl_SystemCapabilityFlag_COMPRESSED_OTA -#define _particle_ctrl_SystemCapabilityFlag_ARRAYSIZE ((particle_ctrl_SystemCapabilityFlag)(particle_ctrl_SystemCapabilityFlag_COMPRESSED_OTA+1)) -typedef enum _particle_ctrl_Feature { - particle_ctrl_Feature_INVALID_FEATURE = 0, - particle_ctrl_Feature_ETHERNET_DETECTION = 1 +/* System features */ +typedef enum _particle_ctrl_Feature { + particle_ctrl_Feature_INVALID_FEATURE = 0, /* Invalid feature */ + particle_ctrl_Feature_ETHERNET_DETECTION = 1 /* Ethernet FeatherWing detection on boot */ } particle_ctrl_Feature; -#define _particle_ctrl_Feature_MIN particle_ctrl_Feature_INVALID_FEATURE -#define _particle_ctrl_Feature_MAX particle_ctrl_Feature_ETHERNET_DETECTION -#define _particle_ctrl_Feature_ARRAYSIZE ((particle_ctrl_Feature)(particle_ctrl_Feature_ETHERNET_DETECTION+1)) /* Struct definitions */ -typedef struct _particle_ctrl_GetDeviceIdRequest { +/* Get the device ID */ +typedef struct _particle_ctrl_GetDeviceIdRequest { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_GetDeviceIdRequest) */ } particle_ctrl_GetDeviceIdRequest; -typedef struct _particle_ctrl_GetDeviceModeRequest { +/* Get the current device mode */ +typedef struct _particle_ctrl_GetDeviceModeRequest { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_GetDeviceModeRequest) */ } particle_ctrl_GetDeviceModeRequest; -typedef struct _particle_ctrl_GetNcpFirmwareVersionRequest { +/* Get the NCP (network coprocessor) firmware version */ +typedef struct _particle_ctrl_GetNcpFirmwareVersionRequest { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_GetNcpFirmwareVersionRequest) */ } particle_ctrl_GetNcpFirmwareVersionRequest; -typedef struct _particle_ctrl_GetSecurityKeyReply { - pb_callback_t data; -/* @@protoc_insertion_point(struct:particle_ctrl_GetSecurityKeyReply) */ +typedef struct _particle_ctrl_GetSecurityKeyReply { + pb_callback_t data; /* Key data in DER format */ } particle_ctrl_GetSecurityKeyReply; -typedef struct _particle_ctrl_GetSerialNumberRequest { +/* Get the device's serial number */ +typedef struct _particle_ctrl_GetSerialNumberRequest { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_GetSerialNumberRequest) */ } particle_ctrl_GetSerialNumberRequest; -typedef struct _particle_ctrl_GetServerProtocolRequest { +typedef struct _particle_ctrl_GetServerProtocolRequest { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_GetServerProtocolRequest) */ } particle_ctrl_GetServerProtocolRequest; -typedef struct _particle_ctrl_GetSystemCapabilitiesRequest { +/* Get system capabilities */ +typedef struct _particle_ctrl_GetSystemCapabilitiesRequest { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_GetSystemCapabilitiesRequest) */ } particle_ctrl_GetSystemCapabilitiesRequest; -typedef struct _particle_ctrl_GetSystemVersionReply { - pb_callback_t version; -/* @@protoc_insertion_point(struct:particle_ctrl_GetSystemVersionReply) */ +typedef struct _particle_ctrl_GetSystemVersionReply { + /* Device OS version in SemVer format */ + pb_callback_t version; } particle_ctrl_GetSystemVersionReply; -typedef struct _particle_ctrl_GetSystemVersionRequest { +/* Get the firmware version */ +typedef struct _particle_ctrl_GetSystemVersionRequest { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_GetSystemVersionRequest) */ } particle_ctrl_GetSystemVersionRequest; -typedef struct _particle_ctrl_IsClaimedRequest { +typedef struct _particle_ctrl_IsClaimedRequest { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_IsClaimedRequest) */ } particle_ctrl_IsClaimedRequest; -typedef struct _particle_ctrl_IsDeviceSetupDoneRequest { +/* Get the flag indicating if the device has been set up */ +typedef struct _particle_ctrl_IsDeviceSetupDoneRequest { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_IsDeviceSetupDoneRequest) */ } particle_ctrl_IsDeviceSetupDoneRequest; -typedef struct _particle_ctrl_SetClaimCodeReply { +typedef struct _particle_ctrl_SetClaimCodeReply { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_SetClaimCodeReply) */ } particle_ctrl_SetClaimCodeReply; -typedef struct _particle_ctrl_SetDeviceSetupDoneReply { +typedef struct _particle_ctrl_SetDeviceSetupDoneReply { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_SetDeviceSetupDoneReply) */ } particle_ctrl_SetDeviceSetupDoneReply; -typedef struct _particle_ctrl_SetFeatureReply { +typedef struct _particle_ctrl_SetFeatureReply { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_SetFeatureReply) */ } particle_ctrl_SetFeatureReply; -typedef struct _particle_ctrl_SetSecurityKeyReply { +typedef struct _particle_ctrl_SetSecurityKeyReply { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_SetSecurityKeyReply) */ } particle_ctrl_SetSecurityKeyReply; -typedef struct _particle_ctrl_SetServerAddressReply { +typedef struct _particle_ctrl_SetServerAddressReply { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_SetServerAddressReply) */ } particle_ctrl_SetServerAddressReply; -typedef struct _particle_ctrl_SetServerProtocolReply { +typedef struct _particle_ctrl_SetServerProtocolReply { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_SetServerProtocolReply) */ } particle_ctrl_SetServerProtocolReply; -typedef struct _particle_ctrl_SetSoftApSsidReply { +typedef struct _particle_ctrl_SetSoftApSsidReply { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_SetSoftApSsidReply) */ } particle_ctrl_SetSoftApSsidReply; -typedef struct _particle_ctrl_SetStartupModeReply { +typedef struct _particle_ctrl_SetStartupModeReply { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_SetStartupModeReply) */ } particle_ctrl_SetStartupModeReply; -typedef struct _particle_ctrl_StartListeningModeReply { +typedef struct _particle_ctrl_StartListeningModeReply { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_StartListeningModeReply) */ } particle_ctrl_StartListeningModeReply; -typedef struct _particle_ctrl_StartListeningModeRequest { +/* Put the device into listening mode */ +typedef struct _particle_ctrl_StartListeningModeRequest { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_StartListeningModeRequest) */ } particle_ctrl_StartListeningModeRequest; -typedef struct _particle_ctrl_StopListeningModeReply { +typedef struct _particle_ctrl_StartNyanSignalReply { + char dummy_field; +} particle_ctrl_StartNyanSignalReply; + +/* Make the device's status LED display a rainbow pattern aka Nyan mode */ +typedef struct _particle_ctrl_StartNyanSignalRequest { + char dummy_field; +} particle_ctrl_StartNyanSignalRequest; + +typedef struct _particle_ctrl_StopListeningModeReply { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_StopListeningModeReply) */ } particle_ctrl_StopListeningModeReply; -typedef struct _particle_ctrl_StopListeningModeRequest { +/* Put the device into normal mode */ +typedef struct _particle_ctrl_StopListeningModeRequest { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_StopListeningModeRequest) */ } particle_ctrl_StopListeningModeRequest; -typedef struct _particle_ctrl_SystemResetReply { +typedef struct _particle_ctrl_StopNyanSignalReply { + char dummy_field; +} particle_ctrl_StopNyanSignalReply; + +/* Exit the Nyan mode */ +typedef struct _particle_ctrl_StopNyanSignalRequest { + char dummy_field; +} particle_ctrl_StopNyanSignalRequest; + +typedef struct _particle_ctrl_SystemResetReply { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_SystemResetReply) */ } particle_ctrl_SystemResetReply; -typedef struct _particle_ctrl_SystemResetRequest { +/* Resets the device, just like hitting the reset button or powering down and back up */ +typedef struct _particle_ctrl_SystemResetRequest { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_SystemResetRequest) */ } particle_ctrl_SystemResetRequest; -typedef struct _particle_ctrl_GetDeviceIdReply { - char id[24]; -/* @@protoc_insertion_point(struct:particle_ctrl_GetDeviceIdReply) */ +typedef struct _particle_ctrl_GetDeviceIdReply { + /* Device ID (hex-encoded) */ + char id[24]; } particle_ctrl_GetDeviceIdReply; -typedef struct _particle_ctrl_GetDeviceModeReply { - particle_ctrl_DeviceMode mode; -/* @@protoc_insertion_point(struct:particle_ctrl_GetDeviceModeReply) */ +typedef struct _particle_ctrl_GetDeviceModeReply { + particle_ctrl_DeviceMode mode; } particle_ctrl_GetDeviceModeReply; -typedef struct _particle_ctrl_GetFeatureReply { - bool enabled; -/* @@protoc_insertion_point(struct:particle_ctrl_GetFeatureReply) */ +typedef struct _particle_ctrl_GetFeatureReply { + bool enabled; } particle_ctrl_GetFeatureReply; -typedef struct _particle_ctrl_GetFeatureRequest { - particle_ctrl_Feature feature; -/* @@protoc_insertion_point(struct:particle_ctrl_GetFeatureRequest) */ +/* Check if the system feature is enabled or disabled */ +typedef struct _particle_ctrl_GetFeatureRequest { + particle_ctrl_Feature feature; } particle_ctrl_GetFeatureRequest; -typedef struct _particle_ctrl_GetNcpFirmwareVersionReply { - pb_callback_t version; - uint32_t module_version; -/* @@protoc_insertion_point(struct:particle_ctrl_GetNcpFirmwareVersionReply) */ +typedef struct _particle_ctrl_GetNcpFirmwareVersionReply { + /* NCP version in SemVer format */ + pb_callback_t version; + /* NCP module version */ + uint32_t module_version; } particle_ctrl_GetNcpFirmwareVersionReply; -typedef struct _particle_ctrl_GetSecurityKeyRequest { - particle_ctrl_SecurityKeyType type; -/* @@protoc_insertion_point(struct:particle_ctrl_GetSecurityKeyRequest) */ +typedef struct _particle_ctrl_GetSecurityKeyRequest { + particle_ctrl_SecurityKeyType type; /* Key type */ } particle_ctrl_GetSecurityKeyRequest; -typedef struct _particle_ctrl_GetSerialNumberReply { - char serial[16]; -/* @@protoc_insertion_point(struct:particle_ctrl_GetSerialNumberReply) */ +typedef struct _particle_ctrl_GetSerialNumberReply { + /* Device serial ID */ + char serial[16]; } particle_ctrl_GetSerialNumberReply; -typedef struct _particle_ctrl_GetServerAddressReply { - pb_callback_t address; - int32_t port; -/* @@protoc_insertion_point(struct:particle_ctrl_GetServerAddressReply) */ +typedef struct _particle_ctrl_GetServerAddressReply { + pb_callback_t address; /* Server address */ + int32_t port; /* Port number */ } particle_ctrl_GetServerAddressReply; -typedef struct _particle_ctrl_GetServerAddressRequest { - particle_ctrl_ServerProtocolType protocol; -/* @@protoc_insertion_point(struct:particle_ctrl_GetServerAddressRequest) */ +typedef struct _particle_ctrl_GetServerAddressRequest { + particle_ctrl_ServerProtocolType protocol; /* Protocol type */ } particle_ctrl_GetServerAddressRequest; -typedef struct _particle_ctrl_GetServerProtocolReply { - particle_ctrl_ServerProtocolType protocol; -/* @@protoc_insertion_point(struct:particle_ctrl_GetServerProtocolReply) */ +typedef struct _particle_ctrl_GetServerProtocolReply { + particle_ctrl_ServerProtocolType protocol; /* Protocol type */ } particle_ctrl_GetServerProtocolReply; -typedef struct _particle_ctrl_GetSystemCapabilitiesReply { - uint32_t flags; -/* @@protoc_insertion_point(struct:particle_ctrl_GetSystemCapabilitiesReply) */ +typedef struct _particle_ctrl_GetSystemCapabilitiesReply { + /* SystemCapabilityFlag flags */ + uint32_t flags; } particle_ctrl_GetSystemCapabilitiesReply; -typedef struct _particle_ctrl_IsClaimedReply { - bool claimed; -/* @@protoc_insertion_point(struct:particle_ctrl_IsClaimedReply) */ +typedef struct _particle_ctrl_IsClaimedReply { + /* `true` if device is claimed */ + bool claimed; } particle_ctrl_IsClaimedReply; -typedef struct _particle_ctrl_IsDeviceSetupDoneReply { - bool done; -/* @@protoc_insertion_point(struct:particle_ctrl_IsDeviceSetupDoneReply) */ +typedef struct _particle_ctrl_IsDeviceSetupDoneReply { + bool done; } particle_ctrl_IsDeviceSetupDoneReply; -typedef struct _particle_ctrl_SetClaimCodeRequest { - char code[64]; -/* @@protoc_insertion_point(struct:particle_ctrl_SetClaimCodeRequest) */ +typedef struct _particle_ctrl_SetClaimCodeRequest { + char code[64]; /* Claim code */ } particle_ctrl_SetClaimCodeRequest; -typedef struct _particle_ctrl_SetDeviceSetupDoneRequest { - bool done; -/* @@protoc_insertion_point(struct:particle_ctrl_SetDeviceSetupDoneRequest) */ +/* Set flag for setup being done */ +typedef struct _particle_ctrl_SetDeviceSetupDoneRequest { + bool done; } particle_ctrl_SetDeviceSetupDoneRequest; -typedef struct _particle_ctrl_SetFeatureRequest { - particle_ctrl_Feature feature; - bool enabled; -/* @@protoc_insertion_point(struct:particle_ctrl_SetFeatureRequest) */ +/* Enable/disable system features */ +typedef struct _particle_ctrl_SetFeatureRequest { + particle_ctrl_Feature feature; + bool enabled; } particle_ctrl_SetFeatureRequest; -typedef struct _particle_ctrl_SetSecurityKeyRequest { - particle_ctrl_SecurityKeyType type; - pb_callback_t data; -/* @@protoc_insertion_point(struct:particle_ctrl_SetSecurityKeyRequest) */ +typedef struct _particle_ctrl_SetSecurityKeyRequest { + particle_ctrl_SecurityKeyType type; /* Key type */ + pb_callback_t data; /* Key data in DER format */ } particle_ctrl_SetSecurityKeyRequest; -typedef struct _particle_ctrl_SetServerAddressRequest { - particle_ctrl_ServerProtocolType protocol; - char address[64]; - int32_t port; -/* @@protoc_insertion_point(struct:particle_ctrl_SetServerAddressRequest) */ +typedef struct _particle_ctrl_SetServerAddressRequest { + particle_ctrl_ServerProtocolType protocol; /* Protocol type */ + char address[64]; /* Server address */ + int32_t port; /* Port number */ } particle_ctrl_SetServerAddressRequest; -typedef struct _particle_ctrl_SetServerProtocolRequest { - particle_ctrl_ServerProtocolType protocol; -/* @@protoc_insertion_point(struct:particle_ctrl_SetServerProtocolRequest) */ +typedef struct _particle_ctrl_SetServerProtocolRequest { + particle_ctrl_ServerProtocolType protocol; /* Protocol type */ } particle_ctrl_SetServerProtocolRequest; -typedef struct _particle_ctrl_SetSoftApSsidRequest { - char prefix[32]; - char suffix[16]; -/* @@protoc_insertion_point(struct:particle_ctrl_SetSoftApSsidRequest) */ +/* Set the SoftAP SSID prefix and suffix */ +typedef struct _particle_ctrl_SetSoftApSsidRequest { + char prefix[32]; /* SSID prefix */ + char suffix[16]; /* SSID sufix */ } particle_ctrl_SetSoftApSsidRequest; -typedef struct _particle_ctrl_SetStartupModeRequest { - particle_ctrl_DeviceMode mode; -/* @@protoc_insertion_point(struct:particle_ctrl_SetStartupModeRequest) */ +/* Set the mode to enter when in safe mode */ +typedef struct _particle_ctrl_SetStartupModeRequest { + particle_ctrl_DeviceMode mode; } particle_ctrl_SetStartupModeRequest; -/* Default values for struct fields */ + +/* Helper constants for enums */ +#define _particle_ctrl_SecurityKeyType_MIN particle_ctrl_SecurityKeyType_INVALID_SECURITY_KEY +#define _particle_ctrl_SecurityKeyType_MAX particle_ctrl_SecurityKeyType_UDP_SERVER_PUBLIC_KEY +#define _particle_ctrl_SecurityKeyType_ARRAYSIZE ((particle_ctrl_SecurityKeyType)(particle_ctrl_SecurityKeyType_UDP_SERVER_PUBLIC_KEY+1)) + +#define _particle_ctrl_ServerProtocolType_MIN particle_ctrl_ServerProtocolType_INVALID_PROTOCOL +#define _particle_ctrl_ServerProtocolType_MAX particle_ctrl_ServerProtocolType_UDP_PROTOCOL +#define _particle_ctrl_ServerProtocolType_ARRAYSIZE ((particle_ctrl_ServerProtocolType)(particle_ctrl_ServerProtocolType_UDP_PROTOCOL+1)) + +#define _particle_ctrl_DeviceMode_MIN particle_ctrl_DeviceMode_NORMAL_MODE +#define _particle_ctrl_DeviceMode_MAX particle_ctrl_DeviceMode_LISTENING_MODE +#define _particle_ctrl_DeviceMode_ARRAYSIZE ((particle_ctrl_DeviceMode)(particle_ctrl_DeviceMode_LISTENING_MODE+1)) + +#define _particle_ctrl_SystemCapabilityFlag_MIN particle_ctrl_SystemCapabilityFlag_NO_SYSTEM_CAPABILITY_FLAGS +#define _particle_ctrl_SystemCapabilityFlag_MAX particle_ctrl_SystemCapabilityFlag_COMPRESSED_OTA +#define _particle_ctrl_SystemCapabilityFlag_ARRAYSIZE ((particle_ctrl_SystemCapabilityFlag)(particle_ctrl_SystemCapabilityFlag_COMPRESSED_OTA+1)) + +#define _particle_ctrl_Feature_MIN particle_ctrl_Feature_INVALID_FEATURE +#define _particle_ctrl_Feature_MAX particle_ctrl_Feature_ETHERNET_DETECTION +#define _particle_ctrl_Feature_ARRAYSIZE ((particle_ctrl_Feature)(particle_ctrl_Feature_ETHERNET_DETECTION+1)) + + +#ifdef __cplusplus +extern "C" { +#endif /* Initializer values for message structs */ #define particle_ctrl_GetDeviceIdRequest_init_default {0} @@ -320,18 +322,18 @@ typedef struct _particle_ctrl_SetStartupModeRequest { #define particle_ctrl_SetClaimCodeReply_init_default {0} #define particle_ctrl_IsClaimedRequest_init_default {0} #define particle_ctrl_IsClaimedReply_init_default {0} -#define particle_ctrl_SetSecurityKeyRequest_init_default {(particle_ctrl_SecurityKeyType)0, {{NULL}, NULL}} +#define particle_ctrl_SetSecurityKeyRequest_init_default {_particle_ctrl_SecurityKeyType_MIN, {{NULL}, NULL}} #define particle_ctrl_SetSecurityKeyReply_init_default {0} -#define particle_ctrl_GetSecurityKeyRequest_init_default {(particle_ctrl_SecurityKeyType)0} +#define particle_ctrl_GetSecurityKeyRequest_init_default {_particle_ctrl_SecurityKeyType_MIN} #define particle_ctrl_GetSecurityKeyReply_init_default {{{NULL}, NULL}} -#define particle_ctrl_SetServerAddressRequest_init_default {(particle_ctrl_ServerProtocolType)0, "", 0} +#define particle_ctrl_SetServerAddressRequest_init_default {_particle_ctrl_ServerProtocolType_MIN, "", 0} #define particle_ctrl_SetServerAddressReply_init_default {0} -#define particle_ctrl_GetServerAddressRequest_init_default {(particle_ctrl_ServerProtocolType)0} +#define particle_ctrl_GetServerAddressRequest_init_default {_particle_ctrl_ServerProtocolType_MIN} #define particle_ctrl_GetServerAddressReply_init_default {{{NULL}, NULL}, 0} -#define particle_ctrl_SetServerProtocolRequest_init_default {(particle_ctrl_ServerProtocolType)0} +#define particle_ctrl_SetServerProtocolRequest_init_default {_particle_ctrl_ServerProtocolType_MIN} #define particle_ctrl_SetServerProtocolReply_init_default {0} #define particle_ctrl_GetServerProtocolRequest_init_default {0} -#define particle_ctrl_GetServerProtocolReply_init_default {(particle_ctrl_ServerProtocolType)0} +#define particle_ctrl_GetServerProtocolReply_init_default {_particle_ctrl_ServerProtocolType_MIN} #define particle_ctrl_SetSoftApSsidRequest_init_default {"", ""} #define particle_ctrl_SetSoftApSsidReply_init_default {0} #define particle_ctrl_StartListeningModeRequest_init_default {0} @@ -339,19 +341,23 @@ typedef struct _particle_ctrl_SetStartupModeRequest { #define particle_ctrl_StopListeningModeRequest_init_default {0} #define particle_ctrl_StopListeningModeReply_init_default {0} #define particle_ctrl_GetDeviceModeRequest_init_default {0} -#define particle_ctrl_GetDeviceModeReply_init_default {(particle_ctrl_DeviceMode)0} +#define particle_ctrl_GetDeviceModeReply_init_default {_particle_ctrl_DeviceMode_MIN} #define particle_ctrl_SetDeviceSetupDoneRequest_init_default {0} #define particle_ctrl_SetDeviceSetupDoneReply_init_default {0} #define particle_ctrl_IsDeviceSetupDoneRequest_init_default {0} #define particle_ctrl_IsDeviceSetupDoneReply_init_default {0} -#define particle_ctrl_SetStartupModeRequest_init_default {(particle_ctrl_DeviceMode)0} +#define particle_ctrl_SetStartupModeRequest_init_default {_particle_ctrl_DeviceMode_MIN} #define particle_ctrl_SetStartupModeReply_init_default {0} #define particle_ctrl_SystemResetRequest_init_default {0} #define particle_ctrl_SystemResetReply_init_default {0} -#define particle_ctrl_SetFeatureRequest_init_default {(particle_ctrl_Feature)0, 0} +#define particle_ctrl_SetFeatureRequest_init_default {_particle_ctrl_Feature_MIN, 0} #define particle_ctrl_SetFeatureReply_init_default {0} -#define particle_ctrl_GetFeatureRequest_init_default {(particle_ctrl_Feature)0} +#define particle_ctrl_GetFeatureRequest_init_default {_particle_ctrl_Feature_MIN} #define particle_ctrl_GetFeatureReply_init_default {0} +#define particle_ctrl_StartNyanSignalRequest_init_default {0} +#define particle_ctrl_StartNyanSignalReply_init_default {0} +#define particle_ctrl_StopNyanSignalRequest_init_default {0} +#define particle_ctrl_StopNyanSignalReply_init_default {0} #define particle_ctrl_GetDeviceIdRequest_init_zero {0} #define particle_ctrl_GetDeviceIdReply_init_zero {""} #define particle_ctrl_GetSerialNumberRequest_init_zero {0} @@ -366,18 +372,18 @@ typedef struct _particle_ctrl_SetStartupModeRequest { #define particle_ctrl_SetClaimCodeReply_init_zero {0} #define particle_ctrl_IsClaimedRequest_init_zero {0} #define particle_ctrl_IsClaimedReply_init_zero {0} -#define particle_ctrl_SetSecurityKeyRequest_init_zero {(particle_ctrl_SecurityKeyType)0, {{NULL}, NULL}} +#define particle_ctrl_SetSecurityKeyRequest_init_zero {_particle_ctrl_SecurityKeyType_MIN, {{NULL}, NULL}} #define particle_ctrl_SetSecurityKeyReply_init_zero {0} -#define particle_ctrl_GetSecurityKeyRequest_init_zero {(particle_ctrl_SecurityKeyType)0} +#define particle_ctrl_GetSecurityKeyRequest_init_zero {_particle_ctrl_SecurityKeyType_MIN} #define particle_ctrl_GetSecurityKeyReply_init_zero {{{NULL}, NULL}} -#define particle_ctrl_SetServerAddressRequest_init_zero {(particle_ctrl_ServerProtocolType)0, "", 0} +#define particle_ctrl_SetServerAddressRequest_init_zero {_particle_ctrl_ServerProtocolType_MIN, "", 0} #define particle_ctrl_SetServerAddressReply_init_zero {0} -#define particle_ctrl_GetServerAddressRequest_init_zero {(particle_ctrl_ServerProtocolType)0} +#define particle_ctrl_GetServerAddressRequest_init_zero {_particle_ctrl_ServerProtocolType_MIN} #define particle_ctrl_GetServerAddressReply_init_zero {{{NULL}, NULL}, 0} -#define particle_ctrl_SetServerProtocolRequest_init_zero {(particle_ctrl_ServerProtocolType)0} +#define particle_ctrl_SetServerProtocolRequest_init_zero {_particle_ctrl_ServerProtocolType_MIN} #define particle_ctrl_SetServerProtocolReply_init_zero {0} #define particle_ctrl_GetServerProtocolRequest_init_zero {0} -#define particle_ctrl_GetServerProtocolReply_init_zero {(particle_ctrl_ServerProtocolType)0} +#define particle_ctrl_GetServerProtocolReply_init_zero {_particle_ctrl_ServerProtocolType_MIN} #define particle_ctrl_SetSoftApSsidRequest_init_zero {"", ""} #define particle_ctrl_SetSoftApSsidReply_init_zero {0} #define particle_ctrl_StartListeningModeRequest_init_zero {0} @@ -385,19 +391,23 @@ typedef struct _particle_ctrl_SetStartupModeRequest { #define particle_ctrl_StopListeningModeRequest_init_zero {0} #define particle_ctrl_StopListeningModeReply_init_zero {0} #define particle_ctrl_GetDeviceModeRequest_init_zero {0} -#define particle_ctrl_GetDeviceModeReply_init_zero {(particle_ctrl_DeviceMode)0} +#define particle_ctrl_GetDeviceModeReply_init_zero {_particle_ctrl_DeviceMode_MIN} #define particle_ctrl_SetDeviceSetupDoneRequest_init_zero {0} #define particle_ctrl_SetDeviceSetupDoneReply_init_zero {0} #define particle_ctrl_IsDeviceSetupDoneRequest_init_zero {0} #define particle_ctrl_IsDeviceSetupDoneReply_init_zero {0} -#define particle_ctrl_SetStartupModeRequest_init_zero {(particle_ctrl_DeviceMode)0} +#define particle_ctrl_SetStartupModeRequest_init_zero {_particle_ctrl_DeviceMode_MIN} #define particle_ctrl_SetStartupModeReply_init_zero {0} #define particle_ctrl_SystemResetRequest_init_zero {0} #define particle_ctrl_SystemResetReply_init_zero {0} -#define particle_ctrl_SetFeatureRequest_init_zero {(particle_ctrl_Feature)0, 0} +#define particle_ctrl_SetFeatureRequest_init_zero {_particle_ctrl_Feature_MIN, 0} #define particle_ctrl_SetFeatureReply_init_zero {0} -#define particle_ctrl_GetFeatureRequest_init_zero {(particle_ctrl_Feature)0} +#define particle_ctrl_GetFeatureRequest_init_zero {_particle_ctrl_Feature_MIN} #define particle_ctrl_GetFeatureReply_init_zero {0} +#define particle_ctrl_StartNyanSignalRequest_init_zero {0} +#define particle_ctrl_StartNyanSignalReply_init_zero {0} +#define particle_ctrl_StopNyanSignalRequest_init_zero {0} +#define particle_ctrl_StopNyanSignalReply_init_zero {0} /* Field tags (for use in manual encoding/decoding) */ #define particle_ctrl_GetSecurityKeyReply_data_tag 1 @@ -432,112 +442,420 @@ typedef struct _particle_ctrl_SetStartupModeRequest { #define particle_ctrl_SetStartupModeRequest_mode_tag 1 /* Struct field encoding specification for nanopb */ -extern const pb_field_t particle_ctrl_GetDeviceIdRequest_fields[1]; -extern const pb_field_t particle_ctrl_GetDeviceIdReply_fields[2]; -extern const pb_field_t particle_ctrl_GetSerialNumberRequest_fields[1]; -extern const pb_field_t particle_ctrl_GetSerialNumberReply_fields[2]; -extern const pb_field_t particle_ctrl_GetSystemVersionRequest_fields[1]; -extern const pb_field_t particle_ctrl_GetSystemVersionReply_fields[2]; -extern const pb_field_t particle_ctrl_GetNcpFirmwareVersionRequest_fields[1]; -extern const pb_field_t particle_ctrl_GetNcpFirmwareVersionReply_fields[3]; -extern const pb_field_t particle_ctrl_GetSystemCapabilitiesRequest_fields[1]; -extern const pb_field_t particle_ctrl_GetSystemCapabilitiesReply_fields[2]; -extern const pb_field_t particle_ctrl_SetClaimCodeRequest_fields[2]; -extern const pb_field_t particle_ctrl_SetClaimCodeReply_fields[1]; -extern const pb_field_t particle_ctrl_IsClaimedRequest_fields[1]; -extern const pb_field_t particle_ctrl_IsClaimedReply_fields[2]; -extern const pb_field_t particle_ctrl_SetSecurityKeyRequest_fields[3]; -extern const pb_field_t particle_ctrl_SetSecurityKeyReply_fields[1]; -extern const pb_field_t particle_ctrl_GetSecurityKeyRequest_fields[2]; -extern const pb_field_t particle_ctrl_GetSecurityKeyReply_fields[2]; -extern const pb_field_t particle_ctrl_SetServerAddressRequest_fields[4]; -extern const pb_field_t particle_ctrl_SetServerAddressReply_fields[1]; -extern const pb_field_t particle_ctrl_GetServerAddressRequest_fields[2]; -extern const pb_field_t particle_ctrl_GetServerAddressReply_fields[3]; -extern const pb_field_t particle_ctrl_SetServerProtocolRequest_fields[2]; -extern const pb_field_t particle_ctrl_SetServerProtocolReply_fields[1]; -extern const pb_field_t particle_ctrl_GetServerProtocolRequest_fields[1]; -extern const pb_field_t particle_ctrl_GetServerProtocolReply_fields[2]; -extern const pb_field_t particle_ctrl_SetSoftApSsidRequest_fields[3]; -extern const pb_field_t particle_ctrl_SetSoftApSsidReply_fields[1]; -extern const pb_field_t particle_ctrl_StartListeningModeRequest_fields[1]; -extern const pb_field_t particle_ctrl_StartListeningModeReply_fields[1]; -extern const pb_field_t particle_ctrl_StopListeningModeRequest_fields[1]; -extern const pb_field_t particle_ctrl_StopListeningModeReply_fields[1]; -extern const pb_field_t particle_ctrl_GetDeviceModeRequest_fields[1]; -extern const pb_field_t particle_ctrl_GetDeviceModeReply_fields[2]; -extern const pb_field_t particle_ctrl_SetDeviceSetupDoneRequest_fields[2]; -extern const pb_field_t particle_ctrl_SetDeviceSetupDoneReply_fields[1]; -extern const pb_field_t particle_ctrl_IsDeviceSetupDoneRequest_fields[1]; -extern const pb_field_t particle_ctrl_IsDeviceSetupDoneReply_fields[2]; -extern const pb_field_t particle_ctrl_SetStartupModeRequest_fields[2]; -extern const pb_field_t particle_ctrl_SetStartupModeReply_fields[1]; -extern const pb_field_t particle_ctrl_SystemResetRequest_fields[1]; -extern const pb_field_t particle_ctrl_SystemResetReply_fields[1]; -extern const pb_field_t particle_ctrl_SetFeatureRequest_fields[3]; -extern const pb_field_t particle_ctrl_SetFeatureReply_fields[1]; -extern const pb_field_t particle_ctrl_GetFeatureRequest_fields[2]; -extern const pb_field_t particle_ctrl_GetFeatureReply_fields[2]; +#define particle_ctrl_GetDeviceIdRequest_FIELDLIST(X, a) \ + +#define particle_ctrl_GetDeviceIdRequest_CALLBACK NULL +#define particle_ctrl_GetDeviceIdRequest_DEFAULT NULL + +#define particle_ctrl_GetDeviceIdReply_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, STRING, id, 1) +#define particle_ctrl_GetDeviceIdReply_CALLBACK NULL +#define particle_ctrl_GetDeviceIdReply_DEFAULT NULL + +#define particle_ctrl_GetSerialNumberRequest_FIELDLIST(X, a) \ + +#define particle_ctrl_GetSerialNumberRequest_CALLBACK NULL +#define particle_ctrl_GetSerialNumberRequest_DEFAULT NULL + +#define particle_ctrl_GetSerialNumberReply_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, STRING, serial, 1) +#define particle_ctrl_GetSerialNumberReply_CALLBACK NULL +#define particle_ctrl_GetSerialNumberReply_DEFAULT NULL + +#define particle_ctrl_GetSystemVersionRequest_FIELDLIST(X, a) \ + +#define particle_ctrl_GetSystemVersionRequest_CALLBACK NULL +#define particle_ctrl_GetSystemVersionRequest_DEFAULT NULL + +#define particle_ctrl_GetSystemVersionReply_FIELDLIST(X, a) \ +X(a, CALLBACK, SINGULAR, STRING, version, 1) +#define particle_ctrl_GetSystemVersionReply_CALLBACK pb_default_field_callback +#define particle_ctrl_GetSystemVersionReply_DEFAULT NULL + +#define particle_ctrl_GetNcpFirmwareVersionRequest_FIELDLIST(X, a) \ + +#define particle_ctrl_GetNcpFirmwareVersionRequest_CALLBACK NULL +#define particle_ctrl_GetNcpFirmwareVersionRequest_DEFAULT NULL + +#define particle_ctrl_GetNcpFirmwareVersionReply_FIELDLIST(X, a) \ +X(a, CALLBACK, SINGULAR, STRING, version, 1) \ +X(a, STATIC, SINGULAR, UINT32, module_version, 2) +#define particle_ctrl_GetNcpFirmwareVersionReply_CALLBACK pb_default_field_callback +#define particle_ctrl_GetNcpFirmwareVersionReply_DEFAULT NULL + +#define particle_ctrl_GetSystemCapabilitiesRequest_FIELDLIST(X, a) \ + +#define particle_ctrl_GetSystemCapabilitiesRequest_CALLBACK NULL +#define particle_ctrl_GetSystemCapabilitiesRequest_DEFAULT NULL + +#define particle_ctrl_GetSystemCapabilitiesReply_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, FIXED32, flags, 1) +#define particle_ctrl_GetSystemCapabilitiesReply_CALLBACK NULL +#define particle_ctrl_GetSystemCapabilitiesReply_DEFAULT NULL + +#define particle_ctrl_SetClaimCodeRequest_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, STRING, code, 1) +#define particle_ctrl_SetClaimCodeRequest_CALLBACK NULL +#define particle_ctrl_SetClaimCodeRequest_DEFAULT NULL + +#define particle_ctrl_SetClaimCodeReply_FIELDLIST(X, a) \ + +#define particle_ctrl_SetClaimCodeReply_CALLBACK NULL +#define particle_ctrl_SetClaimCodeReply_DEFAULT NULL + +#define particle_ctrl_IsClaimedRequest_FIELDLIST(X, a) \ + +#define particle_ctrl_IsClaimedRequest_CALLBACK NULL +#define particle_ctrl_IsClaimedRequest_DEFAULT NULL + +#define particle_ctrl_IsClaimedReply_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, BOOL, claimed, 1) +#define particle_ctrl_IsClaimedReply_CALLBACK NULL +#define particle_ctrl_IsClaimedReply_DEFAULT NULL + +#define particle_ctrl_SetSecurityKeyRequest_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, type, 1) \ +X(a, CALLBACK, SINGULAR, BYTES, data, 2) +#define particle_ctrl_SetSecurityKeyRequest_CALLBACK pb_default_field_callback +#define particle_ctrl_SetSecurityKeyRequest_DEFAULT NULL + +#define particle_ctrl_SetSecurityKeyReply_FIELDLIST(X, a) \ + +#define particle_ctrl_SetSecurityKeyReply_CALLBACK NULL +#define particle_ctrl_SetSecurityKeyReply_DEFAULT NULL + +#define particle_ctrl_GetSecurityKeyRequest_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, type, 1) +#define particle_ctrl_GetSecurityKeyRequest_CALLBACK NULL +#define particle_ctrl_GetSecurityKeyRequest_DEFAULT NULL + +#define particle_ctrl_GetSecurityKeyReply_FIELDLIST(X, a) \ +X(a, CALLBACK, SINGULAR, BYTES, data, 1) +#define particle_ctrl_GetSecurityKeyReply_CALLBACK pb_default_field_callback +#define particle_ctrl_GetSecurityKeyReply_DEFAULT NULL + +#define particle_ctrl_SetServerAddressRequest_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, protocol, 1) \ +X(a, STATIC, SINGULAR, STRING, address, 2) \ +X(a, STATIC, SINGULAR, INT32, port, 3) +#define particle_ctrl_SetServerAddressRequest_CALLBACK NULL +#define particle_ctrl_SetServerAddressRequest_DEFAULT NULL + +#define particle_ctrl_SetServerAddressReply_FIELDLIST(X, a) \ + +#define particle_ctrl_SetServerAddressReply_CALLBACK NULL +#define particle_ctrl_SetServerAddressReply_DEFAULT NULL + +#define particle_ctrl_GetServerAddressRequest_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, protocol, 1) +#define particle_ctrl_GetServerAddressRequest_CALLBACK NULL +#define particle_ctrl_GetServerAddressRequest_DEFAULT NULL + +#define particle_ctrl_GetServerAddressReply_FIELDLIST(X, a) \ +X(a, CALLBACK, SINGULAR, STRING, address, 1) \ +X(a, STATIC, SINGULAR, INT32, port, 2) +#define particle_ctrl_GetServerAddressReply_CALLBACK pb_default_field_callback +#define particle_ctrl_GetServerAddressReply_DEFAULT NULL + +#define particle_ctrl_SetServerProtocolRequest_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, protocol, 1) +#define particle_ctrl_SetServerProtocolRequest_CALLBACK NULL +#define particle_ctrl_SetServerProtocolRequest_DEFAULT NULL + +#define particle_ctrl_SetServerProtocolReply_FIELDLIST(X, a) \ + +#define particle_ctrl_SetServerProtocolReply_CALLBACK NULL +#define particle_ctrl_SetServerProtocolReply_DEFAULT NULL + +#define particle_ctrl_GetServerProtocolRequest_FIELDLIST(X, a) \ + +#define particle_ctrl_GetServerProtocolRequest_CALLBACK NULL +#define particle_ctrl_GetServerProtocolRequest_DEFAULT NULL + +#define particle_ctrl_GetServerProtocolReply_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, protocol, 1) +#define particle_ctrl_GetServerProtocolReply_CALLBACK NULL +#define particle_ctrl_GetServerProtocolReply_DEFAULT NULL + +#define particle_ctrl_SetSoftApSsidRequest_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, STRING, prefix, 1) \ +X(a, STATIC, SINGULAR, STRING, suffix, 2) +#define particle_ctrl_SetSoftApSsidRequest_CALLBACK NULL +#define particle_ctrl_SetSoftApSsidRequest_DEFAULT NULL + +#define particle_ctrl_SetSoftApSsidReply_FIELDLIST(X, a) \ + +#define particle_ctrl_SetSoftApSsidReply_CALLBACK NULL +#define particle_ctrl_SetSoftApSsidReply_DEFAULT NULL + +#define particle_ctrl_StartListeningModeRequest_FIELDLIST(X, a) \ + +#define particle_ctrl_StartListeningModeRequest_CALLBACK NULL +#define particle_ctrl_StartListeningModeRequest_DEFAULT NULL + +#define particle_ctrl_StartListeningModeReply_FIELDLIST(X, a) \ + +#define particle_ctrl_StartListeningModeReply_CALLBACK NULL +#define particle_ctrl_StartListeningModeReply_DEFAULT NULL + +#define particle_ctrl_StopListeningModeRequest_FIELDLIST(X, a) \ + +#define particle_ctrl_StopListeningModeRequest_CALLBACK NULL +#define particle_ctrl_StopListeningModeRequest_DEFAULT NULL + +#define particle_ctrl_StopListeningModeReply_FIELDLIST(X, a) \ + +#define particle_ctrl_StopListeningModeReply_CALLBACK NULL +#define particle_ctrl_StopListeningModeReply_DEFAULT NULL + +#define particle_ctrl_GetDeviceModeRequest_FIELDLIST(X, a) \ + +#define particle_ctrl_GetDeviceModeRequest_CALLBACK NULL +#define particle_ctrl_GetDeviceModeRequest_DEFAULT NULL + +#define particle_ctrl_GetDeviceModeReply_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, mode, 1) +#define particle_ctrl_GetDeviceModeReply_CALLBACK NULL +#define particle_ctrl_GetDeviceModeReply_DEFAULT NULL + +#define particle_ctrl_SetDeviceSetupDoneRequest_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, BOOL, done, 1) +#define particle_ctrl_SetDeviceSetupDoneRequest_CALLBACK NULL +#define particle_ctrl_SetDeviceSetupDoneRequest_DEFAULT NULL + +#define particle_ctrl_SetDeviceSetupDoneReply_FIELDLIST(X, a) \ + +#define particle_ctrl_SetDeviceSetupDoneReply_CALLBACK NULL +#define particle_ctrl_SetDeviceSetupDoneReply_DEFAULT NULL + +#define particle_ctrl_IsDeviceSetupDoneRequest_FIELDLIST(X, a) \ + +#define particle_ctrl_IsDeviceSetupDoneRequest_CALLBACK NULL +#define particle_ctrl_IsDeviceSetupDoneRequest_DEFAULT NULL + +#define particle_ctrl_IsDeviceSetupDoneReply_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, BOOL, done, 1) +#define particle_ctrl_IsDeviceSetupDoneReply_CALLBACK NULL +#define particle_ctrl_IsDeviceSetupDoneReply_DEFAULT NULL + +#define particle_ctrl_SetStartupModeRequest_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, mode, 1) +#define particle_ctrl_SetStartupModeRequest_CALLBACK NULL +#define particle_ctrl_SetStartupModeRequest_DEFAULT NULL + +#define particle_ctrl_SetStartupModeReply_FIELDLIST(X, a) \ + +#define particle_ctrl_SetStartupModeReply_CALLBACK NULL +#define particle_ctrl_SetStartupModeReply_DEFAULT NULL + +#define particle_ctrl_SystemResetRequest_FIELDLIST(X, a) \ + +#define particle_ctrl_SystemResetRequest_CALLBACK NULL +#define particle_ctrl_SystemResetRequest_DEFAULT NULL + +#define particle_ctrl_SystemResetReply_FIELDLIST(X, a) \ + +#define particle_ctrl_SystemResetReply_CALLBACK NULL +#define particle_ctrl_SystemResetReply_DEFAULT NULL + +#define particle_ctrl_SetFeatureRequest_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, feature, 1) \ +X(a, STATIC, SINGULAR, BOOL, enabled, 2) +#define particle_ctrl_SetFeatureRequest_CALLBACK NULL +#define particle_ctrl_SetFeatureRequest_DEFAULT NULL + +#define particle_ctrl_SetFeatureReply_FIELDLIST(X, a) \ + +#define particle_ctrl_SetFeatureReply_CALLBACK NULL +#define particle_ctrl_SetFeatureReply_DEFAULT NULL + +#define particle_ctrl_GetFeatureRequest_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, feature, 1) +#define particle_ctrl_GetFeatureRequest_CALLBACK NULL +#define particle_ctrl_GetFeatureRequest_DEFAULT NULL + +#define particle_ctrl_GetFeatureReply_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, BOOL, enabled, 1) +#define particle_ctrl_GetFeatureReply_CALLBACK NULL +#define particle_ctrl_GetFeatureReply_DEFAULT NULL + +#define particle_ctrl_StartNyanSignalRequest_FIELDLIST(X, a) \ + +#define particle_ctrl_StartNyanSignalRequest_CALLBACK NULL +#define particle_ctrl_StartNyanSignalRequest_DEFAULT NULL + +#define particle_ctrl_StartNyanSignalReply_FIELDLIST(X, a) \ + +#define particle_ctrl_StartNyanSignalReply_CALLBACK NULL +#define particle_ctrl_StartNyanSignalReply_DEFAULT NULL + +#define particle_ctrl_StopNyanSignalRequest_FIELDLIST(X, a) \ + +#define particle_ctrl_StopNyanSignalRequest_CALLBACK NULL +#define particle_ctrl_StopNyanSignalRequest_DEFAULT NULL + +#define particle_ctrl_StopNyanSignalReply_FIELDLIST(X, a) \ + +#define particle_ctrl_StopNyanSignalReply_CALLBACK NULL +#define particle_ctrl_StopNyanSignalReply_DEFAULT NULL + +extern const pb_msgdesc_t particle_ctrl_GetDeviceIdRequest_msg; +extern const pb_msgdesc_t particle_ctrl_GetDeviceIdReply_msg; +extern const pb_msgdesc_t particle_ctrl_GetSerialNumberRequest_msg; +extern const pb_msgdesc_t particle_ctrl_GetSerialNumberReply_msg; +extern const pb_msgdesc_t particle_ctrl_GetSystemVersionRequest_msg; +extern const pb_msgdesc_t particle_ctrl_GetSystemVersionReply_msg; +extern const pb_msgdesc_t particle_ctrl_GetNcpFirmwareVersionRequest_msg; +extern const pb_msgdesc_t particle_ctrl_GetNcpFirmwareVersionReply_msg; +extern const pb_msgdesc_t particle_ctrl_GetSystemCapabilitiesRequest_msg; +extern const pb_msgdesc_t particle_ctrl_GetSystemCapabilitiesReply_msg; +extern const pb_msgdesc_t particle_ctrl_SetClaimCodeRequest_msg; +extern const pb_msgdesc_t particle_ctrl_SetClaimCodeReply_msg; +extern const pb_msgdesc_t particle_ctrl_IsClaimedRequest_msg; +extern const pb_msgdesc_t particle_ctrl_IsClaimedReply_msg; +extern const pb_msgdesc_t particle_ctrl_SetSecurityKeyRequest_msg; +extern const pb_msgdesc_t particle_ctrl_SetSecurityKeyReply_msg; +extern const pb_msgdesc_t particle_ctrl_GetSecurityKeyRequest_msg; +extern const pb_msgdesc_t particle_ctrl_GetSecurityKeyReply_msg; +extern const pb_msgdesc_t particle_ctrl_SetServerAddressRequest_msg; +extern const pb_msgdesc_t particle_ctrl_SetServerAddressReply_msg; +extern const pb_msgdesc_t particle_ctrl_GetServerAddressRequest_msg; +extern const pb_msgdesc_t particle_ctrl_GetServerAddressReply_msg; +extern const pb_msgdesc_t particle_ctrl_SetServerProtocolRequest_msg; +extern const pb_msgdesc_t particle_ctrl_SetServerProtocolReply_msg; +extern const pb_msgdesc_t particle_ctrl_GetServerProtocolRequest_msg; +extern const pb_msgdesc_t particle_ctrl_GetServerProtocolReply_msg; +extern const pb_msgdesc_t particle_ctrl_SetSoftApSsidRequest_msg; +extern const pb_msgdesc_t particle_ctrl_SetSoftApSsidReply_msg; +extern const pb_msgdesc_t particle_ctrl_StartListeningModeRequest_msg; +extern const pb_msgdesc_t particle_ctrl_StartListeningModeReply_msg; +extern const pb_msgdesc_t particle_ctrl_StopListeningModeRequest_msg; +extern const pb_msgdesc_t particle_ctrl_StopListeningModeReply_msg; +extern const pb_msgdesc_t particle_ctrl_GetDeviceModeRequest_msg; +extern const pb_msgdesc_t particle_ctrl_GetDeviceModeReply_msg; +extern const pb_msgdesc_t particle_ctrl_SetDeviceSetupDoneRequest_msg; +extern const pb_msgdesc_t particle_ctrl_SetDeviceSetupDoneReply_msg; +extern const pb_msgdesc_t particle_ctrl_IsDeviceSetupDoneRequest_msg; +extern const pb_msgdesc_t particle_ctrl_IsDeviceSetupDoneReply_msg; +extern const pb_msgdesc_t particle_ctrl_SetStartupModeRequest_msg; +extern const pb_msgdesc_t particle_ctrl_SetStartupModeReply_msg; +extern const pb_msgdesc_t particle_ctrl_SystemResetRequest_msg; +extern const pb_msgdesc_t particle_ctrl_SystemResetReply_msg; +extern const pb_msgdesc_t particle_ctrl_SetFeatureRequest_msg; +extern const pb_msgdesc_t particle_ctrl_SetFeatureReply_msg; +extern const pb_msgdesc_t particle_ctrl_GetFeatureRequest_msg; +extern const pb_msgdesc_t particle_ctrl_GetFeatureReply_msg; +extern const pb_msgdesc_t particle_ctrl_StartNyanSignalRequest_msg; +extern const pb_msgdesc_t particle_ctrl_StartNyanSignalReply_msg; +extern const pb_msgdesc_t particle_ctrl_StopNyanSignalRequest_msg; +extern const pb_msgdesc_t particle_ctrl_StopNyanSignalReply_msg; + +/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ +#define particle_ctrl_GetDeviceIdRequest_fields &particle_ctrl_GetDeviceIdRequest_msg +#define particle_ctrl_GetDeviceIdReply_fields &particle_ctrl_GetDeviceIdReply_msg +#define particle_ctrl_GetSerialNumberRequest_fields &particle_ctrl_GetSerialNumberRequest_msg +#define particle_ctrl_GetSerialNumberReply_fields &particle_ctrl_GetSerialNumberReply_msg +#define particle_ctrl_GetSystemVersionRequest_fields &particle_ctrl_GetSystemVersionRequest_msg +#define particle_ctrl_GetSystemVersionReply_fields &particle_ctrl_GetSystemVersionReply_msg +#define particle_ctrl_GetNcpFirmwareVersionRequest_fields &particle_ctrl_GetNcpFirmwareVersionRequest_msg +#define particle_ctrl_GetNcpFirmwareVersionReply_fields &particle_ctrl_GetNcpFirmwareVersionReply_msg +#define particle_ctrl_GetSystemCapabilitiesRequest_fields &particle_ctrl_GetSystemCapabilitiesRequest_msg +#define particle_ctrl_GetSystemCapabilitiesReply_fields &particle_ctrl_GetSystemCapabilitiesReply_msg +#define particle_ctrl_SetClaimCodeRequest_fields &particle_ctrl_SetClaimCodeRequest_msg +#define particle_ctrl_SetClaimCodeReply_fields &particle_ctrl_SetClaimCodeReply_msg +#define particle_ctrl_IsClaimedRequest_fields &particle_ctrl_IsClaimedRequest_msg +#define particle_ctrl_IsClaimedReply_fields &particle_ctrl_IsClaimedReply_msg +#define particle_ctrl_SetSecurityKeyRequest_fields &particle_ctrl_SetSecurityKeyRequest_msg +#define particle_ctrl_SetSecurityKeyReply_fields &particle_ctrl_SetSecurityKeyReply_msg +#define particle_ctrl_GetSecurityKeyRequest_fields &particle_ctrl_GetSecurityKeyRequest_msg +#define particle_ctrl_GetSecurityKeyReply_fields &particle_ctrl_GetSecurityKeyReply_msg +#define particle_ctrl_SetServerAddressRequest_fields &particle_ctrl_SetServerAddressRequest_msg +#define particle_ctrl_SetServerAddressReply_fields &particle_ctrl_SetServerAddressReply_msg +#define particle_ctrl_GetServerAddressRequest_fields &particle_ctrl_GetServerAddressRequest_msg +#define particle_ctrl_GetServerAddressReply_fields &particle_ctrl_GetServerAddressReply_msg +#define particle_ctrl_SetServerProtocolRequest_fields &particle_ctrl_SetServerProtocolRequest_msg +#define particle_ctrl_SetServerProtocolReply_fields &particle_ctrl_SetServerProtocolReply_msg +#define particle_ctrl_GetServerProtocolRequest_fields &particle_ctrl_GetServerProtocolRequest_msg +#define particle_ctrl_GetServerProtocolReply_fields &particle_ctrl_GetServerProtocolReply_msg +#define particle_ctrl_SetSoftApSsidRequest_fields &particle_ctrl_SetSoftApSsidRequest_msg +#define particle_ctrl_SetSoftApSsidReply_fields &particle_ctrl_SetSoftApSsidReply_msg +#define particle_ctrl_StartListeningModeRequest_fields &particle_ctrl_StartListeningModeRequest_msg +#define particle_ctrl_StartListeningModeReply_fields &particle_ctrl_StartListeningModeReply_msg +#define particle_ctrl_StopListeningModeRequest_fields &particle_ctrl_StopListeningModeRequest_msg +#define particle_ctrl_StopListeningModeReply_fields &particle_ctrl_StopListeningModeReply_msg +#define particle_ctrl_GetDeviceModeRequest_fields &particle_ctrl_GetDeviceModeRequest_msg +#define particle_ctrl_GetDeviceModeReply_fields &particle_ctrl_GetDeviceModeReply_msg +#define particle_ctrl_SetDeviceSetupDoneRequest_fields &particle_ctrl_SetDeviceSetupDoneRequest_msg +#define particle_ctrl_SetDeviceSetupDoneReply_fields &particle_ctrl_SetDeviceSetupDoneReply_msg +#define particle_ctrl_IsDeviceSetupDoneRequest_fields &particle_ctrl_IsDeviceSetupDoneRequest_msg +#define particle_ctrl_IsDeviceSetupDoneReply_fields &particle_ctrl_IsDeviceSetupDoneReply_msg +#define particle_ctrl_SetStartupModeRequest_fields &particle_ctrl_SetStartupModeRequest_msg +#define particle_ctrl_SetStartupModeReply_fields &particle_ctrl_SetStartupModeReply_msg +#define particle_ctrl_SystemResetRequest_fields &particle_ctrl_SystemResetRequest_msg +#define particle_ctrl_SystemResetReply_fields &particle_ctrl_SystemResetReply_msg +#define particle_ctrl_SetFeatureRequest_fields &particle_ctrl_SetFeatureRequest_msg +#define particle_ctrl_SetFeatureReply_fields &particle_ctrl_SetFeatureReply_msg +#define particle_ctrl_GetFeatureRequest_fields &particle_ctrl_GetFeatureRequest_msg +#define particle_ctrl_GetFeatureReply_fields &particle_ctrl_GetFeatureReply_msg +#define particle_ctrl_StartNyanSignalRequest_fields &particle_ctrl_StartNyanSignalRequest_msg +#define particle_ctrl_StartNyanSignalReply_fields &particle_ctrl_StartNyanSignalReply_msg +#define particle_ctrl_StopNyanSignalRequest_fields &particle_ctrl_StopNyanSignalRequest_msg +#define particle_ctrl_StopNyanSignalReply_fields &particle_ctrl_StopNyanSignalReply_msg /* Maximum encoded size of messages (where known) */ -#define particle_ctrl_GetDeviceIdRequest_size 0 -#define particle_ctrl_GetDeviceIdReply_size 26 -#define particle_ctrl_GetSerialNumberRequest_size 0 -#define particle_ctrl_GetSerialNumberReply_size 18 -#define particle_ctrl_GetSystemVersionRequest_size 0 /* particle_ctrl_GetSystemVersionReply_size depends on runtime parameters */ -#define particle_ctrl_GetNcpFirmwareVersionRequest_size 0 /* particle_ctrl_GetNcpFirmwareVersionReply_size depends on runtime parameters */ -#define particle_ctrl_GetSystemCapabilitiesRequest_size 0 +/* particle_ctrl_SetSecurityKeyRequest_size depends on runtime parameters */ +/* particle_ctrl_GetSecurityKeyReply_size depends on runtime parameters */ +/* particle_ctrl_GetServerAddressReply_size depends on runtime parameters */ +#define particle_ctrl_GetDeviceIdReply_size 25 +#define particle_ctrl_GetDeviceIdRequest_size 0 +#define particle_ctrl_GetDeviceModeReply_size 2 +#define particle_ctrl_GetDeviceModeRequest_size 0 +#define particle_ctrl_GetFeatureReply_size 2 +#define particle_ctrl_GetFeatureRequest_size 2 +#define particle_ctrl_GetNcpFirmwareVersionRequest_size 0 +#define particle_ctrl_GetSecurityKeyRequest_size 2 +#define particle_ctrl_GetSerialNumberReply_size 17 +#define particle_ctrl_GetSerialNumberRequest_size 0 +#define particle_ctrl_GetServerAddressRequest_size 2 +#define particle_ctrl_GetServerProtocolReply_size 2 +#define particle_ctrl_GetServerProtocolRequest_size 0 #define particle_ctrl_GetSystemCapabilitiesReply_size 5 -#define particle_ctrl_SetClaimCodeRequest_size 66 -#define particle_ctrl_SetClaimCodeReply_size 0 -#define particle_ctrl_IsClaimedRequest_size 0 +#define particle_ctrl_GetSystemCapabilitiesRequest_size 0 +#define particle_ctrl_GetSystemVersionRequest_size 0 #define particle_ctrl_IsClaimedReply_size 2 -/* particle_ctrl_SetSecurityKeyRequest_size depends on runtime parameters */ +#define particle_ctrl_IsClaimedRequest_size 0 +#define particle_ctrl_IsDeviceSetupDoneReply_size 2 +#define particle_ctrl_IsDeviceSetupDoneRequest_size 0 +#define particle_ctrl_SetClaimCodeReply_size 0 +#define particle_ctrl_SetClaimCodeRequest_size 65 +#define particle_ctrl_SetDeviceSetupDoneReply_size 0 +#define particle_ctrl_SetDeviceSetupDoneRequest_size 2 +#define particle_ctrl_SetFeatureReply_size 0 +#define particle_ctrl_SetFeatureRequest_size 4 #define particle_ctrl_SetSecurityKeyReply_size 0 -#define particle_ctrl_GetSecurityKeyRequest_size 2 -/* particle_ctrl_GetSecurityKeyReply_size depends on runtime parameters */ -#define particle_ctrl_SetServerAddressRequest_size 79 #define particle_ctrl_SetServerAddressReply_size 0 -#define particle_ctrl_GetServerAddressRequest_size 2 -/* particle_ctrl_GetServerAddressReply_size depends on runtime parameters */ -#define particle_ctrl_SetServerProtocolRequest_size 2 +#define particle_ctrl_SetServerAddressRequest_size 78 #define particle_ctrl_SetServerProtocolReply_size 0 -#define particle_ctrl_GetServerProtocolRequest_size 0 -#define particle_ctrl_GetServerProtocolReply_size 2 -#define particle_ctrl_SetSoftApSsidRequest_size 52 +#define particle_ctrl_SetServerProtocolRequest_size 2 #define particle_ctrl_SetSoftApSsidReply_size 0 -#define particle_ctrl_StartListeningModeRequest_size 0 +#define particle_ctrl_SetSoftApSsidRequest_size 50 +#define particle_ctrl_SetStartupModeReply_size 0 +#define particle_ctrl_SetStartupModeRequest_size 2 #define particle_ctrl_StartListeningModeReply_size 0 -#define particle_ctrl_StopListeningModeRequest_size 0 +#define particle_ctrl_StartListeningModeRequest_size 0 +#define particle_ctrl_StartNyanSignalReply_size 0 +#define particle_ctrl_StartNyanSignalRequest_size 0 #define particle_ctrl_StopListeningModeReply_size 0 -#define particle_ctrl_GetDeviceModeRequest_size 0 -#define particle_ctrl_GetDeviceModeReply_size 2 -#define particle_ctrl_SetDeviceSetupDoneRequest_size 2 -#define particle_ctrl_SetDeviceSetupDoneReply_size 0 -#define particle_ctrl_IsDeviceSetupDoneRequest_size 0 -#define particle_ctrl_IsDeviceSetupDoneReply_size 2 -#define particle_ctrl_SetStartupModeRequest_size 2 -#define particle_ctrl_SetStartupModeReply_size 0 -#define particle_ctrl_SystemResetRequest_size 0 +#define particle_ctrl_StopListeningModeRequest_size 0 +#define particle_ctrl_StopNyanSignalReply_size 0 +#define particle_ctrl_StopNyanSignalRequest_size 0 #define particle_ctrl_SystemResetReply_size 0 -#define particle_ctrl_SetFeatureRequest_size 4 -#define particle_ctrl_SetFeatureReply_size 0 -#define particle_ctrl_GetFeatureRequest_size 2 -#define particle_ctrl_GetFeatureReply_size 2 - -/* Message IDs (where set with "msgid" option) */ -#ifdef PB_MSGID - -#define CONFIG_MESSAGES \ - - -#endif +#define particle_ctrl_SystemResetRequest_size 0 #ifdef __cplusplus } /* extern "C" */ #endif -/* @@protoc_insertion_point(eof) */ #endif diff --git a/system/src/control/proto/control.pb.c b/system/src/control/proto/control.pb.c index 577e1cd7ac..56212b8979 100644 --- a/system/src/control/proto/control.pb.c +++ b/system/src/control/proto/control.pb.c @@ -1,14 +1,9 @@ /* Automatically generated nanopb constant definitions */ -/* Generated by nanopb-0.3.9 at Tue Dec 5 16:20:08 2017. */ +/* Generated by nanopb-0.4.5 */ #include "control.pb.h" - -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 +#if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif - - -/* @@protoc_insertion_point(eof) */ diff --git a/system/src/control/proto/control.pb.h b/system/src/control/proto/control.pb.h index 8ebb65d70a..26d377f666 100644 --- a/system/src/control/proto/control.pb.h +++ b/system/src/control/proto/control.pb.h @@ -1,20 +1,15 @@ /* Automatically generated nanopb header */ -/* Generated by nanopb-0.3.9 at Tue Dec 5 16:20:08 2017. */ +/* Generated by nanopb-0.4.5 */ #ifndef PB_PARTICLE_CTRL_CONTROL_PB_H_INCLUDED #define PB_PARTICLE_CTRL_CONTROL_PB_H_INCLUDED #include - #include "common.pb.h" - #include "wifi.pb.h" - #include "network.pb.h" - #include "config.pb.h" -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 +#if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif @@ -25,6 +20,5 @@ extern "C" { #ifdef __cplusplus } /* extern "C" */ #endif -/* @@protoc_insertion_point(eof) */ #endif diff --git a/system/src/control/proto/extensions.pb.c b/system/src/control/proto/extensions.pb.c index 5d449f0c88..aeb64f7567 100644 --- a/system/src/control/proto/extensions.pb.c +++ b/system/src/control/proto/extensions.pb.c @@ -1,16 +1,11 @@ /* Automatically generated nanopb constant definitions */ -/* Generated by nanopb-0.3.9 at Mon Jun 10 21:00:54 2019. */ +/* Generated by nanopb-0.4.5 */ #include "extensions.pb.h" - -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 +#if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif - - -/* @@protoc_insertion_point(eof) */ diff --git a/system/src/control/proto/extensions.pb.h b/system/src/control/proto/extensions.pb.h index 01ee030274..28c1fc6854 100644 --- a/system/src/control/proto/extensions.pb.h +++ b/system/src/control/proto/extensions.pb.h @@ -1,28 +1,26 @@ /* Automatically generated nanopb header */ -/* Generated by nanopb-0.3.9 at Mon Jun 10 21:00:54 2019. */ +/* Generated by nanopb-0.4.5 */ #ifndef PB_EXTENSIONS_PB_H_INCLUDED #define PB_EXTENSIONS_PB_H_INCLUDED #include -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 +#if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif -#ifdef __cplusplus -extern "C" { -#endif - /* Extensions */ /* Extension field type_id was skipped because only "optional" type of extension fields is currently supported. */ /* Extension field int_value was skipped because only "optional" type of extension fields is currently supported. */ +#ifdef __cplusplus +extern "C" { +#endif + #ifdef __cplusplus } /* extern "C" */ #endif -/* @@protoc_insertion_point(eof) */ #endif diff --git a/system/src/control/proto/internal.pb.c b/system/src/control/proto/internal.pb.c index b038e2df37..87f4305d56 100644 --- a/system/src/control/proto/internal.pb.c +++ b/system/src/control/proto/internal.pb.c @@ -1,58 +1,18 @@ /* Automatically generated nanopb constant definitions */ -/* Generated by nanopb-0.3.9 at Mon Jun 10 21:00:55 2019. */ +/* Generated by nanopb-0.4.5 */ #include "internal.pb.h" - -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 +#if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif +PB_BIND(particle_firmware_WifiConfig, particle_firmware_WifiConfig, AUTO) -const pb_field_t particle_firmware_WifiConfig_fields[2] = { - PB_FIELD( 1, MESSAGE , REPEATED, CALLBACK, FIRST, particle_firmware_WifiConfig, networks, networks, &particle_firmware_WifiConfig_Network_fields), - PB_LAST_FIELD -}; - -const pb_field_t particle_firmware_WifiConfig_Network_fields[5] = { - PB_FIELD( 1, STRING , SINGULAR, CALLBACK, FIRST, particle_firmware_WifiConfig_Network, ssid, ssid, 0), - PB_FIELD( 2, BYTES , SINGULAR, STATIC , OTHER, particle_firmware_WifiConfig_Network, bssid, ssid, 0), - PB_FIELD( 3, UENUM , SINGULAR, STATIC , OTHER, particle_firmware_WifiConfig_Network, security, bssid, 0), - PB_FIELD( 4, MESSAGE , SINGULAR, STATIC , OTHER, particle_firmware_WifiConfig_Network, credentials, security, &particle_ctrl_wifi_Credentials_fields), - PB_LAST_FIELD -}; - -const pb_field_t particle_firmware_CellularConfig_fields[4] = { - PB_FIELD( 1, MESSAGE , SINGULAR, STATIC , FIRST, particle_firmware_CellularConfig, internal_sim, internal_sim, &particle_ctrl_cellular_AccessPoint_fields), - PB_FIELD( 2, MESSAGE , SINGULAR, STATIC , OTHER, particle_firmware_CellularConfig, external_sim, internal_sim, &particle_ctrl_cellular_AccessPoint_fields), - PB_FIELD( 3, UENUM , SINGULAR, STATIC , OTHER, particle_firmware_CellularConfig, active_sim, external_sim, 0), - PB_LAST_FIELD -}; - - -/* Check that field information fits in pb_field_t */ -#if !defined(PB_FIELD_32BIT) -/* If you get an error here, it means that you need to define PB_FIELD_32BIT - * compile-time option. You can do that in pb.h or on compiler command line. - * - * The reason you need to do this is that some of your messages contain tag - * numbers or field sizes that are larger than what can fit in 8 or 16 bit - * field descriptors. - */ -PB_STATIC_ASSERT((pb_membersize(particle_firmware_WifiConfig_Network, credentials) < 65536 && pb_membersize(particle_firmware_CellularConfig, internal_sim) < 65536 && pb_membersize(particle_firmware_CellularConfig, external_sim) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_particle_firmware_WifiConfig_particle_firmware_WifiConfig_Network_particle_firmware_CellularConfig) -#endif +PB_BIND(particle_firmware_WifiConfig_Network, particle_firmware_WifiConfig_Network, AUTO) + + +PB_BIND(particle_firmware_CellularConfig, particle_firmware_CellularConfig, AUTO) -#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT) -/* If you get an error here, it means that you need to define PB_FIELD_16BIT - * compile-time option. You can do that in pb.h or on compiler command line. - * - * The reason you need to do this is that some of your messages contain tag - * numbers or field sizes that are larger than what can fit in the default - * 8 bit descriptors. - */ -PB_STATIC_ASSERT((pb_membersize(particle_firmware_WifiConfig_Network, credentials) < 256 && pb_membersize(particle_firmware_CellularConfig, internal_sim) < 256 && pb_membersize(particle_firmware_CellularConfig, external_sim) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_particle_firmware_WifiConfig_particle_firmware_WifiConfig_Network_particle_firmware_CellularConfig) -#endif -/* @@protoc_insertion_point(eof) */ diff --git a/system/src/control/proto/internal.pb.h b/system/src/control/proto/internal.pb.h index 5fcce87536..509bcd8728 100644 --- a/system/src/control/proto/internal.pb.h +++ b/system/src/control/proto/internal.pb.h @@ -1,56 +1,51 @@ /* Automatically generated nanopb header */ -/* Generated by nanopb-0.3.9 at Mon Jun 10 21:00:55 2019. */ +/* Generated by nanopb-0.4.5 */ #ifndef PB_PARTICLE_FIRMWARE_INTERNAL_PB_H_INCLUDED #define PB_PARTICLE_FIRMWARE_INTERNAL_PB_H_INCLUDED #include - #include "wifi_new.pb.h" - #include "cellular.pb.h" - #include "common.pb.h" -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 +#if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif -#ifdef __cplusplus -extern "C" { -#endif - /* Struct definitions */ -typedef struct _particle_firmware_WifiConfig { - pb_callback_t networks; -/* @@protoc_insertion_point(struct:particle_firmware_WifiConfig) */ +typedef struct _particle_firmware_WifiConfig { + pb_callback_t networks; } particle_firmware_WifiConfig; -typedef struct _particle_firmware_CellularConfig { - particle_ctrl_cellular_AccessPoint internal_sim; - particle_ctrl_cellular_AccessPoint external_sim; - particle_ctrl_cellular_SimType active_sim; -/* @@protoc_insertion_point(struct:particle_firmware_CellularConfig) */ +typedef struct _particle_firmware_CellularConfig { + bool has_internal_sim; + particle_ctrl_cellular_AccessPoint internal_sim; + bool has_external_sim; + particle_ctrl_cellular_AccessPoint external_sim; + particle_ctrl_cellular_SimType active_sim; } particle_firmware_CellularConfig; typedef PB_BYTES_ARRAY_T(6) particle_firmware_WifiConfig_Network_bssid_t; -typedef struct _particle_firmware_WifiConfig_Network { - pb_callback_t ssid; - particle_firmware_WifiConfig_Network_bssid_t bssid; - particle_ctrl_wifi_Security security; - particle_ctrl_wifi_Credentials credentials; -/* @@protoc_insertion_point(struct:particle_firmware_WifiConfig_Network) */ +typedef struct _particle_firmware_WifiConfig_Network { + pb_callback_t ssid; + particle_firmware_WifiConfig_Network_bssid_t bssid; + particle_ctrl_wifi_Security security; + bool has_credentials; + particle_ctrl_wifi_Credentials credentials; } particle_firmware_WifiConfig_Network; -/* Default values for struct fields */ + +#ifdef __cplusplus +extern "C" { +#endif /* Initializer values for message structs */ #define particle_firmware_WifiConfig_init_default {{{NULL}, NULL}} -#define particle_firmware_WifiConfig_Network_init_default {{{NULL}, NULL}, {0, {0}}, (particle_ctrl_wifi_Security)0, particle_ctrl_wifi_Credentials_init_default} -#define particle_firmware_CellularConfig_init_default {particle_ctrl_cellular_AccessPoint_init_default, particle_ctrl_cellular_AccessPoint_init_default, (particle_ctrl_cellular_SimType)0} +#define particle_firmware_WifiConfig_Network_init_default {{{NULL}, NULL}, {0, {0}}, _particle_ctrl_wifi_Security_MIN, false, particle_ctrl_wifi_Credentials_init_default} +#define particle_firmware_CellularConfig_init_default {false, particle_ctrl_cellular_AccessPoint_init_default, false, particle_ctrl_cellular_AccessPoint_init_default, _particle_ctrl_cellular_SimType_MIN} #define particle_firmware_WifiConfig_init_zero {{{NULL}, NULL}} -#define particle_firmware_WifiConfig_Network_init_zero {{{NULL}, NULL}, {0, {0}}, (particle_ctrl_wifi_Security)0, particle_ctrl_wifi_Credentials_init_zero} -#define particle_firmware_CellularConfig_init_zero {particle_ctrl_cellular_AccessPoint_init_zero, particle_ctrl_cellular_AccessPoint_init_zero, (particle_ctrl_cellular_SimType)0} +#define particle_firmware_WifiConfig_Network_init_zero {{{NULL}, NULL}, {0, {0}}, _particle_ctrl_wifi_Security_MIN, false, particle_ctrl_wifi_Credentials_init_zero} +#define particle_firmware_CellularConfig_init_zero {false, particle_ctrl_cellular_AccessPoint_init_zero, false, particle_ctrl_cellular_AccessPoint_init_zero, _particle_ctrl_cellular_SimType_MIN} /* Field tags (for use in manual encoding/decoding) */ #define particle_firmware_WifiConfig_networks_tag 1 @@ -63,26 +58,48 @@ typedef struct _particle_firmware_WifiConfig_Network { #define particle_firmware_WifiConfig_Network_credentials_tag 4 /* Struct field encoding specification for nanopb */ -extern const pb_field_t particle_firmware_WifiConfig_fields[2]; -extern const pb_field_t particle_firmware_WifiConfig_Network_fields[5]; -extern const pb_field_t particle_firmware_CellularConfig_fields[4]; +#define particle_firmware_WifiConfig_FIELDLIST(X, a) \ +X(a, CALLBACK, REPEATED, MESSAGE, networks, 1) +#define particle_firmware_WifiConfig_CALLBACK pb_default_field_callback +#define particle_firmware_WifiConfig_DEFAULT NULL +#define particle_firmware_WifiConfig_networks_MSGTYPE particle_firmware_WifiConfig_Network + +#define particle_firmware_WifiConfig_Network_FIELDLIST(X, a) \ +X(a, CALLBACK, SINGULAR, STRING, ssid, 1) \ +X(a, STATIC, SINGULAR, BYTES, bssid, 2) \ +X(a, STATIC, SINGULAR, UENUM, security, 3) \ +X(a, STATIC, OPTIONAL, MESSAGE, credentials, 4) +#define particle_firmware_WifiConfig_Network_CALLBACK pb_default_field_callback +#define particle_firmware_WifiConfig_Network_DEFAULT NULL +#define particle_firmware_WifiConfig_Network_credentials_MSGTYPE particle_ctrl_wifi_Credentials + +#define particle_firmware_CellularConfig_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, MESSAGE, internal_sim, 1) \ +X(a, STATIC, OPTIONAL, MESSAGE, external_sim, 2) \ +X(a, STATIC, SINGULAR, UENUM, active_sim, 3) +#define particle_firmware_CellularConfig_CALLBACK NULL +#define particle_firmware_CellularConfig_DEFAULT NULL +#define particle_firmware_CellularConfig_internal_sim_MSGTYPE particle_ctrl_cellular_AccessPoint +#define particle_firmware_CellularConfig_external_sim_MSGTYPE particle_ctrl_cellular_AccessPoint + +extern const pb_msgdesc_t particle_firmware_WifiConfig_msg; +extern const pb_msgdesc_t particle_firmware_WifiConfig_Network_msg; +extern const pb_msgdesc_t particle_firmware_CellularConfig_msg; + +/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ +#define particle_firmware_WifiConfig_fields &particle_firmware_WifiConfig_msg +#define particle_firmware_WifiConfig_Network_fields &particle_firmware_WifiConfig_Network_msg +#define particle_firmware_CellularConfig_fields &particle_firmware_CellularConfig_msg /* Maximum encoded size of messages (where known) */ /* particle_firmware_WifiConfig_size depends on runtime parameters */ /* particle_firmware_WifiConfig_Network_size depends on runtime parameters */ +#if defined(particle_ctrl_cellular_AccessPoint_size) && defined(particle_ctrl_cellular_AccessPoint_size) #define particle_firmware_CellularConfig_size (14 + particle_ctrl_cellular_AccessPoint_size + particle_ctrl_cellular_AccessPoint_size) - -/* Message IDs (where set with "msgid" option) */ -#ifdef PB_MSGID - -#define INTERNAL_MESSAGES \ - - #endif #ifdef __cplusplus } /* extern "C" */ #endif -/* @@protoc_insertion_point(eof) */ #endif diff --git a/system/src/control/proto/mesh.pb.c b/system/src/control/proto/mesh.pb.c index 8860cda96a..d7aa18f2e2 100644 --- a/system/src/control/proto/mesh.pb.c +++ b/system/src/control/proto/mesh.pb.c @@ -1,318 +1,143 @@ /* Automatically generated nanopb constant definitions */ -/* Generated by nanopb-0.3.9 at Mon Jun 10 21:00:55 2019. */ +/* Generated by nanopb-0.4.5 */ #include "mesh.pb.h" - -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 +#if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif +PB_BIND(particle_ctrl_mesh_NetworkInfo, particle_ctrl_mesh_NetworkInfo, AUTO) + + +PB_BIND(particle_ctrl_mesh_AuthRequest, particle_ctrl_mesh_AuthRequest, AUTO) + + +PB_BIND(particle_ctrl_mesh_AuthReply, particle_ctrl_mesh_AuthReply, AUTO) + + +PB_BIND(particle_ctrl_mesh_CreateNetworkRequest, particle_ctrl_mesh_CreateNetworkRequest, AUTO) + + +PB_BIND(particle_ctrl_mesh_CreateNetworkReply, particle_ctrl_mesh_CreateNetworkReply, AUTO) + + +PB_BIND(particle_ctrl_mesh_StartCommissionerRequest, particle_ctrl_mesh_StartCommissionerRequest, AUTO) + + +PB_BIND(particle_ctrl_mesh_StartCommissionerReply, particle_ctrl_mesh_StartCommissionerReply, AUTO) + + +PB_BIND(particle_ctrl_mesh_StopCommissionerRequest, particle_ctrl_mesh_StopCommissionerRequest, AUTO) + + +PB_BIND(particle_ctrl_mesh_StopCommissionerReply, particle_ctrl_mesh_StopCommissionerReply, AUTO) + + +PB_BIND(particle_ctrl_mesh_PrepareJoinerRequest, particle_ctrl_mesh_PrepareJoinerRequest, AUTO) + + +PB_BIND(particle_ctrl_mesh_PrepareJoinerReply, particle_ctrl_mesh_PrepareJoinerReply, AUTO) + + +PB_BIND(particle_ctrl_mesh_AddJoinerRequest, particle_ctrl_mesh_AddJoinerRequest, AUTO) + + +PB_BIND(particle_ctrl_mesh_AddJoinerReply, particle_ctrl_mesh_AddJoinerReply, AUTO) + + +PB_BIND(particle_ctrl_mesh_RemoveJoinerRequest, particle_ctrl_mesh_RemoveJoinerRequest, AUTO) + + +PB_BIND(particle_ctrl_mesh_RemoveJoinerReply, particle_ctrl_mesh_RemoveJoinerReply, AUTO) + + +PB_BIND(particle_ctrl_mesh_JoinNetworkRequest, particle_ctrl_mesh_JoinNetworkRequest, AUTO) + + +PB_BIND(particle_ctrl_mesh_JoinNetworkReply, particle_ctrl_mesh_JoinNetworkReply, AUTO) + + +PB_BIND(particle_ctrl_mesh_LeaveNetworkRequest, particle_ctrl_mesh_LeaveNetworkRequest, AUTO) + + +PB_BIND(particle_ctrl_mesh_LeaveNetworkReply, particle_ctrl_mesh_LeaveNetworkReply, AUTO) + + +PB_BIND(particle_ctrl_mesh_GetNetworkInfoRequest, particle_ctrl_mesh_GetNetworkInfoRequest, AUTO) + + +PB_BIND(particle_ctrl_mesh_GetNetworkInfoReply, particle_ctrl_mesh_GetNetworkInfoReply, AUTO) + + +PB_BIND(particle_ctrl_mesh_ScanNetworksRequest, particle_ctrl_mesh_ScanNetworksRequest, AUTO) + + +PB_BIND(particle_ctrl_mesh_ScanNetworksReply, particle_ctrl_mesh_ScanNetworksReply, AUTO) + + +PB_BIND(particle_ctrl_mesh_DiagnosticInfo, particle_ctrl_mesh_DiagnosticInfo, 2) + + +PB_BIND(particle_ctrl_mesh_DiagnosticInfo_Connectivity, particle_ctrl_mesh_DiagnosticInfo_Connectivity, AUTO) + + +PB_BIND(particle_ctrl_mesh_DiagnosticInfo_Route64, particle_ctrl_mesh_DiagnosticInfo_Route64, AUTO) + + +PB_BIND(particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData, particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData, AUTO) + + +PB_BIND(particle_ctrl_mesh_DiagnosticInfo_LeaderData, particle_ctrl_mesh_DiagnosticInfo_LeaderData, AUTO) + + +PB_BIND(particle_ctrl_mesh_DiagnosticInfo_NetworkData, particle_ctrl_mesh_DiagnosticInfo_NetworkData, AUTO) + + +PB_BIND(particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute, particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute, AUTO) + + +PB_BIND(particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry, particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry, AUTO) + + +PB_BIND(particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter, particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter, AUTO) + + +PB_BIND(particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry, particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry, AUTO) + + +PB_BIND(particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context, particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context, AUTO) + + +PB_BIND(particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix, particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix, AUTO) + + +PB_BIND(particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server, particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server, AUTO) + + +PB_BIND(particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service, particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service, AUTO) + + +PB_BIND(particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data, particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data, AUTO) + + +PB_BIND(particle_ctrl_mesh_DiagnosticInfo_MacCounters, particle_ctrl_mesh_DiagnosticInfo_MacCounters, AUTO) + + +PB_BIND(particle_ctrl_mesh_DiagnosticInfo_ChildTable, particle_ctrl_mesh_DiagnosticInfo_ChildTable, AUTO) + + +PB_BIND(particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry, particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry, AUTO) + + +PB_BIND(particle_ctrl_mesh_GetNetworkDiagnosticsRequest, particle_ctrl_mesh_GetNetworkDiagnosticsRequest, AUTO) + + +PB_BIND(particle_ctrl_mesh_GetNetworkDiagnosticsReply, particle_ctrl_mesh_GetNetworkDiagnosticsReply, AUTO) + + + -const pb_field_t particle_ctrl_mesh_NetworkInfo_fields[6] = { - PB_FIELD( 1, STRING , SINGULAR, CALLBACK, FIRST, particle_ctrl_mesh_NetworkInfo, name, name, 0), - PB_FIELD( 2, STRING , SINGULAR, CALLBACK, OTHER, particle_ctrl_mesh_NetworkInfo, ext_pan_id, name, 0), - PB_FIELD( 3, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_NetworkInfo, pan_id, ext_pan_id, 0), - PB_FIELD( 4, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_NetworkInfo, channel, pan_id, 0), - PB_FIELD( 5, STRING , SINGULAR, CALLBACK, OTHER, particle_ctrl_mesh_NetworkInfo, network_id, channel, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_AuthRequest_fields[2] = { - PB_FIELD( 1, STRING , SINGULAR, CALLBACK, FIRST, particle_ctrl_mesh_AuthRequest, password, password, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_AuthReply_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_CreateNetworkRequest_fields[5] = { - PB_FIELD( 1, STRING , SINGULAR, CALLBACK, FIRST, particle_ctrl_mesh_CreateNetworkRequest, name, name, 0), - PB_FIELD( 2, STRING , SINGULAR, CALLBACK, OTHER, particle_ctrl_mesh_CreateNetworkRequest, password, name, 0), - PB_FIELD( 3, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_CreateNetworkRequest, channel, password, 0), - PB_FIELD( 4, STRING , SINGULAR, CALLBACK, OTHER, particle_ctrl_mesh_CreateNetworkRequest, network_id, channel, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_CreateNetworkReply_fields[2] = { - PB_FIELD( 1, MESSAGE , SINGULAR, STATIC , FIRST, particle_ctrl_mesh_CreateNetworkReply, network, network, &particle_ctrl_mesh_NetworkInfo_fields), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_StartCommissionerRequest_fields[2] = { - PB_FIELD( 1, UINT32 , SINGULAR, STATIC , FIRST, particle_ctrl_mesh_StartCommissionerRequest, timeout, timeout, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_StartCommissionerReply_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_StopCommissionerRequest_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_StopCommissionerReply_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_PrepareJoinerRequest_fields[2] = { - PB_FIELD( 1, MESSAGE , SINGULAR, STATIC , FIRST, particle_ctrl_mesh_PrepareJoinerRequest, network, network, &particle_ctrl_mesh_NetworkInfo_fields), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_PrepareJoinerReply_fields[3] = { - PB_FIELD( 1, STRING , SINGULAR, CALLBACK, FIRST, particle_ctrl_mesh_PrepareJoinerReply, eui64, eui64, 0), - PB_FIELD( 2, STRING , SINGULAR, CALLBACK, OTHER, particle_ctrl_mesh_PrepareJoinerReply, password, eui64, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_AddJoinerRequest_fields[4] = { - PB_FIELD( 1, STRING , SINGULAR, CALLBACK, FIRST, particle_ctrl_mesh_AddJoinerRequest, eui64, eui64, 0), - PB_FIELD( 2, STRING , SINGULAR, CALLBACK, OTHER, particle_ctrl_mesh_AddJoinerRequest, password, eui64, 0), - PB_FIELD( 3, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_AddJoinerRequest, timeout, password, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_AddJoinerReply_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_RemoveJoinerRequest_fields[2] = { - PB_FIELD( 1, STRING , SINGULAR, CALLBACK, FIRST, particle_ctrl_mesh_RemoveJoinerRequest, eui64, eui64, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_RemoveJoinerReply_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_JoinNetworkRequest_fields[2] = { - PB_FIELD( 1, UINT32 , SINGULAR, STATIC , FIRST, particle_ctrl_mesh_JoinNetworkRequest, timeout, timeout, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_JoinNetworkReply_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_LeaveNetworkRequest_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_LeaveNetworkReply_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_GetNetworkInfoRequest_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_GetNetworkInfoReply_fields[2] = { - PB_FIELD( 1, MESSAGE , SINGULAR, STATIC , FIRST, particle_ctrl_mesh_GetNetworkInfoReply, network, network, &particle_ctrl_mesh_NetworkInfo_fields), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_ScanNetworksRequest_fields[2] = { - PB_FIELD( 1, UINT32 , SINGULAR, STATIC , FIRST, particle_ctrl_mesh_ScanNetworksRequest, duration, duration, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_ScanNetworksReply_fields[2] = { - PB_FIELD( 1, MESSAGE , REPEATED, CALLBACK, FIRST, particle_ctrl_mesh_ScanNetworksReply, networks, networks, &particle_ctrl_mesh_NetworkInfo_fields), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_DiagnosticInfo_fields[18] = { - PB_FIELD( 1, BYTES , SINGULAR, STATIC , FIRST, particle_ctrl_mesh_DiagnosticInfo, ext_mac_address, ext_mac_address, 0), - PB_FIELD( 2, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo, rloc, ext_mac_address, 0), - PB_FIELD( 3, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo, mode, rloc, 0), - PB_FIELD( 4, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo, timeout, mode, 0), - PB_FIELD( 5, MESSAGE , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo, connectivity, timeout, &particle_ctrl_mesh_DiagnosticInfo_Connectivity_fields), - PB_FIELD( 6, MESSAGE , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo, route64, connectivity, &particle_ctrl_mesh_DiagnosticInfo_Route64_fields), - PB_FIELD( 7, MESSAGE , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo, leader_data, route64, &particle_ctrl_mesh_DiagnosticInfo_LeaderData_fields), - PB_FIELD( 8, MESSAGE , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo, network_data, leader_data, &particle_ctrl_mesh_DiagnosticInfo_NetworkData_fields), - PB_FIELD( 9, MESSAGE , REPEATED, CALLBACK, OTHER, particle_ctrl_mesh_DiagnosticInfo, ipv6_address_list, network_data, &particle_ctrl_Ipv6Address_fields), - PB_FIELD( 10, MESSAGE , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo, mac_counters, ipv6_address_list, &particle_ctrl_mesh_DiagnosticInfo_MacCounters_fields), - PB_FIELD( 15, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo, battery_level, mac_counters, 0), - PB_FIELD( 16, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo, supply_voltage, battery_level, 0), - PB_FIELD( 17, MESSAGE , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo, child_table, supply_voltage, &particle_ctrl_mesh_DiagnosticInfo_ChildTable_fields), - PB_FIELD( 18, BYTES , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo, channel_pages, child_table, 0), - PB_FIELD( 19, UENUM , REPEATED, CALLBACK, OTHER, particle_ctrl_mesh_DiagnosticInfo, type_list, channel_pages, 0), - PB_FIELD( 20, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo, max_child_timeout, type_list, 0), - PB_FIELD(100, BYTES , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo, device_id, max_child_timeout, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_DiagnosticInfo_Connectivity_fields[10] = { - PB_FIELD( 1, UINT32 , SINGULAR, STATIC , FIRST, particle_ctrl_mesh_DiagnosticInfo_Connectivity, parent_priority, parent_priority, 0), - PB_FIELD( 2, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo_Connectivity, link_quality_1, parent_priority, 0), - PB_FIELD( 3, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo_Connectivity, link_quality_2, link_quality_1, 0), - PB_FIELD( 4, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo_Connectivity, link_quality_3, link_quality_2, 0), - PB_FIELD( 5, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo_Connectivity, leader_cost, link_quality_3, 0), - PB_FIELD( 6, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo_Connectivity, id_sequence, leader_cost, 0), - PB_FIELD( 7, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo_Connectivity, active_routers, id_sequence, 0), - PB_FIELD( 8, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo_Connectivity, sed_buffer_size, active_routers, 0), - PB_FIELD( 9, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo_Connectivity, sed_datagram_count, sed_buffer_size, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_DiagnosticInfo_Route64_fields[3] = { - PB_FIELD( 1, UINT32 , SINGULAR, STATIC , FIRST, particle_ctrl_mesh_DiagnosticInfo_Route64, id_sequence, id_sequence, 0), - PB_FIELD( 2, MESSAGE , REPEATED, CALLBACK, OTHER, particle_ctrl_mesh_DiagnosticInfo_Route64, routes, id_sequence, &particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData_fields), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData_fields[5] = { - PB_FIELD( 1, UINT32 , SINGULAR, STATIC , FIRST, particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData, router_rloc, router_rloc, 0), - PB_FIELD( 2, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData, link_quality_out, router_rloc, 0), - PB_FIELD( 3, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData, link_quality_in, link_quality_out, 0), - PB_FIELD( 4, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData, route_cost, link_quality_in, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_DiagnosticInfo_LeaderData_fields[6] = { - PB_FIELD( 1, UINT32 , SINGULAR, STATIC , FIRST, particle_ctrl_mesh_DiagnosticInfo_LeaderData, partition_id, partition_id, 0), - PB_FIELD( 2, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo_LeaderData, weighting, partition_id, 0), - PB_FIELD( 3, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo_LeaderData, data_version, weighting, 0), - PB_FIELD( 4, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo_LeaderData, stable_data_version, data_version, 0), - PB_FIELD( 5, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo_LeaderData, leader_rloc, stable_data_version, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_fields[3] = { - PB_FIELD( 1, MESSAGE , SINGULAR, STATIC , FIRST, particle_ctrl_mesh_DiagnosticInfo_NetworkData, stable, stable, &particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_fields), - PB_FIELD( 2, MESSAGE , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo_NetworkData, temporary, stable, &particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_fields), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_fields[2] = { - PB_FIELD( 1, MESSAGE , REPEATED, CALLBACK, FIRST, particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute, entries, entries, &particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry_fields), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry_fields[3] = { - PB_FIELD( 1, UINT32 , SINGULAR, STATIC , FIRST, particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry, rloc, rloc, 0), - PB_FIELD( 2, ENUM , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry, preference, rloc, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_fields[2] = { - PB_FIELD( 1, MESSAGE , REPEATED, CALLBACK, FIRST, particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter, entries, entries, &particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_fields), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_fields[4] = { - PB_FIELD( 1, UINT32 , SINGULAR, STATIC , FIRST, particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry, rloc, rloc, 0), - PB_FIELD( 2, ENUM , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry, preference, rloc, 0), - PB_FIELD( 3, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry, flags, preference, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context_fields[4] = { - PB_FIELD( 1, UINT32 , SINGULAR, STATIC , FIRST, particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context, cid, cid, 0), - PB_FIELD( 2, BOOL , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context, compress, cid, 0), - PB_FIELD( 3, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context, context_length, compress, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_fields[7] = { - PB_FIELD( 1, UINT32 , SINGULAR, STATIC , FIRST, particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix, domain_id, domain_id, 0), - PB_FIELD( 2, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix, prefix_length, domain_id, 0), - PB_FIELD( 3, BYTES , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix, prefix, prefix_length, 0), - PB_FIELD( 4, MESSAGE , REPEATED, CALLBACK, OTHER, particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix, context, prefix, &particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context_fields), - PB_FIELD( 5, MESSAGE , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix, has_route, context, &particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_fields), - PB_FIELD( 6, MESSAGE , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix, border_router, has_route, &particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_fields), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server_fields[3] = { - PB_FIELD( 1, UINT32 , SINGULAR, STATIC , FIRST, particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server, rloc, rloc, 0), - PB_FIELD( 2, BYTES , SINGULAR, CALLBACK, OTHER, particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server, data, rloc, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service_fields[5] = { - PB_FIELD( 1, UINT32 , SINGULAR, STATIC , FIRST, particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service, sid, sid, 0), - PB_FIELD( 2, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service, enterprise_number, sid, 0), - PB_FIELD( 3, BYTES , SINGULAR, CALLBACK, OTHER, particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service, data, enterprise_number, 0), - PB_FIELD( 4, MESSAGE , REPEATED, CALLBACK, OTHER, particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service, servers, data, &particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server_fields), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_fields[3] = { - PB_FIELD( 1, MESSAGE , REPEATED, CALLBACK, FIRST, particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data, prefixes, prefixes, &particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_fields), - PB_FIELD( 2, MESSAGE , REPEATED, CALLBACK, OTHER, particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data, services, prefixes, &particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service_fields), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_DiagnosticInfo_MacCounters_fields[10] = { - PB_FIELD( 1, UINT32 , SINGULAR, STATIC , FIRST, particle_ctrl_mesh_DiagnosticInfo_MacCounters, if_in_unknown_protos, if_in_unknown_protos, 0), - PB_FIELD( 2, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo_MacCounters, if_in_errors, if_in_unknown_protos, 0), - PB_FIELD( 3, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo_MacCounters, if_out_errors, if_in_errors, 0), - PB_FIELD( 4, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo_MacCounters, if_in_ucast_pkts, if_out_errors, 0), - PB_FIELD( 5, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo_MacCounters, if_in_broadcast_pkts, if_in_ucast_pkts, 0), - PB_FIELD( 6, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo_MacCounters, if_in_discards, if_in_broadcast_pkts, 0), - PB_FIELD( 7, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo_MacCounters, if_out_ucast_pkts, if_in_discards, 0), - PB_FIELD( 8, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo_MacCounters, if_out_broadcast_pkts, if_out_ucast_pkts, 0), - PB_FIELD( 9, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo_MacCounters, if_out_discards, if_out_broadcast_pkts, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_DiagnosticInfo_ChildTable_fields[2] = { - PB_FIELD( 1, MESSAGE , REPEATED, CALLBACK, FIRST, particle_ctrl_mesh_DiagnosticInfo_ChildTable, children, children, &particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry_fields), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry_fields[4] = { - PB_FIELD( 1, UINT32 , SINGULAR, STATIC , FIRST, particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry, timeout, timeout, 0), - PB_FIELD( 2, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry, child_id, timeout, 0), - PB_FIELD( 3, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry, mode, child_id, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_GetNetworkDiagnosticsRequest_fields[4] = { - PB_FIELD( 1, UINT32 , SINGULAR, STATIC , FIRST, particle_ctrl_mesh_GetNetworkDiagnosticsRequest, flags, flags, 0), - PB_FIELD( 2, UENUM , REPEATED, CALLBACK, OTHER, particle_ctrl_mesh_GetNetworkDiagnosticsRequest, diagnostic_types, flags, 0), - PB_FIELD( 3, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_mesh_GetNetworkDiagnosticsRequest, timeout, diagnostic_types, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_mesh_GetNetworkDiagnosticsReply_fields[2] = { - PB_FIELD( 1, MESSAGE , REPEATED, CALLBACK, FIRST, particle_ctrl_mesh_GetNetworkDiagnosticsReply, nodes, nodes, &particle_ctrl_mesh_DiagnosticInfo_fields), - PB_LAST_FIELD -}; - - - - - - - -/* Check that field information fits in pb_field_t */ -#if !defined(PB_FIELD_32BIT) -/* If you get an error here, it means that you need to define PB_FIELD_32BIT - * compile-time option. You can do that in pb.h or on compiler command line. - * - * The reason you need to do this is that some of your messages contain tag - * numbers or field sizes that are larger than what can fit in 8 or 16 bit - * field descriptors. - */ -PB_STATIC_ASSERT((pb_membersize(particle_ctrl_mesh_CreateNetworkReply, network) < 65536 && pb_membersize(particle_ctrl_mesh_PrepareJoinerRequest, network) < 65536 && pb_membersize(particle_ctrl_mesh_GetNetworkInfoReply, network) < 65536 && pb_membersize(particle_ctrl_mesh_DiagnosticInfo, connectivity) < 65536 && pb_membersize(particle_ctrl_mesh_DiagnosticInfo, route64) < 65536 && pb_membersize(particle_ctrl_mesh_DiagnosticInfo, leader_data) < 65536 && pb_membersize(particle_ctrl_mesh_DiagnosticInfo, network_data) < 65536 && pb_membersize(particle_ctrl_mesh_DiagnosticInfo, mac_counters) < 65536 && pb_membersize(particle_ctrl_mesh_DiagnosticInfo, child_table) < 65536 && pb_membersize(particle_ctrl_mesh_DiagnosticInfo_NetworkData, stable) < 65536 && pb_membersize(particle_ctrl_mesh_DiagnosticInfo_NetworkData, temporary) < 65536 && pb_membersize(particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix, has_route) < 65536 && pb_membersize(particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix, border_router) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_particle_ctrl_mesh_NetworkInfo_particle_ctrl_mesh_AuthRequest_particle_ctrl_mesh_AuthReply_particle_ctrl_mesh_CreateNetworkRequest_particle_ctrl_mesh_CreateNetworkReply_particle_ctrl_mesh_StartCommissionerRequest_particle_ctrl_mesh_StartCommissionerReply_particle_ctrl_mesh_StopCommissionerRequest_particle_ctrl_mesh_StopCommissionerReply_particle_ctrl_mesh_PrepareJoinerRequest_particle_ctrl_mesh_PrepareJoinerReply_particle_ctrl_mesh_AddJoinerRequest_particle_ctrl_mesh_AddJoinerReply_particle_ctrl_mesh_RemoveJoinerRequest_particle_ctrl_mesh_RemoveJoinerReply_particle_ctrl_mesh_JoinNetworkRequest_particle_ctrl_mesh_JoinNetworkReply_particle_ctrl_mesh_LeaveNetworkRequest_particle_ctrl_mesh_LeaveNetworkReply_particle_ctrl_mesh_GetNetworkInfoRequest_particle_ctrl_mesh_GetNetworkInfoReply_particle_ctrl_mesh_ScanNetworksRequest_particle_ctrl_mesh_ScanNetworksReply_particle_ctrl_mesh_DiagnosticInfo_particle_ctrl_mesh_DiagnosticInfo_Connectivity_particle_ctrl_mesh_DiagnosticInfo_Route64_particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData_particle_ctrl_mesh_DiagnosticInfo_LeaderData_particle_ctrl_mesh_DiagnosticInfo_NetworkData_particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry_particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context_particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server_particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service_particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_particle_ctrl_mesh_DiagnosticInfo_MacCounters_particle_ctrl_mesh_DiagnosticInfo_ChildTable_particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry_particle_ctrl_mesh_GetNetworkDiagnosticsRequest_particle_ctrl_mesh_GetNetworkDiagnosticsReply) -#endif -#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT) -/* If you get an error here, it means that you need to define PB_FIELD_16BIT - * compile-time option. You can do that in pb.h or on compiler command line. - * - * The reason you need to do this is that some of your messages contain tag - * numbers or field sizes that are larger than what can fit in the default - * 8 bit descriptors. - */ -PB_STATIC_ASSERT((pb_membersize(particle_ctrl_mesh_CreateNetworkReply, network) < 256 && pb_membersize(particle_ctrl_mesh_PrepareJoinerRequest, network) < 256 && pb_membersize(particle_ctrl_mesh_GetNetworkInfoReply, network) < 256 && pb_membersize(particle_ctrl_mesh_DiagnosticInfo, connectivity) < 256 && pb_membersize(particle_ctrl_mesh_DiagnosticInfo, route64) < 256 && pb_membersize(particle_ctrl_mesh_DiagnosticInfo, leader_data) < 256 && pb_membersize(particle_ctrl_mesh_DiagnosticInfo, network_data) < 256 && pb_membersize(particle_ctrl_mesh_DiagnosticInfo, mac_counters) < 256 && pb_membersize(particle_ctrl_mesh_DiagnosticInfo, child_table) < 256 && pb_membersize(particle_ctrl_mesh_DiagnosticInfo_NetworkData, stable) < 256 && pb_membersize(particle_ctrl_mesh_DiagnosticInfo_NetworkData, temporary) < 256 && pb_membersize(particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix, has_route) < 256 && pb_membersize(particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix, border_router) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_particle_ctrl_mesh_NetworkInfo_particle_ctrl_mesh_AuthRequest_particle_ctrl_mesh_AuthReply_particle_ctrl_mesh_CreateNetworkRequest_particle_ctrl_mesh_CreateNetworkReply_particle_ctrl_mesh_StartCommissionerRequest_particle_ctrl_mesh_StartCommissionerReply_particle_ctrl_mesh_StopCommissionerRequest_particle_ctrl_mesh_StopCommissionerReply_particle_ctrl_mesh_PrepareJoinerRequest_particle_ctrl_mesh_PrepareJoinerReply_particle_ctrl_mesh_AddJoinerRequest_particle_ctrl_mesh_AddJoinerReply_particle_ctrl_mesh_RemoveJoinerRequest_particle_ctrl_mesh_RemoveJoinerReply_particle_ctrl_mesh_JoinNetworkRequest_particle_ctrl_mesh_JoinNetworkReply_particle_ctrl_mesh_LeaveNetworkRequest_particle_ctrl_mesh_LeaveNetworkReply_particle_ctrl_mesh_GetNetworkInfoRequest_particle_ctrl_mesh_GetNetworkInfoReply_particle_ctrl_mesh_ScanNetworksRequest_particle_ctrl_mesh_ScanNetworksReply_particle_ctrl_mesh_DiagnosticInfo_particle_ctrl_mesh_DiagnosticInfo_Connectivity_particle_ctrl_mesh_DiagnosticInfo_Route64_particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData_particle_ctrl_mesh_DiagnosticInfo_LeaderData_particle_ctrl_mesh_DiagnosticInfo_NetworkData_particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry_particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context_particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server_particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service_particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_particle_ctrl_mesh_DiagnosticInfo_MacCounters_particle_ctrl_mesh_DiagnosticInfo_ChildTable_particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry_particle_ctrl_mesh_GetNetworkDiagnosticsRequest_particle_ctrl_mesh_GetNetworkDiagnosticsReply) -#endif -/* @@protoc_insertion_point(eof) */ diff --git a/system/src/control/proto/mesh.pb.h b/system/src/control/proto/mesh.pb.h index 9936d8d310..f6fbd0ed3d 100644 --- a/system/src/control/proto/mesh.pb.h +++ b/system/src/control/proto/mesh.pb.h @@ -1,395 +1,454 @@ /* Automatically generated nanopb header */ -/* Generated by nanopb-0.3.9 at Mon Jun 10 21:00:55 2019. */ +/* Generated by nanopb-0.4.5 */ #ifndef PB_PARTICLE_CTRL_MESH_MESH_PB_H_INCLUDED #define PB_PARTICLE_CTRL_MESH_MESH_PB_H_INCLUDED #include - #include "extensions.pb.h" - #include "common.pb.h" -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 +#if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif -#ifdef __cplusplus -extern "C" { -#endif - /* Enum definitions */ -typedef enum _particle_ctrl_mesh_DiagnosticType { - particle_ctrl_mesh_DiagnosticType_MAC_EXTENDED_ADDRESS = 0, - particle_ctrl_mesh_DiagnosticType_RLOC = 1, - particle_ctrl_mesh_DiagnosticType_MAC_ADDRESS = 1, - particle_ctrl_mesh_DiagnosticType_MODE = 2, - particle_ctrl_mesh_DiagnosticType_TIMEOUT = 3, - particle_ctrl_mesh_DiagnosticType_CONNECTIVITY = 4, - particle_ctrl_mesh_DiagnosticType_ROUTE64 = 5, - particle_ctrl_mesh_DiagnosticType_LEADER_DATA = 6, - particle_ctrl_mesh_DiagnosticType_NETWORK_DATA = 7, - particle_ctrl_mesh_DiagnosticType_IPV6_ADDRESS_LIST = 8, - particle_ctrl_mesh_DiagnosticType_MAC_COUNTERS = 9, - particle_ctrl_mesh_DiagnosticType_BATTERY_LEVEL = 14, - particle_ctrl_mesh_DiagnosticType_SUPPLY_VOLTAGE = 15, - particle_ctrl_mesh_DiagnosticType_CHILD_TABLE = 16, - particle_ctrl_mesh_DiagnosticType_CHANNEL_PAGES = 17, - particle_ctrl_mesh_DiagnosticType_TYPE_LIST = 18, - particle_ctrl_mesh_DiagnosticType_MAX_CHILD_TIMEOUT = 19 +typedef enum _particle_ctrl_mesh_DiagnosticType { + particle_ctrl_mesh_DiagnosticType_MAC_EXTENDED_ADDRESS = 0, + particle_ctrl_mesh_DiagnosticType_RLOC = 1, + particle_ctrl_mesh_DiagnosticType_MAC_ADDRESS = 1, + particle_ctrl_mesh_DiagnosticType_MODE = 2, + particle_ctrl_mesh_DiagnosticType_TIMEOUT = 3, + particle_ctrl_mesh_DiagnosticType_CONNECTIVITY = 4, + particle_ctrl_mesh_DiagnosticType_ROUTE64 = 5, + particle_ctrl_mesh_DiagnosticType_LEADER_DATA = 6, + particle_ctrl_mesh_DiagnosticType_NETWORK_DATA = 7, + particle_ctrl_mesh_DiagnosticType_IPV6_ADDRESS_LIST = 8, + particle_ctrl_mesh_DiagnosticType_MAC_COUNTERS = 9, + particle_ctrl_mesh_DiagnosticType_BATTERY_LEVEL = 14, + particle_ctrl_mesh_DiagnosticType_SUPPLY_VOLTAGE = 15, + particle_ctrl_mesh_DiagnosticType_CHILD_TABLE = 16, + particle_ctrl_mesh_DiagnosticType_CHANNEL_PAGES = 17, + particle_ctrl_mesh_DiagnosticType_TYPE_LIST = 18, + particle_ctrl_mesh_DiagnosticType_MAX_CHILD_TIMEOUT = 19 } particle_ctrl_mesh_DiagnosticType; -#define _particle_ctrl_mesh_DiagnosticType_MIN particle_ctrl_mesh_DiagnosticType_MAC_EXTENDED_ADDRESS -#define _particle_ctrl_mesh_DiagnosticType_MAX particle_ctrl_mesh_DiagnosticType_MAX_CHILD_TIMEOUT -#define _particle_ctrl_mesh_DiagnosticType_ARRAYSIZE ((particle_ctrl_mesh_DiagnosticType)(particle_ctrl_mesh_DiagnosticType_MAX_CHILD_TIMEOUT+1)) -typedef enum _particle_ctrl_mesh_DiagnosticInfo_Mode { - particle_ctrl_mesh_DiagnosticInfo_Mode_INVALID = 0, - particle_ctrl_mesh_DiagnosticInfo_Mode_RECEIVER_ON_WHEN_IDLE = 16, - particle_ctrl_mesh_DiagnosticInfo_Mode_SECURE_DATA_REQUESTS = 32, - particle_ctrl_mesh_DiagnosticInfo_Mode_DEVICE_TYPE = 48, - particle_ctrl_mesh_DiagnosticInfo_Mode_DEVICE_TYPE_FTD = 48, - particle_ctrl_mesh_DiagnosticInfo_Mode_NETWORK_DATA = 64, - particle_ctrl_mesh_DiagnosticInfo_Mode_NETWORK_DATA_FULL = 64 +typedef enum _particle_ctrl_mesh_DiagnosticInfo_Mode { + particle_ctrl_mesh_DiagnosticInfo_Mode_INVALID = 0, + particle_ctrl_mesh_DiagnosticInfo_Mode_RECEIVER_ON_WHEN_IDLE = 16, + particle_ctrl_mesh_DiagnosticInfo_Mode_SECURE_DATA_REQUESTS = 32, + particle_ctrl_mesh_DiagnosticInfo_Mode_DEVICE_TYPE = 48, + particle_ctrl_mesh_DiagnosticInfo_Mode_DEVICE_TYPE_FTD = 48, + particle_ctrl_mesh_DiagnosticInfo_Mode_NETWORK_DATA = 64, + particle_ctrl_mesh_DiagnosticInfo_Mode_NETWORK_DATA_FULL = 64 } particle_ctrl_mesh_DiagnosticInfo_Mode; -#define _particle_ctrl_mesh_DiagnosticInfo_Mode_MIN particle_ctrl_mesh_DiagnosticInfo_Mode_INVALID -#define _particle_ctrl_mesh_DiagnosticInfo_Mode_MAX particle_ctrl_mesh_DiagnosticInfo_Mode_NETWORK_DATA_FULL -#define _particle_ctrl_mesh_DiagnosticInfo_Mode_ARRAYSIZE ((particle_ctrl_mesh_DiagnosticInfo_Mode)(particle_ctrl_mesh_DiagnosticInfo_Mode_NETWORK_DATA_FULL+1)) -typedef enum _particle_ctrl_mesh_DiagnosticInfo_RoutePreference { - particle_ctrl_mesh_DiagnosticInfo_RoutePreference_MEDIUM = 0, - particle_ctrl_mesh_DiagnosticInfo_RoutePreference_HIGH = 1, - particle_ctrl_mesh_DiagnosticInfo_RoutePreference_LOW = -1 +typedef enum _particle_ctrl_mesh_DiagnosticInfo_RoutePreference { + particle_ctrl_mesh_DiagnosticInfo_RoutePreference_MEDIUM = 0, + particle_ctrl_mesh_DiagnosticInfo_RoutePreference_HIGH = 1, + particle_ctrl_mesh_DiagnosticInfo_RoutePreference_LOW = -1 } particle_ctrl_mesh_DiagnosticInfo_RoutePreference; -#define _particle_ctrl_mesh_DiagnosticInfo_RoutePreference_MIN particle_ctrl_mesh_DiagnosticInfo_RoutePreference_MEDIUM -#define _particle_ctrl_mesh_DiagnosticInfo_RoutePreference_MAX particle_ctrl_mesh_DiagnosticInfo_RoutePreference_LOW -#define _particle_ctrl_mesh_DiagnosticInfo_RoutePreference_ARRAYSIZE ((particle_ctrl_mesh_DiagnosticInfo_RoutePreference)(particle_ctrl_mesh_DiagnosticInfo_RoutePreference_LOW+1)) - -typedef enum _particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags { - particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_NONE = 0, - particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_PREFERRED = 1, - particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_SLAAC = 2, - particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_DHCP = 4, - particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_CONFIGURE = 8, - particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_DEFAULT_ROUTE = 16, - particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_ON_MESH = 32, - particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_ND_DNS = 64 + +typedef enum _particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags { + particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_NONE = 0, + particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_PREFERRED = 1, + particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_SLAAC = 2, + particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_DHCP = 4, + particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_CONFIGURE = 8, + particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_DEFAULT_ROUTE = 16, + particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_ON_MESH = 32, + particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_ND_DNS = 64 } particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags; -#define _particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_MIN particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_NONE -#define _particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_MAX particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_ND_DNS -#define _particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_ARRAYSIZE ((particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags)(particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_ND_DNS+1)) -typedef enum _particle_ctrl_mesh_GetNetworkDiagnosticsRequest_Flags { - particle_ctrl_mesh_GetNetworkDiagnosticsRequest_Flags_INVALID = 0, - particle_ctrl_mesh_GetNetworkDiagnosticsRequest_Flags_QUERY_CHILDREN = 1, - particle_ctrl_mesh_GetNetworkDiagnosticsRequest_Flags_RESOLVE_DEVICE_ID = 2 +typedef enum _particle_ctrl_mesh_GetNetworkDiagnosticsRequest_Flags { + particle_ctrl_mesh_GetNetworkDiagnosticsRequest_Flags_INVALID = 0, + particle_ctrl_mesh_GetNetworkDiagnosticsRequest_Flags_QUERY_CHILDREN = 1, + particle_ctrl_mesh_GetNetworkDiagnosticsRequest_Flags_RESOLVE_DEVICE_ID = 2 } particle_ctrl_mesh_GetNetworkDiagnosticsRequest_Flags; -#define _particle_ctrl_mesh_GetNetworkDiagnosticsRequest_Flags_MIN particle_ctrl_mesh_GetNetworkDiagnosticsRequest_Flags_INVALID -#define _particle_ctrl_mesh_GetNetworkDiagnosticsRequest_Flags_MAX particle_ctrl_mesh_GetNetworkDiagnosticsRequest_Flags_RESOLVE_DEVICE_ID -#define _particle_ctrl_mesh_GetNetworkDiagnosticsRequest_Flags_ARRAYSIZE ((particle_ctrl_mesh_GetNetworkDiagnosticsRequest_Flags)(particle_ctrl_mesh_GetNetworkDiagnosticsRequest_Flags_RESOLVE_DEVICE_ID+1)) /* Struct definitions */ -typedef struct _particle_ctrl_mesh_AddJoinerReply { +/* Result codes: + NO_MEMORY: No memory available to add the joiner + INVALID_STATE: The commissioner role is not started + NOT_ALLOWED: The client is not authenticated */ +typedef struct _particle_ctrl_mesh_AddJoinerReply { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_AddJoinerReply) */ } particle_ctrl_mesh_AddJoinerReply; -typedef struct _particle_ctrl_mesh_AuthReply { +/* Result codes: + NOT_FOUND: The device is not a member of a network + NOT_ALLOWED: Invalid commissioning credential */ +typedef struct _particle_ctrl_mesh_AuthReply { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_AuthReply) */ } particle_ctrl_mesh_AuthReply; -typedef struct _particle_ctrl_mesh_AuthRequest { - pb_callback_t password; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_AuthRequest) */ +/* Authenticate the client as a commissioner */ +typedef struct _particle_ctrl_mesh_AuthRequest { + /* Commissioning credential */ + pb_callback_t password; } particle_ctrl_mesh_AuthRequest; -typedef struct _particle_ctrl_mesh_DiagnosticInfo_ChildTable { - pb_callback_t children; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_DiagnosticInfo_ChildTable) */ +typedef struct _particle_ctrl_mesh_DiagnosticInfo_ChildTable { + pb_callback_t children; } particle_ctrl_mesh_DiagnosticInfo_ChildTable; -typedef struct _particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter { - pb_callback_t entries; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter) */ +typedef struct _particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter { + pb_callback_t entries; } particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter; -typedef struct _particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data { - pb_callback_t prefixes; - pb_callback_t services; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data) */ +typedef struct _particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data { + pb_callback_t prefixes; + pb_callback_t services; } particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data; -typedef struct _particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute { - pb_callback_t entries; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute) */ +typedef struct _particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute { + pb_callback_t entries; } particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute; -typedef struct _particle_ctrl_mesh_GetNetworkDiagnosticsReply { - pb_callback_t nodes; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_GetNetworkDiagnosticsReply) */ +typedef struct _particle_ctrl_mesh_GetNetworkDiagnosticsReply { + pb_callback_t nodes; } particle_ctrl_mesh_GetNetworkDiagnosticsReply; -typedef struct _particle_ctrl_mesh_GetNetworkInfoRequest { +/* Get the info about current network */ +typedef struct _particle_ctrl_mesh_GetNetworkInfoRequest { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_GetNetworkInfoRequest) */ } particle_ctrl_mesh_GetNetworkInfoRequest; -typedef struct _particle_ctrl_mesh_JoinNetworkReply { +/* Result codes: + NOT_FOUND: No joinable network was found + TIMEOUT: The join process timed out + NOT_ALLOWED: Invalid security credentials */ +typedef struct _particle_ctrl_mesh_JoinNetworkReply { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_JoinNetworkReply) */ } particle_ctrl_mesh_JoinNetworkReply; -typedef struct _particle_ctrl_mesh_LeaveNetworkReply { +/* Result codes: + NOT_FOUND: The device is not a member of a network + NOT_ALLOWED: The client is not authenticated */ +typedef struct _particle_ctrl_mesh_LeaveNetworkReply { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_LeaveNetworkReply) */ } particle_ctrl_mesh_LeaveNetworkReply; -typedef struct _particle_ctrl_mesh_LeaveNetworkRequest { +/* Leave the network */ +typedef struct _particle_ctrl_mesh_LeaveNetworkRequest { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_LeaveNetworkRequest) */ } particle_ctrl_mesh_LeaveNetworkRequest; -typedef struct _particle_ctrl_mesh_PrepareJoinerReply { - pb_callback_t eui64; - pb_callback_t password; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_PrepareJoinerReply) */ +/* Result codes: + ALREADY_EXIST: The device is already a member of a network + NOT_ALLOWED: The client is not authenticated */ +typedef struct _particle_ctrl_mesh_PrepareJoinerReply { + /* EUI-64 */ + pb_callback_t eui64; + /* Newly generated joining device credential */ + pb_callback_t password; } particle_ctrl_mesh_PrepareJoinerReply; -typedef struct _particle_ctrl_mesh_RemoveJoinerReply { +/* Result codes: + NOT_FOUND: The joiner was not found + INVALID_STATE: The commissioner role is not started + NOT_ALLOWED: The client is not authenticated */ +typedef struct _particle_ctrl_mesh_RemoveJoinerReply { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_RemoveJoinerReply) */ } particle_ctrl_mesh_RemoveJoinerReply; -typedef struct _particle_ctrl_mesh_RemoveJoinerRequest { - pb_callback_t eui64; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_RemoveJoinerRequest) */ +/* Remove the joiner device */ +typedef struct _particle_ctrl_mesh_RemoveJoinerRequest { + /* EUI-64 of the joiner device */ + pb_callback_t eui64; } particle_ctrl_mesh_RemoveJoinerRequest; -typedef struct _particle_ctrl_mesh_ScanNetworksReply { - pb_callback_t networks; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_ScanNetworksReply) */ +typedef struct _particle_ctrl_mesh_ScanNetworksReply { + pb_callback_t networks; } particle_ctrl_mesh_ScanNetworksReply; -typedef struct _particle_ctrl_mesh_StartCommissionerReply { +/* Result codes: + NOT_ALLOWED: The client is not authenticated */ +typedef struct _particle_ctrl_mesh_StartCommissionerReply { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_StartCommissionerReply) */ } particle_ctrl_mesh_StartCommissionerReply; -typedef struct _particle_ctrl_mesh_StopCommissionerReply { +/* Result codes: + NOT_ALLOWED: The client is not authenticated */ +typedef struct _particle_ctrl_mesh_StopCommissionerReply { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_StopCommissionerReply) */ } particle_ctrl_mesh_StopCommissionerReply; -typedef struct _particle_ctrl_mesh_StopCommissionerRequest { +/* Stop the commissioner role */ +typedef struct _particle_ctrl_mesh_StopCommissionerRequest { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_StopCommissionerRequest) */ } particle_ctrl_mesh_StopCommissionerRequest; -typedef struct _particle_ctrl_mesh_AddJoinerRequest { - pb_callback_t eui64; - pb_callback_t password; - uint32_t timeout; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_AddJoinerRequest) */ +/* Add a joiner device */ +typedef struct _particle_ctrl_mesh_AddJoinerRequest { + /* EUI-64 of the joiner device */ + pb_callback_t eui64; + /* Joining device credential */ + pb_callback_t password; + /* Time is seconds after which the joiner is automatically removed from the commissioner dataset */ + uint32_t timeout; } particle_ctrl_mesh_AddJoinerRequest; -typedef struct _particle_ctrl_mesh_CreateNetworkRequest { - pb_callback_t name; - pb_callback_t password; - uint32_t channel; - pb_callback_t network_id; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_CreateNetworkRequest) */ +/* Create a new network */ +typedef struct _particle_ctrl_mesh_CreateNetworkRequest { + /* Network name */ + pb_callback_t name; + /* Commissioning credential for this network */ + pb_callback_t password; + /* Channel number */ + uint32_t channel; + /* Network ID */ + pb_callback_t network_id; } particle_ctrl_mesh_CreateNetworkRequest; -typedef struct _particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry { - uint32_t timeout; - uint32_t child_id; - uint32_t mode; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry) */ +typedef struct _particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry { + uint32_t timeout; + uint32_t child_id; + uint32_t mode; } particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry; -typedef struct _particle_ctrl_mesh_DiagnosticInfo_Connectivity { - uint32_t parent_priority; - uint32_t link_quality_1; - uint32_t link_quality_2; - uint32_t link_quality_3; - uint32_t leader_cost; - uint32_t id_sequence; - uint32_t active_routers; - uint32_t sed_buffer_size; - uint32_t sed_datagram_count; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_DiagnosticInfo_Connectivity) */ +typedef struct _particle_ctrl_mesh_DiagnosticInfo_Connectivity { + /* Bitmask of Flags */ + uint32_t parent_priority; + /* List of DiagnosticType to request */ + uint32_t link_quality_1; + /* Maximum time in seconds to wait for diagnostic replies */ + uint32_t link_quality_2; + uint32_t link_quality_3; + uint32_t leader_cost; + uint32_t id_sequence; + uint32_t active_routers; + uint32_t sed_buffer_size; + uint32_t sed_datagram_count; } particle_ctrl_mesh_DiagnosticInfo_Connectivity; -typedef struct _particle_ctrl_mesh_DiagnosticInfo_LeaderData { - uint32_t partition_id; - uint32_t weighting; - uint32_t data_version; - uint32_t stable_data_version; - uint32_t leader_rloc; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_DiagnosticInfo_LeaderData) */ +typedef struct _particle_ctrl_mesh_DiagnosticInfo_LeaderData { + uint32_t partition_id; + uint32_t weighting; + uint32_t data_version; + uint32_t stable_data_version; + uint32_t leader_rloc; } particle_ctrl_mesh_DiagnosticInfo_LeaderData; -typedef struct _particle_ctrl_mesh_DiagnosticInfo_MacCounters { - uint32_t if_in_unknown_protos; - uint32_t if_in_errors; - uint32_t if_out_errors; - uint32_t if_in_ucast_pkts; - uint32_t if_in_broadcast_pkts; - uint32_t if_in_discards; - uint32_t if_out_ucast_pkts; - uint32_t if_out_broadcast_pkts; - uint32_t if_out_discards; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_DiagnosticInfo_MacCounters) */ +typedef struct _particle_ctrl_mesh_DiagnosticInfo_MacCounters { + uint32_t if_in_unknown_protos; + uint32_t if_in_errors; + uint32_t if_out_errors; + uint32_t if_in_ucast_pkts; + uint32_t if_in_broadcast_pkts; + uint32_t if_in_discards; + uint32_t if_out_ucast_pkts; + uint32_t if_out_broadcast_pkts; + uint32_t if_out_discards; } particle_ctrl_mesh_DiagnosticInfo_MacCounters; -typedef struct _particle_ctrl_mesh_DiagnosticInfo_NetworkData { - particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data stable; - particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data temporary; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_DiagnosticInfo_NetworkData) */ +typedef struct _particle_ctrl_mesh_DiagnosticInfo_NetworkData { + bool has_stable; + particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data stable; + bool has_temporary; + particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data temporary; } particle_ctrl_mesh_DiagnosticInfo_NetworkData; -typedef struct _particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry { - uint32_t rloc; - particle_ctrl_mesh_DiagnosticInfo_RoutePreference preference; - uint32_t flags; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry) */ +typedef struct _particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry { + uint32_t rloc; + particle_ctrl_mesh_DiagnosticInfo_RoutePreference preference; + uint32_t flags; } particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry; -typedef struct _particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context { - uint32_t cid; - bool compress; - uint32_t context_length; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context) */ +typedef struct _particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context { + uint32_t cid; + bool compress; + uint32_t context_length; } particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context; -typedef struct _particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry { - uint32_t rloc; - particle_ctrl_mesh_DiagnosticInfo_RoutePreference preference; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry) */ +typedef struct _particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry { + uint32_t rloc; + particle_ctrl_mesh_DiagnosticInfo_RoutePreference preference; } particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry; typedef PB_BYTES_ARRAY_T(16) particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_prefix_t; -typedef struct _particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix { - uint32_t domain_id; - uint32_t prefix_length; - particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_prefix_t prefix; - pb_callback_t context; - particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute has_route; - particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter border_router; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix) */ +typedef struct _particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix { + uint32_t domain_id; + uint32_t prefix_length; + particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_prefix_t prefix; + pb_callback_t context; + bool has_has_route; + particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute has_route; + bool has_border_router; + particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter border_router; } particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix; -typedef struct _particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server { - uint32_t rloc; - pb_callback_t data; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server) */ +typedef struct _particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server { + uint32_t rloc; + pb_callback_t data; } particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server; -typedef struct _particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service { - uint32_t sid; - uint32_t enterprise_number; - pb_callback_t data; - pb_callback_t servers; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service) */ +typedef struct _particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service { + uint32_t sid; + uint32_t enterprise_number; + pb_callback_t data; + pb_callback_t servers; } particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service; -typedef struct _particle_ctrl_mesh_DiagnosticInfo_Route64 { - uint32_t id_sequence; - pb_callback_t routes; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_DiagnosticInfo_Route64) */ +typedef struct _particle_ctrl_mesh_DiagnosticInfo_Route64 { + uint32_t id_sequence; + pb_callback_t routes; } particle_ctrl_mesh_DiagnosticInfo_Route64; -typedef struct _particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData { - uint32_t router_rloc; - uint32_t link_quality_out; - uint32_t link_quality_in; - uint32_t route_cost; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData) */ +typedef struct _particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData { + uint32_t router_rloc; + uint32_t link_quality_out; + uint32_t link_quality_in; + uint32_t route_cost; } particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData; -typedef struct _particle_ctrl_mesh_GetNetworkDiagnosticsRequest { - uint32_t flags; - pb_callback_t diagnostic_types; - uint32_t timeout; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_GetNetworkDiagnosticsRequest) */ +typedef struct _particle_ctrl_mesh_GetNetworkDiagnosticsRequest { + uint32_t flags; + pb_callback_t diagnostic_types; + uint32_t timeout; } particle_ctrl_mesh_GetNetworkDiagnosticsRequest; -typedef struct _particle_ctrl_mesh_JoinNetworkRequest { - uint32_t timeout; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_JoinNetworkRequest) */ +/* Join the network */ +typedef struct _particle_ctrl_mesh_JoinNetworkRequest { + /* Time in seconds after which the attempt to join is cancelled */ + uint32_t timeout; } particle_ctrl_mesh_JoinNetworkRequest; -typedef struct _particle_ctrl_mesh_NetworkInfo { - pb_callback_t name; - pb_callback_t ext_pan_id; - uint32_t pan_id; - uint32_t channel; - pb_callback_t network_id; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_NetworkInfo) */ +/* Network info */ +typedef struct _particle_ctrl_mesh_NetworkInfo { + /* Network name */ + pb_callback_t name; + /* Extended PAN ID */ + pb_callback_t ext_pan_id; + /* PAN ID */ + uint32_t pan_id; + /* Channel number */ + uint32_t channel; + /* network ID */ + pb_callback_t network_id; } particle_ctrl_mesh_NetworkInfo; -typedef struct _particle_ctrl_mesh_ScanNetworksRequest { - uint32_t duration; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_ScanNetworksRequest) */ +/* Scan networks */ +typedef struct _particle_ctrl_mesh_ScanNetworksRequest { + /* Time in milliseconds to spend scanning each channel. A value of 0 sets the default OpenThread + timeout (300 ms) */ + uint32_t duration; } particle_ctrl_mesh_ScanNetworksRequest; -typedef struct _particle_ctrl_mesh_StartCommissionerRequest { - uint32_t timeout; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_StartCommissionerRequest) */ +/* Start the commissioner role */ +typedef struct _particle_ctrl_mesh_StartCommissionerRequest { + /* Time is seconds after which the role is automatically stopped */ + uint32_t timeout; } particle_ctrl_mesh_StartCommissionerRequest; -typedef struct _particle_ctrl_mesh_CreateNetworkReply { - particle_ctrl_mesh_NetworkInfo network; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_CreateNetworkReply) */ +/* Result codes: + ALREADY_EXIST: The device is already a member of a network + NOT_ALLOWED: The client is not authenticated */ +typedef struct _particle_ctrl_mesh_CreateNetworkReply { + /* Network info */ + bool has_network; + particle_ctrl_mesh_NetworkInfo network; } particle_ctrl_mesh_CreateNetworkReply; typedef PB_BYTES_ARRAY_T(8) particle_ctrl_mesh_DiagnosticInfo_ext_mac_address_t; typedef PB_BYTES_ARRAY_T(3) particle_ctrl_mesh_DiagnosticInfo_channel_pages_t; typedef PB_BYTES_ARRAY_T(12) particle_ctrl_mesh_DiagnosticInfo_device_id_t; -typedef struct _particle_ctrl_mesh_DiagnosticInfo { - particle_ctrl_mesh_DiagnosticInfo_ext_mac_address_t ext_mac_address; - uint32_t rloc; - uint32_t mode; - uint32_t timeout; - particle_ctrl_mesh_DiagnosticInfo_Connectivity connectivity; - particle_ctrl_mesh_DiagnosticInfo_Route64 route64; - particle_ctrl_mesh_DiagnosticInfo_LeaderData leader_data; - particle_ctrl_mesh_DiagnosticInfo_NetworkData network_data; - pb_callback_t ipv6_address_list; - particle_ctrl_mesh_DiagnosticInfo_MacCounters mac_counters; - uint32_t battery_level; - uint32_t supply_voltage; - particle_ctrl_mesh_DiagnosticInfo_ChildTable child_table; - particle_ctrl_mesh_DiagnosticInfo_channel_pages_t channel_pages; - pb_callback_t type_list; - uint32_t max_child_timeout; - particle_ctrl_mesh_DiagnosticInfo_device_id_t device_id; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_DiagnosticInfo) */ +/* Mapping of Diagnostic TLVs */ +typedef struct _particle_ctrl_mesh_DiagnosticInfo { + /* MAC Extended Address (64-bit): MAC Extended Address TLV */ + particle_ctrl_mesh_DiagnosticInfo_ext_mac_address_t ext_mac_address; + /* MAC Address (16-bit): Address16 TLV (RLOC) */ + uint32_t rloc; + /* Mode (Capability Information): Mode TLV */ + uint32_t mode; + /* Timeout: Timeout TLV */ + uint32_t timeout; + /* Connectivity : Connectivity TLV */ + bool has_connectivity; + particle_ctrl_mesh_DiagnosticInfo_Connectivity connectivity; + /* Route64: Route64 TLV */ + bool has_route64; + particle_ctrl_mesh_DiagnosticInfo_Route64 route64; + /* Leader Data: Leader Data TLV */ + bool has_leader_data; + particle_ctrl_mesh_DiagnosticInfo_LeaderData leader_data; + /* Network Data: Network Data TLV */ + bool has_network_data; + particle_ctrl_mesh_DiagnosticInfo_NetworkData network_data; + /* IPv6 address list: IPv6 Address List TLV */ + pb_callback_t ipv6_address_list; + /* MAC Counters: MAC Counters TLV */ + bool has_mac_counters; + particle_ctrl_mesh_DiagnosticInfo_MacCounters mac_counters; + /* Battery Level: Battery Level TLV */ + uint32_t battery_level; + /* Supply Voltage: Supply Voltage TLV */ + uint32_t supply_voltage; + /* Child Table: Child Table TLV */ + bool has_child_table; + particle_ctrl_mesh_DiagnosticInfo_ChildTable child_table; + /* Channel Pages: Channel Pages TLV */ + particle_ctrl_mesh_DiagnosticInfo_channel_pages_t channel_pages; + /* Type List: Type List TLV + List of DiagnosticType */ + pb_callback_t type_list; + /* Max Child Timeout: Timeout TLV */ + uint32_t max_child_timeout; + /* Particle-specific Device Id */ + particle_ctrl_mesh_DiagnosticInfo_device_id_t device_id; } particle_ctrl_mesh_DiagnosticInfo; -typedef struct _particle_ctrl_mesh_GetNetworkInfoReply { - particle_ctrl_mesh_NetworkInfo network; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_GetNetworkInfoReply) */ +/* Result codes: + NOT_FOUND: The device is not a member of a network */ +typedef struct _particle_ctrl_mesh_GetNetworkInfoReply { + /* Network info */ + bool has_network; + particle_ctrl_mesh_NetworkInfo network; } particle_ctrl_mesh_GetNetworkInfoReply; -typedef struct _particle_ctrl_mesh_PrepareJoinerRequest { - particle_ctrl_mesh_NetworkInfo network; -/* @@protoc_insertion_point(struct:particle_ctrl_mesh_PrepareJoinerRequest) */ +/* Prepare the device to join a network */ +typedef struct _particle_ctrl_mesh_PrepareJoinerRequest { + bool has_network; + particle_ctrl_mesh_NetworkInfo network; } particle_ctrl_mesh_PrepareJoinerRequest; -/* Default values for struct fields */ + +/* Helper constants for enums */ +#define _particle_ctrl_mesh_DiagnosticType_MIN particle_ctrl_mesh_DiagnosticType_MAC_EXTENDED_ADDRESS +#define _particle_ctrl_mesh_DiagnosticType_MAX particle_ctrl_mesh_DiagnosticType_MAX_CHILD_TIMEOUT +#define _particle_ctrl_mesh_DiagnosticType_ARRAYSIZE ((particle_ctrl_mesh_DiagnosticType)(particle_ctrl_mesh_DiagnosticType_MAX_CHILD_TIMEOUT+1)) + +#define _particle_ctrl_mesh_DiagnosticInfo_Mode_MIN particle_ctrl_mesh_DiagnosticInfo_Mode_INVALID +#define _particle_ctrl_mesh_DiagnosticInfo_Mode_MAX particle_ctrl_mesh_DiagnosticInfo_Mode_NETWORK_DATA_FULL +#define _particle_ctrl_mesh_DiagnosticInfo_Mode_ARRAYSIZE ((particle_ctrl_mesh_DiagnosticInfo_Mode)(particle_ctrl_mesh_DiagnosticInfo_Mode_NETWORK_DATA_FULL+1)) + +#define _particle_ctrl_mesh_DiagnosticInfo_RoutePreference_MIN particle_ctrl_mesh_DiagnosticInfo_RoutePreference_LOW +#define _particle_ctrl_mesh_DiagnosticInfo_RoutePreference_MAX particle_ctrl_mesh_DiagnosticInfo_RoutePreference_HIGH +#define _particle_ctrl_mesh_DiagnosticInfo_RoutePreference_ARRAYSIZE ((particle_ctrl_mesh_DiagnosticInfo_RoutePreference)(particle_ctrl_mesh_DiagnosticInfo_RoutePreference_HIGH+1)) + +#define _particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_MIN particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_NONE +#define _particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_MAX particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_ND_DNS +#define _particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_ARRAYSIZE ((particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags)(particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_ND_DNS+1)) + +#define _particle_ctrl_mesh_GetNetworkDiagnosticsRequest_Flags_MIN particle_ctrl_mesh_GetNetworkDiagnosticsRequest_Flags_INVALID +#define _particle_ctrl_mesh_GetNetworkDiagnosticsRequest_Flags_MAX particle_ctrl_mesh_GetNetworkDiagnosticsRequest_Flags_RESOLVE_DEVICE_ID +#define _particle_ctrl_mesh_GetNetworkDiagnosticsRequest_Flags_ARRAYSIZE ((particle_ctrl_mesh_GetNetworkDiagnosticsRequest_Flags)(particle_ctrl_mesh_GetNetworkDiagnosticsRequest_Flags_RESOLVE_DEVICE_ID+1)) + + +#ifdef __cplusplus +extern "C" { +#endif /* Initializer values for message structs */ #define particle_ctrl_mesh_NetworkInfo_init_default {{{NULL}, NULL}, {{NULL}, NULL}, 0, 0, {{NULL}, NULL}} #define particle_ctrl_mesh_AuthRequest_init_default {{{NULL}, NULL}} #define particle_ctrl_mesh_AuthReply_init_default {0} #define particle_ctrl_mesh_CreateNetworkRequest_init_default {{{NULL}, NULL}, {{NULL}, NULL}, 0, {{NULL}, NULL}} -#define particle_ctrl_mesh_CreateNetworkReply_init_default {particle_ctrl_mesh_NetworkInfo_init_default} +#define particle_ctrl_mesh_CreateNetworkReply_init_default {false, particle_ctrl_mesh_NetworkInfo_init_default} #define particle_ctrl_mesh_StartCommissionerRequest_init_default {0} #define particle_ctrl_mesh_StartCommissionerReply_init_default {0} #define particle_ctrl_mesh_StopCommissionerRequest_init_default {0} #define particle_ctrl_mesh_StopCommissionerReply_init_default {0} -#define particle_ctrl_mesh_PrepareJoinerRequest_init_default {particle_ctrl_mesh_NetworkInfo_init_default} +#define particle_ctrl_mesh_PrepareJoinerRequest_init_default {false, particle_ctrl_mesh_NetworkInfo_init_default} #define particle_ctrl_mesh_PrepareJoinerReply_init_default {{{NULL}, NULL}, {{NULL}, NULL}} #define particle_ctrl_mesh_AddJoinerRequest_init_default {{{NULL}, NULL}, {{NULL}, NULL}, 0} #define particle_ctrl_mesh_AddJoinerReply_init_default {0} @@ -400,21 +459,21 @@ typedef struct _particle_ctrl_mesh_PrepareJoinerRequest { #define particle_ctrl_mesh_LeaveNetworkRequest_init_default {0} #define particle_ctrl_mesh_LeaveNetworkReply_init_default {0} #define particle_ctrl_mesh_GetNetworkInfoRequest_init_default {0} -#define particle_ctrl_mesh_GetNetworkInfoReply_init_default {particle_ctrl_mesh_NetworkInfo_init_default} +#define particle_ctrl_mesh_GetNetworkInfoReply_init_default {false, particle_ctrl_mesh_NetworkInfo_init_default} #define particle_ctrl_mesh_ScanNetworksRequest_init_default {0} #define particle_ctrl_mesh_ScanNetworksReply_init_default {{{NULL}, NULL}} -#define particle_ctrl_mesh_DiagnosticInfo_init_default {{0, {0}}, 0, 0, 0, particle_ctrl_mesh_DiagnosticInfo_Connectivity_init_default, particle_ctrl_mesh_DiagnosticInfo_Route64_init_default, particle_ctrl_mesh_DiagnosticInfo_LeaderData_init_default, particle_ctrl_mesh_DiagnosticInfo_NetworkData_init_default, {{NULL}, NULL}, particle_ctrl_mesh_DiagnosticInfo_MacCounters_init_default, 0, 0, particle_ctrl_mesh_DiagnosticInfo_ChildTable_init_default, {0, {0}}, {{NULL}, NULL}, 0, {0, {0}}} +#define particle_ctrl_mesh_DiagnosticInfo_init_default {{0, {0}}, 0, 0, 0, false, particle_ctrl_mesh_DiagnosticInfo_Connectivity_init_default, false, particle_ctrl_mesh_DiagnosticInfo_Route64_init_default, false, particle_ctrl_mesh_DiagnosticInfo_LeaderData_init_default, false, particle_ctrl_mesh_DiagnosticInfo_NetworkData_init_default, {{NULL}, NULL}, false, particle_ctrl_mesh_DiagnosticInfo_MacCounters_init_default, 0, 0, false, particle_ctrl_mesh_DiagnosticInfo_ChildTable_init_default, {0, {0}}, {{NULL}, NULL}, 0, {0, {0}}} #define particle_ctrl_mesh_DiagnosticInfo_Connectivity_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0} #define particle_ctrl_mesh_DiagnosticInfo_Route64_init_default {0, {{NULL}, NULL}} #define particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData_init_default {0, 0, 0, 0} #define particle_ctrl_mesh_DiagnosticInfo_LeaderData_init_default {0, 0, 0, 0, 0} -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_init_default {particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_init_default, particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_init_default} +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_init_default {false, particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_init_default, false, particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_init_default} #define particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_init_default {{{NULL}, NULL}} -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry_init_default {0, (particle_ctrl_mesh_DiagnosticInfo_RoutePreference)0} +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry_init_default {0, _particle_ctrl_mesh_DiagnosticInfo_RoutePreference_MIN} #define particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_init_default {{{NULL}, NULL}} -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_init_default {0, (particle_ctrl_mesh_DiagnosticInfo_RoutePreference)0, 0} +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_init_default {0, _particle_ctrl_mesh_DiagnosticInfo_RoutePreference_MIN, 0} #define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context_init_default {0, 0, 0} -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_init_default {0, 0, {0, {0}}, {{NULL}, NULL}, particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_init_default, particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_init_default} +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_init_default {0, 0, {0, {0}}, {{NULL}, NULL}, false, particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_init_default, false, particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_init_default} #define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server_init_default {0, {{NULL}, NULL}} #define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service_init_default {0, 0, {{NULL}, NULL}, {{NULL}, NULL}} #define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_init_default {{{NULL}, NULL}, {{NULL}, NULL}} @@ -427,12 +486,12 @@ typedef struct _particle_ctrl_mesh_PrepareJoinerRequest { #define particle_ctrl_mesh_AuthRequest_init_zero {{{NULL}, NULL}} #define particle_ctrl_mesh_AuthReply_init_zero {0} #define particle_ctrl_mesh_CreateNetworkRequest_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, 0, {{NULL}, NULL}} -#define particle_ctrl_mesh_CreateNetworkReply_init_zero {particle_ctrl_mesh_NetworkInfo_init_zero} +#define particle_ctrl_mesh_CreateNetworkReply_init_zero {false, particle_ctrl_mesh_NetworkInfo_init_zero} #define particle_ctrl_mesh_StartCommissionerRequest_init_zero {0} #define particle_ctrl_mesh_StartCommissionerReply_init_zero {0} #define particle_ctrl_mesh_StopCommissionerRequest_init_zero {0} #define particle_ctrl_mesh_StopCommissionerReply_init_zero {0} -#define particle_ctrl_mesh_PrepareJoinerRequest_init_zero {particle_ctrl_mesh_NetworkInfo_init_zero} +#define particle_ctrl_mesh_PrepareJoinerRequest_init_zero {false, particle_ctrl_mesh_NetworkInfo_init_zero} #define particle_ctrl_mesh_PrepareJoinerReply_init_zero {{{NULL}, NULL}, {{NULL}, NULL}} #define particle_ctrl_mesh_AddJoinerRequest_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, 0} #define particle_ctrl_mesh_AddJoinerReply_init_zero {0} @@ -443,21 +502,21 @@ typedef struct _particle_ctrl_mesh_PrepareJoinerRequest { #define particle_ctrl_mesh_LeaveNetworkRequest_init_zero {0} #define particle_ctrl_mesh_LeaveNetworkReply_init_zero {0} #define particle_ctrl_mesh_GetNetworkInfoRequest_init_zero {0} -#define particle_ctrl_mesh_GetNetworkInfoReply_init_zero {particle_ctrl_mesh_NetworkInfo_init_zero} +#define particle_ctrl_mesh_GetNetworkInfoReply_init_zero {false, particle_ctrl_mesh_NetworkInfo_init_zero} #define particle_ctrl_mesh_ScanNetworksRequest_init_zero {0} #define particle_ctrl_mesh_ScanNetworksReply_init_zero {{{NULL}, NULL}} -#define particle_ctrl_mesh_DiagnosticInfo_init_zero {{0, {0}}, 0, 0, 0, particle_ctrl_mesh_DiagnosticInfo_Connectivity_init_zero, particle_ctrl_mesh_DiagnosticInfo_Route64_init_zero, particle_ctrl_mesh_DiagnosticInfo_LeaderData_init_zero, particle_ctrl_mesh_DiagnosticInfo_NetworkData_init_zero, {{NULL}, NULL}, particle_ctrl_mesh_DiagnosticInfo_MacCounters_init_zero, 0, 0, particle_ctrl_mesh_DiagnosticInfo_ChildTable_init_zero, {0, {0}}, {{NULL}, NULL}, 0, {0, {0}}} +#define particle_ctrl_mesh_DiagnosticInfo_init_zero {{0, {0}}, 0, 0, 0, false, particle_ctrl_mesh_DiagnosticInfo_Connectivity_init_zero, false, particle_ctrl_mesh_DiagnosticInfo_Route64_init_zero, false, particle_ctrl_mesh_DiagnosticInfo_LeaderData_init_zero, false, particle_ctrl_mesh_DiagnosticInfo_NetworkData_init_zero, {{NULL}, NULL}, false, particle_ctrl_mesh_DiagnosticInfo_MacCounters_init_zero, 0, 0, false, particle_ctrl_mesh_DiagnosticInfo_ChildTable_init_zero, {0, {0}}, {{NULL}, NULL}, 0, {0, {0}}} #define particle_ctrl_mesh_DiagnosticInfo_Connectivity_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0} #define particle_ctrl_mesh_DiagnosticInfo_Route64_init_zero {0, {{NULL}, NULL}} #define particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData_init_zero {0, 0, 0, 0} #define particle_ctrl_mesh_DiagnosticInfo_LeaderData_init_zero {0, 0, 0, 0, 0} -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_init_zero {particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_init_zero, particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_init_zero} +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_init_zero {false, particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_init_zero, false, particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_init_zero} #define particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_init_zero {{{NULL}, NULL}} -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry_init_zero {0, (particle_ctrl_mesh_DiagnosticInfo_RoutePreference)0} +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry_init_zero {0, _particle_ctrl_mesh_DiagnosticInfo_RoutePreference_MIN} #define particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_init_zero {{{NULL}, NULL}} -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_init_zero {0, (particle_ctrl_mesh_DiagnosticInfo_RoutePreference)0, 0} +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_init_zero {0, _particle_ctrl_mesh_DiagnosticInfo_RoutePreference_MIN, 0} #define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context_init_zero {0, 0, 0} -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_init_zero {0, 0, {0, {0}}, {{NULL}, NULL}, particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_init_zero, particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_init_zero} +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_init_zero {0, 0, {0, {0}}, {{NULL}, NULL}, false, particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_init_zero, false, particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_init_zero} #define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server_init_zero {0, {{NULL}, NULL}} #define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service_init_zero {0, 0, {{NULL}, NULL}, {{NULL}, NULL}} #define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_init_zero {{{NULL}, NULL}, {{NULL}, NULL}} @@ -573,106 +632,451 @@ typedef struct _particle_ctrl_mesh_PrepareJoinerRequest { #define particle_ctrl_mesh_PrepareJoinerRequest_network_tag 1 /* Struct field encoding specification for nanopb */ -extern const pb_field_t particle_ctrl_mesh_NetworkInfo_fields[6]; -extern const pb_field_t particle_ctrl_mesh_AuthRequest_fields[2]; -extern const pb_field_t particle_ctrl_mesh_AuthReply_fields[1]; -extern const pb_field_t particle_ctrl_mesh_CreateNetworkRequest_fields[5]; -extern const pb_field_t particle_ctrl_mesh_CreateNetworkReply_fields[2]; -extern const pb_field_t particle_ctrl_mesh_StartCommissionerRequest_fields[2]; -extern const pb_field_t particle_ctrl_mesh_StartCommissionerReply_fields[1]; -extern const pb_field_t particle_ctrl_mesh_StopCommissionerRequest_fields[1]; -extern const pb_field_t particle_ctrl_mesh_StopCommissionerReply_fields[1]; -extern const pb_field_t particle_ctrl_mesh_PrepareJoinerRequest_fields[2]; -extern const pb_field_t particle_ctrl_mesh_PrepareJoinerReply_fields[3]; -extern const pb_field_t particle_ctrl_mesh_AddJoinerRequest_fields[4]; -extern const pb_field_t particle_ctrl_mesh_AddJoinerReply_fields[1]; -extern const pb_field_t particle_ctrl_mesh_RemoveJoinerRequest_fields[2]; -extern const pb_field_t particle_ctrl_mesh_RemoveJoinerReply_fields[1]; -extern const pb_field_t particle_ctrl_mesh_JoinNetworkRequest_fields[2]; -extern const pb_field_t particle_ctrl_mesh_JoinNetworkReply_fields[1]; -extern const pb_field_t particle_ctrl_mesh_LeaveNetworkRequest_fields[1]; -extern const pb_field_t particle_ctrl_mesh_LeaveNetworkReply_fields[1]; -extern const pb_field_t particle_ctrl_mesh_GetNetworkInfoRequest_fields[1]; -extern const pb_field_t particle_ctrl_mesh_GetNetworkInfoReply_fields[2]; -extern const pb_field_t particle_ctrl_mesh_ScanNetworksRequest_fields[2]; -extern const pb_field_t particle_ctrl_mesh_ScanNetworksReply_fields[2]; -extern const pb_field_t particle_ctrl_mesh_DiagnosticInfo_fields[18]; -extern const pb_field_t particle_ctrl_mesh_DiagnosticInfo_Connectivity_fields[10]; -extern const pb_field_t particle_ctrl_mesh_DiagnosticInfo_Route64_fields[3]; -extern const pb_field_t particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData_fields[5]; -extern const pb_field_t particle_ctrl_mesh_DiagnosticInfo_LeaderData_fields[6]; -extern const pb_field_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_fields[3]; -extern const pb_field_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_fields[2]; -extern const pb_field_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry_fields[3]; -extern const pb_field_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_fields[2]; -extern const pb_field_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_fields[4]; -extern const pb_field_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context_fields[4]; -extern const pb_field_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_fields[7]; -extern const pb_field_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server_fields[3]; -extern const pb_field_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service_fields[5]; -extern const pb_field_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_fields[3]; -extern const pb_field_t particle_ctrl_mesh_DiagnosticInfo_MacCounters_fields[10]; -extern const pb_field_t particle_ctrl_mesh_DiagnosticInfo_ChildTable_fields[2]; -extern const pb_field_t particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry_fields[4]; -extern const pb_field_t particle_ctrl_mesh_GetNetworkDiagnosticsRequest_fields[4]; -extern const pb_field_t particle_ctrl_mesh_GetNetworkDiagnosticsReply_fields[2]; +#define particle_ctrl_mesh_NetworkInfo_FIELDLIST(X, a) \ +X(a, CALLBACK, SINGULAR, STRING, name, 1) \ +X(a, CALLBACK, SINGULAR, STRING, ext_pan_id, 2) \ +X(a, STATIC, SINGULAR, UINT32, pan_id, 3) \ +X(a, STATIC, SINGULAR, UINT32, channel, 4) \ +X(a, CALLBACK, SINGULAR, STRING, network_id, 5) +#define particle_ctrl_mesh_NetworkInfo_CALLBACK pb_default_field_callback +#define particle_ctrl_mesh_NetworkInfo_DEFAULT NULL + +#define particle_ctrl_mesh_AuthRequest_FIELDLIST(X, a) \ +X(a, CALLBACK, SINGULAR, STRING, password, 1) +#define particle_ctrl_mesh_AuthRequest_CALLBACK pb_default_field_callback +#define particle_ctrl_mesh_AuthRequest_DEFAULT NULL + +#define particle_ctrl_mesh_AuthReply_FIELDLIST(X, a) \ + +#define particle_ctrl_mesh_AuthReply_CALLBACK NULL +#define particle_ctrl_mesh_AuthReply_DEFAULT NULL + +#define particle_ctrl_mesh_CreateNetworkRequest_FIELDLIST(X, a) \ +X(a, CALLBACK, SINGULAR, STRING, name, 1) \ +X(a, CALLBACK, SINGULAR, STRING, password, 2) \ +X(a, STATIC, SINGULAR, UINT32, channel, 3) \ +X(a, CALLBACK, SINGULAR, STRING, network_id, 4) +#define particle_ctrl_mesh_CreateNetworkRequest_CALLBACK pb_default_field_callback +#define particle_ctrl_mesh_CreateNetworkRequest_DEFAULT NULL + +#define particle_ctrl_mesh_CreateNetworkReply_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, MESSAGE, network, 1) +#define particle_ctrl_mesh_CreateNetworkReply_CALLBACK NULL +#define particle_ctrl_mesh_CreateNetworkReply_DEFAULT NULL +#define particle_ctrl_mesh_CreateNetworkReply_network_MSGTYPE particle_ctrl_mesh_NetworkInfo + +#define particle_ctrl_mesh_StartCommissionerRequest_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UINT32, timeout, 1) +#define particle_ctrl_mesh_StartCommissionerRequest_CALLBACK NULL +#define particle_ctrl_mesh_StartCommissionerRequest_DEFAULT NULL + +#define particle_ctrl_mesh_StartCommissionerReply_FIELDLIST(X, a) \ + +#define particle_ctrl_mesh_StartCommissionerReply_CALLBACK NULL +#define particle_ctrl_mesh_StartCommissionerReply_DEFAULT NULL + +#define particle_ctrl_mesh_StopCommissionerRequest_FIELDLIST(X, a) \ + +#define particle_ctrl_mesh_StopCommissionerRequest_CALLBACK NULL +#define particle_ctrl_mesh_StopCommissionerRequest_DEFAULT NULL + +#define particle_ctrl_mesh_StopCommissionerReply_FIELDLIST(X, a) \ + +#define particle_ctrl_mesh_StopCommissionerReply_CALLBACK NULL +#define particle_ctrl_mesh_StopCommissionerReply_DEFAULT NULL + +#define particle_ctrl_mesh_PrepareJoinerRequest_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, MESSAGE, network, 1) +#define particle_ctrl_mesh_PrepareJoinerRequest_CALLBACK NULL +#define particle_ctrl_mesh_PrepareJoinerRequest_DEFAULT NULL +#define particle_ctrl_mesh_PrepareJoinerRequest_network_MSGTYPE particle_ctrl_mesh_NetworkInfo + +#define particle_ctrl_mesh_PrepareJoinerReply_FIELDLIST(X, a) \ +X(a, CALLBACK, SINGULAR, STRING, eui64, 1) \ +X(a, CALLBACK, SINGULAR, STRING, password, 2) +#define particle_ctrl_mesh_PrepareJoinerReply_CALLBACK pb_default_field_callback +#define particle_ctrl_mesh_PrepareJoinerReply_DEFAULT NULL + +#define particle_ctrl_mesh_AddJoinerRequest_FIELDLIST(X, a) \ +X(a, CALLBACK, SINGULAR, STRING, eui64, 1) \ +X(a, CALLBACK, SINGULAR, STRING, password, 2) \ +X(a, STATIC, SINGULAR, UINT32, timeout, 3) +#define particle_ctrl_mesh_AddJoinerRequest_CALLBACK pb_default_field_callback +#define particle_ctrl_mesh_AddJoinerRequest_DEFAULT NULL + +#define particle_ctrl_mesh_AddJoinerReply_FIELDLIST(X, a) \ + +#define particle_ctrl_mesh_AddJoinerReply_CALLBACK NULL +#define particle_ctrl_mesh_AddJoinerReply_DEFAULT NULL + +#define particle_ctrl_mesh_RemoveJoinerRequest_FIELDLIST(X, a) \ +X(a, CALLBACK, SINGULAR, STRING, eui64, 1) +#define particle_ctrl_mesh_RemoveJoinerRequest_CALLBACK pb_default_field_callback +#define particle_ctrl_mesh_RemoveJoinerRequest_DEFAULT NULL + +#define particle_ctrl_mesh_RemoveJoinerReply_FIELDLIST(X, a) \ + +#define particle_ctrl_mesh_RemoveJoinerReply_CALLBACK NULL +#define particle_ctrl_mesh_RemoveJoinerReply_DEFAULT NULL + +#define particle_ctrl_mesh_JoinNetworkRequest_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UINT32, timeout, 1) +#define particle_ctrl_mesh_JoinNetworkRequest_CALLBACK NULL +#define particle_ctrl_mesh_JoinNetworkRequest_DEFAULT NULL + +#define particle_ctrl_mesh_JoinNetworkReply_FIELDLIST(X, a) \ + +#define particle_ctrl_mesh_JoinNetworkReply_CALLBACK NULL +#define particle_ctrl_mesh_JoinNetworkReply_DEFAULT NULL + +#define particle_ctrl_mesh_LeaveNetworkRequest_FIELDLIST(X, a) \ + +#define particle_ctrl_mesh_LeaveNetworkRequest_CALLBACK NULL +#define particle_ctrl_mesh_LeaveNetworkRequest_DEFAULT NULL + +#define particle_ctrl_mesh_LeaveNetworkReply_FIELDLIST(X, a) \ + +#define particle_ctrl_mesh_LeaveNetworkReply_CALLBACK NULL +#define particle_ctrl_mesh_LeaveNetworkReply_DEFAULT NULL + +#define particle_ctrl_mesh_GetNetworkInfoRequest_FIELDLIST(X, a) \ + +#define particle_ctrl_mesh_GetNetworkInfoRequest_CALLBACK NULL +#define particle_ctrl_mesh_GetNetworkInfoRequest_DEFAULT NULL + +#define particle_ctrl_mesh_GetNetworkInfoReply_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, MESSAGE, network, 1) +#define particle_ctrl_mesh_GetNetworkInfoReply_CALLBACK NULL +#define particle_ctrl_mesh_GetNetworkInfoReply_DEFAULT NULL +#define particle_ctrl_mesh_GetNetworkInfoReply_network_MSGTYPE particle_ctrl_mesh_NetworkInfo + +#define particle_ctrl_mesh_ScanNetworksRequest_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UINT32, duration, 1) +#define particle_ctrl_mesh_ScanNetworksRequest_CALLBACK NULL +#define particle_ctrl_mesh_ScanNetworksRequest_DEFAULT NULL + +#define particle_ctrl_mesh_ScanNetworksReply_FIELDLIST(X, a) \ +X(a, CALLBACK, REPEATED, MESSAGE, networks, 1) +#define particle_ctrl_mesh_ScanNetworksReply_CALLBACK pb_default_field_callback +#define particle_ctrl_mesh_ScanNetworksReply_DEFAULT NULL +#define particle_ctrl_mesh_ScanNetworksReply_networks_MSGTYPE particle_ctrl_mesh_NetworkInfo + +#define particle_ctrl_mesh_DiagnosticInfo_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, BYTES, ext_mac_address, 1) \ +X(a, STATIC, SINGULAR, UINT32, rloc, 2) \ +X(a, STATIC, SINGULAR, UINT32, mode, 3) \ +X(a, STATIC, SINGULAR, UINT32, timeout, 4) \ +X(a, STATIC, OPTIONAL, MESSAGE, connectivity, 5) \ +X(a, STATIC, OPTIONAL, MESSAGE, route64, 6) \ +X(a, STATIC, OPTIONAL, MESSAGE, leader_data, 7) \ +X(a, STATIC, OPTIONAL, MESSAGE, network_data, 8) \ +X(a, CALLBACK, REPEATED, MESSAGE, ipv6_address_list, 9) \ +X(a, STATIC, OPTIONAL, MESSAGE, mac_counters, 10) \ +X(a, STATIC, SINGULAR, UINT32, battery_level, 15) \ +X(a, STATIC, SINGULAR, UINT32, supply_voltage, 16) \ +X(a, STATIC, OPTIONAL, MESSAGE, child_table, 17) \ +X(a, STATIC, SINGULAR, BYTES, channel_pages, 18) \ +X(a, CALLBACK, REPEATED, UENUM, type_list, 19) \ +X(a, STATIC, SINGULAR, UINT32, max_child_timeout, 20) \ +X(a, STATIC, SINGULAR, BYTES, device_id, 100) +#define particle_ctrl_mesh_DiagnosticInfo_CALLBACK pb_default_field_callback +#define particle_ctrl_mesh_DiagnosticInfo_DEFAULT NULL +#define particle_ctrl_mesh_DiagnosticInfo_connectivity_MSGTYPE particle_ctrl_mesh_DiagnosticInfo_Connectivity +#define particle_ctrl_mesh_DiagnosticInfo_route64_MSGTYPE particle_ctrl_mesh_DiagnosticInfo_Route64 +#define particle_ctrl_mesh_DiagnosticInfo_leader_data_MSGTYPE particle_ctrl_mesh_DiagnosticInfo_LeaderData +#define particle_ctrl_mesh_DiagnosticInfo_network_data_MSGTYPE particle_ctrl_mesh_DiagnosticInfo_NetworkData +#define particle_ctrl_mesh_DiagnosticInfo_ipv6_address_list_MSGTYPE particle_ctrl_Ipv6Address +#define particle_ctrl_mesh_DiagnosticInfo_mac_counters_MSGTYPE particle_ctrl_mesh_DiagnosticInfo_MacCounters +#define particle_ctrl_mesh_DiagnosticInfo_child_table_MSGTYPE particle_ctrl_mesh_DiagnosticInfo_ChildTable + +#define particle_ctrl_mesh_DiagnosticInfo_Connectivity_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UINT32, parent_priority, 1) \ +X(a, STATIC, SINGULAR, UINT32, link_quality_1, 2) \ +X(a, STATIC, SINGULAR, UINT32, link_quality_2, 3) \ +X(a, STATIC, SINGULAR, UINT32, link_quality_3, 4) \ +X(a, STATIC, SINGULAR, UINT32, leader_cost, 5) \ +X(a, STATIC, SINGULAR, UINT32, id_sequence, 6) \ +X(a, STATIC, SINGULAR, UINT32, active_routers, 7) \ +X(a, STATIC, SINGULAR, UINT32, sed_buffer_size, 8) \ +X(a, STATIC, SINGULAR, UINT32, sed_datagram_count, 9) +#define particle_ctrl_mesh_DiagnosticInfo_Connectivity_CALLBACK NULL +#define particle_ctrl_mesh_DiagnosticInfo_Connectivity_DEFAULT NULL + +#define particle_ctrl_mesh_DiagnosticInfo_Route64_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UINT32, id_sequence, 1) \ +X(a, CALLBACK, REPEATED, MESSAGE, routes, 2) +#define particle_ctrl_mesh_DiagnosticInfo_Route64_CALLBACK pb_default_field_callback +#define particle_ctrl_mesh_DiagnosticInfo_Route64_DEFAULT NULL +#define particle_ctrl_mesh_DiagnosticInfo_Route64_routes_MSGTYPE particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData + +#define particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UINT32, router_rloc, 1) \ +X(a, STATIC, SINGULAR, UINT32, link_quality_out, 2) \ +X(a, STATIC, SINGULAR, UINT32, link_quality_in, 3) \ +X(a, STATIC, SINGULAR, UINT32, route_cost, 4) +#define particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData_CALLBACK NULL +#define particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData_DEFAULT NULL + +#define particle_ctrl_mesh_DiagnosticInfo_LeaderData_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UINT32, partition_id, 1) \ +X(a, STATIC, SINGULAR, UINT32, weighting, 2) \ +X(a, STATIC, SINGULAR, UINT32, data_version, 3) \ +X(a, STATIC, SINGULAR, UINT32, stable_data_version, 4) \ +X(a, STATIC, SINGULAR, UINT32, leader_rloc, 5) +#define particle_ctrl_mesh_DiagnosticInfo_LeaderData_CALLBACK NULL +#define particle_ctrl_mesh_DiagnosticInfo_LeaderData_DEFAULT NULL + +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, MESSAGE, stable, 1) \ +X(a, STATIC, OPTIONAL, MESSAGE, temporary, 2) +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_CALLBACK NULL +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_DEFAULT NULL +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_stable_MSGTYPE particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_temporary_MSGTYPE particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data + +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_FIELDLIST(X, a) \ +X(a, CALLBACK, REPEATED, MESSAGE, entries, 1) +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_CALLBACK pb_default_field_callback +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_DEFAULT NULL +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_entries_MSGTYPE particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry + +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UINT32, rloc, 1) \ +X(a, STATIC, SINGULAR, ENUM, preference, 2) +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry_CALLBACK NULL +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry_DEFAULT NULL + +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_FIELDLIST(X, a) \ +X(a, CALLBACK, REPEATED, MESSAGE, entries, 1) +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_CALLBACK pb_default_field_callback +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_DEFAULT NULL +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_entries_MSGTYPE particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry + +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UINT32, rloc, 1) \ +X(a, STATIC, SINGULAR, ENUM, preference, 2) \ +X(a, STATIC, SINGULAR, UINT32, flags, 3) +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_CALLBACK NULL +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_DEFAULT NULL + +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UINT32, cid, 1) \ +X(a, STATIC, SINGULAR, BOOL, compress, 2) \ +X(a, STATIC, SINGULAR, UINT32, context_length, 3) +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context_CALLBACK NULL +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context_DEFAULT NULL + +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UINT32, domain_id, 1) \ +X(a, STATIC, SINGULAR, UINT32, prefix_length, 2) \ +X(a, STATIC, SINGULAR, BYTES, prefix, 3) \ +X(a, CALLBACK, REPEATED, MESSAGE, context, 4) \ +X(a, STATIC, OPTIONAL, MESSAGE, has_route, 5) \ +X(a, STATIC, OPTIONAL, MESSAGE, border_router, 6) +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_CALLBACK pb_default_field_callback +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_DEFAULT NULL +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_context_MSGTYPE particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_has_route_MSGTYPE particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_border_router_MSGTYPE particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter + +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UINT32, rloc, 1) \ +X(a, CALLBACK, SINGULAR, BYTES, data, 2) +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server_CALLBACK pb_default_field_callback +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server_DEFAULT NULL + +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UINT32, sid, 1) \ +X(a, STATIC, SINGULAR, UINT32, enterprise_number, 2) \ +X(a, CALLBACK, SINGULAR, BYTES, data, 3) \ +X(a, CALLBACK, REPEATED, MESSAGE, servers, 4) +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service_CALLBACK pb_default_field_callback +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service_DEFAULT NULL +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service_servers_MSGTYPE particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server + +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_FIELDLIST(X, a) \ +X(a, CALLBACK, REPEATED, MESSAGE, prefixes, 1) \ +X(a, CALLBACK, REPEATED, MESSAGE, services, 2) +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_CALLBACK pb_default_field_callback +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_DEFAULT NULL +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_prefixes_MSGTYPE particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_services_MSGTYPE particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service + +#define particle_ctrl_mesh_DiagnosticInfo_MacCounters_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UINT32, if_in_unknown_protos, 1) \ +X(a, STATIC, SINGULAR, UINT32, if_in_errors, 2) \ +X(a, STATIC, SINGULAR, UINT32, if_out_errors, 3) \ +X(a, STATIC, SINGULAR, UINT32, if_in_ucast_pkts, 4) \ +X(a, STATIC, SINGULAR, UINT32, if_in_broadcast_pkts, 5) \ +X(a, STATIC, SINGULAR, UINT32, if_in_discards, 6) \ +X(a, STATIC, SINGULAR, UINT32, if_out_ucast_pkts, 7) \ +X(a, STATIC, SINGULAR, UINT32, if_out_broadcast_pkts, 8) \ +X(a, STATIC, SINGULAR, UINT32, if_out_discards, 9) +#define particle_ctrl_mesh_DiagnosticInfo_MacCounters_CALLBACK NULL +#define particle_ctrl_mesh_DiagnosticInfo_MacCounters_DEFAULT NULL + +#define particle_ctrl_mesh_DiagnosticInfo_ChildTable_FIELDLIST(X, a) \ +X(a, CALLBACK, REPEATED, MESSAGE, children, 1) +#define particle_ctrl_mesh_DiagnosticInfo_ChildTable_CALLBACK pb_default_field_callback +#define particle_ctrl_mesh_DiagnosticInfo_ChildTable_DEFAULT NULL +#define particle_ctrl_mesh_DiagnosticInfo_ChildTable_children_MSGTYPE particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry + +#define particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UINT32, timeout, 1) \ +X(a, STATIC, SINGULAR, UINT32, child_id, 2) \ +X(a, STATIC, SINGULAR, UINT32, mode, 3) +#define particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry_CALLBACK NULL +#define particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry_DEFAULT NULL + +#define particle_ctrl_mesh_GetNetworkDiagnosticsRequest_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UINT32, flags, 1) \ +X(a, CALLBACK, REPEATED, UENUM, diagnostic_types, 2) \ +X(a, STATIC, SINGULAR, UINT32, timeout, 3) +#define particle_ctrl_mesh_GetNetworkDiagnosticsRequest_CALLBACK pb_default_field_callback +#define particle_ctrl_mesh_GetNetworkDiagnosticsRequest_DEFAULT NULL + +#define particle_ctrl_mesh_GetNetworkDiagnosticsReply_FIELDLIST(X, a) \ +X(a, CALLBACK, REPEATED, MESSAGE, nodes, 1) +#define particle_ctrl_mesh_GetNetworkDiagnosticsReply_CALLBACK pb_default_field_callback +#define particle_ctrl_mesh_GetNetworkDiagnosticsReply_DEFAULT NULL +#define particle_ctrl_mesh_GetNetworkDiagnosticsReply_nodes_MSGTYPE particle_ctrl_mesh_DiagnosticInfo + +extern const pb_msgdesc_t particle_ctrl_mesh_NetworkInfo_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_AuthRequest_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_AuthReply_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_CreateNetworkRequest_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_CreateNetworkReply_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_StartCommissionerRequest_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_StartCommissionerReply_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_StopCommissionerRequest_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_StopCommissionerReply_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_PrepareJoinerRequest_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_PrepareJoinerReply_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_AddJoinerRequest_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_AddJoinerReply_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_RemoveJoinerRequest_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_RemoveJoinerReply_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_JoinNetworkRequest_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_JoinNetworkReply_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_LeaveNetworkRequest_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_LeaveNetworkReply_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_GetNetworkInfoRequest_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_GetNetworkInfoReply_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_ScanNetworksRequest_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_ScanNetworksReply_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_DiagnosticInfo_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_DiagnosticInfo_Connectivity_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_DiagnosticInfo_Route64_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_DiagnosticInfo_LeaderData_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_DiagnosticInfo_MacCounters_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_DiagnosticInfo_ChildTable_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_GetNetworkDiagnosticsRequest_msg; +extern const pb_msgdesc_t particle_ctrl_mesh_GetNetworkDiagnosticsReply_msg; + +/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ +#define particle_ctrl_mesh_NetworkInfo_fields &particle_ctrl_mesh_NetworkInfo_msg +#define particle_ctrl_mesh_AuthRequest_fields &particle_ctrl_mesh_AuthRequest_msg +#define particle_ctrl_mesh_AuthReply_fields &particle_ctrl_mesh_AuthReply_msg +#define particle_ctrl_mesh_CreateNetworkRequest_fields &particle_ctrl_mesh_CreateNetworkRequest_msg +#define particle_ctrl_mesh_CreateNetworkReply_fields &particle_ctrl_mesh_CreateNetworkReply_msg +#define particle_ctrl_mesh_StartCommissionerRequest_fields &particle_ctrl_mesh_StartCommissionerRequest_msg +#define particle_ctrl_mesh_StartCommissionerReply_fields &particle_ctrl_mesh_StartCommissionerReply_msg +#define particle_ctrl_mesh_StopCommissionerRequest_fields &particle_ctrl_mesh_StopCommissionerRequest_msg +#define particle_ctrl_mesh_StopCommissionerReply_fields &particle_ctrl_mesh_StopCommissionerReply_msg +#define particle_ctrl_mesh_PrepareJoinerRequest_fields &particle_ctrl_mesh_PrepareJoinerRequest_msg +#define particle_ctrl_mesh_PrepareJoinerReply_fields &particle_ctrl_mesh_PrepareJoinerReply_msg +#define particle_ctrl_mesh_AddJoinerRequest_fields &particle_ctrl_mesh_AddJoinerRequest_msg +#define particle_ctrl_mesh_AddJoinerReply_fields &particle_ctrl_mesh_AddJoinerReply_msg +#define particle_ctrl_mesh_RemoveJoinerRequest_fields &particle_ctrl_mesh_RemoveJoinerRequest_msg +#define particle_ctrl_mesh_RemoveJoinerReply_fields &particle_ctrl_mesh_RemoveJoinerReply_msg +#define particle_ctrl_mesh_JoinNetworkRequest_fields &particle_ctrl_mesh_JoinNetworkRequest_msg +#define particle_ctrl_mesh_JoinNetworkReply_fields &particle_ctrl_mesh_JoinNetworkReply_msg +#define particle_ctrl_mesh_LeaveNetworkRequest_fields &particle_ctrl_mesh_LeaveNetworkRequest_msg +#define particle_ctrl_mesh_LeaveNetworkReply_fields &particle_ctrl_mesh_LeaveNetworkReply_msg +#define particle_ctrl_mesh_GetNetworkInfoRequest_fields &particle_ctrl_mesh_GetNetworkInfoRequest_msg +#define particle_ctrl_mesh_GetNetworkInfoReply_fields &particle_ctrl_mesh_GetNetworkInfoReply_msg +#define particle_ctrl_mesh_ScanNetworksRequest_fields &particle_ctrl_mesh_ScanNetworksRequest_msg +#define particle_ctrl_mesh_ScanNetworksReply_fields &particle_ctrl_mesh_ScanNetworksReply_msg +#define particle_ctrl_mesh_DiagnosticInfo_fields &particle_ctrl_mesh_DiagnosticInfo_msg +#define particle_ctrl_mesh_DiagnosticInfo_Connectivity_fields &particle_ctrl_mesh_DiagnosticInfo_Connectivity_msg +#define particle_ctrl_mesh_DiagnosticInfo_Route64_fields &particle_ctrl_mesh_DiagnosticInfo_Route64_msg +#define particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData_fields &particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData_msg +#define particle_ctrl_mesh_DiagnosticInfo_LeaderData_fields &particle_ctrl_mesh_DiagnosticInfo_LeaderData_msg +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_fields &particle_ctrl_mesh_DiagnosticInfo_NetworkData_msg +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_fields &particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_msg +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry_fields &particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry_msg +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_fields &particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_msg +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_fields &particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_msg +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context_fields &particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context_msg +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_fields &particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_msg +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server_fields &particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server_msg +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service_fields &particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service_msg +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_fields &particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_msg +#define particle_ctrl_mesh_DiagnosticInfo_MacCounters_fields &particle_ctrl_mesh_DiagnosticInfo_MacCounters_msg +#define particle_ctrl_mesh_DiagnosticInfo_ChildTable_fields &particle_ctrl_mesh_DiagnosticInfo_ChildTable_msg +#define particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry_fields &particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry_msg +#define particle_ctrl_mesh_GetNetworkDiagnosticsRequest_fields &particle_ctrl_mesh_GetNetworkDiagnosticsRequest_msg +#define particle_ctrl_mesh_GetNetworkDiagnosticsReply_fields &particle_ctrl_mesh_GetNetworkDiagnosticsReply_msg /* Maximum encoded size of messages (where known) */ /* particle_ctrl_mesh_NetworkInfo_size depends on runtime parameters */ /* particle_ctrl_mesh_AuthRequest_size depends on runtime parameters */ -#define particle_ctrl_mesh_AuthReply_size 0 /* particle_ctrl_mesh_CreateNetworkRequest_size depends on runtime parameters */ -#define particle_ctrl_mesh_CreateNetworkReply_size (6 + particle_ctrl_mesh_NetworkInfo_size) -#define particle_ctrl_mesh_StartCommissionerRequest_size 6 -#define particle_ctrl_mesh_StartCommissionerReply_size 0 -#define particle_ctrl_mesh_StopCommissionerRequest_size 0 -#define particle_ctrl_mesh_StopCommissionerReply_size 0 -#define particle_ctrl_mesh_PrepareJoinerRequest_size (6 + particle_ctrl_mesh_NetworkInfo_size) +/* particle_ctrl_mesh_CreateNetworkReply_size depends on runtime parameters */ +/* particle_ctrl_mesh_PrepareJoinerRequest_size depends on runtime parameters */ /* particle_ctrl_mesh_PrepareJoinerReply_size depends on runtime parameters */ /* particle_ctrl_mesh_AddJoinerRequest_size depends on runtime parameters */ -#define particle_ctrl_mesh_AddJoinerReply_size 0 /* particle_ctrl_mesh_RemoveJoinerRequest_size depends on runtime parameters */ -#define particle_ctrl_mesh_RemoveJoinerReply_size 0 -#define particle_ctrl_mesh_JoinNetworkRequest_size 6 -#define particle_ctrl_mesh_JoinNetworkReply_size 0 -#define particle_ctrl_mesh_LeaveNetworkRequest_size 0 -#define particle_ctrl_mesh_LeaveNetworkReply_size 0 -#define particle_ctrl_mesh_GetNetworkInfoRequest_size 0 -#define particle_ctrl_mesh_GetNetworkInfoReply_size (6 + particle_ctrl_mesh_NetworkInfo_size) -#define particle_ctrl_mesh_ScanNetworksRequest_size 6 +/* particle_ctrl_mesh_GetNetworkInfoReply_size depends on runtime parameters */ /* particle_ctrl_mesh_ScanNetworksReply_size depends on runtime parameters */ /* particle_ctrl_mesh_DiagnosticInfo_size depends on runtime parameters */ -#define particle_ctrl_mesh_DiagnosticInfo_Connectivity_size 54 /* particle_ctrl_mesh_DiagnosticInfo_Route64_size depends on runtime parameters */ -#define particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData_size 24 -#define particle_ctrl_mesh_DiagnosticInfo_LeaderData_size 30 -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_size (12 + particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_size + particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_size) +/* particle_ctrl_mesh_DiagnosticInfo_NetworkData_size depends on runtime parameters */ /* particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_size depends on runtime parameters */ -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry_size 17 /* particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_size depends on runtime parameters */ -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_size 23 -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context_size 14 /* particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_size depends on runtime parameters */ /* particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server_size depends on runtime parameters */ /* particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service_size depends on runtime parameters */ /* particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_size depends on runtime parameters */ -#define particle_ctrl_mesh_DiagnosticInfo_MacCounters_size 54 /* particle_ctrl_mesh_DiagnosticInfo_ChildTable_size depends on runtime parameters */ -#define particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry_size 18 /* particle_ctrl_mesh_GetNetworkDiagnosticsRequest_size depends on runtime parameters */ /* particle_ctrl_mesh_GetNetworkDiagnosticsReply_size depends on runtime parameters */ - -/* Message IDs (where set with "msgid" option) */ -#ifdef PB_MSGID - -#define MESH_MESSAGES \ - - -#endif +#define particle_ctrl_mesh_AddJoinerReply_size 0 +#define particle_ctrl_mesh_AuthReply_size 0 +#define particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry_size 18 +#define particle_ctrl_mesh_DiagnosticInfo_Connectivity_size 54 +#define particle_ctrl_mesh_DiagnosticInfo_LeaderData_size 30 +#define particle_ctrl_mesh_DiagnosticInfo_MacCounters_size 54 +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_size 23 +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context_size 14 +#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry_size 17 +#define particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData_size 24 +#define particle_ctrl_mesh_GetNetworkInfoRequest_size 0 +#define particle_ctrl_mesh_JoinNetworkReply_size 0 +#define particle_ctrl_mesh_JoinNetworkRequest_size 6 +#define particle_ctrl_mesh_LeaveNetworkReply_size 0 +#define particle_ctrl_mesh_LeaveNetworkRequest_size 0 +#define particle_ctrl_mesh_RemoveJoinerReply_size 0 +#define particle_ctrl_mesh_ScanNetworksRequest_size 6 +#define particle_ctrl_mesh_StartCommissionerReply_size 0 +#define particle_ctrl_mesh_StartCommissionerRequest_size 6 +#define particle_ctrl_mesh_StopCommissionerReply_size 0 +#define particle_ctrl_mesh_StopCommissionerRequest_size 0 #ifdef __cplusplus } /* extern "C" */ #endif -/* @@protoc_insertion_point(eof) */ #endif diff --git a/system/src/control/proto/network.pb.c b/system/src/control/proto/network.pb.c index 76d5d996b1..36b6757ce9 100644 --- a/system/src/control/proto/network.pb.c +++ b/system/src/control/proto/network.pb.c @@ -1,155 +1,68 @@ /* Automatically generated nanopb constant definitions */ -/* Generated by nanopb-0.3.9 at Tue Jan 29 21:26:45 2019. */ +/* Generated by nanopb-0.4.5 */ #include "network.pb.h" - -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 +#if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif +PB_BIND(particle_ctrl_NetworkGetStatusRequest, particle_ctrl_NetworkGetStatusRequest, AUTO) + + +PB_BIND(particle_ctrl_NetworkGetStatusReply, particle_ctrl_NetworkGetStatusReply, AUTO) + + +PB_BIND(particle_ctrl_NetworkGetConfigurationRequest, particle_ctrl_NetworkGetConfigurationRequest, AUTO) + + +PB_BIND(particle_ctrl_NetworkGetConfigurationReply, particle_ctrl_NetworkGetConfigurationReply, AUTO) + + +PB_BIND(particle_ctrl_NetworkSetConfigurationRequest, particle_ctrl_NetworkSetConfigurationRequest, AUTO) + + +PB_BIND(particle_ctrl_NetworkSetConfigurationReply, particle_ctrl_NetworkSetConfigurationReply, AUTO) + + +PB_BIND(particle_ctrl_IPConfiguration, particle_ctrl_IPConfiguration, AUTO) + + +PB_BIND(particle_ctrl_DNSConfiguration, particle_ctrl_DNSConfiguration, AUTO) + + +PB_BIND(particle_ctrl_NetworkConfiguration, particle_ctrl_NetworkConfiguration, AUTO) + + +PB_BIND(particle_ctrl_InterfaceAddress, particle_ctrl_InterfaceAddress, AUTO) + + +PB_BIND(particle_ctrl_Ipv4Config, particle_ctrl_Ipv4Config, AUTO) + + +PB_BIND(particle_ctrl_Ipv6Config, particle_ctrl_Ipv6Config, AUTO) + + +PB_BIND(particle_ctrl_Interface, particle_ctrl_Interface, AUTO) + + +PB_BIND(particle_ctrl_InterfaceEntry, particle_ctrl_InterfaceEntry, AUTO) + + +PB_BIND(particle_ctrl_GetInterfaceListRequest, particle_ctrl_GetInterfaceListRequest, AUTO) + + +PB_BIND(particle_ctrl_GetInterfaceListReply, particle_ctrl_GetInterfaceListReply, AUTO) + + +PB_BIND(particle_ctrl_GetInterfaceRequest, particle_ctrl_GetInterfaceRequest, AUTO) + + +PB_BIND(particle_ctrl_GetInterfaceReply, particle_ctrl_GetInterfaceReply, AUTO) + + + -const pb_field_t particle_ctrl_NetworkGetStatusRequest_fields[2] = { - PB_FIELD( 1, INT32 , SINGULAR, STATIC , FIRST, particle_ctrl_NetworkGetStatusRequest, interface, interface, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_NetworkGetStatusReply_fields[2] = { - PB_FIELD( 1, MESSAGE , SINGULAR, STATIC , FIRST, particle_ctrl_NetworkGetStatusReply, config, config, &particle_ctrl_NetworkConfiguration_fields), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_NetworkGetConfigurationRequest_fields[2] = { - PB_FIELD( 1, INT32 , SINGULAR, STATIC , FIRST, particle_ctrl_NetworkGetConfigurationRequest, interface, interface, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_NetworkGetConfigurationReply_fields[2] = { - PB_FIELD( 1, MESSAGE , SINGULAR, STATIC , FIRST, particle_ctrl_NetworkGetConfigurationReply, config, config, &particle_ctrl_NetworkConfiguration_fields), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_NetworkSetConfigurationRequest_fields[2] = { - PB_FIELD( 1, MESSAGE , SINGULAR, STATIC , FIRST, particle_ctrl_NetworkSetConfigurationRequest, config, config, &particle_ctrl_NetworkConfiguration_fields), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_NetworkSetConfigurationReply_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_IPConfiguration_fields[7] = { - PB_FIELD( 1, UENUM , SINGULAR, STATIC , FIRST, particle_ctrl_IPConfiguration, type, type, 0), - PB_FIELD( 2, MESSAGE , SINGULAR, STATIC , OTHER, particle_ctrl_IPConfiguration, address, type, &particle_ctrl_IPAddress_fields), - PB_FIELD( 3, MESSAGE , SINGULAR, STATIC , OTHER, particle_ctrl_IPConfiguration, netmask, address, &particle_ctrl_IPAddress_fields), - PB_FIELD( 4, MESSAGE , SINGULAR, STATIC , OTHER, particle_ctrl_IPConfiguration, gateway, netmask, &particle_ctrl_IPAddress_fields), - PB_FIELD( 5, MESSAGE , SINGULAR, STATIC , OTHER, particle_ctrl_IPConfiguration, dhcp_server, gateway, &particle_ctrl_IPAddress_fields), - PB_FIELD( 6, STRING , SINGULAR, CALLBACK, OTHER, particle_ctrl_IPConfiguration, hostname, dhcp_server, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_DNSConfiguration_fields[2] = { - PB_FIELD( 1, MESSAGE , REPEATED, CALLBACK, FIRST, particle_ctrl_DNSConfiguration, servers, servers, &particle_ctrl_IPAddress_fields), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_NetworkConfiguration_fields[7] = { - PB_FIELD( 1, INT32 , SINGULAR, STATIC , FIRST, particle_ctrl_NetworkConfiguration, interface, interface, 0), - PB_FIELD( 2, UENUM , SINGULAR, STATIC , OTHER, particle_ctrl_NetworkConfiguration, state, interface, 0), - PB_FIELD( 3, STRING , SINGULAR, CALLBACK, OTHER, particle_ctrl_NetworkConfiguration, name, state, 0), - PB_FIELD( 4, BYTES , SINGULAR, STATIC , OTHER, particle_ctrl_NetworkConfiguration, mac, name, 0), - PB_FIELD( 5, MESSAGE , SINGULAR, STATIC , OTHER, particle_ctrl_NetworkConfiguration, ipconfig, mac, &particle_ctrl_IPConfiguration_fields), - PB_FIELD( 6, MESSAGE , SINGULAR, STATIC , OTHER, particle_ctrl_NetworkConfiguration, dnsconfig, ipconfig, &particle_ctrl_DNSConfiguration_fields), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_InterfaceAddress_fields[3] = { - PB_FIELD( 1, MESSAGE , SINGULAR, STATIC , FIRST, particle_ctrl_InterfaceAddress, address, address, &particle_ctrl_IpAddress_fields), - PB_FIELD( 2, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_InterfaceAddress, prefix_length, address, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_Ipv4Config_fields[4] = { - PB_FIELD( 1, MESSAGE , REPEATED, CALLBACK, FIRST, particle_ctrl_Ipv4Config, addresses, addresses, &particle_ctrl_InterfaceAddress_fields), - PB_FIELD( 2, MESSAGE , SINGULAR, STATIC , OTHER, particle_ctrl_Ipv4Config, peer, addresses, &particle_ctrl_Ipv4Address_fields), - PB_FIELD( 3, MESSAGE , SINGULAR, STATIC , OTHER, particle_ctrl_Ipv4Config, gateway, peer, &particle_ctrl_Ipv4Address_fields), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_Ipv6Config_fields[2] = { - PB_FIELD( 1, MESSAGE , REPEATED, CALLBACK, FIRST, particle_ctrl_Ipv6Config, addresses, addresses, &particle_ctrl_InterfaceAddress_fields), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_Interface_fields[11] = { - PB_FIELD( 1, UINT32 , SINGULAR, STATIC , FIRST, particle_ctrl_Interface, index, index, 0), - PB_FIELD( 2, STRING , SINGULAR, CALLBACK, OTHER, particle_ctrl_Interface, name, index, 0), - PB_FIELD( 3, UENUM , SINGULAR, STATIC , OTHER, particle_ctrl_Interface, type, name, 0), - PB_FIELD( 4, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_Interface, flags, type, 0), - PB_FIELD( 5, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_Interface, ext_flags, flags, 0), - PB_FIELD( 6, MESSAGE , SINGULAR, STATIC , OTHER, particle_ctrl_Interface, ipv4_config, ext_flags, &particle_ctrl_Ipv4Config_fields), - PB_FIELD( 7, MESSAGE , SINGULAR, STATIC , OTHER, particle_ctrl_Interface, ipv6_config, ipv4_config, &particle_ctrl_Ipv6Config_fields), - PB_FIELD( 8, BYTES , SINGULAR, STATIC , OTHER, particle_ctrl_Interface, hw_address, ipv6_config, 0), - PB_FIELD( 9, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_Interface, mtu, hw_address, 0), - PB_FIELD( 10, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_Interface, metric, mtu, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_InterfaceEntry_fields[4] = { - PB_FIELD( 1, UINT32 , SINGULAR, STATIC , FIRST, particle_ctrl_InterfaceEntry, index, index, 0), - PB_FIELD( 2, STRING , SINGULAR, CALLBACK, OTHER, particle_ctrl_InterfaceEntry, name, index, 0), - PB_FIELD( 3, UENUM , SINGULAR, STATIC , OTHER, particle_ctrl_InterfaceEntry, type, name, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_GetInterfaceListRequest_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_GetInterfaceListReply_fields[2] = { - PB_FIELD( 1, MESSAGE , REPEATED, CALLBACK, FIRST, particle_ctrl_GetInterfaceListReply, interfaces, interfaces, &particle_ctrl_InterfaceEntry_fields), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_GetInterfaceRequest_fields[2] = { - PB_FIELD( 1, UINT32 , SINGULAR, STATIC , FIRST, particle_ctrl_GetInterfaceRequest, index, index, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_GetInterfaceReply_fields[2] = { - PB_FIELD( 1, MESSAGE , SINGULAR, STATIC , FIRST, particle_ctrl_GetInterfaceReply, interface, interface, &particle_ctrl_Interface_fields), - PB_LAST_FIELD -}; - - - - - - - -/* Check that field information fits in pb_field_t */ -#if !defined(PB_FIELD_32BIT) -/* If you get an error here, it means that you need to define PB_FIELD_32BIT - * compile-time option. You can do that in pb.h or on compiler command line. - * - * The reason you need to do this is that some of your messages contain tag - * numbers or field sizes that are larger than what can fit in 8 or 16 bit - * field descriptors. - */ -PB_STATIC_ASSERT((pb_membersize(particle_ctrl_NetworkGetStatusReply, config) < 65536 && pb_membersize(particle_ctrl_NetworkGetConfigurationReply, config) < 65536 && pb_membersize(particle_ctrl_NetworkSetConfigurationRequest, config) < 65536 && pb_membersize(particle_ctrl_IPConfiguration, address) < 65536 && pb_membersize(particle_ctrl_IPConfiguration, netmask) < 65536 && pb_membersize(particle_ctrl_IPConfiguration, gateway) < 65536 && pb_membersize(particle_ctrl_IPConfiguration, dhcp_server) < 65536 && pb_membersize(particle_ctrl_NetworkConfiguration, ipconfig) < 65536 && pb_membersize(particle_ctrl_NetworkConfiguration, dnsconfig) < 65536 && pb_membersize(particle_ctrl_InterfaceAddress, address) < 65536 && pb_membersize(particle_ctrl_Ipv4Config, peer) < 65536 && pb_membersize(particle_ctrl_Ipv4Config, gateway) < 65536 && pb_membersize(particle_ctrl_Interface, ipv4_config) < 65536 && pb_membersize(particle_ctrl_Interface, ipv6_config) < 65536 && pb_membersize(particle_ctrl_GetInterfaceReply, interface) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_particle_ctrl_NetworkGetStatusRequest_particle_ctrl_NetworkGetStatusReply_particle_ctrl_NetworkGetConfigurationRequest_particle_ctrl_NetworkGetConfigurationReply_particle_ctrl_NetworkSetConfigurationRequest_particle_ctrl_NetworkSetConfigurationReply_particle_ctrl_IPConfiguration_particle_ctrl_DNSConfiguration_particle_ctrl_NetworkConfiguration_particle_ctrl_InterfaceAddress_particle_ctrl_Ipv4Config_particle_ctrl_Ipv6Config_particle_ctrl_Interface_particle_ctrl_InterfaceEntry_particle_ctrl_GetInterfaceListRequest_particle_ctrl_GetInterfaceListReply_particle_ctrl_GetInterfaceRequest_particle_ctrl_GetInterfaceReply) -#endif -#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT) -/* If you get an error here, it means that you need to define PB_FIELD_16BIT - * compile-time option. You can do that in pb.h or on compiler command line. - * - * The reason you need to do this is that some of your messages contain tag - * numbers or field sizes that are larger than what can fit in the default - * 8 bit descriptors. - */ -PB_STATIC_ASSERT((pb_membersize(particle_ctrl_NetworkGetStatusReply, config) < 256 && pb_membersize(particle_ctrl_NetworkGetConfigurationReply, config) < 256 && pb_membersize(particle_ctrl_NetworkSetConfigurationRequest, config) < 256 && pb_membersize(particle_ctrl_IPConfiguration, address) < 256 && pb_membersize(particle_ctrl_IPConfiguration, netmask) < 256 && pb_membersize(particle_ctrl_IPConfiguration, gateway) < 256 && pb_membersize(particle_ctrl_IPConfiguration, dhcp_server) < 256 && pb_membersize(particle_ctrl_NetworkConfiguration, ipconfig) < 256 && pb_membersize(particle_ctrl_NetworkConfiguration, dnsconfig) < 256 && pb_membersize(particle_ctrl_InterfaceAddress, address) < 256 && pb_membersize(particle_ctrl_Ipv4Config, peer) < 256 && pb_membersize(particle_ctrl_Ipv4Config, gateway) < 256 && pb_membersize(particle_ctrl_Interface, ipv4_config) < 256 && pb_membersize(particle_ctrl_Interface, ipv6_config) < 256 && pb_membersize(particle_ctrl_GetInterfaceReply, interface) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_particle_ctrl_NetworkGetStatusRequest_particle_ctrl_NetworkGetStatusReply_particle_ctrl_NetworkGetConfigurationRequest_particle_ctrl_NetworkGetConfigurationReply_particle_ctrl_NetworkSetConfigurationRequest_particle_ctrl_NetworkSetConfigurationReply_particle_ctrl_IPConfiguration_particle_ctrl_DNSConfiguration_particle_ctrl_NetworkConfiguration_particle_ctrl_InterfaceAddress_particle_ctrl_Ipv4Config_particle_ctrl_Ipv6Config_particle_ctrl_Interface_particle_ctrl_InterfaceEntry_particle_ctrl_GetInterfaceListRequest_particle_ctrl_GetInterfaceListReply_particle_ctrl_GetInterfaceRequest_particle_ctrl_GetInterfaceReply) -#endif -/* @@protoc_insertion_point(eof) */ diff --git a/system/src/control/proto/network.pb.h b/system/src/control/proto/network.pb.h index 34e6f225e5..c21c2c34ce 100644 --- a/system/src/control/proto/network.pb.h +++ b/system/src/control/proto/network.pb.h @@ -1,241 +1,246 @@ /* Automatically generated nanopb header */ -/* Generated by nanopb-0.3.9 at Tue Jan 29 21:26:45 2019. */ +/* Generated by nanopb-0.4.5 */ #ifndef PB_PARTICLE_CTRL_NETWORK_PB_H_INCLUDED #define PB_PARTICLE_CTRL_NETWORK_PB_H_INCLUDED #include - #include "extensions.pb.h" - #include "common.pb.h" -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 +#if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif -#ifdef __cplusplus -extern "C" { -#endif - /* Enum definitions */ -typedef enum _particle_ctrl_NetworkState { - particle_ctrl_NetworkState_NETWORK_STATUS_NONE = 0, - particle_ctrl_NetworkState_DOWN = 1, - particle_ctrl_NetworkState_UP = 2 +typedef enum _particle_ctrl_NetworkState { + particle_ctrl_NetworkState_NETWORK_STATUS_NONE = 0, + particle_ctrl_NetworkState_DOWN = 1, + particle_ctrl_NetworkState_UP = 2 } particle_ctrl_NetworkState; -#define _particle_ctrl_NetworkState_MIN particle_ctrl_NetworkState_NETWORK_STATUS_NONE -#define _particle_ctrl_NetworkState_MAX particle_ctrl_NetworkState_UP -#define _particle_ctrl_NetworkState_ARRAYSIZE ((particle_ctrl_NetworkState)(particle_ctrl_NetworkState_UP+1)) -typedef enum _particle_ctrl_InterfaceFlag { - particle_ctrl_InterfaceFlag_IFF_NONE = 0, - particle_ctrl_InterfaceFlag_IFF_UP = 1, - particle_ctrl_InterfaceFlag_IFF_BROADCAST = 2, - particle_ctrl_InterfaceFlag_IFF_DEBUG = 4, - particle_ctrl_InterfaceFlag_IFF_LOOPBACK = 8, - particle_ctrl_InterfaceFlag_IFF_POINTTOPOINT = 16, - particle_ctrl_InterfaceFlag_IFF_RUNNING = 64, - particle_ctrl_InterfaceFlag_IFF_LOWER_UP = 64, - particle_ctrl_InterfaceFlag_IFF_NOARP = 128, - particle_ctrl_InterfaceFlag_IFF_PROMISC = 256, - particle_ctrl_InterfaceFlag_IFF_ALLMULTI = 512, - particle_ctrl_InterfaceFlag_IFF_MULTICAST = 32768, - particle_ctrl_InterfaceFlag_IFF_NOND6 = 65536 +/* Direct mapping to if_flags_t */ +typedef enum _particle_ctrl_InterfaceFlag { + particle_ctrl_InterfaceFlag_IFF_NONE = 0, + particle_ctrl_InterfaceFlag_IFF_UP = 1, + particle_ctrl_InterfaceFlag_IFF_BROADCAST = 2, + particle_ctrl_InterfaceFlag_IFF_DEBUG = 4, + particle_ctrl_InterfaceFlag_IFF_LOOPBACK = 8, + particle_ctrl_InterfaceFlag_IFF_POINTTOPOINT = 16, + particle_ctrl_InterfaceFlag_IFF_RUNNING = 64, + particle_ctrl_InterfaceFlag_IFF_LOWER_UP = 64, + particle_ctrl_InterfaceFlag_IFF_NOARP = 128, + particle_ctrl_InterfaceFlag_IFF_PROMISC = 256, + particle_ctrl_InterfaceFlag_IFF_ALLMULTI = 512, + particle_ctrl_InterfaceFlag_IFF_MULTICAST = 32768, + particle_ctrl_InterfaceFlag_IFF_NOND6 = 65536 } particle_ctrl_InterfaceFlag; -#define _particle_ctrl_InterfaceFlag_MIN particle_ctrl_InterfaceFlag_IFF_NONE -#define _particle_ctrl_InterfaceFlag_MAX particle_ctrl_InterfaceFlag_IFF_NOND6 -#define _particle_ctrl_InterfaceFlag_ARRAYSIZE ((particle_ctrl_InterfaceFlag)(particle_ctrl_InterfaceFlag_IFF_NOND6+1)) -typedef enum _particle_ctrl_InterfaceExtFlag { - particle_ctrl_InterfaceExtFlag_IFXF_NONE = 0, - particle_ctrl_InterfaceExtFlag_IFXF_WOL = 16, - particle_ctrl_InterfaceExtFlag_IFXF_AUTOCONF6 = 32, - particle_ctrl_InterfaceExtFlag_IFXF_DHCP = 65536, - particle_ctrl_InterfaceExtFlag_IFXF_DHCP6 = 131072, - particle_ctrl_InterfaceExtFlag_IFXF_AUTOIP = 262144 +/* Direct mapping to if_xflags_t */ +typedef enum _particle_ctrl_InterfaceExtFlag { + particle_ctrl_InterfaceExtFlag_IFXF_NONE = 0, + particle_ctrl_InterfaceExtFlag_IFXF_WOL = 16, + particle_ctrl_InterfaceExtFlag_IFXF_AUTOCONF6 = 32, + particle_ctrl_InterfaceExtFlag_IFXF_DHCP = 65536, + particle_ctrl_InterfaceExtFlag_IFXF_DHCP6 = 131072, + particle_ctrl_InterfaceExtFlag_IFXF_AUTOIP = 262144 } particle_ctrl_InterfaceExtFlag; -#define _particle_ctrl_InterfaceExtFlag_MIN particle_ctrl_InterfaceExtFlag_IFXF_NONE -#define _particle_ctrl_InterfaceExtFlag_MAX particle_ctrl_InterfaceExtFlag_IFXF_AUTOIP -#define _particle_ctrl_InterfaceExtFlag_ARRAYSIZE ((particle_ctrl_InterfaceExtFlag)(particle_ctrl_InterfaceExtFlag_IFXF_AUTOIP+1)) -typedef enum _particle_ctrl_InterfaceType { - particle_ctrl_InterfaceType_INVALID_INTERFACE_TYPE = 0, - particle_ctrl_InterfaceType_LOOPBACK = 1, - particle_ctrl_InterfaceType_THREAD = 2, - particle_ctrl_InterfaceType_ETHERNET = 4, - particle_ctrl_InterfaceType_WIFI = 8, - particle_ctrl_InterfaceType_PPP = 16 +typedef enum _particle_ctrl_InterfaceType { + particle_ctrl_InterfaceType_INVALID_INTERFACE_TYPE = 0, + particle_ctrl_InterfaceType_LOOPBACK = 1, + particle_ctrl_InterfaceType_THREAD = 2, + particle_ctrl_InterfaceType_ETHERNET = 4, + particle_ctrl_InterfaceType_WIFI = 8, + particle_ctrl_InterfaceType_PPP = 16 } particle_ctrl_InterfaceType; -#define _particle_ctrl_InterfaceType_MIN particle_ctrl_InterfaceType_INVALID_INTERFACE_TYPE -#define _particle_ctrl_InterfaceType_MAX particle_ctrl_InterfaceType_PPP -#define _particle_ctrl_InterfaceType_ARRAYSIZE ((particle_ctrl_InterfaceType)(particle_ctrl_InterfaceType_PPP+1)) -typedef enum _particle_ctrl_IPConfiguration_Type { - particle_ctrl_IPConfiguration_Type_NONE = 0, - particle_ctrl_IPConfiguration_Type_DHCP = 1, - particle_ctrl_IPConfiguration_Type_STATIC = 2 +typedef enum _particle_ctrl_IPConfiguration_Type { + particle_ctrl_IPConfiguration_Type_NONE = 0, + particle_ctrl_IPConfiguration_Type_DHCP = 1, + particle_ctrl_IPConfiguration_Type_STATIC = 2 } particle_ctrl_IPConfiguration_Type; -#define _particle_ctrl_IPConfiguration_Type_MIN particle_ctrl_IPConfiguration_Type_NONE -#define _particle_ctrl_IPConfiguration_Type_MAX particle_ctrl_IPConfiguration_Type_STATIC -#define _particle_ctrl_IPConfiguration_Type_ARRAYSIZE ((particle_ctrl_IPConfiguration_Type)(particle_ctrl_IPConfiguration_Type_STATIC+1)) /* Struct definitions */ -typedef struct _particle_ctrl_DNSConfiguration { - pb_callback_t servers; -/* @@protoc_insertion_point(struct:particle_ctrl_DNSConfiguration) */ +typedef struct _particle_ctrl_DNSConfiguration { + pb_callback_t servers; } particle_ctrl_DNSConfiguration; -typedef struct _particle_ctrl_GetInterfaceListReply { - pb_callback_t interfaces; -/* @@protoc_insertion_point(struct:particle_ctrl_GetInterfaceListReply) */ +typedef struct _particle_ctrl_GetInterfaceListReply { + pb_callback_t interfaces; } particle_ctrl_GetInterfaceListReply; -typedef struct _particle_ctrl_GetInterfaceListRequest { +typedef struct _particle_ctrl_GetInterfaceListRequest { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_GetInterfaceListRequest) */ } particle_ctrl_GetInterfaceListRequest; -typedef struct _particle_ctrl_Ipv6Config { - pb_callback_t addresses; -/* @@protoc_insertion_point(struct:particle_ctrl_Ipv6Config) */ +typedef struct _particle_ctrl_Ipv6Config { + pb_callback_t addresses; } particle_ctrl_Ipv6Config; -typedef struct _particle_ctrl_NetworkSetConfigurationReply { +typedef struct _particle_ctrl_NetworkSetConfigurationReply { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_NetworkSetConfigurationReply) */ } particle_ctrl_NetworkSetConfigurationReply; -typedef struct _particle_ctrl_GetInterfaceRequest { - uint32_t index; -/* @@protoc_insertion_point(struct:particle_ctrl_GetInterfaceRequest) */ +typedef struct _particle_ctrl_GetInterfaceRequest { + uint32_t index; } particle_ctrl_GetInterfaceRequest; -typedef struct _particle_ctrl_IPConfiguration { - particle_ctrl_IPConfiguration_Type type; - particle_ctrl_IPAddress address; - particle_ctrl_IPAddress netmask; - particle_ctrl_IPAddress gateway; - particle_ctrl_IPAddress dhcp_server; - pb_callback_t hostname; -/* @@protoc_insertion_point(struct:particle_ctrl_IPConfiguration) */ +typedef struct _particle_ctrl_IPConfiguration { + particle_ctrl_IPConfiguration_Type type; + bool has_address; + particle_ctrl_IPAddress address; + bool has_netmask; + particle_ctrl_IPAddress netmask; + bool has_gateway; + particle_ctrl_IPAddress gateway; + bool has_dhcp_server; + particle_ctrl_IPAddress dhcp_server; + pb_callback_t hostname; } particle_ctrl_IPConfiguration; -typedef struct _particle_ctrl_InterfaceAddress { - particle_ctrl_IpAddress address; - uint32_t prefix_length; -/* @@protoc_insertion_point(struct:particle_ctrl_InterfaceAddress) */ +typedef struct _particle_ctrl_InterfaceAddress { + bool has_address; + particle_ctrl_IpAddress address; + uint32_t prefix_length; /* TODO: state, scope, lifetimes, etc. */ } particle_ctrl_InterfaceAddress; -typedef struct _particle_ctrl_InterfaceEntry { - uint32_t index; - pb_callback_t name; - particle_ctrl_InterfaceType type; -/* @@protoc_insertion_point(struct:particle_ctrl_InterfaceEntry) */ +typedef struct _particle_ctrl_InterfaceEntry { + uint32_t index; + pb_callback_t name; + particle_ctrl_InterfaceType type; } particle_ctrl_InterfaceEntry; -typedef struct _particle_ctrl_Ipv4Config { - pb_callback_t addresses; - particle_ctrl_Ipv4Address peer; - particle_ctrl_Ipv4Address gateway; -/* @@protoc_insertion_point(struct:particle_ctrl_Ipv4Config) */ +typedef struct _particle_ctrl_Ipv4Config { + pb_callback_t addresses; + /* On P2P links */ + bool has_peer; + particle_ctrl_Ipv4Address peer; + /* Temporary, will be moved to routing table */ + bool has_gateway; + particle_ctrl_Ipv4Address gateway; } particle_ctrl_Ipv4Config; -typedef struct _particle_ctrl_NetworkGetConfigurationRequest { - int32_t interface; -/* @@protoc_insertion_point(struct:particle_ctrl_NetworkGetConfigurationRequest) */ +typedef struct _particle_ctrl_NetworkGetConfigurationRequest { + int32_t interface; } particle_ctrl_NetworkGetConfigurationRequest; -typedef struct _particle_ctrl_NetworkGetStatusRequest { - int32_t interface; -/* @@protoc_insertion_point(struct:particle_ctrl_NetworkGetStatusRequest) */ +typedef struct _particle_ctrl_NetworkGetStatusRequest { + int32_t interface; } particle_ctrl_NetworkGetStatusRequest; typedef PB_BYTES_ARRAY_T(8) particle_ctrl_Interface_hw_address_t; -typedef struct _particle_ctrl_Interface { - uint32_t index; - pb_callback_t name; - particle_ctrl_InterfaceType type; - uint32_t flags; - uint32_t ext_flags; - particle_ctrl_Ipv4Config ipv4_config; - particle_ctrl_Ipv6Config ipv6_config; - particle_ctrl_Interface_hw_address_t hw_address; - uint32_t mtu; - uint32_t metric; -/* @@protoc_insertion_point(struct:particle_ctrl_Interface) */ +/* Operation state of the interface */ +typedef struct _particle_ctrl_Interface { + uint32_t index; + pb_callback_t name; + particle_ctrl_InterfaceType type; + uint32_t flags; /* InterfaceFlag */ + uint32_t ext_flags; /* InterfaceExtFlag */ + bool has_ipv4_config; + particle_ctrl_Ipv4Config ipv4_config; + bool has_ipv6_config; + particle_ctrl_Ipv6Config ipv6_config; + particle_ctrl_Interface_hw_address_t hw_address; + uint32_t mtu; + uint32_t metric; } particle_ctrl_Interface; typedef PB_BYTES_ARRAY_T(6) particle_ctrl_NetworkConfiguration_mac_t; -typedef struct _particle_ctrl_NetworkConfiguration { - int32_t interface; - particle_ctrl_NetworkState state; - pb_callback_t name; - particle_ctrl_NetworkConfiguration_mac_t mac; - particle_ctrl_IPConfiguration ipconfig; - particle_ctrl_DNSConfiguration dnsconfig; -/* @@protoc_insertion_point(struct:particle_ctrl_NetworkConfiguration) */ +typedef struct _particle_ctrl_NetworkConfiguration { + int32_t interface; + particle_ctrl_NetworkState state; + pb_callback_t name; + particle_ctrl_NetworkConfiguration_mac_t mac; + bool has_ipconfig; + particle_ctrl_IPConfiguration ipconfig; + bool has_dnsconfig; + particle_ctrl_DNSConfiguration dnsconfig; } particle_ctrl_NetworkConfiguration; -typedef struct _particle_ctrl_GetInterfaceReply { - particle_ctrl_Interface interface; -/* @@protoc_insertion_point(struct:particle_ctrl_GetInterfaceReply) */ +typedef struct _particle_ctrl_GetInterfaceReply { + bool has_interface; + particle_ctrl_Interface interface; } particle_ctrl_GetInterfaceReply; -typedef struct _particle_ctrl_NetworkGetConfigurationReply { - particle_ctrl_NetworkConfiguration config; -/* @@protoc_insertion_point(struct:particle_ctrl_NetworkGetConfigurationReply) */ +typedef struct _particle_ctrl_NetworkGetConfigurationReply { + bool has_config; + particle_ctrl_NetworkConfiguration config; } particle_ctrl_NetworkGetConfigurationReply; -typedef struct _particle_ctrl_NetworkGetStatusReply { - particle_ctrl_NetworkConfiguration config; -/* @@protoc_insertion_point(struct:particle_ctrl_NetworkGetStatusReply) */ +typedef struct _particle_ctrl_NetworkGetStatusReply { + bool has_config; + particle_ctrl_NetworkConfiguration config; } particle_ctrl_NetworkGetStatusReply; -typedef struct _particle_ctrl_NetworkSetConfigurationRequest { - particle_ctrl_NetworkConfiguration config; -/* @@protoc_insertion_point(struct:particle_ctrl_NetworkSetConfigurationRequest) */ +typedef struct _particle_ctrl_NetworkSetConfigurationRequest { + bool has_config; + particle_ctrl_NetworkConfiguration config; } particle_ctrl_NetworkSetConfigurationRequest; -/* Default values for struct fields */ + +/* Helper constants for enums */ +#define _particle_ctrl_NetworkState_MIN particle_ctrl_NetworkState_NETWORK_STATUS_NONE +#define _particle_ctrl_NetworkState_MAX particle_ctrl_NetworkState_UP +#define _particle_ctrl_NetworkState_ARRAYSIZE ((particle_ctrl_NetworkState)(particle_ctrl_NetworkState_UP+1)) + +#define _particle_ctrl_InterfaceFlag_MIN particle_ctrl_InterfaceFlag_IFF_NONE +#define _particle_ctrl_InterfaceFlag_MAX particle_ctrl_InterfaceFlag_IFF_NOND6 +#define _particle_ctrl_InterfaceFlag_ARRAYSIZE ((particle_ctrl_InterfaceFlag)(particle_ctrl_InterfaceFlag_IFF_NOND6+1)) + +#define _particle_ctrl_InterfaceExtFlag_MIN particle_ctrl_InterfaceExtFlag_IFXF_NONE +#define _particle_ctrl_InterfaceExtFlag_MAX particle_ctrl_InterfaceExtFlag_IFXF_AUTOIP +#define _particle_ctrl_InterfaceExtFlag_ARRAYSIZE ((particle_ctrl_InterfaceExtFlag)(particle_ctrl_InterfaceExtFlag_IFXF_AUTOIP+1)) + +#define _particle_ctrl_InterfaceType_MIN particle_ctrl_InterfaceType_INVALID_INTERFACE_TYPE +#define _particle_ctrl_InterfaceType_MAX particle_ctrl_InterfaceType_PPP +#define _particle_ctrl_InterfaceType_ARRAYSIZE ((particle_ctrl_InterfaceType)(particle_ctrl_InterfaceType_PPP+1)) + +#define _particle_ctrl_IPConfiguration_Type_MIN particle_ctrl_IPConfiguration_Type_NONE +#define _particle_ctrl_IPConfiguration_Type_MAX particle_ctrl_IPConfiguration_Type_STATIC +#define _particle_ctrl_IPConfiguration_Type_ARRAYSIZE ((particle_ctrl_IPConfiguration_Type)(particle_ctrl_IPConfiguration_Type_STATIC+1)) + + +#ifdef __cplusplus +extern "C" { +#endif /* Initializer values for message structs */ #define particle_ctrl_NetworkGetStatusRequest_init_default {0} -#define particle_ctrl_NetworkGetStatusReply_init_default {particle_ctrl_NetworkConfiguration_init_default} +#define particle_ctrl_NetworkGetStatusReply_init_default {false, particle_ctrl_NetworkConfiguration_init_default} #define particle_ctrl_NetworkGetConfigurationRequest_init_default {0} -#define particle_ctrl_NetworkGetConfigurationReply_init_default {particle_ctrl_NetworkConfiguration_init_default} -#define particle_ctrl_NetworkSetConfigurationRequest_init_default {particle_ctrl_NetworkConfiguration_init_default} +#define particle_ctrl_NetworkGetConfigurationReply_init_default {false, particle_ctrl_NetworkConfiguration_init_default} +#define particle_ctrl_NetworkSetConfigurationRequest_init_default {false, particle_ctrl_NetworkConfiguration_init_default} #define particle_ctrl_NetworkSetConfigurationReply_init_default {0} -#define particle_ctrl_IPConfiguration_init_default {(particle_ctrl_IPConfiguration_Type)0, particle_ctrl_IPAddress_init_default, particle_ctrl_IPAddress_init_default, particle_ctrl_IPAddress_init_default, particle_ctrl_IPAddress_init_default, {{NULL}, NULL}} +#define particle_ctrl_IPConfiguration_init_default {_particle_ctrl_IPConfiguration_Type_MIN, false, particle_ctrl_IPAddress_init_default, false, particle_ctrl_IPAddress_init_default, false, particle_ctrl_IPAddress_init_default, false, particle_ctrl_IPAddress_init_default, {{NULL}, NULL}} #define particle_ctrl_DNSConfiguration_init_default {{{NULL}, NULL}} -#define particle_ctrl_NetworkConfiguration_init_default {0, (particle_ctrl_NetworkState)0, {{NULL}, NULL}, {0, {0}}, particle_ctrl_IPConfiguration_init_default, particle_ctrl_DNSConfiguration_init_default} -#define particle_ctrl_InterfaceAddress_init_default {particle_ctrl_IpAddress_init_default, 0} -#define particle_ctrl_Ipv4Config_init_default {{{NULL}, NULL}, particle_ctrl_Ipv4Address_init_default, particle_ctrl_Ipv4Address_init_default} +#define particle_ctrl_NetworkConfiguration_init_default {0, _particle_ctrl_NetworkState_MIN, {{NULL}, NULL}, {0, {0}}, false, particle_ctrl_IPConfiguration_init_default, false, particle_ctrl_DNSConfiguration_init_default} +#define particle_ctrl_InterfaceAddress_init_default {false, particle_ctrl_IpAddress_init_default, 0} +#define particle_ctrl_Ipv4Config_init_default {{{NULL}, NULL}, false, particle_ctrl_Ipv4Address_init_default, false, particle_ctrl_Ipv4Address_init_default} #define particle_ctrl_Ipv6Config_init_default {{{NULL}, NULL}} -#define particle_ctrl_Interface_init_default {0, {{NULL}, NULL}, (particle_ctrl_InterfaceType)0, 0, 0, particle_ctrl_Ipv4Config_init_default, particle_ctrl_Ipv6Config_init_default, {0, {0}}, 0, 0} -#define particle_ctrl_InterfaceEntry_init_default {0, {{NULL}, NULL}, (particle_ctrl_InterfaceType)0} +#define particle_ctrl_Interface_init_default {0, {{NULL}, NULL}, _particle_ctrl_InterfaceType_MIN, 0, 0, false, particle_ctrl_Ipv4Config_init_default, false, particle_ctrl_Ipv6Config_init_default, {0, {0}}, 0, 0} +#define particle_ctrl_InterfaceEntry_init_default {0, {{NULL}, NULL}, _particle_ctrl_InterfaceType_MIN} #define particle_ctrl_GetInterfaceListRequest_init_default {0} #define particle_ctrl_GetInterfaceListReply_init_default {{{NULL}, NULL}} #define particle_ctrl_GetInterfaceRequest_init_default {0} -#define particle_ctrl_GetInterfaceReply_init_default {particle_ctrl_Interface_init_default} +#define particle_ctrl_GetInterfaceReply_init_default {false, particle_ctrl_Interface_init_default} #define particle_ctrl_NetworkGetStatusRequest_init_zero {0} -#define particle_ctrl_NetworkGetStatusReply_init_zero {particle_ctrl_NetworkConfiguration_init_zero} +#define particle_ctrl_NetworkGetStatusReply_init_zero {false, particle_ctrl_NetworkConfiguration_init_zero} #define particle_ctrl_NetworkGetConfigurationRequest_init_zero {0} -#define particle_ctrl_NetworkGetConfigurationReply_init_zero {particle_ctrl_NetworkConfiguration_init_zero} -#define particle_ctrl_NetworkSetConfigurationRequest_init_zero {particle_ctrl_NetworkConfiguration_init_zero} +#define particle_ctrl_NetworkGetConfigurationReply_init_zero {false, particle_ctrl_NetworkConfiguration_init_zero} +#define particle_ctrl_NetworkSetConfigurationRequest_init_zero {false, particle_ctrl_NetworkConfiguration_init_zero} #define particle_ctrl_NetworkSetConfigurationReply_init_zero {0} -#define particle_ctrl_IPConfiguration_init_zero {(particle_ctrl_IPConfiguration_Type)0, particle_ctrl_IPAddress_init_zero, particle_ctrl_IPAddress_init_zero, particle_ctrl_IPAddress_init_zero, particle_ctrl_IPAddress_init_zero, {{NULL}, NULL}} +#define particle_ctrl_IPConfiguration_init_zero {_particle_ctrl_IPConfiguration_Type_MIN, false, particle_ctrl_IPAddress_init_zero, false, particle_ctrl_IPAddress_init_zero, false, particle_ctrl_IPAddress_init_zero, false, particle_ctrl_IPAddress_init_zero, {{NULL}, NULL}} #define particle_ctrl_DNSConfiguration_init_zero {{{NULL}, NULL}} -#define particle_ctrl_NetworkConfiguration_init_zero {0, (particle_ctrl_NetworkState)0, {{NULL}, NULL}, {0, {0}}, particle_ctrl_IPConfiguration_init_zero, particle_ctrl_DNSConfiguration_init_zero} -#define particle_ctrl_InterfaceAddress_init_zero {particle_ctrl_IpAddress_init_zero, 0} -#define particle_ctrl_Ipv4Config_init_zero {{{NULL}, NULL}, particle_ctrl_Ipv4Address_init_zero, particle_ctrl_Ipv4Address_init_zero} +#define particle_ctrl_NetworkConfiguration_init_zero {0, _particle_ctrl_NetworkState_MIN, {{NULL}, NULL}, {0, {0}}, false, particle_ctrl_IPConfiguration_init_zero, false, particle_ctrl_DNSConfiguration_init_zero} +#define particle_ctrl_InterfaceAddress_init_zero {false, particle_ctrl_IpAddress_init_zero, 0} +#define particle_ctrl_Ipv4Config_init_zero {{{NULL}, NULL}, false, particle_ctrl_Ipv4Address_init_zero, false, particle_ctrl_Ipv4Address_init_zero} #define particle_ctrl_Ipv6Config_init_zero {{{NULL}, NULL}} -#define particle_ctrl_Interface_init_zero {0, {{NULL}, NULL}, (particle_ctrl_InterfaceType)0, 0, 0, particle_ctrl_Ipv4Config_init_zero, particle_ctrl_Ipv6Config_init_zero, {0, {0}}, 0, 0} -#define particle_ctrl_InterfaceEntry_init_zero {0, {{NULL}, NULL}, (particle_ctrl_InterfaceType)0} +#define particle_ctrl_Interface_init_zero {0, {{NULL}, NULL}, _particle_ctrl_InterfaceType_MIN, 0, 0, false, particle_ctrl_Ipv4Config_init_zero, false, particle_ctrl_Ipv6Config_init_zero, {0, {0}}, 0, 0} +#define particle_ctrl_InterfaceEntry_init_zero {0, {{NULL}, NULL}, _particle_ctrl_InterfaceType_MIN} #define particle_ctrl_GetInterfaceListRequest_init_zero {0} #define particle_ctrl_GetInterfaceListReply_init_zero {{{NULL}, NULL}} #define particle_ctrl_GetInterfaceRequest_init_zero {0} -#define particle_ctrl_GetInterfaceReply_init_zero {particle_ctrl_Interface_init_zero} +#define particle_ctrl_GetInterfaceReply_init_zero {false, particle_ctrl_Interface_init_zero} /* Field tags (for use in manual encoding/decoding) */ #define particle_ctrl_DNSConfiguration_servers_tag 1 @@ -280,56 +285,200 @@ typedef struct _particle_ctrl_NetworkSetConfigurationRequest { #define particle_ctrl_NetworkSetConfigurationRequest_config_tag 1 /* Struct field encoding specification for nanopb */ -extern const pb_field_t particle_ctrl_NetworkGetStatusRequest_fields[2]; -extern const pb_field_t particle_ctrl_NetworkGetStatusReply_fields[2]; -extern const pb_field_t particle_ctrl_NetworkGetConfigurationRequest_fields[2]; -extern const pb_field_t particle_ctrl_NetworkGetConfigurationReply_fields[2]; -extern const pb_field_t particle_ctrl_NetworkSetConfigurationRequest_fields[2]; -extern const pb_field_t particle_ctrl_NetworkSetConfigurationReply_fields[1]; -extern const pb_field_t particle_ctrl_IPConfiguration_fields[7]; -extern const pb_field_t particle_ctrl_DNSConfiguration_fields[2]; -extern const pb_field_t particle_ctrl_NetworkConfiguration_fields[7]; -extern const pb_field_t particle_ctrl_InterfaceAddress_fields[3]; -extern const pb_field_t particle_ctrl_Ipv4Config_fields[4]; -extern const pb_field_t particle_ctrl_Ipv6Config_fields[2]; -extern const pb_field_t particle_ctrl_Interface_fields[11]; -extern const pb_field_t particle_ctrl_InterfaceEntry_fields[4]; -extern const pb_field_t particle_ctrl_GetInterfaceListRequest_fields[1]; -extern const pb_field_t particle_ctrl_GetInterfaceListReply_fields[2]; -extern const pb_field_t particle_ctrl_GetInterfaceRequest_fields[2]; -extern const pb_field_t particle_ctrl_GetInterfaceReply_fields[2]; +#define particle_ctrl_NetworkGetStatusRequest_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, INT32, interface, 1) +#define particle_ctrl_NetworkGetStatusRequest_CALLBACK NULL +#define particle_ctrl_NetworkGetStatusRequest_DEFAULT NULL + +#define particle_ctrl_NetworkGetStatusReply_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, MESSAGE, config, 1) +#define particle_ctrl_NetworkGetStatusReply_CALLBACK NULL +#define particle_ctrl_NetworkGetStatusReply_DEFAULT NULL +#define particle_ctrl_NetworkGetStatusReply_config_MSGTYPE particle_ctrl_NetworkConfiguration + +#define particle_ctrl_NetworkGetConfigurationRequest_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, INT32, interface, 1) +#define particle_ctrl_NetworkGetConfigurationRequest_CALLBACK NULL +#define particle_ctrl_NetworkGetConfigurationRequest_DEFAULT NULL + +#define particle_ctrl_NetworkGetConfigurationReply_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, MESSAGE, config, 1) +#define particle_ctrl_NetworkGetConfigurationReply_CALLBACK NULL +#define particle_ctrl_NetworkGetConfigurationReply_DEFAULT NULL +#define particle_ctrl_NetworkGetConfigurationReply_config_MSGTYPE particle_ctrl_NetworkConfiguration + +#define particle_ctrl_NetworkSetConfigurationRequest_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, MESSAGE, config, 1) +#define particle_ctrl_NetworkSetConfigurationRequest_CALLBACK NULL +#define particle_ctrl_NetworkSetConfigurationRequest_DEFAULT NULL +#define particle_ctrl_NetworkSetConfigurationRequest_config_MSGTYPE particle_ctrl_NetworkConfiguration + +#define particle_ctrl_NetworkSetConfigurationReply_FIELDLIST(X, a) \ + +#define particle_ctrl_NetworkSetConfigurationReply_CALLBACK NULL +#define particle_ctrl_NetworkSetConfigurationReply_DEFAULT NULL + +#define particle_ctrl_IPConfiguration_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, type, 1) \ +X(a, STATIC, OPTIONAL, MESSAGE, address, 2) \ +X(a, STATIC, OPTIONAL, MESSAGE, netmask, 3) \ +X(a, STATIC, OPTIONAL, MESSAGE, gateway, 4) \ +X(a, STATIC, OPTIONAL, MESSAGE, dhcp_server, 5) \ +X(a, CALLBACK, SINGULAR, STRING, hostname, 6) +#define particle_ctrl_IPConfiguration_CALLBACK pb_default_field_callback +#define particle_ctrl_IPConfiguration_DEFAULT NULL +#define particle_ctrl_IPConfiguration_address_MSGTYPE particle_ctrl_IPAddress +#define particle_ctrl_IPConfiguration_netmask_MSGTYPE particle_ctrl_IPAddress +#define particle_ctrl_IPConfiguration_gateway_MSGTYPE particle_ctrl_IPAddress +#define particle_ctrl_IPConfiguration_dhcp_server_MSGTYPE particle_ctrl_IPAddress + +#define particle_ctrl_DNSConfiguration_FIELDLIST(X, a) \ +X(a, CALLBACK, REPEATED, MESSAGE, servers, 1) +#define particle_ctrl_DNSConfiguration_CALLBACK pb_default_field_callback +#define particle_ctrl_DNSConfiguration_DEFAULT NULL +#define particle_ctrl_DNSConfiguration_servers_MSGTYPE particle_ctrl_IPAddress + +#define particle_ctrl_NetworkConfiguration_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, INT32, interface, 1) \ +X(a, STATIC, SINGULAR, UENUM, state, 2) \ +X(a, CALLBACK, SINGULAR, STRING, name, 3) \ +X(a, STATIC, SINGULAR, BYTES, mac, 4) \ +X(a, STATIC, OPTIONAL, MESSAGE, ipconfig, 5) \ +X(a, STATIC, OPTIONAL, MESSAGE, dnsconfig, 6) +#define particle_ctrl_NetworkConfiguration_CALLBACK pb_default_field_callback +#define particle_ctrl_NetworkConfiguration_DEFAULT NULL +#define particle_ctrl_NetworkConfiguration_ipconfig_MSGTYPE particle_ctrl_IPConfiguration +#define particle_ctrl_NetworkConfiguration_dnsconfig_MSGTYPE particle_ctrl_DNSConfiguration + +#define particle_ctrl_InterfaceAddress_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, MESSAGE, address, 1) \ +X(a, STATIC, SINGULAR, UINT32, prefix_length, 2) +#define particle_ctrl_InterfaceAddress_CALLBACK NULL +#define particle_ctrl_InterfaceAddress_DEFAULT NULL +#define particle_ctrl_InterfaceAddress_address_MSGTYPE particle_ctrl_IpAddress + +#define particle_ctrl_Ipv4Config_FIELDLIST(X, a) \ +X(a, CALLBACK, REPEATED, MESSAGE, addresses, 1) \ +X(a, STATIC, OPTIONAL, MESSAGE, peer, 2) \ +X(a, STATIC, OPTIONAL, MESSAGE, gateway, 3) +#define particle_ctrl_Ipv4Config_CALLBACK pb_default_field_callback +#define particle_ctrl_Ipv4Config_DEFAULT NULL +#define particle_ctrl_Ipv4Config_addresses_MSGTYPE particle_ctrl_InterfaceAddress +#define particle_ctrl_Ipv4Config_peer_MSGTYPE particle_ctrl_Ipv4Address +#define particle_ctrl_Ipv4Config_gateway_MSGTYPE particle_ctrl_Ipv4Address + +#define particle_ctrl_Ipv6Config_FIELDLIST(X, a) \ +X(a, CALLBACK, REPEATED, MESSAGE, addresses, 1) +#define particle_ctrl_Ipv6Config_CALLBACK pb_default_field_callback +#define particle_ctrl_Ipv6Config_DEFAULT NULL +#define particle_ctrl_Ipv6Config_addresses_MSGTYPE particle_ctrl_InterfaceAddress + +#define particle_ctrl_Interface_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UINT32, index, 1) \ +X(a, CALLBACK, SINGULAR, STRING, name, 2) \ +X(a, STATIC, SINGULAR, UENUM, type, 3) \ +X(a, STATIC, SINGULAR, UINT32, flags, 4) \ +X(a, STATIC, SINGULAR, UINT32, ext_flags, 5) \ +X(a, STATIC, OPTIONAL, MESSAGE, ipv4_config, 6) \ +X(a, STATIC, OPTIONAL, MESSAGE, ipv6_config, 7) \ +X(a, STATIC, SINGULAR, BYTES, hw_address, 8) \ +X(a, STATIC, SINGULAR, UINT32, mtu, 9) \ +X(a, STATIC, SINGULAR, UINT32, metric, 10) +#define particle_ctrl_Interface_CALLBACK pb_default_field_callback +#define particle_ctrl_Interface_DEFAULT NULL +#define particle_ctrl_Interface_ipv4_config_MSGTYPE particle_ctrl_Ipv4Config +#define particle_ctrl_Interface_ipv6_config_MSGTYPE particle_ctrl_Ipv6Config + +#define particle_ctrl_InterfaceEntry_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UINT32, index, 1) \ +X(a, CALLBACK, SINGULAR, STRING, name, 2) \ +X(a, STATIC, SINGULAR, UENUM, type, 3) +#define particle_ctrl_InterfaceEntry_CALLBACK pb_default_field_callback +#define particle_ctrl_InterfaceEntry_DEFAULT NULL + +#define particle_ctrl_GetInterfaceListRequest_FIELDLIST(X, a) \ + +#define particle_ctrl_GetInterfaceListRequest_CALLBACK NULL +#define particle_ctrl_GetInterfaceListRequest_DEFAULT NULL + +#define particle_ctrl_GetInterfaceListReply_FIELDLIST(X, a) \ +X(a, CALLBACK, REPEATED, MESSAGE, interfaces, 1) +#define particle_ctrl_GetInterfaceListReply_CALLBACK pb_default_field_callback +#define particle_ctrl_GetInterfaceListReply_DEFAULT NULL +#define particle_ctrl_GetInterfaceListReply_interfaces_MSGTYPE particle_ctrl_InterfaceEntry + +#define particle_ctrl_GetInterfaceRequest_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UINT32, index, 1) +#define particle_ctrl_GetInterfaceRequest_CALLBACK NULL +#define particle_ctrl_GetInterfaceRequest_DEFAULT NULL + +#define particle_ctrl_GetInterfaceReply_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, MESSAGE, interface, 1) +#define particle_ctrl_GetInterfaceReply_CALLBACK NULL +#define particle_ctrl_GetInterfaceReply_DEFAULT NULL +#define particle_ctrl_GetInterfaceReply_interface_MSGTYPE particle_ctrl_Interface + +extern const pb_msgdesc_t particle_ctrl_NetworkGetStatusRequest_msg; +extern const pb_msgdesc_t particle_ctrl_NetworkGetStatusReply_msg; +extern const pb_msgdesc_t particle_ctrl_NetworkGetConfigurationRequest_msg; +extern const pb_msgdesc_t particle_ctrl_NetworkGetConfigurationReply_msg; +extern const pb_msgdesc_t particle_ctrl_NetworkSetConfigurationRequest_msg; +extern const pb_msgdesc_t particle_ctrl_NetworkSetConfigurationReply_msg; +extern const pb_msgdesc_t particle_ctrl_IPConfiguration_msg; +extern const pb_msgdesc_t particle_ctrl_DNSConfiguration_msg; +extern const pb_msgdesc_t particle_ctrl_NetworkConfiguration_msg; +extern const pb_msgdesc_t particle_ctrl_InterfaceAddress_msg; +extern const pb_msgdesc_t particle_ctrl_Ipv4Config_msg; +extern const pb_msgdesc_t particle_ctrl_Ipv6Config_msg; +extern const pb_msgdesc_t particle_ctrl_Interface_msg; +extern const pb_msgdesc_t particle_ctrl_InterfaceEntry_msg; +extern const pb_msgdesc_t particle_ctrl_GetInterfaceListRequest_msg; +extern const pb_msgdesc_t particle_ctrl_GetInterfaceListReply_msg; +extern const pb_msgdesc_t particle_ctrl_GetInterfaceRequest_msg; +extern const pb_msgdesc_t particle_ctrl_GetInterfaceReply_msg; + +/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ +#define particle_ctrl_NetworkGetStatusRequest_fields &particle_ctrl_NetworkGetStatusRequest_msg +#define particle_ctrl_NetworkGetStatusReply_fields &particle_ctrl_NetworkGetStatusReply_msg +#define particle_ctrl_NetworkGetConfigurationRequest_fields &particle_ctrl_NetworkGetConfigurationRequest_msg +#define particle_ctrl_NetworkGetConfigurationReply_fields &particle_ctrl_NetworkGetConfigurationReply_msg +#define particle_ctrl_NetworkSetConfigurationRequest_fields &particle_ctrl_NetworkSetConfigurationRequest_msg +#define particle_ctrl_NetworkSetConfigurationReply_fields &particle_ctrl_NetworkSetConfigurationReply_msg +#define particle_ctrl_IPConfiguration_fields &particle_ctrl_IPConfiguration_msg +#define particle_ctrl_DNSConfiguration_fields &particle_ctrl_DNSConfiguration_msg +#define particle_ctrl_NetworkConfiguration_fields &particle_ctrl_NetworkConfiguration_msg +#define particle_ctrl_InterfaceAddress_fields &particle_ctrl_InterfaceAddress_msg +#define particle_ctrl_Ipv4Config_fields &particle_ctrl_Ipv4Config_msg +#define particle_ctrl_Ipv6Config_fields &particle_ctrl_Ipv6Config_msg +#define particle_ctrl_Interface_fields &particle_ctrl_Interface_msg +#define particle_ctrl_InterfaceEntry_fields &particle_ctrl_InterfaceEntry_msg +#define particle_ctrl_GetInterfaceListRequest_fields &particle_ctrl_GetInterfaceListRequest_msg +#define particle_ctrl_GetInterfaceListReply_fields &particle_ctrl_GetInterfaceListReply_msg +#define particle_ctrl_GetInterfaceRequest_fields &particle_ctrl_GetInterfaceRequest_msg +#define particle_ctrl_GetInterfaceReply_fields &particle_ctrl_GetInterfaceReply_msg /* Maximum encoded size of messages (where known) */ -#define particle_ctrl_NetworkGetStatusRequest_size 11 -#define particle_ctrl_NetworkGetStatusReply_size (6 + particle_ctrl_NetworkConfiguration_size) -#define particle_ctrl_NetworkGetConfigurationRequest_size 11 -#define particle_ctrl_NetworkGetConfigurationReply_size (6 + particle_ctrl_NetworkConfiguration_size) -#define particle_ctrl_NetworkSetConfigurationRequest_size (6 + particle_ctrl_NetworkConfiguration_size) -#define particle_ctrl_NetworkSetConfigurationReply_size 0 +/* particle_ctrl_NetworkGetStatusReply_size depends on runtime parameters */ +/* particle_ctrl_NetworkGetConfigurationReply_size depends on runtime parameters */ +/* particle_ctrl_NetworkSetConfigurationRequest_size depends on runtime parameters */ /* particle_ctrl_IPConfiguration_size depends on runtime parameters */ /* particle_ctrl_DNSConfiguration_size depends on runtime parameters */ /* particle_ctrl_NetworkConfiguration_size depends on runtime parameters */ -#define particle_ctrl_InterfaceAddress_size 28 /* particle_ctrl_Ipv4Config_size depends on runtime parameters */ /* particle_ctrl_Ipv6Config_size depends on runtime parameters */ /* particle_ctrl_Interface_size depends on runtime parameters */ /* particle_ctrl_InterfaceEntry_size depends on runtime parameters */ -#define particle_ctrl_GetInterfaceListRequest_size 0 /* particle_ctrl_GetInterfaceListReply_size depends on runtime parameters */ +/* particle_ctrl_GetInterfaceReply_size depends on runtime parameters */ +#define particle_ctrl_GetInterfaceListRequest_size 0 #define particle_ctrl_GetInterfaceRequest_size 6 -#define particle_ctrl_GetInterfaceReply_size (6 + particle_ctrl_Interface_size) - -/* Message IDs (where set with "msgid" option) */ -#ifdef PB_MSGID - -#define NETWORK_MESSAGES \ - - -#endif +#define particle_ctrl_InterfaceAddress_size 28 +#define particle_ctrl_NetworkGetConfigurationRequest_size 11 +#define particle_ctrl_NetworkGetStatusRequest_size 11 +#define particle_ctrl_NetworkSetConfigurationReply_size 0 #ifdef __cplusplus } /* extern "C" */ #endif -/* @@protoc_insertion_point(eof) */ #endif diff --git a/system/src/control/proto/storage.pb.c b/system/src/control/proto/storage.pb.c index 8264ecc06d..eb0ca828e1 100644 --- a/system/src/control/proto/storage.pb.c +++ b/system/src/control/proto/storage.pb.c @@ -1,183 +1,90 @@ /* Automatically generated nanopb constant definitions */ -/* Generated by nanopb-0.3.9 at Mon Jun 10 21:00:54 2019. */ +/* Generated by nanopb-0.4.5 */ #include "storage.pb.h" - -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 +#if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif +PB_BIND(particle_ctrl_StartFirmwareUpdateRequest, particle_ctrl_StartFirmwareUpdateRequest, AUTO) + + +PB_BIND(particle_ctrl_StartFirmwareUpdateReply, particle_ctrl_StartFirmwareUpdateReply, AUTO) + + +PB_BIND(particle_ctrl_FinishFirmwareUpdateRequest, particle_ctrl_FinishFirmwareUpdateRequest, AUTO) + + +PB_BIND(particle_ctrl_FinishFirmwareUpdateReply, particle_ctrl_FinishFirmwareUpdateReply, AUTO) + + +PB_BIND(particle_ctrl_CancelFirmwareUpdateRequest, particle_ctrl_CancelFirmwareUpdateRequest, AUTO) + + +PB_BIND(particle_ctrl_CancelFirmwareUpdateReply, particle_ctrl_CancelFirmwareUpdateReply, AUTO) + + +PB_BIND(particle_ctrl_FirmwareUpdateDataRequest, particle_ctrl_FirmwareUpdateDataRequest, AUTO) + + +PB_BIND(particle_ctrl_FirmwareUpdateDataReply, particle_ctrl_FirmwareUpdateDataReply, AUTO) + + +PB_BIND(particle_ctrl_DescribeStorageRequest, particle_ctrl_DescribeStorageRequest, AUTO) + + +PB_BIND(particle_ctrl_DescribeStorageReply, particle_ctrl_DescribeStorageReply, AUTO) + + +PB_BIND(particle_ctrl_DescribeStorageReply_Section, particle_ctrl_DescribeStorageReply_Section, AUTO) + + +PB_BIND(particle_ctrl_DescribeStorageReply_Section_FirmwareModule, particle_ctrl_DescribeStorageReply_Section_FirmwareModule, AUTO) + + +PB_BIND(particle_ctrl_DescribeStorageReply_Storage, particle_ctrl_DescribeStorageReply_Storage, AUTO) + + +PB_BIND(particle_ctrl_ReadSectionDataRequest, particle_ctrl_ReadSectionDataRequest, AUTO) + + +PB_BIND(particle_ctrl_ReadSectionDataReply, particle_ctrl_ReadSectionDataReply, AUTO) + + +PB_BIND(particle_ctrl_WriteSectionDataRequest, particle_ctrl_WriteSectionDataRequest, AUTO) + + +PB_BIND(particle_ctrl_WriteSectionDataReply, particle_ctrl_WriteSectionDataReply, AUTO) + + +PB_BIND(particle_ctrl_ClearSectionDataRequest, particle_ctrl_ClearSectionDataRequest, AUTO) + + +PB_BIND(particle_ctrl_ClearSectionDataReply, particle_ctrl_ClearSectionDataReply, AUTO) + + +PB_BIND(particle_ctrl_GetSectionDataSizeRequest, particle_ctrl_GetSectionDataSizeRequest, AUTO) + + +PB_BIND(particle_ctrl_GetSectionDataSizeReply, particle_ctrl_GetSectionDataSizeReply, AUTO) + + +PB_BIND(particle_ctrl_GetModuleInfoRequest, particle_ctrl_GetModuleInfoRequest, AUTO) + + +PB_BIND(particle_ctrl_GetModuleInfoReply, particle_ctrl_GetModuleInfoReply, AUTO) + + +PB_BIND(particle_ctrl_GetModuleInfoReply_Dependency, particle_ctrl_GetModuleInfoReply_Dependency, AUTO) + + +PB_BIND(particle_ctrl_GetModuleInfoReply_Module, particle_ctrl_GetModuleInfoReply_Module, AUTO) + + + + -const pb_field_t particle_ctrl_StartFirmwareUpdateRequest_fields[3] = { - PB_FIELD( 1, UINT32 , SINGULAR, STATIC , FIRST, particle_ctrl_StartFirmwareUpdateRequest, size, size, 0), - PB_FIELD( 2, UENUM , SINGULAR, STATIC , OTHER, particle_ctrl_StartFirmwareUpdateRequest, format, size, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_StartFirmwareUpdateReply_fields[2] = { - PB_FIELD( 1, UINT32 , SINGULAR, STATIC , FIRST, particle_ctrl_StartFirmwareUpdateReply, chunk_size, chunk_size, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_FinishFirmwareUpdateRequest_fields[2] = { - PB_FIELD( 1, BOOL , SINGULAR, STATIC , FIRST, particle_ctrl_FinishFirmwareUpdateRequest, validate_only, validate_only, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_FinishFirmwareUpdateReply_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_CancelFirmwareUpdateRequest_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_CancelFirmwareUpdateReply_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_FirmwareUpdateDataRequest_fields[2] = { - PB_FIELD( 1, BYTES , SINGULAR, CALLBACK, FIRST, particle_ctrl_FirmwareUpdateDataRequest, data, data, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_FirmwareUpdateDataReply_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_DescribeStorageRequest_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_DescribeStorageReply_fields[2] = { - PB_FIELD( 1, MESSAGE , REPEATED, CALLBACK, FIRST, particle_ctrl_DescribeStorageReply, storage, storage, &particle_ctrl_DescribeStorageReply_Storage_fields), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_DescribeStorageReply_Section_fields[5] = { - PB_FIELD( 1, UENUM , SINGULAR, STATIC , FIRST, particle_ctrl_DescribeStorageReply_Section, type, type, 0), - PB_FIELD( 2, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_DescribeStorageReply_Section, size, type, 0), - PB_FIELD( 3, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_DescribeStorageReply_Section, flags, size, 0), - PB_FIELD( 4, MESSAGE , SINGULAR, STATIC , OTHER, particle_ctrl_DescribeStorageReply_Section, firmware_module, flags, &particle_ctrl_DescribeStorageReply_Section_FirmwareModule_fields), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_DescribeStorageReply_Section_FirmwareModule_fields[3] = { - PB_FIELD( 1, UENUM , SINGULAR, STATIC , FIRST, particle_ctrl_DescribeStorageReply_Section_FirmwareModule, type, type, 0), - PB_FIELD( 2, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_DescribeStorageReply_Section_FirmwareModule, index, type, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_DescribeStorageReply_Storage_fields[4] = { - PB_FIELD( 1, UENUM , SINGULAR, STATIC , FIRST, particle_ctrl_DescribeStorageReply_Storage, type, type, 0), - PB_FIELD( 2, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_DescribeStorageReply_Storage, flags, type, 0), - PB_FIELD( 3, MESSAGE , REPEATED, CALLBACK, OTHER, particle_ctrl_DescribeStorageReply_Storage, sections, flags, &particle_ctrl_DescribeStorageReply_Section_fields), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_ReadSectionDataRequest_fields[5] = { - PB_FIELD( 1, UINT32 , SINGULAR, STATIC , FIRST, particle_ctrl_ReadSectionDataRequest, storage, storage, 0), - PB_FIELD( 2, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_ReadSectionDataRequest, section, storage, 0), - PB_FIELD( 3, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_ReadSectionDataRequest, offset, section, 0), - PB_FIELD( 4, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_ReadSectionDataRequest, size, offset, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_ReadSectionDataReply_fields[2] = { - PB_FIELD( 1, BYTES , SINGULAR, CALLBACK, FIRST, particle_ctrl_ReadSectionDataReply, data, data, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_WriteSectionDataRequest_fields[5] = { - PB_FIELD( 1, UINT32 , SINGULAR, STATIC , FIRST, particle_ctrl_WriteSectionDataRequest, storage, storage, 0), - PB_FIELD( 2, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_WriteSectionDataRequest, section, storage, 0), - PB_FIELD( 3, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_WriteSectionDataRequest, offset, section, 0), - PB_FIELD( 4, BYTES , SINGULAR, CALLBACK, OTHER, particle_ctrl_WriteSectionDataRequest, data, offset, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_WriteSectionDataReply_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_ClearSectionDataRequest_fields[3] = { - PB_FIELD( 1, UINT32 , SINGULAR, STATIC , FIRST, particle_ctrl_ClearSectionDataRequest, storage, storage, 0), - PB_FIELD( 2, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_ClearSectionDataRequest, section, storage, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_ClearSectionDataReply_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_GetSectionDataSizeRequest_fields[3] = { - PB_FIELD( 1, UINT32 , SINGULAR, STATIC , FIRST, particle_ctrl_GetSectionDataSizeRequest, storage, storage, 0), - PB_FIELD( 2, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_GetSectionDataSizeRequest, section, storage, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_GetSectionDataSizeReply_fields[2] = { - PB_FIELD( 1, UINT32 , SINGULAR, STATIC , FIRST, particle_ctrl_GetSectionDataSizeReply, size, size, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_GetModuleInfoRequest_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_GetModuleInfoReply_fields[2] = { - PB_FIELD( 1, MESSAGE , REPEATED, CALLBACK, FIRST, particle_ctrl_GetModuleInfoReply, modules, modules, &particle_ctrl_GetModuleInfoReply_Module_fields), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_GetModuleInfoReply_Dependency_fields[4] = { - PB_FIELD( 1, UENUM , SINGULAR, STATIC , FIRST, particle_ctrl_GetModuleInfoReply_Dependency, type, type, 0), - PB_FIELD( 2, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_GetModuleInfoReply_Dependency, index, type, 0), - PB_FIELD( 3, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_GetModuleInfoReply_Dependency, version, index, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_GetModuleInfoReply_Module_fields[7] = { - PB_FIELD( 1, UENUM , SINGULAR, STATIC , FIRST, particle_ctrl_GetModuleInfoReply_Module, type, type, 0), - PB_FIELD( 2, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_GetModuleInfoReply_Module, index, type, 0), - PB_FIELD( 3, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_GetModuleInfoReply_Module, version, index, 0), - PB_FIELD( 4, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_GetModuleInfoReply_Module, size, version, 0), - PB_FIELD( 5, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_GetModuleInfoReply_Module, validity, size, 0), - PB_FIELD( 6, MESSAGE , REPEATED, CALLBACK, OTHER, particle_ctrl_GetModuleInfoReply_Module, dependencies, validity, &particle_ctrl_GetModuleInfoReply_Dependency_fields), - PB_LAST_FIELD -}; - - - - - - - - -/* Check that field information fits in pb_field_t */ -#if !defined(PB_FIELD_32BIT) -/* If you get an error here, it means that you need to define PB_FIELD_32BIT - * compile-time option. You can do that in pb.h or on compiler command line. - * - * The reason you need to do this is that some of your messages contain tag - * numbers or field sizes that are larger than what can fit in 8 or 16 bit - * field descriptors. - */ -PB_STATIC_ASSERT((pb_membersize(particle_ctrl_DescribeStorageReply_Section, firmware_module) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_particle_ctrl_StartFirmwareUpdateRequest_particle_ctrl_StartFirmwareUpdateReply_particle_ctrl_FinishFirmwareUpdateRequest_particle_ctrl_FinishFirmwareUpdateReply_particle_ctrl_CancelFirmwareUpdateRequest_particle_ctrl_CancelFirmwareUpdateReply_particle_ctrl_FirmwareUpdateDataRequest_particle_ctrl_FirmwareUpdateDataReply_particle_ctrl_DescribeStorageRequest_particle_ctrl_DescribeStorageReply_particle_ctrl_DescribeStorageReply_Section_particle_ctrl_DescribeStorageReply_Section_FirmwareModule_particle_ctrl_DescribeStorageReply_Storage_particle_ctrl_ReadSectionDataRequest_particle_ctrl_ReadSectionDataReply_particle_ctrl_WriteSectionDataRequest_particle_ctrl_WriteSectionDataReply_particle_ctrl_ClearSectionDataRequest_particle_ctrl_ClearSectionDataReply_particle_ctrl_GetSectionDataSizeRequest_particle_ctrl_GetSectionDataSizeReply_particle_ctrl_GetModuleInfoRequest_particle_ctrl_GetModuleInfoReply_particle_ctrl_GetModuleInfoReply_Dependency_particle_ctrl_GetModuleInfoReply_Module) -#endif -#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT) -/* If you get an error here, it means that you need to define PB_FIELD_16BIT - * compile-time option. You can do that in pb.h or on compiler command line. - * - * The reason you need to do this is that some of your messages contain tag - * numbers or field sizes that are larger than what can fit in the default - * 8 bit descriptors. - */ -PB_STATIC_ASSERT((pb_membersize(particle_ctrl_DescribeStorageReply_Section, firmware_module) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_particle_ctrl_StartFirmwareUpdateRequest_particle_ctrl_StartFirmwareUpdateReply_particle_ctrl_FinishFirmwareUpdateRequest_particle_ctrl_FinishFirmwareUpdateReply_particle_ctrl_CancelFirmwareUpdateRequest_particle_ctrl_CancelFirmwareUpdateReply_particle_ctrl_FirmwareUpdateDataRequest_particle_ctrl_FirmwareUpdateDataReply_particle_ctrl_DescribeStorageRequest_particle_ctrl_DescribeStorageReply_particle_ctrl_DescribeStorageReply_Section_particle_ctrl_DescribeStorageReply_Section_FirmwareModule_particle_ctrl_DescribeStorageReply_Storage_particle_ctrl_ReadSectionDataRequest_particle_ctrl_ReadSectionDataReply_particle_ctrl_WriteSectionDataRequest_particle_ctrl_WriteSectionDataReply_particle_ctrl_ClearSectionDataRequest_particle_ctrl_ClearSectionDataReply_particle_ctrl_GetSectionDataSizeRequest_particle_ctrl_GetSectionDataSizeReply_particle_ctrl_GetModuleInfoRequest_particle_ctrl_GetModuleInfoReply_particle_ctrl_GetModuleInfoReply_Dependency_particle_ctrl_GetModuleInfoReply_Module) -#endif -/* @@protoc_insertion_point(eof) */ diff --git a/system/src/control/proto/storage.pb.h b/system/src/control/proto/storage.pb.h index fa2021732a..1751e3e5af 100644 --- a/system/src/control/proto/storage.pb.h +++ b/system/src/control/proto/storage.pb.h @@ -1,238 +1,225 @@ /* Automatically generated nanopb header */ -/* Generated by nanopb-0.3.9 at Mon Jun 10 21:00:54 2019. */ +/* Generated by nanopb-0.4.5 */ #ifndef PB_PARTICLE_CTRL_STORAGE_PB_H_INCLUDED #define PB_PARTICLE_CTRL_STORAGE_PB_H_INCLUDED #include - #include "extensions.pb.h" - #include "common.pb.h" -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 +#if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif -#ifdef __cplusplus -extern "C" { -#endif - /* Enum definitions */ -typedef enum _particle_ctrl_StorageType { - particle_ctrl_StorageType_INVALID_STORAGE = 0, - particle_ctrl_StorageType_INTERNAL = 1 +typedef enum _particle_ctrl_StorageType { + particle_ctrl_StorageType_INVALID_STORAGE = 0, + particle_ctrl_StorageType_INTERNAL = 1 /* Internal flash */ } particle_ctrl_StorageType; -#define _particle_ctrl_StorageType_MIN particle_ctrl_StorageType_INVALID_STORAGE -#define _particle_ctrl_StorageType_MAX particle_ctrl_StorageType_INTERNAL -#define _particle_ctrl_StorageType_ARRAYSIZE ((particle_ctrl_StorageType)(particle_ctrl_StorageType_INTERNAL+1)) -typedef enum _particle_ctrl_SectionType { - particle_ctrl_SectionType_INVALID_SECTION = 0, - particle_ctrl_SectionType_FIRMWARE = 1, - particle_ctrl_SectionType_OTA_BACKUP = 2, - particle_ctrl_SectionType_FACTORY_BACKUP = 3, - particle_ctrl_SectionType_CONFIG = 4, - particle_ctrl_SectionType_EEPROM = 5 +typedef enum _particle_ctrl_SectionType { + particle_ctrl_SectionType_INVALID_SECTION = 0, + particle_ctrl_SectionType_FIRMWARE = 1, /* Firmware module */ + particle_ctrl_SectionType_OTA_BACKUP = 2, /* OTA backup */ + particle_ctrl_SectionType_FACTORY_BACKUP = 3, /* Factory backup */ + particle_ctrl_SectionType_CONFIG = 4, /* Device configuration */ + particle_ctrl_SectionType_EEPROM = 5 /* Emulated EEPROM */ } particle_ctrl_SectionType; -#define _particle_ctrl_SectionType_MIN particle_ctrl_SectionType_INVALID_SECTION -#define _particle_ctrl_SectionType_MAX particle_ctrl_SectionType_EEPROM -#define _particle_ctrl_SectionType_ARRAYSIZE ((particle_ctrl_SectionType)(particle_ctrl_SectionType_EEPROM+1)) -typedef enum _particle_ctrl_FirmwareModuleType { - particle_ctrl_FirmwareModuleType_INVALID_FIRMWARE_MODULE = 0, - particle_ctrl_FirmwareModuleType_BOOTLOADER = 1, - particle_ctrl_FirmwareModuleType_SYSTEM_PART = 2, - particle_ctrl_FirmwareModuleType_USER_PART = 3, - particle_ctrl_FirmwareModuleType_MONO_FIRMWARE = 4, - particle_ctrl_FirmwareModuleType_NCP_FIRMWARE = 5, - particle_ctrl_FirmwareModuleType_RADIO_STACK = 6 +typedef enum _particle_ctrl_FirmwareModuleType { + particle_ctrl_FirmwareModuleType_INVALID_FIRMWARE_MODULE = 0, + particle_ctrl_FirmwareModuleType_BOOTLOADER = 1, /* Bootloader */ + particle_ctrl_FirmwareModuleType_SYSTEM_PART = 2, /* System part */ + particle_ctrl_FirmwareModuleType_USER_PART = 3, /* User part */ + particle_ctrl_FirmwareModuleType_MONO_FIRMWARE = 4, /* Monolithic firmware */ + particle_ctrl_FirmwareModuleType_NCP_FIRMWARE = 5, /* NCP firmware */ + particle_ctrl_FirmwareModuleType_RADIO_STACK = 6 /* Radio stack binary */ } particle_ctrl_FirmwareModuleType; -#define _particle_ctrl_FirmwareModuleType_MIN particle_ctrl_FirmwareModuleType_INVALID_FIRMWARE_MODULE -#define _particle_ctrl_FirmwareModuleType_MAX particle_ctrl_FirmwareModuleType_RADIO_STACK -#define _particle_ctrl_FirmwareModuleType_ARRAYSIZE ((particle_ctrl_FirmwareModuleType)(particle_ctrl_FirmwareModuleType_RADIO_STACK+1)) -typedef enum _particle_ctrl_FirmwareModuleValidityFlag { - particle_ctrl_FirmwareModuleValidityFlag_NO_VALIDATION_ERRORS = 0, - particle_ctrl_FirmwareModuleValidityFlag_INTEGRITY_CHECK_FAILED = 1, - particle_ctrl_FirmwareModuleValidityFlag_DEPENDENCY_CHECK_FAILED = 2 +typedef enum _particle_ctrl_FirmwareModuleValidityFlag { + particle_ctrl_FirmwareModuleValidityFlag_NO_VALIDATION_ERRORS = 0, + particle_ctrl_FirmwareModuleValidityFlag_INTEGRITY_CHECK_FAILED = 1, /* Integrity check failed */ + particle_ctrl_FirmwareModuleValidityFlag_DEPENDENCY_CHECK_FAILED = 2 /* Dependency check failed */ } particle_ctrl_FirmwareModuleValidityFlag; -#define _particle_ctrl_FirmwareModuleValidityFlag_MIN particle_ctrl_FirmwareModuleValidityFlag_NO_VALIDATION_ERRORS -#define _particle_ctrl_FirmwareModuleValidityFlag_MAX particle_ctrl_FirmwareModuleValidityFlag_DEPENDENCY_CHECK_FAILED -#define _particle_ctrl_FirmwareModuleValidityFlag_ARRAYSIZE ((particle_ctrl_FirmwareModuleValidityFlag)(particle_ctrl_FirmwareModuleValidityFlag_DEPENDENCY_CHECK_FAILED+1)) -typedef enum _particle_ctrl_SectionFlag { - particle_ctrl_SectionFlag_NO_SECTION_FLAGS = 0, - particle_ctrl_SectionFlag_CAN_READ = 1, - particle_ctrl_SectionFlag_CAN_WRITE = 2, - particle_ctrl_SectionFlag_CAN_CLEAR = 4, - particle_ctrl_SectionFlag_CAN_GET_SIZE = 8, - particle_ctrl_SectionFlag_NEED_CLEAR = 16 +typedef enum _particle_ctrl_SectionFlag { + particle_ctrl_SectionFlag_NO_SECTION_FLAGS = 0, + particle_ctrl_SectionFlag_CAN_READ = 1, /* Section data is readable */ + particle_ctrl_SectionFlag_CAN_WRITE = 2, /* Section data is writable */ + particle_ctrl_SectionFlag_CAN_CLEAR = 4, /* Section can be cleared */ + particle_ctrl_SectionFlag_CAN_GET_SIZE = 8, /* Actual size of the section data can be determined */ + particle_ctrl_SectionFlag_NEED_CLEAR = 16 /* Section needs to be cleared before writing */ } particle_ctrl_SectionFlag; -#define _particle_ctrl_SectionFlag_MIN particle_ctrl_SectionFlag_NO_SECTION_FLAGS -#define _particle_ctrl_SectionFlag_MAX particle_ctrl_SectionFlag_NEED_CLEAR -#define _particle_ctrl_SectionFlag_ARRAYSIZE ((particle_ctrl_SectionFlag)(particle_ctrl_SectionFlag_NEED_CLEAR+1)) -typedef enum _particle_ctrl_FileFormat { - particle_ctrl_FileFormat_BIN = 0, - particle_ctrl_FileFormat_MINIZ = 1 +typedef enum _particle_ctrl_FileFormat { + particle_ctrl_FileFormat_BIN = 0, /* Binary */ + particle_ctrl_FileFormat_MINIZ = 1 /* miniz compressed */ } particle_ctrl_FileFormat; -#define _particle_ctrl_FileFormat_MIN particle_ctrl_FileFormat_BIN -#define _particle_ctrl_FileFormat_MAX particle_ctrl_FileFormat_MINIZ -#define _particle_ctrl_FileFormat_ARRAYSIZE ((particle_ctrl_FileFormat)(particle_ctrl_FileFormat_MINIZ+1)) /* Struct definitions */ -typedef struct _particle_ctrl_CancelFirmwareUpdateReply { +typedef struct _particle_ctrl_CancelFirmwareUpdateReply { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_CancelFirmwareUpdateReply) */ } particle_ctrl_CancelFirmwareUpdateReply; -typedef struct _particle_ctrl_CancelFirmwareUpdateRequest { +/* Cancel the firmware update */ +typedef struct _particle_ctrl_CancelFirmwareUpdateRequest { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_CancelFirmwareUpdateRequest) */ } particle_ctrl_CancelFirmwareUpdateRequest; -typedef struct _particle_ctrl_ClearSectionDataReply { +/* * + Get firmware module info. */ +typedef struct _particle_ctrl_ClearSectionDataReply { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_ClearSectionDataReply) */ } particle_ctrl_ClearSectionDataReply; -typedef struct _particle_ctrl_DescribeStorageReply { - pb_callback_t storage; -/* @@protoc_insertion_point(struct:particle_ctrl_DescribeStorageReply) */ +typedef struct _particle_ctrl_DescribeStorageReply { + pb_callback_t storage; /* Storages */ } particle_ctrl_DescribeStorageReply; -typedef struct _particle_ctrl_DescribeStorageRequest { +/* Describe the built-in storage */ +typedef struct _particle_ctrl_DescribeStorageRequest { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_DescribeStorageRequest) */ } particle_ctrl_DescribeStorageRequest; -typedef struct _particle_ctrl_FinishFirmwareUpdateReply { +typedef struct _particle_ctrl_FinishFirmwareUpdateReply { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_FinishFirmwareUpdateReply) */ } particle_ctrl_FinishFirmwareUpdateReply; -typedef struct _particle_ctrl_FirmwareUpdateDataReply { +typedef struct _particle_ctrl_FirmwareUpdateDataReply { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_FirmwareUpdateDataReply) */ } particle_ctrl_FirmwareUpdateDataReply; -typedef struct _particle_ctrl_FirmwareUpdateDataRequest { - pb_callback_t data; -/* @@protoc_insertion_point(struct:particle_ctrl_FirmwareUpdateDataRequest) */ +/* Send the firmware update file */ +typedef struct _particle_ctrl_FirmwareUpdateDataRequest { + pb_callback_t data; } particle_ctrl_FirmwareUpdateDataRequest; -typedef struct _particle_ctrl_GetModuleInfoReply { - pb_callback_t modules; -/* @@protoc_insertion_point(struct:particle_ctrl_GetModuleInfoReply) */ +typedef struct _particle_ctrl_GetModuleInfoReply { + pb_callback_t modules; } particle_ctrl_GetModuleInfoReply; -typedef struct _particle_ctrl_GetModuleInfoRequest { +typedef struct _particle_ctrl_GetModuleInfoRequest { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_GetModuleInfoRequest) */ } particle_ctrl_GetModuleInfoRequest; -typedef struct _particle_ctrl_ReadSectionDataReply { - pb_callback_t data; -/* @@protoc_insertion_point(struct:particle_ctrl_ReadSectionDataReply) */ +typedef struct _particle_ctrl_ReadSectionDataReply { + pb_callback_t data; /* Storage index */ } particle_ctrl_ReadSectionDataReply; -typedef struct _particle_ctrl_WriteSectionDataReply { +typedef struct _particle_ctrl_WriteSectionDataReply { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_WriteSectionDataReply) */ } particle_ctrl_WriteSectionDataReply; -typedef struct _particle_ctrl_ClearSectionDataRequest { - uint32_t storage; - uint32_t section; -/* @@protoc_insertion_point(struct:particle_ctrl_ClearSectionDataRequest) */ +typedef struct _particle_ctrl_ClearSectionDataRequest { + uint32_t storage; /* Section data size */ + uint32_t section; } particle_ctrl_ClearSectionDataRequest; -typedef struct _particle_ctrl_DescribeStorageReply_Section_FirmwareModule { - particle_ctrl_FirmwareModuleType type; - uint32_t index; -/* @@protoc_insertion_point(struct:particle_ctrl_DescribeStorageReply_Section_FirmwareModule) */ +typedef struct _particle_ctrl_DescribeStorageReply_Section_FirmwareModule { + particle_ctrl_FirmwareModuleType type; /* Section data */ + uint32_t index; } particle_ctrl_DescribeStorageReply_Section_FirmwareModule; -typedef struct _particle_ctrl_DescribeStorageReply_Storage { - particle_ctrl_StorageType type; - uint32_t flags; - pb_callback_t sections; -/* @@protoc_insertion_point(struct:particle_ctrl_DescribeStorageReply_Storage) */ +typedef struct _particle_ctrl_DescribeStorageReply_Storage { + particle_ctrl_StorageType type; /* Storage index */ + uint32_t flags; /* Section index */ + pb_callback_t sections; /* Offset */ } particle_ctrl_DescribeStorageReply_Storage; -typedef struct _particle_ctrl_FinishFirmwareUpdateRequest { - bool validate_only; -/* @@protoc_insertion_point(struct:particle_ctrl_FinishFirmwareUpdateRequest) */ +/* Finish the firmware update process */ +typedef struct _particle_ctrl_FinishFirmwareUpdateRequest { + bool validate_only; /* When `true` it will only validate the integity of the update but won't write it to flash */ } particle_ctrl_FinishFirmwareUpdateRequest; -typedef struct _particle_ctrl_GetModuleInfoReply_Dependency { - particle_ctrl_FirmwareModuleType type; - uint32_t index; - uint32_t version; -/* @@protoc_insertion_point(struct:particle_ctrl_GetModuleInfoReply_Dependency) */ +typedef struct _particle_ctrl_GetModuleInfoReply_Dependency { + particle_ctrl_FirmwareModuleType type; + uint32_t index; + uint32_t version; } particle_ctrl_GetModuleInfoReply_Dependency; -typedef struct _particle_ctrl_GetModuleInfoReply_Module { - particle_ctrl_FirmwareModuleType type; - uint32_t index; - uint32_t version; - uint32_t size; - uint32_t validity; - pb_callback_t dependencies; -/* @@protoc_insertion_point(struct:particle_ctrl_GetModuleInfoReply_Module) */ +typedef struct _particle_ctrl_GetModuleInfoReply_Module { + particle_ctrl_FirmwareModuleType type; + uint32_t index; + uint32_t version; + uint32_t size; + uint32_t validity; + pb_callback_t dependencies; } particle_ctrl_GetModuleInfoReply_Module; -typedef struct _particle_ctrl_GetSectionDataSizeReply { - uint32_t size; -/* @@protoc_insertion_point(struct:particle_ctrl_GetSectionDataSizeReply) */ +typedef struct _particle_ctrl_GetSectionDataSizeReply { + uint32_t size; } particle_ctrl_GetSectionDataSizeReply; -typedef struct _particle_ctrl_GetSectionDataSizeRequest { - uint32_t storage; - uint32_t section; -/* @@protoc_insertion_point(struct:particle_ctrl_GetSectionDataSizeRequest) */ +typedef struct _particle_ctrl_GetSectionDataSizeRequest { + uint32_t storage; /* Firmware modules */ + uint32_t section; } particle_ctrl_GetSectionDataSizeRequest; -typedef struct _particle_ctrl_ReadSectionDataRequest { - uint32_t storage; - uint32_t section; - uint32_t offset; - uint32_t size; -/* @@protoc_insertion_point(struct:particle_ctrl_ReadSectionDataRequest) */ +typedef struct _particle_ctrl_ReadSectionDataRequest { + uint32_t storage; + uint32_t section; + uint32_t offset; + uint32_t size; } particle_ctrl_ReadSectionDataRequest; -typedef struct _particle_ctrl_StartFirmwareUpdateReply { - uint32_t chunk_size; -/* @@protoc_insertion_point(struct:particle_ctrl_StartFirmwareUpdateReply) */ +typedef struct _particle_ctrl_StartFirmwareUpdateReply { + uint32_t chunk_size; /* Maximum chunk size */ } particle_ctrl_StartFirmwareUpdateReply; -typedef struct _particle_ctrl_StartFirmwareUpdateRequest { - uint32_t size; - particle_ctrl_FileFormat format; -/* @@protoc_insertion_point(struct:particle_ctrl_StartFirmwareUpdateRequest) */ +/* Start the firmware update process */ +typedef struct _particle_ctrl_StartFirmwareUpdateRequest { + uint32_t size; /* Size of the firmware binary */ + particle_ctrl_FileFormat format; /* Format of the firmware binary */ } particle_ctrl_StartFirmwareUpdateRequest; -typedef struct _particle_ctrl_WriteSectionDataRequest { - uint32_t storage; - uint32_t section; - uint32_t offset; - pb_callback_t data; -/* @@protoc_insertion_point(struct:particle_ctrl_WriteSectionDataRequest) */ +typedef struct _particle_ctrl_WriteSectionDataRequest { + uint32_t storage; + uint32_t section; + uint32_t offset; + pb_callback_t data; } particle_ctrl_WriteSectionDataRequest; -typedef struct _particle_ctrl_DescribeStorageReply_Section { - particle_ctrl_SectionType type; - uint32_t size; - uint32_t flags; - particle_ctrl_DescribeStorageReply_Section_FirmwareModule firmware_module; -/* @@protoc_insertion_point(struct:particle_ctrl_DescribeStorageReply_Section) */ +typedef struct _particle_ctrl_DescribeStorageReply_Section { + particle_ctrl_SectionType type; /* Storage index */ + uint32_t size; /* Section index */ + uint32_t flags; /* Offset */ + bool has_firmware_module; + particle_ctrl_DescribeStorageReply_Section_FirmwareModule firmware_module; /* Size */ } particle_ctrl_DescribeStorageReply_Section; -/* Default values for struct fields */ + +/* Helper constants for enums */ +#define _particle_ctrl_StorageType_MIN particle_ctrl_StorageType_INVALID_STORAGE +#define _particle_ctrl_StorageType_MAX particle_ctrl_StorageType_INTERNAL +#define _particle_ctrl_StorageType_ARRAYSIZE ((particle_ctrl_StorageType)(particle_ctrl_StorageType_INTERNAL+1)) + +#define _particle_ctrl_SectionType_MIN particle_ctrl_SectionType_INVALID_SECTION +#define _particle_ctrl_SectionType_MAX particle_ctrl_SectionType_EEPROM +#define _particle_ctrl_SectionType_ARRAYSIZE ((particle_ctrl_SectionType)(particle_ctrl_SectionType_EEPROM+1)) + +#define _particle_ctrl_FirmwareModuleType_MIN particle_ctrl_FirmwareModuleType_INVALID_FIRMWARE_MODULE +#define _particle_ctrl_FirmwareModuleType_MAX particle_ctrl_FirmwareModuleType_RADIO_STACK +#define _particle_ctrl_FirmwareModuleType_ARRAYSIZE ((particle_ctrl_FirmwareModuleType)(particle_ctrl_FirmwareModuleType_RADIO_STACK+1)) + +#define _particle_ctrl_FirmwareModuleValidityFlag_MIN particle_ctrl_FirmwareModuleValidityFlag_NO_VALIDATION_ERRORS +#define _particle_ctrl_FirmwareModuleValidityFlag_MAX particle_ctrl_FirmwareModuleValidityFlag_DEPENDENCY_CHECK_FAILED +#define _particle_ctrl_FirmwareModuleValidityFlag_ARRAYSIZE ((particle_ctrl_FirmwareModuleValidityFlag)(particle_ctrl_FirmwareModuleValidityFlag_DEPENDENCY_CHECK_FAILED+1)) + +#define _particle_ctrl_SectionFlag_MIN particle_ctrl_SectionFlag_NO_SECTION_FLAGS +#define _particle_ctrl_SectionFlag_MAX particle_ctrl_SectionFlag_NEED_CLEAR +#define _particle_ctrl_SectionFlag_ARRAYSIZE ((particle_ctrl_SectionFlag)(particle_ctrl_SectionFlag_NEED_CLEAR+1)) + +#define _particle_ctrl_FileFormat_MIN particle_ctrl_FileFormat_BIN +#define _particle_ctrl_FileFormat_MAX particle_ctrl_FileFormat_MINIZ +#define _particle_ctrl_FileFormat_ARRAYSIZE ((particle_ctrl_FileFormat)(particle_ctrl_FileFormat_MINIZ+1)) + + +#ifdef __cplusplus +extern "C" { +#endif /* Initializer values for message structs */ -#define particle_ctrl_StartFirmwareUpdateRequest_init_default {0, (particle_ctrl_FileFormat)0} +#define particle_ctrl_StartFirmwareUpdateRequest_init_default {0, _particle_ctrl_FileFormat_MIN} #define particle_ctrl_StartFirmwareUpdateReply_init_default {0} #define particle_ctrl_FinishFirmwareUpdateRequest_init_default {0} #define particle_ctrl_FinishFirmwareUpdateReply_init_default {0} @@ -242,9 +229,9 @@ typedef struct _particle_ctrl_DescribeStorageReply_Section { #define particle_ctrl_FirmwareUpdateDataReply_init_default {0} #define particle_ctrl_DescribeStorageRequest_init_default {0} #define particle_ctrl_DescribeStorageReply_init_default {{{NULL}, NULL}} -#define particle_ctrl_DescribeStorageReply_Section_init_default {(particle_ctrl_SectionType)0, 0, 0, particle_ctrl_DescribeStorageReply_Section_FirmwareModule_init_default} -#define particle_ctrl_DescribeStorageReply_Section_FirmwareModule_init_default {(particle_ctrl_FirmwareModuleType)0, 0} -#define particle_ctrl_DescribeStorageReply_Storage_init_default {(particle_ctrl_StorageType)0, 0, {{NULL}, NULL}} +#define particle_ctrl_DescribeStorageReply_Section_init_default {_particle_ctrl_SectionType_MIN, 0, 0, false, particle_ctrl_DescribeStorageReply_Section_FirmwareModule_init_default} +#define particle_ctrl_DescribeStorageReply_Section_FirmwareModule_init_default {_particle_ctrl_FirmwareModuleType_MIN, 0} +#define particle_ctrl_DescribeStorageReply_Storage_init_default {_particle_ctrl_StorageType_MIN, 0, {{NULL}, NULL}} #define particle_ctrl_ReadSectionDataRequest_init_default {0, 0, 0, 0} #define particle_ctrl_ReadSectionDataReply_init_default {{{NULL}, NULL}} #define particle_ctrl_WriteSectionDataRequest_init_default {0, 0, 0, {{NULL}, NULL}} @@ -255,9 +242,9 @@ typedef struct _particle_ctrl_DescribeStorageReply_Section { #define particle_ctrl_GetSectionDataSizeReply_init_default {0} #define particle_ctrl_GetModuleInfoRequest_init_default {0} #define particle_ctrl_GetModuleInfoReply_init_default {{{NULL}, NULL}} -#define particle_ctrl_GetModuleInfoReply_Dependency_init_default {(particle_ctrl_FirmwareModuleType)0, 0, 0} -#define particle_ctrl_GetModuleInfoReply_Module_init_default {(particle_ctrl_FirmwareModuleType)0, 0, 0, 0, 0, {{NULL}, NULL}} -#define particle_ctrl_StartFirmwareUpdateRequest_init_zero {0, (particle_ctrl_FileFormat)0} +#define particle_ctrl_GetModuleInfoReply_Dependency_init_default {_particle_ctrl_FirmwareModuleType_MIN, 0, 0} +#define particle_ctrl_GetModuleInfoReply_Module_init_default {_particle_ctrl_FirmwareModuleType_MIN, 0, 0, 0, 0, {{NULL}, NULL}} +#define particle_ctrl_StartFirmwareUpdateRequest_init_zero {0, _particle_ctrl_FileFormat_MIN} #define particle_ctrl_StartFirmwareUpdateReply_init_zero {0} #define particle_ctrl_FinishFirmwareUpdateRequest_init_zero {0} #define particle_ctrl_FinishFirmwareUpdateReply_init_zero {0} @@ -267,9 +254,9 @@ typedef struct _particle_ctrl_DescribeStorageReply_Section { #define particle_ctrl_FirmwareUpdateDataReply_init_zero {0} #define particle_ctrl_DescribeStorageRequest_init_zero {0} #define particle_ctrl_DescribeStorageReply_init_zero {{{NULL}, NULL}} -#define particle_ctrl_DescribeStorageReply_Section_init_zero {(particle_ctrl_SectionType)0, 0, 0, particle_ctrl_DescribeStorageReply_Section_FirmwareModule_init_zero} -#define particle_ctrl_DescribeStorageReply_Section_FirmwareModule_init_zero {(particle_ctrl_FirmwareModuleType)0, 0} -#define particle_ctrl_DescribeStorageReply_Storage_init_zero {(particle_ctrl_StorageType)0, 0, {{NULL}, NULL}} +#define particle_ctrl_DescribeStorageReply_Section_init_zero {_particle_ctrl_SectionType_MIN, 0, 0, false, particle_ctrl_DescribeStorageReply_Section_FirmwareModule_init_zero} +#define particle_ctrl_DescribeStorageReply_Section_FirmwareModule_init_zero {_particle_ctrl_FirmwareModuleType_MIN, 0} +#define particle_ctrl_DescribeStorageReply_Storage_init_zero {_particle_ctrl_StorageType_MIN, 0, {{NULL}, NULL}} #define particle_ctrl_ReadSectionDataRequest_init_zero {0, 0, 0, 0} #define particle_ctrl_ReadSectionDataReply_init_zero {{{NULL}, NULL}} #define particle_ctrl_WriteSectionDataRequest_init_zero {0, 0, 0, {{NULL}, NULL}} @@ -280,8 +267,8 @@ typedef struct _particle_ctrl_DescribeStorageReply_Section { #define particle_ctrl_GetSectionDataSizeReply_init_zero {0} #define particle_ctrl_GetModuleInfoRequest_init_zero {0} #define particle_ctrl_GetModuleInfoReply_init_zero {{{NULL}, NULL}} -#define particle_ctrl_GetModuleInfoReply_Dependency_init_zero {(particle_ctrl_FirmwareModuleType)0, 0, 0} -#define particle_ctrl_GetModuleInfoReply_Module_init_zero {(particle_ctrl_FirmwareModuleType)0, 0, 0, 0, 0, {{NULL}, NULL}} +#define particle_ctrl_GetModuleInfoReply_Dependency_init_zero {_particle_ctrl_FirmwareModuleType_MIN, 0, 0} +#define particle_ctrl_GetModuleInfoReply_Module_init_zero {_particle_ctrl_FirmwareModuleType_MIN, 0, 0, 0, 0, {{NULL}, NULL}} /* Field tags (for use in manual encoding/decoding) */ #define particle_ctrl_DescribeStorageReply_storage_tag 1 @@ -325,70 +312,240 @@ typedef struct _particle_ctrl_DescribeStorageReply_Section { #define particle_ctrl_DescribeStorageReply_Section_firmware_module_tag 4 /* Struct field encoding specification for nanopb */ -extern const pb_field_t particle_ctrl_StartFirmwareUpdateRequest_fields[3]; -extern const pb_field_t particle_ctrl_StartFirmwareUpdateReply_fields[2]; -extern const pb_field_t particle_ctrl_FinishFirmwareUpdateRequest_fields[2]; -extern const pb_field_t particle_ctrl_FinishFirmwareUpdateReply_fields[1]; -extern const pb_field_t particle_ctrl_CancelFirmwareUpdateRequest_fields[1]; -extern const pb_field_t particle_ctrl_CancelFirmwareUpdateReply_fields[1]; -extern const pb_field_t particle_ctrl_FirmwareUpdateDataRequest_fields[2]; -extern const pb_field_t particle_ctrl_FirmwareUpdateDataReply_fields[1]; -extern const pb_field_t particle_ctrl_DescribeStorageRequest_fields[1]; -extern const pb_field_t particle_ctrl_DescribeStorageReply_fields[2]; -extern const pb_field_t particle_ctrl_DescribeStorageReply_Section_fields[5]; -extern const pb_field_t particle_ctrl_DescribeStorageReply_Section_FirmwareModule_fields[3]; -extern const pb_field_t particle_ctrl_DescribeStorageReply_Storage_fields[4]; -extern const pb_field_t particle_ctrl_ReadSectionDataRequest_fields[5]; -extern const pb_field_t particle_ctrl_ReadSectionDataReply_fields[2]; -extern const pb_field_t particle_ctrl_WriteSectionDataRequest_fields[5]; -extern const pb_field_t particle_ctrl_WriteSectionDataReply_fields[1]; -extern const pb_field_t particle_ctrl_ClearSectionDataRequest_fields[3]; -extern const pb_field_t particle_ctrl_ClearSectionDataReply_fields[1]; -extern const pb_field_t particle_ctrl_GetSectionDataSizeRequest_fields[3]; -extern const pb_field_t particle_ctrl_GetSectionDataSizeReply_fields[2]; -extern const pb_field_t particle_ctrl_GetModuleInfoRequest_fields[1]; -extern const pb_field_t particle_ctrl_GetModuleInfoReply_fields[2]; -extern const pb_field_t particle_ctrl_GetModuleInfoReply_Dependency_fields[4]; -extern const pb_field_t particle_ctrl_GetModuleInfoReply_Module_fields[7]; +#define particle_ctrl_StartFirmwareUpdateRequest_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UINT32, size, 1) \ +X(a, STATIC, SINGULAR, UENUM, format, 2) +#define particle_ctrl_StartFirmwareUpdateRequest_CALLBACK NULL +#define particle_ctrl_StartFirmwareUpdateRequest_DEFAULT NULL + +#define particle_ctrl_StartFirmwareUpdateReply_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UINT32, chunk_size, 1) +#define particle_ctrl_StartFirmwareUpdateReply_CALLBACK NULL +#define particle_ctrl_StartFirmwareUpdateReply_DEFAULT NULL + +#define particle_ctrl_FinishFirmwareUpdateRequest_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, BOOL, validate_only, 1) +#define particle_ctrl_FinishFirmwareUpdateRequest_CALLBACK NULL +#define particle_ctrl_FinishFirmwareUpdateRequest_DEFAULT NULL + +#define particle_ctrl_FinishFirmwareUpdateReply_FIELDLIST(X, a) \ + +#define particle_ctrl_FinishFirmwareUpdateReply_CALLBACK NULL +#define particle_ctrl_FinishFirmwareUpdateReply_DEFAULT NULL + +#define particle_ctrl_CancelFirmwareUpdateRequest_FIELDLIST(X, a) \ + +#define particle_ctrl_CancelFirmwareUpdateRequest_CALLBACK NULL +#define particle_ctrl_CancelFirmwareUpdateRequest_DEFAULT NULL + +#define particle_ctrl_CancelFirmwareUpdateReply_FIELDLIST(X, a) \ + +#define particle_ctrl_CancelFirmwareUpdateReply_CALLBACK NULL +#define particle_ctrl_CancelFirmwareUpdateReply_DEFAULT NULL + +#define particle_ctrl_FirmwareUpdateDataRequest_FIELDLIST(X, a) \ +X(a, CALLBACK, SINGULAR, BYTES, data, 1) +#define particle_ctrl_FirmwareUpdateDataRequest_CALLBACK pb_default_field_callback +#define particle_ctrl_FirmwareUpdateDataRequest_DEFAULT NULL + +#define particle_ctrl_FirmwareUpdateDataReply_FIELDLIST(X, a) \ + +#define particle_ctrl_FirmwareUpdateDataReply_CALLBACK NULL +#define particle_ctrl_FirmwareUpdateDataReply_DEFAULT NULL + +#define particle_ctrl_DescribeStorageRequest_FIELDLIST(X, a) \ + +#define particle_ctrl_DescribeStorageRequest_CALLBACK NULL +#define particle_ctrl_DescribeStorageRequest_DEFAULT NULL + +#define particle_ctrl_DescribeStorageReply_FIELDLIST(X, a) \ +X(a, CALLBACK, REPEATED, MESSAGE, storage, 1) +#define particle_ctrl_DescribeStorageReply_CALLBACK pb_default_field_callback +#define particle_ctrl_DescribeStorageReply_DEFAULT NULL +#define particle_ctrl_DescribeStorageReply_storage_MSGTYPE particle_ctrl_DescribeStorageReply_Storage + +#define particle_ctrl_DescribeStorageReply_Section_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, type, 1) \ +X(a, STATIC, SINGULAR, UINT32, size, 2) \ +X(a, STATIC, SINGULAR, UINT32, flags, 3) \ +X(a, STATIC, OPTIONAL, MESSAGE, firmware_module, 4) +#define particle_ctrl_DescribeStorageReply_Section_CALLBACK NULL +#define particle_ctrl_DescribeStorageReply_Section_DEFAULT NULL +#define particle_ctrl_DescribeStorageReply_Section_firmware_module_MSGTYPE particle_ctrl_DescribeStorageReply_Section_FirmwareModule + +#define particle_ctrl_DescribeStorageReply_Section_FirmwareModule_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, type, 1) \ +X(a, STATIC, SINGULAR, UINT32, index, 2) +#define particle_ctrl_DescribeStorageReply_Section_FirmwareModule_CALLBACK NULL +#define particle_ctrl_DescribeStorageReply_Section_FirmwareModule_DEFAULT NULL + +#define particle_ctrl_DescribeStorageReply_Storage_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, type, 1) \ +X(a, STATIC, SINGULAR, UINT32, flags, 2) \ +X(a, CALLBACK, REPEATED, MESSAGE, sections, 3) +#define particle_ctrl_DescribeStorageReply_Storage_CALLBACK pb_default_field_callback +#define particle_ctrl_DescribeStorageReply_Storage_DEFAULT NULL +#define particle_ctrl_DescribeStorageReply_Storage_sections_MSGTYPE particle_ctrl_DescribeStorageReply_Section + +#define particle_ctrl_ReadSectionDataRequest_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UINT32, storage, 1) \ +X(a, STATIC, SINGULAR, UINT32, section, 2) \ +X(a, STATIC, SINGULAR, UINT32, offset, 3) \ +X(a, STATIC, SINGULAR, UINT32, size, 4) +#define particle_ctrl_ReadSectionDataRequest_CALLBACK NULL +#define particle_ctrl_ReadSectionDataRequest_DEFAULT NULL + +#define particle_ctrl_ReadSectionDataReply_FIELDLIST(X, a) \ +X(a, CALLBACK, SINGULAR, BYTES, data, 1) +#define particle_ctrl_ReadSectionDataReply_CALLBACK pb_default_field_callback +#define particle_ctrl_ReadSectionDataReply_DEFAULT NULL + +#define particle_ctrl_WriteSectionDataRequest_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UINT32, storage, 1) \ +X(a, STATIC, SINGULAR, UINT32, section, 2) \ +X(a, STATIC, SINGULAR, UINT32, offset, 3) \ +X(a, CALLBACK, SINGULAR, BYTES, data, 4) +#define particle_ctrl_WriteSectionDataRequest_CALLBACK pb_default_field_callback +#define particle_ctrl_WriteSectionDataRequest_DEFAULT NULL + +#define particle_ctrl_WriteSectionDataReply_FIELDLIST(X, a) \ + +#define particle_ctrl_WriteSectionDataReply_CALLBACK NULL +#define particle_ctrl_WriteSectionDataReply_DEFAULT NULL + +#define particle_ctrl_ClearSectionDataRequest_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UINT32, storage, 1) \ +X(a, STATIC, SINGULAR, UINT32, section, 2) +#define particle_ctrl_ClearSectionDataRequest_CALLBACK NULL +#define particle_ctrl_ClearSectionDataRequest_DEFAULT NULL + +#define particle_ctrl_ClearSectionDataReply_FIELDLIST(X, a) \ + +#define particle_ctrl_ClearSectionDataReply_CALLBACK NULL +#define particle_ctrl_ClearSectionDataReply_DEFAULT NULL + +#define particle_ctrl_GetSectionDataSizeRequest_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UINT32, storage, 1) \ +X(a, STATIC, SINGULAR, UINT32, section, 2) +#define particle_ctrl_GetSectionDataSizeRequest_CALLBACK NULL +#define particle_ctrl_GetSectionDataSizeRequest_DEFAULT NULL + +#define particle_ctrl_GetSectionDataSizeReply_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UINT32, size, 1) +#define particle_ctrl_GetSectionDataSizeReply_CALLBACK NULL +#define particle_ctrl_GetSectionDataSizeReply_DEFAULT NULL + +#define particle_ctrl_GetModuleInfoRequest_FIELDLIST(X, a) \ + +#define particle_ctrl_GetModuleInfoRequest_CALLBACK NULL +#define particle_ctrl_GetModuleInfoRequest_DEFAULT NULL + +#define particle_ctrl_GetModuleInfoReply_FIELDLIST(X, a) \ +X(a, CALLBACK, REPEATED, MESSAGE, modules, 1) +#define particle_ctrl_GetModuleInfoReply_CALLBACK pb_default_field_callback +#define particle_ctrl_GetModuleInfoReply_DEFAULT NULL +#define particle_ctrl_GetModuleInfoReply_modules_MSGTYPE particle_ctrl_GetModuleInfoReply_Module + +#define particle_ctrl_GetModuleInfoReply_Dependency_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, type, 1) \ +X(a, STATIC, SINGULAR, UINT32, index, 2) \ +X(a, STATIC, SINGULAR, UINT32, version, 3) +#define particle_ctrl_GetModuleInfoReply_Dependency_CALLBACK NULL +#define particle_ctrl_GetModuleInfoReply_Dependency_DEFAULT NULL + +#define particle_ctrl_GetModuleInfoReply_Module_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, type, 1) \ +X(a, STATIC, SINGULAR, UINT32, index, 2) \ +X(a, STATIC, SINGULAR, UINT32, version, 3) \ +X(a, STATIC, SINGULAR, UINT32, size, 4) \ +X(a, STATIC, SINGULAR, UINT32, validity, 5) \ +X(a, CALLBACK, REPEATED, MESSAGE, dependencies, 6) +#define particle_ctrl_GetModuleInfoReply_Module_CALLBACK pb_default_field_callback +#define particle_ctrl_GetModuleInfoReply_Module_DEFAULT NULL +#define particle_ctrl_GetModuleInfoReply_Module_dependencies_MSGTYPE particle_ctrl_GetModuleInfoReply_Dependency + +extern const pb_msgdesc_t particle_ctrl_StartFirmwareUpdateRequest_msg; +extern const pb_msgdesc_t particle_ctrl_StartFirmwareUpdateReply_msg; +extern const pb_msgdesc_t particle_ctrl_FinishFirmwareUpdateRequest_msg; +extern const pb_msgdesc_t particle_ctrl_FinishFirmwareUpdateReply_msg; +extern const pb_msgdesc_t particle_ctrl_CancelFirmwareUpdateRequest_msg; +extern const pb_msgdesc_t particle_ctrl_CancelFirmwareUpdateReply_msg; +extern const pb_msgdesc_t particle_ctrl_FirmwareUpdateDataRequest_msg; +extern const pb_msgdesc_t particle_ctrl_FirmwareUpdateDataReply_msg; +extern const pb_msgdesc_t particle_ctrl_DescribeStorageRequest_msg; +extern const pb_msgdesc_t particle_ctrl_DescribeStorageReply_msg; +extern const pb_msgdesc_t particle_ctrl_DescribeStorageReply_Section_msg; +extern const pb_msgdesc_t particle_ctrl_DescribeStorageReply_Section_FirmwareModule_msg; +extern const pb_msgdesc_t particle_ctrl_DescribeStorageReply_Storage_msg; +extern const pb_msgdesc_t particle_ctrl_ReadSectionDataRequest_msg; +extern const pb_msgdesc_t particle_ctrl_ReadSectionDataReply_msg; +extern const pb_msgdesc_t particle_ctrl_WriteSectionDataRequest_msg; +extern const pb_msgdesc_t particle_ctrl_WriteSectionDataReply_msg; +extern const pb_msgdesc_t particle_ctrl_ClearSectionDataRequest_msg; +extern const pb_msgdesc_t particle_ctrl_ClearSectionDataReply_msg; +extern const pb_msgdesc_t particle_ctrl_GetSectionDataSizeRequest_msg; +extern const pb_msgdesc_t particle_ctrl_GetSectionDataSizeReply_msg; +extern const pb_msgdesc_t particle_ctrl_GetModuleInfoRequest_msg; +extern const pb_msgdesc_t particle_ctrl_GetModuleInfoReply_msg; +extern const pb_msgdesc_t particle_ctrl_GetModuleInfoReply_Dependency_msg; +extern const pb_msgdesc_t particle_ctrl_GetModuleInfoReply_Module_msg; + +/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ +#define particle_ctrl_StartFirmwareUpdateRequest_fields &particle_ctrl_StartFirmwareUpdateRequest_msg +#define particle_ctrl_StartFirmwareUpdateReply_fields &particle_ctrl_StartFirmwareUpdateReply_msg +#define particle_ctrl_FinishFirmwareUpdateRequest_fields &particle_ctrl_FinishFirmwareUpdateRequest_msg +#define particle_ctrl_FinishFirmwareUpdateReply_fields &particle_ctrl_FinishFirmwareUpdateReply_msg +#define particle_ctrl_CancelFirmwareUpdateRequest_fields &particle_ctrl_CancelFirmwareUpdateRequest_msg +#define particle_ctrl_CancelFirmwareUpdateReply_fields &particle_ctrl_CancelFirmwareUpdateReply_msg +#define particle_ctrl_FirmwareUpdateDataRequest_fields &particle_ctrl_FirmwareUpdateDataRequest_msg +#define particle_ctrl_FirmwareUpdateDataReply_fields &particle_ctrl_FirmwareUpdateDataReply_msg +#define particle_ctrl_DescribeStorageRequest_fields &particle_ctrl_DescribeStorageRequest_msg +#define particle_ctrl_DescribeStorageReply_fields &particle_ctrl_DescribeStorageReply_msg +#define particle_ctrl_DescribeStorageReply_Section_fields &particle_ctrl_DescribeStorageReply_Section_msg +#define particle_ctrl_DescribeStorageReply_Section_FirmwareModule_fields &particle_ctrl_DescribeStorageReply_Section_FirmwareModule_msg +#define particle_ctrl_DescribeStorageReply_Storage_fields &particle_ctrl_DescribeStorageReply_Storage_msg +#define particle_ctrl_ReadSectionDataRequest_fields &particle_ctrl_ReadSectionDataRequest_msg +#define particle_ctrl_ReadSectionDataReply_fields &particle_ctrl_ReadSectionDataReply_msg +#define particle_ctrl_WriteSectionDataRequest_fields &particle_ctrl_WriteSectionDataRequest_msg +#define particle_ctrl_WriteSectionDataReply_fields &particle_ctrl_WriteSectionDataReply_msg +#define particle_ctrl_ClearSectionDataRequest_fields &particle_ctrl_ClearSectionDataRequest_msg +#define particle_ctrl_ClearSectionDataReply_fields &particle_ctrl_ClearSectionDataReply_msg +#define particle_ctrl_GetSectionDataSizeRequest_fields &particle_ctrl_GetSectionDataSizeRequest_msg +#define particle_ctrl_GetSectionDataSizeReply_fields &particle_ctrl_GetSectionDataSizeReply_msg +#define particle_ctrl_GetModuleInfoRequest_fields &particle_ctrl_GetModuleInfoRequest_msg +#define particle_ctrl_GetModuleInfoReply_fields &particle_ctrl_GetModuleInfoReply_msg +#define particle_ctrl_GetModuleInfoReply_Dependency_fields &particle_ctrl_GetModuleInfoReply_Dependency_msg +#define particle_ctrl_GetModuleInfoReply_Module_fields &particle_ctrl_GetModuleInfoReply_Module_msg /* Maximum encoded size of messages (where known) */ -#define particle_ctrl_StartFirmwareUpdateRequest_size 8 -#define particle_ctrl_StartFirmwareUpdateReply_size 6 -#define particle_ctrl_FinishFirmwareUpdateRequest_size 2 -#define particle_ctrl_FinishFirmwareUpdateReply_size 0 -#define particle_ctrl_CancelFirmwareUpdateRequest_size 0 -#define particle_ctrl_CancelFirmwareUpdateReply_size 0 /* particle_ctrl_FirmwareUpdateDataRequest_size depends on runtime parameters */ -#define particle_ctrl_FirmwareUpdateDataReply_size 0 -#define particle_ctrl_DescribeStorageRequest_size 0 /* particle_ctrl_DescribeStorageReply_size depends on runtime parameters */ -#define particle_ctrl_DescribeStorageReply_Section_size 24 -#define particle_ctrl_DescribeStorageReply_Section_FirmwareModule_size 8 /* particle_ctrl_DescribeStorageReply_Storage_size depends on runtime parameters */ -#define particle_ctrl_ReadSectionDataRequest_size 24 /* particle_ctrl_ReadSectionDataReply_size depends on runtime parameters */ /* particle_ctrl_WriteSectionDataRequest_size depends on runtime parameters */ -#define particle_ctrl_WriteSectionDataReply_size 0 -#define particle_ctrl_ClearSectionDataRequest_size 12 -#define particle_ctrl_ClearSectionDataReply_size 0 -#define particle_ctrl_GetSectionDataSizeRequest_size 12 -#define particle_ctrl_GetSectionDataSizeReply_size 6 -#define particle_ctrl_GetModuleInfoRequest_size 0 /* particle_ctrl_GetModuleInfoReply_size depends on runtime parameters */ -#define particle_ctrl_GetModuleInfoReply_Dependency_size 14 /* particle_ctrl_GetModuleInfoReply_Module_size depends on runtime parameters */ - -/* Message IDs (where set with "msgid" option) */ -#ifdef PB_MSGID - -#define STORAGE_MESSAGES \ - - -#endif +#define particle_ctrl_CancelFirmwareUpdateReply_size 0 +#define particle_ctrl_CancelFirmwareUpdateRequest_size 0 +#define particle_ctrl_ClearSectionDataReply_size 0 +#define particle_ctrl_ClearSectionDataRequest_size 12 +#define particle_ctrl_DescribeStorageReply_Section_FirmwareModule_size 8 +#define particle_ctrl_DescribeStorageReply_Section_size 24 +#define particle_ctrl_DescribeStorageRequest_size 0 +#define particle_ctrl_FinishFirmwareUpdateReply_size 0 +#define particle_ctrl_FinishFirmwareUpdateRequest_size 2 +#define particle_ctrl_FirmwareUpdateDataReply_size 0 +#define particle_ctrl_GetModuleInfoReply_Dependency_size 14 +#define particle_ctrl_GetModuleInfoRequest_size 0 +#define particle_ctrl_GetSectionDataSizeReply_size 6 +#define particle_ctrl_GetSectionDataSizeRequest_size 12 +#define particle_ctrl_ReadSectionDataRequest_size 24 +#define particle_ctrl_StartFirmwareUpdateReply_size 6 +#define particle_ctrl_StartFirmwareUpdateRequest_size 8 +#define particle_ctrl_WriteSectionDataReply_size 0 #ifdef __cplusplus } /* extern "C" */ #endif -/* @@protoc_insertion_point(eof) */ #endif diff --git a/system/src/control/proto/wifi.pb.c b/system/src/control/proto/wifi.pb.c index d8bb68cfe2..04b51e42b8 100644 --- a/system/src/control/proto/wifi.pb.c +++ b/system/src/control/proto/wifi.pb.c @@ -1,118 +1,55 @@ /* Automatically generated nanopb constant definitions */ -/* Generated by nanopb-0.3.9 at Mon Jun 10 21:00:54 2019. */ +/* Generated by nanopb-0.4.5 */ #include "wifi.pb.h" - -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 +#if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif +PB_BIND(particle_ctrl_WiFiGetAntennaRequest, particle_ctrl_WiFiGetAntennaRequest, AUTO) + + +PB_BIND(particle_ctrl_WiFiGetAntennaReply, particle_ctrl_WiFiGetAntennaReply, AUTO) + + +PB_BIND(particle_ctrl_WiFiSetAntennaRequest, particle_ctrl_WiFiSetAntennaRequest, AUTO) + + +PB_BIND(particle_ctrl_WiFiSetAntennaReply, particle_ctrl_WiFiSetAntennaReply, AUTO) + + +PB_BIND(particle_ctrl_WiFiScanRequest, particle_ctrl_WiFiScanRequest, AUTO) + + +PB_BIND(particle_ctrl_WiFiScanReply, particle_ctrl_WiFiScanReply, AUTO) + + +PB_BIND(particle_ctrl_WiFiGetCredentialsRequest, particle_ctrl_WiFiGetCredentialsRequest, AUTO) + + +PB_BIND(particle_ctrl_WiFiGetCredentialsReply, particle_ctrl_WiFiGetCredentialsReply, AUTO) + + +PB_BIND(particle_ctrl_WiFiSetCredentialsRequest, particle_ctrl_WiFiSetCredentialsRequest, AUTO) + + +PB_BIND(particle_ctrl_WiFiSetCredentialsReply, particle_ctrl_WiFiSetCredentialsReply, AUTO) + + +PB_BIND(particle_ctrl_WiFiClearCredentialsRequest, particle_ctrl_WiFiClearCredentialsRequest, AUTO) + + +PB_BIND(particle_ctrl_WiFiClearCredentialsReply, particle_ctrl_WiFiClearCredentialsReply, AUTO) + + +PB_BIND(particle_ctrl_WiFiAccessPoint, particle_ctrl_WiFiAccessPoint, AUTO) + + +PB_BIND(particle_ctrl_WiFiAccessPointList, particle_ctrl_WiFiAccessPointList, AUTO) + + -const pb_field_t particle_ctrl_WiFiGetAntennaRequest_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_WiFiGetAntennaReply_fields[2] = { - PB_FIELD( 1, UENUM , SINGULAR, STATIC , FIRST, particle_ctrl_WiFiGetAntennaReply, antenna, antenna, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_WiFiSetAntennaRequest_fields[2] = { - PB_FIELD( 1, UENUM , SINGULAR, STATIC , FIRST, particle_ctrl_WiFiSetAntennaRequest, antenna, antenna, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_WiFiSetAntennaReply_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_WiFiScanRequest_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_WiFiScanReply_fields[2] = { - PB_FIELD( 1, MESSAGE , SINGULAR, STATIC , FIRST, particle_ctrl_WiFiScanReply, list, list, &particle_ctrl_WiFiAccessPointList_fields), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_WiFiGetCredentialsRequest_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_WiFiGetCredentialsReply_fields[2] = { - PB_FIELD( 1, MESSAGE , SINGULAR, STATIC , FIRST, particle_ctrl_WiFiGetCredentialsReply, list, list, &particle_ctrl_WiFiAccessPointList_fields), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_WiFiSetCredentialsRequest_fields[2] = { - PB_FIELD( 1, MESSAGE , SINGULAR, STATIC , FIRST, particle_ctrl_WiFiSetCredentialsRequest, ap, ap, &particle_ctrl_WiFiAccessPoint_fields), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_WiFiSetCredentialsReply_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_WiFiClearCredentialsRequest_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_WiFiClearCredentialsReply_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_WiFiAccessPoint_fields[15] = { - PB_FIELD( 1, STRING , SINGULAR, STATIC , FIRST, particle_ctrl_WiFiAccessPoint, ssid, ssid, 0), - PB_FIELD( 2, FIXED_LENGTH_BYTES, SINGULAR, STATIC , OTHER, particle_ctrl_WiFiAccessPoint, bssid, ssid, 0), - PB_FIELD( 3, UENUM , SINGULAR, STATIC , OTHER, particle_ctrl_WiFiAccessPoint, security, bssid, 0), - PB_FIELD( 4, UENUM , SINGULAR, STATIC , OTHER, particle_ctrl_WiFiAccessPoint, cipher, security, 0), - PB_FIELD( 5, UINT32 , SINGULAR, STATIC , OTHER, particle_ctrl_WiFiAccessPoint, channel, cipher, 0), - PB_FIELD( 6, INT32 , SINGULAR, STATIC , OTHER, particle_ctrl_WiFiAccessPoint, max_data_rate, channel, 0), - PB_FIELD( 7, INT32 , SINGULAR, STATIC , OTHER, particle_ctrl_WiFiAccessPoint, rssi, max_data_rate, 0), - PB_FIELD( 8, STRING , SINGULAR, CALLBACK, OTHER, particle_ctrl_WiFiAccessPoint, password, rssi, 0), - PB_FIELD( 9, UENUM , SINGULAR, STATIC , OTHER, particle_ctrl_WiFiAccessPoint, eap_type, password, 0), - PB_FIELD( 10, STRING , SINGULAR, CALLBACK, OTHER, particle_ctrl_WiFiAccessPoint, inner_identity, eap_type, 0), - PB_FIELD( 11, STRING , SINGULAR, CALLBACK, OTHER, particle_ctrl_WiFiAccessPoint, outer_identity, inner_identity, 0), - PB_FIELD( 12, BYTES , SINGULAR, CALLBACK, OTHER, particle_ctrl_WiFiAccessPoint, private_key, outer_identity, 0), - PB_FIELD( 13, BYTES , SINGULAR, CALLBACK, OTHER, particle_ctrl_WiFiAccessPoint, client_certificate, private_key, 0), - PB_FIELD( 14, BYTES , SINGULAR, CALLBACK, OTHER, particle_ctrl_WiFiAccessPoint, ca_certificate, client_certificate, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_WiFiAccessPointList_fields[2] = { - PB_FIELD( 1, MESSAGE , REPEATED, CALLBACK, FIRST, particle_ctrl_WiFiAccessPointList, aps, aps, &particle_ctrl_WiFiAccessPoint_fields), - PB_LAST_FIELD -}; - - - - - - -/* Check that field information fits in pb_field_t */ -#if !defined(PB_FIELD_32BIT) -/* If you get an error here, it means that you need to define PB_FIELD_32BIT - * compile-time option. You can do that in pb.h or on compiler command line. - * - * The reason you need to do this is that some of your messages contain tag - * numbers or field sizes that are larger than what can fit in 8 or 16 bit - * field descriptors. - */ -PB_STATIC_ASSERT((pb_membersize(particle_ctrl_WiFiScanReply, list) < 65536 && pb_membersize(particle_ctrl_WiFiGetCredentialsReply, list) < 65536 && pb_membersize(particle_ctrl_WiFiSetCredentialsRequest, ap) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_particle_ctrl_WiFiGetAntennaRequest_particle_ctrl_WiFiGetAntennaReply_particle_ctrl_WiFiSetAntennaRequest_particle_ctrl_WiFiSetAntennaReply_particle_ctrl_WiFiScanRequest_particle_ctrl_WiFiScanReply_particle_ctrl_WiFiGetCredentialsRequest_particle_ctrl_WiFiGetCredentialsReply_particle_ctrl_WiFiSetCredentialsRequest_particle_ctrl_WiFiSetCredentialsReply_particle_ctrl_WiFiClearCredentialsRequest_particle_ctrl_WiFiClearCredentialsReply_particle_ctrl_WiFiAccessPoint_particle_ctrl_WiFiAccessPointList) -#endif -#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT) -/* If you get an error here, it means that you need to define PB_FIELD_16BIT - * compile-time option. You can do that in pb.h or on compiler command line. - * - * The reason you need to do this is that some of your messages contain tag - * numbers or field sizes that are larger than what can fit in the default - * 8 bit descriptors. - */ -PB_STATIC_ASSERT((pb_membersize(particle_ctrl_WiFiScanReply, list) < 256 && pb_membersize(particle_ctrl_WiFiGetCredentialsReply, list) < 256 && pb_membersize(particle_ctrl_WiFiSetCredentialsRequest, ap) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_particle_ctrl_WiFiGetAntennaRequest_particle_ctrl_WiFiGetAntennaReply_particle_ctrl_WiFiSetAntennaRequest_particle_ctrl_WiFiSetAntennaReply_particle_ctrl_WiFiScanRequest_particle_ctrl_WiFiScanReply_particle_ctrl_WiFiGetCredentialsRequest_particle_ctrl_WiFiGetCredentialsReply_particle_ctrl_WiFiSetCredentialsRequest_particle_ctrl_WiFiSetCredentialsReply_particle_ctrl_WiFiClearCredentialsRequest_particle_ctrl_WiFiClearCredentialsReply_particle_ctrl_WiFiAccessPoint_particle_ctrl_WiFiAccessPointList) -#endif -/* @@protoc_insertion_point(eof) */ diff --git a/system/src/control/proto/wifi.pb.h b/system/src/control/proto/wifi.pb.h index 861e901de6..04270d0be8 100644 --- a/system/src/control/proto/wifi.pb.h +++ b/system/src/control/proto/wifi.pb.h @@ -1,180 +1,172 @@ /* Automatically generated nanopb header */ -/* Generated by nanopb-0.3.9 at Mon Jun 10 21:00:54 2019. */ +/* Generated by nanopb-0.4.5 */ #ifndef PB_PARTICLE_CTRL_WIFI_PB_H_INCLUDED #define PB_PARTICLE_CTRL_WIFI_PB_H_INCLUDED #include - #include "extensions.pb.h" - #include "common.pb.h" -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 +#if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif -#ifdef __cplusplus -extern "C" { -#endif - /* Enum definitions */ -typedef enum _particle_ctrl_WiFiAntenna { - particle_ctrl_WiFiAntenna_ANTENNA_NONE = 0, - particle_ctrl_WiFiAntenna_INTERNAL = 1, - particle_ctrl_WiFiAntenna_EXTERNAL = 2, - particle_ctrl_WiFiAntenna_AUTO = 3 +typedef enum _particle_ctrl_WiFiAntenna { + particle_ctrl_WiFiAntenna_ANTENNA_NONE = 0, + particle_ctrl_WiFiAntenna_INTERNAL = 1, + particle_ctrl_WiFiAntenna_EXTERNAL = 2, + particle_ctrl_WiFiAntenna_AUTO = 3 } particle_ctrl_WiFiAntenna; -#define _particle_ctrl_WiFiAntenna_MIN particle_ctrl_WiFiAntenna_ANTENNA_NONE -#define _particle_ctrl_WiFiAntenna_MAX particle_ctrl_WiFiAntenna_AUTO -#define _particle_ctrl_WiFiAntenna_ARRAYSIZE ((particle_ctrl_WiFiAntenna)(particle_ctrl_WiFiAntenna_AUTO+1)) -typedef enum _particle_ctrl_WiFiSecurityType { - particle_ctrl_WiFiSecurityType_UNSEC = 0, - particle_ctrl_WiFiSecurityType_WEP = 1, - particle_ctrl_WiFiSecurityType_WPA = 2, - particle_ctrl_WiFiSecurityType_WPA2 = 3, - particle_ctrl_WiFiSecurityType_WPA_ENTERPRISE = 4, - particle_ctrl_WiFiSecurityType_WPA2_ENTERPRISE = 5, - particle_ctrl_WiFiSecurityType_UNKNOWN = 255 +typedef enum _particle_ctrl_WiFiSecurityType { + particle_ctrl_WiFiSecurityType_UNSEC = 0, + particle_ctrl_WiFiSecurityType_WEP = 1, + particle_ctrl_WiFiSecurityType_WPA = 2, + particle_ctrl_WiFiSecurityType_WPA2 = 3, + particle_ctrl_WiFiSecurityType_WPA_ENTERPRISE = 4, + particle_ctrl_WiFiSecurityType_WPA2_ENTERPRISE = 5, + particle_ctrl_WiFiSecurityType_UNKNOWN = 255 } particle_ctrl_WiFiSecurityType; -#define _particle_ctrl_WiFiSecurityType_MIN particle_ctrl_WiFiSecurityType_UNSEC -#define _particle_ctrl_WiFiSecurityType_MAX particle_ctrl_WiFiSecurityType_UNKNOWN -#define _particle_ctrl_WiFiSecurityType_ARRAYSIZE ((particle_ctrl_WiFiSecurityType)(particle_ctrl_WiFiSecurityType_UNKNOWN+1)) -typedef enum _particle_ctrl_WiFiSecurityCipher { - particle_ctrl_WiFiSecurityCipher_CIPHER_NONE = 0, - particle_ctrl_WiFiSecurityCipher_AES = 1, - particle_ctrl_WiFiSecurityCipher_TKIP = 2, - particle_ctrl_WiFiSecurityCipher_AES_TKIP = 3 +typedef enum _particle_ctrl_WiFiSecurityCipher { + particle_ctrl_WiFiSecurityCipher_CIPHER_NONE = 0, + particle_ctrl_WiFiSecurityCipher_AES = 1, + particle_ctrl_WiFiSecurityCipher_TKIP = 2, + particle_ctrl_WiFiSecurityCipher_AES_TKIP = 3 } particle_ctrl_WiFiSecurityCipher; -#define _particle_ctrl_WiFiSecurityCipher_MIN particle_ctrl_WiFiSecurityCipher_CIPHER_NONE -#define _particle_ctrl_WiFiSecurityCipher_MAX particle_ctrl_WiFiSecurityCipher_AES_TKIP -#define _particle_ctrl_WiFiSecurityCipher_ARRAYSIZE ((particle_ctrl_WiFiSecurityCipher)(particle_ctrl_WiFiSecurityCipher_AES_TKIP+1)) -typedef enum _particle_ctrl_EapType { - particle_ctrl_EapType_EAP_TYPE_NONE = 0, - particle_ctrl_EapType_TLS = 13, - particle_ctrl_EapType_PEAP = 25 +typedef enum _particle_ctrl_EapType { + particle_ctrl_EapType_EAP_TYPE_NONE = 0, + particle_ctrl_EapType_TLS = 13, + particle_ctrl_EapType_PEAP = 25 } particle_ctrl_EapType; -#define _particle_ctrl_EapType_MIN particle_ctrl_EapType_EAP_TYPE_NONE -#define _particle_ctrl_EapType_MAX particle_ctrl_EapType_PEAP -#define _particle_ctrl_EapType_ARRAYSIZE ((particle_ctrl_EapType)(particle_ctrl_EapType_PEAP+1)) /* Struct definitions */ -typedef struct _particle_ctrl_WiFiAccessPointList { - pb_callback_t aps; -/* @@protoc_insertion_point(struct:particle_ctrl_WiFiAccessPointList) */ +typedef struct _particle_ctrl_WiFiAccessPointList { + pb_callback_t aps; } particle_ctrl_WiFiAccessPointList; -typedef struct _particle_ctrl_WiFiClearCredentialsReply { +typedef struct _particle_ctrl_WiFiClearCredentialsReply { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_WiFiClearCredentialsReply) */ } particle_ctrl_WiFiClearCredentialsReply; -typedef struct _particle_ctrl_WiFiClearCredentialsRequest { +typedef struct _particle_ctrl_WiFiClearCredentialsRequest { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_WiFiClearCredentialsRequest) */ } particle_ctrl_WiFiClearCredentialsRequest; -typedef struct _particle_ctrl_WiFiGetAntennaRequest { +typedef struct _particle_ctrl_WiFiGetAntennaRequest { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_WiFiGetAntennaRequest) */ } particle_ctrl_WiFiGetAntennaRequest; -typedef struct _particle_ctrl_WiFiGetCredentialsRequest { +typedef struct _particle_ctrl_WiFiGetCredentialsRequest { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_WiFiGetCredentialsRequest) */ } particle_ctrl_WiFiGetCredentialsRequest; -typedef struct _particle_ctrl_WiFiScanRequest { +typedef struct _particle_ctrl_WiFiScanRequest { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_WiFiScanRequest) */ } particle_ctrl_WiFiScanRequest; -typedef struct _particle_ctrl_WiFiSetAntennaReply { +typedef struct _particle_ctrl_WiFiSetAntennaReply { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_WiFiSetAntennaReply) */ } particle_ctrl_WiFiSetAntennaReply; -typedef struct _particle_ctrl_WiFiSetCredentialsReply { +typedef struct _particle_ctrl_WiFiSetCredentialsReply { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_WiFiSetCredentialsReply) */ } particle_ctrl_WiFiSetCredentialsReply; -typedef struct _particle_ctrl_WiFiAccessPoint { - char ssid[33]; - pb_byte_t bssid[6]; - particle_ctrl_WiFiSecurityType security; - particle_ctrl_WiFiSecurityCipher cipher; - uint32_t channel; - int32_t max_data_rate; - int32_t rssi; - pb_callback_t password; - particle_ctrl_EapType eap_type; - pb_callback_t inner_identity; - pb_callback_t outer_identity; - pb_callback_t private_key; - pb_callback_t client_certificate; - pb_callback_t ca_certificate; -/* @@protoc_insertion_point(struct:particle_ctrl_WiFiAccessPoint) */ +typedef struct _particle_ctrl_WiFiAccessPoint { + char ssid[33]; + pb_byte_t bssid[6]; + particle_ctrl_WiFiSecurityType security; + particle_ctrl_WiFiSecurityCipher cipher; + uint32_t channel; + int32_t max_data_rate; + int32_t rssi; + /* Credentials */ + pb_callback_t password; + particle_ctrl_EapType eap_type; + pb_callback_t inner_identity; + pb_callback_t outer_identity; + pb_callback_t private_key; + pb_callback_t client_certificate; + pb_callback_t ca_certificate; } particle_ctrl_WiFiAccessPoint; -typedef struct _particle_ctrl_WiFiGetAntennaReply { - particle_ctrl_WiFiAntenna antenna; -/* @@protoc_insertion_point(struct:particle_ctrl_WiFiGetAntennaReply) */ +typedef struct _particle_ctrl_WiFiGetAntennaReply { + particle_ctrl_WiFiAntenna antenna; } particle_ctrl_WiFiGetAntennaReply; -typedef struct _particle_ctrl_WiFiGetCredentialsReply { - particle_ctrl_WiFiAccessPointList list; -/* @@protoc_insertion_point(struct:particle_ctrl_WiFiGetCredentialsReply) */ +typedef struct _particle_ctrl_WiFiGetCredentialsReply { + bool has_list; + particle_ctrl_WiFiAccessPointList list; } particle_ctrl_WiFiGetCredentialsReply; -typedef struct _particle_ctrl_WiFiScanReply { - particle_ctrl_WiFiAccessPointList list; -/* @@protoc_insertion_point(struct:particle_ctrl_WiFiScanReply) */ +typedef struct _particle_ctrl_WiFiScanReply { + bool has_list; + particle_ctrl_WiFiAccessPointList list; } particle_ctrl_WiFiScanReply; -typedef struct _particle_ctrl_WiFiSetAntennaRequest { - particle_ctrl_WiFiAntenna antenna; -/* @@protoc_insertion_point(struct:particle_ctrl_WiFiSetAntennaRequest) */ +typedef struct _particle_ctrl_WiFiSetAntennaRequest { + particle_ctrl_WiFiAntenna antenna; } particle_ctrl_WiFiSetAntennaRequest; -typedef struct _particle_ctrl_WiFiSetCredentialsRequest { - particle_ctrl_WiFiAccessPoint ap; -/* @@protoc_insertion_point(struct:particle_ctrl_WiFiSetCredentialsRequest) */ +typedef struct _particle_ctrl_WiFiSetCredentialsRequest { + bool has_ap; + particle_ctrl_WiFiAccessPoint ap; } particle_ctrl_WiFiSetCredentialsRequest; -/* Default values for struct fields */ + +/* Helper constants for enums */ +#define _particle_ctrl_WiFiAntenna_MIN particle_ctrl_WiFiAntenna_ANTENNA_NONE +#define _particle_ctrl_WiFiAntenna_MAX particle_ctrl_WiFiAntenna_AUTO +#define _particle_ctrl_WiFiAntenna_ARRAYSIZE ((particle_ctrl_WiFiAntenna)(particle_ctrl_WiFiAntenna_AUTO+1)) + +#define _particle_ctrl_WiFiSecurityType_MIN particle_ctrl_WiFiSecurityType_UNSEC +#define _particle_ctrl_WiFiSecurityType_MAX particle_ctrl_WiFiSecurityType_UNKNOWN +#define _particle_ctrl_WiFiSecurityType_ARRAYSIZE ((particle_ctrl_WiFiSecurityType)(particle_ctrl_WiFiSecurityType_UNKNOWN+1)) + +#define _particle_ctrl_WiFiSecurityCipher_MIN particle_ctrl_WiFiSecurityCipher_CIPHER_NONE +#define _particle_ctrl_WiFiSecurityCipher_MAX particle_ctrl_WiFiSecurityCipher_AES_TKIP +#define _particle_ctrl_WiFiSecurityCipher_ARRAYSIZE ((particle_ctrl_WiFiSecurityCipher)(particle_ctrl_WiFiSecurityCipher_AES_TKIP+1)) + +#define _particle_ctrl_EapType_MIN particle_ctrl_EapType_EAP_TYPE_NONE +#define _particle_ctrl_EapType_MAX particle_ctrl_EapType_PEAP +#define _particle_ctrl_EapType_ARRAYSIZE ((particle_ctrl_EapType)(particle_ctrl_EapType_PEAP+1)) + + +#ifdef __cplusplus +extern "C" { +#endif /* Initializer values for message structs */ #define particle_ctrl_WiFiGetAntennaRequest_init_default {0} -#define particle_ctrl_WiFiGetAntennaReply_init_default {(particle_ctrl_WiFiAntenna)0} -#define particle_ctrl_WiFiSetAntennaRequest_init_default {(particle_ctrl_WiFiAntenna)0} +#define particle_ctrl_WiFiGetAntennaReply_init_default {_particle_ctrl_WiFiAntenna_MIN} +#define particle_ctrl_WiFiSetAntennaRequest_init_default {_particle_ctrl_WiFiAntenna_MIN} #define particle_ctrl_WiFiSetAntennaReply_init_default {0} #define particle_ctrl_WiFiScanRequest_init_default {0} -#define particle_ctrl_WiFiScanReply_init_default {particle_ctrl_WiFiAccessPointList_init_default} +#define particle_ctrl_WiFiScanReply_init_default {false, particle_ctrl_WiFiAccessPointList_init_default} #define particle_ctrl_WiFiGetCredentialsRequest_init_default {0} -#define particle_ctrl_WiFiGetCredentialsReply_init_default {particle_ctrl_WiFiAccessPointList_init_default} -#define particle_ctrl_WiFiSetCredentialsRequest_init_default {particle_ctrl_WiFiAccessPoint_init_default} +#define particle_ctrl_WiFiGetCredentialsReply_init_default {false, particle_ctrl_WiFiAccessPointList_init_default} +#define particle_ctrl_WiFiSetCredentialsRequest_init_default {false, particle_ctrl_WiFiAccessPoint_init_default} #define particle_ctrl_WiFiSetCredentialsReply_init_default {0} #define particle_ctrl_WiFiClearCredentialsRequest_init_default {0} #define particle_ctrl_WiFiClearCredentialsReply_init_default {0} -#define particle_ctrl_WiFiAccessPoint_init_default {"", {0}, (particle_ctrl_WiFiSecurityType)0, (particle_ctrl_WiFiSecurityCipher)0, 0, 0, 0, {{NULL}, NULL}, (particle_ctrl_EapType)0, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}} +#define particle_ctrl_WiFiAccessPoint_init_default {"", {0}, _particle_ctrl_WiFiSecurityType_MIN, _particle_ctrl_WiFiSecurityCipher_MIN, 0, 0, 0, {{NULL}, NULL}, _particle_ctrl_EapType_MIN, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}} #define particle_ctrl_WiFiAccessPointList_init_default {{{NULL}, NULL}} #define particle_ctrl_WiFiGetAntennaRequest_init_zero {0} -#define particle_ctrl_WiFiGetAntennaReply_init_zero {(particle_ctrl_WiFiAntenna)0} -#define particle_ctrl_WiFiSetAntennaRequest_init_zero {(particle_ctrl_WiFiAntenna)0} +#define particle_ctrl_WiFiGetAntennaReply_init_zero {_particle_ctrl_WiFiAntenna_MIN} +#define particle_ctrl_WiFiSetAntennaRequest_init_zero {_particle_ctrl_WiFiAntenna_MIN} #define particle_ctrl_WiFiSetAntennaReply_init_zero {0} #define particle_ctrl_WiFiScanRequest_init_zero {0} -#define particle_ctrl_WiFiScanReply_init_zero {particle_ctrl_WiFiAccessPointList_init_zero} +#define particle_ctrl_WiFiScanReply_init_zero {false, particle_ctrl_WiFiAccessPointList_init_zero} #define particle_ctrl_WiFiGetCredentialsRequest_init_zero {0} -#define particle_ctrl_WiFiGetCredentialsReply_init_zero {particle_ctrl_WiFiAccessPointList_init_zero} -#define particle_ctrl_WiFiSetCredentialsRequest_init_zero {particle_ctrl_WiFiAccessPoint_init_zero} +#define particle_ctrl_WiFiGetCredentialsReply_init_zero {false, particle_ctrl_WiFiAccessPointList_init_zero} +#define particle_ctrl_WiFiSetCredentialsRequest_init_zero {false, particle_ctrl_WiFiAccessPoint_init_zero} #define particle_ctrl_WiFiSetCredentialsReply_init_zero {0} #define particle_ctrl_WiFiClearCredentialsRequest_init_zero {0} #define particle_ctrl_WiFiClearCredentialsReply_init_zero {0} -#define particle_ctrl_WiFiAccessPoint_init_zero {"", {0}, (particle_ctrl_WiFiSecurityType)0, (particle_ctrl_WiFiSecurityCipher)0, 0, 0, 0, {{NULL}, NULL}, (particle_ctrl_EapType)0, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}} +#define particle_ctrl_WiFiAccessPoint_init_zero {"", {0}, _particle_ctrl_WiFiSecurityType_MIN, _particle_ctrl_WiFiSecurityCipher_MIN, 0, 0, 0, {{NULL}, NULL}, _particle_ctrl_EapType_MIN, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}} #define particle_ctrl_WiFiAccessPointList_init_zero {{{NULL}, NULL}} /* Field tags (for use in manual encoding/decoding) */ @@ -200,48 +192,142 @@ typedef struct _particle_ctrl_WiFiSetCredentialsRequest { #define particle_ctrl_WiFiSetCredentialsRequest_ap_tag 1 /* Struct field encoding specification for nanopb */ -extern const pb_field_t particle_ctrl_WiFiGetAntennaRequest_fields[1]; -extern const pb_field_t particle_ctrl_WiFiGetAntennaReply_fields[2]; -extern const pb_field_t particle_ctrl_WiFiSetAntennaRequest_fields[2]; -extern const pb_field_t particle_ctrl_WiFiSetAntennaReply_fields[1]; -extern const pb_field_t particle_ctrl_WiFiScanRequest_fields[1]; -extern const pb_field_t particle_ctrl_WiFiScanReply_fields[2]; -extern const pb_field_t particle_ctrl_WiFiGetCredentialsRequest_fields[1]; -extern const pb_field_t particle_ctrl_WiFiGetCredentialsReply_fields[2]; -extern const pb_field_t particle_ctrl_WiFiSetCredentialsRequest_fields[2]; -extern const pb_field_t particle_ctrl_WiFiSetCredentialsReply_fields[1]; -extern const pb_field_t particle_ctrl_WiFiClearCredentialsRequest_fields[1]; -extern const pb_field_t particle_ctrl_WiFiClearCredentialsReply_fields[1]; -extern const pb_field_t particle_ctrl_WiFiAccessPoint_fields[15]; -extern const pb_field_t particle_ctrl_WiFiAccessPointList_fields[2]; +#define particle_ctrl_WiFiGetAntennaRequest_FIELDLIST(X, a) \ + +#define particle_ctrl_WiFiGetAntennaRequest_CALLBACK NULL +#define particle_ctrl_WiFiGetAntennaRequest_DEFAULT NULL + +#define particle_ctrl_WiFiGetAntennaReply_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, antenna, 1) +#define particle_ctrl_WiFiGetAntennaReply_CALLBACK NULL +#define particle_ctrl_WiFiGetAntennaReply_DEFAULT NULL + +#define particle_ctrl_WiFiSetAntennaRequest_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, antenna, 1) +#define particle_ctrl_WiFiSetAntennaRequest_CALLBACK NULL +#define particle_ctrl_WiFiSetAntennaRequest_DEFAULT NULL + +#define particle_ctrl_WiFiSetAntennaReply_FIELDLIST(X, a) \ + +#define particle_ctrl_WiFiSetAntennaReply_CALLBACK NULL +#define particle_ctrl_WiFiSetAntennaReply_DEFAULT NULL + +#define particle_ctrl_WiFiScanRequest_FIELDLIST(X, a) \ + +#define particle_ctrl_WiFiScanRequest_CALLBACK NULL +#define particle_ctrl_WiFiScanRequest_DEFAULT NULL + +#define particle_ctrl_WiFiScanReply_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, MESSAGE, list, 1) +#define particle_ctrl_WiFiScanReply_CALLBACK NULL +#define particle_ctrl_WiFiScanReply_DEFAULT NULL +#define particle_ctrl_WiFiScanReply_list_MSGTYPE particle_ctrl_WiFiAccessPointList + +#define particle_ctrl_WiFiGetCredentialsRequest_FIELDLIST(X, a) \ + +#define particle_ctrl_WiFiGetCredentialsRequest_CALLBACK NULL +#define particle_ctrl_WiFiGetCredentialsRequest_DEFAULT NULL + +#define particle_ctrl_WiFiGetCredentialsReply_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, MESSAGE, list, 1) +#define particle_ctrl_WiFiGetCredentialsReply_CALLBACK NULL +#define particle_ctrl_WiFiGetCredentialsReply_DEFAULT NULL +#define particle_ctrl_WiFiGetCredentialsReply_list_MSGTYPE particle_ctrl_WiFiAccessPointList + +#define particle_ctrl_WiFiSetCredentialsRequest_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, MESSAGE, ap, 1) +#define particle_ctrl_WiFiSetCredentialsRequest_CALLBACK NULL +#define particle_ctrl_WiFiSetCredentialsRequest_DEFAULT NULL +#define particle_ctrl_WiFiSetCredentialsRequest_ap_MSGTYPE particle_ctrl_WiFiAccessPoint + +#define particle_ctrl_WiFiSetCredentialsReply_FIELDLIST(X, a) \ + +#define particle_ctrl_WiFiSetCredentialsReply_CALLBACK NULL +#define particle_ctrl_WiFiSetCredentialsReply_DEFAULT NULL + +#define particle_ctrl_WiFiClearCredentialsRequest_FIELDLIST(X, a) \ + +#define particle_ctrl_WiFiClearCredentialsRequest_CALLBACK NULL +#define particle_ctrl_WiFiClearCredentialsRequest_DEFAULT NULL + +#define particle_ctrl_WiFiClearCredentialsReply_FIELDLIST(X, a) \ + +#define particle_ctrl_WiFiClearCredentialsReply_CALLBACK NULL +#define particle_ctrl_WiFiClearCredentialsReply_DEFAULT NULL + +#define particle_ctrl_WiFiAccessPoint_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, STRING, ssid, 1) \ +X(a, STATIC, SINGULAR, FIXED_LENGTH_BYTES, bssid, 2) \ +X(a, STATIC, SINGULAR, UENUM, security, 3) \ +X(a, STATIC, SINGULAR, UENUM, cipher, 4) \ +X(a, STATIC, SINGULAR, UINT32, channel, 5) \ +X(a, STATIC, SINGULAR, INT32, max_data_rate, 6) \ +X(a, STATIC, SINGULAR, INT32, rssi, 7) \ +X(a, CALLBACK, SINGULAR, STRING, password, 8) \ +X(a, STATIC, SINGULAR, UENUM, eap_type, 9) \ +X(a, CALLBACK, SINGULAR, STRING, inner_identity, 10) \ +X(a, CALLBACK, SINGULAR, STRING, outer_identity, 11) \ +X(a, CALLBACK, SINGULAR, BYTES, private_key, 12) \ +X(a, CALLBACK, SINGULAR, BYTES, client_certificate, 13) \ +X(a, CALLBACK, SINGULAR, BYTES, ca_certificate, 14) +#define particle_ctrl_WiFiAccessPoint_CALLBACK pb_default_field_callback +#define particle_ctrl_WiFiAccessPoint_DEFAULT NULL + +#define particle_ctrl_WiFiAccessPointList_FIELDLIST(X, a) \ +X(a, CALLBACK, REPEATED, MESSAGE, aps, 1) +#define particle_ctrl_WiFiAccessPointList_CALLBACK pb_default_field_callback +#define particle_ctrl_WiFiAccessPointList_DEFAULT NULL +#define particle_ctrl_WiFiAccessPointList_aps_MSGTYPE particle_ctrl_WiFiAccessPoint + +extern const pb_msgdesc_t particle_ctrl_WiFiGetAntennaRequest_msg; +extern const pb_msgdesc_t particle_ctrl_WiFiGetAntennaReply_msg; +extern const pb_msgdesc_t particle_ctrl_WiFiSetAntennaRequest_msg; +extern const pb_msgdesc_t particle_ctrl_WiFiSetAntennaReply_msg; +extern const pb_msgdesc_t particle_ctrl_WiFiScanRequest_msg; +extern const pb_msgdesc_t particle_ctrl_WiFiScanReply_msg; +extern const pb_msgdesc_t particle_ctrl_WiFiGetCredentialsRequest_msg; +extern const pb_msgdesc_t particle_ctrl_WiFiGetCredentialsReply_msg; +extern const pb_msgdesc_t particle_ctrl_WiFiSetCredentialsRequest_msg; +extern const pb_msgdesc_t particle_ctrl_WiFiSetCredentialsReply_msg; +extern const pb_msgdesc_t particle_ctrl_WiFiClearCredentialsRequest_msg; +extern const pb_msgdesc_t particle_ctrl_WiFiClearCredentialsReply_msg; +extern const pb_msgdesc_t particle_ctrl_WiFiAccessPoint_msg; +extern const pb_msgdesc_t particle_ctrl_WiFiAccessPointList_msg; + +/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ +#define particle_ctrl_WiFiGetAntennaRequest_fields &particle_ctrl_WiFiGetAntennaRequest_msg +#define particle_ctrl_WiFiGetAntennaReply_fields &particle_ctrl_WiFiGetAntennaReply_msg +#define particle_ctrl_WiFiSetAntennaRequest_fields &particle_ctrl_WiFiSetAntennaRequest_msg +#define particle_ctrl_WiFiSetAntennaReply_fields &particle_ctrl_WiFiSetAntennaReply_msg +#define particle_ctrl_WiFiScanRequest_fields &particle_ctrl_WiFiScanRequest_msg +#define particle_ctrl_WiFiScanReply_fields &particle_ctrl_WiFiScanReply_msg +#define particle_ctrl_WiFiGetCredentialsRequest_fields &particle_ctrl_WiFiGetCredentialsRequest_msg +#define particle_ctrl_WiFiGetCredentialsReply_fields &particle_ctrl_WiFiGetCredentialsReply_msg +#define particle_ctrl_WiFiSetCredentialsRequest_fields &particle_ctrl_WiFiSetCredentialsRequest_msg +#define particle_ctrl_WiFiSetCredentialsReply_fields &particle_ctrl_WiFiSetCredentialsReply_msg +#define particle_ctrl_WiFiClearCredentialsRequest_fields &particle_ctrl_WiFiClearCredentialsRequest_msg +#define particle_ctrl_WiFiClearCredentialsReply_fields &particle_ctrl_WiFiClearCredentialsReply_msg +#define particle_ctrl_WiFiAccessPoint_fields &particle_ctrl_WiFiAccessPoint_msg +#define particle_ctrl_WiFiAccessPointList_fields &particle_ctrl_WiFiAccessPointList_msg /* Maximum encoded size of messages (where known) */ -#define particle_ctrl_WiFiGetAntennaRequest_size 0 +/* particle_ctrl_WiFiScanReply_size depends on runtime parameters */ +/* particle_ctrl_WiFiGetCredentialsReply_size depends on runtime parameters */ +/* particle_ctrl_WiFiSetCredentialsRequest_size depends on runtime parameters */ +/* particle_ctrl_WiFiAccessPoint_size depends on runtime parameters */ +/* particle_ctrl_WiFiAccessPointList_size depends on runtime parameters */ +#define particle_ctrl_WiFiClearCredentialsReply_size 0 +#define particle_ctrl_WiFiClearCredentialsRequest_size 0 #define particle_ctrl_WiFiGetAntennaReply_size 2 -#define particle_ctrl_WiFiSetAntennaRequest_size 2 -#define particle_ctrl_WiFiSetAntennaReply_size 0 -#define particle_ctrl_WiFiScanRequest_size 0 -#define particle_ctrl_WiFiScanReply_size (6 + particle_ctrl_WiFiAccessPointList_size) +#define particle_ctrl_WiFiGetAntennaRequest_size 0 #define particle_ctrl_WiFiGetCredentialsRequest_size 0 -#define particle_ctrl_WiFiGetCredentialsReply_size (6 + particle_ctrl_WiFiAccessPointList_size) -#define particle_ctrl_WiFiSetCredentialsRequest_size (6 + particle_ctrl_WiFiAccessPoint_size) +#define particle_ctrl_WiFiScanRequest_size 0 +#define particle_ctrl_WiFiSetAntennaReply_size 0 +#define particle_ctrl_WiFiSetAntennaRequest_size 2 #define particle_ctrl_WiFiSetCredentialsReply_size 0 -#define particle_ctrl_WiFiClearCredentialsRequest_size 0 -#define particle_ctrl_WiFiClearCredentialsReply_size 0 -/* particle_ctrl_WiFiAccessPoint_size depends on runtime parameters */ -/* particle_ctrl_WiFiAccessPointList_size depends on runtime parameters */ - -/* Message IDs (where set with "msgid" option) */ -#ifdef PB_MSGID - -#define WIFI_MESSAGES \ - - -#endif #ifdef __cplusplus } /* extern "C" */ #endif -/* @@protoc_insertion_point(eof) */ #endif diff --git a/system/src/control/proto/wifi_new.pb.c b/system/src/control/proto/wifi_new.pb.c index e929570585..96de79d3c3 100644 --- a/system/src/control/proto/wifi_new.pb.c +++ b/system/src/control/proto/wifi_new.pb.c @@ -1,130 +1,62 @@ /* Automatically generated nanopb constant definitions */ -/* Generated by nanopb-0.3.9 at Mon Jun 10 21:00:54 2019. */ +/* Generated by nanopb-0.4.5 */ #include "wifi_new.pb.h" - -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 +#if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif +PB_BIND(particle_ctrl_wifi_Credentials, particle_ctrl_wifi_Credentials, AUTO) + + +PB_BIND(particle_ctrl_wifi_JoinNewNetworkRequest, particle_ctrl_wifi_JoinNewNetworkRequest, AUTO) + + +PB_BIND(particle_ctrl_wifi_JoinNewNetworkReply, particle_ctrl_wifi_JoinNewNetworkReply, AUTO) + + +PB_BIND(particle_ctrl_wifi_JoinKnownNetworkRequest, particle_ctrl_wifi_JoinKnownNetworkRequest, AUTO) + + +PB_BIND(particle_ctrl_wifi_JoinKnownNetworkReply, particle_ctrl_wifi_JoinKnownNetworkReply, AUTO) + + +PB_BIND(particle_ctrl_wifi_GetKnownNetworksRequest, particle_ctrl_wifi_GetKnownNetworksRequest, AUTO) + + +PB_BIND(particle_ctrl_wifi_GetKnownNetworksReply, particle_ctrl_wifi_GetKnownNetworksReply, AUTO) + + +PB_BIND(particle_ctrl_wifi_GetKnownNetworksReply_Network, particle_ctrl_wifi_GetKnownNetworksReply_Network, AUTO) + + +PB_BIND(particle_ctrl_wifi_RemoveKnownNetworkRequest, particle_ctrl_wifi_RemoveKnownNetworkRequest, AUTO) + + +PB_BIND(particle_ctrl_wifi_RemoveKnownNetworkReply, particle_ctrl_wifi_RemoveKnownNetworkReply, AUTO) + + +PB_BIND(particle_ctrl_wifi_ClearKnownNetworksRequest, particle_ctrl_wifi_ClearKnownNetworksRequest, AUTO) + + +PB_BIND(particle_ctrl_wifi_ClearKnownNetworksReply, particle_ctrl_wifi_ClearKnownNetworksReply, AUTO) + + +PB_BIND(particle_ctrl_wifi_GetCurrentNetworkRequest, particle_ctrl_wifi_GetCurrentNetworkRequest, AUTO) + + +PB_BIND(particle_ctrl_wifi_GetCurrentNetworkReply, particle_ctrl_wifi_GetCurrentNetworkReply, AUTO) + + +PB_BIND(particle_ctrl_wifi_ScanNetworksRequest, particle_ctrl_wifi_ScanNetworksRequest, AUTO) + + +PB_BIND(particle_ctrl_wifi_ScanNetworksReply, particle_ctrl_wifi_ScanNetworksReply, AUTO) + + +PB_BIND(particle_ctrl_wifi_ScanNetworksReply_Network, particle_ctrl_wifi_ScanNetworksReply_Network, AUTO) -const pb_field_t particle_ctrl_wifi_Credentials_fields[3] = { - PB_FIELD( 1, UENUM , SINGULAR, STATIC , FIRST, particle_ctrl_wifi_Credentials, type, type, 0), - PB_FIELD( 2, STRING , SINGULAR, CALLBACK, OTHER, particle_ctrl_wifi_Credentials, password, type, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_wifi_JoinNewNetworkRequest_fields[5] = { - PB_FIELD( 1, STRING , SINGULAR, CALLBACK, FIRST, particle_ctrl_wifi_JoinNewNetworkRequest, ssid, ssid, 0), - PB_FIELD( 2, BYTES , SINGULAR, STATIC , OTHER, particle_ctrl_wifi_JoinNewNetworkRequest, bssid, ssid, 0), - PB_FIELD( 3, UENUM , SINGULAR, STATIC , OTHER, particle_ctrl_wifi_JoinNewNetworkRequest, security, bssid, 0), - PB_FIELD( 4, MESSAGE , SINGULAR, STATIC , OTHER, particle_ctrl_wifi_JoinNewNetworkRequest, credentials, security, &particle_ctrl_wifi_Credentials_fields), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_wifi_JoinNewNetworkReply_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_wifi_JoinKnownNetworkRequest_fields[2] = { - PB_FIELD( 1, STRING , SINGULAR, CALLBACK, FIRST, particle_ctrl_wifi_JoinKnownNetworkRequest, ssid, ssid, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_wifi_JoinKnownNetworkReply_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_wifi_GetKnownNetworksRequest_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_wifi_GetKnownNetworksReply_fields[2] = { - PB_FIELD( 1, MESSAGE , REPEATED, CALLBACK, FIRST, particle_ctrl_wifi_GetKnownNetworksReply, networks, networks, &particle_ctrl_wifi_GetKnownNetworksReply_Network_fields), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_wifi_GetKnownNetworksReply_Network_fields[4] = { - PB_FIELD( 1, STRING , SINGULAR, CALLBACK, FIRST, particle_ctrl_wifi_GetKnownNetworksReply_Network, ssid, ssid, 0), - PB_FIELD( 2, UENUM , SINGULAR, STATIC , OTHER, particle_ctrl_wifi_GetKnownNetworksReply_Network, security, ssid, 0), - PB_FIELD( 3, UENUM , SINGULAR, STATIC , OTHER, particle_ctrl_wifi_GetKnownNetworksReply_Network, credentials_type, security, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_wifi_RemoveKnownNetworkRequest_fields[2] = { - PB_FIELD( 1, STRING , SINGULAR, CALLBACK, FIRST, particle_ctrl_wifi_RemoveKnownNetworkRequest, ssid, ssid, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_wifi_RemoveKnownNetworkReply_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_wifi_ClearKnownNetworksRequest_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_wifi_ClearKnownNetworksReply_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_wifi_GetCurrentNetworkRequest_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_wifi_GetCurrentNetworkReply_fields[5] = { - PB_FIELD( 1, STRING , SINGULAR, CALLBACK, FIRST, particle_ctrl_wifi_GetCurrentNetworkReply, ssid, ssid, 0), - PB_FIELD( 2, BYTES , SINGULAR, STATIC , OTHER, particle_ctrl_wifi_GetCurrentNetworkReply, bssid, ssid, 0), - PB_FIELD( 3, INT32 , SINGULAR, STATIC , OTHER, particle_ctrl_wifi_GetCurrentNetworkReply, channel, bssid, 0), - PB_FIELD( 4, INT32 , SINGULAR, STATIC , OTHER, particle_ctrl_wifi_GetCurrentNetworkReply, rssi, channel, 0), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_wifi_ScanNetworksRequest_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_wifi_ScanNetworksReply_fields[2] = { - PB_FIELD( 1, MESSAGE , REPEATED, CALLBACK, FIRST, particle_ctrl_wifi_ScanNetworksReply, networks, networks, &particle_ctrl_wifi_ScanNetworksReply_Network_fields), - PB_LAST_FIELD -}; - -const pb_field_t particle_ctrl_wifi_ScanNetworksReply_Network_fields[6] = { - PB_FIELD( 1, STRING , SINGULAR, CALLBACK, FIRST, particle_ctrl_wifi_ScanNetworksReply_Network, ssid, ssid, 0), - PB_FIELD( 2, BYTES , SINGULAR, STATIC , OTHER, particle_ctrl_wifi_ScanNetworksReply_Network, bssid, ssid, 0), - PB_FIELD( 3, UENUM , SINGULAR, STATIC , OTHER, particle_ctrl_wifi_ScanNetworksReply_Network, security, bssid, 0), - PB_FIELD( 4, INT32 , SINGULAR, STATIC , OTHER, particle_ctrl_wifi_ScanNetworksReply_Network, channel, security, 0), - PB_FIELD( 5, INT32 , SINGULAR, STATIC , OTHER, particle_ctrl_wifi_ScanNetworksReply_Network, rssi, channel, 0), - PB_LAST_FIELD -}; - - - - -/* Check that field information fits in pb_field_t */ -#if !defined(PB_FIELD_32BIT) -/* If you get an error here, it means that you need to define PB_FIELD_32BIT - * compile-time option. You can do that in pb.h or on compiler command line. - * - * The reason you need to do this is that some of your messages contain tag - * numbers or field sizes that are larger than what can fit in 8 or 16 bit - * field descriptors. - */ -PB_STATIC_ASSERT((pb_membersize(particle_ctrl_wifi_JoinNewNetworkRequest, credentials) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_particle_ctrl_wifi_Credentials_particle_ctrl_wifi_JoinNewNetworkRequest_particle_ctrl_wifi_JoinNewNetworkReply_particle_ctrl_wifi_JoinKnownNetworkRequest_particle_ctrl_wifi_JoinKnownNetworkReply_particle_ctrl_wifi_GetKnownNetworksRequest_particle_ctrl_wifi_GetKnownNetworksReply_particle_ctrl_wifi_GetKnownNetworksReply_Network_particle_ctrl_wifi_RemoveKnownNetworkRequest_particle_ctrl_wifi_RemoveKnownNetworkReply_particle_ctrl_wifi_ClearKnownNetworksRequest_particle_ctrl_wifi_ClearKnownNetworksReply_particle_ctrl_wifi_GetCurrentNetworkRequest_particle_ctrl_wifi_GetCurrentNetworkReply_particle_ctrl_wifi_ScanNetworksRequest_particle_ctrl_wifi_ScanNetworksReply_particle_ctrl_wifi_ScanNetworksReply_Network) -#endif -#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT) -/* If you get an error here, it means that you need to define PB_FIELD_16BIT - * compile-time option. You can do that in pb.h or on compiler command line. - * - * The reason you need to do this is that some of your messages contain tag - * numbers or field sizes that are larger than what can fit in the default - * 8 bit descriptors. - */ -PB_STATIC_ASSERT((pb_membersize(particle_ctrl_wifi_JoinNewNetworkRequest, credentials) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_particle_ctrl_wifi_Credentials_particle_ctrl_wifi_JoinNewNetworkRequest_particle_ctrl_wifi_JoinNewNetworkReply_particle_ctrl_wifi_JoinKnownNetworkRequest_particle_ctrl_wifi_JoinKnownNetworkReply_particle_ctrl_wifi_GetKnownNetworksRequest_particle_ctrl_wifi_GetKnownNetworksReply_particle_ctrl_wifi_GetKnownNetworksReply_Network_particle_ctrl_wifi_RemoveKnownNetworkRequest_particle_ctrl_wifi_RemoveKnownNetworkReply_particle_ctrl_wifi_ClearKnownNetworksRequest_particle_ctrl_wifi_ClearKnownNetworksReply_particle_ctrl_wifi_GetCurrentNetworkRequest_particle_ctrl_wifi_GetCurrentNetworkReply_particle_ctrl_wifi_ScanNetworksRequest_particle_ctrl_wifi_ScanNetworksReply_particle_ctrl_wifi_ScanNetworksReply_Network) -#endif -/* @@protoc_insertion_point(eof) */ diff --git a/system/src/control/proto/wifi_new.pb.h b/system/src/control/proto/wifi_new.pb.h index f8856e90d6..b1857bea8e 100644 --- a/system/src/control/proto/wifi_new.pb.h +++ b/system/src/control/proto/wifi_new.pb.h @@ -1,156 +1,170 @@ /* Automatically generated nanopb header */ -/* Generated by nanopb-0.3.9 at Mon Jun 10 21:00:54 2019. */ +/* Generated by nanopb-0.4.5 */ #ifndef PB_PARTICLE_CTRL_WIFI_WIFI_NEW_PB_H_INCLUDED #define PB_PARTICLE_CTRL_WIFI_WIFI_NEW_PB_H_INCLUDED #include - #include "extensions.pb.h" - #include "common.pb.h" -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 +#if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif -#ifdef __cplusplus -extern "C" { -#endif - /* Enum definitions */ -typedef enum _particle_ctrl_wifi_Security { - particle_ctrl_wifi_Security_NO_SECURITY = 0, - particle_ctrl_wifi_Security_WEP = 1, - particle_ctrl_wifi_Security_WPA_PSK = 2, - particle_ctrl_wifi_Security_WPA2_PSK = 3, - particle_ctrl_wifi_Security_WPA_WPA2_PSK = 4 +/* * + WiFi security types. + + Note: The values of this enum should match the values defined by the `WifiSecurity` enum in + the firmware. */ +typedef enum _particle_ctrl_wifi_Security { + particle_ctrl_wifi_Security_NO_SECURITY = 0, /* No security */ + particle_ctrl_wifi_Security_WEP = 1, /* WEP */ + particle_ctrl_wifi_Security_WPA_PSK = 2, /* WPA PSK */ + particle_ctrl_wifi_Security_WPA2_PSK = 3, /* WPA2 PSK */ + particle_ctrl_wifi_Security_WPA_WPA2_PSK = 4 /* WPA/WPA2 PSK */ } particle_ctrl_wifi_Security; -#define _particle_ctrl_wifi_Security_MIN particle_ctrl_wifi_Security_NO_SECURITY -#define _particle_ctrl_wifi_Security_MAX particle_ctrl_wifi_Security_WPA_WPA2_PSK -#define _particle_ctrl_wifi_Security_ARRAYSIZE ((particle_ctrl_wifi_Security)(particle_ctrl_wifi_Security_WPA_WPA2_PSK+1)) -typedef enum _particle_ctrl_wifi_CredentialsType { - particle_ctrl_wifi_CredentialsType_NO_CREDENTIALS = 0, - particle_ctrl_wifi_CredentialsType_PASSWORD = 1 +/* * + Network credential types. + + Note: The values of this enum should match the values defined by the `WiFiCredentials::Type` enum + in the firmware. */ +typedef enum _particle_ctrl_wifi_CredentialsType { + particle_ctrl_wifi_CredentialsType_NO_CREDENTIALS = 0, /* No WiFi credentials */ + particle_ctrl_wifi_CredentialsType_PASSWORD = 1 /* WiFi password */ } particle_ctrl_wifi_CredentialsType; -#define _particle_ctrl_wifi_CredentialsType_MIN particle_ctrl_wifi_CredentialsType_NO_CREDENTIALS -#define _particle_ctrl_wifi_CredentialsType_MAX particle_ctrl_wifi_CredentialsType_PASSWORD -#define _particle_ctrl_wifi_CredentialsType_ARRAYSIZE ((particle_ctrl_wifi_CredentialsType)(particle_ctrl_wifi_CredentialsType_PASSWORD+1)) /* Struct definitions */ -typedef struct _particle_ctrl_wifi_ClearKnownNetworksReply { +/* * + Get the current network. + + This request gets the network which the device is currently connected to. */ +typedef struct _particle_ctrl_wifi_ClearKnownNetworksReply { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_wifi_ClearKnownNetworksReply) */ } particle_ctrl_wifi_ClearKnownNetworksReply; -typedef struct _particle_ctrl_wifi_ClearKnownNetworksRequest { +typedef struct _particle_ctrl_wifi_ClearKnownNetworksRequest { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_wifi_ClearKnownNetworksRequest) */ } particle_ctrl_wifi_ClearKnownNetworksRequest; -typedef struct _particle_ctrl_wifi_GetCurrentNetworkRequest { +typedef struct _particle_ctrl_wifi_GetCurrentNetworkRequest { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_wifi_GetCurrentNetworkRequest) */ } particle_ctrl_wifi_GetCurrentNetworkRequest; -typedef struct _particle_ctrl_wifi_GetKnownNetworksReply { - pb_callback_t networks; -/* @@protoc_insertion_point(struct:particle_ctrl_wifi_GetKnownNetworksReply) */ +typedef struct _particle_ctrl_wifi_GetKnownNetworksReply { + pb_callback_t networks; /* All known networks */ } particle_ctrl_wifi_GetKnownNetworksReply; -typedef struct _particle_ctrl_wifi_GetKnownNetworksRequest { +/* * + Get the list of known networks. */ +typedef struct _particle_ctrl_wifi_GetKnownNetworksRequest { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_wifi_GetKnownNetworksRequest) */ } particle_ctrl_wifi_GetKnownNetworksRequest; -typedef struct _particle_ctrl_wifi_JoinKnownNetworkReply { +typedef struct _particle_ctrl_wifi_JoinKnownNetworkReply { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_wifi_JoinKnownNetworkReply) */ } particle_ctrl_wifi_JoinKnownNetworkReply; -typedef struct _particle_ctrl_wifi_JoinKnownNetworkRequest { - pb_callback_t ssid; -/* @@protoc_insertion_point(struct:particle_ctrl_wifi_JoinKnownNetworkRequest) */ +/* * + Join a known network. */ +typedef struct _particle_ctrl_wifi_JoinKnownNetworkRequest { + pb_callback_t ssid; /* Network SSID */ } particle_ctrl_wifi_JoinKnownNetworkRequest; -typedef struct _particle_ctrl_wifi_JoinNewNetworkReply { +typedef struct _particle_ctrl_wifi_JoinNewNetworkReply { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_wifi_JoinNewNetworkReply) */ } particle_ctrl_wifi_JoinNewNetworkReply; -typedef struct _particle_ctrl_wifi_RemoveKnownNetworkReply { +/* * + Remove all known networks. */ +typedef struct _particle_ctrl_wifi_RemoveKnownNetworkReply { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_wifi_RemoveKnownNetworkReply) */ } particle_ctrl_wifi_RemoveKnownNetworkReply; -typedef struct _particle_ctrl_wifi_RemoveKnownNetworkRequest { - pb_callback_t ssid; -/* @@protoc_insertion_point(struct:particle_ctrl_wifi_RemoveKnownNetworkRequest) */ +typedef struct _particle_ctrl_wifi_RemoveKnownNetworkRequest { + pb_callback_t ssid; } particle_ctrl_wifi_RemoveKnownNetworkRequest; -typedef struct _particle_ctrl_wifi_ScanNetworksReply { - pb_callback_t networks; -/* @@protoc_insertion_point(struct:particle_ctrl_wifi_ScanNetworksReply) */ +typedef struct _particle_ctrl_wifi_ScanNetworksReply { + pb_callback_t networks; } particle_ctrl_wifi_ScanNetworksReply; -typedef struct _particle_ctrl_wifi_ScanNetworksRequest { +typedef struct _particle_ctrl_wifi_ScanNetworksRequest { char dummy_field; -/* @@protoc_insertion_point(struct:particle_ctrl_wifi_ScanNetworksRequest) */ } particle_ctrl_wifi_ScanNetworksRequest; -typedef struct _particle_ctrl_wifi_Credentials { - particle_ctrl_wifi_CredentialsType type; - pb_callback_t password; -/* @@protoc_insertion_point(struct:particle_ctrl_wifi_Credentials) */ +/* * + Network credentials. */ +typedef struct _particle_ctrl_wifi_Credentials { + particle_ctrl_wifi_CredentialsType type; + pb_callback_t password; } particle_ctrl_wifi_Credentials; typedef PB_BYTES_ARRAY_T(6) particle_ctrl_wifi_GetCurrentNetworkReply_bssid_t; -typedef struct _particle_ctrl_wifi_GetCurrentNetworkReply { - pb_callback_t ssid; - particle_ctrl_wifi_GetCurrentNetworkReply_bssid_t bssid; - int32_t channel; - int32_t rssi; -/* @@protoc_insertion_point(struct:particle_ctrl_wifi_GetCurrentNetworkReply) */ +/* * + Scan for networks. */ +typedef struct _particle_ctrl_wifi_GetCurrentNetworkReply { + pb_callback_t ssid; + particle_ctrl_wifi_GetCurrentNetworkReply_bssid_t bssid; + int32_t channel; + int32_t rssi; } particle_ctrl_wifi_GetCurrentNetworkReply; -typedef struct _particle_ctrl_wifi_GetKnownNetworksReply_Network { - pb_callback_t ssid; - particle_ctrl_wifi_Security security; - particle_ctrl_wifi_CredentialsType credentials_type; -/* @@protoc_insertion_point(struct:particle_ctrl_wifi_GetKnownNetworksReply_Network) */ +/* * + Remove the network from the list of known networks. */ +typedef struct _particle_ctrl_wifi_GetKnownNetworksReply_Network { + pb_callback_t ssid; /* Network SSID */ + particle_ctrl_wifi_Security security; + particle_ctrl_wifi_CredentialsType credentials_type; } particle_ctrl_wifi_GetKnownNetworksReply_Network; typedef PB_BYTES_ARRAY_T(6) particle_ctrl_wifi_ScanNetworksReply_Network_bssid_t; -typedef struct _particle_ctrl_wifi_ScanNetworksReply_Network { - pb_callback_t ssid; - particle_ctrl_wifi_ScanNetworksReply_Network_bssid_t bssid; - particle_ctrl_wifi_Security security; - int32_t channel; - int32_t rssi; -/* @@protoc_insertion_point(struct:particle_ctrl_wifi_ScanNetworksReply_Network) */ +typedef struct _particle_ctrl_wifi_ScanNetworksReply_Network { + pb_callback_t ssid; + particle_ctrl_wifi_ScanNetworksReply_Network_bssid_t bssid; + particle_ctrl_wifi_Security security; + int32_t channel; + int32_t rssi; } particle_ctrl_wifi_ScanNetworksReply_Network; typedef PB_BYTES_ARRAY_T(6) particle_ctrl_wifi_JoinNewNetworkRequest_bssid_t; -typedef struct _particle_ctrl_wifi_JoinNewNetworkRequest { - pb_callback_t ssid; - particle_ctrl_wifi_JoinNewNetworkRequest_bssid_t bssid; - particle_ctrl_wifi_Security security; - particle_ctrl_wifi_Credentials credentials; -/* @@protoc_insertion_point(struct:particle_ctrl_wifi_JoinNewNetworkRequest) */ +/* * + Join a new network. + + On success, the network credentials get saved to a persistent storage. */ +typedef struct _particle_ctrl_wifi_JoinNewNetworkRequest { + pb_callback_t ssid; /* Network SSID */ + particle_ctrl_wifi_JoinNewNetworkRequest_bssid_t bssid; /* Network address */ + particle_ctrl_wifi_Security security; /* Network security */ + bool has_credentials; + particle_ctrl_wifi_Credentials credentials; /* Network credentials */ } particle_ctrl_wifi_JoinNewNetworkRequest; -/* Default values for struct fields */ + +/* Helper constants for enums */ +#define _particle_ctrl_wifi_Security_MIN particle_ctrl_wifi_Security_NO_SECURITY +#define _particle_ctrl_wifi_Security_MAX particle_ctrl_wifi_Security_WPA_WPA2_PSK +#define _particle_ctrl_wifi_Security_ARRAYSIZE ((particle_ctrl_wifi_Security)(particle_ctrl_wifi_Security_WPA_WPA2_PSK+1)) + +#define _particle_ctrl_wifi_CredentialsType_MIN particle_ctrl_wifi_CredentialsType_NO_CREDENTIALS +#define _particle_ctrl_wifi_CredentialsType_MAX particle_ctrl_wifi_CredentialsType_PASSWORD +#define _particle_ctrl_wifi_CredentialsType_ARRAYSIZE ((particle_ctrl_wifi_CredentialsType)(particle_ctrl_wifi_CredentialsType_PASSWORD+1)) + + +#ifdef __cplusplus +extern "C" { +#endif /* Initializer values for message structs */ -#define particle_ctrl_wifi_Credentials_init_default {(particle_ctrl_wifi_CredentialsType)0, {{NULL}, NULL}} -#define particle_ctrl_wifi_JoinNewNetworkRequest_init_default {{{NULL}, NULL}, {0, {0}}, (particle_ctrl_wifi_Security)0, particle_ctrl_wifi_Credentials_init_default} +#define particle_ctrl_wifi_Credentials_init_default {_particle_ctrl_wifi_CredentialsType_MIN, {{NULL}, NULL}} +#define particle_ctrl_wifi_JoinNewNetworkRequest_init_default {{{NULL}, NULL}, {0, {0}}, _particle_ctrl_wifi_Security_MIN, false, particle_ctrl_wifi_Credentials_init_default} #define particle_ctrl_wifi_JoinNewNetworkReply_init_default {0} #define particle_ctrl_wifi_JoinKnownNetworkRequest_init_default {{{NULL}, NULL}} #define particle_ctrl_wifi_JoinKnownNetworkReply_init_default {0} #define particle_ctrl_wifi_GetKnownNetworksRequest_init_default {0} #define particle_ctrl_wifi_GetKnownNetworksReply_init_default {{{NULL}, NULL}} -#define particle_ctrl_wifi_GetKnownNetworksReply_Network_init_default {{{NULL}, NULL}, (particle_ctrl_wifi_Security)0, (particle_ctrl_wifi_CredentialsType)0} +#define particle_ctrl_wifi_GetKnownNetworksReply_Network_init_default {{{NULL}, NULL}, _particle_ctrl_wifi_Security_MIN, _particle_ctrl_wifi_CredentialsType_MIN} #define particle_ctrl_wifi_RemoveKnownNetworkRequest_init_default {{{NULL}, NULL}} #define particle_ctrl_wifi_RemoveKnownNetworkReply_init_default {0} #define particle_ctrl_wifi_ClearKnownNetworksRequest_init_default {0} @@ -159,15 +173,15 @@ typedef struct _particle_ctrl_wifi_JoinNewNetworkRequest { #define particle_ctrl_wifi_GetCurrentNetworkReply_init_default {{{NULL}, NULL}, {0, {0}}, 0, 0} #define particle_ctrl_wifi_ScanNetworksRequest_init_default {0} #define particle_ctrl_wifi_ScanNetworksReply_init_default {{{NULL}, NULL}} -#define particle_ctrl_wifi_ScanNetworksReply_Network_init_default {{{NULL}, NULL}, {0, {0}}, (particle_ctrl_wifi_Security)0, 0, 0} -#define particle_ctrl_wifi_Credentials_init_zero {(particle_ctrl_wifi_CredentialsType)0, {{NULL}, NULL}} -#define particle_ctrl_wifi_JoinNewNetworkRequest_init_zero {{{NULL}, NULL}, {0, {0}}, (particle_ctrl_wifi_Security)0, particle_ctrl_wifi_Credentials_init_zero} +#define particle_ctrl_wifi_ScanNetworksReply_Network_init_default {{{NULL}, NULL}, {0, {0}}, _particle_ctrl_wifi_Security_MIN, 0, 0} +#define particle_ctrl_wifi_Credentials_init_zero {_particle_ctrl_wifi_CredentialsType_MIN, {{NULL}, NULL}} +#define particle_ctrl_wifi_JoinNewNetworkRequest_init_zero {{{NULL}, NULL}, {0, {0}}, _particle_ctrl_wifi_Security_MIN, false, particle_ctrl_wifi_Credentials_init_zero} #define particle_ctrl_wifi_JoinNewNetworkReply_init_zero {0} #define particle_ctrl_wifi_JoinKnownNetworkRequest_init_zero {{{NULL}, NULL}} #define particle_ctrl_wifi_JoinKnownNetworkReply_init_zero {0} #define particle_ctrl_wifi_GetKnownNetworksRequest_init_zero {0} #define particle_ctrl_wifi_GetKnownNetworksReply_init_zero {{{NULL}, NULL}} -#define particle_ctrl_wifi_GetKnownNetworksReply_Network_init_zero {{{NULL}, NULL}, (particle_ctrl_wifi_Security)0, (particle_ctrl_wifi_CredentialsType)0} +#define particle_ctrl_wifi_GetKnownNetworksReply_Network_init_zero {{{NULL}, NULL}, _particle_ctrl_wifi_Security_MIN, _particle_ctrl_wifi_CredentialsType_MIN} #define particle_ctrl_wifi_RemoveKnownNetworkRequest_init_zero {{{NULL}, NULL}} #define particle_ctrl_wifi_RemoveKnownNetworkReply_init_zero {0} #define particle_ctrl_wifi_ClearKnownNetworksRequest_init_zero {0} @@ -176,7 +190,7 @@ typedef struct _particle_ctrl_wifi_JoinNewNetworkRequest { #define particle_ctrl_wifi_GetCurrentNetworkReply_init_zero {{{NULL}, NULL}, {0, {0}}, 0, 0} #define particle_ctrl_wifi_ScanNetworksRequest_init_zero {0} #define particle_ctrl_wifi_ScanNetworksReply_init_zero {{{NULL}, NULL}} -#define particle_ctrl_wifi_ScanNetworksReply_Network_init_zero {{{NULL}, NULL}, {0, {0}}, (particle_ctrl_wifi_Security)0, 0, 0} +#define particle_ctrl_wifi_ScanNetworksReply_Network_init_zero {{{NULL}, NULL}, {0, {0}}, _particle_ctrl_wifi_Security_MIN, 0, 0} /* Field tags (for use in manual encoding/decoding) */ #define particle_ctrl_wifi_GetKnownNetworksReply_networks_tag 1 @@ -203,54 +217,165 @@ typedef struct _particle_ctrl_wifi_JoinNewNetworkRequest { #define particle_ctrl_wifi_JoinNewNetworkRequest_credentials_tag 4 /* Struct field encoding specification for nanopb */ -extern const pb_field_t particle_ctrl_wifi_Credentials_fields[3]; -extern const pb_field_t particle_ctrl_wifi_JoinNewNetworkRequest_fields[5]; -extern const pb_field_t particle_ctrl_wifi_JoinNewNetworkReply_fields[1]; -extern const pb_field_t particle_ctrl_wifi_JoinKnownNetworkRequest_fields[2]; -extern const pb_field_t particle_ctrl_wifi_JoinKnownNetworkReply_fields[1]; -extern const pb_field_t particle_ctrl_wifi_GetKnownNetworksRequest_fields[1]; -extern const pb_field_t particle_ctrl_wifi_GetKnownNetworksReply_fields[2]; -extern const pb_field_t particle_ctrl_wifi_GetKnownNetworksReply_Network_fields[4]; -extern const pb_field_t particle_ctrl_wifi_RemoveKnownNetworkRequest_fields[2]; -extern const pb_field_t particle_ctrl_wifi_RemoveKnownNetworkReply_fields[1]; -extern const pb_field_t particle_ctrl_wifi_ClearKnownNetworksRequest_fields[1]; -extern const pb_field_t particle_ctrl_wifi_ClearKnownNetworksReply_fields[1]; -extern const pb_field_t particle_ctrl_wifi_GetCurrentNetworkRequest_fields[1]; -extern const pb_field_t particle_ctrl_wifi_GetCurrentNetworkReply_fields[5]; -extern const pb_field_t particle_ctrl_wifi_ScanNetworksRequest_fields[1]; -extern const pb_field_t particle_ctrl_wifi_ScanNetworksReply_fields[2]; -extern const pb_field_t particle_ctrl_wifi_ScanNetworksReply_Network_fields[6]; +#define particle_ctrl_wifi_Credentials_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, type, 1) \ +X(a, CALLBACK, SINGULAR, STRING, password, 2) +#define particle_ctrl_wifi_Credentials_CALLBACK pb_default_field_callback +#define particle_ctrl_wifi_Credentials_DEFAULT NULL + +#define particle_ctrl_wifi_JoinNewNetworkRequest_FIELDLIST(X, a) \ +X(a, CALLBACK, SINGULAR, STRING, ssid, 1) \ +X(a, STATIC, SINGULAR, BYTES, bssid, 2) \ +X(a, STATIC, SINGULAR, UENUM, security, 3) \ +X(a, STATIC, OPTIONAL, MESSAGE, credentials, 4) +#define particle_ctrl_wifi_JoinNewNetworkRequest_CALLBACK pb_default_field_callback +#define particle_ctrl_wifi_JoinNewNetworkRequest_DEFAULT NULL +#define particle_ctrl_wifi_JoinNewNetworkRequest_credentials_MSGTYPE particle_ctrl_wifi_Credentials + +#define particle_ctrl_wifi_JoinNewNetworkReply_FIELDLIST(X, a) \ + +#define particle_ctrl_wifi_JoinNewNetworkReply_CALLBACK NULL +#define particle_ctrl_wifi_JoinNewNetworkReply_DEFAULT NULL + +#define particle_ctrl_wifi_JoinKnownNetworkRequest_FIELDLIST(X, a) \ +X(a, CALLBACK, SINGULAR, STRING, ssid, 1) +#define particle_ctrl_wifi_JoinKnownNetworkRequest_CALLBACK pb_default_field_callback +#define particle_ctrl_wifi_JoinKnownNetworkRequest_DEFAULT NULL + +#define particle_ctrl_wifi_JoinKnownNetworkReply_FIELDLIST(X, a) \ + +#define particle_ctrl_wifi_JoinKnownNetworkReply_CALLBACK NULL +#define particle_ctrl_wifi_JoinKnownNetworkReply_DEFAULT NULL + +#define particle_ctrl_wifi_GetKnownNetworksRequest_FIELDLIST(X, a) \ + +#define particle_ctrl_wifi_GetKnownNetworksRequest_CALLBACK NULL +#define particle_ctrl_wifi_GetKnownNetworksRequest_DEFAULT NULL + +#define particle_ctrl_wifi_GetKnownNetworksReply_FIELDLIST(X, a) \ +X(a, CALLBACK, REPEATED, MESSAGE, networks, 1) +#define particle_ctrl_wifi_GetKnownNetworksReply_CALLBACK pb_default_field_callback +#define particle_ctrl_wifi_GetKnownNetworksReply_DEFAULT NULL +#define particle_ctrl_wifi_GetKnownNetworksReply_networks_MSGTYPE particle_ctrl_wifi_GetKnownNetworksReply_Network + +#define particle_ctrl_wifi_GetKnownNetworksReply_Network_FIELDLIST(X, a) \ +X(a, CALLBACK, SINGULAR, STRING, ssid, 1) \ +X(a, STATIC, SINGULAR, UENUM, security, 2) \ +X(a, STATIC, SINGULAR, UENUM, credentials_type, 3) +#define particle_ctrl_wifi_GetKnownNetworksReply_Network_CALLBACK pb_default_field_callback +#define particle_ctrl_wifi_GetKnownNetworksReply_Network_DEFAULT NULL + +#define particle_ctrl_wifi_RemoveKnownNetworkRequest_FIELDLIST(X, a) \ +X(a, CALLBACK, SINGULAR, STRING, ssid, 1) +#define particle_ctrl_wifi_RemoveKnownNetworkRequest_CALLBACK pb_default_field_callback +#define particle_ctrl_wifi_RemoveKnownNetworkRequest_DEFAULT NULL + +#define particle_ctrl_wifi_RemoveKnownNetworkReply_FIELDLIST(X, a) \ + +#define particle_ctrl_wifi_RemoveKnownNetworkReply_CALLBACK NULL +#define particle_ctrl_wifi_RemoveKnownNetworkReply_DEFAULT NULL + +#define particle_ctrl_wifi_ClearKnownNetworksRequest_FIELDLIST(X, a) \ + +#define particle_ctrl_wifi_ClearKnownNetworksRequest_CALLBACK NULL +#define particle_ctrl_wifi_ClearKnownNetworksRequest_DEFAULT NULL + +#define particle_ctrl_wifi_ClearKnownNetworksReply_FIELDLIST(X, a) \ + +#define particle_ctrl_wifi_ClearKnownNetworksReply_CALLBACK NULL +#define particle_ctrl_wifi_ClearKnownNetworksReply_DEFAULT NULL + +#define particle_ctrl_wifi_GetCurrentNetworkRequest_FIELDLIST(X, a) \ + +#define particle_ctrl_wifi_GetCurrentNetworkRequest_CALLBACK NULL +#define particle_ctrl_wifi_GetCurrentNetworkRequest_DEFAULT NULL + +#define particle_ctrl_wifi_GetCurrentNetworkReply_FIELDLIST(X, a) \ +X(a, CALLBACK, SINGULAR, STRING, ssid, 1) \ +X(a, STATIC, SINGULAR, BYTES, bssid, 2) \ +X(a, STATIC, SINGULAR, INT32, channel, 3) \ +X(a, STATIC, SINGULAR, INT32, rssi, 4) +#define particle_ctrl_wifi_GetCurrentNetworkReply_CALLBACK pb_default_field_callback +#define particle_ctrl_wifi_GetCurrentNetworkReply_DEFAULT NULL + +#define particle_ctrl_wifi_ScanNetworksRequest_FIELDLIST(X, a) \ + +#define particle_ctrl_wifi_ScanNetworksRequest_CALLBACK NULL +#define particle_ctrl_wifi_ScanNetworksRequest_DEFAULT NULL + +#define particle_ctrl_wifi_ScanNetworksReply_FIELDLIST(X, a) \ +X(a, CALLBACK, REPEATED, MESSAGE, networks, 1) +#define particle_ctrl_wifi_ScanNetworksReply_CALLBACK pb_default_field_callback +#define particle_ctrl_wifi_ScanNetworksReply_DEFAULT NULL +#define particle_ctrl_wifi_ScanNetworksReply_networks_MSGTYPE particle_ctrl_wifi_ScanNetworksReply_Network + +#define particle_ctrl_wifi_ScanNetworksReply_Network_FIELDLIST(X, a) \ +X(a, CALLBACK, SINGULAR, STRING, ssid, 1) \ +X(a, STATIC, SINGULAR, BYTES, bssid, 2) \ +X(a, STATIC, SINGULAR, UENUM, security, 3) \ +X(a, STATIC, SINGULAR, INT32, channel, 4) \ +X(a, STATIC, SINGULAR, INT32, rssi, 5) +#define particle_ctrl_wifi_ScanNetworksReply_Network_CALLBACK pb_default_field_callback +#define particle_ctrl_wifi_ScanNetworksReply_Network_DEFAULT NULL + +extern const pb_msgdesc_t particle_ctrl_wifi_Credentials_msg; +extern const pb_msgdesc_t particle_ctrl_wifi_JoinNewNetworkRequest_msg; +extern const pb_msgdesc_t particle_ctrl_wifi_JoinNewNetworkReply_msg; +extern const pb_msgdesc_t particle_ctrl_wifi_JoinKnownNetworkRequest_msg; +extern const pb_msgdesc_t particle_ctrl_wifi_JoinKnownNetworkReply_msg; +extern const pb_msgdesc_t particle_ctrl_wifi_GetKnownNetworksRequest_msg; +extern const pb_msgdesc_t particle_ctrl_wifi_GetKnownNetworksReply_msg; +extern const pb_msgdesc_t particle_ctrl_wifi_GetKnownNetworksReply_Network_msg; +extern const pb_msgdesc_t particle_ctrl_wifi_RemoveKnownNetworkRequest_msg; +extern const pb_msgdesc_t particle_ctrl_wifi_RemoveKnownNetworkReply_msg; +extern const pb_msgdesc_t particle_ctrl_wifi_ClearKnownNetworksRequest_msg; +extern const pb_msgdesc_t particle_ctrl_wifi_ClearKnownNetworksReply_msg; +extern const pb_msgdesc_t particle_ctrl_wifi_GetCurrentNetworkRequest_msg; +extern const pb_msgdesc_t particle_ctrl_wifi_GetCurrentNetworkReply_msg; +extern const pb_msgdesc_t particle_ctrl_wifi_ScanNetworksRequest_msg; +extern const pb_msgdesc_t particle_ctrl_wifi_ScanNetworksReply_msg; +extern const pb_msgdesc_t particle_ctrl_wifi_ScanNetworksReply_Network_msg; + +/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ +#define particle_ctrl_wifi_Credentials_fields &particle_ctrl_wifi_Credentials_msg +#define particle_ctrl_wifi_JoinNewNetworkRequest_fields &particle_ctrl_wifi_JoinNewNetworkRequest_msg +#define particle_ctrl_wifi_JoinNewNetworkReply_fields &particle_ctrl_wifi_JoinNewNetworkReply_msg +#define particle_ctrl_wifi_JoinKnownNetworkRequest_fields &particle_ctrl_wifi_JoinKnownNetworkRequest_msg +#define particle_ctrl_wifi_JoinKnownNetworkReply_fields &particle_ctrl_wifi_JoinKnownNetworkReply_msg +#define particle_ctrl_wifi_GetKnownNetworksRequest_fields &particle_ctrl_wifi_GetKnownNetworksRequest_msg +#define particle_ctrl_wifi_GetKnownNetworksReply_fields &particle_ctrl_wifi_GetKnownNetworksReply_msg +#define particle_ctrl_wifi_GetKnownNetworksReply_Network_fields &particle_ctrl_wifi_GetKnownNetworksReply_Network_msg +#define particle_ctrl_wifi_RemoveKnownNetworkRequest_fields &particle_ctrl_wifi_RemoveKnownNetworkRequest_msg +#define particle_ctrl_wifi_RemoveKnownNetworkReply_fields &particle_ctrl_wifi_RemoveKnownNetworkReply_msg +#define particle_ctrl_wifi_ClearKnownNetworksRequest_fields &particle_ctrl_wifi_ClearKnownNetworksRequest_msg +#define particle_ctrl_wifi_ClearKnownNetworksReply_fields &particle_ctrl_wifi_ClearKnownNetworksReply_msg +#define particle_ctrl_wifi_GetCurrentNetworkRequest_fields &particle_ctrl_wifi_GetCurrentNetworkRequest_msg +#define particle_ctrl_wifi_GetCurrentNetworkReply_fields &particle_ctrl_wifi_GetCurrentNetworkReply_msg +#define particle_ctrl_wifi_ScanNetworksRequest_fields &particle_ctrl_wifi_ScanNetworksRequest_msg +#define particle_ctrl_wifi_ScanNetworksReply_fields &particle_ctrl_wifi_ScanNetworksReply_msg +#define particle_ctrl_wifi_ScanNetworksReply_Network_fields &particle_ctrl_wifi_ScanNetworksReply_Network_msg /* Maximum encoded size of messages (where known) */ /* particle_ctrl_wifi_Credentials_size depends on runtime parameters */ /* particle_ctrl_wifi_JoinNewNetworkRequest_size depends on runtime parameters */ -#define particle_ctrl_wifi_JoinNewNetworkReply_size 0 /* particle_ctrl_wifi_JoinKnownNetworkRequest_size depends on runtime parameters */ -#define particle_ctrl_wifi_JoinKnownNetworkReply_size 0 -#define particle_ctrl_wifi_GetKnownNetworksRequest_size 0 /* particle_ctrl_wifi_GetKnownNetworksReply_size depends on runtime parameters */ /* particle_ctrl_wifi_GetKnownNetworksReply_Network_size depends on runtime parameters */ /* particle_ctrl_wifi_RemoveKnownNetworkRequest_size depends on runtime parameters */ -#define particle_ctrl_wifi_RemoveKnownNetworkReply_size 0 -#define particle_ctrl_wifi_ClearKnownNetworksRequest_size 0 -#define particle_ctrl_wifi_ClearKnownNetworksReply_size 0 -#define particle_ctrl_wifi_GetCurrentNetworkRequest_size 0 /* particle_ctrl_wifi_GetCurrentNetworkReply_size depends on runtime parameters */ -#define particle_ctrl_wifi_ScanNetworksRequest_size 0 /* particle_ctrl_wifi_ScanNetworksReply_size depends on runtime parameters */ /* particle_ctrl_wifi_ScanNetworksReply_Network_size depends on runtime parameters */ - -/* Message IDs (where set with "msgid" option) */ -#ifdef PB_MSGID - -#define WIFI_NEW_MESSAGES \ - - -#endif +#define particle_ctrl_wifi_ClearKnownNetworksReply_size 0 +#define particle_ctrl_wifi_ClearKnownNetworksRequest_size 0 +#define particle_ctrl_wifi_GetCurrentNetworkRequest_size 0 +#define particle_ctrl_wifi_GetKnownNetworksRequest_size 0 +#define particle_ctrl_wifi_JoinKnownNetworkReply_size 0 +#define particle_ctrl_wifi_JoinNewNetworkReply_size 0 +#define particle_ctrl_wifi_RemoveKnownNetworkReply_size 0 +#define particle_ctrl_wifi_ScanNetworksRequest_size 0 #ifdef __cplusplus } /* extern "C" */ #endif -/* @@protoc_insertion_point(eof) */ #endif From 1dd312bb290f31d7961cbd1ae30fa2fd529c62b1 Mon Sep 17 00:00:00 2001 From: keeramis Date: Mon, 24 Oct 2022 19:33:28 -0500 Subject: [PATCH 025/112] Prevent trackerM from connecting on wifi interface with SCAN_ONLY flag enabled --- system/src/system_network_manager.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/system/src/system_network_manager.cpp b/system/src/system_network_manager.cpp index 4e83819a19..9cac8bcffe 100644 --- a/system/src/system_network_manager.cpp +++ b/system/src/system_network_manager.cpp @@ -725,10 +725,14 @@ bool NetworkManager::haveLowerLayerConfiguration(if_t iface) const { if_get_name(iface, name); #if HAL_PLATFORM_WIFI && HAL_PLATFORM_NCP if (!strncmp(name, "wl", 2)) { +#if HAL_PLATFORM_WIFI_SCAN_ONLY + return false; +#else auto wifiMan = wifiNetworkManager(); return wifiMan->hasNetworkConfig(); +#endif // HAL_PLATFORM_WIFI_SCAN_ONLY } -#endif // HAL_PLATFORM_WIFI +#endif // HAL_PLATFORM_WIFI && HAL_PLATFORM_NCP return true; } From 411e53ae21f34d2cd25cec5eb5b4ec2b8aae5b4c Mon Sep 17 00:00:00 2001 From: Andrey Tolstoy Date: Sat, 29 Oct 2022 08:28:03 +0700 Subject: [PATCH 026/112] [rtl872x] prebootloader: enable BOR with lowest available thresholds --- .../src/rtl872x/part1/rtl_support.c | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/bootloader/prebootloader/src/rtl872x/part1/rtl_support.c b/bootloader/prebootloader/src/rtl872x/part1/rtl_support.c index c4911ed2b4..c48aa95c25 100644 --- a/bootloader/prebootloader/src/rtl872x/part1/rtl_support.c +++ b/bootloader/prebootloader/src/rtl872x/part1/rtl_support.c @@ -18,8 +18,14 @@ #include "ameba_soc.h" #include "rtl_support.h" #include "rtl8721d_system.h" +#include "rtl8721d_bor.h" +#include "rtl8721d.h" +#include + +extern CPU_PWR_SEQ HSPWR_OFF_SEQ[]; uint32_t tickless_debug = 0; +static volatile bool km4_powered_on = false; /* The binary data of generated ram_retention.bin should copy into retention_ram_patch_array. Then fill in the patch size at the second dword */ @@ -289,6 +295,14 @@ static uint32_t app_mpu_nocache_init(void) { return 0; } +void bodIrqHandler() { + // Brown-out - reset + if (km4_powered_on) { + BOOT_ROM_CM4PON((u32)HSPWR_OFF_SEQ); + } + NVIC_SystemReset(); +} + // Copy-paste from BOOT_FLASH_Image1() void rtlLowLevelInit() { /*Get Chip Version*/ @@ -301,6 +315,15 @@ void rtlLowLevelInit() { } HAL_WRITE32(SYSTEM_CTRL_BASE_LP, REG_AON_BOOT_REASON1, temp); + // Use BOD interrupt as tresholds are much higher compared to reset mode + BOR_ClearINT(); + InterruptRegister((IRQ_FUN)bodIrqHandler, BOR2_IRQ_LP, 0, 0); + InterruptEn(BOR2_IRQ_LP, 0); + BOR_ThresholdSet(BOR_TH_LOW7, BOR_TH_HIGH7); + BOR_ModeSet(BOR_INTR, ENABLE); + // XXX: Does this work? Enable BOD reset as well + BOR_ModeSet(BOR_RESET, ENABLE); + boot_ram_function_enable(); /* loguart use 40MHz */ @@ -450,6 +473,7 @@ void rtlPowerOnBigCore() { HAL_WRITE32(SYSTEM_CTRL_BASE_LP, REG_LP_KM0_CTRL, (km0_system_control & (~BIT_LSYS_PLFM_FLASH_SCE))); } + km4_powered_on = true; km4_boot_on(); } From 82407a4089e493d212468550e5e6663bea49e844 Mon Sep 17 00:00:00 2001 From: Scott Brust Date: Wed, 2 Nov 2022 10:37:09 -0700 Subject: [PATCH 027/112] Fix i2c hal deadlock on trackerm --- hal/src/nRF52840/i2c_hal.cpp | 4 ++-- hal/src/rtl872x/i2c_hal.cpp | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/hal/src/nRF52840/i2c_hal.cpp b/hal/src/nRF52840/i2c_hal.cpp index 4e6f76b884..c883db1df2 100644 --- a/hal/src/nRF52840/i2c_hal.cpp +++ b/hal/src/nRF52840/i2c_hal.cpp @@ -315,9 +315,9 @@ int hal_i2c_init(hal_i2c_interface_t i2c, const hal_i2c_config_t* config) { os_mutex_recursive_create(&i2cMap[i2c].mutex); } - // Capture the mutex and re-enable threading - I2cLock lk(i2c); + // Re-enable threading and capture the mutex os_thread_scheduling(true, nullptr); + I2cLock lk(i2c); if (i2cMap[i2c].configured) { // Configured, but new buffers are invalid diff --git a/hal/src/rtl872x/i2c_hal.cpp b/hal/src/rtl872x/i2c_hal.cpp index 5dceb37129..1733aca0f2 100644 --- a/hal/src/rtl872x/i2c_hal.cpp +++ b/hal/src/rtl872x/i2c_hal.cpp @@ -91,16 +91,18 @@ class I2cClass { if (!mutex_) { os_mutex_recursive_create(&mutex_); } - lock(); os_thread_scheduling(true, nullptr); + lock(); if (isConfigured()) { // Configured, but new buffers are invalid if (!isConfigValid(conf)){ + unlock(); return SYSTEM_ERROR_INVALID_ARGUMENT; } // Configured, but new buffers are smaller if (conf->rx_buffer_size <= rxBuffer_.size() || conf->tx_buffer_size <= txBuffer_.size()) { + unlock(); return SYSTEM_ERROR_NOT_ENOUGH_DATA; } CHECK(deInit()); From 5713cbff2eb7c5ddf6d8f65a79bb2cb3dcaa413c Mon Sep 17 00:00:00 2001 From: Andrey Tolstoy Date: Thu, 3 Nov 2022 21:54:00 +0700 Subject: [PATCH 028/112] [cellular] sara: add SIM card initialization workarounds / refactor CFUN management --- .../ncp/cellular/cellular_ncp_client.h | 14 ++ .../ncp_client/sara/sara_ncp_client.cpp | 167 ++++++++++-------- hal/network/ncp_client/sara/sara_ncp_client.h | 4 +- 3 files changed, 108 insertions(+), 77 deletions(-) diff --git a/hal/network/ncp/cellular/cellular_ncp_client.h b/hal/network/ncp/cellular/cellular_ncp_client.h index fba676fdbd..67fa977616 100644 --- a/hal/network/ncp/cellular/cellular_ncp_client.h +++ b/hal/network/ncp/cellular/cellular_ncp_client.h @@ -21,6 +21,7 @@ #include "cellular_network_manager.h" #include "cellular_hal_cellular_global_identity.h" #include "timer_hal.h" +#include "underlying_type.h" namespace particle { @@ -80,6 +81,19 @@ enum class CellularAccessTechnology { LTE_NB_IOT = 9 }; +enum class CellularFunctionality { + NONE = -1, + MINIMUM = 0, + FULL = 1, + AIRPLANE = 4, + FAST_SHUTDOWN = 10, + RESET_NO_SIM = 15, + RESET_WITH_SIM = 16, + MINIMUM_NO_SIM = 19, +}; + +PARTICLE_DEFINE_ENUM_COMPARISON_OPERATORS(CellularFunctionality); + enum class CellularStrengthUnits { NONE = 0, RXLEV = 1, diff --git a/hal/network/ncp_client/sara/sara_ncp_client.cpp b/hal/network/ncp_client/sara/sara_ncp_client.cpp index a3c67e3835..4f4ca1d80e 100644 --- a/hal/network/ncp_client/sara/sara_ncp_client.cpp +++ b/hal/network/ncp_client/sara/sara_ncp_client.cpp @@ -143,6 +143,9 @@ const int UUFWINSTALL_COMPLETE = 128; const int UBLOX_WAIT_AT_RESPONSE_WHILE_UUFWINSTALL_TIMEOUT = 300000; const int UBLOX_WAIT_AT_RESPONSE_WHILE_UUFWINSTALL_PERIOD = 10000; +const unsigned CHECK_SIM_CARD_INTERVAL = 1000; +const unsigned CHECK_SIM_CARD_ATTEMPTS = 10; + } // anonymous SaraNcpClient::SaraNcpClient() { @@ -459,9 +462,7 @@ int SaraNcpClient::disconnect() { return SYSTEM_ERROR_NONE; } CHECK(checkParser()); - // NOTE: R510 does not like the explicit CFUN=0,0 (x,0 is default, and we are intending on the default 0,0 but leaving as 0 for maximum compatibility) - const int r = CHECK_PARSER(parser_.execCommand(UBLOX_CFUN_TIMEOUT, "AT+CFUN=0")); - (void)r; + CHECK_PARSER(setModuleFunctionality(CellularFunctionality::MINIMUM)); // CHECK_TRUE(r == AtResponse::OK, SYSTEM_ERROR_AT_NOT_OK); resetRegistrationState(); @@ -602,22 +603,18 @@ int SaraNcpClient::getIccid(char* buf, size_t size) { CHECK(checkParser()); // ICCID command errors if CFUN is 0. Run CFUN=4 before reading ICCID. - auto respCfun = parser_.sendCommand(UBLOX_CFUN_TIMEOUT, "AT+CFUN?"); int cfunVal = -1; - auto retCfun = CHECK_PARSER(respCfun.scanf("+CFUN: %d", &cfunVal)); - CHECK_PARSER_OK(respCfun.readResult()); - if (retCfun == 1 && cfunVal == 0) { - // Intending on the default 4,0 but leaving as 4 for maximum compatibility - CHECK_PARSER_OK(parser_.execCommand(UBLOX_CFUN_TIMEOUT, "AT+CFUN=4")); + cfunVal = getModuleFunctionality(); + if (cfunVal == CellularFunctionality::MINIMUM) { + CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::AIRPLANE)); } auto res = getIccidImpl(buf, size); // Modify CFUN back to 0 if it was changed previously, // as CFUN:0 is needed to prevent long reg problems on certain SIMs - if (cfunVal == 0) { - // NOTE: R510 does not like the explicit CFUN=0,0 (x,0 is default, and we are intending on the default 0,0 but leaving as 0 for maximum compatibility) - CHECK_PARSER_OK(parser_.execCommand(UBLOX_CFUN_TIMEOUT, "AT+CFUN=0")); + if (cfunVal == CellularFunctionality::MINIMUM) { + CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::MINIMUM)); } return res; @@ -1150,14 +1147,7 @@ int SaraNcpClient::selectNetworkProf(ModemState& state) { } // Disconnect before making changes to the UMNOPROF - auto respCfun = parser_.sendCommand(UBLOX_CFUN_TIMEOUT, "AT+CFUN?"); - int cfunVal = -1; - auto retCfun = CHECK_PARSER(respCfun.scanf("+CFUN: %d", &cfunVal)); - CHECK_PARSER_OK(respCfun.readResult()); - if (retCfun == 1 && cfunVal != 0) { - // NOTE: R510 does not like the explicit CFUN=0,0 (x,0 is default, and we are intending on the default 0,0 but leaving as 0 for maximum compatibility) - CHECK_PARSER_OK(parser_.execCommand(UBLOX_CFUN_TIMEOUT, "AT+CFUN=0")); - } + CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::MINIMUM, true /* check */)); // This is a persistent setting parser_.execCommand(1000, "AT+UMNOPROF=%d", newProf); // Not checking for error since we will reset either way @@ -1184,9 +1174,9 @@ int SaraNcpClient::selectNetworkProf(ModemState& state) { } if (reset) { if (ncpId() == PLATFORM_NCP_SARA_R410) { - CHECK_PARSER_OK(parser_.execCommand(UBLOX_CFUN_TIMEOUT, "AT+CFUN=15")); + CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::RESET_NO_SIM)); } else if (ncpId() == PLATFORM_NCP_SARA_R510) { - CHECK_PARSER_OK(parser_.execCommand(UBLOX_CFUN_TIMEOUT, "AT+CFUN=16")); + CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::RESET_WITH_SIM)); } HAL_Delay_Milliseconds(2000); @@ -1303,18 +1293,15 @@ int SaraNcpClient::selectSimCard(ModemState& state) { if (reset) { if (ncpId() == PLATFORM_NCP_SARA_R410) { // R410 - const int r = CHECK_PARSER(parser_.execCommand(UBLOX_CFUN_TIMEOUT, "AT+CFUN=15")); - CHECK_TRUE(r == AtResponse::OK, SYSTEM_ERROR_AT_NOT_OK); + CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::RESET_NO_SIM)); HAL_Delay_Milliseconds(10000); } else if (ncpId() == PLATFORM_NCP_SARA_R510) { // R510 - const int r = CHECK_PARSER(parser_.execCommand(UBLOX_CFUN_TIMEOUT, "AT+CFUN=16")); - CHECK_TRUE(r == AtResponse::OK, SYSTEM_ERROR_AT_NOT_OK); + CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::RESET_WITH_SIM)); HAL_Delay_Milliseconds(10000); } else { // U201 - const int r = CHECK_PARSER(parser_.execCommand(UBLOX_CFUN_TIMEOUT, "AT+CFUN=16,0")); - CHECK_TRUE(r == AtResponse::OK, SYSTEM_ERROR_AT_NOT_OK); + CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::RESET_WITH_SIM)); HAL_Delay_Milliseconds(1000); } @@ -1737,18 +1724,32 @@ int SaraNcpClient::startNcpFwUpdate(bool update) { return SYSTEM_ERROR_NONE; } -int SaraNcpClient::checkSimCard() { - auto resp = parser_.sendCommand("AT+CPIN?"); - char code[33] = {}; - int r = CHECK_PARSER(resp.scanf("+CPIN: %32[^\n]", code)); - CHECK_TRUE(r == 1, SYSTEM_ERROR_AT_RESPONSE_UNEXPECTED); - r = CHECK_PARSER(resp.readResult()); - CHECK_TRUE(r == AtResponse::OK, SYSTEM_ERROR_AT_NOT_OK); - if (!strcmp(code, "READY")) { - CHECK_PARSER_OK(parser_.execCommand("AT+CCID")); - return SYSTEM_ERROR_NONE; +int SaraNcpClient::checkSimCard(bool* failure) { + auto check = [this]() -> int { + auto resp = parser_.sendCommand("AT+CPIN?"); + char code[33] = {}; + int r = CHECK_PARSER(resp.scanf("+CPIN: %32[^\n]", code)); + CHECK_TRUE(r == 1, SYSTEM_ERROR_AT_RESPONSE_UNEXPECTED); + r = CHECK_PARSER(resp.readResult()); + CHECK_TRUE(r == AtResponse::OK, SYSTEM_ERROR_AT_NOT_OK); + if (!strcmp(code, "READY")) { + CHECK_PARSER_OK(parser_.execCommand("AT+CCID")); + return SYSTEM_ERROR_NONE; + } + return SYSTEM_ERROR_UNKNOWN; + }; + + for (unsigned i = 0; i < CHECK_SIM_CARD_ATTEMPTS; i++) { + if (!check()) { + // OK + return 0; + } + if (failure) { + *failure = true; + } + HAL_Delay_Milliseconds(CHECK_SIM_CARD_INTERVAL); } - return SYSTEM_ERROR_UNKNOWN; + return SYSTEM_ERROR_INVALID_STATE; } int SaraNcpClient::checkSimReadiness(bool checkForRfReset) { @@ -1756,39 +1757,64 @@ int SaraNcpClient::checkSimReadiness(bool checkForRfReset) { // int r = CHECK_PARSER(parser_.execCommand("AT+CMEE=2")); // CHECK_TRUE(r == AtResponse::OK, SYSTEM_ERROR_AT_NOT_OK); - int simState = 0; - unsigned attempts = 0; - for (attempts = 0; attempts < 10; attempts++) { - simState = checkSimCard(); - if (!simState) { - break; - } - HAL_Delay_Milliseconds(1000); - } + bool encounteredFailure = false; + int r = checkSimCard(&encounteredFailure); - if (checkForRfReset && attempts != 0 && ncpId() == PLATFORM_NCP_SARA_R410) { + if (checkForRfReset && encounteredFailure && ncpId() == PLATFORM_NCP_SARA_R410) { // There was an error initializing the SIM // This often leads to inability to talk over the data (PPP) muxed channel // for some reason. Attempt to cycle the modem through minimal/full functional state. // We only do this for R4-based devices, as U2-based modems seem to fail // to change baudrate later on for some reason - CHECK_PARSER_OK(parser_.execCommand(UBLOX_CFUN_TIMEOUT, "AT+CFUN=0,0")); - CHECK_PARSER_OK(parser_.execCommand(UBLOX_CFUN_TIMEOUT, "AT+CFUN=1,0")); + CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::MINIMUM)); + CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::FULL)); } - return (simState == 0 ? SYSTEM_ERROR_NONE : simState); + return r; +} + +int SaraNcpClient::getModuleFunctionality() { + auto resp = parser_.sendCommand(UBLOX_CFUN_TIMEOUT, "AT+CFUN?"); + int curVal = -1; + auto r = resp.scanf("+CFUN: %d", &curVal); + CHECK_PARSER_OK(resp.readResult()); + CHECK_TRUE(r == 1, SYSTEM_ERROR_AT_RESPONSE_UNEXPECTED); + return curVal; +} + +int SaraNcpClient::setModuleFunctionality(CellularFunctionality cfun, bool check) { + if (check) { + if (cfun == CHECK(getModuleFunctionality())) { + // Already in required state + return 0; + } + } + + int r = SYSTEM_ERROR_UNKNOWN; + + if (ncpId() == PLATFORM_NCP_SARA_R510 || + (ncpId() == PLATFORM_NCP_SARA_R410 && cfun >= CellularFunctionality::AIRPLANE)) { + // NOTE: R510 does not like the explicit CFUN=0,0 (x,0 is default, and we are intending on the default 0,0 but leaving as 0 for maximum compatibility) + r = parser_.execCommand(UBLOX_CFUN_TIMEOUT, "AT+CFUN=%d", (int)cfun); + } else { + r = parser_.execCommand(UBLOX_CFUN_TIMEOUT, "AT+CFUN=%d,0", (int)cfun); + } + + CHECK_PARSER(r); + + if (!r && ncpId() == PLATFORM_NCP_SARA_R410 && (cfun == CellularFunctionality::FULL || cfun == CellularFunctionality::AIRPLANE)) { + // When switching to full-functionality mode on R410-based devices check the SIM card readiness + // otherwise some other AT commands unrelated to SIM card will fail with CME ERROR e.g. SIM failure + CHECK(checkSimCard()); + } + // AtResponse::Result! + return r; } int SaraNcpClient::configureApn(const CellularNetworkConfig& conf) { // IMPORTANT: Set modem full functionality! // Otherwise we won't be able to query ICCID/IMSI - auto respCfun = parser_.sendCommand(UBLOX_CFUN_TIMEOUT, "AT+CFUN?"); - int cfunVal = -1; - auto rcfun = respCfun.scanf("+CFUN: %d", &cfunVal); - CHECK_PARSER_OK(respCfun.readResult()); - if (rcfun && cfunVal != 1) { - CHECK_PARSER_OK(parser_.execCommand(UBLOX_CFUN_TIMEOUT, "AT+CFUN=1,0")); - } + CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::FULL, true /* check */)); netConf_ = conf; if (!netConf_.isValid()) { @@ -1844,10 +1870,7 @@ int SaraNcpClient::configureApn(const CellularNetworkConfig& conf) { // setApn, cgdcontIpVal, cgdcontApnVal, cgdcontFmt, netConf_.hasApn(), // netConf_.apn(), strncmp(cgdcontApnVal, netConf_.hasApn() ? netConf_.apn() : "", sizeof(cgdcontApnVal)) != 0); if (setApn) { - if (ncpId() == PLATFORM_NCP_SARA_R510) { // CH76421 - // Intending on the default 4,0 but leaving as 4 for maximum compatibility - CHECK_PARSER_OK(parser_.execCommand(UBLOX_CFUN_TIMEOUT, "AT+CFUN=4")); - } + CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::AIRPLANE)); auto resp = parser_.sendCommand("AT+CGDCONT=%d,\"%s\",\"%s%s\"", UBLOX_DEFAULT_CID, UBLOX_DEFAULT_PDP_TYPE, (netConf_.hasUser() && netConf_.hasPassword()) ? "CHAP:" : "", @@ -1868,13 +1891,7 @@ int SaraNcpClient::registerNet() { int r = 0; // Set modem full functionality - auto respCfun = parser_.sendCommand(UBLOX_CFUN_TIMEOUT, "AT+CFUN?"); - int cfunVal = -1; - auto rCfun = respCfun.scanf("+CFUN: %d", &cfunVal); - CHECK_PARSER_OK(respCfun.readResult()); - if (rCfun && cfunVal != 1) { - CHECK_PARSER_OK(parser_.execCommand(UBLOX_CFUN_TIMEOUT, "AT+CFUN=1,0")); - } + CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::FULL, true /* check */)); resetRegistrationState(); @@ -2211,9 +2228,8 @@ int SaraNcpClient::interveneRegistration() { csd_.reset(); psd_.reset(); registrationInterventions_++; - // NOTE: R510 does not like the explicit CFUN=0,0 (x,0 is default, and we are intending on the default 0,0 but leaving as 0 for maximum compatibility) - CHECK_PARSER_OK(parser_.execCommand(UBLOX_CFUN_TIMEOUT, "AT+CFUN=0")); - CHECK_PARSER_OK(parser_.execCommand(UBLOX_CFUN_TIMEOUT, "AT+CFUN=1,0")); + CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::MINIMUM)); + CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::FULL)); return 0; } } @@ -2244,9 +2260,8 @@ int SaraNcpClient::interveneRegistration() { LOG(TRACE, "Sticky EPS denied state for %lu s, RF reset", eps_.duration() / 1000); eps_.reset(); registrationInterventions_++; - // NOTE: R510 does not like the explicit CFUN=0,0 (x,0 is default, and we are intending on the default 0,0 but leaving as 0 for maximum compatibility) - CHECK_PARSER_OK(parser_.execCommand(UBLOX_CFUN_TIMEOUT, "AT+CFUN=0")); - CHECK_PARSER_OK(parser_.execCommand(UBLOX_CFUN_TIMEOUT, "AT+CFUN=1,0")); + CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::MINIMUM)); + CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::FULL)); } } } diff --git a/hal/network/ncp_client/sara/sara_ncp_client.h b/hal/network/ncp_client/sara/sara_ncp_client.h index bb61e594bb..606d898eb0 100644 --- a/hal/network/ncp_client/sara/sara_ncp_client.h +++ b/hal/network/ncp_client/sara/sara_ncp_client.h @@ -135,7 +135,7 @@ class SaraNcpClient: public CellularNcpClient { int waitAtResponse(AtParser& parser, unsigned int timeout, unsigned int period = 1000); int selectSimCard(ModemState& state); int selectNetworkProf(ModemState& state); - int checkSimCard(); + int checkSimCard(bool* failure = nullptr); int configureApn(const CellularNetworkConfig& conf); int registerNet(); int changeBaudRate(unsigned int baud); @@ -167,6 +167,8 @@ class SaraNcpClient: public CellularNcpClient { int waitAtResponseFromPowerOn(ModemState& modemState); int disablePsmEdrx(); int checkSimReadiness(bool checkForRfReset = false); + int setModuleFunctionality(CellularFunctionality cfun, bool check = false); + int getModuleFunctionality(); }; inline AtParser* SaraNcpClient::atParser() { From 55031beb0cf29b039d9c2479d5f0cb46d7ce4782 Mon Sep 17 00:00:00 2001 From: keeramis Date: Thu, 3 Nov 2022 12:30:18 -0500 Subject: [PATCH 029/112] Add IFC query checks to check sim readiness --- hal/network/ncp_client/sara/sara_ncp_client.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hal/network/ncp_client/sara/sara_ncp_client.cpp b/hal/network/ncp_client/sara/sara_ncp_client.cpp index 4f4ca1d80e..43da82275d 100644 --- a/hal/network/ncp_client/sara/sara_ncp_client.cpp +++ b/hal/network/ncp_client/sara/sara_ncp_client.cpp @@ -1734,6 +1734,9 @@ int SaraNcpClient::checkSimCard(bool* failure) { CHECK_TRUE(r == AtResponse::OK, SYSTEM_ERROR_AT_NOT_OK); if (!strcmp(code, "READY")) { CHECK_PARSER_OK(parser_.execCommand("AT+CCID")); + // IFC checks are generally unrelated to the SIM. However, there is a + // known issue with u-blox R410 that fails IFC command with `+CME ERROR: SIM failure` + CHECK_PARSER_OK(parser_.execCommand("AT+IFC?")); return SYSTEM_ERROR_NONE; } return SYSTEM_ERROR_UNKNOWN; From 1cf79c39f9aefebbf9037b1e97cf830b8c1c4e05 Mon Sep 17 00:00:00 2001 From: Andrey Tolstoy Date: Fri, 4 Nov 2022 01:34:27 +0700 Subject: [PATCH 030/112] minor --- hal/network/ncp_client/sara/sara_ncp_client.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hal/network/ncp_client/sara/sara_ncp_client.cpp b/hal/network/ncp_client/sara/sara_ncp_client.cpp index 43da82275d..e252258d37 100644 --- a/hal/network/ncp_client/sara/sara_ncp_client.cpp +++ b/hal/network/ncp_client/sara/sara_ncp_client.cpp @@ -1735,7 +1735,8 @@ int SaraNcpClient::checkSimCard(bool* failure) { if (!strcmp(code, "READY")) { CHECK_PARSER_OK(parser_.execCommand("AT+CCID")); // IFC checks are generally unrelated to the SIM. However, there is a - // known issue with u-blox R410 that fails IFC command with `+CME ERROR: SIM failure` + // known issue with u-blox R410 that fails IFC and potentially some other + // commands with `+CME ERROR: SIM failure` CHECK_PARSER_OK(parser_.execCommand("AT+IFC?")); return SYSTEM_ERROR_NONE; } From 628d2e73d1919b84ec8c7a0b76391cc79f493c81 Mon Sep 17 00:00:00 2001 From: Andrey Tolstoy Date: Wed, 2 Nov 2022 06:51:45 +0700 Subject: [PATCH 031/112] [boron / b som] hal: adds a workaround for R410 PPP session 'crash' in network phase --- hal/network/lwip/cellular/pppncpnetif.cpp | 59 ++++++++++++++++++- hal/network/lwip/cellular/pppncpnetif.h | 4 +- hal/network/lwip/ppp_client.cpp | 48 +++++++++++---- hal/network/lwip/ppp_client.h | 27 ++++++++- .../ncp/cellular/cellular_ncp_client.h | 1 + .../ncp_client/quectel/quectel_ncp_client.cpp | 4 ++ .../ncp_client/quectel/quectel_ncp_client.h | 1 + .../ncp_client/sara/sara_ncp_client.cpp | 27 +++++++++ hal/network/ncp_client/sara/sara_ncp_client.h | 1 + hal/src/nRF52840/lwip/lwip_logging.h | 4 -- hal/src/nRF52840/lwip/lwipopts.h | 2 - hal/src/nRF52840/lwip/lwippppopts.h | 13 ++-- services/inc/system_error.h | 15 ++++- third_party/lwip/lwip | 2 +- 14 files changed, 175 insertions(+), 33 deletions(-) diff --git a/hal/network/lwip/cellular/pppncpnetif.cpp b/hal/network/lwip/cellular/pppncpnetif.cpp index 39f03b1af2..1c9b525f9e 100644 --- a/hal/network/lwip/cellular/pppncpnetif.cpp +++ b/hal/network/lwip/cellular/pppncpnetif.cpp @@ -48,6 +48,56 @@ namespace { // 5 minutes const unsigned PPP_CONNECT_TIMEOUT = 5 * 60 * 1000; +int pppErrorToSystem(int err) { + using namespace particle::net::ppp; + switch(err) { + case Client::ERROR_NONE: { + return SYSTEM_ERROR_NONE; + } + case Client::ERROR_PARAM: { + return SYSTEM_ERROR_PPP_PARAM; + } + case Client::ERROR_OPEN: { + return SYSTEM_ERROR_PPP_OPEN; + } + case Client::ERROR_DEVICE: { + return SYSTEM_ERROR_PPP_DEVICE; + } + case Client::ERROR_ALLOC: { + return SYSTEM_ERROR_PPP_ALLOC; + } + case Client::ERROR_USER: { + return SYSTEM_ERROR_PPP_USER; + } + case Client::ERROR_CONNECT: { + return SYSTEM_ERROR_PPP_CONNECT; + } + case Client::ERROR_AUTHFAIL: { + return SYSTEM_ERROR_PPP_AUTH_FAIL; + } + case Client::ERROR_PROTOCOL: { + return SYSTEM_ERROR_PPP_PROTOCOL; + } + case Client::ERROR_PEERDEAD: { + return SYSTEM_ERROR_PPP_PEER_DEAD; + } + case Client::ERROR_IDLETIMEOUT: { + return SYSTEM_ERROR_PPP_IDLE_TIMEOUT; + } + case Client::ERROR_CONNECTTIME: { + return SYSTEM_ERROR_PPP_CONNECT_TIME; + } + case Client::ERROR_LOOPBACK: { + return SYSTEM_ERROR_PPP_LOOPBACK; + } + case Client::ERROR_NO_CARRIER_IN_NETWORK_PHASE: { + return SYSTEM_ERROR_PPP_NO_CARRIER_IN_NETWORK_PHASE; + } + } + + return SYSTEM_ERROR_UNKNOWN; +} + } // anonymous @@ -311,12 +361,12 @@ void PppNcpNetif::netifEventHandler(netif_nsc_reason_t reason, const netif_ext_c /* Nothing to do here */ } -void PppNcpNetif::pppEventHandlerCb(particle::net::ppp::Client* c, uint64_t ev, void* ctx) { +void PppNcpNetif::pppEventHandlerCb(particle::net::ppp::Client* c, uint64_t ev, int data, void* ctx) { auto self = (PppNcpNetif*)ctx; - self->pppEventHandler(ev); + self->pppEventHandler(ev, data); } -void PppNcpNetif::pppEventHandler(uint64_t ev) { +void PppNcpNetif::pppEventHandler(uint64_t ev, int data) { if (ev == particle::net::ppp::Client::EVENT_UP) { unsigned mtu = client_.getIf()->mtu; LOG(TRACE, "Negotiated MTU: %u", mtu); @@ -331,6 +381,9 @@ void PppNcpNetif::pppEventHandler(uint64_t ev) { if (connectStart_ == 0) { connectStart_ = HAL_Timer_Get_Milli_Seconds(); } + } else if (ev == particle::net::ppp::Client::EVENT_ERROR) { + LOG(ERROR, "PPP error event data=%d", data); + celMan_->ncpClient()->dataModeError(pppErrorToSystem(data)); } } diff --git a/hal/network/lwip/cellular/pppncpnetif.h b/hal/network/lwip/cellular/pppncpnetif.h index de5aaf4058..84c78fe886 100644 --- a/hal/network/lwip/cellular/pppncpnetif.h +++ b/hal/network/lwip/cellular/pppncpnetif.h @@ -77,8 +77,8 @@ class PppNcpNetif : public BaseNetif { static void loop(void* arg); - static void pppEventHandlerCb(particle::net::ppp::Client* c, uint64_t ev, void* ctx); - void pppEventHandler(uint64_t ev); + static void pppEventHandlerCb(particle::net::ppp::Client* c, uint64_t ev, int data, void* ctx); + void pppEventHandler(uint64_t ev, int data); static void mempEventHandler(memp_t type, unsigned available, unsigned size, void* ctx); diff --git a/hal/network/lwip/ppp_client.cpp b/hal/network/lwip/ppp_client.cpp index d28f74eb84..32b89a7420 100644 --- a/hal/network/lwip/ppp_client.cpp +++ b/hal/network/lwip/ppp_client.cpp @@ -109,7 +109,7 @@ void Client::init() { pppapi_set_notify_phase_callback(pcb_, &Client::notifyPhaseCb); - os_queue_create(&queue_, sizeof(uint64_t), 5, nullptr); + os_queue_create(&queue_, sizeof(QueueEvent), 5, nullptr); SPARK_ASSERT(queue_); os_thread_create(&thread_, "ppp", OS_THREAD_PRIORITY_NETWORK, &Client::loopCb, this, OS_THREAD_STACK_SIZE_DEFAULT_HIGH); @@ -199,11 +199,14 @@ bool Client::configure(void* config) { return true; } -bool Client::notifyEvent(uint64_t ev) { +bool Client::notifyEvent(uint64_t ev, int data) { if (!running_) { return false; } - return os_queue_put(queue_, &ev, CONCURRENT_WAIT_FOREVER, nullptr) == 0; + QueueEvent event = {}; + event.ev = ev; + event.data = data; + return os_queue_put(queue_, &event, CONCURRENT_WAIT_FOREVER, nullptr) == 0; } int Client::input(const uint8_t* data, size_t size) { @@ -213,6 +216,18 @@ int Client::input(const uint8_t* data, size_t size) { case STATE_DISCONNECTING: case STATE_CONNECTED: { LOG_DEBUG(TRACE, "RX: %lu", size); + + if (platform_primary_ncp_identifier() == PLATFORM_NCP_SARA_R410) { + auto pppos = (pppos_pcb*)pcb_->link_ctx_cb; + const char NO_CARRIER[] = "\r\nNO CARRIER\r\n"; + if (pppos && pppos->in_state == PDADDRESS && pcb_->phase == PPP_PHASE_NETWORK && data[0] != PPP_FLAG && size >= sizeof(NO_CARRIER) - 1 && !strncmp((const char*)data, NO_CARRIER, size)) { + LOG(ERROR, "NO CARRIER in network PPP phase"); + notifyEvent(EVENT_ERROR, ERROR_NO_CARRIER_IN_NETWORK_PHASE); + pppapi_close(pcb_, 1); + break; + } + } + #if !PPP_INPROC_IRQ_SAFE err_t err = pppos_input_tcpip(pcb_, (u8_t*)data, size); #else @@ -321,7 +336,7 @@ void Client::loop() { } err_t err = pppapi_connect(pcb_, 0); if (err != ERR_OK) { - LOG(TRACE, "PPP error connecting: %x", err); + LOG(TRACE, "PPP error connecting: %d", err); transition(STATE_CONNECT); } break; @@ -361,11 +376,11 @@ void Client::loop() { } } - uint64_t ev = 0; + QueueEvent ev = {}; if (os_queue_take(queue_, &ev, qWait, nullptr) == 0) { - LOG(TRACE, "PPP thread event %s", eventNames_[ev]); + LOG(TRACE, "PPP thread event %s data=%d", eventNames_[ev.ev], ev.data); /* Incoming event */ - switch (ev) { + switch (ev.ev) { case EVENT_LOWER_UP: { if (!lowerState_) { lowerState_ = true; @@ -427,6 +442,16 @@ void Client::loop() { } break; } + case EVENT_ERROR: { + std::unique_lock lk(mutex_); + auto cb = cb_; + auto ctx = cbCtx_; + lk.unlock(); + if (cb) { + cb(this, EVENT_ERROR, ev.data, ctx); + } + break; + } } } } @@ -464,7 +489,9 @@ void Client::notifyPhaseCb(ppp_pcb* pcb, uint8_t phase, void* ctx) { } void Client::notifyPhase(uint8_t phase) { +#if !PPP_DEBUG LOG(TRACE, "PPP phase -> %d", phase); +#endif // !PPP_DEBUG } void Client::notifyStatusCb(ppp_pcb* pcb, int err, void* ctx) { @@ -484,6 +511,7 @@ void Client::notifyStatus(int err) { } default: { /* Error connecting */ + notifyEvent(EVENT_ERROR, err); notifyEvent(EVENT_DOWN); break; } @@ -518,11 +546,11 @@ void Client::transition(State newState) { lk.unlock(); if (cb) { if (state_ == STATE_CONNECTED) { - cb(this, EVENT_UP, ctx); + cb(this, EVENT_UP, ERROR_NONE, ctx); } else if (state_ == STATE_DISCONNECTED) { - cb(this, EVENT_DOWN, ctx); + cb(this, EVENT_DOWN, ERROR_NONE, ctx); } else if (state_ == STATE_CONNECTING) { - cb(this, EVENT_CONNECTING, ctx); + cb(this, EVENT_CONNECTING, ERROR_NONE, ctx); } } } diff --git a/hal/network/lwip/ppp_client.h b/hal/network/lwip/ppp_client.h index dc7c65d269..d3793345ad 100644 --- a/hal/network/lwip/ppp_client.h +++ b/hal/network/lwip/ppp_client.h @@ -65,6 +65,23 @@ class Client { EVENT_MAX = 0x09 }; + enum Error { + ERROR_NONE = PPPERR_NONE, + ERROR_PARAM = PPPERR_PARAM, + ERROR_OPEN = PPPERR_OPEN, + ERROR_DEVICE = PPPERR_DEVICE, + ERROR_ALLOC = PPPERR_ALLOC, + ERROR_USER = PPPERR_USER, + ERROR_CONNECT = PPPERR_CONNECT, + ERROR_AUTHFAIL = PPPERR_AUTHFAIL, + ERROR_PROTOCOL = PPPERR_PROTOCOL, + ERROR_PEERDEAD = PPPERR_PEERDEAD, + ERROR_IDLETIMEOUT = PPPERR_IDLETIMEOUT, + ERROR_CONNECTTIME = PPPERR_CONNECTTIME, + ERROR_LOOPBACK = PPPERR_LOOPBACK, + ERROR_NO_CARRIER_IN_NETWORK_PHASE = 100 + }; + enum State { STATE_NONE = 0, STATE_READY = 1, @@ -77,7 +94,7 @@ class Client { STATE_MAX = 8 }; - bool notifyEvent(uint64_t ev); + bool notifyEvent(uint64_t ev, int data = ERROR_NONE); int input(const uint8_t* data, size_t size); typedef int (*OutputCallback)(const uint8_t* data, size_t size, void* ctx); @@ -85,7 +102,7 @@ class Client { void setOutputCallback(OutputCallback cb, void* ctx); void setEnterDataModeCallback(EnterDataModeCallback, void* ctx); - typedef void (*NotifyCallback)(Client* c, uint64_t ev, void* ctx); + typedef void (*NotifyCallback)(Client* c, uint64_t ev, int data, void* ctx); void setNotifyCallback(NotifyCallback cb, void* ctx); @@ -142,6 +159,12 @@ class Client { void transition(State newState); private: + + struct QueueEvent { + uint64_t ev; + int data; + }; + netif if_ = {}; ppp_pcb* pcb_ = nullptr; #if PPP_IPCP_OVERRIDE diff --git a/hal/network/ncp/cellular/cellular_ncp_client.h b/hal/network/ncp/cellular/cellular_ncp_client.h index 67fa977616..e191eaace3 100644 --- a/hal/network/ncp/cellular/cellular_ncp_client.h +++ b/hal/network/ncp/cellular/cellular_ncp_client.h @@ -147,6 +147,7 @@ class CellularNcpClient: public NcpClient { virtual int getMtu() = 0; virtual int urcs(bool enable) = 0; virtual int startNcpFwUpdate(bool update) = 0; + virtual int dataModeError(int error) = 0; }; inline CellularNcpClientConfig::CellularNcpClientConfig() : diff --git a/hal/network/ncp_client/quectel/quectel_ncp_client.cpp b/hal/network/ncp_client/quectel/quectel_ncp_client.cpp index bc6b568da3..670e127e07 100644 --- a/hal/network/ncp_client/quectel/quectel_ncp_client.cpp +++ b/hal/network/ncp_client/quectel/quectel_ncp_client.cpp @@ -1573,6 +1573,10 @@ int QuectelNcpClient::enterDataMode() { return r; } +int QuectelNcpClient::dataModeError(int error) { + return 0; +} + int QuectelNcpClient::getMtu() { return 0; } diff --git a/hal/network/ncp_client/quectel/quectel_ncp_client.h b/hal/network/ncp_client/quectel/quectel_ncp_client.h index 811329e8c4..cdd23e8733 100644 --- a/hal/network/ncp_client/quectel/quectel_ncp_client.h +++ b/hal/network/ncp_client/quectel/quectel_ncp_client.h @@ -74,6 +74,7 @@ class QuectelNcpClient: public CellularNcpClient { virtual int getMtu() override; virtual int urcs(bool enable) override; virtual int startNcpFwUpdate(bool update) override; + virtual int dataModeError(int error) override; auto getMuxer() { return &muxer_; diff --git a/hal/network/ncp_client/sara/sara_ncp_client.cpp b/hal/network/ncp_client/sara/sara_ncp_client.cpp index e252258d37..8d93da666f 100644 --- a/hal/network/ncp_client/sara/sara_ncp_client.cpp +++ b/hal/network/ncp_client/sara/sara_ncp_client.cpp @@ -1498,6 +1498,20 @@ int SaraNcpClient::initReady(ModemState state) { // Enable packet domain error reporting CHECK_PARSER_OK(parser_.execCommand("AT+CGEREP=1,0")); + // Disable LWM2M + // NOTE: this command hangs in muxed mode for some reason + if ((ncpId() == PLATFORM_NCP_SARA_R410 || ncpId() == PLATFORM_NCP_SARA_R510) + && state != ModemState::MuxerAtChannel) { + auto resp = parser_.sendCommand("AT+ULWM2M?"); + int lwm2m = -1; + r = resp.scanf("+ULWM2M: %d", &lwm2m); + CHECK_PARSER(resp.readResult()); + if (lwm2m == 0) { + // Enabled -> disable + CHECK_PARSER(parser_.execCommand(("AT+ULWM2M=1"))); + } + } + if (ncpId() == PLATFORM_NCP_SARA_R410 || ncpId() == PLATFORM_NCP_SARA_R510) { // Force Cat M1-only mode // We may encounter a CME ERROR response with u-blox firmware 05.08,A.02.04 and in that case Cat-M1 mode is @@ -2079,6 +2093,19 @@ int SaraNcpClient::enterDataMode() { return r; } +int SaraNcpClient::dataModeError(int error) { + if (ncpId() == PLATFORM_NCP_SARA_R410 && error == SYSTEM_ERROR_PPP_NO_CARRIER_IN_NETWORK_PHASE) { + CHECK_TRUE(connectionState() == NcpConnectionState::CONNECTED, SYSTEM_ERROR_INVALID_STATE); + // FIXME: this is a workaround for some R410 firmware versions where the PPP session suddenly dies + // in network phase after the first IPCP ConfReq. For some reason CGATT=0/1 helps. + const NcpClientLock lock(this); + CHECK_PARSER_OK(parser_.execCommand(3 * 60 * 1000, "AT+CGATT=0")); + HAL_Delay_Milliseconds(1000); + CHECK_PARSER_OK(parser_.execCommand(3 * 60 * 1000, "AT+CGATT=1")); + } + return 0; +} + int SaraNcpClient::getMtu() { if (ncpId() == PLATFORM_NCP_SARA_R410 && fwVersion_ <= UBLOX_NCP_R4_APP_FW_VERSION_NO_HW_FLOW_CONTROL_MAX) { return UBLOX_NCP_R4_NO_HW_FLOW_CONTROL_MTU; diff --git a/hal/network/ncp_client/sara/sara_ncp_client.h b/hal/network/ncp_client/sara/sara_ncp_client.h index 606d898eb0..334e736b20 100644 --- a/hal/network/ncp_client/sara/sara_ncp_client.h +++ b/hal/network/ncp_client/sara/sara_ncp_client.h @@ -74,6 +74,7 @@ class SaraNcpClient: public CellularNcpClient { virtual int getMtu() override; virtual int urcs(bool enable) override; virtual int startNcpFwUpdate(bool update) override; + virtual int dataModeError(int error) override; private: AtParser parser_; diff --git a/hal/src/nRF52840/lwip/lwip_logging.h b/hal/src/nRF52840/lwip/lwip_logging.h index 7f955cbba1..95c1d06179 100644 --- a/hal/src/nRF52840/lwip/lwip_logging.h +++ b/hal/src/nRF52840/lwip/lwip_logging.h @@ -28,10 +28,6 @@ void lwip_log_message(const char *fmt, ...); } #endif /* __cplusplus */ -#ifdef DEBUG_BUILD #define LWIP_PLATFORM_DIAG(x) do { lwip_log_message x; } while(0) -#else -#define LWIP_PLATFORM_DIAG(x) -#endif /* DEBUG_BUILD */ #endif /* HAL_LWIP_LOGGING_H */ diff --git a/hal/src/nRF52840/lwip/lwipopts.h b/hal/src/nRF52840/lwip/lwipopts.h index 1c93d696f9..fd75432e6d 100644 --- a/hal/src/nRF52840/lwip/lwipopts.h +++ b/hal/src/nRF52840/lwip/lwipopts.h @@ -1865,9 +1865,7 @@ void sys_unlock_tcpip_core(void); --------------------------------------- */ -#ifdef DEBUG_BUILD #define LWIP_DEBUG 1 -#endif // DEBUG_BUILD /** * LWIP_DBG_MIN_LEVEL: After masking, the value of the debug is diff --git a/hal/src/nRF52840/lwip/lwippppopts.h b/hal/src/nRF52840/lwip/lwippppopts.h index bbc2b3b8d4..9d996691d0 100644 --- a/hal/src/nRF52840/lwip/lwippppopts.h +++ b/hal/src/nRF52840/lwip/lwippppopts.h @@ -99,11 +99,12 @@ /** * PPP_DEBUG: Enable debugging for PPP. */ -#ifdef DEBUG_BUILD #define PPP_DEBUG LWIP_DBG_ON -#else -#define PPP_DEBUG LWIP_DBG_OFF -#endif // DEBUG_BUILD + +/** + * PPPOS_DEBUG: Enable debugging for PPPoS. + */ +#define PPPOS_DEBUG LWIP_DBG_OFF /** * PPP_INPROC_IRQ_SAFE==1 call pppos_input() using tcpip_callback(). @@ -117,11 +118,7 @@ * * Mandatory for debugging, it displays exchanged packet content in debug trace. */ -#ifndef DEBUG_BUILD -#define PRINTPKT_SUPPORT 0 -#else #define PRINTPKT_SUPPORT 1 -#endif // DEBUG_BUILD /** * PPP_IPV4_SUPPORT==1: Enable PPP IPv4 support diff --git a/services/inc/system_error.h b/services/inc/system_error.h index 5c0f8a39d3..db7f1a796d 100644 --- a/services/inc/system_error.h +++ b/services/inc/system_error.h @@ -74,7 +74,20 @@ (I2C_FILL_DATA_TIMEOUT, "Fill data timeout", -1603), \ (I2C_TX_DATA_TIMEOUT, "Send data timeout", -1604), \ (I2C_STOP_TIMEOUT, "Send stop timeout", -1605), \ - (I2C_ABORT, "I2C transmission abort", -1606) + (I2C_ABORT, "I2C transmission abort", -1606), \ + (PPP_PARAM, "Invalid parameter", -1700), /* -1799 ... -1700: PPP errors */ \ + (PPP_OPEN, "Unable to open PPP session", -1701), \ + (PPP_DEVICE, "Invalid I/O device for PPP", -1702), \ + (PPP_ALLOC, "Unable to allocate resources", -1703), \ + (PPP_USER, "User interrupt", -1704), \ + (PPP_CONNECT, "Connection lost", -1705), \ + (PPP_AUTH_FAIL, "Failed authentication challenge", -1706), \ + (PPP_PROTOCOL, "Failed to meet protocol", -1707), \ + (PPP_PEER_DEAD, "Connection timeout", -1708), \ + (PPP_IDLE_TIMEOUT, "Idle timeout", -1709), \ + (PPP_CONNECT_TIME, "Max connect time reached", -1710), \ + (PPP_LOOPBACK, "Loopback detected", -1711), \ + (PPP_NO_CARRIER_IN_NETWORK_PHASE, "Received NO CARRIER in network phase", -1712) // Expands to enum values for all errors #define SYSTEM_ERROR_ENUM_VALUES(prefix) \ diff --git a/third_party/lwip/lwip b/third_party/lwip/lwip index 8837180def..b8901aabff 160000 --- a/third_party/lwip/lwip +++ b/third_party/lwip/lwip @@ -1 +1 @@ -Subproject commit 8837180def0fea7e71e6e8311e3e71eeb01886f7 +Subproject commit b8901aabff7f3da808bcb5cbfffdcc2dac823e18 From 65f3dc53694a13420b76e3a1286e98ad7b2e678a Mon Sep 17 00:00:00 2001 From: Andrey Tolstoy Date: Wed, 2 Nov 2022 07:23:41 +0700 Subject: [PATCH 032/112] minor workaround for AT+ULWMW2M --- hal/network/ncp_client/sara/sara_ncp_client.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hal/network/ncp_client/sara/sara_ncp_client.cpp b/hal/network/ncp_client/sara/sara_ncp_client.cpp index 8d93da666f..cfc3d9beb0 100644 --- a/hal/network/ncp_client/sara/sara_ncp_client.cpp +++ b/hal/network/ncp_client/sara/sara_ncp_client.cpp @@ -1500,12 +1500,12 @@ int SaraNcpClient::initReady(ModemState state) { // Disable LWM2M // NOTE: this command hangs in muxed mode for some reason - if ((ncpId() == PLATFORM_NCP_SARA_R410 || ncpId() == PLATFORM_NCP_SARA_R510) + if ((ncpId() == PLATFORM_NCP_SARA_R410) && state != ModemState::MuxerAtChannel) { auto resp = parser_.sendCommand("AT+ULWM2M?"); int lwm2m = -1; r = resp.scanf("+ULWM2M: %d", &lwm2m); - CHECK_PARSER(resp.readResult()); + resp.readResult(); if (lwm2m == 0) { // Enabled -> disable CHECK_PARSER(parser_.execCommand(("AT+ULWM2M=1"))); From 2fc530a2224cd7ae3a1fd532e3e076e5161a88ed Mon Sep 17 00:00:00 2001 From: Andrey Tolstoy Date: Wed, 2 Nov 2022 07:24:58 +0700 Subject: [PATCH 033/112] minor --- hal/network/ncp_client/sara/sara_ncp_client.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hal/network/ncp_client/sara/sara_ncp_client.cpp b/hal/network/ncp_client/sara/sara_ncp_client.cpp index cfc3d9beb0..f8377c2b2d 100644 --- a/hal/network/ncp_client/sara/sara_ncp_client.cpp +++ b/hal/network/ncp_client/sara/sara_ncp_client.cpp @@ -1500,8 +1500,7 @@ int SaraNcpClient::initReady(ModemState state) { // Disable LWM2M // NOTE: this command hangs in muxed mode for some reason - if ((ncpId() == PLATFORM_NCP_SARA_R410) - && state != ModemState::MuxerAtChannel) { + if (ncpId() == PLATFORM_NCP_SARA_R410 && state != ModemState::MuxerAtChannel) { auto resp = parser_.sendCommand("AT+ULWM2M?"); int lwm2m = -1; r = resp.scanf("+ULWM2M: %d", &lwm2m); From 32553e95e38113fd4f2ab93f4475e1778cfb79e5 Mon Sep 17 00:00:00 2001 From: Andrey Tolstoy Date: Wed, 2 Nov 2022 08:39:21 +0700 Subject: [PATCH 034/112] [gen3] enable PPP packet logs --- hal/network/lwip/ppp_client.cpp | 19 ++++++++++++++-- hal/src/nRF52840/lwip/lwip_logging.cpp | 30 ++++++++++++++++++++++++++ hal/src/nRF52840/lwip/lwipopts.h | 2 +- hal/src/nRF52840/lwip/lwippppopts.h | 2 +- third_party/lwip/lwip | 2 +- 5 files changed, 50 insertions(+), 5 deletions(-) diff --git a/hal/network/lwip/ppp_client.cpp b/hal/network/lwip/ppp_client.cpp index 32b89a7420..6bb6424fd1 100644 --- a/hal/network/lwip/ppp_client.cpp +++ b/hal/network/lwip/ppp_client.cpp @@ -52,6 +52,21 @@ int Client::netifClientDataIdx_ = -1; constexpr const char* Client::eventNames_[]; constexpr const char* Client::stateNames_[]; +namespace { + +#if !PPP_DEBUG +const char* pppPhaseToString(uint8_t phase) { + const char* phases[] = { + "Dead", "Master", "Holdoff", "Initialize", "SerialConn", + "Dormant", "Establish", "Authenticate", "Callback", "Network", + "Running", "Terminate", "Disconnect", "Unknown" + }; + return phases[std::min(phase, sizeof(phases) / sizeof(phases[0]) - 1)]; +} +#endif // !PPP_DEBUG + +} // anonymous + Client::Client() { std::call_once(once_, []() { LOCK_TCPIP_CORE(); @@ -222,8 +237,8 @@ int Client::input(const uint8_t* data, size_t size) { const char NO_CARRIER[] = "\r\nNO CARRIER\r\n"; if (pppos && pppos->in_state == PDADDRESS && pcb_->phase == PPP_PHASE_NETWORK && data[0] != PPP_FLAG && size >= sizeof(NO_CARRIER) - 1 && !strncmp((const char*)data, NO_CARRIER, size)) { LOG(ERROR, "NO CARRIER in network PPP phase"); - notifyEvent(EVENT_ERROR, ERROR_NO_CARRIER_IN_NETWORK_PHASE); pppapi_close(pcb_, 1); + notifyEvent(EVENT_ERROR, ERROR_NO_CARRIER_IN_NETWORK_PHASE); break; } } @@ -490,7 +505,7 @@ void Client::notifyPhaseCb(ppp_pcb* pcb, uint8_t phase, void* ctx) { void Client::notifyPhase(uint8_t phase) { #if !PPP_DEBUG - LOG(TRACE, "PPP phase -> %d", phase); + LOG(TRACE, "PPP phase -> %s", pppPhaseToString(phase)); #endif // !PPP_DEBUG } diff --git a/hal/src/nRF52840/lwip/lwip_logging.cpp b/hal/src/nRF52840/lwip/lwip_logging.cpp index 53bf3a9f45..8f0ff3f9e1 100644 --- a/hal/src/nRF52840/lwip/lwip_logging.cpp +++ b/hal/src/nRF52840/lwip/lwip_logging.cpp @@ -15,9 +15,23 @@ * License along with this library; if not, see . */ +#undef LOG_COMPILE_TIME_LEVEL +#define LOG_COMPILE_TIME_LEVEL LOG_LEVEL_ALL + #include "lwip_logging.h" #include #include "logging.h" +#include "lwipopts.h" + +#if defined(PPP_SUPPORT) && PPP_SUPPORT +#ifndef PPPDEBUG_H +/* we do not want this header, as it redefines our LOG_XXX macros */ +#define PPPDEBUG_H +#endif /* PPPDEBUG_H */ +extern "C" { +#include +} +#endif // defined(PPP_SUPPORT) && PPP_SUPPORT uint32_t g_lwip_debug_flags = 0xffffffff; @@ -33,3 +47,19 @@ void lwip_log_message(const char* fmt, ...) { log_message_v(1, "lwip", &attr, nullptr /* reserved */, tmp, args); va_end(args); } + +void ppp_dbglog(const char *fmt, ...) { + // Only enable PPP negotiation packet logs + if (strstr(fmt, "%P") == nullptr) { + return; + } + + va_list args; + + va_start(args, fmt); + char tmp[LOG_MAX_STRING_LENGTH] = {}; + ppp_vslprintf(tmp, sizeof(tmp) - 1, fmt, args); + va_end(args); + tmp[strcspn(tmp, "\r\n")] = 0; + LOG(TRACE, "%s", tmp); +} diff --git a/hal/src/nRF52840/lwip/lwipopts.h b/hal/src/nRF52840/lwip/lwipopts.h index fd75432e6d..1271392be3 100644 --- a/hal/src/nRF52840/lwip/lwipopts.h +++ b/hal/src/nRF52840/lwip/lwipopts.h @@ -1865,7 +1865,7 @@ void sys_unlock_tcpip_core(void); --------------------------------------- */ -#define LWIP_DEBUG 1 +#define LWIP_DEBUG 0 /** * LWIP_DBG_MIN_LEVEL: After masking, the value of the debug is diff --git a/hal/src/nRF52840/lwip/lwippppopts.h b/hal/src/nRF52840/lwip/lwippppopts.h index 9d996691d0..8be5e66dd9 100644 --- a/hal/src/nRF52840/lwip/lwippppopts.h +++ b/hal/src/nRF52840/lwip/lwippppopts.h @@ -99,7 +99,7 @@ /** * PPP_DEBUG: Enable debugging for PPP. */ -#define PPP_DEBUG LWIP_DBG_ON +#define PPP_DEBUG LWIP_DBG_OFF /** * PPPOS_DEBUG: Enable debugging for PPPoS. diff --git a/third_party/lwip/lwip b/third_party/lwip/lwip index b8901aabff..a0a74c79f2 160000 --- a/third_party/lwip/lwip +++ b/third_party/lwip/lwip @@ -1 +1 @@ -Subproject commit b8901aabff7f3da808bcb5cbfffdcc2dac823e18 +Subproject commit a0a74c79f27a484d05daf4db9a94ad279a23e0c7 From 5d220d27a0cb2c906b331f05e83549d2b2c13dc0 Mon Sep 17 00:00:00 2001 From: Andrey Tolstoy Date: Tue, 8 Nov 2022 21:10:04 +0700 Subject: [PATCH 035/112] [boron / bsom] lwm2m/fota stuff --- .../ncp_client/sara/sara_ncp_client.cpp | 120 ++++++++++++------ hal/network/ncp_client/sara/sara_ncp_client.h | 12 ++ 2 files changed, 96 insertions(+), 36 deletions(-) diff --git a/hal/network/ncp_client/sara/sara_ncp_client.cpp b/hal/network/ncp_client/sara/sara_ncp_client.cpp index f8377c2b2d..fd4c55c610 100644 --- a/hal/network/ncp_client/sara/sara_ncp_client.cpp +++ b/hal/network/ncp_client/sara/sara_ncp_client.cpp @@ -1173,13 +1173,7 @@ int SaraNcpClient::selectNetworkProf(ModemState& state) { } } if (reset) { - if (ncpId() == PLATFORM_NCP_SARA_R410) { - CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::RESET_NO_SIM)); - } else if (ncpId() == PLATFORM_NCP_SARA_R510) { - CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::RESET_WITH_SIM)); - } - HAL_Delay_Milliseconds(2000); - + CHECK(modemSoftReset()); CHECK(waitAtResponseFromPowerOn(state)); // Checking for SIM readiness ensures that other related commands @@ -1291,20 +1285,7 @@ int SaraNcpClient::selectSimCard(ModemState& state) { } if (reset) { - if (ncpId() == PLATFORM_NCP_SARA_R410) { - // R410 - CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::RESET_NO_SIM)); - HAL_Delay_Milliseconds(10000); - } else if (ncpId() == PLATFORM_NCP_SARA_R510) { - // R510 - CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::RESET_WITH_SIM)); - HAL_Delay_Milliseconds(10000); - } else { - // U201 - CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::RESET_WITH_SIM)); - HAL_Delay_Milliseconds(1000); - } - + CHECK(modemSoftReset()); CHECK(waitAtResponseFromPowerOn(state)); } @@ -1427,6 +1408,25 @@ int SaraNcpClient::changeBaudRate(unsigned int baud) { return serial_->setBaudRate(baud); } +int SaraNcpClient::applyPppNetworkPhaseIssueWorkarounds(ModemState& state) { + if (ncpId() != PLATFORM_NCP_SARA_R410) { + return 0; + } + + if (getInitializationState() != SaraNcpInitializationState::FOTA_LWM2M_DISABLED) { + // NOTE: AT+ULWM2M hangs in muxed mode, we have to reset here + if (state == ModemState::MuxerAtChannel || getModuleFunctionality() != CellularFunctionality::AIRPLANE) { + CHECK(modemSoftReset()); + CHECK(waitAtResponseFromPowerOn(state)); + } + // NOTE: may fail on some modem firmware versions + CHECK_PARSER(parser_.execCommand(UBLOX_CFUN_TIMEOUT, "AT+UFOTACONF=2,-1")); + CHECK_PARSER(parser_.execCommand("AT+ULWM2M=1")); + setInitializationState(SaraNcpInitializationState::FOTA_LWM2M_DISABLED); + } + return 0; +} + int SaraNcpClient::getAppFirmwareVersion() { // ATI9 (get version and app version) // example output @@ -1455,6 +1455,14 @@ int SaraNcpClient::initReady(ModemState state) { // L0.0.00.00.05.06,A.02.00 has a memory issue memoryIssuePresent_ = (ncpId() == PLATFORM_NCP_SARA_R410) ? (fwVersion_ == UBLOX_NCP_R4_APP_FW_VERSION_MEMORY_LEAK_ISSUE) : false; oldFirmwarePresent_ = (ncpId() == PLATFORM_NCP_SARA_R410) ? (fwVersion_ < UBLOX_NCP_R4_APP_FW_VERSION_LATEST_02B_01) : false; + + if (state != ModemState::MuxerAtChannel) { + if (getModuleFunctionality() != CellularFunctionality::AIRPLANE) { + CHECK(modemSoftReset()); + CHECK(waitAtResponseFromPowerOn(state)); + } + } + // Select either internal or external SIM card slot depending on the configuration CHECK(selectSimCard(state)); // Make sure flow control is enabled as well @@ -1491,6 +1499,8 @@ int SaraNcpClient::initReady(ModemState state) { CHECK(selectNetworkProf(state)); } + CHECK(applyPppNetworkPhaseIssueWorkarounds(state)); + // Reformat the operator string to be numeric // (allows the capture of `mcc` and `mnc`) int r = CHECK_PARSER(parser_.execCommand("AT+COPS=3,2")); @@ -1498,19 +1508,6 @@ int SaraNcpClient::initReady(ModemState state) { // Enable packet domain error reporting CHECK_PARSER_OK(parser_.execCommand("AT+CGEREP=1,0")); - // Disable LWM2M - // NOTE: this command hangs in muxed mode for some reason - if (ncpId() == PLATFORM_NCP_SARA_R410 && state != ModemState::MuxerAtChannel) { - auto resp = parser_.sendCommand("AT+ULWM2M?"); - int lwm2m = -1; - r = resp.scanf("+ULWM2M: %d", &lwm2m); - resp.readResult(); - if (lwm2m == 0) { - // Enabled -> disable - CHECK_PARSER(parser_.execCommand(("AT+ULWM2M=1"))); - } - } - if (ncpId() == PLATFORM_NCP_SARA_R410 || ncpId() == PLATFORM_NCP_SARA_R510) { // Force Cat M1-only mode // We may encounter a CME ERROR response with u-blox firmware 05.08,A.02.04 and in that case Cat-M1 mode is @@ -1828,6 +1825,27 @@ int SaraNcpClient::setModuleFunctionality(CellularFunctionality cfun, bool check return r; } +int SaraNcpClient::getInitializationState() { + CHECK_TRUE(ncpId() == PLATFORM_NCP_SARA_R410, SYSTEM_ERROR_NOT_SUPPORTED); + auto resp = parser_.sendCommand("AT+CGPIAF?"); + int bits[4] = {}; + auto r = resp.scanf("+CGPIAF: %d,%d,%d,%d", &bits[0], &bits[1], &bits[2], &bits[3]); + CHECK_PARSER_OK(resp.readResult()); + CHECK_TRUE(r == sizeof(bits) / sizeof(bits[0]), SYSTEM_ERROR_AT_RESPONSE_UNEXPECTED); + int state = bits[0] | (bits[1] << 1) | (bits[2] << 2) | (bits[3] << 3); + return state; +} + +int SaraNcpClient::setInitializationState(SaraNcpInitializationState state) { + CHECK_TRUE(ncpId() == PLATFORM_NCP_SARA_R410, SYSTEM_ERROR_NOT_SUPPORTED); + int bits[4] = {}; + for (int i = 0; i < (int) (sizeof(bits)/sizeof(bits[0])); i++) { + bits[i] = ((int)state >> i) & 0x01; + } + CHECK_PARSER_OK(parser_.execCommand("AT+CGPIAF=%d,%d,%d,%d", bits[0], bits[1], bits[2], bits[3])); + return 0; +} + int SaraNcpClient::configureApn(const CellularNetworkConfig& conf) { // IMPORTANT: Set modem full functionality! // Otherwise we won't be able to query ICCID/IMSI @@ -2098,9 +2116,9 @@ int SaraNcpClient::dataModeError(int error) { // FIXME: this is a workaround for some R410 firmware versions where the PPP session suddenly dies // in network phase after the first IPCP ConfReq. For some reason CGATT=0/1 helps. const NcpClientLock lock(this); - CHECK_PARSER_OK(parser_.execCommand(3 * 60 * 1000, "AT+CGATT=0")); + CHECK_PARSER_OK(parser_.execCommand(UBLOX_CFUN_TIMEOUT, "AT+CGATT=0")); HAL_Delay_Milliseconds(1000); - CHECK_PARSER_OK(parser_.execCommand(3 * 60 * 1000, "AT+CGATT=1")); + CHECK_PARSER_OK(parser_.execCommand(UBLOX_CFUN_TIMEOUT, "AT+CGATT=1")); } return 0; } @@ -2537,6 +2555,33 @@ int SaraNcpClient::modemPowerOff() { return SYSTEM_ERROR_NONE; } +int SaraNcpClient::modemSoftReset() { + bool running = muxer_.isRunning(); + + if (ncpId() == PLATFORM_NCP_SARA_R410) { + // R410 + CHECK(setModuleFunctionality(CellularFunctionality::AIRPLANE)); + CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::RESET_NO_SIM)); + HAL_Delay_Milliseconds(10000); + } else if (ncpId() == PLATFORM_NCP_SARA_R510) { + // R510 + CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::RESET_WITH_SIM)); + HAL_Delay_Milliseconds(10000); + } else { + // U201 + CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::RESET_WITH_SIM)); + HAL_Delay_Milliseconds(1000); + } + + if (running) { + // Disable ourselves/channel, so that the muxer can potentially stop faster non-gracefully + serial_->enabled(false); + muxer_.stop(); + serial_->enabled(true); + } + return 0; +} + int SaraNcpClient::modemSoftPowerOff() { if (firmwareUpdateR510_) { CHECK_TRUE(!modemPowerState(), SYSTEM_ERROR_INVALID_STATE); @@ -2550,6 +2595,9 @@ int SaraNcpClient::modemSoftPowerOff() { LOG(ERROR, "NCP client is not ready"); return SYSTEM_ERROR_INVALID_STATE; } + if (ncpId() == PLATFORM_NCP_SARA_R410) { + CHECK(setModuleFunctionality(CellularFunctionality::AIRPLANE)); + } int r = CHECK_PARSER(parser_.execCommand("AT+CPWROFF")); if (r != AtResponse::OK) { LOG(ERROR, "AT+CPWROFF command is not responding"); diff --git a/hal/network/ncp_client/sara/sara_ncp_client.h b/hal/network/ncp_client/sara/sara_ncp_client.h index 334e736b20..a20c245584 100644 --- a/hal/network/ncp_client/sara/sara_ncp_client.h +++ b/hal/network/ncp_client/sara/sara_ncp_client.h @@ -29,11 +29,19 @@ #include "static_recursive_mutex.h" #include "serial_stream.h" #include "cellular_reg_status.h" +#include "underlying_type.h" namespace particle { class SerialStream; +// Has to be outside the class for PARTICLE_DEFINE_ENUM_COMPARISON_OPERATORS +enum class SaraNcpInitializationState { + DEFAULT = 0, + FOTA_LWM2M_DISABLED = 0b0110 // R410-specific state +}; +PARTICLE_DEFINE_ENUM_COMPARISON_OPERATORS(SaraNcpInitializationState); + class SaraNcpClient: public CellularNcpClient { public: SaraNcpClient(); @@ -159,6 +167,7 @@ class SaraNcpClient: public CellularNcpClient { int modemPowerOn(); int modemPowerOff(); int modemSoftPowerOff(); + int modemSoftReset(); int modemHardReset(bool powerOff = false); int modemEmergencyHardReset(); bool modemPowerState() const; @@ -170,6 +179,9 @@ class SaraNcpClient: public CellularNcpClient { int checkSimReadiness(bool checkForRfReset = false); int setModuleFunctionality(CellularFunctionality cfun, bool check = false); int getModuleFunctionality(); + int getInitializationState(); + int setInitializationState(SaraNcpInitializationState state); + int applyPppNetworkPhaseIssueWorkarounds(ModemState& state); }; inline AtParser* SaraNcpClient::atParser() { From 80e52891d3deb89752927e46100c5be3f5def43c Mon Sep 17 00:00:00 2001 From: Andrey Tolstoy Date: Tue, 8 Nov 2022 22:49:08 +0700 Subject: [PATCH 036/112] Revert "[boron / bsom] lwm2m/fota stuff" This reverts commit 5d220d27a0cb2c906b331f05e83549d2b2c13dc0. --- .../ncp_client/sara/sara_ncp_client.cpp | 120 ++++++------------ hal/network/ncp_client/sara/sara_ncp_client.h | 12 -- 2 files changed, 36 insertions(+), 96 deletions(-) diff --git a/hal/network/ncp_client/sara/sara_ncp_client.cpp b/hal/network/ncp_client/sara/sara_ncp_client.cpp index fd4c55c610..f8377c2b2d 100644 --- a/hal/network/ncp_client/sara/sara_ncp_client.cpp +++ b/hal/network/ncp_client/sara/sara_ncp_client.cpp @@ -1173,7 +1173,13 @@ int SaraNcpClient::selectNetworkProf(ModemState& state) { } } if (reset) { - CHECK(modemSoftReset()); + if (ncpId() == PLATFORM_NCP_SARA_R410) { + CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::RESET_NO_SIM)); + } else if (ncpId() == PLATFORM_NCP_SARA_R510) { + CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::RESET_WITH_SIM)); + } + HAL_Delay_Milliseconds(2000); + CHECK(waitAtResponseFromPowerOn(state)); // Checking for SIM readiness ensures that other related commands @@ -1285,7 +1291,20 @@ int SaraNcpClient::selectSimCard(ModemState& state) { } if (reset) { - CHECK(modemSoftReset()); + if (ncpId() == PLATFORM_NCP_SARA_R410) { + // R410 + CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::RESET_NO_SIM)); + HAL_Delay_Milliseconds(10000); + } else if (ncpId() == PLATFORM_NCP_SARA_R510) { + // R510 + CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::RESET_WITH_SIM)); + HAL_Delay_Milliseconds(10000); + } else { + // U201 + CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::RESET_WITH_SIM)); + HAL_Delay_Milliseconds(1000); + } + CHECK(waitAtResponseFromPowerOn(state)); } @@ -1408,25 +1427,6 @@ int SaraNcpClient::changeBaudRate(unsigned int baud) { return serial_->setBaudRate(baud); } -int SaraNcpClient::applyPppNetworkPhaseIssueWorkarounds(ModemState& state) { - if (ncpId() != PLATFORM_NCP_SARA_R410) { - return 0; - } - - if (getInitializationState() != SaraNcpInitializationState::FOTA_LWM2M_DISABLED) { - // NOTE: AT+ULWM2M hangs in muxed mode, we have to reset here - if (state == ModemState::MuxerAtChannel || getModuleFunctionality() != CellularFunctionality::AIRPLANE) { - CHECK(modemSoftReset()); - CHECK(waitAtResponseFromPowerOn(state)); - } - // NOTE: may fail on some modem firmware versions - CHECK_PARSER(parser_.execCommand(UBLOX_CFUN_TIMEOUT, "AT+UFOTACONF=2,-1")); - CHECK_PARSER(parser_.execCommand("AT+ULWM2M=1")); - setInitializationState(SaraNcpInitializationState::FOTA_LWM2M_DISABLED); - } - return 0; -} - int SaraNcpClient::getAppFirmwareVersion() { // ATI9 (get version and app version) // example output @@ -1455,14 +1455,6 @@ int SaraNcpClient::initReady(ModemState state) { // L0.0.00.00.05.06,A.02.00 has a memory issue memoryIssuePresent_ = (ncpId() == PLATFORM_NCP_SARA_R410) ? (fwVersion_ == UBLOX_NCP_R4_APP_FW_VERSION_MEMORY_LEAK_ISSUE) : false; oldFirmwarePresent_ = (ncpId() == PLATFORM_NCP_SARA_R410) ? (fwVersion_ < UBLOX_NCP_R4_APP_FW_VERSION_LATEST_02B_01) : false; - - if (state != ModemState::MuxerAtChannel) { - if (getModuleFunctionality() != CellularFunctionality::AIRPLANE) { - CHECK(modemSoftReset()); - CHECK(waitAtResponseFromPowerOn(state)); - } - } - // Select either internal or external SIM card slot depending on the configuration CHECK(selectSimCard(state)); // Make sure flow control is enabled as well @@ -1499,8 +1491,6 @@ int SaraNcpClient::initReady(ModemState state) { CHECK(selectNetworkProf(state)); } - CHECK(applyPppNetworkPhaseIssueWorkarounds(state)); - // Reformat the operator string to be numeric // (allows the capture of `mcc` and `mnc`) int r = CHECK_PARSER(parser_.execCommand("AT+COPS=3,2")); @@ -1508,6 +1498,19 @@ int SaraNcpClient::initReady(ModemState state) { // Enable packet domain error reporting CHECK_PARSER_OK(parser_.execCommand("AT+CGEREP=1,0")); + // Disable LWM2M + // NOTE: this command hangs in muxed mode for some reason + if (ncpId() == PLATFORM_NCP_SARA_R410 && state != ModemState::MuxerAtChannel) { + auto resp = parser_.sendCommand("AT+ULWM2M?"); + int lwm2m = -1; + r = resp.scanf("+ULWM2M: %d", &lwm2m); + resp.readResult(); + if (lwm2m == 0) { + // Enabled -> disable + CHECK_PARSER(parser_.execCommand(("AT+ULWM2M=1"))); + } + } + if (ncpId() == PLATFORM_NCP_SARA_R410 || ncpId() == PLATFORM_NCP_SARA_R510) { // Force Cat M1-only mode // We may encounter a CME ERROR response with u-blox firmware 05.08,A.02.04 and in that case Cat-M1 mode is @@ -1825,27 +1828,6 @@ int SaraNcpClient::setModuleFunctionality(CellularFunctionality cfun, bool check return r; } -int SaraNcpClient::getInitializationState() { - CHECK_TRUE(ncpId() == PLATFORM_NCP_SARA_R410, SYSTEM_ERROR_NOT_SUPPORTED); - auto resp = parser_.sendCommand("AT+CGPIAF?"); - int bits[4] = {}; - auto r = resp.scanf("+CGPIAF: %d,%d,%d,%d", &bits[0], &bits[1], &bits[2], &bits[3]); - CHECK_PARSER_OK(resp.readResult()); - CHECK_TRUE(r == sizeof(bits) / sizeof(bits[0]), SYSTEM_ERROR_AT_RESPONSE_UNEXPECTED); - int state = bits[0] | (bits[1] << 1) | (bits[2] << 2) | (bits[3] << 3); - return state; -} - -int SaraNcpClient::setInitializationState(SaraNcpInitializationState state) { - CHECK_TRUE(ncpId() == PLATFORM_NCP_SARA_R410, SYSTEM_ERROR_NOT_SUPPORTED); - int bits[4] = {}; - for (int i = 0; i < (int) (sizeof(bits)/sizeof(bits[0])); i++) { - bits[i] = ((int)state >> i) & 0x01; - } - CHECK_PARSER_OK(parser_.execCommand("AT+CGPIAF=%d,%d,%d,%d", bits[0], bits[1], bits[2], bits[3])); - return 0; -} - int SaraNcpClient::configureApn(const CellularNetworkConfig& conf) { // IMPORTANT: Set modem full functionality! // Otherwise we won't be able to query ICCID/IMSI @@ -2116,9 +2098,9 @@ int SaraNcpClient::dataModeError(int error) { // FIXME: this is a workaround for some R410 firmware versions where the PPP session suddenly dies // in network phase after the first IPCP ConfReq. For some reason CGATT=0/1 helps. const NcpClientLock lock(this); - CHECK_PARSER_OK(parser_.execCommand(UBLOX_CFUN_TIMEOUT, "AT+CGATT=0")); + CHECK_PARSER_OK(parser_.execCommand(3 * 60 * 1000, "AT+CGATT=0")); HAL_Delay_Milliseconds(1000); - CHECK_PARSER_OK(parser_.execCommand(UBLOX_CFUN_TIMEOUT, "AT+CGATT=1")); + CHECK_PARSER_OK(parser_.execCommand(3 * 60 * 1000, "AT+CGATT=1")); } return 0; } @@ -2555,33 +2537,6 @@ int SaraNcpClient::modemPowerOff() { return SYSTEM_ERROR_NONE; } -int SaraNcpClient::modemSoftReset() { - bool running = muxer_.isRunning(); - - if (ncpId() == PLATFORM_NCP_SARA_R410) { - // R410 - CHECK(setModuleFunctionality(CellularFunctionality::AIRPLANE)); - CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::RESET_NO_SIM)); - HAL_Delay_Milliseconds(10000); - } else if (ncpId() == PLATFORM_NCP_SARA_R510) { - // R510 - CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::RESET_WITH_SIM)); - HAL_Delay_Milliseconds(10000); - } else { - // U201 - CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::RESET_WITH_SIM)); - HAL_Delay_Milliseconds(1000); - } - - if (running) { - // Disable ourselves/channel, so that the muxer can potentially stop faster non-gracefully - serial_->enabled(false); - muxer_.stop(); - serial_->enabled(true); - } - return 0; -} - int SaraNcpClient::modemSoftPowerOff() { if (firmwareUpdateR510_) { CHECK_TRUE(!modemPowerState(), SYSTEM_ERROR_INVALID_STATE); @@ -2595,9 +2550,6 @@ int SaraNcpClient::modemSoftPowerOff() { LOG(ERROR, "NCP client is not ready"); return SYSTEM_ERROR_INVALID_STATE; } - if (ncpId() == PLATFORM_NCP_SARA_R410) { - CHECK(setModuleFunctionality(CellularFunctionality::AIRPLANE)); - } int r = CHECK_PARSER(parser_.execCommand("AT+CPWROFF")); if (r != AtResponse::OK) { LOG(ERROR, "AT+CPWROFF command is not responding"); diff --git a/hal/network/ncp_client/sara/sara_ncp_client.h b/hal/network/ncp_client/sara/sara_ncp_client.h index a20c245584..334e736b20 100644 --- a/hal/network/ncp_client/sara/sara_ncp_client.h +++ b/hal/network/ncp_client/sara/sara_ncp_client.h @@ -29,19 +29,11 @@ #include "static_recursive_mutex.h" #include "serial_stream.h" #include "cellular_reg_status.h" -#include "underlying_type.h" namespace particle { class SerialStream; -// Has to be outside the class for PARTICLE_DEFINE_ENUM_COMPARISON_OPERATORS -enum class SaraNcpInitializationState { - DEFAULT = 0, - FOTA_LWM2M_DISABLED = 0b0110 // R410-specific state -}; -PARTICLE_DEFINE_ENUM_COMPARISON_OPERATORS(SaraNcpInitializationState); - class SaraNcpClient: public CellularNcpClient { public: SaraNcpClient(); @@ -167,7 +159,6 @@ class SaraNcpClient: public CellularNcpClient { int modemPowerOn(); int modemPowerOff(); int modemSoftPowerOff(); - int modemSoftReset(); int modemHardReset(bool powerOff = false); int modemEmergencyHardReset(); bool modemPowerState() const; @@ -179,9 +170,6 @@ class SaraNcpClient: public CellularNcpClient { int checkSimReadiness(bool checkForRfReset = false); int setModuleFunctionality(CellularFunctionality cfun, bool check = false); int getModuleFunctionality(); - int getInitializationState(); - int setInitializationState(SaraNcpInitializationState state); - int applyPppNetworkPhaseIssueWorkarounds(ModemState& state); }; inline AtParser* SaraNcpClient::atParser() { From 25c468589537bbaec6912a46adac2b2d76c58f29 Mon Sep 17 00:00:00 2001 From: Andrey Tolstoy Date: Tue, 8 Nov 2022 22:56:06 +0700 Subject: [PATCH 037/112] [boron / bsom] no point disabling lwm2m --- hal/network/ncp_client/sara/sara_ncp_client.cpp | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/hal/network/ncp_client/sara/sara_ncp_client.cpp b/hal/network/ncp_client/sara/sara_ncp_client.cpp index f8377c2b2d..a91dbc73a1 100644 --- a/hal/network/ncp_client/sara/sara_ncp_client.cpp +++ b/hal/network/ncp_client/sara/sara_ncp_client.cpp @@ -1498,19 +1498,6 @@ int SaraNcpClient::initReady(ModemState state) { // Enable packet domain error reporting CHECK_PARSER_OK(parser_.execCommand("AT+CGEREP=1,0")); - // Disable LWM2M - // NOTE: this command hangs in muxed mode for some reason - if (ncpId() == PLATFORM_NCP_SARA_R410 && state != ModemState::MuxerAtChannel) { - auto resp = parser_.sendCommand("AT+ULWM2M?"); - int lwm2m = -1; - r = resp.scanf("+ULWM2M: %d", &lwm2m); - resp.readResult(); - if (lwm2m == 0) { - // Enabled -> disable - CHECK_PARSER(parser_.execCommand(("AT+ULWM2M=1"))); - } - } - if (ncpId() == PLATFORM_NCP_SARA_R410 || ncpId() == PLATFORM_NCP_SARA_R510) { // Force Cat M1-only mode // We may encounter a CME ERROR response with u-blox firmware 05.08,A.02.04 and in that case Cat-M1 mode is From ed9786bee7575d4e0fa5410111248f71fd14d4d7 Mon Sep 17 00:00:00 2001 From: Andrey Tolstoy Date: Wed, 9 Nov 2022 00:31:53 +0700 Subject: [PATCH 038/112] minor --- .../ncp_client/sara/sara_ncp_client.cpp | 44 +++++++++---------- hal/network/ncp_client/sara/sara_ncp_client.h | 1 + 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/hal/network/ncp_client/sara/sara_ncp_client.cpp b/hal/network/ncp_client/sara/sara_ncp_client.cpp index a91dbc73a1..4d2f2efe74 100644 --- a/hal/network/ncp_client/sara/sara_ncp_client.cpp +++ b/hal/network/ncp_client/sara/sara_ncp_client.cpp @@ -1173,13 +1173,7 @@ int SaraNcpClient::selectNetworkProf(ModemState& state) { } } if (reset) { - if (ncpId() == PLATFORM_NCP_SARA_R410) { - CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::RESET_NO_SIM)); - } else if (ncpId() == PLATFORM_NCP_SARA_R510) { - CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::RESET_WITH_SIM)); - } - HAL_Delay_Milliseconds(2000); - + CHECK(modemSoftReset()); CHECK(waitAtResponseFromPowerOn(state)); // Checking for SIM readiness ensures that other related commands @@ -1291,20 +1285,7 @@ int SaraNcpClient::selectSimCard(ModemState& state) { } if (reset) { - if (ncpId() == PLATFORM_NCP_SARA_R410) { - // R410 - CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::RESET_NO_SIM)); - HAL_Delay_Milliseconds(10000); - } else if (ncpId() == PLATFORM_NCP_SARA_R510) { - // R510 - CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::RESET_WITH_SIM)); - HAL_Delay_Milliseconds(10000); - } else { - // U201 - CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::RESET_WITH_SIM)); - HAL_Delay_Milliseconds(1000); - } - + CHECK(modemSoftReset()); CHECK(waitAtResponseFromPowerOn(state)); } @@ -2085,9 +2066,9 @@ int SaraNcpClient::dataModeError(int error) { // FIXME: this is a workaround for some R410 firmware versions where the PPP session suddenly dies // in network phase after the first IPCP ConfReq. For some reason CGATT=0/1 helps. const NcpClientLock lock(this); - CHECK_PARSER_OK(parser_.execCommand(3 * 60 * 1000, "AT+CGATT=0")); + CHECK_PARSER_OK(parser_.execCommand(UBLOX_CFUN_TIMEOUT, "AT+CGATT=0")); HAL_Delay_Milliseconds(1000); - CHECK_PARSER_OK(parser_.execCommand(3 * 60 * 1000, "AT+CGATT=1")); + CHECK_PARSER_OK(parser_.execCommand(UBLOX_CFUN_TIMEOUT, "AT+CGATT=1")); } return 0; } @@ -2524,6 +2505,23 @@ int SaraNcpClient::modemPowerOff() { return SYSTEM_ERROR_NONE; } +int SaraNcpClient::modemSoftReset() { + if (ncpId() == PLATFORM_NCP_SARA_R410) { + // R410 + CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::RESET_NO_SIM)); + HAL_Delay_Milliseconds(10000); + } else if (ncpId() == PLATFORM_NCP_SARA_R510) { + // R510 + CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::RESET_WITH_SIM)); + HAL_Delay_Milliseconds(10000); + } else { + // U201 + CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::RESET_WITH_SIM)); + HAL_Delay_Milliseconds(1000); + } + return 0; +} + int SaraNcpClient::modemSoftPowerOff() { if (firmwareUpdateR510_) { CHECK_TRUE(!modemPowerState(), SYSTEM_ERROR_INVALID_STATE); diff --git a/hal/network/ncp_client/sara/sara_ncp_client.h b/hal/network/ncp_client/sara/sara_ncp_client.h index 334e736b20..60feb180bb 100644 --- a/hal/network/ncp_client/sara/sara_ncp_client.h +++ b/hal/network/ncp_client/sara/sara_ncp_client.h @@ -158,6 +158,7 @@ class SaraNcpClient: public CellularNcpClient { bool waitModemPowerState(bool onOff, system_tick_t timeout); int modemPowerOn(); int modemPowerOff(); + int modemSoftReset(); int modemSoftPowerOff(); int modemHardReset(bool powerOff = false); int modemEmergencyHardReset(); From 64b822e89fda08fd3c2a58dbb6b8cb59df9d7ed9 Mon Sep 17 00:00:00 2001 From: Andrey Tolstoy Date: Thu, 10 Nov 2022 00:52:16 +0700 Subject: [PATCH 039/112] minor --- hal/network/ncp_client/sara/sara_ncp_client.cpp | 5 +++++ hal/network/ncp_client/sara/sara_ncp_client.h | 2 ++ hal/src/nRF52840/lwip/lwip_logging.cpp | 4 +++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/hal/network/ncp_client/sara/sara_ncp_client.cpp b/hal/network/ncp_client/sara/sara_ncp_client.cpp index 4d2f2efe74..d36ecf8768 100644 --- a/hal/network/ncp_client/sara/sara_ncp_client.cpp +++ b/hal/network/ncp_client/sara/sara_ncp_client.cpp @@ -2066,9 +2066,11 @@ int SaraNcpClient::dataModeError(int error) { // FIXME: this is a workaround for some R410 firmware versions where the PPP session suddenly dies // in network phase after the first IPCP ConfReq. For some reason CGATT=0/1 helps. const NcpClientLock lock(this); + CHECK_FALSE(cgattWorkaroundApplied_, SYSTEM_ERROR_INVALID_STATE); CHECK_PARSER_OK(parser_.execCommand(UBLOX_CFUN_TIMEOUT, "AT+CGATT=0")); HAL_Delay_Milliseconds(1000); CHECK_PARSER_OK(parser_.execCommand(UBLOX_CFUN_TIMEOUT, "AT+CGATT=1")); + cgattWorkaroundApplied_ = true; } return 0; } @@ -2106,6 +2108,9 @@ void SaraNcpClient::connectionState(NcpConnectionState state) { connState_ = state; if (connState_ == NcpConnectionState::CONNECTED) { + // Reset CGATT workaround flag + cgattWorkaroundApplied_ = false; + if (firmwareUpdateR510_) { LOG(WARN, "Skipping PPP data connection to download NCP firmware"); return; diff --git a/hal/network/ncp_client/sara/sara_ncp_client.h b/hal/network/ncp_client/sara/sara_ncp_client.h index 60feb180bb..fa8c52fb84 100644 --- a/hal/network/ncp_client/sara/sara_ncp_client.h +++ b/hal/network/ncp_client/sara/sara_ncp_client.h @@ -125,6 +125,8 @@ class SaraNcpClient: public CellularNcpClient { system_tick_t lastWindow_ = 0; size_t bytesInWindow_ = 0; + bool cgattWorkaroundApplied_ = false; + int queryAndParseAtCops(CellularSignalQuality* qual); int initParser(Stream* stream); int waitReady(bool powerOn = false); diff --git a/hal/src/nRF52840/lwip/lwip_logging.cpp b/hal/src/nRF52840/lwip/lwip_logging.cpp index 8f0ff3f9e1..f83725e949 100644 --- a/hal/src/nRF52840/lwip/lwip_logging.cpp +++ b/hal/src/nRF52840/lwip/lwip_logging.cpp @@ -61,5 +61,7 @@ void ppp_dbglog(const char *fmt, ...) { ppp_vslprintf(tmp, sizeof(tmp) - 1, fmt, args); va_end(args); tmp[strcspn(tmp, "\r\n")] = 0; - LOG(TRACE, "%s", tmp); + + LogAttributes attr = {}; + log_message(LOG_LEVEL_TRACE, "lwip.ppp", &attr, nullptr /* reserved */, tmp); } From fdefbd552be6d80ac8f478b36675354210cb22bf Mon Sep 17 00:00:00 2001 From: Andrey Tolstoy Date: Thu, 10 Nov 2022 02:03:30 +0700 Subject: [PATCH 040/112] [gen3] ppp_dbglog() only if PPP_SUPPORT==1 --- hal/src/nRF52840/lwip/lwip_logging.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hal/src/nRF52840/lwip/lwip_logging.cpp b/hal/src/nRF52840/lwip/lwip_logging.cpp index f83725e949..7ad981424e 100644 --- a/hal/src/nRF52840/lwip/lwip_logging.cpp +++ b/hal/src/nRF52840/lwip/lwip_logging.cpp @@ -48,6 +48,8 @@ void lwip_log_message(const char* fmt, ...) { va_end(args); } +#if defined(PPP_SUPPORT) && PPP_SUPPORT + void ppp_dbglog(const char *fmt, ...) { // Only enable PPP negotiation packet logs if (strstr(fmt, "%P") == nullptr) { @@ -65,3 +67,5 @@ void ppp_dbglog(const char *fmt, ...) { LogAttributes attr = {}; log_message(LOG_LEVEL_TRACE, "lwip.ppp", &attr, nullptr /* reserved */, tmp); } + +#endif // defined(PPP_SUPPORT) && PPP_SUPPORT From 056c8c5dc46c8b1a4649b8a90b8fbb927674b2e7 Mon Sep 17 00:00:00 2001 From: Andrey Tolstoy Date: Thu, 10 Nov 2022 03:11:18 +0700 Subject: [PATCH 041/112] [tracker] disable CHAP support to save flash space --- hal/src/nRF52840/lwip/lwippppopts.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hal/src/nRF52840/lwip/lwippppopts.h b/hal/src/nRF52840/lwip/lwippppopts.h index 8be5e66dd9..5defdb4e0e 100644 --- a/hal/src/nRF52840/lwip/lwippppopts.h +++ b/hal/src/nRF52840/lwip/lwippppopts.h @@ -176,7 +176,7 @@ /** * CHAP_SUPPORT==1: Support CHAP. */ -#define CHAP_SUPPORT 1 +#define CHAP_SUPPORT (PLATFORM_ID != PLATFORM_TRACKER) /** * MSCHAP_SUPPORT==1: Support MSCHAP. From c15e4f18b45ec1a8778c6978f923cd18849791df Mon Sep 17 00:00:00 2001 From: keeramis Date: Wed, 9 Nov 2022 14:14:52 -0600 Subject: [PATCH 042/112] Ensure CGATT is enabled before dialing --- hal/network/ncp_client/sara/sara_ncp_client.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hal/network/ncp_client/sara/sara_ncp_client.cpp b/hal/network/ncp_client/sara/sara_ncp_client.cpp index d36ecf8768..1790d9e8b0 100644 --- a/hal/network/ncp_client/sara/sara_ncp_client.cpp +++ b/hal/network/ncp_client/sara/sara_ncp_client.cpp @@ -1987,6 +1987,17 @@ int SaraNcpClient::enterDataMode() { CHECK(waitAtResponse(parser_, 5000)); } + // CGATT should be enabled before we dial + auto respCgatt = parser_.sendCommand("AT+CGATT?"); + unsigned cgattState = 0; + respCgatt.scanf("+CGATT:%u", &cgattState); + CHECK_PARSER(respCgatt.readResult()); + if (cgattState == 0) { + CHECK_PARSER_OK(parser_.execCommand("AT+CGATT=1")); + // Modem could go through quick dereg/reg with this setting + HAL_Delay_Milliseconds(1000); + } + CHECK_TRUE(muxer_.setChannelDataHandler(UBLOX_NCP_PPP_CHANNEL, muxerDataStream_->channelDataCb, muxerDataStream_.get()) == 0, SYSTEM_ERROR_INTERNAL); // Send data mode break if (ncpId() != PLATFORM_NCP_SARA_R410 && ncpId() != PLATFORM_NCP_SARA_R510) { From 77f03d32bbfd8e4e2c3ca3fd356c69da79863aaa Mon Sep 17 00:00:00 2001 From: keeramis Date: Wed, 9 Nov 2022 14:24:10 -0600 Subject: [PATCH 043/112] minor --- hal/network/ncp_client/sara/sara_ncp_client.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hal/network/ncp_client/sara/sara_ncp_client.cpp b/hal/network/ncp_client/sara/sara_ncp_client.cpp index 1790d9e8b0..f5e03c2b39 100644 --- a/hal/network/ncp_client/sara/sara_ncp_client.cpp +++ b/hal/network/ncp_client/sara/sara_ncp_client.cpp @@ -1989,10 +1989,10 @@ int SaraNcpClient::enterDataMode() { // CGATT should be enabled before we dial auto respCgatt = parser_.sendCommand("AT+CGATT?"); - unsigned cgattState = 0; - respCgatt.scanf("+CGATT:%u", &cgattState); + int cgattState = -1; + auto ret = respCgatt.scanf("+CGATT: %d", &cgattState); CHECK_PARSER(respCgatt.readResult()); - if (cgattState == 0) { + if (ret == 1 && cgattState == 0) { CHECK_PARSER_OK(parser_.execCommand("AT+CGATT=1")); // Modem could go through quick dereg/reg with this setting HAL_Delay_Milliseconds(1000); From be9d52c280d999265656ca179bfb0aac149f324d Mon Sep 17 00:00:00 2001 From: Sergey Polyakov Date: Mon, 24 Oct 2022 11:42:17 +0400 Subject: [PATCH 044/112] Pass ServerMovedPermanentlyRequest to the system layer Compile cloud protocol definitions Parse the ServerMovedPermanentlyRequest Save the address and key of the new server Add a function for parsing a server address string Add a class for managing the server key and address Bugfixes; temporarily disable server key/address restoration Verify the signature of the new server settings Fix error handling Allow updating/restoring the TCP server key and address; minor refactoring Improve validation of the server address Validate the server settings on startup Add a reset reason code for configuration changes that require a system reset; minor fixes Remove unused APIs added in PR#1300 Remove the proto submodule Re-add device-os-protobuf submodule at different path; rework the script for compiling .proto files Add makefiles for the new proto module Use protobuf definitions from the proto module Fix module dependencies Rename the module with protobuf definitions to proto_defs Minor fix Update submodule ref [proto] fixes .gitmodules --- .gitmodules | 7 +- communication/inc/coap.h | 3 +- communication/inc/protocol.h | 10 + communication/inc/spark_protocol_functions.h | 13 +- communication/src/messages.cpp | 2 + communication/src/protocol.cpp | 98 ++ hal/inc/ota_flash_hal.h | 4 - hal/makefile | 2 +- .../ncp/cellular/cellular_network_manager.cpp | 3 +- hal/network/ncp/wifi/wifi_network_manager.cpp | 3 +- hal/shared/parse_server_address.h | 130 +- hal/src/gcc/ota_flash_hal.cpp | 19 - hal/src/nRF52840/ota_flash_hal.cpp | 25 +- hal/src/rtl872x/ota_flash_hal.cpp | 25 +- main/makefile | 4 +- modules/argon/system-part1/makefile | 6 +- modules/b5som/system-part1/makefile | 6 +- modules/boron/system-part1/makefile | 6 +- modules/tracker/system-part1/makefile | 6 +- modules/trackerm/system-part1/makefile | 6 +- modules/tron/system-part1/makefile | 6 +- proto | 1 - proto_defs/build.mk | 2 + proto_defs/gen_proto.sh | 50 + proto_defs/import.mk | 7 + proto_defs/include.mk | 1 + proto_defs/internal/network_config.proto | 25 + proto_defs/makefile | 12 + proto_defs/shared | 1 + proto_defs/src/cloud/cloud.pb.c | 15 + proto_defs/src/cloud/cloud.pb.h | 86 ++ .../src/control}/cellular.pb.c | 2 +- .../src/control}/cellular.pb.h | 7 +- .../src/control}/cloud.pb.c | 2 +- .../src/control}/cloud.pb.h | 6 +- .../src/control}/common.pb.c | 2 +- .../src/control}/common.pb.h | 6 +- .../src/control}/config.pb.c | 2 +- .../src/control}/config.pb.h | 7 +- .../src/control}/extensions.pb.c | 2 +- .../src/control}/extensions.pb.h | 4 +- .../src/control}/network.pb.c | 2 +- .../src/control}/network.pb.h | 8 +- .../src/control}/storage.pb.c | 2 +- .../src/control}/storage.pb.h | 7 +- .../src/control}/wifi.pb.c | 2 +- .../src/control}/wifi.pb.h | 7 +- .../src/control}/wifi_new.pb.c | 2 +- .../src/control}/wifi_new.pb.h | 7 +- .../src/network_config.pb.c | 2 +- .../src/network_config.pb.h | 9 +- services/inc/system_defs.h | 6 +- services/makefile | 4 +- system/inc/system_cloud.h | 38 +- system/makefile | 2 +- system/src/control/cellular.cpp | 2 +- system/src/control/cloud.cpp | 2 +- system/src/control/common.h | 2 +- system/src/control/config.cpp | 2 +- system/src/control/network.cpp | 2 +- system/src/control/proto/build.sh | 42 - system/src/control/proto/control.pb.c | 9 - system/src/control/proto/control.pb.h | 24 - system/src/control/proto/mesh.pb.c | 143 --- system/src/control/proto/mesh.pb.h | 1082 ----------------- system/src/control/storage.cpp | 2 +- system/src/control/wifi_new.cpp | 2 +- system/src/main.cpp | 4 +- system/src/server_config.cpp | 273 +++++ system/src/server_config.h | 99 ++ system/src/system_cloud_connection.cpp | 17 - system/src/system_cloud_internal.cpp | 137 ++- system/src/system_cloud_internal_constants.c | 90 -- 73 files changed, 975 insertions(+), 1681 deletions(-) delete mode 160000 proto create mode 100644 proto_defs/build.mk create mode 100755 proto_defs/gen_proto.sh create mode 100644 proto_defs/import.mk create mode 100644 proto_defs/include.mk create mode 100644 proto_defs/internal/network_config.proto create mode 100644 proto_defs/makefile create mode 160000 proto_defs/shared create mode 100644 proto_defs/src/cloud/cloud.pb.c create mode 100644 proto_defs/src/cloud/cloud.pb.h rename {system/src/control/proto => proto_defs/src/control}/cellular.pb.c (97%) rename {system/src/control/proto => proto_defs/src/control}/cellular.pb.h (98%) rename {system/src/control/proto => proto_defs/src/control}/cloud.pb.c (96%) rename {system/src/control/proto => proto_defs/src/control}/cloud.pb.h (97%) rename {system/src/control/proto => proto_defs/src/control}/common.pb.c (93%) rename {system/src/control/proto => proto_defs/src/control}/common.pb.h (97%) rename {system/src/control/proto => proto_defs/src/control}/config.pb.c (99%) rename {system/src/control/proto => proto_defs/src/control}/config.pb.h (99%) rename {system/src/control/proto => proto_defs/src/control}/extensions.pb.c (85%) rename {system/src/control/proto => proto_defs/src/control}/extensions.pb.h (86%) rename {system/src/control/proto => proto_defs/src/control}/network.pb.c (98%) rename {system/src/control/proto => proto_defs/src/control}/network.pb.h (99%) rename {system/src/control/proto => proto_defs/src/control}/storage.pb.c (98%) rename {system/src/control/proto => proto_defs/src/control}/storage.pb.h (99%) rename {system/src/control/proto => proto_defs/src/control}/wifi.pb.c (98%) rename {system/src/control/proto => proto_defs/src/control}/wifi.pb.h (99%) rename {system/src/control/proto => proto_defs/src/control}/wifi_new.pb.c (98%) rename {system/src/control/proto => proto_defs/src/control}/wifi_new.pb.h (99%) rename system/src/control/proto/internal.pb.c => proto_defs/src/network_config.pb.c (93%) rename system/src/control/proto/internal.pb.h => proto_defs/src/network_config.pb.h (96%) delete mode 100755 system/src/control/proto/build.sh delete mode 100644 system/src/control/proto/control.pb.c delete mode 100644 system/src/control/proto/control.pb.h delete mode 100644 system/src/control/proto/mesh.pb.c delete mode 100644 system/src/control/proto/mesh.pb.h create mode 100644 system/src/server_config.cpp create mode 100644 system/src/server_config.h delete mode 100644 system/src/system_cloud_internal_constants.c diff --git a/.gitmodules b/.gitmodules index 533fa578fc..ad07765838 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,7 +1,3 @@ -[submodule "proto"] - path = proto - url = https://github.com/particle-iot/firmware-protobuf.git - branch = master [submodule "third_party/nrf5_sdk/nrf5_sdk"] path = third_party/nrf5_sdk/nrf5_sdk url = https://github.com/particle-iot/nrf5_sdk.git @@ -54,3 +50,6 @@ [submodule "third_party/coremark/coremark"] path = third_party/coremark/coremark url = https://github.com/particle-iot/coremark +[submodule "proto_defs/shared"] + path = proto_defs/shared + url = git@github.com:particle-iot/device-os-protobuf.git diff --git a/communication/inc/coap.h b/communication/inc/coap.h index fd9164561f..a08cdb1653 100644 --- a/communication/inc/coap.h +++ b/communication/inc/coap.h @@ -56,7 +56,8 @@ namespace CoAPMessageType { NONE, UPDATE_START_V3, UPDATE_FINISH_V3, - UPDATE_CHUNK_V3 + UPDATE_CHUNK_V3, + SERVER_MOVED }; } diff --git a/communication/inc/protocol.h b/communication/inc/protocol.h index 93774be6c6..ced338aac3 100644 --- a/communication/inc/protocol.h +++ b/communication/inc/protocol.h @@ -306,6 +306,16 @@ class Protocol */ void handle_time_response(uint32_t time); + /** + * Handle a ServerMoved request. + */ + ProtocolError handle_server_moved_request(Message& msg); + + /** + * Send a response for a ServerMoved request. + */ + static void send_server_moved_response(int error, void* ctx); + /** * Copy an initialize a block of memory from a source to a target, where the source may be smaller than the target. * This handles the case where the caller was compiled using a smaller version of the struct memory than what is the current. diff --git a/communication/inc/spark_protocol_functions.h b/communication/inc/spark_protocol_functions.h index 18ebfe8fe9..a42cd26be7 100644 --- a/communication/inc/spark_protocol_functions.h +++ b/communication/inc/spark_protocol_functions.h @@ -57,6 +57,8 @@ enum ProtocolFactory PROTOCOL_DTLS, }; +typedef void (*ServerMovedResponseCallback)(int error, void* context); + struct SparkCallbacks { uint16_t size; @@ -132,9 +134,18 @@ struct SparkCallbacks void (*notify_client_messages_processed)(void* reserved); // size == 56 + + /** + * Notify the system that the server wants to permanently move the device to another server. + */ + // TODO: Parse the request in the communication library + void (*server_moved)(const char* request_data, size_t request_size, ServerMovedResponseCallback response_callback, + void* context); + + // size == 60 }; -PARTICLE_STATIC_ASSERT(SparkCallbacks_size, sizeof(SparkCallbacks)==(sizeof(void*)*14)); +PARTICLE_STATIC_ASSERT(SparkCallbacks_size, sizeof(SparkCallbacks)==(sizeof(void*)*15)); /** * Application-supplied callbacks. (Deliberately distinct from the system-supplied diff --git a/communication/src/messages.cpp b/communication/src/messages.cpp index ea38bf0afb..028d83bb6d 100644 --- a/communication/src/messages.cpp +++ b/communication/src/messages.cpp @@ -82,6 +82,8 @@ CoAPMessageType::Enum Messages::decodeType(const uint8_t* buf, size_t length) return CoAPMessageType::UPDATE_FINISH_V3; case 'C': return CoAPMessageType::UPDATE_CHUNK_V3; + case 'M': + return CoAPMessageType::SERVER_MOVED; default: break; } diff --git a/communication/src/protocol.cpp b/communication/src/protocol.cpp index a570c4b7e6..3f41a4c84d 100644 --- a/communication/src/protocol.cpp +++ b/communication/src/protocol.cpp @@ -26,10 +26,13 @@ LOG_SOURCE_CATEGORY("comm.protocol") #include "mbedtls_config.h" #include "protocol_defs.h" +#include "protocol_util.h" #include "protocol.h" #include "chunked_transfer.h" #include "subscriptions.h" #include "functions.h" +#include "coap_message_decoder.h" +#include "coap_message_encoder.h" namespace particle { namespace protocol { @@ -46,6 +49,11 @@ enum HelloFlag { HELLO_FLAG_OTA_PROTOCOL_V3 = 0x80 }; +struct ServerMovedContext { + Protocol* proto; + token_t token; +}; + } // namespace /** @@ -201,6 +209,10 @@ ProtocolError Protocol::handle_received_message(Message& message, error = channel.send(message); break; + case CoAPMessageType::SERVER_MOVED: + return handle_server_moved_request(message); + break; + case CoAPMessageType::ERROR: default: ; // drop it on the floor @@ -269,6 +281,92 @@ void Protocol::handle_time_response(uint32_t time) timesync_.handle_time_response(time, callbacks.millis(), callbacks.set_time); } +ProtocolError Protocol::handle_server_moved_request(Message& msg) +{ + // Parse the request + CoapMessageDecoder dec; + int r = dec.decode((const char*)msg.buf(), msg.length()); + if (r < 0 || dec.type() != CoapType::CON || !dec.hasToken()) { + LOG(ERROR, "Received a malformed ServerMoved request"); + return ProtocolError::NO_ERROR; // Ignore the request + } + LOG(WARN, "Received a ServerMoved request"); + // Acknowledge the request + Message ack; + r = channel.response(msg, ack, msg.capacity() - msg.length()); + if (r != ProtocolError::NO_ERROR) { + LOG(ERROR, "Failed to create message: %d", r); + return (ProtocolError)r; + } + CoapMessageEncoder enc((char*)ack.buf(), ack.capacity()); + enc.type(CoapType::ACK); + enc.code(CoapCode::EMPTY); + enc.id(0); // Encoded by the message channel + r = enc.encode(); + if (r < 0) { + LOG(ERROR, "Failed to encode message: %d", r); + return ProtocolError::INTERNAL; + } + if (r > (int)ack.capacity()) { + LOG(ERROR, "Message data is too long"); + return ProtocolError::INSUFFICIENT_STORAGE; + } + ack.set_length(r); + ack.set_id(dec.id()); + r = channel.send(ack); + if (r != ProtocolError::NO_ERROR) { + LOG(ERROR, "Failed to send message: %d", r); + return (ProtocolError)r; + } + // Process the request + std::unique_ptr ctx(new(std::nothrow) ServerMovedContext()); + if (!ctx) { + return ProtocolError::NO_MEMORY; + } + ctx->proto = this; + SPARK_ASSERT(dec.tokenSize() == sizeof(ctx->token)); // Verified in handle_received_message() + memcpy(&ctx->token, dec.token(), sizeof(ctx->token)); + SPARK_ASSERT(callbacks.server_moved); + callbacks.server_moved(dec.payload(), dec.payloadSize(), send_server_moved_response, ctx.release()); // Transfer ownership over the context + return ProtocolError::NO_ERROR; +} + +void Protocol::send_server_moved_response(int error, void* context) { + SPARK_ASSERT(context); + std::unique_ptr ctx(static_cast(context)); + Message msg; + int r = ctx->proto->channel.create(msg); + if (r != ProtocolError::NO_ERROR) { + LOG(ERROR, "Failed to create message: %d", r); + return; + } + CoapMessageEncoder enc((char*)msg.buf(), msg.capacity()); + enc.type(CoapType::CON); + enc.code(coapCodeForSystemError(error)); + enc.id(0); // Encoded by the message channel + enc.token((const char*)&ctx->token, sizeof(ctx->token)); + if (error < 0) { + r = formatDiagnosticPayload(enc.payloadData(), enc.maxPayloadSize(), error); + if (r > 0) { + enc.payloadSize(r); + } + } + r = enc.encode(); + if (r < 0) { + LOG(ERROR, "Failed to encode message: %d", r); + return; + } + if (r > (int)msg.capacity()) { + LOG(ERROR, "Message data is too long"); + return; + } + msg.set_length(r); + r = ctx->proto->channel.send(msg); + if (r != ProtocolError::NO_ERROR) { + LOG(ERROR, "Failed to send message: %d", (int)r); + } +} + /** * Copy an initialize a block of memory from a source to a target, where the source may be smaller than the target. * This handles the case where the caller was compiled using a smaller version of the struct memory than what is the current. diff --git a/hal/inc/ota_flash_hal.h b/hal/inc/ota_flash_hal.h index 5eb86d41ad..2fbe7dff2d 100644 --- a/hal/inc/ota_flash_hal.h +++ b/hal/inc/ota_flash_hal.h @@ -227,15 +227,11 @@ PARTICLE_STATIC_ASSERT(ServerAddress_size, sizeof(ServerAddress)==128); /* Length in bytes of DER-encoded 2048-bit RSA public key */ #define EXTERNAL_FLASH_SERVER_PUBLIC_KEY_LENGTH (294) -/* Length in bytes of server address */ -#define EXTERNAL_FLASH_SERVER_ADDRESS_LENGTH (128) /* Length in bytes of DER-encoded 1024-bit RSA private key */ #define EXTERNAL_FLASH_CORE_PRIVATE_KEY_LENGTH (612) void HAL_FLASH_Read_ServerAddress(ServerAddress *server_addr); -void HAL_FLASH_Write_ServerAddress(const uint8_t *buf, bool udp); void HAL_FLASH_Read_ServerPublicKey(uint8_t *keyBuffer); -void HAL_FLASH_Write_ServerPublicKey(const uint8_t *keyBuffer, bool udp); typedef enum { /** diff --git a/hal/makefile b/hal/makefile index b0c5d36ad7..5d3c7df39a 100644 --- a/hal/makefile +++ b/hal/makefile @@ -6,7 +6,7 @@ HAL_MODULE_PATH=. TARGET_TYPE = a BUILD_PATH_EXT = $(HAL_BUILD_PATH_EXT) -DEPENDENCIES = newlib_nano platform services dynalib bootloader wiring crypto +DEPENDENCIES = newlib_nano platform services dynalib bootloader wiring crypto proto_defs # ensure PLATFORM_NAME is defined include ../build/platform-id.mk diff --git a/hal/network/ncp/cellular/cellular_network_manager.cpp b/hal/network/ncp/cellular/cellular_network_manager.cpp index 034f7824e6..861caee015 100644 --- a/hal/network/ncp/cellular/cellular_network_manager.cpp +++ b/hal/network/ncp/cellular/cellular_network_manager.cpp @@ -26,8 +26,7 @@ // FIXME: Move nanopb utilities to a common header file #include "../../../../system/src/control/common.h" -// FIXME: Build internal protocol files in a separate directory -#include "../../../../system/src/control/proto/internal.pb.h" +#include "network_config.pb.h" #define PB(_name) particle_firmware_##_name #define PB_CELLULAR(_name) particle_ctrl_cellular_##_name diff --git a/hal/network/ncp/wifi/wifi_network_manager.cpp b/hal/network/ncp/wifi/wifi_network_manager.cpp index 7d74f97c47..6c616b4cfb 100644 --- a/hal/network/ncp/wifi/wifi_network_manager.cpp +++ b/hal/network/ncp/wifi/wifi_network_manager.cpp @@ -31,8 +31,7 @@ // FIXME: Move nanopb utilities to a common header file #include "../../../system/src/control/common.h" -// FIXME: Build internal protocol files in a separate directory -#include "../../../system/src/control/proto/internal.pb.h" +#include "network_config.pb.h" #define PB(_name) particle_firmware_##_name #define PB_WIFI(_name) particle_ctrl_wifi_##_name diff --git a/hal/shared/parse_server_address.h b/hal/shared/parse_server_address.h index 3d23db7dcc..4beb6e2c1c 100644 --- a/hal/shared/parse_server_address.h +++ b/hal/shared/parse_server_address.h @@ -19,56 +19,70 @@ #ifndef PARSE_SERVER_ADDRESS_H #define PARSE_SERVER_ADDRESS_H -#include "ota_flash_hal.h" - +#include "ota_flash_hal.h" // For ServerAddress #include "system_error.h" -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -inline void parseServerAddressData(ServerAddress* server_addr, const uint8_t* buf, int maxLength) -{ - // Internet address stored on external flash may be - // either a domain name or an IP address. - // It's stored in a type-length-value encoding. - // First byte is type, second byte is length, the rest is value. - - switch (buf[0]) - { - case IP_ADDRESS: - server_addr->addr_type = IP_ADDRESS; - server_addr->length = 4; - server_addr->ip = (buf[2] << 24) | (buf[3] << 16) | - (buf[4] << 8) | buf[5]; - break; - - case DOMAIN_NAME: - if (buf[1] <= maxLength - 2) - { - server_addr->addr_type = DOMAIN_NAME; - server_addr->length = buf[1]; - memcpy(server_addr->domain, buf + 2, buf[1]); - - // null terminate string - char *p = server_addr->domain + buf[1]; - *p = 0; +#include +#include +#include +#include + +namespace particle { + +inline void parseServerAddressData(ServerAddress* addr, const uint8_t* buf, size_t size) { + // Internet address stored on external flash may be + // either a domain name or an IP address. + // It's stored in a type-length-value encoding. + // First byte is type, second byte is length, the rest is value. + if (size < 2) { + addr->addr_type = INVALID_INTERNET_ADDRESS; + return; + } + switch (buf[0]) { + case IP_ADDRESS: { + size_t addr_len = buf[1]; + if (addr_len != 4 || size < 6) { + addr->addr_type = INVALID_INTERNET_ADDRESS; + return; + } + auto ip = ((unsigned)buf[2] << 24) | ((unsigned)buf[3] << 16) | ((unsigned)buf[4] << 8) | (unsigned)buf[5]; + if (!ip || ip == 0xffffffffu) { // 0.0.0.0 or 255.255.255.255 + addr->addr_type = INVALID_INTERNET_ADDRESS; + return; + } + addr->addr_type = IP_ADDRESS; + addr->length = addr_len; + addr->ip = ip; break; - } - // else fall through to default - + } + case DOMAIN_NAME: { + size_t name_len = buf[1]; + if (name_len + 2 > size || name_len > sizeof(addr->domain) - 1) { // Reserve 1 byte for '\0' + addr->addr_type = INVALID_INTERNET_ADDRESS; + return; + } + auto name = buf + 2; + for (size_t i = 0; i < name_len; ++i) { + if (!isprint(name[i])) { + addr->addr_type = INVALID_INTERNET_ADDRESS; + return; + } + } + addr->addr_type = DOMAIN_NAME; + addr->length = name_len; + memcpy(addr->domain, name, name_len); + addr->domain[name_len] = '\0'; + break; + } default: - server_addr->addr_type = INVALID_INTERNET_ADDRESS; - } - if (server_addr->addr_type!=INVALID_INTERNET_ADDRESS) - { - server_addr->port = buf[66]<<8 | buf[67]; - - } - + addr->addr_type = INVALID_INTERNET_ADDRESS; + return; + } + if (size < 68) { + addr->addr_type = INVALID_INTERNET_ADDRESS; + return; + } + addr->port = (buf[66] << 8) | buf[67]; } inline int encodeServerAddressData(const ServerAddress* addr, uint8_t* buf, size_t bufSize) { @@ -98,9 +112,29 @@ inline int encodeServerAddressData(const ServerAddress* addr, uint8_t* buf, size return 0; } -#ifdef __cplusplus +// Note: This function doesn't parse the port number +inline int parseServerAddressString(ServerAddress* addr, const char* str) { + unsigned n1 = 0, n2 = 0, n3 = 0, n4 = 0; + if (sscanf(str, "%u.%u.%u.%u", &n1, &n2, &n3, &n4) == 4) { + if (n1 > 255 || n2 > 255 || n3 > 255 || n4 > 255) { + return SYSTEM_ERROR_INVALID_ARGUMENT; + } + addr->addr_type = IP_ADDRESS; + addr->length = 4; + addr->ip = (n1 << 24) | (n2 << 16) | (n3 << 8) | n4; + } else { + size_t len = strlen(str); + if (len > sizeof(addr->domain) - 1) { // Reserve 1 byte for '\0' + return SYSTEM_ERROR_TOO_LARGE; + } + addr->addr_type = DOMAIN_NAME; + addr->length = len; + memcpy(addr->domain, str, len + 1); // Include '\0' + } + return 0; } -#endif + +} // namespace particle #endif /* PARSE_SERVER_ADDRESS_H */ diff --git a/hal/src/gcc/ota_flash_hal.cpp b/hal/src/gcc/ota_flash_hal.cpp index 7112b3039d..a0930b0f2c 100644 --- a/hal/src/gcc/ota_flash_hal.cpp +++ b/hal/src/gcc/ota_flash_hal.cpp @@ -434,12 +434,8 @@ void parseServerAddressData(ServerAddress* server_addr, uint8_t* buf) } -#define MAXIMUM_CLOUD_KEY_LEN (512) #define SERVER_ADDRESS_OFFSET (384) #define SERVER_ADDRESS_OFFSET_EC (192) -#define SERVER_ADDRESS_SIZE (128) -#define SERVER_PUBLIC_KEY_SIZE (294) -#define SERVER_PUBLIC_KEY_EC_SIZE (320) void HAL_FLASH_Read_ServerAddress(ServerAddress* server_addr) @@ -449,12 +445,6 @@ void HAL_FLASH_Read_ServerAddress(ServerAddress* server_addr) parseServerAddressData(server_addr, deviceConfig.server_key+offset); } -void HAL_FLASH_Write_ServerAddress(const uint8_t *buf, bool udp) -{ - int offset = (udp) ? SERVER_ADDRESS_OFFSET_EC : SERVER_ADDRESS_OFFSET; - memcpy(deviceConfig.server_key+offset, buf, SERVER_ADDRESS_SIZE); -} - bool HAL_OTA_Flashed_GetStatus(void) { return false; @@ -475,15 +465,6 @@ void HAL_FLASH_Read_ServerPublicKey(uint8_t *keyBuffer) INFO("server key: %s", buf); } -void HAL_FLASH_Write_ServerPublicKey(const uint8_t *keyBuffer, bool udp) -{ - if (udp) { - memcpy(&deviceConfig.server_key, keyBuffer, SERVER_PUBLIC_KEY_EC_SIZE); - } else { - memcpy(&deviceConfig.server_key, keyBuffer, SERVER_PUBLIC_KEY_SIZE); - } -} - int HAL_FLASH_Read_CorePrivateKey(uint8_t *keyBuffer, private_key_generation_t* generation) { memcpy(keyBuffer, deviceConfig.device_key, PRIVATE_KEY_LEN); diff --git a/hal/src/nRF52840/ota_flash_hal.cpp b/hal/src/nRF52840/ota_flash_hal.cpp index 2a3e3d7dda..adc69455d0 100644 --- a/hal/src/nRF52840/ota_flash_hal.cpp +++ b/hal/src/nRF52840/ota_flash_hal.cpp @@ -54,6 +54,8 @@ LOG_SOURCE_CATEGORY("hal.ota") #define BOOTLOADER_RANDOM_BACKOFF_MIN (200) #define BOOTLOADER_RANDOM_BACKOFF_MAX (1000) +using namespace particle; + namespace { const uint16_t BOOTLOADER_MBR_UPDATE_MIN_VERSION = 1001; // 2.0.0-rc.1 @@ -773,29 +775,6 @@ bool HAL_IsDeviceClaimed(void* reserved) return (claimed)=='1'; } -void HAL_FLASH_Write_ServerPublicKey(const uint8_t *keyBuffer, bool udp) -{ - if (udp) - { - dct_write_app_data(keyBuffer, DCT_ALT_SERVER_PUBLIC_KEY_OFFSET, DCT_ALT_SERVER_PUBLIC_KEY_SIZE); - } else - { - dct_write_app_data(keyBuffer, DCT_SERVER_PUBLIC_KEY_OFFSET, EXTERNAL_FLASH_SERVER_PUBLIC_KEY_LENGTH); - } -} - -void HAL_FLASH_Write_ServerAddress(const uint8_t *buf, bool udp) -{ - if (udp) - { - dct_write_app_data(buf, DCT_ALT_SERVER_ADDRESS_OFFSET, DCT_ALT_SERVER_ADDRESS_SIZE); - } - else - { - dct_write_app_data(buf, DCT_SERVER_ADDRESS_OFFSET, DCT_SERVER_ADDRESS_SIZE); - } -} - int HAL_Set_System_Config(hal_system_config_t config_item, const void* data, unsigned data_length) { unsigned offset = 0; diff --git a/hal/src/rtl872x/ota_flash_hal.cpp b/hal/src/rtl872x/ota_flash_hal.cpp index a797f1c13c..56de98f3bc 100644 --- a/hal/src/rtl872x/ota_flash_hal.cpp +++ b/hal/src/rtl872x/ota_flash_hal.cpp @@ -54,6 +54,8 @@ LOG_SOURCE_CATEGORY("hal.ota") #define BOOTLOADER_RANDOM_BACKOFF_MIN (200) #define BOOTLOADER_RANDOM_BACKOFF_MAX (1000) +using namespace particle; + namespace { const uint16_t BOOTLOADER_MBR_UPDATE_MIN_VERSION = 1001; // 2.0.0-rc.1 @@ -691,29 +693,6 @@ bool HAL_IsDeviceClaimed(void* reserved) return (claimed)=='1'; } -void HAL_FLASH_Write_ServerPublicKey(const uint8_t *keyBuffer, bool udp) -{ - if (udp) - { - dct_write_app_data(keyBuffer, DCT_ALT_SERVER_PUBLIC_KEY_OFFSET, DCT_ALT_SERVER_PUBLIC_KEY_SIZE); - } else - { - dct_write_app_data(keyBuffer, DCT_SERVER_PUBLIC_KEY_OFFSET, EXTERNAL_FLASH_SERVER_PUBLIC_KEY_LENGTH); - } -} - -void HAL_FLASH_Write_ServerAddress(const uint8_t *buf, bool udp) -{ - if (udp) - { - dct_write_app_data(buf, DCT_ALT_SERVER_ADDRESS_OFFSET, DCT_ALT_SERVER_ADDRESS_SIZE); - } - else - { - dct_write_app_data(buf, DCT_SERVER_ADDRESS_OFFSET, DCT_SERVER_ADDRESS_SIZE); - } -} - int HAL_Set_System_Config(hal_system_config_t config_item, const void* data, unsigned data_length) { unsigned offset = 0; diff --git a/main/makefile b/main/makefile index 0077545380..c97a7cfb53 100644 --- a/main/makefile +++ b/main/makefile @@ -82,11 +82,11 @@ endif # It's critical that user comes before wiring so that the setup()/loop() functions are linked in preference # to the weak functions from wiring -MAKE_DEPENDENCIES = newlib_nano user wiring hal system services communication platform wiring_globals crypto +MAKE_DEPENDENCIES = newlib_nano user wiring hal system services communication platform wiring_globals crypto proto_defs DEPENDENCIES = $(MAKE_DEPENDENCIES) dynalib LIBS += $(MAKE_DEPENDENCIES) -LIB_DEPS += $(USER_LIB_DEP) $(WIRING_LIB_DEP) $(SYSTEM_LIB_DEP) $(SERVICES_LIB_DEP) $(COMMUNICATION_LIB_DEP) $(HAL_LIB_DEP) $(PLATFORM_LIB_DEP) $(WIRING_GLOBALS_LIB_DEP) $(CRYPTO_LIB_DEP) +LIB_DEPS += $(USER_LIB_DEP) $(WIRING_LIB_DEP) $(SYSTEM_LIB_DEP) $(SERVICES_LIB_DEP) $(COMMUNICATION_LIB_DEP) $(HAL_LIB_DEP) $(PLATFORM_LIB_DEP) $(WIRING_GLOBALS_LIB_DEP) $(CRYPTO_LIB_DEP) $(PROTO_DEFS_LIB_DEP) LIB_DIRS += $(dir $(LIB_DEPS)) # Target this makefile is building. diff --git a/modules/argon/system-part1/makefile b/modules/argon/system-part1/makefile index 8c66c14d67..d928b67ce0 100644 --- a/modules/argon/system-part1/makefile +++ b/modules/argon/system-part1/makefile @@ -6,8 +6,8 @@ HAL_LINK := PLATFORM_DFU = 0x30000 NCP_FIRMWARE_MODULE_VERSION=4 # MODULE_DEPENDENCY2=7,0,$(NCP_FIRMWARE_MODULE_VERSION) -DEPENDENCIES = newlib_nano modules/argon/user-part modules/argon/system-part1 dynalib services hal platform system wiring communication rt-dynalib crypto -LIB_DEPENDENCIES = services system wiring communication hal platform crypto +DEPENDENCIES = newlib_nano modules/argon/user-part modules/argon/system-part1 dynalib services hal platform system wiring communication rt-dynalib crypto proto_defs +LIB_DEPENDENCIES = services system wiring communication hal platform crypto proto_defs # newlib_nano is special in that it's linked automatically by the system, so no need to add it to the library path here MAKE_DEPENDENCIES = newlib_nano $(LIB_DEPENDENCIES) @@ -15,7 +15,7 @@ include ../modular.mk include $(PROJECT_ROOT)/build/platform-id.mk LIBS += $(LIB_DEPENDENCIES) -LIB_DEPS += $(SERVICES_LIB_DEP) $(PLATFORM_LIB_DEP) $(HAL_LIB_DEP) $(SYSTEM_LIB_DEP) $(COMMUNICATION_LIB_DEP) $(WIRING_LIB_DEP) $(CRYPTO_LIB_DEP) +LIB_DEPS += $(SERVICES_LIB_DEP) $(PLATFORM_LIB_DEP) $(HAL_LIB_DEP) $(SYSTEM_LIB_DEP) $(COMMUNICATION_LIB_DEP) $(WIRING_LIB_DEP) $(CRYPTO_LIB_DEP) $(PROTO_DEFS_LIB_DEP) DEPENDENCIES += wiring_globals LIB_DEPENDENCIES += wiring_globals diff --git a/modules/b5som/system-part1/makefile b/modules/b5som/system-part1/makefile index d7b2dd0bfa..0a6af8aa62 100644 --- a/modules/b5som/system-part1/makefile +++ b/modules/b5som/system-part1/makefile @@ -5,15 +5,15 @@ BUILD_PATH_EXT = $(BUILD_TARGET_PLATFORM) HAL_LINK := PLATFORM_DFU = 0x30000 -DEPENDENCIES = newlib_nano modules/b5som/user-part modules/b5som/system-part1 dynalib services hal platform system wiring communication rt-dynalib crypto wiring_globals -LIB_DEPENDENCIES = services system wiring communication hal platform crypto wiring_globals +DEPENDENCIES = newlib_nano modules/b5som/user-part modules/b5som/system-part1 dynalib services hal platform system wiring communication rt-dynalib crypto proto_defs wiring_globals +LIB_DEPENDENCIES = services system wiring communication hal platform crypto proto_defs wiring_globals # newlib_nano is special in that it's linked automatically by the system, so no need to add it to the library path here MAKE_DEPENDENCIES = newlib_nano $(LIB_DEPENDENCIES) include ../modular.mk include $(PROJECT_ROOT)/build/platform-id.mk LIBS += $(LIB_DEPENDENCIES) -LIB_DEPS += $(SERVICES_LIB_DEP) $(PLATFORM_LIB_DEP) $(HAL_LIB_DEP) $(SYSTEM_LIB_DEP) $(COMMUNICATION_LIB_DEP) $(WIRING_LIB_DEP) $(CRYPTO_LIB_DEP) $(WIRING_GLOBALS_LIB_DEP) +LIB_DEPS += $(SERVICES_LIB_DEP) $(PLATFORM_LIB_DEP) $(HAL_LIB_DEP) $(SYSTEM_LIB_DEP) $(COMMUNICATION_LIB_DEP) $(WIRING_LIB_DEP) $(CRYPTO_LIB_DEP) $(PROTO_DEFS_LIB_DEP) $(WIRING_GLOBALS_LIB_DEP) LIB_DIRS += $(dir $(LIB_DEPS)) TARGET=elf bin lst hex size diff --git a/modules/boron/system-part1/makefile b/modules/boron/system-part1/makefile index c6e60bbf4d..51cfd534d5 100644 --- a/modules/boron/system-part1/makefile +++ b/modules/boron/system-part1/makefile @@ -5,15 +5,15 @@ BUILD_PATH_EXT = $(BUILD_TARGET_PLATFORM) HAL_LINK := PLATFORM_DFU = 0x30000 -DEPENDENCIES = newlib_nano modules/boron/user-part modules/boron/system-part1 dynalib services hal platform system wiring communication rt-dynalib crypto wiring_globals -LIB_DEPENDENCIES = services system wiring communication hal platform crypto wiring_globals +DEPENDENCIES = newlib_nano modules/boron/user-part modules/boron/system-part1 dynalib services hal platform system wiring communication rt-dynalib crypto proto_defs wiring_globals +LIB_DEPENDENCIES = services system wiring communication hal platform crypto proto_defs wiring_globals # newlib_nano is special in that it's linked automatically by the system, so no need to add it to the library path here MAKE_DEPENDENCIES = newlib_nano $(LIB_DEPENDENCIES) include ../modular.mk include $(PROJECT_ROOT)/build/platform-id.mk LIBS += $(LIB_DEPENDENCIES) -LIB_DEPS += $(SERVICES_LIB_DEP) $(PLATFORM_LIB_DEP) $(HAL_LIB_DEP) $(SYSTEM_LIB_DEP) $(COMMUNICATION_LIB_DEP) $(WIRING_LIB_DEP) $(CRYPTO_LIB_DEP) $(WIRING_GLOBALS_LIB_DEP) +LIB_DEPS += $(SERVICES_LIB_DEP) $(PLATFORM_LIB_DEP) $(HAL_LIB_DEP) $(SYSTEM_LIB_DEP) $(COMMUNICATION_LIB_DEP) $(WIRING_LIB_DEP) $(CRYPTO_LIB_DEP) $(WIRING_GLOBALS_LIB_DEP) $(PROTO_DEFS_LIB_DEP) LIB_DIRS += $(dir $(LIB_DEPS)) TARGET=elf bin lst hex size diff --git a/modules/tracker/system-part1/makefile b/modules/tracker/system-part1/makefile index f2144ef8e0..0e90eabb88 100644 --- a/modules/tracker/system-part1/makefile +++ b/modules/tracker/system-part1/makefile @@ -5,15 +5,15 @@ BUILD_PATH_EXT = $(BUILD_TARGET_PLATFORM) HAL_LINK := PLATFORM_DFU = 0x30000 -DEPENDENCIES = newlib_nano modules/tracker/user-part modules/tracker/system-part1 dynalib services hal platform system wiring communication rt-dynalib crypto wiring_globals -LIB_DEPENDENCIES = services system wiring communication hal platform crypto wiring_globals +DEPENDENCIES = newlib_nano modules/tracker/user-part modules/tracker/system-part1 dynalib services hal platform system wiring communication rt-dynalib crypto proto_defs wiring_globals +LIB_DEPENDENCIES = services system wiring communication hal platform crypto proto_defs wiring_globals # newlib_nano is special in that it's linked automatically by the system, so no need to add it to the library path here MAKE_DEPENDENCIES = newlib_nano $(LIB_DEPENDENCIES) include ../modular.mk include $(PROJECT_ROOT)/build/platform-id.mk LIBS += $(LIB_DEPENDENCIES) -LIB_DEPS += $(SERVICES_LIB_DEP) $(PLATFORM_LIB_DEP) $(HAL_LIB_DEP) $(SYSTEM_LIB_DEP) $(COMMUNICATION_LIB_DEP) $(WIRING_LIB_DEP) $(CRYPTO_LIB_DEP) $(WIRING_GLOBALS_LIB_DEP) +LIB_DEPS += $(SERVICES_LIB_DEP) $(PLATFORM_LIB_DEP) $(HAL_LIB_DEP) $(SYSTEM_LIB_DEP) $(COMMUNICATION_LIB_DEP) $(WIRING_LIB_DEP) $(CRYPTO_LIB_DEP) $(PROTO_DEFS_LIB_DEP) $(WIRING_GLOBALS_LIB_DEP) LIB_DIRS += $(dir $(LIB_DEPS)) TARGET=elf bin lst hex size diff --git a/modules/trackerm/system-part1/makefile b/modules/trackerm/system-part1/makefile index e53d18476f..cfaacdf2c8 100644 --- a/modules/trackerm/system-part1/makefile +++ b/modules/trackerm/system-part1/makefile @@ -4,15 +4,15 @@ PROJECT_ROOT = ../../.. BUILD_PATH_EXT = $(BUILD_TARGET_PLATFORM) HAL_LINK := -DEPENDENCIES = newlib_nano modules/trackerm/user-part modules/trackerm/system-part1 dynalib services hal platform system wiring communication rt-dynalib crypto wiring_globals -LIB_DEPENDENCIES = services system wiring communication hal platform crypto wiring_globals +DEPENDENCIES = newlib_nano modules/trackerm/user-part modules/trackerm/system-part1 dynalib services hal platform system wiring communication rt-dynalib crypto proto_defs wiring_globals +LIB_DEPENDENCIES = services system wiring communication hal platform crypto proto_defs wiring_globals # newlib_nano is special in that it's linked automatically by the system, so no need to add it to the library path here MAKE_DEPENDENCIES = newlib_nano $(LIB_DEPENDENCIES) include ../modular.mk include $(PROJECT_ROOT)/build/platform-id.mk LIBS += $(LIB_DEPENDENCIES) -LIB_DEPS += $(SERVICES_LIB_DEP) $(PLATFORM_LIB_DEP) $(HAL_LIB_DEP) $(SYSTEM_LIB_DEP) $(COMMUNICATION_LIB_DEP) $(WIRING_LIB_DEP) $(CRYPTO_LIB_DEP) $(WIRING_GLOBALS_LIB_DEP) +LIB_DEPS += $(SERVICES_LIB_DEP) $(PLATFORM_LIB_DEP) $(HAL_LIB_DEP) $(SYSTEM_LIB_DEP) $(COMMUNICATION_LIB_DEP) $(WIRING_LIB_DEP) $(CRYPTO_LIB_DEP) $(PROTO_DEFS_LIB_DEP) $(WIRING_GLOBALS_LIB_DEP) LIB_DIRS += $(dir $(LIB_DEPS)) TARGET=elf bin lst hex size diff --git a/modules/tron/system-part1/makefile b/modules/tron/system-part1/makefile index fa557c2228..5dccb0ab2f 100644 --- a/modules/tron/system-part1/makefile +++ b/modules/tron/system-part1/makefile @@ -4,15 +4,15 @@ PROJECT_ROOT = ../../.. BUILD_PATH_EXT = $(BUILD_TARGET_PLATFORM) HAL_LINK := -DEPENDENCIES = newlib_nano modules/tron/user-part modules/tron/system-part1 dynalib services hal platform system wiring communication rt-dynalib crypto wiring_globals -LIB_DEPENDENCIES = services system wiring communication hal platform crypto wiring_globals +DEPENDENCIES = newlib_nano modules/tron/user-part modules/tron/system-part1 dynalib services hal platform system wiring communication rt-dynalib crypto proto_defs wiring_globals +LIB_DEPENDENCIES = services system wiring communication hal platform crypto proto_defs wiring_globals # newlib_nano is special in that it's linked automatically by the system, so no need to add it to the library path here MAKE_DEPENDENCIES = newlib_nano $(LIB_DEPENDENCIES) include ../modular.mk include $(PROJECT_ROOT)/build/platform-id.mk LIBS += $(LIB_DEPENDENCIES) -LIB_DEPS += $(SERVICES_LIB_DEP) $(PLATFORM_LIB_DEP) $(HAL_LIB_DEP) $(SYSTEM_LIB_DEP) $(COMMUNICATION_LIB_DEP) $(WIRING_LIB_DEP) $(CRYPTO_LIB_DEP) $(WIRING_GLOBALS_LIB_DEP) +LIB_DEPS += $(SERVICES_LIB_DEP) $(PLATFORM_LIB_DEP) $(HAL_LIB_DEP) $(SYSTEM_LIB_DEP) $(COMMUNICATION_LIB_DEP) $(WIRING_LIB_DEP) $(CRYPTO_LIB_DEP) $(PROTO_DEFS_LIB_DEP) $(WIRING_GLOBALS_LIB_DEP) LIB_DIRS += $(dir $(LIB_DEPS)) TARGET=elf bin lst hex size diff --git a/proto b/proto deleted file mode 160000 index 0fa2944b52..0000000000 --- a/proto +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0fa2944b52b18d891ef3af2998bb5d0ad7ff2048 diff --git a/proto_defs/build.mk b/proto_defs/build.mk new file mode 100644 index 0000000000..421351a452 --- /dev/null +++ b/proto_defs/build.mk @@ -0,0 +1,2 @@ +CPPSRC += $(call target_files,$(PROTO_DEFS_MODULE_PATH)/src,*.cpp) +CSRC += $(call target_files,$(PROTO_DEFS_MODULE_PATH)/src,*.c) diff --git a/proto_defs/gen_proto.sh b/proto_defs/gen_proto.sh new file mode 100755 index 0000000000..fa9808e047 --- /dev/null +++ b/proto_defs/gen_proto.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# Note for macOS users: +# +# 1. The following dependencies are required to build the protocol files using the nanopb plugin: +# +# brew install protobuf python +# pip2 install protobuf +# +# 2. Make sure your system Python can find Python modules installed via Homebrew: +# +# mkdir -p ~/Library/Python/2.7/lib/python/site-packages +# echo 'import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")' >> ~/Library/Python/2.7/lib/python/site-packages/homebrew.pth + +set -e + +DEVICE_OS_DIR="$(cd "$(dirname "$0")/.." && pwd)" +PROTO_DEFS_DIR="$DEVICE_OS_DIR/proto_defs" +SHARED_DIR="$PROTO_DEFS_DIR/shared" +INTERNAL_DIR="$PROTO_DEFS_DIR/internal" +DEST_DIR="$PROTO_DEFS_DIR/src" + +NANOPB_DIR="$DEVICE_OS_DIR/third_party/nanopb/nanopb" +NANOPB_PLUGIN_DIR="$NANOPB_DIR/generator/protoc-gen-nanopb" + +gen_proto() { + echo "Compiling $1" + protoc -I"$NANOPB_DIR/generator/proto" \ + -I"$SHARED_DIR" \ + -I"$(dirname "$1")" \ + --plugin="protoc-gen-nanopb=$NANOPB_PLUGIN_DIR" \ + --nanopb_out="${DEST_DIR}" "$1" +} + +# Control requests +gen_proto "${SHARED_DIR}/control/extensions.proto" +gen_proto "${SHARED_DIR}/control/common.proto" +gen_proto "${SHARED_DIR}/control/config.proto" +gen_proto "${SHARED_DIR}/control/wifi.proto" +gen_proto "${SHARED_DIR}/control/wifi_new.proto" +gen_proto "${SHARED_DIR}/control/cellular.proto" +gen_proto "${SHARED_DIR}/control/network.proto" +gen_proto "${SHARED_DIR}/control/storage.proto" +gen_proto "${SHARED_DIR}/control/cloud.proto" + +# Cloud protocol +gen_proto "${SHARED_DIR}/cloud/cloud.proto" + +# Internal definitions +gen_proto "${INTERNAL_DIR}/network_config.proto" diff --git a/proto_defs/import.mk b/proto_defs/import.mk new file mode 100644 index 0000000000..f81b61de9a --- /dev/null +++ b/proto_defs/import.mk @@ -0,0 +1,7 @@ +PROTO_DEFS_MODULE_NAME = proto_defs +PROTO_DEFS_MODULE_PATH ?= $(PROJECT_ROOT)/$(PROTO_DEFS_MODULE_NAME) +include $(call rwildcard,$(PROTO_DEFS_MODULE_PATH)/,include.mk) + +PROTO_DEFS_BUILD_PATH_EXT = $(BUILD_TARGET_PLATFORM) +PROTO_DEFS_LIB_DIR = $(BUILD_PATH_BASE)/$(PROTO_DEFS_MODULE_NAME)/$(PROTO_DEFS_BUILD_PATH_EXT) +PROTO_DEFS_LIB_DEP = $(PROTO_DEFS_LIB_DIR)/lib$(PROTO_DEFS_MODULE_NAME).a diff --git a/proto_defs/include.mk b/proto_defs/include.mk new file mode 100644 index 0000000000..0d6cd95e90 --- /dev/null +++ b/proto_defs/include.mk @@ -0,0 +1 @@ +INCLUDE_DIRS += $(PROTO_DEFS_MODULE_PATH)/src diff --git a/proto_defs/internal/network_config.proto b/proto_defs/internal/network_config.proto new file mode 100644 index 0000000000..1e7238b3da --- /dev/null +++ b/proto_defs/internal/network_config.proto @@ -0,0 +1,25 @@ +syntax = "proto3"; + +package particle.firmware; + +import "control/wifi_new.proto"; +import "control/cellular.proto"; + +import "nanopb.proto"; + +message WifiConfig { + message Network { + string ssid = 1; + bytes bssid = 2 [(nanopb).max_size = 6]; + ctrl.wifi.Security security = 3; + ctrl.wifi.Credentials credentials = 4; + } + + repeated Network networks = 1; +} + +message CellularConfig { + ctrl.cellular.AccessPoint internal_sim = 1; + ctrl.cellular.AccessPoint external_sim = 2; + ctrl.cellular.SimType active_sim = 3; +} diff --git a/proto_defs/makefile b/proto_defs/makefile new file mode 100644 index 0000000000..385c404890 --- /dev/null +++ b/proto_defs/makefile @@ -0,0 +1,12 @@ +MODULE = proto_defs +PROTO_DEFS_MODULE_PATH = . + +# Target this makefile is building. +TARGET_TYPE = a + +BUILD_PATH_EXT = $(PROTO_DEFS_BUILD_PATH_EXT) + +DEPENDENCIES = third_party/nanopb +MAKE_DEPENDENCIES = third_party/nanopb + +include ../build/arm-tlm.mk diff --git a/proto_defs/shared b/proto_defs/shared new file mode 160000 index 0000000000..9050062b73 --- /dev/null +++ b/proto_defs/shared @@ -0,0 +1 @@ +Subproject commit 9050062b733b8bf6f5335a1441b170d2392b7d36 diff --git a/proto_defs/src/cloud/cloud.pb.c b/proto_defs/src/cloud/cloud.pb.c new file mode 100644 index 0000000000..f0e819c244 --- /dev/null +++ b/proto_defs/src/cloud/cloud.pb.c @@ -0,0 +1,15 @@ +/* Automatically generated nanopb constant definitions */ +/* Generated by nanopb-0.4.5 */ + +#include "cloud/cloud.pb.h" +#if PB_PROTO_HEADER_VERSION != 40 +#error Regenerate this file with the current version of nanopb generator. +#endif + +PB_BIND(particle_cloud_ServerMovedPermanentlyRequest, particle_cloud_ServerMovedPermanentlyRequest, AUTO) + + +PB_BIND(particle_cloud_ServerMovedPermanentlyResponse, particle_cloud_ServerMovedPermanentlyResponse, AUTO) + + + diff --git a/proto_defs/src/cloud/cloud.pb.h b/proto_defs/src/cloud/cloud.pb.h new file mode 100644 index 0000000000..c22a72813f --- /dev/null +++ b/proto_defs/src/cloud/cloud.pb.h @@ -0,0 +1,86 @@ +/* Automatically generated nanopb header */ +/* Generated by nanopb-0.4.5 */ + +#ifndef PB_PARTICLE_CLOUD_CLOUD_CLOUD_PB_H_INCLUDED +#define PB_PARTICLE_CLOUD_CLOUD_CLOUD_PB_H_INCLUDED +#include + +#if PB_PROTO_HEADER_VERSION != 40 +#error Regenerate this file with the current version of nanopb generator. +#endif + +/* Struct definitions */ +/* * + A response for a ServerMovedPermanentlyRequest. */ +typedef struct _particle_cloud_ServerMovedPermanentlyResponse { + char dummy_field; +} particle_cloud_ServerMovedPermanentlyResponse; + +/* * + A request sent to the device to notify it that it must disconnect from the current server and + use another server for further connections to the Cloud. */ +typedef struct _particle_cloud_ServerMovedPermanentlyRequest { + /* * + The address of the new server. + + The address can be a domain name or IP address. A domain name may contain placeholder arguments + such as `$id`. */ + pb_callback_t server_addr; + /* * + The port number of the new server. The default value is 5684. */ + uint32_t server_port; + /* * + The public key of the new server in DER format. */ + pb_callback_t server_pub_key; + /* * + The signature of the server details. */ + pb_callback_t sign; +} particle_cloud_ServerMovedPermanentlyRequest; + + +#ifdef __cplusplus +extern "C" { +#endif + +/* Initializer values for message structs */ +#define particle_cloud_ServerMovedPermanentlyRequest_init_default {{{NULL}, NULL}, 0, {{NULL}, NULL}, {{NULL}, NULL}} +#define particle_cloud_ServerMovedPermanentlyResponse_init_default {0} +#define particle_cloud_ServerMovedPermanentlyRequest_init_zero {{{NULL}, NULL}, 0, {{NULL}, NULL}, {{NULL}, NULL}} +#define particle_cloud_ServerMovedPermanentlyResponse_init_zero {0} + +/* Field tags (for use in manual encoding/decoding) */ +#define particle_cloud_ServerMovedPermanentlyRequest_server_addr_tag 1 +#define particle_cloud_ServerMovedPermanentlyRequest_server_port_tag 2 +#define particle_cloud_ServerMovedPermanentlyRequest_server_pub_key_tag 3 +#define particle_cloud_ServerMovedPermanentlyRequest_sign_tag 4 + +/* Struct field encoding specification for nanopb */ +#define particle_cloud_ServerMovedPermanentlyRequest_FIELDLIST(X, a) \ +X(a, CALLBACK, SINGULAR, STRING, server_addr, 1) \ +X(a, STATIC, SINGULAR, UINT32, server_port, 2) \ +X(a, CALLBACK, SINGULAR, BYTES, server_pub_key, 3) \ +X(a, CALLBACK, SINGULAR, BYTES, sign, 4) +#define particle_cloud_ServerMovedPermanentlyRequest_CALLBACK pb_default_field_callback +#define particle_cloud_ServerMovedPermanentlyRequest_DEFAULT NULL + +#define particle_cloud_ServerMovedPermanentlyResponse_FIELDLIST(X, a) \ + +#define particle_cloud_ServerMovedPermanentlyResponse_CALLBACK NULL +#define particle_cloud_ServerMovedPermanentlyResponse_DEFAULT NULL + +extern const pb_msgdesc_t particle_cloud_ServerMovedPermanentlyRequest_msg; +extern const pb_msgdesc_t particle_cloud_ServerMovedPermanentlyResponse_msg; + +/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ +#define particle_cloud_ServerMovedPermanentlyRequest_fields &particle_cloud_ServerMovedPermanentlyRequest_msg +#define particle_cloud_ServerMovedPermanentlyResponse_fields &particle_cloud_ServerMovedPermanentlyResponse_msg + +/* Maximum encoded size of messages (where known) */ +/* particle_cloud_ServerMovedPermanentlyRequest_size depends on runtime parameters */ +#define particle_cloud_ServerMovedPermanentlyResponse_size 0 + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif diff --git a/system/src/control/proto/cellular.pb.c b/proto_defs/src/control/cellular.pb.c similarity index 97% rename from system/src/control/proto/cellular.pb.c rename to proto_defs/src/control/cellular.pb.c index 0e24702da1..f0f3b7e8b6 100644 --- a/system/src/control/proto/cellular.pb.c +++ b/proto_defs/src/control/cellular.pb.c @@ -1,7 +1,7 @@ /* Automatically generated nanopb constant definitions */ /* Generated by nanopb-0.4.5 */ -#include "cellular.pb.h" +#include "control/cellular.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif diff --git a/system/src/control/proto/cellular.pb.h b/proto_defs/src/control/cellular.pb.h similarity index 98% rename from system/src/control/proto/cellular.pb.h rename to proto_defs/src/control/cellular.pb.h index 4a7389b18c..1051abc85f 100644 --- a/system/src/control/proto/cellular.pb.h +++ b/proto_defs/src/control/cellular.pb.h @@ -1,11 +1,10 @@ /* Automatically generated nanopb header */ /* Generated by nanopb-0.4.5 */ -#ifndef PB_PARTICLE_CTRL_CELLULAR_CELLULAR_PB_H_INCLUDED -#define PB_PARTICLE_CTRL_CELLULAR_CELLULAR_PB_H_INCLUDED +#ifndef PB_PARTICLE_CTRL_CELLULAR_CONTROL_CELLULAR_PB_H_INCLUDED +#define PB_PARTICLE_CTRL_CELLULAR_CONTROL_CELLULAR_PB_H_INCLUDED #include -#include "extensions.pb.h" -#include "common.pb.h" +#include "control/extensions.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. diff --git a/system/src/control/proto/cloud.pb.c b/proto_defs/src/control/cloud.pb.c similarity index 96% rename from system/src/control/proto/cloud.pb.c rename to proto_defs/src/control/cloud.pb.c index c398b532a3..155e7f6310 100644 --- a/system/src/control/proto/cloud.pb.c +++ b/proto_defs/src/control/cloud.pb.c @@ -1,7 +1,7 @@ /* Automatically generated nanopb constant definitions */ /* Generated by nanopb-0.4.5 */ -#include "cloud.pb.h" +#include "control/cloud.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif diff --git a/system/src/control/proto/cloud.pb.h b/proto_defs/src/control/cloud.pb.h similarity index 97% rename from system/src/control/proto/cloud.pb.h rename to proto_defs/src/control/cloud.pb.h index aff2435af2..7cb797d54c 100644 --- a/system/src/control/proto/cloud.pb.h +++ b/proto_defs/src/control/cloud.pb.h @@ -1,10 +1,10 @@ /* Automatically generated nanopb header */ /* Generated by nanopb-0.4.5 */ -#ifndef PB_PARTICLE_CTRL_CLOUD_CLOUD_PB_H_INCLUDED -#define PB_PARTICLE_CTRL_CLOUD_CLOUD_PB_H_INCLUDED +#ifndef PB_PARTICLE_CTRL_CLOUD_CONTROL_CLOUD_PB_H_INCLUDED +#define PB_PARTICLE_CTRL_CLOUD_CONTROL_CLOUD_PB_H_INCLUDED #include -#include "extensions.pb.h" +#include "control/extensions.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. diff --git a/system/src/control/proto/common.pb.c b/proto_defs/src/control/common.pb.c similarity index 93% rename from system/src/control/proto/common.pb.c rename to proto_defs/src/control/common.pb.c index 46ed78907d..046182f6f7 100644 --- a/system/src/control/proto/common.pb.c +++ b/proto_defs/src/control/common.pb.c @@ -1,7 +1,7 @@ /* Automatically generated nanopb constant definitions */ /* Generated by nanopb-0.4.5 */ -#include "common.pb.h" +#include "control/common.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif diff --git a/system/src/control/proto/common.pb.h b/proto_defs/src/control/common.pb.h similarity index 97% rename from system/src/control/proto/common.pb.h rename to proto_defs/src/control/common.pb.h index e7683877c2..a6ac431d0e 100644 --- a/system/src/control/proto/common.pb.h +++ b/proto_defs/src/control/common.pb.h @@ -1,10 +1,10 @@ /* Automatically generated nanopb header */ /* Generated by nanopb-0.4.5 */ -#ifndef PB_PARTICLE_CTRL_COMMON_PB_H_INCLUDED -#define PB_PARTICLE_CTRL_COMMON_PB_H_INCLUDED +#ifndef PB_PARTICLE_CTRL_CONTROL_COMMON_PB_H_INCLUDED +#define PB_PARTICLE_CTRL_CONTROL_COMMON_PB_H_INCLUDED #include -#include "extensions.pb.h" +#include "control/extensions.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. diff --git a/system/src/control/proto/config.pb.c b/proto_defs/src/control/config.pb.c similarity index 99% rename from system/src/control/proto/config.pb.c rename to proto_defs/src/control/config.pb.c index 31b54770d0..6e175d6024 100644 --- a/system/src/control/proto/config.pb.c +++ b/proto_defs/src/control/config.pb.c @@ -1,7 +1,7 @@ /* Automatically generated nanopb constant definitions */ /* Generated by nanopb-0.4.5 */ -#include "config.pb.h" +#include "control/config.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif diff --git a/system/src/control/proto/config.pb.h b/proto_defs/src/control/config.pb.h similarity index 99% rename from system/src/control/proto/config.pb.h rename to proto_defs/src/control/config.pb.h index c68bbbc881..b312b5d21d 100644 --- a/system/src/control/proto/config.pb.h +++ b/proto_defs/src/control/config.pb.h @@ -1,11 +1,10 @@ /* Automatically generated nanopb header */ /* Generated by nanopb-0.4.5 */ -#ifndef PB_PARTICLE_CTRL_CONFIG_PB_H_INCLUDED -#define PB_PARTICLE_CTRL_CONFIG_PB_H_INCLUDED +#ifndef PB_PARTICLE_CTRL_CONTROL_CONFIG_PB_H_INCLUDED +#define PB_PARTICLE_CTRL_CONTROL_CONFIG_PB_H_INCLUDED #include -#include "extensions.pb.h" -#include "common.pb.h" +#include "control/extensions.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. diff --git a/system/src/control/proto/extensions.pb.c b/proto_defs/src/control/extensions.pb.c similarity index 85% rename from system/src/control/proto/extensions.pb.c rename to proto_defs/src/control/extensions.pb.c index aeb64f7567..1a69a6932a 100644 --- a/system/src/control/proto/extensions.pb.c +++ b/proto_defs/src/control/extensions.pb.c @@ -1,7 +1,7 @@ /* Automatically generated nanopb constant definitions */ /* Generated by nanopb-0.4.5 */ -#include "extensions.pb.h" +#include "control/extensions.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif diff --git a/system/src/control/proto/extensions.pb.h b/proto_defs/src/control/extensions.pb.h similarity index 86% rename from system/src/control/proto/extensions.pb.h rename to proto_defs/src/control/extensions.pb.h index 28c1fc6854..581ffa8730 100644 --- a/system/src/control/proto/extensions.pb.h +++ b/proto_defs/src/control/extensions.pb.h @@ -1,8 +1,8 @@ /* Automatically generated nanopb header */ /* Generated by nanopb-0.4.5 */ -#ifndef PB_EXTENSIONS_PB_H_INCLUDED -#define PB_EXTENSIONS_PB_H_INCLUDED +#ifndef PB_CONTROL_EXTENSIONS_PB_H_INCLUDED +#define PB_CONTROL_EXTENSIONS_PB_H_INCLUDED #include #if PB_PROTO_HEADER_VERSION != 40 diff --git a/system/src/control/proto/network.pb.c b/proto_defs/src/control/network.pb.c similarity index 98% rename from system/src/control/proto/network.pb.c rename to proto_defs/src/control/network.pb.c index 36b6757ce9..082670ec04 100644 --- a/system/src/control/proto/network.pb.c +++ b/proto_defs/src/control/network.pb.c @@ -1,7 +1,7 @@ /* Automatically generated nanopb constant definitions */ /* Generated by nanopb-0.4.5 */ -#include "network.pb.h" +#include "control/network.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif diff --git a/system/src/control/proto/network.pb.h b/proto_defs/src/control/network.pb.h similarity index 99% rename from system/src/control/proto/network.pb.h rename to proto_defs/src/control/network.pb.h index c21c2c34ce..6bde073c7f 100644 --- a/system/src/control/proto/network.pb.h +++ b/proto_defs/src/control/network.pb.h @@ -1,11 +1,11 @@ /* Automatically generated nanopb header */ /* Generated by nanopb-0.4.5 */ -#ifndef PB_PARTICLE_CTRL_NETWORK_PB_H_INCLUDED -#define PB_PARTICLE_CTRL_NETWORK_PB_H_INCLUDED +#ifndef PB_PARTICLE_CTRL_CONTROL_NETWORK_PB_H_INCLUDED +#define PB_PARTICLE_CTRL_CONTROL_NETWORK_PB_H_INCLUDED #include -#include "extensions.pb.h" -#include "common.pb.h" +#include "control/extensions.pb.h" +#include "control/common.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. diff --git a/system/src/control/proto/storage.pb.c b/proto_defs/src/control/storage.pb.c similarity index 98% rename from system/src/control/proto/storage.pb.c rename to proto_defs/src/control/storage.pb.c index eb0ca828e1..cf96996e8a 100644 --- a/system/src/control/proto/storage.pb.c +++ b/proto_defs/src/control/storage.pb.c @@ -1,7 +1,7 @@ /* Automatically generated nanopb constant definitions */ /* Generated by nanopb-0.4.5 */ -#include "storage.pb.h" +#include "control/storage.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif diff --git a/system/src/control/proto/storage.pb.h b/proto_defs/src/control/storage.pb.h similarity index 99% rename from system/src/control/proto/storage.pb.h rename to proto_defs/src/control/storage.pb.h index 1751e3e5af..7c896303b9 100644 --- a/system/src/control/proto/storage.pb.h +++ b/proto_defs/src/control/storage.pb.h @@ -1,11 +1,10 @@ /* Automatically generated nanopb header */ /* Generated by nanopb-0.4.5 */ -#ifndef PB_PARTICLE_CTRL_STORAGE_PB_H_INCLUDED -#define PB_PARTICLE_CTRL_STORAGE_PB_H_INCLUDED +#ifndef PB_PARTICLE_CTRL_CONTROL_STORAGE_PB_H_INCLUDED +#define PB_PARTICLE_CTRL_CONTROL_STORAGE_PB_H_INCLUDED #include -#include "extensions.pb.h" -#include "common.pb.h" +#include "control/extensions.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. diff --git a/system/src/control/proto/wifi.pb.c b/proto_defs/src/control/wifi.pb.c similarity index 98% rename from system/src/control/proto/wifi.pb.c rename to proto_defs/src/control/wifi.pb.c index 04b51e42b8..4eed386e10 100644 --- a/system/src/control/proto/wifi.pb.c +++ b/proto_defs/src/control/wifi.pb.c @@ -1,7 +1,7 @@ /* Automatically generated nanopb constant definitions */ /* Generated by nanopb-0.4.5 */ -#include "wifi.pb.h" +#include "control/wifi.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif diff --git a/system/src/control/proto/wifi.pb.h b/proto_defs/src/control/wifi.pb.h similarity index 99% rename from system/src/control/proto/wifi.pb.h rename to proto_defs/src/control/wifi.pb.h index 04270d0be8..33f9232afe 100644 --- a/system/src/control/proto/wifi.pb.h +++ b/proto_defs/src/control/wifi.pb.h @@ -1,11 +1,10 @@ /* Automatically generated nanopb header */ /* Generated by nanopb-0.4.5 */ -#ifndef PB_PARTICLE_CTRL_WIFI_PB_H_INCLUDED -#define PB_PARTICLE_CTRL_WIFI_PB_H_INCLUDED +#ifndef PB_PARTICLE_CTRL_CONTROL_WIFI_PB_H_INCLUDED +#define PB_PARTICLE_CTRL_CONTROL_WIFI_PB_H_INCLUDED #include -#include "extensions.pb.h" -#include "common.pb.h" +#include "control/extensions.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. diff --git a/system/src/control/proto/wifi_new.pb.c b/proto_defs/src/control/wifi_new.pb.c similarity index 98% rename from system/src/control/proto/wifi_new.pb.c rename to proto_defs/src/control/wifi_new.pb.c index 96de79d3c3..f69bb93586 100644 --- a/system/src/control/proto/wifi_new.pb.c +++ b/proto_defs/src/control/wifi_new.pb.c @@ -1,7 +1,7 @@ /* Automatically generated nanopb constant definitions */ /* Generated by nanopb-0.4.5 */ -#include "wifi_new.pb.h" +#include "control/wifi_new.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif diff --git a/system/src/control/proto/wifi_new.pb.h b/proto_defs/src/control/wifi_new.pb.h similarity index 99% rename from system/src/control/proto/wifi_new.pb.h rename to proto_defs/src/control/wifi_new.pb.h index b1857bea8e..6107273f8f 100644 --- a/system/src/control/proto/wifi_new.pb.h +++ b/proto_defs/src/control/wifi_new.pb.h @@ -1,11 +1,10 @@ /* Automatically generated nanopb header */ /* Generated by nanopb-0.4.5 */ -#ifndef PB_PARTICLE_CTRL_WIFI_WIFI_NEW_PB_H_INCLUDED -#define PB_PARTICLE_CTRL_WIFI_WIFI_NEW_PB_H_INCLUDED +#ifndef PB_PARTICLE_CTRL_WIFI_CONTROL_WIFI_NEW_PB_H_INCLUDED +#define PB_PARTICLE_CTRL_WIFI_CONTROL_WIFI_NEW_PB_H_INCLUDED #include -#include "extensions.pb.h" -#include "common.pb.h" +#include "control/extensions.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. diff --git a/system/src/control/proto/internal.pb.c b/proto_defs/src/network_config.pb.c similarity index 93% rename from system/src/control/proto/internal.pb.c rename to proto_defs/src/network_config.pb.c index 87f4305d56..c1cdf56fce 100644 --- a/system/src/control/proto/internal.pb.c +++ b/proto_defs/src/network_config.pb.c @@ -1,7 +1,7 @@ /* Automatically generated nanopb constant definitions */ /* Generated by nanopb-0.4.5 */ -#include "internal.pb.h" +#include "network_config.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif diff --git a/system/src/control/proto/internal.pb.h b/proto_defs/src/network_config.pb.h similarity index 96% rename from system/src/control/proto/internal.pb.h rename to proto_defs/src/network_config.pb.h index 509bcd8728..3957b45d02 100644 --- a/system/src/control/proto/internal.pb.h +++ b/proto_defs/src/network_config.pb.h @@ -1,12 +1,11 @@ /* Automatically generated nanopb header */ /* Generated by nanopb-0.4.5 */ -#ifndef PB_PARTICLE_FIRMWARE_INTERNAL_PB_H_INCLUDED -#define PB_PARTICLE_FIRMWARE_INTERNAL_PB_H_INCLUDED +#ifndef PB_PARTICLE_FIRMWARE_NETWORK_CONFIG_PB_H_INCLUDED +#define PB_PARTICLE_FIRMWARE_NETWORK_CONFIG_PB_H_INCLUDED #include -#include "wifi_new.pb.h" -#include "cellular.pb.h" -#include "common.pb.h" +#include "control/wifi_new.pb.h" +#include "control/cellular.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. diff --git a/services/inc/system_defs.h b/services/inc/system_defs.h index 776f373e08..4edcbd8cea 100644 --- a/services/inc/system_defs.h +++ b/services/inc/system_defs.h @@ -63,7 +63,8 @@ typedef enum System_Reset_Reason { RESET_REASON_SAFE_MODE = 110, ///< Safe mode requested. RESET_REASON_DFU_MODE = 120, ///< DFU mode requested. RESET_REASON_PANIC = 130, ///< System panic. - RESET_REASON_USER = 140 ///< User-requested reset. + RESET_REASON_USER = 140, ///< User-requested reset. + RESET_REASON_CONFIG_UPDATE = 150 ///< Reset to apply configuration changes. } System_Reset_Reason; /** @@ -77,7 +78,8 @@ typedef enum cloud_disconnect_reason { CLOUD_DISCONNECT_REASON_LISTENING = 4, ///< Disconnected to enter the listening mode. CLOUD_DISCONNECT_REASON_SYSTEM_RESET = 5, ///< Disconnected due to a system reset. CLOUD_DISCONNECT_REASON_SLEEP = 6, ///< Disconnected to enter a sleep mode. - CLOUD_DISCONNECT_REASON_UNKNOWN = 7 ///< Unspecified disconnection reason. + CLOUD_DISCONNECT_REASON_UNKNOWN = 7, ///< Unspecified disconnection reason. + CLOUD_DISCONNECT_REASON_SERVER_MOVED = 8 ///< Server address/key changed. } cloud_disconnect_reason; /** diff --git a/services/makefile b/services/makefile index 18284813d7..5be1fcddd0 100644 --- a/services/makefile +++ b/services/makefile @@ -5,7 +5,7 @@ SERVICES_MODULE_PATH=. # Target this makefile is building. TARGET_TYPE = a BUILD_PATH_EXT=$(SERVICES_BUILD_PATH_EXT) -DEPENDENCIES = platform hal system wiring third_party/nanopb dynalib -MAKE_DEPENDENCIES = third_party/nanopb +DEPENDENCIES = platform hal system wiring dynalib +MAKE_DEPENDENCIES = include ../build/arm-tlm.mk diff --git a/system/inc/system_cloud.h b/system/inc/system_cloud.h index 457b37d332..01feb07bb8 100644 --- a/system/inc/system_cloud.h +++ b/system/inc/system_cloud.h @@ -34,28 +34,31 @@ #define DEFAULT_CLOUD_EVENT_TTL 60 +namespace particle { + enum ParticleKeyErrorFlag: uint32_t { - NO_ERROR = 0, - PUBLIC_SERVER_KEY_BLANK = 1, - PUBLIC_SERVER_KEY_CORRUPTED = 2, - SERVER_ADDRESS_BLANK = 4, - SERVER_ADDRESS_CORRUPTED = 8, - PUBLIC_DEVICE_KEY_BLANK = 16, - PUBLIC_DEVICE_KEY_CORRUPTED = 32, - PRIVATE_DEVICE_KEY_BLANK = 64, - PRIVATE_DEVICE_KEY_CORRUPTED = 128 + NO_ERROR = 0, + // PUBLIC_SERVER_KEY_BLANK = 1, + PUBLIC_SERVER_KEY_CORRUPTED = 2, + // SERVER_ADDRESS_BLANK = 4, + SERVER_ADDRESS_CORRUPTED = 8, + // PUBLIC_DEVICE_KEY_BLANK = 16, + // PUBLIC_DEVICE_KEY_CORRUPTED = 32, + // PRIVATE_DEVICE_KEY_BLANK = 64, + // PRIVATE_DEVICE_KEY_CORRUPTED = 128 + SERVER_SETTINGS_CORRUPTED = PUBLIC_SERVER_KEY_CORRUPTED | SERVER_ADDRESS_CORRUPTED }; +const system_tick_t NOW = static_cast(-1); + +} // namespace particle + typedef enum { CLOUD_VAR_BOOLEAN = 1, CLOUD_VAR_INT = 2, CLOUD_VAR_STRING = 4, CLOUD_VAR_DOUBLE = 9 } Spark_Data_TypeDef; -namespace particle { - static const system_tick_t NOW = static_cast(-1); -} - template struct CloudVariableType { }; @@ -355,15 +358,6 @@ int spark_get_connection_property(unsigned property, void* data, size_t* size, v int spark_set_random_seed_from_cloud_handler(void (*handler)(unsigned int), void* reserved); -extern const unsigned char backup_udp_public_server_key[]; -extern const size_t backup_udp_public_server_key_size; - -extern const unsigned char backup_udp_public_server_address[]; -extern const size_t backup_udp_public_server_address_size; - -extern const unsigned char backup_tcp_public_server_key[294]; -extern const unsigned char backup_tcp_public_server_address[18]; - #define SPARK_BUF_LEN 600 //#define SPARK_SERVER_IP "54.235.79.249" diff --git a/system/makefile b/system/makefile index 2846483452..fd022076f6 100644 --- a/system/makefile +++ b/system/makefile @@ -7,7 +7,7 @@ ifeq ("","$(SPARK_NO_PLATFORM)") DEPENDENCIES += platform CFLAGS += -DSPARK_PLATFORM endif -DEPENDENCIES = platform hal services third_party/nanopb communication wiring dynalib crypto +DEPENDENCIES = platform hal services communication wiring dynalib crypto proto_defs TARGET_TYPE = a MAKE_DEPENDENCIES = diff --git a/system/src/control/cellular.cpp b/system/src/control/cellular.cpp index 94229de85f..5ec6730149 100644 --- a/system/src/control/cellular.cpp +++ b/system/src/control/cellular.cpp @@ -29,7 +29,7 @@ #include "check.h" -#include "cellular.pb.h" +#include "control/cellular.pb.h" #define PB(_name) particle_ctrl_cellular_##_name diff --git a/system/src/control/cloud.cpp b/system/src/control/cloud.cpp index 034656d7b5..2c857cc986 100644 --- a/system/src/control/cloud.cpp +++ b/system/src/control/cloud.cpp @@ -25,7 +25,7 @@ #include "spark_wiring_diagnostics.h" -#include "cloud.pb.h" +#include "control/cloud.pb.h" #define PB(_name) particle_ctrl_cloud_##_name #define PB_FIELDS(_name) particle_ctrl_cloud_##_name##_fields diff --git a/system/src/control/common.h b/system/src/control/common.h index 72b78c5175..8df0a2e2e1 100644 --- a/system/src/control/common.h +++ b/system/src/control/common.h @@ -29,7 +29,7 @@ #include #include -#include "proto/common.pb.h" +#include "control/common.pb.h" namespace particle { namespace control { diff --git a/system/src/control/config.cpp b/system/src/control/config.cpp index f4f6a41fdf..ddedcac642 100644 --- a/system/src/control/config.cpp +++ b/system/src/control/config.cpp @@ -42,7 +42,7 @@ #include "network/ncp/wifi/wifi_ncp_client.h" #endif -#include "config.pb.h" +#include "control/config.pb.h" #include diff --git a/system/src/control/network.cpp b/system/src/control/network.cpp index fc96c81b31..78f2cace89 100644 --- a/system/src/control/network.cpp +++ b/system/src/control/network.cpp @@ -32,7 +32,7 @@ #include "check.h" #include "debug.h" -#include "network.pb.h" +#include "control/network.pb.h" #include diff --git a/system/src/control/proto/build.sh b/system/src/control/proto/build.sh deleted file mode 100755 index 681ae19bf4..0000000000 --- a/system/src/control/proto/build.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -# Note for macOS users: -# -# 1. The following dependencies are required to build the protocol files using the nanopb plugin: -# -# brew install protobuf python -# pip2 install protobuf -# -# 2. Make sure your system Python can find Python modules installed via Homebrew: -# -# mkdir -p ~/Library/Python/2.7/lib/python/site-packages -# echo 'import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")' >> ~/Library/Python/2.7/lib/python/site-packages/homebrew.pth - -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -FIRMWARE_ROOT_DIR="${DIR}/../../../.." - -PROTO_DIR="${FIRMWARE_ROOT_DIR}/proto/control" -NANOPB_PATH="${FIRMWARE_ROOT_DIR}/third_party/nanopb/nanopb" -PROTOC_NANOPB_PLUGIN="${NANOPB_PATH}/generator/protoc-gen-nanopb" -PROTOC_INCLUDE_PATH=" - -I${PROTO_DIR} \ - -I${NANOPB_PATH}/generator \ - -I${NANOPB_PATH}/generator/proto" - -gen_proto() { - protoc ${PROTOC_INCLUDE_PATH} --plugin=protoc-gen-nanopb=${PROTOC_NANOPB_PLUGIN} --nanopb_out=${DIR} "$1" -} - -gen_proto "${PROTO_DIR}/extensions.proto" -gen_proto "${PROTO_DIR}/common.proto" -gen_proto "${PROTO_DIR}/control.proto" -gen_proto "${PROTO_DIR}/config.proto" -gen_proto "${PROTO_DIR}/wifi.proto" -gen_proto "${PROTO_DIR}/wifi_new.proto" -gen_proto "${PROTO_DIR}/cellular.proto" -gen_proto "${PROTO_DIR}/network.proto" -gen_proto "${PROTO_DIR}/storage.proto" -gen_proto "${PROTO_DIR}/mesh.proto" -gen_proto "${PROTO_DIR}/cloud.proto" -gen_proto "${PROTO_DIR}/internal.proto" diff --git a/system/src/control/proto/control.pb.c b/system/src/control/proto/control.pb.c deleted file mode 100644 index 56212b8979..0000000000 --- a/system/src/control/proto/control.pb.c +++ /dev/null @@ -1,9 +0,0 @@ -/* Automatically generated nanopb constant definitions */ -/* Generated by nanopb-0.4.5 */ - -#include "control.pb.h" -#if PB_PROTO_HEADER_VERSION != 40 -#error Regenerate this file with the current version of nanopb generator. -#endif - - diff --git a/system/src/control/proto/control.pb.h b/system/src/control/proto/control.pb.h deleted file mode 100644 index 26d377f666..0000000000 --- a/system/src/control/proto/control.pb.h +++ /dev/null @@ -1,24 +0,0 @@ -/* Automatically generated nanopb header */ -/* Generated by nanopb-0.4.5 */ - -#ifndef PB_PARTICLE_CTRL_CONTROL_PB_H_INCLUDED -#define PB_PARTICLE_CTRL_CONTROL_PB_H_INCLUDED -#include -#include "common.pb.h" -#include "wifi.pb.h" -#include "network.pb.h" -#include "config.pb.h" - -#if PB_PROTO_HEADER_VERSION != 40 -#error Regenerate this file with the current version of nanopb generator. -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif diff --git a/system/src/control/proto/mesh.pb.c b/system/src/control/proto/mesh.pb.c deleted file mode 100644 index d7aa18f2e2..0000000000 --- a/system/src/control/proto/mesh.pb.c +++ /dev/null @@ -1,143 +0,0 @@ -/* Automatically generated nanopb constant definitions */ -/* Generated by nanopb-0.4.5 */ - -#include "mesh.pb.h" -#if PB_PROTO_HEADER_VERSION != 40 -#error Regenerate this file with the current version of nanopb generator. -#endif - -PB_BIND(particle_ctrl_mesh_NetworkInfo, particle_ctrl_mesh_NetworkInfo, AUTO) - - -PB_BIND(particle_ctrl_mesh_AuthRequest, particle_ctrl_mesh_AuthRequest, AUTO) - - -PB_BIND(particle_ctrl_mesh_AuthReply, particle_ctrl_mesh_AuthReply, AUTO) - - -PB_BIND(particle_ctrl_mesh_CreateNetworkRequest, particle_ctrl_mesh_CreateNetworkRequest, AUTO) - - -PB_BIND(particle_ctrl_mesh_CreateNetworkReply, particle_ctrl_mesh_CreateNetworkReply, AUTO) - - -PB_BIND(particle_ctrl_mesh_StartCommissionerRequest, particle_ctrl_mesh_StartCommissionerRequest, AUTO) - - -PB_BIND(particle_ctrl_mesh_StartCommissionerReply, particle_ctrl_mesh_StartCommissionerReply, AUTO) - - -PB_BIND(particle_ctrl_mesh_StopCommissionerRequest, particle_ctrl_mesh_StopCommissionerRequest, AUTO) - - -PB_BIND(particle_ctrl_mesh_StopCommissionerReply, particle_ctrl_mesh_StopCommissionerReply, AUTO) - - -PB_BIND(particle_ctrl_mesh_PrepareJoinerRequest, particle_ctrl_mesh_PrepareJoinerRequest, AUTO) - - -PB_BIND(particle_ctrl_mesh_PrepareJoinerReply, particle_ctrl_mesh_PrepareJoinerReply, AUTO) - - -PB_BIND(particle_ctrl_mesh_AddJoinerRequest, particle_ctrl_mesh_AddJoinerRequest, AUTO) - - -PB_BIND(particle_ctrl_mesh_AddJoinerReply, particle_ctrl_mesh_AddJoinerReply, AUTO) - - -PB_BIND(particle_ctrl_mesh_RemoveJoinerRequest, particle_ctrl_mesh_RemoveJoinerRequest, AUTO) - - -PB_BIND(particle_ctrl_mesh_RemoveJoinerReply, particle_ctrl_mesh_RemoveJoinerReply, AUTO) - - -PB_BIND(particle_ctrl_mesh_JoinNetworkRequest, particle_ctrl_mesh_JoinNetworkRequest, AUTO) - - -PB_BIND(particle_ctrl_mesh_JoinNetworkReply, particle_ctrl_mesh_JoinNetworkReply, AUTO) - - -PB_BIND(particle_ctrl_mesh_LeaveNetworkRequest, particle_ctrl_mesh_LeaveNetworkRequest, AUTO) - - -PB_BIND(particle_ctrl_mesh_LeaveNetworkReply, particle_ctrl_mesh_LeaveNetworkReply, AUTO) - - -PB_BIND(particle_ctrl_mesh_GetNetworkInfoRequest, particle_ctrl_mesh_GetNetworkInfoRequest, AUTO) - - -PB_BIND(particle_ctrl_mesh_GetNetworkInfoReply, particle_ctrl_mesh_GetNetworkInfoReply, AUTO) - - -PB_BIND(particle_ctrl_mesh_ScanNetworksRequest, particle_ctrl_mesh_ScanNetworksRequest, AUTO) - - -PB_BIND(particle_ctrl_mesh_ScanNetworksReply, particle_ctrl_mesh_ScanNetworksReply, AUTO) - - -PB_BIND(particle_ctrl_mesh_DiagnosticInfo, particle_ctrl_mesh_DiagnosticInfo, 2) - - -PB_BIND(particle_ctrl_mesh_DiagnosticInfo_Connectivity, particle_ctrl_mesh_DiagnosticInfo_Connectivity, AUTO) - - -PB_BIND(particle_ctrl_mesh_DiagnosticInfo_Route64, particle_ctrl_mesh_DiagnosticInfo_Route64, AUTO) - - -PB_BIND(particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData, particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData, AUTO) - - -PB_BIND(particle_ctrl_mesh_DiagnosticInfo_LeaderData, particle_ctrl_mesh_DiagnosticInfo_LeaderData, AUTO) - - -PB_BIND(particle_ctrl_mesh_DiagnosticInfo_NetworkData, particle_ctrl_mesh_DiagnosticInfo_NetworkData, AUTO) - - -PB_BIND(particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute, particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute, AUTO) - - -PB_BIND(particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry, particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry, AUTO) - - -PB_BIND(particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter, particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter, AUTO) - - -PB_BIND(particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry, particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry, AUTO) - - -PB_BIND(particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context, particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context, AUTO) - - -PB_BIND(particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix, particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix, AUTO) - - -PB_BIND(particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server, particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server, AUTO) - - -PB_BIND(particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service, particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service, AUTO) - - -PB_BIND(particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data, particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data, AUTO) - - -PB_BIND(particle_ctrl_mesh_DiagnosticInfo_MacCounters, particle_ctrl_mesh_DiagnosticInfo_MacCounters, AUTO) - - -PB_BIND(particle_ctrl_mesh_DiagnosticInfo_ChildTable, particle_ctrl_mesh_DiagnosticInfo_ChildTable, AUTO) - - -PB_BIND(particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry, particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry, AUTO) - - -PB_BIND(particle_ctrl_mesh_GetNetworkDiagnosticsRequest, particle_ctrl_mesh_GetNetworkDiagnosticsRequest, AUTO) - - -PB_BIND(particle_ctrl_mesh_GetNetworkDiagnosticsReply, particle_ctrl_mesh_GetNetworkDiagnosticsReply, AUTO) - - - - - - - - diff --git a/system/src/control/proto/mesh.pb.h b/system/src/control/proto/mesh.pb.h deleted file mode 100644 index f6fbd0ed3d..0000000000 --- a/system/src/control/proto/mesh.pb.h +++ /dev/null @@ -1,1082 +0,0 @@ -/* Automatically generated nanopb header */ -/* Generated by nanopb-0.4.5 */ - -#ifndef PB_PARTICLE_CTRL_MESH_MESH_PB_H_INCLUDED -#define PB_PARTICLE_CTRL_MESH_MESH_PB_H_INCLUDED -#include -#include "extensions.pb.h" -#include "common.pb.h" - -#if PB_PROTO_HEADER_VERSION != 40 -#error Regenerate this file with the current version of nanopb generator. -#endif - -/* Enum definitions */ -typedef enum _particle_ctrl_mesh_DiagnosticType { - particle_ctrl_mesh_DiagnosticType_MAC_EXTENDED_ADDRESS = 0, - particle_ctrl_mesh_DiagnosticType_RLOC = 1, - particle_ctrl_mesh_DiagnosticType_MAC_ADDRESS = 1, - particle_ctrl_mesh_DiagnosticType_MODE = 2, - particle_ctrl_mesh_DiagnosticType_TIMEOUT = 3, - particle_ctrl_mesh_DiagnosticType_CONNECTIVITY = 4, - particle_ctrl_mesh_DiagnosticType_ROUTE64 = 5, - particle_ctrl_mesh_DiagnosticType_LEADER_DATA = 6, - particle_ctrl_mesh_DiagnosticType_NETWORK_DATA = 7, - particle_ctrl_mesh_DiagnosticType_IPV6_ADDRESS_LIST = 8, - particle_ctrl_mesh_DiagnosticType_MAC_COUNTERS = 9, - particle_ctrl_mesh_DiagnosticType_BATTERY_LEVEL = 14, - particle_ctrl_mesh_DiagnosticType_SUPPLY_VOLTAGE = 15, - particle_ctrl_mesh_DiagnosticType_CHILD_TABLE = 16, - particle_ctrl_mesh_DiagnosticType_CHANNEL_PAGES = 17, - particle_ctrl_mesh_DiagnosticType_TYPE_LIST = 18, - particle_ctrl_mesh_DiagnosticType_MAX_CHILD_TIMEOUT = 19 -} particle_ctrl_mesh_DiagnosticType; - -typedef enum _particle_ctrl_mesh_DiagnosticInfo_Mode { - particle_ctrl_mesh_DiagnosticInfo_Mode_INVALID = 0, - particle_ctrl_mesh_DiagnosticInfo_Mode_RECEIVER_ON_WHEN_IDLE = 16, - particle_ctrl_mesh_DiagnosticInfo_Mode_SECURE_DATA_REQUESTS = 32, - particle_ctrl_mesh_DiagnosticInfo_Mode_DEVICE_TYPE = 48, - particle_ctrl_mesh_DiagnosticInfo_Mode_DEVICE_TYPE_FTD = 48, - particle_ctrl_mesh_DiagnosticInfo_Mode_NETWORK_DATA = 64, - particle_ctrl_mesh_DiagnosticInfo_Mode_NETWORK_DATA_FULL = 64 -} particle_ctrl_mesh_DiagnosticInfo_Mode; - -typedef enum _particle_ctrl_mesh_DiagnosticInfo_RoutePreference { - particle_ctrl_mesh_DiagnosticInfo_RoutePreference_MEDIUM = 0, - particle_ctrl_mesh_DiagnosticInfo_RoutePreference_HIGH = 1, - particle_ctrl_mesh_DiagnosticInfo_RoutePreference_LOW = -1 -} particle_ctrl_mesh_DiagnosticInfo_RoutePreference; - -typedef enum _particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags { - particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_NONE = 0, - particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_PREFERRED = 1, - particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_SLAAC = 2, - particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_DHCP = 4, - particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_CONFIGURE = 8, - particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_DEFAULT_ROUTE = 16, - particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_ON_MESH = 32, - particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_ND_DNS = 64 -} particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags; - -typedef enum _particle_ctrl_mesh_GetNetworkDiagnosticsRequest_Flags { - particle_ctrl_mesh_GetNetworkDiagnosticsRequest_Flags_INVALID = 0, - particle_ctrl_mesh_GetNetworkDiagnosticsRequest_Flags_QUERY_CHILDREN = 1, - particle_ctrl_mesh_GetNetworkDiagnosticsRequest_Flags_RESOLVE_DEVICE_ID = 2 -} particle_ctrl_mesh_GetNetworkDiagnosticsRequest_Flags; - -/* Struct definitions */ -/* Result codes: - NO_MEMORY: No memory available to add the joiner - INVALID_STATE: The commissioner role is not started - NOT_ALLOWED: The client is not authenticated */ -typedef struct _particle_ctrl_mesh_AddJoinerReply { - char dummy_field; -} particle_ctrl_mesh_AddJoinerReply; - -/* Result codes: - NOT_FOUND: The device is not a member of a network - NOT_ALLOWED: Invalid commissioning credential */ -typedef struct _particle_ctrl_mesh_AuthReply { - char dummy_field; -} particle_ctrl_mesh_AuthReply; - -/* Authenticate the client as a commissioner */ -typedef struct _particle_ctrl_mesh_AuthRequest { - /* Commissioning credential */ - pb_callback_t password; -} particle_ctrl_mesh_AuthRequest; - -typedef struct _particle_ctrl_mesh_DiagnosticInfo_ChildTable { - pb_callback_t children; -} particle_ctrl_mesh_DiagnosticInfo_ChildTable; - -typedef struct _particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter { - pb_callback_t entries; -} particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter; - -typedef struct _particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data { - pb_callback_t prefixes; - pb_callback_t services; -} particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data; - -typedef struct _particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute { - pb_callback_t entries; -} particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute; - -typedef struct _particle_ctrl_mesh_GetNetworkDiagnosticsReply { - pb_callback_t nodes; -} particle_ctrl_mesh_GetNetworkDiagnosticsReply; - -/* Get the info about current network */ -typedef struct _particle_ctrl_mesh_GetNetworkInfoRequest { - char dummy_field; -} particle_ctrl_mesh_GetNetworkInfoRequest; - -/* Result codes: - NOT_FOUND: No joinable network was found - TIMEOUT: The join process timed out - NOT_ALLOWED: Invalid security credentials */ -typedef struct _particle_ctrl_mesh_JoinNetworkReply { - char dummy_field; -} particle_ctrl_mesh_JoinNetworkReply; - -/* Result codes: - NOT_FOUND: The device is not a member of a network - NOT_ALLOWED: The client is not authenticated */ -typedef struct _particle_ctrl_mesh_LeaveNetworkReply { - char dummy_field; -} particle_ctrl_mesh_LeaveNetworkReply; - -/* Leave the network */ -typedef struct _particle_ctrl_mesh_LeaveNetworkRequest { - char dummy_field; -} particle_ctrl_mesh_LeaveNetworkRequest; - -/* Result codes: - ALREADY_EXIST: The device is already a member of a network - NOT_ALLOWED: The client is not authenticated */ -typedef struct _particle_ctrl_mesh_PrepareJoinerReply { - /* EUI-64 */ - pb_callback_t eui64; - /* Newly generated joining device credential */ - pb_callback_t password; -} particle_ctrl_mesh_PrepareJoinerReply; - -/* Result codes: - NOT_FOUND: The joiner was not found - INVALID_STATE: The commissioner role is not started - NOT_ALLOWED: The client is not authenticated */ -typedef struct _particle_ctrl_mesh_RemoveJoinerReply { - char dummy_field; -} particle_ctrl_mesh_RemoveJoinerReply; - -/* Remove the joiner device */ -typedef struct _particle_ctrl_mesh_RemoveJoinerRequest { - /* EUI-64 of the joiner device */ - pb_callback_t eui64; -} particle_ctrl_mesh_RemoveJoinerRequest; - -typedef struct _particle_ctrl_mesh_ScanNetworksReply { - pb_callback_t networks; -} particle_ctrl_mesh_ScanNetworksReply; - -/* Result codes: - NOT_ALLOWED: The client is not authenticated */ -typedef struct _particle_ctrl_mesh_StartCommissionerReply { - char dummy_field; -} particle_ctrl_mesh_StartCommissionerReply; - -/* Result codes: - NOT_ALLOWED: The client is not authenticated */ -typedef struct _particle_ctrl_mesh_StopCommissionerReply { - char dummy_field; -} particle_ctrl_mesh_StopCommissionerReply; - -/* Stop the commissioner role */ -typedef struct _particle_ctrl_mesh_StopCommissionerRequest { - char dummy_field; -} particle_ctrl_mesh_StopCommissionerRequest; - -/* Add a joiner device */ -typedef struct _particle_ctrl_mesh_AddJoinerRequest { - /* EUI-64 of the joiner device */ - pb_callback_t eui64; - /* Joining device credential */ - pb_callback_t password; - /* Time is seconds after which the joiner is automatically removed from the commissioner dataset */ - uint32_t timeout; -} particle_ctrl_mesh_AddJoinerRequest; - -/* Create a new network */ -typedef struct _particle_ctrl_mesh_CreateNetworkRequest { - /* Network name */ - pb_callback_t name; - /* Commissioning credential for this network */ - pb_callback_t password; - /* Channel number */ - uint32_t channel; - /* Network ID */ - pb_callback_t network_id; -} particle_ctrl_mesh_CreateNetworkRequest; - -typedef struct _particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry { - uint32_t timeout; - uint32_t child_id; - uint32_t mode; -} particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry; - -typedef struct _particle_ctrl_mesh_DiagnosticInfo_Connectivity { - /* Bitmask of Flags */ - uint32_t parent_priority; - /* List of DiagnosticType to request */ - uint32_t link_quality_1; - /* Maximum time in seconds to wait for diagnostic replies */ - uint32_t link_quality_2; - uint32_t link_quality_3; - uint32_t leader_cost; - uint32_t id_sequence; - uint32_t active_routers; - uint32_t sed_buffer_size; - uint32_t sed_datagram_count; -} particle_ctrl_mesh_DiagnosticInfo_Connectivity; - -typedef struct _particle_ctrl_mesh_DiagnosticInfo_LeaderData { - uint32_t partition_id; - uint32_t weighting; - uint32_t data_version; - uint32_t stable_data_version; - uint32_t leader_rloc; -} particle_ctrl_mesh_DiagnosticInfo_LeaderData; - -typedef struct _particle_ctrl_mesh_DiagnosticInfo_MacCounters { - uint32_t if_in_unknown_protos; - uint32_t if_in_errors; - uint32_t if_out_errors; - uint32_t if_in_ucast_pkts; - uint32_t if_in_broadcast_pkts; - uint32_t if_in_discards; - uint32_t if_out_ucast_pkts; - uint32_t if_out_broadcast_pkts; - uint32_t if_out_discards; -} particle_ctrl_mesh_DiagnosticInfo_MacCounters; - -typedef struct _particle_ctrl_mesh_DiagnosticInfo_NetworkData { - bool has_stable; - particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data stable; - bool has_temporary; - particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data temporary; -} particle_ctrl_mesh_DiagnosticInfo_NetworkData; - -typedef struct _particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry { - uint32_t rloc; - particle_ctrl_mesh_DiagnosticInfo_RoutePreference preference; - uint32_t flags; -} particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry; - -typedef struct _particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context { - uint32_t cid; - bool compress; - uint32_t context_length; -} particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context; - -typedef struct _particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry { - uint32_t rloc; - particle_ctrl_mesh_DiagnosticInfo_RoutePreference preference; -} particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry; - -typedef PB_BYTES_ARRAY_T(16) particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_prefix_t; -typedef struct _particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix { - uint32_t domain_id; - uint32_t prefix_length; - particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_prefix_t prefix; - pb_callback_t context; - bool has_has_route; - particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute has_route; - bool has_border_router; - particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter border_router; -} particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix; - -typedef struct _particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server { - uint32_t rloc; - pb_callback_t data; -} particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server; - -typedef struct _particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service { - uint32_t sid; - uint32_t enterprise_number; - pb_callback_t data; - pb_callback_t servers; -} particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service; - -typedef struct _particle_ctrl_mesh_DiagnosticInfo_Route64 { - uint32_t id_sequence; - pb_callback_t routes; -} particle_ctrl_mesh_DiagnosticInfo_Route64; - -typedef struct _particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData { - uint32_t router_rloc; - uint32_t link_quality_out; - uint32_t link_quality_in; - uint32_t route_cost; -} particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData; - -typedef struct _particle_ctrl_mesh_GetNetworkDiagnosticsRequest { - uint32_t flags; - pb_callback_t diagnostic_types; - uint32_t timeout; -} particle_ctrl_mesh_GetNetworkDiagnosticsRequest; - -/* Join the network */ -typedef struct _particle_ctrl_mesh_JoinNetworkRequest { - /* Time in seconds after which the attempt to join is cancelled */ - uint32_t timeout; -} particle_ctrl_mesh_JoinNetworkRequest; - -/* Network info */ -typedef struct _particle_ctrl_mesh_NetworkInfo { - /* Network name */ - pb_callback_t name; - /* Extended PAN ID */ - pb_callback_t ext_pan_id; - /* PAN ID */ - uint32_t pan_id; - /* Channel number */ - uint32_t channel; - /* network ID */ - pb_callback_t network_id; -} particle_ctrl_mesh_NetworkInfo; - -/* Scan networks */ -typedef struct _particle_ctrl_mesh_ScanNetworksRequest { - /* Time in milliseconds to spend scanning each channel. A value of 0 sets the default OpenThread - timeout (300 ms) */ - uint32_t duration; -} particle_ctrl_mesh_ScanNetworksRequest; - -/* Start the commissioner role */ -typedef struct _particle_ctrl_mesh_StartCommissionerRequest { - /* Time is seconds after which the role is automatically stopped */ - uint32_t timeout; -} particle_ctrl_mesh_StartCommissionerRequest; - -/* Result codes: - ALREADY_EXIST: The device is already a member of a network - NOT_ALLOWED: The client is not authenticated */ -typedef struct _particle_ctrl_mesh_CreateNetworkReply { - /* Network info */ - bool has_network; - particle_ctrl_mesh_NetworkInfo network; -} particle_ctrl_mesh_CreateNetworkReply; - -typedef PB_BYTES_ARRAY_T(8) particle_ctrl_mesh_DiagnosticInfo_ext_mac_address_t; -typedef PB_BYTES_ARRAY_T(3) particle_ctrl_mesh_DiagnosticInfo_channel_pages_t; -typedef PB_BYTES_ARRAY_T(12) particle_ctrl_mesh_DiagnosticInfo_device_id_t; -/* Mapping of Diagnostic TLVs */ -typedef struct _particle_ctrl_mesh_DiagnosticInfo { - /* MAC Extended Address (64-bit): MAC Extended Address TLV */ - particle_ctrl_mesh_DiagnosticInfo_ext_mac_address_t ext_mac_address; - /* MAC Address (16-bit): Address16 TLV (RLOC) */ - uint32_t rloc; - /* Mode (Capability Information): Mode TLV */ - uint32_t mode; - /* Timeout: Timeout TLV */ - uint32_t timeout; - /* Connectivity : Connectivity TLV */ - bool has_connectivity; - particle_ctrl_mesh_DiagnosticInfo_Connectivity connectivity; - /* Route64: Route64 TLV */ - bool has_route64; - particle_ctrl_mesh_DiagnosticInfo_Route64 route64; - /* Leader Data: Leader Data TLV */ - bool has_leader_data; - particle_ctrl_mesh_DiagnosticInfo_LeaderData leader_data; - /* Network Data: Network Data TLV */ - bool has_network_data; - particle_ctrl_mesh_DiagnosticInfo_NetworkData network_data; - /* IPv6 address list: IPv6 Address List TLV */ - pb_callback_t ipv6_address_list; - /* MAC Counters: MAC Counters TLV */ - bool has_mac_counters; - particle_ctrl_mesh_DiagnosticInfo_MacCounters mac_counters; - /* Battery Level: Battery Level TLV */ - uint32_t battery_level; - /* Supply Voltage: Supply Voltage TLV */ - uint32_t supply_voltage; - /* Child Table: Child Table TLV */ - bool has_child_table; - particle_ctrl_mesh_DiagnosticInfo_ChildTable child_table; - /* Channel Pages: Channel Pages TLV */ - particle_ctrl_mesh_DiagnosticInfo_channel_pages_t channel_pages; - /* Type List: Type List TLV - List of DiagnosticType */ - pb_callback_t type_list; - /* Max Child Timeout: Timeout TLV */ - uint32_t max_child_timeout; - /* Particle-specific Device Id */ - particle_ctrl_mesh_DiagnosticInfo_device_id_t device_id; -} particle_ctrl_mesh_DiagnosticInfo; - -/* Result codes: - NOT_FOUND: The device is not a member of a network */ -typedef struct _particle_ctrl_mesh_GetNetworkInfoReply { - /* Network info */ - bool has_network; - particle_ctrl_mesh_NetworkInfo network; -} particle_ctrl_mesh_GetNetworkInfoReply; - -/* Prepare the device to join a network */ -typedef struct _particle_ctrl_mesh_PrepareJoinerRequest { - bool has_network; - particle_ctrl_mesh_NetworkInfo network; -} particle_ctrl_mesh_PrepareJoinerRequest; - - -/* Helper constants for enums */ -#define _particle_ctrl_mesh_DiagnosticType_MIN particle_ctrl_mesh_DiagnosticType_MAC_EXTENDED_ADDRESS -#define _particle_ctrl_mesh_DiagnosticType_MAX particle_ctrl_mesh_DiagnosticType_MAX_CHILD_TIMEOUT -#define _particle_ctrl_mesh_DiagnosticType_ARRAYSIZE ((particle_ctrl_mesh_DiagnosticType)(particle_ctrl_mesh_DiagnosticType_MAX_CHILD_TIMEOUT+1)) - -#define _particle_ctrl_mesh_DiagnosticInfo_Mode_MIN particle_ctrl_mesh_DiagnosticInfo_Mode_INVALID -#define _particle_ctrl_mesh_DiagnosticInfo_Mode_MAX particle_ctrl_mesh_DiagnosticInfo_Mode_NETWORK_DATA_FULL -#define _particle_ctrl_mesh_DiagnosticInfo_Mode_ARRAYSIZE ((particle_ctrl_mesh_DiagnosticInfo_Mode)(particle_ctrl_mesh_DiagnosticInfo_Mode_NETWORK_DATA_FULL+1)) - -#define _particle_ctrl_mesh_DiagnosticInfo_RoutePreference_MIN particle_ctrl_mesh_DiagnosticInfo_RoutePreference_LOW -#define _particle_ctrl_mesh_DiagnosticInfo_RoutePreference_MAX particle_ctrl_mesh_DiagnosticInfo_RoutePreference_HIGH -#define _particle_ctrl_mesh_DiagnosticInfo_RoutePreference_ARRAYSIZE ((particle_ctrl_mesh_DiagnosticInfo_RoutePreference)(particle_ctrl_mesh_DiagnosticInfo_RoutePreference_HIGH+1)) - -#define _particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_MIN particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_NONE -#define _particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_MAX particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_ND_DNS -#define _particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_ARRAYSIZE ((particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags)(particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_Flags_ND_DNS+1)) - -#define _particle_ctrl_mesh_GetNetworkDiagnosticsRequest_Flags_MIN particle_ctrl_mesh_GetNetworkDiagnosticsRequest_Flags_INVALID -#define _particle_ctrl_mesh_GetNetworkDiagnosticsRequest_Flags_MAX particle_ctrl_mesh_GetNetworkDiagnosticsRequest_Flags_RESOLVE_DEVICE_ID -#define _particle_ctrl_mesh_GetNetworkDiagnosticsRequest_Flags_ARRAYSIZE ((particle_ctrl_mesh_GetNetworkDiagnosticsRequest_Flags)(particle_ctrl_mesh_GetNetworkDiagnosticsRequest_Flags_RESOLVE_DEVICE_ID+1)) - - -#ifdef __cplusplus -extern "C" { -#endif - -/* Initializer values for message structs */ -#define particle_ctrl_mesh_NetworkInfo_init_default {{{NULL}, NULL}, {{NULL}, NULL}, 0, 0, {{NULL}, NULL}} -#define particle_ctrl_mesh_AuthRequest_init_default {{{NULL}, NULL}} -#define particle_ctrl_mesh_AuthReply_init_default {0} -#define particle_ctrl_mesh_CreateNetworkRequest_init_default {{{NULL}, NULL}, {{NULL}, NULL}, 0, {{NULL}, NULL}} -#define particle_ctrl_mesh_CreateNetworkReply_init_default {false, particle_ctrl_mesh_NetworkInfo_init_default} -#define particle_ctrl_mesh_StartCommissionerRequest_init_default {0} -#define particle_ctrl_mesh_StartCommissionerReply_init_default {0} -#define particle_ctrl_mesh_StopCommissionerRequest_init_default {0} -#define particle_ctrl_mesh_StopCommissionerReply_init_default {0} -#define particle_ctrl_mesh_PrepareJoinerRequest_init_default {false, particle_ctrl_mesh_NetworkInfo_init_default} -#define particle_ctrl_mesh_PrepareJoinerReply_init_default {{{NULL}, NULL}, {{NULL}, NULL}} -#define particle_ctrl_mesh_AddJoinerRequest_init_default {{{NULL}, NULL}, {{NULL}, NULL}, 0} -#define particle_ctrl_mesh_AddJoinerReply_init_default {0} -#define particle_ctrl_mesh_RemoveJoinerRequest_init_default {{{NULL}, NULL}} -#define particle_ctrl_mesh_RemoveJoinerReply_init_default {0} -#define particle_ctrl_mesh_JoinNetworkRequest_init_default {0} -#define particle_ctrl_mesh_JoinNetworkReply_init_default {0} -#define particle_ctrl_mesh_LeaveNetworkRequest_init_default {0} -#define particle_ctrl_mesh_LeaveNetworkReply_init_default {0} -#define particle_ctrl_mesh_GetNetworkInfoRequest_init_default {0} -#define particle_ctrl_mesh_GetNetworkInfoReply_init_default {false, particle_ctrl_mesh_NetworkInfo_init_default} -#define particle_ctrl_mesh_ScanNetworksRequest_init_default {0} -#define particle_ctrl_mesh_ScanNetworksReply_init_default {{{NULL}, NULL}} -#define particle_ctrl_mesh_DiagnosticInfo_init_default {{0, {0}}, 0, 0, 0, false, particle_ctrl_mesh_DiagnosticInfo_Connectivity_init_default, false, particle_ctrl_mesh_DiagnosticInfo_Route64_init_default, false, particle_ctrl_mesh_DiagnosticInfo_LeaderData_init_default, false, particle_ctrl_mesh_DiagnosticInfo_NetworkData_init_default, {{NULL}, NULL}, false, particle_ctrl_mesh_DiagnosticInfo_MacCounters_init_default, 0, 0, false, particle_ctrl_mesh_DiagnosticInfo_ChildTable_init_default, {0, {0}}, {{NULL}, NULL}, 0, {0, {0}}} -#define particle_ctrl_mesh_DiagnosticInfo_Connectivity_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0} -#define particle_ctrl_mesh_DiagnosticInfo_Route64_init_default {0, {{NULL}, NULL}} -#define particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData_init_default {0, 0, 0, 0} -#define particle_ctrl_mesh_DiagnosticInfo_LeaderData_init_default {0, 0, 0, 0, 0} -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_init_default {false, particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_init_default, false, particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_init_default} -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_init_default {{{NULL}, NULL}} -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry_init_default {0, _particle_ctrl_mesh_DiagnosticInfo_RoutePreference_MIN} -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_init_default {{{NULL}, NULL}} -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_init_default {0, _particle_ctrl_mesh_DiagnosticInfo_RoutePreference_MIN, 0} -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context_init_default {0, 0, 0} -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_init_default {0, 0, {0, {0}}, {{NULL}, NULL}, false, particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_init_default, false, particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_init_default} -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server_init_default {0, {{NULL}, NULL}} -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service_init_default {0, 0, {{NULL}, NULL}, {{NULL}, NULL}} -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_init_default {{{NULL}, NULL}, {{NULL}, NULL}} -#define particle_ctrl_mesh_DiagnosticInfo_MacCounters_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0} -#define particle_ctrl_mesh_DiagnosticInfo_ChildTable_init_default {{{NULL}, NULL}} -#define particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry_init_default {0, 0, 0} -#define particle_ctrl_mesh_GetNetworkDiagnosticsRequest_init_default {0, {{NULL}, NULL}, 0} -#define particle_ctrl_mesh_GetNetworkDiagnosticsReply_init_default {{{NULL}, NULL}} -#define particle_ctrl_mesh_NetworkInfo_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, 0, 0, {{NULL}, NULL}} -#define particle_ctrl_mesh_AuthRequest_init_zero {{{NULL}, NULL}} -#define particle_ctrl_mesh_AuthReply_init_zero {0} -#define particle_ctrl_mesh_CreateNetworkRequest_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, 0, {{NULL}, NULL}} -#define particle_ctrl_mesh_CreateNetworkReply_init_zero {false, particle_ctrl_mesh_NetworkInfo_init_zero} -#define particle_ctrl_mesh_StartCommissionerRequest_init_zero {0} -#define particle_ctrl_mesh_StartCommissionerReply_init_zero {0} -#define particle_ctrl_mesh_StopCommissionerRequest_init_zero {0} -#define particle_ctrl_mesh_StopCommissionerReply_init_zero {0} -#define particle_ctrl_mesh_PrepareJoinerRequest_init_zero {false, particle_ctrl_mesh_NetworkInfo_init_zero} -#define particle_ctrl_mesh_PrepareJoinerReply_init_zero {{{NULL}, NULL}, {{NULL}, NULL}} -#define particle_ctrl_mesh_AddJoinerRequest_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, 0} -#define particle_ctrl_mesh_AddJoinerReply_init_zero {0} -#define particle_ctrl_mesh_RemoveJoinerRequest_init_zero {{{NULL}, NULL}} -#define particle_ctrl_mesh_RemoveJoinerReply_init_zero {0} -#define particle_ctrl_mesh_JoinNetworkRequest_init_zero {0} -#define particle_ctrl_mesh_JoinNetworkReply_init_zero {0} -#define particle_ctrl_mesh_LeaveNetworkRequest_init_zero {0} -#define particle_ctrl_mesh_LeaveNetworkReply_init_zero {0} -#define particle_ctrl_mesh_GetNetworkInfoRequest_init_zero {0} -#define particle_ctrl_mesh_GetNetworkInfoReply_init_zero {false, particle_ctrl_mesh_NetworkInfo_init_zero} -#define particle_ctrl_mesh_ScanNetworksRequest_init_zero {0} -#define particle_ctrl_mesh_ScanNetworksReply_init_zero {{{NULL}, NULL}} -#define particle_ctrl_mesh_DiagnosticInfo_init_zero {{0, {0}}, 0, 0, 0, false, particle_ctrl_mesh_DiagnosticInfo_Connectivity_init_zero, false, particle_ctrl_mesh_DiagnosticInfo_Route64_init_zero, false, particle_ctrl_mesh_DiagnosticInfo_LeaderData_init_zero, false, particle_ctrl_mesh_DiagnosticInfo_NetworkData_init_zero, {{NULL}, NULL}, false, particle_ctrl_mesh_DiagnosticInfo_MacCounters_init_zero, 0, 0, false, particle_ctrl_mesh_DiagnosticInfo_ChildTable_init_zero, {0, {0}}, {{NULL}, NULL}, 0, {0, {0}}} -#define particle_ctrl_mesh_DiagnosticInfo_Connectivity_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0} -#define particle_ctrl_mesh_DiagnosticInfo_Route64_init_zero {0, {{NULL}, NULL}} -#define particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData_init_zero {0, 0, 0, 0} -#define particle_ctrl_mesh_DiagnosticInfo_LeaderData_init_zero {0, 0, 0, 0, 0} -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_init_zero {false, particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_init_zero, false, particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_init_zero} -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_init_zero {{{NULL}, NULL}} -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry_init_zero {0, _particle_ctrl_mesh_DiagnosticInfo_RoutePreference_MIN} -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_init_zero {{{NULL}, NULL}} -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_init_zero {0, _particle_ctrl_mesh_DiagnosticInfo_RoutePreference_MIN, 0} -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context_init_zero {0, 0, 0} -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_init_zero {0, 0, {0, {0}}, {{NULL}, NULL}, false, particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_init_zero, false, particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_init_zero} -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server_init_zero {0, {{NULL}, NULL}} -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service_init_zero {0, 0, {{NULL}, NULL}, {{NULL}, NULL}} -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_init_zero {{{NULL}, NULL}, {{NULL}, NULL}} -#define particle_ctrl_mesh_DiagnosticInfo_MacCounters_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0} -#define particle_ctrl_mesh_DiagnosticInfo_ChildTable_init_zero {{{NULL}, NULL}} -#define particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry_init_zero {0, 0, 0} -#define particle_ctrl_mesh_GetNetworkDiagnosticsRequest_init_zero {0, {{NULL}, NULL}, 0} -#define particle_ctrl_mesh_GetNetworkDiagnosticsReply_init_zero {{{NULL}, NULL}} - -/* Field tags (for use in manual encoding/decoding) */ -#define particle_ctrl_mesh_AuthRequest_password_tag 1 -#define particle_ctrl_mesh_DiagnosticInfo_ChildTable_children_tag 1 -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_entries_tag 1 -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_prefixes_tag 1 -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_services_tag 2 -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_entries_tag 1 -#define particle_ctrl_mesh_GetNetworkDiagnosticsReply_nodes_tag 1 -#define particle_ctrl_mesh_PrepareJoinerReply_eui64_tag 1 -#define particle_ctrl_mesh_PrepareJoinerReply_password_tag 2 -#define particle_ctrl_mesh_RemoveJoinerRequest_eui64_tag 1 -#define particle_ctrl_mesh_ScanNetworksReply_networks_tag 1 -#define particle_ctrl_mesh_AddJoinerRequest_eui64_tag 1 -#define particle_ctrl_mesh_AddJoinerRequest_password_tag 2 -#define particle_ctrl_mesh_AddJoinerRequest_timeout_tag 3 -#define particle_ctrl_mesh_CreateNetworkRequest_name_tag 1 -#define particle_ctrl_mesh_CreateNetworkRequest_password_tag 2 -#define particle_ctrl_mesh_CreateNetworkRequest_channel_tag 3 -#define particle_ctrl_mesh_CreateNetworkRequest_network_id_tag 4 -#define particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry_timeout_tag 1 -#define particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry_child_id_tag 2 -#define particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry_mode_tag 3 -#define particle_ctrl_mesh_DiagnosticInfo_Connectivity_parent_priority_tag 1 -#define particle_ctrl_mesh_DiagnosticInfo_Connectivity_link_quality_1_tag 2 -#define particle_ctrl_mesh_DiagnosticInfo_Connectivity_link_quality_2_tag 3 -#define particle_ctrl_mesh_DiagnosticInfo_Connectivity_link_quality_3_tag 4 -#define particle_ctrl_mesh_DiagnosticInfo_Connectivity_leader_cost_tag 5 -#define particle_ctrl_mesh_DiagnosticInfo_Connectivity_id_sequence_tag 6 -#define particle_ctrl_mesh_DiagnosticInfo_Connectivity_active_routers_tag 7 -#define particle_ctrl_mesh_DiagnosticInfo_Connectivity_sed_buffer_size_tag 8 -#define particle_ctrl_mesh_DiagnosticInfo_Connectivity_sed_datagram_count_tag 9 -#define particle_ctrl_mesh_DiagnosticInfo_LeaderData_partition_id_tag 1 -#define particle_ctrl_mesh_DiagnosticInfo_LeaderData_weighting_tag 2 -#define particle_ctrl_mesh_DiagnosticInfo_LeaderData_data_version_tag 3 -#define particle_ctrl_mesh_DiagnosticInfo_LeaderData_stable_data_version_tag 4 -#define particle_ctrl_mesh_DiagnosticInfo_LeaderData_leader_rloc_tag 5 -#define particle_ctrl_mesh_DiagnosticInfo_MacCounters_if_in_unknown_protos_tag 1 -#define particle_ctrl_mesh_DiagnosticInfo_MacCounters_if_in_errors_tag 2 -#define particle_ctrl_mesh_DiagnosticInfo_MacCounters_if_out_errors_tag 3 -#define particle_ctrl_mesh_DiagnosticInfo_MacCounters_if_in_ucast_pkts_tag 4 -#define particle_ctrl_mesh_DiagnosticInfo_MacCounters_if_in_broadcast_pkts_tag 5 -#define particle_ctrl_mesh_DiagnosticInfo_MacCounters_if_in_discards_tag 6 -#define particle_ctrl_mesh_DiagnosticInfo_MacCounters_if_out_ucast_pkts_tag 7 -#define particle_ctrl_mesh_DiagnosticInfo_MacCounters_if_out_broadcast_pkts_tag 8 -#define particle_ctrl_mesh_DiagnosticInfo_MacCounters_if_out_discards_tag 9 -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_stable_tag 1 -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_temporary_tag 2 -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_rloc_tag 1 -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_preference_tag 2 -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_flags_tag 3 -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context_cid_tag 1 -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context_compress_tag 2 -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context_context_length_tag 3 -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry_rloc_tag 1 -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry_preference_tag 2 -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_domain_id_tag 1 -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_prefix_length_tag 2 -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_prefix_tag 3 -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_context_tag 4 -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_has_route_tag 5 -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_border_router_tag 6 -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server_rloc_tag 1 -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server_data_tag 2 -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service_sid_tag 1 -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service_enterprise_number_tag 2 -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service_data_tag 3 -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service_servers_tag 4 -#define particle_ctrl_mesh_DiagnosticInfo_Route64_id_sequence_tag 1 -#define particle_ctrl_mesh_DiagnosticInfo_Route64_routes_tag 2 -#define particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData_router_rloc_tag 1 -#define particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData_link_quality_out_tag 2 -#define particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData_link_quality_in_tag 3 -#define particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData_route_cost_tag 4 -#define particle_ctrl_mesh_GetNetworkDiagnosticsRequest_flags_tag 1 -#define particle_ctrl_mesh_GetNetworkDiagnosticsRequest_diagnostic_types_tag 2 -#define particle_ctrl_mesh_GetNetworkDiagnosticsRequest_timeout_tag 3 -#define particle_ctrl_mesh_JoinNetworkRequest_timeout_tag 1 -#define particle_ctrl_mesh_NetworkInfo_name_tag 1 -#define particle_ctrl_mesh_NetworkInfo_ext_pan_id_tag 2 -#define particle_ctrl_mesh_NetworkInfo_pan_id_tag 3 -#define particle_ctrl_mesh_NetworkInfo_channel_tag 4 -#define particle_ctrl_mesh_NetworkInfo_network_id_tag 5 -#define particle_ctrl_mesh_ScanNetworksRequest_duration_tag 1 -#define particle_ctrl_mesh_StartCommissionerRequest_timeout_tag 1 -#define particle_ctrl_mesh_CreateNetworkReply_network_tag 1 -#define particle_ctrl_mesh_DiagnosticInfo_ext_mac_address_tag 1 -#define particle_ctrl_mesh_DiagnosticInfo_rloc_tag 2 -#define particle_ctrl_mesh_DiagnosticInfo_mode_tag 3 -#define particle_ctrl_mesh_DiagnosticInfo_timeout_tag 4 -#define particle_ctrl_mesh_DiagnosticInfo_connectivity_tag 5 -#define particle_ctrl_mesh_DiagnosticInfo_route64_tag 6 -#define particle_ctrl_mesh_DiagnosticInfo_leader_data_tag 7 -#define particle_ctrl_mesh_DiagnosticInfo_network_data_tag 8 -#define particle_ctrl_mesh_DiagnosticInfo_ipv6_address_list_tag 9 -#define particle_ctrl_mesh_DiagnosticInfo_mac_counters_tag 10 -#define particle_ctrl_mesh_DiagnosticInfo_battery_level_tag 15 -#define particle_ctrl_mesh_DiagnosticInfo_supply_voltage_tag 16 -#define particle_ctrl_mesh_DiagnosticInfo_child_table_tag 17 -#define particle_ctrl_mesh_DiagnosticInfo_channel_pages_tag 18 -#define particle_ctrl_mesh_DiagnosticInfo_type_list_tag 19 -#define particle_ctrl_mesh_DiagnosticInfo_max_child_timeout_tag 20 -#define particle_ctrl_mesh_DiagnosticInfo_device_id_tag 100 -#define particle_ctrl_mesh_GetNetworkInfoReply_network_tag 1 -#define particle_ctrl_mesh_PrepareJoinerRequest_network_tag 1 - -/* Struct field encoding specification for nanopb */ -#define particle_ctrl_mesh_NetworkInfo_FIELDLIST(X, a) \ -X(a, CALLBACK, SINGULAR, STRING, name, 1) \ -X(a, CALLBACK, SINGULAR, STRING, ext_pan_id, 2) \ -X(a, STATIC, SINGULAR, UINT32, pan_id, 3) \ -X(a, STATIC, SINGULAR, UINT32, channel, 4) \ -X(a, CALLBACK, SINGULAR, STRING, network_id, 5) -#define particle_ctrl_mesh_NetworkInfo_CALLBACK pb_default_field_callback -#define particle_ctrl_mesh_NetworkInfo_DEFAULT NULL - -#define particle_ctrl_mesh_AuthRequest_FIELDLIST(X, a) \ -X(a, CALLBACK, SINGULAR, STRING, password, 1) -#define particle_ctrl_mesh_AuthRequest_CALLBACK pb_default_field_callback -#define particle_ctrl_mesh_AuthRequest_DEFAULT NULL - -#define particle_ctrl_mesh_AuthReply_FIELDLIST(X, a) \ - -#define particle_ctrl_mesh_AuthReply_CALLBACK NULL -#define particle_ctrl_mesh_AuthReply_DEFAULT NULL - -#define particle_ctrl_mesh_CreateNetworkRequest_FIELDLIST(X, a) \ -X(a, CALLBACK, SINGULAR, STRING, name, 1) \ -X(a, CALLBACK, SINGULAR, STRING, password, 2) \ -X(a, STATIC, SINGULAR, UINT32, channel, 3) \ -X(a, CALLBACK, SINGULAR, STRING, network_id, 4) -#define particle_ctrl_mesh_CreateNetworkRequest_CALLBACK pb_default_field_callback -#define particle_ctrl_mesh_CreateNetworkRequest_DEFAULT NULL - -#define particle_ctrl_mesh_CreateNetworkReply_FIELDLIST(X, a) \ -X(a, STATIC, OPTIONAL, MESSAGE, network, 1) -#define particle_ctrl_mesh_CreateNetworkReply_CALLBACK NULL -#define particle_ctrl_mesh_CreateNetworkReply_DEFAULT NULL -#define particle_ctrl_mesh_CreateNetworkReply_network_MSGTYPE particle_ctrl_mesh_NetworkInfo - -#define particle_ctrl_mesh_StartCommissionerRequest_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, UINT32, timeout, 1) -#define particle_ctrl_mesh_StartCommissionerRequest_CALLBACK NULL -#define particle_ctrl_mesh_StartCommissionerRequest_DEFAULT NULL - -#define particle_ctrl_mesh_StartCommissionerReply_FIELDLIST(X, a) \ - -#define particle_ctrl_mesh_StartCommissionerReply_CALLBACK NULL -#define particle_ctrl_mesh_StartCommissionerReply_DEFAULT NULL - -#define particle_ctrl_mesh_StopCommissionerRequest_FIELDLIST(X, a) \ - -#define particle_ctrl_mesh_StopCommissionerRequest_CALLBACK NULL -#define particle_ctrl_mesh_StopCommissionerRequest_DEFAULT NULL - -#define particle_ctrl_mesh_StopCommissionerReply_FIELDLIST(X, a) \ - -#define particle_ctrl_mesh_StopCommissionerReply_CALLBACK NULL -#define particle_ctrl_mesh_StopCommissionerReply_DEFAULT NULL - -#define particle_ctrl_mesh_PrepareJoinerRequest_FIELDLIST(X, a) \ -X(a, STATIC, OPTIONAL, MESSAGE, network, 1) -#define particle_ctrl_mesh_PrepareJoinerRequest_CALLBACK NULL -#define particle_ctrl_mesh_PrepareJoinerRequest_DEFAULT NULL -#define particle_ctrl_mesh_PrepareJoinerRequest_network_MSGTYPE particle_ctrl_mesh_NetworkInfo - -#define particle_ctrl_mesh_PrepareJoinerReply_FIELDLIST(X, a) \ -X(a, CALLBACK, SINGULAR, STRING, eui64, 1) \ -X(a, CALLBACK, SINGULAR, STRING, password, 2) -#define particle_ctrl_mesh_PrepareJoinerReply_CALLBACK pb_default_field_callback -#define particle_ctrl_mesh_PrepareJoinerReply_DEFAULT NULL - -#define particle_ctrl_mesh_AddJoinerRequest_FIELDLIST(X, a) \ -X(a, CALLBACK, SINGULAR, STRING, eui64, 1) \ -X(a, CALLBACK, SINGULAR, STRING, password, 2) \ -X(a, STATIC, SINGULAR, UINT32, timeout, 3) -#define particle_ctrl_mesh_AddJoinerRequest_CALLBACK pb_default_field_callback -#define particle_ctrl_mesh_AddJoinerRequest_DEFAULT NULL - -#define particle_ctrl_mesh_AddJoinerReply_FIELDLIST(X, a) \ - -#define particle_ctrl_mesh_AddJoinerReply_CALLBACK NULL -#define particle_ctrl_mesh_AddJoinerReply_DEFAULT NULL - -#define particle_ctrl_mesh_RemoveJoinerRequest_FIELDLIST(X, a) \ -X(a, CALLBACK, SINGULAR, STRING, eui64, 1) -#define particle_ctrl_mesh_RemoveJoinerRequest_CALLBACK pb_default_field_callback -#define particle_ctrl_mesh_RemoveJoinerRequest_DEFAULT NULL - -#define particle_ctrl_mesh_RemoveJoinerReply_FIELDLIST(X, a) \ - -#define particle_ctrl_mesh_RemoveJoinerReply_CALLBACK NULL -#define particle_ctrl_mesh_RemoveJoinerReply_DEFAULT NULL - -#define particle_ctrl_mesh_JoinNetworkRequest_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, UINT32, timeout, 1) -#define particle_ctrl_mesh_JoinNetworkRequest_CALLBACK NULL -#define particle_ctrl_mesh_JoinNetworkRequest_DEFAULT NULL - -#define particle_ctrl_mesh_JoinNetworkReply_FIELDLIST(X, a) \ - -#define particle_ctrl_mesh_JoinNetworkReply_CALLBACK NULL -#define particle_ctrl_mesh_JoinNetworkReply_DEFAULT NULL - -#define particle_ctrl_mesh_LeaveNetworkRequest_FIELDLIST(X, a) \ - -#define particle_ctrl_mesh_LeaveNetworkRequest_CALLBACK NULL -#define particle_ctrl_mesh_LeaveNetworkRequest_DEFAULT NULL - -#define particle_ctrl_mesh_LeaveNetworkReply_FIELDLIST(X, a) \ - -#define particle_ctrl_mesh_LeaveNetworkReply_CALLBACK NULL -#define particle_ctrl_mesh_LeaveNetworkReply_DEFAULT NULL - -#define particle_ctrl_mesh_GetNetworkInfoRequest_FIELDLIST(X, a) \ - -#define particle_ctrl_mesh_GetNetworkInfoRequest_CALLBACK NULL -#define particle_ctrl_mesh_GetNetworkInfoRequest_DEFAULT NULL - -#define particle_ctrl_mesh_GetNetworkInfoReply_FIELDLIST(X, a) \ -X(a, STATIC, OPTIONAL, MESSAGE, network, 1) -#define particle_ctrl_mesh_GetNetworkInfoReply_CALLBACK NULL -#define particle_ctrl_mesh_GetNetworkInfoReply_DEFAULT NULL -#define particle_ctrl_mesh_GetNetworkInfoReply_network_MSGTYPE particle_ctrl_mesh_NetworkInfo - -#define particle_ctrl_mesh_ScanNetworksRequest_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, UINT32, duration, 1) -#define particle_ctrl_mesh_ScanNetworksRequest_CALLBACK NULL -#define particle_ctrl_mesh_ScanNetworksRequest_DEFAULT NULL - -#define particle_ctrl_mesh_ScanNetworksReply_FIELDLIST(X, a) \ -X(a, CALLBACK, REPEATED, MESSAGE, networks, 1) -#define particle_ctrl_mesh_ScanNetworksReply_CALLBACK pb_default_field_callback -#define particle_ctrl_mesh_ScanNetworksReply_DEFAULT NULL -#define particle_ctrl_mesh_ScanNetworksReply_networks_MSGTYPE particle_ctrl_mesh_NetworkInfo - -#define particle_ctrl_mesh_DiagnosticInfo_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, BYTES, ext_mac_address, 1) \ -X(a, STATIC, SINGULAR, UINT32, rloc, 2) \ -X(a, STATIC, SINGULAR, UINT32, mode, 3) \ -X(a, STATIC, SINGULAR, UINT32, timeout, 4) \ -X(a, STATIC, OPTIONAL, MESSAGE, connectivity, 5) \ -X(a, STATIC, OPTIONAL, MESSAGE, route64, 6) \ -X(a, STATIC, OPTIONAL, MESSAGE, leader_data, 7) \ -X(a, STATIC, OPTIONAL, MESSAGE, network_data, 8) \ -X(a, CALLBACK, REPEATED, MESSAGE, ipv6_address_list, 9) \ -X(a, STATIC, OPTIONAL, MESSAGE, mac_counters, 10) \ -X(a, STATIC, SINGULAR, UINT32, battery_level, 15) \ -X(a, STATIC, SINGULAR, UINT32, supply_voltage, 16) \ -X(a, STATIC, OPTIONAL, MESSAGE, child_table, 17) \ -X(a, STATIC, SINGULAR, BYTES, channel_pages, 18) \ -X(a, CALLBACK, REPEATED, UENUM, type_list, 19) \ -X(a, STATIC, SINGULAR, UINT32, max_child_timeout, 20) \ -X(a, STATIC, SINGULAR, BYTES, device_id, 100) -#define particle_ctrl_mesh_DiagnosticInfo_CALLBACK pb_default_field_callback -#define particle_ctrl_mesh_DiagnosticInfo_DEFAULT NULL -#define particle_ctrl_mesh_DiagnosticInfo_connectivity_MSGTYPE particle_ctrl_mesh_DiagnosticInfo_Connectivity -#define particle_ctrl_mesh_DiagnosticInfo_route64_MSGTYPE particle_ctrl_mesh_DiagnosticInfo_Route64 -#define particle_ctrl_mesh_DiagnosticInfo_leader_data_MSGTYPE particle_ctrl_mesh_DiagnosticInfo_LeaderData -#define particle_ctrl_mesh_DiagnosticInfo_network_data_MSGTYPE particle_ctrl_mesh_DiagnosticInfo_NetworkData -#define particle_ctrl_mesh_DiagnosticInfo_ipv6_address_list_MSGTYPE particle_ctrl_Ipv6Address -#define particle_ctrl_mesh_DiagnosticInfo_mac_counters_MSGTYPE particle_ctrl_mesh_DiagnosticInfo_MacCounters -#define particle_ctrl_mesh_DiagnosticInfo_child_table_MSGTYPE particle_ctrl_mesh_DiagnosticInfo_ChildTable - -#define particle_ctrl_mesh_DiagnosticInfo_Connectivity_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, UINT32, parent_priority, 1) \ -X(a, STATIC, SINGULAR, UINT32, link_quality_1, 2) \ -X(a, STATIC, SINGULAR, UINT32, link_quality_2, 3) \ -X(a, STATIC, SINGULAR, UINT32, link_quality_3, 4) \ -X(a, STATIC, SINGULAR, UINT32, leader_cost, 5) \ -X(a, STATIC, SINGULAR, UINT32, id_sequence, 6) \ -X(a, STATIC, SINGULAR, UINT32, active_routers, 7) \ -X(a, STATIC, SINGULAR, UINT32, sed_buffer_size, 8) \ -X(a, STATIC, SINGULAR, UINT32, sed_datagram_count, 9) -#define particle_ctrl_mesh_DiagnosticInfo_Connectivity_CALLBACK NULL -#define particle_ctrl_mesh_DiagnosticInfo_Connectivity_DEFAULT NULL - -#define particle_ctrl_mesh_DiagnosticInfo_Route64_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, UINT32, id_sequence, 1) \ -X(a, CALLBACK, REPEATED, MESSAGE, routes, 2) -#define particle_ctrl_mesh_DiagnosticInfo_Route64_CALLBACK pb_default_field_callback -#define particle_ctrl_mesh_DiagnosticInfo_Route64_DEFAULT NULL -#define particle_ctrl_mesh_DiagnosticInfo_Route64_routes_MSGTYPE particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData - -#define particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, UINT32, router_rloc, 1) \ -X(a, STATIC, SINGULAR, UINT32, link_quality_out, 2) \ -X(a, STATIC, SINGULAR, UINT32, link_quality_in, 3) \ -X(a, STATIC, SINGULAR, UINT32, route_cost, 4) -#define particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData_CALLBACK NULL -#define particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData_DEFAULT NULL - -#define particle_ctrl_mesh_DiagnosticInfo_LeaderData_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, UINT32, partition_id, 1) \ -X(a, STATIC, SINGULAR, UINT32, weighting, 2) \ -X(a, STATIC, SINGULAR, UINT32, data_version, 3) \ -X(a, STATIC, SINGULAR, UINT32, stable_data_version, 4) \ -X(a, STATIC, SINGULAR, UINT32, leader_rloc, 5) -#define particle_ctrl_mesh_DiagnosticInfo_LeaderData_CALLBACK NULL -#define particle_ctrl_mesh_DiagnosticInfo_LeaderData_DEFAULT NULL - -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_FIELDLIST(X, a) \ -X(a, STATIC, OPTIONAL, MESSAGE, stable, 1) \ -X(a, STATIC, OPTIONAL, MESSAGE, temporary, 2) -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_CALLBACK NULL -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_DEFAULT NULL -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_stable_MSGTYPE particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_temporary_MSGTYPE particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data - -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_FIELDLIST(X, a) \ -X(a, CALLBACK, REPEATED, MESSAGE, entries, 1) -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_CALLBACK pb_default_field_callback -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_DEFAULT NULL -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_entries_MSGTYPE particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry - -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, UINT32, rloc, 1) \ -X(a, STATIC, SINGULAR, ENUM, preference, 2) -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry_CALLBACK NULL -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry_DEFAULT NULL - -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_FIELDLIST(X, a) \ -X(a, CALLBACK, REPEATED, MESSAGE, entries, 1) -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_CALLBACK pb_default_field_callback -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_DEFAULT NULL -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_entries_MSGTYPE particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry - -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, UINT32, rloc, 1) \ -X(a, STATIC, SINGULAR, ENUM, preference, 2) \ -X(a, STATIC, SINGULAR, UINT32, flags, 3) -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_CALLBACK NULL -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_DEFAULT NULL - -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, UINT32, cid, 1) \ -X(a, STATIC, SINGULAR, BOOL, compress, 2) \ -X(a, STATIC, SINGULAR, UINT32, context_length, 3) -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context_CALLBACK NULL -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context_DEFAULT NULL - -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, UINT32, domain_id, 1) \ -X(a, STATIC, SINGULAR, UINT32, prefix_length, 2) \ -X(a, STATIC, SINGULAR, BYTES, prefix, 3) \ -X(a, CALLBACK, REPEATED, MESSAGE, context, 4) \ -X(a, STATIC, OPTIONAL, MESSAGE, has_route, 5) \ -X(a, STATIC, OPTIONAL, MESSAGE, border_router, 6) -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_CALLBACK pb_default_field_callback -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_DEFAULT NULL -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_context_MSGTYPE particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_has_route_MSGTYPE particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_border_router_MSGTYPE particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter - -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, UINT32, rloc, 1) \ -X(a, CALLBACK, SINGULAR, BYTES, data, 2) -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server_CALLBACK pb_default_field_callback -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server_DEFAULT NULL - -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, UINT32, sid, 1) \ -X(a, STATIC, SINGULAR, UINT32, enterprise_number, 2) \ -X(a, CALLBACK, SINGULAR, BYTES, data, 3) \ -X(a, CALLBACK, REPEATED, MESSAGE, servers, 4) -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service_CALLBACK pb_default_field_callback -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service_DEFAULT NULL -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service_servers_MSGTYPE particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server - -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_FIELDLIST(X, a) \ -X(a, CALLBACK, REPEATED, MESSAGE, prefixes, 1) \ -X(a, CALLBACK, REPEATED, MESSAGE, services, 2) -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_CALLBACK pb_default_field_callback -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_DEFAULT NULL -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_prefixes_MSGTYPE particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_services_MSGTYPE particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service - -#define particle_ctrl_mesh_DiagnosticInfo_MacCounters_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, UINT32, if_in_unknown_protos, 1) \ -X(a, STATIC, SINGULAR, UINT32, if_in_errors, 2) \ -X(a, STATIC, SINGULAR, UINT32, if_out_errors, 3) \ -X(a, STATIC, SINGULAR, UINT32, if_in_ucast_pkts, 4) \ -X(a, STATIC, SINGULAR, UINT32, if_in_broadcast_pkts, 5) \ -X(a, STATIC, SINGULAR, UINT32, if_in_discards, 6) \ -X(a, STATIC, SINGULAR, UINT32, if_out_ucast_pkts, 7) \ -X(a, STATIC, SINGULAR, UINT32, if_out_broadcast_pkts, 8) \ -X(a, STATIC, SINGULAR, UINT32, if_out_discards, 9) -#define particle_ctrl_mesh_DiagnosticInfo_MacCounters_CALLBACK NULL -#define particle_ctrl_mesh_DiagnosticInfo_MacCounters_DEFAULT NULL - -#define particle_ctrl_mesh_DiagnosticInfo_ChildTable_FIELDLIST(X, a) \ -X(a, CALLBACK, REPEATED, MESSAGE, children, 1) -#define particle_ctrl_mesh_DiagnosticInfo_ChildTable_CALLBACK pb_default_field_callback -#define particle_ctrl_mesh_DiagnosticInfo_ChildTable_DEFAULT NULL -#define particle_ctrl_mesh_DiagnosticInfo_ChildTable_children_MSGTYPE particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry - -#define particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, UINT32, timeout, 1) \ -X(a, STATIC, SINGULAR, UINT32, child_id, 2) \ -X(a, STATIC, SINGULAR, UINT32, mode, 3) -#define particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry_CALLBACK NULL -#define particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry_DEFAULT NULL - -#define particle_ctrl_mesh_GetNetworkDiagnosticsRequest_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, UINT32, flags, 1) \ -X(a, CALLBACK, REPEATED, UENUM, diagnostic_types, 2) \ -X(a, STATIC, SINGULAR, UINT32, timeout, 3) -#define particle_ctrl_mesh_GetNetworkDiagnosticsRequest_CALLBACK pb_default_field_callback -#define particle_ctrl_mesh_GetNetworkDiagnosticsRequest_DEFAULT NULL - -#define particle_ctrl_mesh_GetNetworkDiagnosticsReply_FIELDLIST(X, a) \ -X(a, CALLBACK, REPEATED, MESSAGE, nodes, 1) -#define particle_ctrl_mesh_GetNetworkDiagnosticsReply_CALLBACK pb_default_field_callback -#define particle_ctrl_mesh_GetNetworkDiagnosticsReply_DEFAULT NULL -#define particle_ctrl_mesh_GetNetworkDiagnosticsReply_nodes_MSGTYPE particle_ctrl_mesh_DiagnosticInfo - -extern const pb_msgdesc_t particle_ctrl_mesh_NetworkInfo_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_AuthRequest_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_AuthReply_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_CreateNetworkRequest_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_CreateNetworkReply_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_StartCommissionerRequest_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_StartCommissionerReply_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_StopCommissionerRequest_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_StopCommissionerReply_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_PrepareJoinerRequest_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_PrepareJoinerReply_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_AddJoinerRequest_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_AddJoinerReply_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_RemoveJoinerRequest_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_RemoveJoinerReply_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_JoinNetworkRequest_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_JoinNetworkReply_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_LeaveNetworkRequest_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_LeaveNetworkReply_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_GetNetworkInfoRequest_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_GetNetworkInfoReply_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_ScanNetworksRequest_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_ScanNetworksReply_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_DiagnosticInfo_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_DiagnosticInfo_Connectivity_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_DiagnosticInfo_Route64_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_DiagnosticInfo_LeaderData_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_DiagnosticInfo_MacCounters_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_DiagnosticInfo_ChildTable_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_GetNetworkDiagnosticsRequest_msg; -extern const pb_msgdesc_t particle_ctrl_mesh_GetNetworkDiagnosticsReply_msg; - -/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ -#define particle_ctrl_mesh_NetworkInfo_fields &particle_ctrl_mesh_NetworkInfo_msg -#define particle_ctrl_mesh_AuthRequest_fields &particle_ctrl_mesh_AuthRequest_msg -#define particle_ctrl_mesh_AuthReply_fields &particle_ctrl_mesh_AuthReply_msg -#define particle_ctrl_mesh_CreateNetworkRequest_fields &particle_ctrl_mesh_CreateNetworkRequest_msg -#define particle_ctrl_mesh_CreateNetworkReply_fields &particle_ctrl_mesh_CreateNetworkReply_msg -#define particle_ctrl_mesh_StartCommissionerRequest_fields &particle_ctrl_mesh_StartCommissionerRequest_msg -#define particle_ctrl_mesh_StartCommissionerReply_fields &particle_ctrl_mesh_StartCommissionerReply_msg -#define particle_ctrl_mesh_StopCommissionerRequest_fields &particle_ctrl_mesh_StopCommissionerRequest_msg -#define particle_ctrl_mesh_StopCommissionerReply_fields &particle_ctrl_mesh_StopCommissionerReply_msg -#define particle_ctrl_mesh_PrepareJoinerRequest_fields &particle_ctrl_mesh_PrepareJoinerRequest_msg -#define particle_ctrl_mesh_PrepareJoinerReply_fields &particle_ctrl_mesh_PrepareJoinerReply_msg -#define particle_ctrl_mesh_AddJoinerRequest_fields &particle_ctrl_mesh_AddJoinerRequest_msg -#define particle_ctrl_mesh_AddJoinerReply_fields &particle_ctrl_mesh_AddJoinerReply_msg -#define particle_ctrl_mesh_RemoveJoinerRequest_fields &particle_ctrl_mesh_RemoveJoinerRequest_msg -#define particle_ctrl_mesh_RemoveJoinerReply_fields &particle_ctrl_mesh_RemoveJoinerReply_msg -#define particle_ctrl_mesh_JoinNetworkRequest_fields &particle_ctrl_mesh_JoinNetworkRequest_msg -#define particle_ctrl_mesh_JoinNetworkReply_fields &particle_ctrl_mesh_JoinNetworkReply_msg -#define particle_ctrl_mesh_LeaveNetworkRequest_fields &particle_ctrl_mesh_LeaveNetworkRequest_msg -#define particle_ctrl_mesh_LeaveNetworkReply_fields &particle_ctrl_mesh_LeaveNetworkReply_msg -#define particle_ctrl_mesh_GetNetworkInfoRequest_fields &particle_ctrl_mesh_GetNetworkInfoRequest_msg -#define particle_ctrl_mesh_GetNetworkInfoReply_fields &particle_ctrl_mesh_GetNetworkInfoReply_msg -#define particle_ctrl_mesh_ScanNetworksRequest_fields &particle_ctrl_mesh_ScanNetworksRequest_msg -#define particle_ctrl_mesh_ScanNetworksReply_fields &particle_ctrl_mesh_ScanNetworksReply_msg -#define particle_ctrl_mesh_DiagnosticInfo_fields &particle_ctrl_mesh_DiagnosticInfo_msg -#define particle_ctrl_mesh_DiagnosticInfo_Connectivity_fields &particle_ctrl_mesh_DiagnosticInfo_Connectivity_msg -#define particle_ctrl_mesh_DiagnosticInfo_Route64_fields &particle_ctrl_mesh_DiagnosticInfo_Route64_msg -#define particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData_fields &particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData_msg -#define particle_ctrl_mesh_DiagnosticInfo_LeaderData_fields &particle_ctrl_mesh_DiagnosticInfo_LeaderData_msg -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_fields &particle_ctrl_mesh_DiagnosticInfo_NetworkData_msg -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_fields &particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_msg -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry_fields &particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry_msg -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_fields &particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_msg -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_fields &particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_msg -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context_fields &particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context_msg -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_fields &particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_msg -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server_fields &particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server_msg -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service_fields &particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service_msg -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_fields &particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_msg -#define particle_ctrl_mesh_DiagnosticInfo_MacCounters_fields &particle_ctrl_mesh_DiagnosticInfo_MacCounters_msg -#define particle_ctrl_mesh_DiagnosticInfo_ChildTable_fields &particle_ctrl_mesh_DiagnosticInfo_ChildTable_msg -#define particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry_fields &particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry_msg -#define particle_ctrl_mesh_GetNetworkDiagnosticsRequest_fields &particle_ctrl_mesh_GetNetworkDiagnosticsRequest_msg -#define particle_ctrl_mesh_GetNetworkDiagnosticsReply_fields &particle_ctrl_mesh_GetNetworkDiagnosticsReply_msg - -/* Maximum encoded size of messages (where known) */ -/* particle_ctrl_mesh_NetworkInfo_size depends on runtime parameters */ -/* particle_ctrl_mesh_AuthRequest_size depends on runtime parameters */ -/* particle_ctrl_mesh_CreateNetworkRequest_size depends on runtime parameters */ -/* particle_ctrl_mesh_CreateNetworkReply_size depends on runtime parameters */ -/* particle_ctrl_mesh_PrepareJoinerRequest_size depends on runtime parameters */ -/* particle_ctrl_mesh_PrepareJoinerReply_size depends on runtime parameters */ -/* particle_ctrl_mesh_AddJoinerRequest_size depends on runtime parameters */ -/* particle_ctrl_mesh_RemoveJoinerRequest_size depends on runtime parameters */ -/* particle_ctrl_mesh_GetNetworkInfoReply_size depends on runtime parameters */ -/* particle_ctrl_mesh_ScanNetworksReply_size depends on runtime parameters */ -/* particle_ctrl_mesh_DiagnosticInfo_size depends on runtime parameters */ -/* particle_ctrl_mesh_DiagnosticInfo_Route64_size depends on runtime parameters */ -/* particle_ctrl_mesh_DiagnosticInfo_NetworkData_size depends on runtime parameters */ -/* particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_size depends on runtime parameters */ -/* particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_size depends on runtime parameters */ -/* particle_ctrl_mesh_DiagnosticInfo_NetworkData_Prefix_size depends on runtime parameters */ -/* particle_ctrl_mesh_DiagnosticInfo_NetworkData_Server_size depends on runtime parameters */ -/* particle_ctrl_mesh_DiagnosticInfo_NetworkData_Service_size depends on runtime parameters */ -/* particle_ctrl_mesh_DiagnosticInfo_NetworkData_Data_size depends on runtime parameters */ -/* particle_ctrl_mesh_DiagnosticInfo_ChildTable_size depends on runtime parameters */ -/* particle_ctrl_mesh_GetNetworkDiagnosticsRequest_size depends on runtime parameters */ -/* particle_ctrl_mesh_GetNetworkDiagnosticsReply_size depends on runtime parameters */ -#define particle_ctrl_mesh_AddJoinerReply_size 0 -#define particle_ctrl_mesh_AuthReply_size 0 -#define particle_ctrl_mesh_DiagnosticInfo_ChildTable_ChildEntry_size 18 -#define particle_ctrl_mesh_DiagnosticInfo_Connectivity_size 54 -#define particle_ctrl_mesh_DiagnosticInfo_LeaderData_size 30 -#define particle_ctrl_mesh_DiagnosticInfo_MacCounters_size 54 -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_BorderRouter_BorderRouterEntry_size 23 -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_Context_size 14 -#define particle_ctrl_mesh_DiagnosticInfo_NetworkData_HasRoute_HasRouteEntry_size 17 -#define particle_ctrl_mesh_DiagnosticInfo_Route64_RouteData_size 24 -#define particle_ctrl_mesh_GetNetworkInfoRequest_size 0 -#define particle_ctrl_mesh_JoinNetworkReply_size 0 -#define particle_ctrl_mesh_JoinNetworkRequest_size 6 -#define particle_ctrl_mesh_LeaveNetworkReply_size 0 -#define particle_ctrl_mesh_LeaveNetworkRequest_size 0 -#define particle_ctrl_mesh_RemoveJoinerReply_size 0 -#define particle_ctrl_mesh_ScanNetworksRequest_size 6 -#define particle_ctrl_mesh_StartCommissionerReply_size 0 -#define particle_ctrl_mesh_StartCommissionerRequest_size 6 -#define particle_ctrl_mesh_StopCommissionerReply_size 0 -#define particle_ctrl_mesh_StopCommissionerRequest_size 0 - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif diff --git a/system/src/control/storage.cpp b/system/src/control/storage.cpp index 0fd7e83783..30fab30afe 100644 --- a/system/src/control/storage.cpp +++ b/system/src/control/storage.cpp @@ -34,7 +34,7 @@ #include "platforms.h" -#include "storage.pb.h" +#include "control/storage.pb.h" #include diff --git a/system/src/control/wifi_new.cpp b/system/src/control/wifi_new.cpp index fbbd2a2af8..1e8ffe0a7b 100644 --- a/system/src/control/wifi_new.cpp +++ b/system/src/control/wifi_new.cpp @@ -32,7 +32,7 @@ #include "spark_wiring_vector.h" -#include "wifi_new.pb.h" +#include "control/wifi_new.pb.h" #include "system_event.h" #include "delay_hal.h" diff --git a/system/src/main.cpp b/system/src/main.cpp index cd7804577d..cdd77e0e98 100644 --- a/system/src/main.cpp +++ b/system/src/main.cpp @@ -61,6 +61,7 @@ #include "spark_wiring_system.h" #include "system_power.h" #include "spark_wiring_wifi.h" +#include "server_config.h" // FIXME #include "system_control_internal.h" @@ -668,8 +669,7 @@ int resetSettingsToFactoryDefaultsIfNeeded() { CHECK(dct_write_app_data(devPrivKey.get(), DCT_ALT_DEVICE_PRIVATE_KEY_OFFSET, DCT_ALT_DEVICE_PRIVATE_KEY_SIZE)); CHECK(dct_write_app_data(devPubKey.get(), DCT_ALT_DEVICE_PUBLIC_KEY_OFFSET, DCT_ALT_DEVICE_PUBLIC_KEY_SIZE)); // Restore default server key and address - CHECK(dct_write_app_data(backup_udp_public_server_key, DCT_ALT_SERVER_PUBLIC_KEY_OFFSET, backup_udp_public_server_key_size)); - CHECK(dct_write_app_data(backup_udp_public_server_address, DCT_ALT_SERVER_ADDRESS_OFFSET, backup_udp_public_server_address_size)); + ServerConfig::instance()->restoreDefaultSettings(); #endif // HAL_PLATFORM_NRF52840 #endif // !defined(SPARK_NO_PLATFORM) && HAL_PLATFORM_DCT return 0; diff --git a/system/src/server_config.cpp b/system/src/server_config.cpp new file mode 100644 index 0000000000..987ecd5784 --- /dev/null +++ b/system/src/server_config.cpp @@ -0,0 +1,273 @@ +/* + * Copyright (c) 2022 Particle Industries, Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#undef LOG_COMPILE_TIME_LEVEL + +#include +#include + +#include +#include + +#include "server_config.h" +#include "ota_flash_hal.h" // For ServerAddress +#include "dct_hal.h" +#include "core_hal.h" +#include "parse_server_address.h" +#include "mbedtls_util.h" +#include "sha256.h" +#include "system_error.h" +#include "endian_util.h" +#include "logging.h" +#include "scope_guard.h" +#include "check.h" + +namespace particle { + +namespace { + +// EC public key in DER format +const uint8_t DEFAULT_UDP_SERVER_PUBLIC_KEY[] = { + 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, + 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, + 0x42, 0x00, 0x04, 0x50, 0x9b, 0xfc, 0x18, 0x56, 0x48, 0xc3, 0x3f, 0x80, + 0x90, 0x7a, 0xe1, 0x32, 0x60, 0xdf, 0x33, 0x28, 0x21, 0x15, 0x20, 0x9e, + 0x54, 0xa2, 0x2f, 0x2b, 0x10, 0x59, 0x84, 0xa4, 0x63, 0x62, 0xc0, 0x7c, + 0x26, 0x79, 0xf6, 0xe4, 0xce, 0x76, 0xca, 0x00, 0x2d, 0x3d, 0xe4, 0xbf, + 0x2e, 0x9e, 0x3a, 0x62, 0x15, 0x1c, 0x48, 0x17, 0x9b, 0xd8, 0x09, 0xdd, + 0xce, 0x9c, 0x5d, 0xc3, 0x0f, 0x54, 0xb8 +}; + +// RSA public key in DER format +const uint8_t DEFAULT_TCP_SERVER_PUBLIC_KEY[] = { + 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, + 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, + 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xbe, 0xcc, 0xbe, + 0x43, 0xdb, 0x8e, 0xea, 0x15, 0x27, 0xa6, 0xbb, 0x52, 0x6d, 0xe1, 0x51, + 0x2b, 0xa0, 0xab, 0xcc, 0xa1, 0x64, 0x77, 0x48, 0xad, 0x7c, 0x66, 0xfc, + 0x80, 0x7f, 0xf6, 0x99, 0xa5, 0x25, 0xf2, 0xf2, 0xda, 0xe0, 0x43, 0xcf, + 0x3a, 0x26, 0xa4, 0x9b, 0xa1, 0x87, 0x03, 0x0e, 0x9a, 0x8d, 0x23, 0x9a, + 0xbc, 0xea, 0x99, 0xea, 0x68, 0xd3, 0x5a, 0x14, 0xb1, 0x26, 0x0f, 0xbd, + 0xaa, 0x6d, 0x6f, 0x0c, 0xac, 0xc4, 0x77, 0x2c, 0xd1, 0xc5, 0xc8, 0xb1, + 0xd1, 0x7b, 0x68, 0xe0, 0x25, 0x73, 0x7b, 0x52, 0x89, 0x68, 0x20, 0xbd, + 0x06, 0xc6, 0xf0, 0xe6, 0x00, 0x30, 0xc0, 0xe0, 0xcf, 0xf6, 0x1b, 0x3a, + 0x45, 0xe9, 0xc4, 0x5b, 0x55, 0x17, 0x06, 0xa3, 0xd3, 0x4a, 0xc6, 0xd5, + 0xb8, 0xd2, 0x17, 0x02, 0xb5, 0x27, 0x7d, 0x8d, 0xe4, 0xd4, 0x7d, 0xd3, + 0xed, 0xc0, 0x1d, 0x8a, 0x7c, 0x25, 0x1e, 0x21, 0x4a, 0x51, 0xae, 0x57, + 0x06, 0xdd, 0x60, 0xbc, 0xa1, 0x34, 0x90, 0xaa, 0xcc, 0x09, 0x9e, 0x3b, + 0x3a, 0x41, 0x4c, 0x3c, 0x9d, 0xf3, 0xfd, 0xfd, 0xb7, 0x27, 0xc1, 0x59, + 0x81, 0x98, 0x54, 0x60, 0x4a, 0x62, 0x7a, 0xa4, 0x9a, 0xbf, 0xdf, 0x92, + 0x1b, 0x3e, 0xfc, 0xa7, 0xe4, 0xa4, 0xb3, 0x3a, 0x9a, 0x5f, 0x57, 0x93, + 0x8e, 0xeb, 0x19, 0x64, 0x95, 0x22, 0x4a, 0x2c, 0xd5, 0x60, 0xf5, 0xf9, + 0xd0, 0x03, 0x50, 0x83, 0x69, 0xc0, 0x6b, 0x53, 0xf0, 0xf0, 0xda, 0xf8, + 0x13, 0x82, 0x1f, 0xcc, 0xbb, 0x5f, 0xe2, 0xc1, 0xdf, 0x3a, 0xe9, 0x7f, + 0x5d, 0xe2, 0x7d, 0xb9, 0x50, 0x80, 0x3c, 0x58, 0x33, 0xef, 0x8c, 0xf3, + 0x80, 0x3f, 0x11, 0x01, 0xd2, 0x68, 0x86, 0x5f, 0x3c, 0x5e, 0xe6, 0xc1, + 0x8e, 0x32, 0x2b, 0x28, 0xcb, 0xb5, 0xcc, 0x1b, 0xa8, 0x50, 0x5e, 0xa7, + 0x0d, 0x02, 0x03, 0x01, 0x00, 0x01 +}; + +// EC public key in DER format +const uint8_t SERVER_MOVED_SIGNATURE_PUBLIC_KEY[] = { + 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, + 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, + 0x42, 0x00, 0x04, 0xf9, 0xd2, 0x85, 0xc4, 0xfa, 0xb7, 0x0f, 0x0d, 0x04, + 0xa8, 0x5a, 0xd4, 0x34, 0xae, 0x1c, 0x90, 0xe4, 0x8a, 0x4a, 0xa5, 0x6c, + 0x4d, 0xa9, 0xf0, 0xe5, 0xdb, 0x68, 0xde, 0xf6, 0xf2, 0x20, 0x2e, 0x59, + 0xfc, 0x51, 0x75, 0xc7, 0x56, 0x78, 0xea, 0xe7, 0xf1, 0x27, 0x2d, 0x35, + 0x2c, 0x10, 0xae, 0x85, 0x6f, 0x7e, 0x4b, 0x9d, 0xee, 0x51, 0xa5, 0xc2, + 0x28, 0x7a, 0x92, 0xc7, 0xd4, 0x7c, 0x71 +}; + +const auto DEFAULT_UDP_SERVER_ADDRESS = "$id.udp.particle.io"; +const auto DEFAULT_TCP_SERVER_ADDRESS = "device.tcp.particle.io"; + +const uint16_t DEFAULT_UDP_SERVER_PORT = 5684; +const uint16_t DEFAULT_TCP_SERVER_PORT = 5683; + +int updateServerSettings(const char* addr, uint16_t port, const uint8_t* pubKey, size_t pubKeySize, bool udp) { + LOG(INFO, "Updating %s server settings", udp ? "UDP" : "TCP"); + LOG(INFO, "Address: \"%s\"; port: %u", addr, (unsigned)port); + LOG(TRACE, "Public key (%u bytes):", (unsigned)pubKeySize); + LOG_DUMP(TRACE, pubKey, pubKeySize); + LOG_PRINT(TRACE, "\r\n"); + // Parse and validate the new server address + ServerAddress saddr = {}; + CHECK(parseServerAddressString(&saddr, addr)); + saddr.port = port; + // Erase both the current server key and address so that we don't potentially end up with a + // key and address from different servers in the DCT + size_t maxPubKeySize = udp ? DCT_ALT_SERVER_PUBLIC_KEY_SIZE : DCT_SERVER_PUBLIC_KEY_SIZE; + if (pubKeySize > maxPubKeySize) { + return SYSTEM_ERROR_TOO_LARGE; + } + size_t maxAddrSize = udp ? DCT_ALT_SERVER_ADDRESS_SIZE : DCT_SERVER_ADDRESS_SIZE; + size_t bufSize = std::max(maxPubKeySize, maxAddrSize); + std::unique_ptr buf(new(std::nothrow) uint8_t[bufSize]); + if (!buf) { + return SYSTEM_ERROR_NO_MEMORY; + } + memset(buf.get(), 0xff, bufSize); + size_t addrOffs = udp ? DCT_ALT_SERVER_ADDRESS_OFFSET : DCT_SERVER_ADDRESS_OFFSET; + int r = dct_write_app_data(buf.get(), addrOffs, maxAddrSize); + if (r != 0) { + return SYSTEM_ERROR_IO; + } + size_t pubKeyOffs = udp ? DCT_ALT_SERVER_PUBLIC_KEY_OFFSET : DCT_SERVER_PUBLIC_KEY_OFFSET; + r = dct_write_app_data(buf.get(), pubKeyOffs, maxPubKeySize); + if (r != 0) { + return SYSTEM_ERROR_IO; + } + // Write the server key + r = dct_write_app_data(pubKey, pubKeyOffs, pubKeySize); + if (r != 0) { + return SYSTEM_ERROR_IO; + } + // Serialize and write the server address + CHECK(encodeServerAddressData(&saddr, buf.get(), maxAddrSize)); + r = dct_write_app_data(buf.get(), addrOffs, maxAddrSize); + if (r != 0) { + return SYSTEM_ERROR_IO; + } + return 0; +} + +int validateServerSettings(bool udp) { + size_t maxPubKeySize = udp ? DCT_ALT_SERVER_PUBLIC_KEY_SIZE : DCT_SERVER_PUBLIC_KEY_SIZE; + size_t maxAddrSize = udp ? DCT_ALT_SERVER_ADDRESS_SIZE : DCT_SERVER_ADDRESS_SIZE; + size_t bufSize = std::max(maxPubKeySize, maxAddrSize); + std::unique_ptr buf(new(std::nothrow) uint8_t[bufSize]); + if (!buf) { + return SYSTEM_ERROR_NO_MEMORY; + } + // Load and validate the server address + size_t addrOffs = udp ? DCT_ALT_SERVER_ADDRESS_OFFSET : DCT_SERVER_ADDRESS_OFFSET; + int r = dct_read_app_data_copy(addrOffs, buf.get(), maxAddrSize); + if (r != 0) { + return SYSTEM_ERROR_IO; + } + ServerAddress addr = {}; + parseServerAddressData(&addr, buf.get(), maxAddrSize); + if (addr.addr_type == INVALID_INTERNET_ADDRESS) { + return SYSTEM_ERROR_BAD_DATA; + } + // Load the server key + size_t pubKeyOffs = udp ? DCT_ALT_SERVER_PUBLIC_KEY_OFFSET : DCT_SERVER_PUBLIC_KEY_OFFSET; + r = dct_read_app_data_copy(pubKeyOffs, buf.get(), maxPubKeySize); + if (r != 0) { + return SYSTEM_ERROR_IO; + } + // Determine the actual size of the key + uint8_t* p = buf.get(); + size_t pubKeySize = 0; + r = mbedtls_asn1_get_tag(&p, buf.get() + maxPubKeySize, &pubKeySize, MBEDTLS_ASN1_CONSTRUCTED | + MBEDTLS_ASN1_SEQUENCE); + if (r != 0) { + return SYSTEM_ERROR_BAD_DATA; + } + pubKeySize += p - buf.get(); // Include size of the tag and length fields + // Parse the key + mbedtls_pk_context pk = {}; + mbedtls_pk_init(&pk); + SCOPE_GUARD({ + mbedtls_pk_free(&pk); + }); + r = mbedtls_pk_parse_public_key(&pk, buf.get(), pubKeySize); + if (r != 0) { + return SYSTEM_ERROR_BAD_DATA; + } + return 0; +} + +inline bool udpEnabled() { + // XXX: The current gen platforms don't really allow changing the cloud transport protocol, + // but let's keep this check in place until the support for TCP is removed from the codebase + return HAL_Feature_Get(FEATURE_CLOUD_UDP); +} + +} // namespace + +int ServerConfig::updateSettings(const ServerSettings& conf) { + bool udp = udpEnabled(); + auto port = conf.port; + if (!port) { + port = udp ? DEFAULT_UDP_SERVER_PORT : DEFAULT_TCP_SERVER_PORT; + } + CHECK(updateServerSettings(conf.address, port, conf.publicKey, conf.publicKeySize, udp)); + return 0; +} + +int ServerConfig::validateSettings() const { + CHECK(validateServerSettings(udpEnabled())); + return 0; +} + +int ServerConfig::validateServerMovedRequest(const ServerMovedRequest& req) const { + if (!udpEnabled()) { + return SYSTEM_ERROR_NOT_SUPPORTED; + } + // Load the signature key + mbedtls_pk_context pk = {}; + mbedtls_pk_init(&pk); + SCOPE_GUARD({ + mbedtls_pk_free(&pk); + }); + CHECK_MBEDTLS(mbedtls_pk_parse_public_key(&pk, SERVER_MOVED_SIGNATURE_PUBLIC_KEY, sizeof(SERVER_MOVED_SIGNATURE_PUBLIC_KEY))); + // Hash the server settings + Sha256 sha; + CHECK(sha.init()); + CHECK(sha.start()); + uint32_t u32 = nativeToLittleEndian(req.publicKeySize); + CHECK(sha.update((const char*)&u32, sizeof(u32))); + CHECK(sha.update((const char*)req.publicKey, req.publicKeySize)); + size_t addrLen = strlen(req.address); + u32 = nativeToLittleEndian(addrLen); + CHECK(sha.update((const char*)&u32, sizeof(u32))); + CHECK(sha.update(req.address, addrLen)); + auto port = req.port; + if (!port) { + port = DEFAULT_UDP_SERVER_PORT; + } + uint16_t u16 = nativeToLittleEndian(port); + CHECK(sha.update((const char*)&u16, sizeof(u16))); + char hash[Sha256::HASH_SIZE] = {}; + CHECK(sha.finish(hash)); + // Verify the signature + int r = mbedtls_pk_verify(&pk, MBEDTLS_MD_SHA256, (const uint8_t*)hash, sizeof(hash), req.signature, req.signatureSize); + if (r != 0) { + return SYSTEM_ERROR_BAD_DATA; + } + return 0; +} + +int ServerConfig::restoreDefaultSettings() { + if (udpEnabled()) { + CHECK(updateServerSettings(DEFAULT_UDP_SERVER_ADDRESS, DEFAULT_UDP_SERVER_PORT, DEFAULT_UDP_SERVER_PUBLIC_KEY, + sizeof(DEFAULT_UDP_SERVER_PUBLIC_KEY), true /* udp */)); + } else { + CHECK(updateServerSettings(DEFAULT_TCP_SERVER_ADDRESS, DEFAULT_TCP_SERVER_PORT, DEFAULT_TCP_SERVER_PUBLIC_KEY, + sizeof(DEFAULT_TCP_SERVER_PUBLIC_KEY), false)); + } + return 0; +} + +ServerConfig* ServerConfig::instance() { + static ServerConfig conf; + return &conf; +} + +} // namespace particle diff --git a/system/src/server_config.h b/system/src/server_config.h new file mode 100644 index 0000000000..90bd2921f3 --- /dev/null +++ b/system/src/server_config.h @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2022 Particle Industries, Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#pragma once + +#include + +namespace particle { + +/** + * Server configuration manager. + */ +class ServerConfig { +public: + /** + * Server settings. + */ + struct ServerSettings { + const char* address; ///< Server address (an IP address or domain name). + const uint8_t* publicKey; ///< Server public key in DER format. + size_t publicKeySize; ///< Size of the server public key. + uint16_t port; ///< Server port. If 0, the default port will be used. + + ServerSettings() : + address(""), + publicKey(nullptr), + publicKeySize(0), + port(0) { + } + }; + + /** + * A request to change the server settings. + */ + struct ServerMovedRequest: ServerSettings { + const uint8_t* signature; ///< Request signature. + size_t signatureSize; ///< Size of the request signature. + + ServerMovedRequest() : + signature(nullptr), + signatureSize(0) { + } + }; + + /** + * Update the current server settings. + * + * @param conf Server settings. + * @return 0 if the settings were updated successfully, otherwise an error code defined by + * `system_error_t`. + */ + int updateSettings(const ServerSettings& conf); + + /** + * Validate the current server settings. + * + * @return 0 if the settings are valid, otherwise an error code defined by `system_error_t`. + */ + int validateSettings() const; + + /** + * Validate the signature of a ServerMoved request. + * + * @param req Request data. + * @return 0 if the signature is valid, otherwise an error code defined by `system_error_t`. + */ + int validateServerMovedRequest(const ServerMovedRequest& req) const; + + /** + * Restore the default server settings. + * + * @return 0 if the settings were restored successfully, otherwise an error code defined by + * `system_error_t`. + */ + int restoreDefaultSettings(); + + /** + * Get the global instance of this class. + * + * @return Instance. + */ + static ServerConfig* instance(); +}; + +} // namespace particle diff --git a/system/src/system_cloud_connection.cpp b/system/src/system_cloud_connection.cpp index 7435c228ac..22f858dc22 100644 --- a/system/src/system_cloud_connection.cpp +++ b/system/src/system_cloud_connection.cpp @@ -41,7 +41,6 @@ uint16_t cloud_udp_port = PORT_COAPS; // default Particle Cloud UDP port /* FIXME: */ extern uint8_t feature_cloud_udp; -extern uint32_t particle_key_errors; volatile bool cloud_socket_aborted = false; #if HAL_PLATFORM_CELLULAR @@ -140,22 +139,6 @@ int spark_cloud_socket_connect() ServerAddress server_addr = {}; HAL_FLASH_Read_ServerAddress(&server_addr); - - // if server address is erased, restore with a backup from system firmware - if (server_addr.addr_type != IP_ADDRESS && server_addr.addr_type != DOMAIN_NAME) { - LOG(WARN, "Public Server Address was blank, restoring."); - if (udp) { -#if HAL_PLATFORM_CLOUD_UDP - memcpy(&server_addr, backup_udp_public_server_address, backup_udp_public_server_address_size); -#endif // HAL_PLATFORM_CLOUD_UDP - } - else { -#if HAL_PLATFORM_CLOUD_TCP - memcpy(&server_addr, backup_tcp_public_server_address, sizeof(backup_tcp_public_server_address)); -#endif // HAL_PLATFORM_CLOUD_TCP - } - particle_key_errors |= SERVER_ADDRESS_BLANK; - } switch (server_addr.addr_type) { case IP_ADDRESS: diff --git a/system/src/system_cloud_internal.cpp b/system/src/system_cloud_internal.cpp index 7cc5948e6b..1073e96430 100644 --- a/system/src/system_cloud_internal.cpp +++ b/system/src/system_cloud_internal.cpp @@ -59,11 +59,16 @@ #endif // HAL_PLATFORM_MUXER_MAY_NEED_DELAY_IN_TX #include "system_version.h" #include "firmware_update.h" +#include "server_config.h" #if PLATFORM_ID == PLATFORM_GCC #include "device_config.h" #endif +#include "control/common.h" // FIXME: Move to another directory +#include "cloud/cloud.pb.h" +#include "nanopb_misc.h" + #include #include #include @@ -71,6 +76,8 @@ using namespace particle; using namespace particle::system; using particle::protocol::ProtocolError; +using particle::control::common::DecodedString; +using particle::control::common::DecodedCString; extern volatile uint8_t SPARK_UPDATE_PENDING_EVENT_RECEIVED; @@ -144,30 +151,13 @@ void systemEventHandler(const char* name, const char* data) } } else if (!strncmp(name, KEY_RESTORE_EVENT, strlen(KEY_RESTORE_EVENT))) { - // Restore PSK to DCT - LOG(INFO,"Restoring Public Server Key and Server Address to flash"); -#if HAL_PLATFORM_CLOUD_UDP - bool udp = HAL_Feature_Get(FEATURE_CLOUD_UDP); -#else - bool udp = false; -#endif - unsigned char psk_buf[EXTERNAL_FLASH_SERVER_PUBLIC_KEY_LENGTH]; // 320 (udp) vs 294 (tcp), allocate 320. - unsigned char server_addr_buf[EXTERNAL_FLASH_SERVER_ADDRESS_LENGTH]; - memset(&psk_buf, 0xff, sizeof(psk_buf)); - memset(&server_addr_buf, 0xff, sizeof(server_addr_buf)); - if (udp) { -#if HAL_PLATFORM_CLOUD_UDP - memcpy(&psk_buf, backup_udp_public_server_key, backup_udp_public_server_key_size); - memcpy(&server_addr_buf, backup_udp_public_server_address, backup_udp_public_server_address_size); -#endif // HAL_PLATFORM_CLOUD_UDP - } else { -#if HAL_PLATFORM_CLOUD_TCP - memcpy(&psk_buf, backup_tcp_public_server_key, sizeof(backup_tcp_public_server_key)); - memcpy(&server_addr_buf, backup_tcp_public_server_address, sizeof(backup_tcp_public_server_address)); -#endif // HAL_PLATFORM_CLOUD_TCP + LOG(WARN, "Received key restore event"); + int r = ServerConfig::instance()->restoreDefaultSettings(); + if (r < 0) { + LOG(ERROR, "Failed to restore default server settings: %d", r); + // Reset anyway } - HAL_FLASH_Write_ServerPublicKey(psk_buf, udp); - HAL_FLASH_Write_ServerAddress(server_addr_buf, udp); + system_pending_shutdown(RESET_REASON_CONFIG_UPDATE); } } @@ -259,7 +249,7 @@ extern uint8_t feature_cloud_udp; extern volatile bool cloud_socket_aborted; static volatile uint32_t lastCloudEvent = 0; -uint32_t particle_key_errors = NO_ERROR; +static uint32_t particle_key_errors = ParticleKeyErrorFlag::NO_ERROR; const int CLAIM_CODE_SIZE = 63; @@ -692,6 +682,69 @@ bool publishSafeModeEventIfNeeded() { return true; // ok } +void handleServerMovedRequest(const char* reqData, size_t reqSize, ServerMovedResponseCallback respCallback, void* ctx) { + clear_system_error_message(); + int result = SYSTEM_ERROR_UNKNOWN; + NAMED_SCOPE_GUARD(respGuard, { + respCallback(result, ctx); + }); + // Parse the request + // TODO: Add a helper function to initialize a buffered stream and decode Protobuf data in one call + auto stream = pb_istream_init(nullptr /* reserved */); + if (!stream) { + result = SYSTEM_ERROR_NO_MEMORY; + return; + } + NAMED_SCOPE_GUARD(streamGuard, { + pb_istream_free(stream, nullptr /* reserved */); + }); + bool ok = pb_istream_from_buffer_ex(stream, (const pb_byte_t*)reqData, reqSize, nullptr /* reserved */); + if (!ok) { + result = SYSTEM_ERROR_INTERNAL; + return; + } + particle_cloud_ServerMovedPermanentlyRequest pbReq = {}; + DecodedCString pbAddr(&pbReq.server_addr); // Decode to a null-terminated string + DecodedString pbPubKey(&pbReq.server_pub_key); + DecodedString pbSign(&pbReq.sign); + ok = pb_decode(stream, &particle_cloud_ServerMovedPermanentlyRequest_msg, &pbReq); + if (!ok) { + SYSTEM_ERROR_MESSAGE("Failed to parse ServerMoved request"); + result = SYSTEM_ERROR_BAD_DATA; + return; + } + pb_istream_free(stream, nullptr); + streamGuard.dismiss(); + // Validate the request + ServerConfig::ServerMovedRequest req; + req.address = pbAddr.data; + req.port = pbReq.server_port; + req.publicKey = (const uint8_t*)pbPubKey.data; + req.publicKeySize = pbPubKey.size; + req.signature = (const uint8_t*)pbSign.data; + req.signatureSize = pbSign.size; + int r = ServerConfig::instance()->validateServerMovedRequest(req); + if (r < 0) { + SYSTEM_ERROR_MESSAGE("Failed to validate ServerMoved request: %d", r); + result = r; + return; + } + // Reply to the server + respCallback(SYSTEM_ERROR_NONE, ctx); + respGuard.dismiss(); + // Gracefully disconnect from the cloud and clear the session data + CloudConnectionSettings::instance()->setPendingDisconnectOptions(CloudDisconnectOptions().graceful(true) + .clearSession(true)); + cloud_disconnect(CLOUD_DISCONNECT_GRACEFULLY, CLOUD_DISCONNECT_REASON_SERVER_MOVED); + // Apply the new server settings + r = ServerConfig::instance()->updateSettings(req); + if (r < 0) { + LOG(ERROR, "Failed to update server settings: %d", r); + // Reset anyway + } + system_pending_shutdown(RESET_REASON_CONFIG_UPDATE); +} + #if HAL_PLATFORM_COMPRESSED_OTA // Minimum bootloader version required to support compressed/combined OTA updates const uint16_t COMPRESSED_OTA_MIN_BOOTLOADER_VERSION = 1000; // 2.0.0 @@ -871,6 +924,8 @@ static const char* resetReasonString(System_Reset_Reason reason) return "panic"; case RESET_REASON_USER: return "user"; + case RESET_REASON_CONFIG_UPDATE: + return "config_update"; default: return nullptr; } @@ -957,6 +1012,18 @@ void Spark_Protocol_Init(void) if (!spark_protocol_is_initialized(sp)) { #if PLATFORM_ID != PLATFORM_GCC + // Validate the server key and address in the DCT and restore the factory defaults if needed + auto servConf = ServerConfig::instance(); + int r = servConf->validateSettings(); + if (r < 0) { + LOG(ERROR, "Validation of server settings failed: %d; restoring defaults", r); + particle_key_errors |= ParticleKeyErrorFlag::SERVER_SETTINGS_CORRUPTED; + r = servConf->restoreDefaultSettings(); + if (r < 0) { + LOG(ERROR, "Failed to restore default server settings: %d", r); + } + } + product_details_t info; info.size = sizeof(info); spark_protocol_get_product_details(sp, &info); @@ -1027,6 +1094,7 @@ void Spark_Protocol_Init(void) callbacks.millis = HAL_Timer_Get_Milli_Seconds; callbacks.set_time = system_set_time; callbacks.notify_client_messages_processed = clientMessagesProcessed; + callbacks.server_moved = handleServerMovedRequest; SparkDescriptor descriptor; memset(&descriptor, 0, sizeof(descriptor)); @@ -1045,8 +1113,8 @@ void Spark_Protocol_Init(void) // todo - this pushes a lot of data on the stack! refactor to remove heavy stack usage unsigned char pubkey[EXTERNAL_FLASH_SERVER_PUBLIC_KEY_LENGTH]; unsigned char private_key[EXTERNAL_FLASH_CORE_PRIVATE_KEY_LENGTH]; - memset(&pubkey, 0xff, sizeof(pubkey)); - memset(&private_key, 0xff, sizeof(private_key)); + memset(&pubkey, 0, sizeof(pubkey)); + memset(&private_key, 0, sizeof(private_key)); SparkKeys keys; keys.size = sizeof(keys); @@ -1060,21 +1128,6 @@ void Spark_Protocol_Init(void) HAL_FLASH_Read_CorePrivateKey(private_key, &genspec); HAL_FLASH_Read_ServerPublicKey(pubkey); - // if public server key is erased, restore with a backup from system firmware - if (pubkey[0] == 0xff) { - LOG(WARN, "Public Server Key was blank, restoring."); - if (udp) { -#if HAL_PLATFORM_CLOUD_UDP - memcpy(&pubkey, backup_udp_public_server_key, backup_udp_public_server_key_size); -#endif // HAL_PLATFORM_CLOUD_UDP - } else { -#if HAL_PLATFORM_CLOUD_TCP - memcpy(&pubkey, backup_tcp_public_server_key, sizeof(backup_tcp_public_server_key)); -#endif // HAL_PLATFORM_CLOUD_TCP - } - particle_key_errors |= PUBLIC_SERVER_KEY_BLANK; - } - uint8_t id_length = hal_get_device_id(NULL, 0); uint8_t id[id_length]; hal_get_device_id(id, id_length); @@ -1232,7 +1285,7 @@ int Spark_Handshake(bool presence_announce) return err; } } - if (particle_key_errors != NO_ERROR) { + if (particle_key_errors != ParticleKeyErrorFlag::NO_ERROR) { char buf[sizeof(unsigned long)*8+1]; ultoa((unsigned long)particle_key_errors, buf, 10); LOG(INFO,"Send event spark/device/key/error=%s", buf); diff --git a/system/src/system_cloud_internal_constants.c b/system/src/system_cloud_internal_constants.c deleted file mode 100644 index a757046a7d..0000000000 --- a/system/src/system_cloud_internal_constants.c +++ /dev/null @@ -1,90 +0,0 @@ -/** - Copyright (c) 2013-2015 Particle Industries, Inc. All rights reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation, either - version 3 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . - ****************************************************************************** - */ - -#include "static_assert.h" -#include "hal_platform.h" - -#include - -#if HAL_PLATFORM_CLOUD_UDP - -// minimal udp public server key -const unsigned char backup_udp_public_server_key[] = { - 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, - 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, - 0x42, 0x00, 0x04, 0x50, 0x9b, 0xfc, 0x18, 0x56, 0x48, 0xc3, 0x3f, 0x80, - 0x90, 0x7a, 0xe1, 0x32, 0x60, 0xdf, 0x33, 0x28, 0x21, 0x15, 0x20, 0x9e, - 0x54, 0xa2, 0x2f, 0x2b, 0x10, 0x59, 0x84, 0xa4, 0x63, 0x62, 0xc0, 0x7c, - 0x26, 0x79, 0xf6, 0xe4, 0xce, 0x76, 0xca, 0x00, 0x2d, 0x3d, 0xe4, 0xbf, - 0x2e, 0x9e, 0x3a, 0x62, 0x15, 0x1c, 0x48, 0x17, 0x9b, 0xd8, 0x09, 0xdd, - 0xce, 0x9c, 0x5d, 0xc3, 0x0f, 0x54, 0xb8 -}; - -STATIC_ASSERT(backup_udp_public_server_key_size, sizeof(backup_udp_public_server_key)==91); - -const size_t backup_udp_public_server_key_size = sizeof(backup_udp_public_server_key); - -// $id.udp.particle.io -const unsigned char backup_udp_public_server_address[] = { - 0x01, 0x13, 0x24, 0x69, 0x64, 0x2e, 0x75, 0x64, 0x70, 0x2e, 0x70, 0x61, - 0x72, 0x74, 0x69, 0x63, 0x6c, 0x65, 0x2e, 0x69, 0x6f, 0x00 -}; - -STATIC_ASSERT(backup_udp_public_server_address_size, sizeof(backup_udp_public_server_address)==22); - -const size_t backup_udp_public_server_address_size = sizeof(backup_udp_public_server_address); - -#endif // HAL_PLATFORM_CLOUD_UDP - -#if HAL_PLATFORM_CLOUD_TCP -// minimal tcp public server key -const unsigned char backup_tcp_public_server_key[] = { - 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, - 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, - 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xbe, 0xcc, 0xbe, - 0x43, 0xdb, 0x8e, 0xea, 0x15, 0x27, 0xa6, 0xbb, 0x52, 0x6d, 0xe1, 0x51, - 0x2b, 0xa0, 0xab, 0xcc, 0xa1, 0x64, 0x77, 0x48, 0xad, 0x7c, 0x66, 0xfc, - 0x80, 0x7f, 0xf6, 0x99, 0xa5, 0x25, 0xf2, 0xf2, 0xda, 0xe0, 0x43, 0xcf, - 0x3a, 0x26, 0xa4, 0x9b, 0xa1, 0x87, 0x03, 0x0e, 0x9a, 0x8d, 0x23, 0x9a, - 0xbc, 0xea, 0x99, 0xea, 0x68, 0xd3, 0x5a, 0x14, 0xb1, 0x26, 0x0f, 0xbd, - 0xaa, 0x6d, 0x6f, 0x0c, 0xac, 0xc4, 0x77, 0x2c, 0xd1, 0xc5, 0xc8, 0xb1, - 0xd1, 0x7b, 0x68, 0xe0, 0x25, 0x73, 0x7b, 0x52, 0x89, 0x68, 0x20, 0xbd, - 0x06, 0xc6, 0xf0, 0xe6, 0x00, 0x30, 0xc0, 0xe0, 0xcf, 0xf6, 0x1b, 0x3a, - 0x45, 0xe9, 0xc4, 0x5b, 0x55, 0x17, 0x06, 0xa3, 0xd3, 0x4a, 0xc6, 0xd5, - 0xb8, 0xd2, 0x17, 0x02, 0xb5, 0x27, 0x7d, 0x8d, 0xe4, 0xd4, 0x7d, 0xd3, - 0xed, 0xc0, 0x1d, 0x8a, 0x7c, 0x25, 0x1e, 0x21, 0x4a, 0x51, 0xae, 0x57, - 0x06, 0xdd, 0x60, 0xbc, 0xa1, 0x34, 0x90, 0xaa, 0xcc, 0x09, 0x9e, 0x3b, - 0x3a, 0x41, 0x4c, 0x3c, 0x9d, 0xf3, 0xfd, 0xfd, 0xb7, 0x27, 0xc1, 0x59, - 0x81, 0x98, 0x54, 0x60, 0x4a, 0x62, 0x7a, 0xa4, 0x9a, 0xbf, 0xdf, 0x92, - 0x1b, 0x3e, 0xfc, 0xa7, 0xe4, 0xa4, 0xb3, 0x3a, 0x9a, 0x5f, 0x57, 0x93, - 0x8e, 0xeb, 0x19, 0x64, 0x95, 0x22, 0x4a, 0x2c, 0xd5, 0x60, 0xf5, 0xf9, - 0xd0, 0x03, 0x50, 0x83, 0x69, 0xc0, 0x6b, 0x53, 0xf0, 0xf0, 0xda, 0xf8, - 0x13, 0x82, 0x1f, 0xcc, 0xbb, 0x5f, 0xe2, 0xc1, 0xdf, 0x3a, 0xe9, 0x7f, - 0x5d, 0xe2, 0x7d, 0xb9, 0x50, 0x80, 0x3c, 0x58, 0x33, 0xef, 0x8c, 0xf3, - 0x80, 0x3f, 0x11, 0x01, 0xd2, 0x68, 0x86, 0x5f, 0x3c, 0x5e, 0xe6, 0xc1, - 0x8e, 0x32, 0x2b, 0x28, 0xcb, 0xb5, 0xcc, 0x1b, 0xa8, 0x50, 0x5e, 0xa7, - 0x0d, 0x02, 0x03, 0x01, 0x00, 0x01 -}; -const unsigned char backup_tcp_public_server_address[] = { - 0x01, 0x0f, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x73, 0x70, 0x61, - 0x72, 0x6b, 0x2e, 0x69, 0x6f, 0x00 -}; -STATIC_ASSERT(backup_tcp_public_server_key_size, sizeof(backup_tcp_public_server_key)==294); -STATIC_ASSERT(backup_tcp_public_server_address_size, sizeof(backup_tcp_public_server_address)==18); - -#endif // HAL_PLATFORM_CLOUD_TCP From 7e770ad92939a195b63dceb31ebc5566d48348d4 Mon Sep 17 00:00:00 2001 From: Andrey Tolstoy Date: Sat, 12 Nov 2022 01:04:31 +0700 Subject: [PATCH 045/112] decouple proto def changes --- communication/inc/coap.h | 3 +- communication/inc/protocol.h | 10 - communication/inc/spark_protocol_functions.h | 13 +- communication/src/messages.cpp | 2 - communication/src/protocol.cpp | 98 ------- hal/inc/ota_flash_hal.h | 4 + hal/shared/parse_server_address.h | 130 ++++----- hal/src/gcc/ota_flash_hal.cpp | 19 ++ hal/src/nRF52840/ota_flash_hal.cpp | 25 +- hal/src/rtl872x/ota_flash_hal.cpp | 25 +- services/inc/system_defs.h | 6 +- system/inc/system_cloud.h | 38 +-- system/src/main.cpp | 4 +- system/src/server_config.cpp | 273 ------------------- system/src/server_config.h | 99 ------- system/src/system_cloud_connection.cpp | 17 ++ system/src/system_cloud_internal.cpp | 137 +++------- system/src/system_cloud_internal_constants.c | 90 ++++++ 18 files changed, 294 insertions(+), 699 deletions(-) delete mode 100644 system/src/server_config.cpp delete mode 100644 system/src/server_config.h create mode 100644 system/src/system_cloud_internal_constants.c diff --git a/communication/inc/coap.h b/communication/inc/coap.h index a08cdb1653..fd9164561f 100644 --- a/communication/inc/coap.h +++ b/communication/inc/coap.h @@ -56,8 +56,7 @@ namespace CoAPMessageType { NONE, UPDATE_START_V3, UPDATE_FINISH_V3, - UPDATE_CHUNK_V3, - SERVER_MOVED + UPDATE_CHUNK_V3 }; } diff --git a/communication/inc/protocol.h b/communication/inc/protocol.h index ced338aac3..93774be6c6 100644 --- a/communication/inc/protocol.h +++ b/communication/inc/protocol.h @@ -306,16 +306,6 @@ class Protocol */ void handle_time_response(uint32_t time); - /** - * Handle a ServerMoved request. - */ - ProtocolError handle_server_moved_request(Message& msg); - - /** - * Send a response for a ServerMoved request. - */ - static void send_server_moved_response(int error, void* ctx); - /** * Copy an initialize a block of memory from a source to a target, where the source may be smaller than the target. * This handles the case where the caller was compiled using a smaller version of the struct memory than what is the current. diff --git a/communication/inc/spark_protocol_functions.h b/communication/inc/spark_protocol_functions.h index a42cd26be7..18ebfe8fe9 100644 --- a/communication/inc/spark_protocol_functions.h +++ b/communication/inc/spark_protocol_functions.h @@ -57,8 +57,6 @@ enum ProtocolFactory PROTOCOL_DTLS, }; -typedef void (*ServerMovedResponseCallback)(int error, void* context); - struct SparkCallbacks { uint16_t size; @@ -134,18 +132,9 @@ struct SparkCallbacks void (*notify_client_messages_processed)(void* reserved); // size == 56 - - /** - * Notify the system that the server wants to permanently move the device to another server. - */ - // TODO: Parse the request in the communication library - void (*server_moved)(const char* request_data, size_t request_size, ServerMovedResponseCallback response_callback, - void* context); - - // size == 60 }; -PARTICLE_STATIC_ASSERT(SparkCallbacks_size, sizeof(SparkCallbacks)==(sizeof(void*)*15)); +PARTICLE_STATIC_ASSERT(SparkCallbacks_size, sizeof(SparkCallbacks)==(sizeof(void*)*14)); /** * Application-supplied callbacks. (Deliberately distinct from the system-supplied diff --git a/communication/src/messages.cpp b/communication/src/messages.cpp index 028d83bb6d..ea38bf0afb 100644 --- a/communication/src/messages.cpp +++ b/communication/src/messages.cpp @@ -82,8 +82,6 @@ CoAPMessageType::Enum Messages::decodeType(const uint8_t* buf, size_t length) return CoAPMessageType::UPDATE_FINISH_V3; case 'C': return CoAPMessageType::UPDATE_CHUNK_V3; - case 'M': - return CoAPMessageType::SERVER_MOVED; default: break; } diff --git a/communication/src/protocol.cpp b/communication/src/protocol.cpp index 3f41a4c84d..a570c4b7e6 100644 --- a/communication/src/protocol.cpp +++ b/communication/src/protocol.cpp @@ -26,13 +26,10 @@ LOG_SOURCE_CATEGORY("comm.protocol") #include "mbedtls_config.h" #include "protocol_defs.h" -#include "protocol_util.h" #include "protocol.h" #include "chunked_transfer.h" #include "subscriptions.h" #include "functions.h" -#include "coap_message_decoder.h" -#include "coap_message_encoder.h" namespace particle { namespace protocol { @@ -49,11 +46,6 @@ enum HelloFlag { HELLO_FLAG_OTA_PROTOCOL_V3 = 0x80 }; -struct ServerMovedContext { - Protocol* proto; - token_t token; -}; - } // namespace /** @@ -209,10 +201,6 @@ ProtocolError Protocol::handle_received_message(Message& message, error = channel.send(message); break; - case CoAPMessageType::SERVER_MOVED: - return handle_server_moved_request(message); - break; - case CoAPMessageType::ERROR: default: ; // drop it on the floor @@ -281,92 +269,6 @@ void Protocol::handle_time_response(uint32_t time) timesync_.handle_time_response(time, callbacks.millis(), callbacks.set_time); } -ProtocolError Protocol::handle_server_moved_request(Message& msg) -{ - // Parse the request - CoapMessageDecoder dec; - int r = dec.decode((const char*)msg.buf(), msg.length()); - if (r < 0 || dec.type() != CoapType::CON || !dec.hasToken()) { - LOG(ERROR, "Received a malformed ServerMoved request"); - return ProtocolError::NO_ERROR; // Ignore the request - } - LOG(WARN, "Received a ServerMoved request"); - // Acknowledge the request - Message ack; - r = channel.response(msg, ack, msg.capacity() - msg.length()); - if (r != ProtocolError::NO_ERROR) { - LOG(ERROR, "Failed to create message: %d", r); - return (ProtocolError)r; - } - CoapMessageEncoder enc((char*)ack.buf(), ack.capacity()); - enc.type(CoapType::ACK); - enc.code(CoapCode::EMPTY); - enc.id(0); // Encoded by the message channel - r = enc.encode(); - if (r < 0) { - LOG(ERROR, "Failed to encode message: %d", r); - return ProtocolError::INTERNAL; - } - if (r > (int)ack.capacity()) { - LOG(ERROR, "Message data is too long"); - return ProtocolError::INSUFFICIENT_STORAGE; - } - ack.set_length(r); - ack.set_id(dec.id()); - r = channel.send(ack); - if (r != ProtocolError::NO_ERROR) { - LOG(ERROR, "Failed to send message: %d", r); - return (ProtocolError)r; - } - // Process the request - std::unique_ptr ctx(new(std::nothrow) ServerMovedContext()); - if (!ctx) { - return ProtocolError::NO_MEMORY; - } - ctx->proto = this; - SPARK_ASSERT(dec.tokenSize() == sizeof(ctx->token)); // Verified in handle_received_message() - memcpy(&ctx->token, dec.token(), sizeof(ctx->token)); - SPARK_ASSERT(callbacks.server_moved); - callbacks.server_moved(dec.payload(), dec.payloadSize(), send_server_moved_response, ctx.release()); // Transfer ownership over the context - return ProtocolError::NO_ERROR; -} - -void Protocol::send_server_moved_response(int error, void* context) { - SPARK_ASSERT(context); - std::unique_ptr ctx(static_cast(context)); - Message msg; - int r = ctx->proto->channel.create(msg); - if (r != ProtocolError::NO_ERROR) { - LOG(ERROR, "Failed to create message: %d", r); - return; - } - CoapMessageEncoder enc((char*)msg.buf(), msg.capacity()); - enc.type(CoapType::CON); - enc.code(coapCodeForSystemError(error)); - enc.id(0); // Encoded by the message channel - enc.token((const char*)&ctx->token, sizeof(ctx->token)); - if (error < 0) { - r = formatDiagnosticPayload(enc.payloadData(), enc.maxPayloadSize(), error); - if (r > 0) { - enc.payloadSize(r); - } - } - r = enc.encode(); - if (r < 0) { - LOG(ERROR, "Failed to encode message: %d", r); - return; - } - if (r > (int)msg.capacity()) { - LOG(ERROR, "Message data is too long"); - return; - } - msg.set_length(r); - r = ctx->proto->channel.send(msg); - if (r != ProtocolError::NO_ERROR) { - LOG(ERROR, "Failed to send message: %d", (int)r); - } -} - /** * Copy an initialize a block of memory from a source to a target, where the source may be smaller than the target. * This handles the case where the caller was compiled using a smaller version of the struct memory than what is the current. diff --git a/hal/inc/ota_flash_hal.h b/hal/inc/ota_flash_hal.h index 2fbe7dff2d..5eb86d41ad 100644 --- a/hal/inc/ota_flash_hal.h +++ b/hal/inc/ota_flash_hal.h @@ -227,11 +227,15 @@ PARTICLE_STATIC_ASSERT(ServerAddress_size, sizeof(ServerAddress)==128); /* Length in bytes of DER-encoded 2048-bit RSA public key */ #define EXTERNAL_FLASH_SERVER_PUBLIC_KEY_LENGTH (294) +/* Length in bytes of server address */ +#define EXTERNAL_FLASH_SERVER_ADDRESS_LENGTH (128) /* Length in bytes of DER-encoded 1024-bit RSA private key */ #define EXTERNAL_FLASH_CORE_PRIVATE_KEY_LENGTH (612) void HAL_FLASH_Read_ServerAddress(ServerAddress *server_addr); +void HAL_FLASH_Write_ServerAddress(const uint8_t *buf, bool udp); void HAL_FLASH_Read_ServerPublicKey(uint8_t *keyBuffer); +void HAL_FLASH_Write_ServerPublicKey(const uint8_t *keyBuffer, bool udp); typedef enum { /** diff --git a/hal/shared/parse_server_address.h b/hal/shared/parse_server_address.h index 4beb6e2c1c..3d23db7dcc 100644 --- a/hal/shared/parse_server_address.h +++ b/hal/shared/parse_server_address.h @@ -19,70 +19,56 @@ #ifndef PARSE_SERVER_ADDRESS_H #define PARSE_SERVER_ADDRESS_H -#include "ota_flash_hal.h" // For ServerAddress +#include "ota_flash_hal.h" + #include "system_error.h" -#include -#include -#include -#include - -namespace particle { - -inline void parseServerAddressData(ServerAddress* addr, const uint8_t* buf, size_t size) { - // Internet address stored on external flash may be - // either a domain name or an IP address. - // It's stored in a type-length-value encoding. - // First byte is type, second byte is length, the rest is value. - if (size < 2) { - addr->addr_type = INVALID_INTERNET_ADDRESS; - return; - } - switch (buf[0]) { - case IP_ADDRESS: { - size_t addr_len = buf[1]; - if (addr_len != 4 || size < 6) { - addr->addr_type = INVALID_INTERNET_ADDRESS; - return; - } - auto ip = ((unsigned)buf[2] << 24) | ((unsigned)buf[3] << 16) | ((unsigned)buf[4] << 8) | (unsigned)buf[5]; - if (!ip || ip == 0xffffffffu) { // 0.0.0.0 or 255.255.255.255 - addr->addr_type = INVALID_INTERNET_ADDRESS; - return; - } - addr->addr_type = IP_ADDRESS; - addr->length = addr_len; - addr->ip = ip; - break; - } - case DOMAIN_NAME: { - size_t name_len = buf[1]; - if (name_len + 2 > size || name_len > sizeof(addr->domain) - 1) { // Reserve 1 byte for '\0' - addr->addr_type = INVALID_INTERNET_ADDRESS; - return; - } - auto name = buf + 2; - for (size_t i = 0; i < name_len; ++i) { - if (!isprint(name[i])) { - addr->addr_type = INVALID_INTERNET_ADDRESS; - return; - } - } - addr->addr_type = DOMAIN_NAME; - addr->length = name_len; - memcpy(addr->domain, name, name_len); - addr->domain[name_len] = '\0'; +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +inline void parseServerAddressData(ServerAddress* server_addr, const uint8_t* buf, int maxLength) +{ + // Internet address stored on external flash may be + // either a domain name or an IP address. + // It's stored in a type-length-value encoding. + // First byte is type, second byte is length, the rest is value. + + switch (buf[0]) + { + case IP_ADDRESS: + server_addr->addr_type = IP_ADDRESS; + server_addr->length = 4; + server_addr->ip = (buf[2] << 24) | (buf[3] << 16) | + (buf[4] << 8) | buf[5]; + break; + + case DOMAIN_NAME: + if (buf[1] <= maxLength - 2) + { + server_addr->addr_type = DOMAIN_NAME; + server_addr->length = buf[1]; + memcpy(server_addr->domain, buf + 2, buf[1]); + + // null terminate string + char *p = server_addr->domain + buf[1]; + *p = 0; break; - } + } + // else fall through to default + default: - addr->addr_type = INVALID_INTERNET_ADDRESS; - return; - } - if (size < 68) { - addr->addr_type = INVALID_INTERNET_ADDRESS; - return; - } - addr->port = (buf[66] << 8) | buf[67]; + server_addr->addr_type = INVALID_INTERNET_ADDRESS; + } + if (server_addr->addr_type!=INVALID_INTERNET_ADDRESS) + { + server_addr->port = buf[66]<<8 | buf[67]; + + } + } inline int encodeServerAddressData(const ServerAddress* addr, uint8_t* buf, size_t bufSize) { @@ -112,29 +98,9 @@ inline int encodeServerAddressData(const ServerAddress* addr, uint8_t* buf, size return 0; } -// Note: This function doesn't parse the port number -inline int parseServerAddressString(ServerAddress* addr, const char* str) { - unsigned n1 = 0, n2 = 0, n3 = 0, n4 = 0; - if (sscanf(str, "%u.%u.%u.%u", &n1, &n2, &n3, &n4) == 4) { - if (n1 > 255 || n2 > 255 || n3 > 255 || n4 > 255) { - return SYSTEM_ERROR_INVALID_ARGUMENT; - } - addr->addr_type = IP_ADDRESS; - addr->length = 4; - addr->ip = (n1 << 24) | (n2 << 16) | (n3 << 8) | n4; - } else { - size_t len = strlen(str); - if (len > sizeof(addr->domain) - 1) { // Reserve 1 byte for '\0' - return SYSTEM_ERROR_TOO_LARGE; - } - addr->addr_type = DOMAIN_NAME; - addr->length = len; - memcpy(addr->domain, str, len + 1); // Include '\0' - } - return 0; +#ifdef __cplusplus } - -} // namespace particle +#endif #endif /* PARSE_SERVER_ADDRESS_H */ diff --git a/hal/src/gcc/ota_flash_hal.cpp b/hal/src/gcc/ota_flash_hal.cpp index a0930b0f2c..7112b3039d 100644 --- a/hal/src/gcc/ota_flash_hal.cpp +++ b/hal/src/gcc/ota_flash_hal.cpp @@ -434,8 +434,12 @@ void parseServerAddressData(ServerAddress* server_addr, uint8_t* buf) } +#define MAXIMUM_CLOUD_KEY_LEN (512) #define SERVER_ADDRESS_OFFSET (384) #define SERVER_ADDRESS_OFFSET_EC (192) +#define SERVER_ADDRESS_SIZE (128) +#define SERVER_PUBLIC_KEY_SIZE (294) +#define SERVER_PUBLIC_KEY_EC_SIZE (320) void HAL_FLASH_Read_ServerAddress(ServerAddress* server_addr) @@ -445,6 +449,12 @@ void HAL_FLASH_Read_ServerAddress(ServerAddress* server_addr) parseServerAddressData(server_addr, deviceConfig.server_key+offset); } +void HAL_FLASH_Write_ServerAddress(const uint8_t *buf, bool udp) +{ + int offset = (udp) ? SERVER_ADDRESS_OFFSET_EC : SERVER_ADDRESS_OFFSET; + memcpy(deviceConfig.server_key+offset, buf, SERVER_ADDRESS_SIZE); +} + bool HAL_OTA_Flashed_GetStatus(void) { return false; @@ -465,6 +475,15 @@ void HAL_FLASH_Read_ServerPublicKey(uint8_t *keyBuffer) INFO("server key: %s", buf); } +void HAL_FLASH_Write_ServerPublicKey(const uint8_t *keyBuffer, bool udp) +{ + if (udp) { + memcpy(&deviceConfig.server_key, keyBuffer, SERVER_PUBLIC_KEY_EC_SIZE); + } else { + memcpy(&deviceConfig.server_key, keyBuffer, SERVER_PUBLIC_KEY_SIZE); + } +} + int HAL_FLASH_Read_CorePrivateKey(uint8_t *keyBuffer, private_key_generation_t* generation) { memcpy(keyBuffer, deviceConfig.device_key, PRIVATE_KEY_LEN); diff --git a/hal/src/nRF52840/ota_flash_hal.cpp b/hal/src/nRF52840/ota_flash_hal.cpp index adc69455d0..2a3e3d7dda 100644 --- a/hal/src/nRF52840/ota_flash_hal.cpp +++ b/hal/src/nRF52840/ota_flash_hal.cpp @@ -54,8 +54,6 @@ LOG_SOURCE_CATEGORY("hal.ota") #define BOOTLOADER_RANDOM_BACKOFF_MIN (200) #define BOOTLOADER_RANDOM_BACKOFF_MAX (1000) -using namespace particle; - namespace { const uint16_t BOOTLOADER_MBR_UPDATE_MIN_VERSION = 1001; // 2.0.0-rc.1 @@ -775,6 +773,29 @@ bool HAL_IsDeviceClaimed(void* reserved) return (claimed)=='1'; } +void HAL_FLASH_Write_ServerPublicKey(const uint8_t *keyBuffer, bool udp) +{ + if (udp) + { + dct_write_app_data(keyBuffer, DCT_ALT_SERVER_PUBLIC_KEY_OFFSET, DCT_ALT_SERVER_PUBLIC_KEY_SIZE); + } else + { + dct_write_app_data(keyBuffer, DCT_SERVER_PUBLIC_KEY_OFFSET, EXTERNAL_FLASH_SERVER_PUBLIC_KEY_LENGTH); + } +} + +void HAL_FLASH_Write_ServerAddress(const uint8_t *buf, bool udp) +{ + if (udp) + { + dct_write_app_data(buf, DCT_ALT_SERVER_ADDRESS_OFFSET, DCT_ALT_SERVER_ADDRESS_SIZE); + } + else + { + dct_write_app_data(buf, DCT_SERVER_ADDRESS_OFFSET, DCT_SERVER_ADDRESS_SIZE); + } +} + int HAL_Set_System_Config(hal_system_config_t config_item, const void* data, unsigned data_length) { unsigned offset = 0; diff --git a/hal/src/rtl872x/ota_flash_hal.cpp b/hal/src/rtl872x/ota_flash_hal.cpp index 56de98f3bc..a797f1c13c 100644 --- a/hal/src/rtl872x/ota_flash_hal.cpp +++ b/hal/src/rtl872x/ota_flash_hal.cpp @@ -54,8 +54,6 @@ LOG_SOURCE_CATEGORY("hal.ota") #define BOOTLOADER_RANDOM_BACKOFF_MIN (200) #define BOOTLOADER_RANDOM_BACKOFF_MAX (1000) -using namespace particle; - namespace { const uint16_t BOOTLOADER_MBR_UPDATE_MIN_VERSION = 1001; // 2.0.0-rc.1 @@ -693,6 +691,29 @@ bool HAL_IsDeviceClaimed(void* reserved) return (claimed)=='1'; } +void HAL_FLASH_Write_ServerPublicKey(const uint8_t *keyBuffer, bool udp) +{ + if (udp) + { + dct_write_app_data(keyBuffer, DCT_ALT_SERVER_PUBLIC_KEY_OFFSET, DCT_ALT_SERVER_PUBLIC_KEY_SIZE); + } else + { + dct_write_app_data(keyBuffer, DCT_SERVER_PUBLIC_KEY_OFFSET, EXTERNAL_FLASH_SERVER_PUBLIC_KEY_LENGTH); + } +} + +void HAL_FLASH_Write_ServerAddress(const uint8_t *buf, bool udp) +{ + if (udp) + { + dct_write_app_data(buf, DCT_ALT_SERVER_ADDRESS_OFFSET, DCT_ALT_SERVER_ADDRESS_SIZE); + } + else + { + dct_write_app_data(buf, DCT_SERVER_ADDRESS_OFFSET, DCT_SERVER_ADDRESS_SIZE); + } +} + int HAL_Set_System_Config(hal_system_config_t config_item, const void* data, unsigned data_length) { unsigned offset = 0; diff --git a/services/inc/system_defs.h b/services/inc/system_defs.h index 4edcbd8cea..776f373e08 100644 --- a/services/inc/system_defs.h +++ b/services/inc/system_defs.h @@ -63,8 +63,7 @@ typedef enum System_Reset_Reason { RESET_REASON_SAFE_MODE = 110, ///< Safe mode requested. RESET_REASON_DFU_MODE = 120, ///< DFU mode requested. RESET_REASON_PANIC = 130, ///< System panic. - RESET_REASON_USER = 140, ///< User-requested reset. - RESET_REASON_CONFIG_UPDATE = 150 ///< Reset to apply configuration changes. + RESET_REASON_USER = 140 ///< User-requested reset. } System_Reset_Reason; /** @@ -78,8 +77,7 @@ typedef enum cloud_disconnect_reason { CLOUD_DISCONNECT_REASON_LISTENING = 4, ///< Disconnected to enter the listening mode. CLOUD_DISCONNECT_REASON_SYSTEM_RESET = 5, ///< Disconnected due to a system reset. CLOUD_DISCONNECT_REASON_SLEEP = 6, ///< Disconnected to enter a sleep mode. - CLOUD_DISCONNECT_REASON_UNKNOWN = 7, ///< Unspecified disconnection reason. - CLOUD_DISCONNECT_REASON_SERVER_MOVED = 8 ///< Server address/key changed. + CLOUD_DISCONNECT_REASON_UNKNOWN = 7 ///< Unspecified disconnection reason. } cloud_disconnect_reason; /** diff --git a/system/inc/system_cloud.h b/system/inc/system_cloud.h index 01feb07bb8..457b37d332 100644 --- a/system/inc/system_cloud.h +++ b/system/inc/system_cloud.h @@ -34,31 +34,28 @@ #define DEFAULT_CLOUD_EVENT_TTL 60 -namespace particle { - enum ParticleKeyErrorFlag: uint32_t { - NO_ERROR = 0, - // PUBLIC_SERVER_KEY_BLANK = 1, - PUBLIC_SERVER_KEY_CORRUPTED = 2, - // SERVER_ADDRESS_BLANK = 4, - SERVER_ADDRESS_CORRUPTED = 8, - // PUBLIC_DEVICE_KEY_BLANK = 16, - // PUBLIC_DEVICE_KEY_CORRUPTED = 32, - // PRIVATE_DEVICE_KEY_BLANK = 64, - // PRIVATE_DEVICE_KEY_CORRUPTED = 128 - SERVER_SETTINGS_CORRUPTED = PUBLIC_SERVER_KEY_CORRUPTED | SERVER_ADDRESS_CORRUPTED + NO_ERROR = 0, + PUBLIC_SERVER_KEY_BLANK = 1, + PUBLIC_SERVER_KEY_CORRUPTED = 2, + SERVER_ADDRESS_BLANK = 4, + SERVER_ADDRESS_CORRUPTED = 8, + PUBLIC_DEVICE_KEY_BLANK = 16, + PUBLIC_DEVICE_KEY_CORRUPTED = 32, + PRIVATE_DEVICE_KEY_BLANK = 64, + PRIVATE_DEVICE_KEY_CORRUPTED = 128 }; -const system_tick_t NOW = static_cast(-1); - -} // namespace particle - typedef enum { CLOUD_VAR_BOOLEAN = 1, CLOUD_VAR_INT = 2, CLOUD_VAR_STRING = 4, CLOUD_VAR_DOUBLE = 9 } Spark_Data_TypeDef; +namespace particle { + static const system_tick_t NOW = static_cast(-1); +} + template struct CloudVariableType { }; @@ -358,6 +355,15 @@ int spark_get_connection_property(unsigned property, void* data, size_t* size, v int spark_set_random_seed_from_cloud_handler(void (*handler)(unsigned int), void* reserved); +extern const unsigned char backup_udp_public_server_key[]; +extern const size_t backup_udp_public_server_key_size; + +extern const unsigned char backup_udp_public_server_address[]; +extern const size_t backup_udp_public_server_address_size; + +extern const unsigned char backup_tcp_public_server_key[294]; +extern const unsigned char backup_tcp_public_server_address[18]; + #define SPARK_BUF_LEN 600 //#define SPARK_SERVER_IP "54.235.79.249" diff --git a/system/src/main.cpp b/system/src/main.cpp index cdd77e0e98..cd7804577d 100644 --- a/system/src/main.cpp +++ b/system/src/main.cpp @@ -61,7 +61,6 @@ #include "spark_wiring_system.h" #include "system_power.h" #include "spark_wiring_wifi.h" -#include "server_config.h" // FIXME #include "system_control_internal.h" @@ -669,7 +668,8 @@ int resetSettingsToFactoryDefaultsIfNeeded() { CHECK(dct_write_app_data(devPrivKey.get(), DCT_ALT_DEVICE_PRIVATE_KEY_OFFSET, DCT_ALT_DEVICE_PRIVATE_KEY_SIZE)); CHECK(dct_write_app_data(devPubKey.get(), DCT_ALT_DEVICE_PUBLIC_KEY_OFFSET, DCT_ALT_DEVICE_PUBLIC_KEY_SIZE)); // Restore default server key and address - ServerConfig::instance()->restoreDefaultSettings(); + CHECK(dct_write_app_data(backup_udp_public_server_key, DCT_ALT_SERVER_PUBLIC_KEY_OFFSET, backup_udp_public_server_key_size)); + CHECK(dct_write_app_data(backup_udp_public_server_address, DCT_ALT_SERVER_ADDRESS_OFFSET, backup_udp_public_server_address_size)); #endif // HAL_PLATFORM_NRF52840 #endif // !defined(SPARK_NO_PLATFORM) && HAL_PLATFORM_DCT return 0; diff --git a/system/src/server_config.cpp b/system/src/server_config.cpp deleted file mode 100644 index 987ecd5784..0000000000 --- a/system/src/server_config.cpp +++ /dev/null @@ -1,273 +0,0 @@ -/* - * Copyright (c) 2022 Particle Industries, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -#undef LOG_COMPILE_TIME_LEVEL - -#include -#include - -#include -#include - -#include "server_config.h" -#include "ota_flash_hal.h" // For ServerAddress -#include "dct_hal.h" -#include "core_hal.h" -#include "parse_server_address.h" -#include "mbedtls_util.h" -#include "sha256.h" -#include "system_error.h" -#include "endian_util.h" -#include "logging.h" -#include "scope_guard.h" -#include "check.h" - -namespace particle { - -namespace { - -// EC public key in DER format -const uint8_t DEFAULT_UDP_SERVER_PUBLIC_KEY[] = { - 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, - 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, - 0x42, 0x00, 0x04, 0x50, 0x9b, 0xfc, 0x18, 0x56, 0x48, 0xc3, 0x3f, 0x80, - 0x90, 0x7a, 0xe1, 0x32, 0x60, 0xdf, 0x33, 0x28, 0x21, 0x15, 0x20, 0x9e, - 0x54, 0xa2, 0x2f, 0x2b, 0x10, 0x59, 0x84, 0xa4, 0x63, 0x62, 0xc0, 0x7c, - 0x26, 0x79, 0xf6, 0xe4, 0xce, 0x76, 0xca, 0x00, 0x2d, 0x3d, 0xe4, 0xbf, - 0x2e, 0x9e, 0x3a, 0x62, 0x15, 0x1c, 0x48, 0x17, 0x9b, 0xd8, 0x09, 0xdd, - 0xce, 0x9c, 0x5d, 0xc3, 0x0f, 0x54, 0xb8 -}; - -// RSA public key in DER format -const uint8_t DEFAULT_TCP_SERVER_PUBLIC_KEY[] = { - 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, - 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, - 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xbe, 0xcc, 0xbe, - 0x43, 0xdb, 0x8e, 0xea, 0x15, 0x27, 0xa6, 0xbb, 0x52, 0x6d, 0xe1, 0x51, - 0x2b, 0xa0, 0xab, 0xcc, 0xa1, 0x64, 0x77, 0x48, 0xad, 0x7c, 0x66, 0xfc, - 0x80, 0x7f, 0xf6, 0x99, 0xa5, 0x25, 0xf2, 0xf2, 0xda, 0xe0, 0x43, 0xcf, - 0x3a, 0x26, 0xa4, 0x9b, 0xa1, 0x87, 0x03, 0x0e, 0x9a, 0x8d, 0x23, 0x9a, - 0xbc, 0xea, 0x99, 0xea, 0x68, 0xd3, 0x5a, 0x14, 0xb1, 0x26, 0x0f, 0xbd, - 0xaa, 0x6d, 0x6f, 0x0c, 0xac, 0xc4, 0x77, 0x2c, 0xd1, 0xc5, 0xc8, 0xb1, - 0xd1, 0x7b, 0x68, 0xe0, 0x25, 0x73, 0x7b, 0x52, 0x89, 0x68, 0x20, 0xbd, - 0x06, 0xc6, 0xf0, 0xe6, 0x00, 0x30, 0xc0, 0xe0, 0xcf, 0xf6, 0x1b, 0x3a, - 0x45, 0xe9, 0xc4, 0x5b, 0x55, 0x17, 0x06, 0xa3, 0xd3, 0x4a, 0xc6, 0xd5, - 0xb8, 0xd2, 0x17, 0x02, 0xb5, 0x27, 0x7d, 0x8d, 0xe4, 0xd4, 0x7d, 0xd3, - 0xed, 0xc0, 0x1d, 0x8a, 0x7c, 0x25, 0x1e, 0x21, 0x4a, 0x51, 0xae, 0x57, - 0x06, 0xdd, 0x60, 0xbc, 0xa1, 0x34, 0x90, 0xaa, 0xcc, 0x09, 0x9e, 0x3b, - 0x3a, 0x41, 0x4c, 0x3c, 0x9d, 0xf3, 0xfd, 0xfd, 0xb7, 0x27, 0xc1, 0x59, - 0x81, 0x98, 0x54, 0x60, 0x4a, 0x62, 0x7a, 0xa4, 0x9a, 0xbf, 0xdf, 0x92, - 0x1b, 0x3e, 0xfc, 0xa7, 0xe4, 0xa4, 0xb3, 0x3a, 0x9a, 0x5f, 0x57, 0x93, - 0x8e, 0xeb, 0x19, 0x64, 0x95, 0x22, 0x4a, 0x2c, 0xd5, 0x60, 0xf5, 0xf9, - 0xd0, 0x03, 0x50, 0x83, 0x69, 0xc0, 0x6b, 0x53, 0xf0, 0xf0, 0xda, 0xf8, - 0x13, 0x82, 0x1f, 0xcc, 0xbb, 0x5f, 0xe2, 0xc1, 0xdf, 0x3a, 0xe9, 0x7f, - 0x5d, 0xe2, 0x7d, 0xb9, 0x50, 0x80, 0x3c, 0x58, 0x33, 0xef, 0x8c, 0xf3, - 0x80, 0x3f, 0x11, 0x01, 0xd2, 0x68, 0x86, 0x5f, 0x3c, 0x5e, 0xe6, 0xc1, - 0x8e, 0x32, 0x2b, 0x28, 0xcb, 0xb5, 0xcc, 0x1b, 0xa8, 0x50, 0x5e, 0xa7, - 0x0d, 0x02, 0x03, 0x01, 0x00, 0x01 -}; - -// EC public key in DER format -const uint8_t SERVER_MOVED_SIGNATURE_PUBLIC_KEY[] = { - 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, - 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, - 0x42, 0x00, 0x04, 0xf9, 0xd2, 0x85, 0xc4, 0xfa, 0xb7, 0x0f, 0x0d, 0x04, - 0xa8, 0x5a, 0xd4, 0x34, 0xae, 0x1c, 0x90, 0xe4, 0x8a, 0x4a, 0xa5, 0x6c, - 0x4d, 0xa9, 0xf0, 0xe5, 0xdb, 0x68, 0xde, 0xf6, 0xf2, 0x20, 0x2e, 0x59, - 0xfc, 0x51, 0x75, 0xc7, 0x56, 0x78, 0xea, 0xe7, 0xf1, 0x27, 0x2d, 0x35, - 0x2c, 0x10, 0xae, 0x85, 0x6f, 0x7e, 0x4b, 0x9d, 0xee, 0x51, 0xa5, 0xc2, - 0x28, 0x7a, 0x92, 0xc7, 0xd4, 0x7c, 0x71 -}; - -const auto DEFAULT_UDP_SERVER_ADDRESS = "$id.udp.particle.io"; -const auto DEFAULT_TCP_SERVER_ADDRESS = "device.tcp.particle.io"; - -const uint16_t DEFAULT_UDP_SERVER_PORT = 5684; -const uint16_t DEFAULT_TCP_SERVER_PORT = 5683; - -int updateServerSettings(const char* addr, uint16_t port, const uint8_t* pubKey, size_t pubKeySize, bool udp) { - LOG(INFO, "Updating %s server settings", udp ? "UDP" : "TCP"); - LOG(INFO, "Address: \"%s\"; port: %u", addr, (unsigned)port); - LOG(TRACE, "Public key (%u bytes):", (unsigned)pubKeySize); - LOG_DUMP(TRACE, pubKey, pubKeySize); - LOG_PRINT(TRACE, "\r\n"); - // Parse and validate the new server address - ServerAddress saddr = {}; - CHECK(parseServerAddressString(&saddr, addr)); - saddr.port = port; - // Erase both the current server key and address so that we don't potentially end up with a - // key and address from different servers in the DCT - size_t maxPubKeySize = udp ? DCT_ALT_SERVER_PUBLIC_KEY_SIZE : DCT_SERVER_PUBLIC_KEY_SIZE; - if (pubKeySize > maxPubKeySize) { - return SYSTEM_ERROR_TOO_LARGE; - } - size_t maxAddrSize = udp ? DCT_ALT_SERVER_ADDRESS_SIZE : DCT_SERVER_ADDRESS_SIZE; - size_t bufSize = std::max(maxPubKeySize, maxAddrSize); - std::unique_ptr buf(new(std::nothrow) uint8_t[bufSize]); - if (!buf) { - return SYSTEM_ERROR_NO_MEMORY; - } - memset(buf.get(), 0xff, bufSize); - size_t addrOffs = udp ? DCT_ALT_SERVER_ADDRESS_OFFSET : DCT_SERVER_ADDRESS_OFFSET; - int r = dct_write_app_data(buf.get(), addrOffs, maxAddrSize); - if (r != 0) { - return SYSTEM_ERROR_IO; - } - size_t pubKeyOffs = udp ? DCT_ALT_SERVER_PUBLIC_KEY_OFFSET : DCT_SERVER_PUBLIC_KEY_OFFSET; - r = dct_write_app_data(buf.get(), pubKeyOffs, maxPubKeySize); - if (r != 0) { - return SYSTEM_ERROR_IO; - } - // Write the server key - r = dct_write_app_data(pubKey, pubKeyOffs, pubKeySize); - if (r != 0) { - return SYSTEM_ERROR_IO; - } - // Serialize and write the server address - CHECK(encodeServerAddressData(&saddr, buf.get(), maxAddrSize)); - r = dct_write_app_data(buf.get(), addrOffs, maxAddrSize); - if (r != 0) { - return SYSTEM_ERROR_IO; - } - return 0; -} - -int validateServerSettings(bool udp) { - size_t maxPubKeySize = udp ? DCT_ALT_SERVER_PUBLIC_KEY_SIZE : DCT_SERVER_PUBLIC_KEY_SIZE; - size_t maxAddrSize = udp ? DCT_ALT_SERVER_ADDRESS_SIZE : DCT_SERVER_ADDRESS_SIZE; - size_t bufSize = std::max(maxPubKeySize, maxAddrSize); - std::unique_ptr buf(new(std::nothrow) uint8_t[bufSize]); - if (!buf) { - return SYSTEM_ERROR_NO_MEMORY; - } - // Load and validate the server address - size_t addrOffs = udp ? DCT_ALT_SERVER_ADDRESS_OFFSET : DCT_SERVER_ADDRESS_OFFSET; - int r = dct_read_app_data_copy(addrOffs, buf.get(), maxAddrSize); - if (r != 0) { - return SYSTEM_ERROR_IO; - } - ServerAddress addr = {}; - parseServerAddressData(&addr, buf.get(), maxAddrSize); - if (addr.addr_type == INVALID_INTERNET_ADDRESS) { - return SYSTEM_ERROR_BAD_DATA; - } - // Load the server key - size_t pubKeyOffs = udp ? DCT_ALT_SERVER_PUBLIC_KEY_OFFSET : DCT_SERVER_PUBLIC_KEY_OFFSET; - r = dct_read_app_data_copy(pubKeyOffs, buf.get(), maxPubKeySize); - if (r != 0) { - return SYSTEM_ERROR_IO; - } - // Determine the actual size of the key - uint8_t* p = buf.get(); - size_t pubKeySize = 0; - r = mbedtls_asn1_get_tag(&p, buf.get() + maxPubKeySize, &pubKeySize, MBEDTLS_ASN1_CONSTRUCTED | - MBEDTLS_ASN1_SEQUENCE); - if (r != 0) { - return SYSTEM_ERROR_BAD_DATA; - } - pubKeySize += p - buf.get(); // Include size of the tag and length fields - // Parse the key - mbedtls_pk_context pk = {}; - mbedtls_pk_init(&pk); - SCOPE_GUARD({ - mbedtls_pk_free(&pk); - }); - r = mbedtls_pk_parse_public_key(&pk, buf.get(), pubKeySize); - if (r != 0) { - return SYSTEM_ERROR_BAD_DATA; - } - return 0; -} - -inline bool udpEnabled() { - // XXX: The current gen platforms don't really allow changing the cloud transport protocol, - // but let's keep this check in place until the support for TCP is removed from the codebase - return HAL_Feature_Get(FEATURE_CLOUD_UDP); -} - -} // namespace - -int ServerConfig::updateSettings(const ServerSettings& conf) { - bool udp = udpEnabled(); - auto port = conf.port; - if (!port) { - port = udp ? DEFAULT_UDP_SERVER_PORT : DEFAULT_TCP_SERVER_PORT; - } - CHECK(updateServerSettings(conf.address, port, conf.publicKey, conf.publicKeySize, udp)); - return 0; -} - -int ServerConfig::validateSettings() const { - CHECK(validateServerSettings(udpEnabled())); - return 0; -} - -int ServerConfig::validateServerMovedRequest(const ServerMovedRequest& req) const { - if (!udpEnabled()) { - return SYSTEM_ERROR_NOT_SUPPORTED; - } - // Load the signature key - mbedtls_pk_context pk = {}; - mbedtls_pk_init(&pk); - SCOPE_GUARD({ - mbedtls_pk_free(&pk); - }); - CHECK_MBEDTLS(mbedtls_pk_parse_public_key(&pk, SERVER_MOVED_SIGNATURE_PUBLIC_KEY, sizeof(SERVER_MOVED_SIGNATURE_PUBLIC_KEY))); - // Hash the server settings - Sha256 sha; - CHECK(sha.init()); - CHECK(sha.start()); - uint32_t u32 = nativeToLittleEndian(req.publicKeySize); - CHECK(sha.update((const char*)&u32, sizeof(u32))); - CHECK(sha.update((const char*)req.publicKey, req.publicKeySize)); - size_t addrLen = strlen(req.address); - u32 = nativeToLittleEndian(addrLen); - CHECK(sha.update((const char*)&u32, sizeof(u32))); - CHECK(sha.update(req.address, addrLen)); - auto port = req.port; - if (!port) { - port = DEFAULT_UDP_SERVER_PORT; - } - uint16_t u16 = nativeToLittleEndian(port); - CHECK(sha.update((const char*)&u16, sizeof(u16))); - char hash[Sha256::HASH_SIZE] = {}; - CHECK(sha.finish(hash)); - // Verify the signature - int r = mbedtls_pk_verify(&pk, MBEDTLS_MD_SHA256, (const uint8_t*)hash, sizeof(hash), req.signature, req.signatureSize); - if (r != 0) { - return SYSTEM_ERROR_BAD_DATA; - } - return 0; -} - -int ServerConfig::restoreDefaultSettings() { - if (udpEnabled()) { - CHECK(updateServerSettings(DEFAULT_UDP_SERVER_ADDRESS, DEFAULT_UDP_SERVER_PORT, DEFAULT_UDP_SERVER_PUBLIC_KEY, - sizeof(DEFAULT_UDP_SERVER_PUBLIC_KEY), true /* udp */)); - } else { - CHECK(updateServerSettings(DEFAULT_TCP_SERVER_ADDRESS, DEFAULT_TCP_SERVER_PORT, DEFAULT_TCP_SERVER_PUBLIC_KEY, - sizeof(DEFAULT_TCP_SERVER_PUBLIC_KEY), false)); - } - return 0; -} - -ServerConfig* ServerConfig::instance() { - static ServerConfig conf; - return &conf; -} - -} // namespace particle diff --git a/system/src/server_config.h b/system/src/server_config.h deleted file mode 100644 index 90bd2921f3..0000000000 --- a/system/src/server_config.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2022 Particle Industries, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -#pragma once - -#include - -namespace particle { - -/** - * Server configuration manager. - */ -class ServerConfig { -public: - /** - * Server settings. - */ - struct ServerSettings { - const char* address; ///< Server address (an IP address or domain name). - const uint8_t* publicKey; ///< Server public key in DER format. - size_t publicKeySize; ///< Size of the server public key. - uint16_t port; ///< Server port. If 0, the default port will be used. - - ServerSettings() : - address(""), - publicKey(nullptr), - publicKeySize(0), - port(0) { - } - }; - - /** - * A request to change the server settings. - */ - struct ServerMovedRequest: ServerSettings { - const uint8_t* signature; ///< Request signature. - size_t signatureSize; ///< Size of the request signature. - - ServerMovedRequest() : - signature(nullptr), - signatureSize(0) { - } - }; - - /** - * Update the current server settings. - * - * @param conf Server settings. - * @return 0 if the settings were updated successfully, otherwise an error code defined by - * `system_error_t`. - */ - int updateSettings(const ServerSettings& conf); - - /** - * Validate the current server settings. - * - * @return 0 if the settings are valid, otherwise an error code defined by `system_error_t`. - */ - int validateSettings() const; - - /** - * Validate the signature of a ServerMoved request. - * - * @param req Request data. - * @return 0 if the signature is valid, otherwise an error code defined by `system_error_t`. - */ - int validateServerMovedRequest(const ServerMovedRequest& req) const; - - /** - * Restore the default server settings. - * - * @return 0 if the settings were restored successfully, otherwise an error code defined by - * `system_error_t`. - */ - int restoreDefaultSettings(); - - /** - * Get the global instance of this class. - * - * @return Instance. - */ - static ServerConfig* instance(); -}; - -} // namespace particle diff --git a/system/src/system_cloud_connection.cpp b/system/src/system_cloud_connection.cpp index 22f858dc22..7435c228ac 100644 --- a/system/src/system_cloud_connection.cpp +++ b/system/src/system_cloud_connection.cpp @@ -41,6 +41,7 @@ uint16_t cloud_udp_port = PORT_COAPS; // default Particle Cloud UDP port /* FIXME: */ extern uint8_t feature_cloud_udp; +extern uint32_t particle_key_errors; volatile bool cloud_socket_aborted = false; #if HAL_PLATFORM_CELLULAR @@ -139,6 +140,22 @@ int spark_cloud_socket_connect() ServerAddress server_addr = {}; HAL_FLASH_Read_ServerAddress(&server_addr); + + // if server address is erased, restore with a backup from system firmware + if (server_addr.addr_type != IP_ADDRESS && server_addr.addr_type != DOMAIN_NAME) { + LOG(WARN, "Public Server Address was blank, restoring."); + if (udp) { +#if HAL_PLATFORM_CLOUD_UDP + memcpy(&server_addr, backup_udp_public_server_address, backup_udp_public_server_address_size); +#endif // HAL_PLATFORM_CLOUD_UDP + } + else { +#if HAL_PLATFORM_CLOUD_TCP + memcpy(&server_addr, backup_tcp_public_server_address, sizeof(backup_tcp_public_server_address)); +#endif // HAL_PLATFORM_CLOUD_TCP + } + particle_key_errors |= SERVER_ADDRESS_BLANK; + } switch (server_addr.addr_type) { case IP_ADDRESS: diff --git a/system/src/system_cloud_internal.cpp b/system/src/system_cloud_internal.cpp index 1073e96430..7cc5948e6b 100644 --- a/system/src/system_cloud_internal.cpp +++ b/system/src/system_cloud_internal.cpp @@ -59,16 +59,11 @@ #endif // HAL_PLATFORM_MUXER_MAY_NEED_DELAY_IN_TX #include "system_version.h" #include "firmware_update.h" -#include "server_config.h" #if PLATFORM_ID == PLATFORM_GCC #include "device_config.h" #endif -#include "control/common.h" // FIXME: Move to another directory -#include "cloud/cloud.pb.h" -#include "nanopb_misc.h" - #include #include #include @@ -76,8 +71,6 @@ using namespace particle; using namespace particle::system; using particle::protocol::ProtocolError; -using particle::control::common::DecodedString; -using particle::control::common::DecodedCString; extern volatile uint8_t SPARK_UPDATE_PENDING_EVENT_RECEIVED; @@ -151,13 +144,30 @@ void systemEventHandler(const char* name, const char* data) } } else if (!strncmp(name, KEY_RESTORE_EVENT, strlen(KEY_RESTORE_EVENT))) { - LOG(WARN, "Received key restore event"); - int r = ServerConfig::instance()->restoreDefaultSettings(); - if (r < 0) { - LOG(ERROR, "Failed to restore default server settings: %d", r); - // Reset anyway + // Restore PSK to DCT + LOG(INFO,"Restoring Public Server Key and Server Address to flash"); +#if HAL_PLATFORM_CLOUD_UDP + bool udp = HAL_Feature_Get(FEATURE_CLOUD_UDP); +#else + bool udp = false; +#endif + unsigned char psk_buf[EXTERNAL_FLASH_SERVER_PUBLIC_KEY_LENGTH]; // 320 (udp) vs 294 (tcp), allocate 320. + unsigned char server_addr_buf[EXTERNAL_FLASH_SERVER_ADDRESS_LENGTH]; + memset(&psk_buf, 0xff, sizeof(psk_buf)); + memset(&server_addr_buf, 0xff, sizeof(server_addr_buf)); + if (udp) { +#if HAL_PLATFORM_CLOUD_UDP + memcpy(&psk_buf, backup_udp_public_server_key, backup_udp_public_server_key_size); + memcpy(&server_addr_buf, backup_udp_public_server_address, backup_udp_public_server_address_size); +#endif // HAL_PLATFORM_CLOUD_UDP + } else { +#if HAL_PLATFORM_CLOUD_TCP + memcpy(&psk_buf, backup_tcp_public_server_key, sizeof(backup_tcp_public_server_key)); + memcpy(&server_addr_buf, backup_tcp_public_server_address, sizeof(backup_tcp_public_server_address)); +#endif // HAL_PLATFORM_CLOUD_TCP } - system_pending_shutdown(RESET_REASON_CONFIG_UPDATE); + HAL_FLASH_Write_ServerPublicKey(psk_buf, udp); + HAL_FLASH_Write_ServerAddress(server_addr_buf, udp); } } @@ -249,7 +259,7 @@ extern uint8_t feature_cloud_udp; extern volatile bool cloud_socket_aborted; static volatile uint32_t lastCloudEvent = 0; -static uint32_t particle_key_errors = ParticleKeyErrorFlag::NO_ERROR; +uint32_t particle_key_errors = NO_ERROR; const int CLAIM_CODE_SIZE = 63; @@ -682,69 +692,6 @@ bool publishSafeModeEventIfNeeded() { return true; // ok } -void handleServerMovedRequest(const char* reqData, size_t reqSize, ServerMovedResponseCallback respCallback, void* ctx) { - clear_system_error_message(); - int result = SYSTEM_ERROR_UNKNOWN; - NAMED_SCOPE_GUARD(respGuard, { - respCallback(result, ctx); - }); - // Parse the request - // TODO: Add a helper function to initialize a buffered stream and decode Protobuf data in one call - auto stream = pb_istream_init(nullptr /* reserved */); - if (!stream) { - result = SYSTEM_ERROR_NO_MEMORY; - return; - } - NAMED_SCOPE_GUARD(streamGuard, { - pb_istream_free(stream, nullptr /* reserved */); - }); - bool ok = pb_istream_from_buffer_ex(stream, (const pb_byte_t*)reqData, reqSize, nullptr /* reserved */); - if (!ok) { - result = SYSTEM_ERROR_INTERNAL; - return; - } - particle_cloud_ServerMovedPermanentlyRequest pbReq = {}; - DecodedCString pbAddr(&pbReq.server_addr); // Decode to a null-terminated string - DecodedString pbPubKey(&pbReq.server_pub_key); - DecodedString pbSign(&pbReq.sign); - ok = pb_decode(stream, &particle_cloud_ServerMovedPermanentlyRequest_msg, &pbReq); - if (!ok) { - SYSTEM_ERROR_MESSAGE("Failed to parse ServerMoved request"); - result = SYSTEM_ERROR_BAD_DATA; - return; - } - pb_istream_free(stream, nullptr); - streamGuard.dismiss(); - // Validate the request - ServerConfig::ServerMovedRequest req; - req.address = pbAddr.data; - req.port = pbReq.server_port; - req.publicKey = (const uint8_t*)pbPubKey.data; - req.publicKeySize = pbPubKey.size; - req.signature = (const uint8_t*)pbSign.data; - req.signatureSize = pbSign.size; - int r = ServerConfig::instance()->validateServerMovedRequest(req); - if (r < 0) { - SYSTEM_ERROR_MESSAGE("Failed to validate ServerMoved request: %d", r); - result = r; - return; - } - // Reply to the server - respCallback(SYSTEM_ERROR_NONE, ctx); - respGuard.dismiss(); - // Gracefully disconnect from the cloud and clear the session data - CloudConnectionSettings::instance()->setPendingDisconnectOptions(CloudDisconnectOptions().graceful(true) - .clearSession(true)); - cloud_disconnect(CLOUD_DISCONNECT_GRACEFULLY, CLOUD_DISCONNECT_REASON_SERVER_MOVED); - // Apply the new server settings - r = ServerConfig::instance()->updateSettings(req); - if (r < 0) { - LOG(ERROR, "Failed to update server settings: %d", r); - // Reset anyway - } - system_pending_shutdown(RESET_REASON_CONFIG_UPDATE); -} - #if HAL_PLATFORM_COMPRESSED_OTA // Minimum bootloader version required to support compressed/combined OTA updates const uint16_t COMPRESSED_OTA_MIN_BOOTLOADER_VERSION = 1000; // 2.0.0 @@ -924,8 +871,6 @@ static const char* resetReasonString(System_Reset_Reason reason) return "panic"; case RESET_REASON_USER: return "user"; - case RESET_REASON_CONFIG_UPDATE: - return "config_update"; default: return nullptr; } @@ -1012,18 +957,6 @@ void Spark_Protocol_Init(void) if (!spark_protocol_is_initialized(sp)) { #if PLATFORM_ID != PLATFORM_GCC - // Validate the server key and address in the DCT and restore the factory defaults if needed - auto servConf = ServerConfig::instance(); - int r = servConf->validateSettings(); - if (r < 0) { - LOG(ERROR, "Validation of server settings failed: %d; restoring defaults", r); - particle_key_errors |= ParticleKeyErrorFlag::SERVER_SETTINGS_CORRUPTED; - r = servConf->restoreDefaultSettings(); - if (r < 0) { - LOG(ERROR, "Failed to restore default server settings: %d", r); - } - } - product_details_t info; info.size = sizeof(info); spark_protocol_get_product_details(sp, &info); @@ -1094,7 +1027,6 @@ void Spark_Protocol_Init(void) callbacks.millis = HAL_Timer_Get_Milli_Seconds; callbacks.set_time = system_set_time; callbacks.notify_client_messages_processed = clientMessagesProcessed; - callbacks.server_moved = handleServerMovedRequest; SparkDescriptor descriptor; memset(&descriptor, 0, sizeof(descriptor)); @@ -1113,8 +1045,8 @@ void Spark_Protocol_Init(void) // todo - this pushes a lot of data on the stack! refactor to remove heavy stack usage unsigned char pubkey[EXTERNAL_FLASH_SERVER_PUBLIC_KEY_LENGTH]; unsigned char private_key[EXTERNAL_FLASH_CORE_PRIVATE_KEY_LENGTH]; - memset(&pubkey, 0, sizeof(pubkey)); - memset(&private_key, 0, sizeof(private_key)); + memset(&pubkey, 0xff, sizeof(pubkey)); + memset(&private_key, 0xff, sizeof(private_key)); SparkKeys keys; keys.size = sizeof(keys); @@ -1128,6 +1060,21 @@ void Spark_Protocol_Init(void) HAL_FLASH_Read_CorePrivateKey(private_key, &genspec); HAL_FLASH_Read_ServerPublicKey(pubkey); + // if public server key is erased, restore with a backup from system firmware + if (pubkey[0] == 0xff) { + LOG(WARN, "Public Server Key was blank, restoring."); + if (udp) { +#if HAL_PLATFORM_CLOUD_UDP + memcpy(&pubkey, backup_udp_public_server_key, backup_udp_public_server_key_size); +#endif // HAL_PLATFORM_CLOUD_UDP + } else { +#if HAL_PLATFORM_CLOUD_TCP + memcpy(&pubkey, backup_tcp_public_server_key, sizeof(backup_tcp_public_server_key)); +#endif // HAL_PLATFORM_CLOUD_TCP + } + particle_key_errors |= PUBLIC_SERVER_KEY_BLANK; + } + uint8_t id_length = hal_get_device_id(NULL, 0); uint8_t id[id_length]; hal_get_device_id(id, id_length); @@ -1285,7 +1232,7 @@ int Spark_Handshake(bool presence_announce) return err; } } - if (particle_key_errors != ParticleKeyErrorFlag::NO_ERROR) { + if (particle_key_errors != NO_ERROR) { char buf[sizeof(unsigned long)*8+1]; ultoa((unsigned long)particle_key_errors, buf, 10); LOG(INFO,"Send event spark/device/key/error=%s", buf); diff --git a/system/src/system_cloud_internal_constants.c b/system/src/system_cloud_internal_constants.c new file mode 100644 index 0000000000..a757046a7d --- /dev/null +++ b/system/src/system_cloud_internal_constants.c @@ -0,0 +1,90 @@ +/** + Copyright (c) 2013-2015 Particle Industries, Inc. All rights reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation, either + version 3 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, see . + ****************************************************************************** + */ + +#include "static_assert.h" +#include "hal_platform.h" + +#include + +#if HAL_PLATFORM_CLOUD_UDP + +// minimal udp public server key +const unsigned char backup_udp_public_server_key[] = { + 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, + 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, + 0x42, 0x00, 0x04, 0x50, 0x9b, 0xfc, 0x18, 0x56, 0x48, 0xc3, 0x3f, 0x80, + 0x90, 0x7a, 0xe1, 0x32, 0x60, 0xdf, 0x33, 0x28, 0x21, 0x15, 0x20, 0x9e, + 0x54, 0xa2, 0x2f, 0x2b, 0x10, 0x59, 0x84, 0xa4, 0x63, 0x62, 0xc0, 0x7c, + 0x26, 0x79, 0xf6, 0xe4, 0xce, 0x76, 0xca, 0x00, 0x2d, 0x3d, 0xe4, 0xbf, + 0x2e, 0x9e, 0x3a, 0x62, 0x15, 0x1c, 0x48, 0x17, 0x9b, 0xd8, 0x09, 0xdd, + 0xce, 0x9c, 0x5d, 0xc3, 0x0f, 0x54, 0xb8 +}; + +STATIC_ASSERT(backup_udp_public_server_key_size, sizeof(backup_udp_public_server_key)==91); + +const size_t backup_udp_public_server_key_size = sizeof(backup_udp_public_server_key); + +// $id.udp.particle.io +const unsigned char backup_udp_public_server_address[] = { + 0x01, 0x13, 0x24, 0x69, 0x64, 0x2e, 0x75, 0x64, 0x70, 0x2e, 0x70, 0x61, + 0x72, 0x74, 0x69, 0x63, 0x6c, 0x65, 0x2e, 0x69, 0x6f, 0x00 +}; + +STATIC_ASSERT(backup_udp_public_server_address_size, sizeof(backup_udp_public_server_address)==22); + +const size_t backup_udp_public_server_address_size = sizeof(backup_udp_public_server_address); + +#endif // HAL_PLATFORM_CLOUD_UDP + +#if HAL_PLATFORM_CLOUD_TCP +// minimal tcp public server key +const unsigned char backup_tcp_public_server_key[] = { + 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, + 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, + 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xbe, 0xcc, 0xbe, + 0x43, 0xdb, 0x8e, 0xea, 0x15, 0x27, 0xa6, 0xbb, 0x52, 0x6d, 0xe1, 0x51, + 0x2b, 0xa0, 0xab, 0xcc, 0xa1, 0x64, 0x77, 0x48, 0xad, 0x7c, 0x66, 0xfc, + 0x80, 0x7f, 0xf6, 0x99, 0xa5, 0x25, 0xf2, 0xf2, 0xda, 0xe0, 0x43, 0xcf, + 0x3a, 0x26, 0xa4, 0x9b, 0xa1, 0x87, 0x03, 0x0e, 0x9a, 0x8d, 0x23, 0x9a, + 0xbc, 0xea, 0x99, 0xea, 0x68, 0xd3, 0x5a, 0x14, 0xb1, 0x26, 0x0f, 0xbd, + 0xaa, 0x6d, 0x6f, 0x0c, 0xac, 0xc4, 0x77, 0x2c, 0xd1, 0xc5, 0xc8, 0xb1, + 0xd1, 0x7b, 0x68, 0xe0, 0x25, 0x73, 0x7b, 0x52, 0x89, 0x68, 0x20, 0xbd, + 0x06, 0xc6, 0xf0, 0xe6, 0x00, 0x30, 0xc0, 0xe0, 0xcf, 0xf6, 0x1b, 0x3a, + 0x45, 0xe9, 0xc4, 0x5b, 0x55, 0x17, 0x06, 0xa3, 0xd3, 0x4a, 0xc6, 0xd5, + 0xb8, 0xd2, 0x17, 0x02, 0xb5, 0x27, 0x7d, 0x8d, 0xe4, 0xd4, 0x7d, 0xd3, + 0xed, 0xc0, 0x1d, 0x8a, 0x7c, 0x25, 0x1e, 0x21, 0x4a, 0x51, 0xae, 0x57, + 0x06, 0xdd, 0x60, 0xbc, 0xa1, 0x34, 0x90, 0xaa, 0xcc, 0x09, 0x9e, 0x3b, + 0x3a, 0x41, 0x4c, 0x3c, 0x9d, 0xf3, 0xfd, 0xfd, 0xb7, 0x27, 0xc1, 0x59, + 0x81, 0x98, 0x54, 0x60, 0x4a, 0x62, 0x7a, 0xa4, 0x9a, 0xbf, 0xdf, 0x92, + 0x1b, 0x3e, 0xfc, 0xa7, 0xe4, 0xa4, 0xb3, 0x3a, 0x9a, 0x5f, 0x57, 0x93, + 0x8e, 0xeb, 0x19, 0x64, 0x95, 0x22, 0x4a, 0x2c, 0xd5, 0x60, 0xf5, 0xf9, + 0xd0, 0x03, 0x50, 0x83, 0x69, 0xc0, 0x6b, 0x53, 0xf0, 0xf0, 0xda, 0xf8, + 0x13, 0x82, 0x1f, 0xcc, 0xbb, 0x5f, 0xe2, 0xc1, 0xdf, 0x3a, 0xe9, 0x7f, + 0x5d, 0xe2, 0x7d, 0xb9, 0x50, 0x80, 0x3c, 0x58, 0x33, 0xef, 0x8c, 0xf3, + 0x80, 0x3f, 0x11, 0x01, 0xd2, 0x68, 0x86, 0x5f, 0x3c, 0x5e, 0xe6, 0xc1, + 0x8e, 0x32, 0x2b, 0x28, 0xcb, 0xb5, 0xcc, 0x1b, 0xa8, 0x50, 0x5e, 0xa7, + 0x0d, 0x02, 0x03, 0x01, 0x00, 0x01 +}; +const unsigned char backup_tcp_public_server_address[] = { + 0x01, 0x0f, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x73, 0x70, 0x61, + 0x72, 0x6b, 0x2e, 0x69, 0x6f, 0x00 +}; +STATIC_ASSERT(backup_tcp_public_server_key_size, sizeof(backup_tcp_public_server_key)==294); +STATIC_ASSERT(backup_tcp_public_server_address_size, sizeof(backup_tcp_public_server_address)==18); + +#endif // HAL_PLATFORM_CLOUD_TCP From 2fef1d6ba2ae8a41cd9621e5c71a56038c811c82 Mon Sep 17 00:00:00 2001 From: Andrey Tolstoy Date: Sat, 12 Nov 2022 01:29:13 +0700 Subject: [PATCH 046/112] [proto] git -> https --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index ad07765838..dd6d7996a6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -52,4 +52,4 @@ url = https://github.com/particle-iot/coremark [submodule "proto_defs/shared"] path = proto_defs/shared - url = git@github.com:particle-iot/device-os-protobuf.git + url = https://github.com/particle-iot/device-os-protobuf.git From 0c976b0c15aba5fd0f38b5ad88495df9c145a739 Mon Sep 17 00:00:00 2001 From: Andrey Tolstoy Date: Sat, 12 Nov 2022 01:29:52 +0700 Subject: [PATCH 047/112] update submodule references for nanopb/proto_defs --- proto_defs/shared | 2 +- third_party/nanopb/nanopb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/proto_defs/shared b/proto_defs/shared index 9050062b73..fdae2412cb 160000 --- a/proto_defs/shared +++ b/proto_defs/shared @@ -1 +1 @@ -Subproject commit 9050062b733b8bf6f5335a1441b170d2392b7d36 +Subproject commit fdae2412cbee069b74f3407edff42533ad56913b diff --git a/third_party/nanopb/nanopb b/third_party/nanopb/nanopb index 4a4f79940f..1b205c8910 160000 --- a/third_party/nanopb/nanopb +++ b/third_party/nanopb/nanopb @@ -1 +1 @@ -Subproject commit 4a4f79940fa00aa0a1483a5ba3f5669c9087122e +Subproject commit 1b205c89105342b1aec08d3c1a8a648a7644f366 From 20b1d8ce61e3f27f0f94f0ce6b8fffcd40e536bc Mon Sep 17 00:00:00 2001 From: Andrey Tolstoy Date: Sat, 12 Nov 2022 01:30:47 +0700 Subject: [PATCH 048/112] regenerate nanopb headers/sources --- proto_defs/src/control/cellular.pb.h | 14 +++-- proto_defs/src/control/network.pb.h | 81 ++++++++++++---------------- proto_defs/src/control/storage.pb.h | 7 ++- proto_defs/src/control/wifi.pb.h | 21 ++++---- proto_defs/src/control/wifi_new.pb.h | 7 ++- proto_defs/src/network_config.pb.h | 17 +++--- 6 files changed, 61 insertions(+), 86 deletions(-) diff --git a/proto_defs/src/control/cellular.pb.h b/proto_defs/src/control/cellular.pb.h index 1051abc85f..b50c234ff3 100644 --- a/proto_defs/src/control/cellular.pb.h +++ b/proto_defs/src/control/cellular.pb.h @@ -76,7 +76,6 @@ typedef struct _particle_ctrl_cellular_SetActiveSimRequest { } particle_ctrl_cellular_SetActiveSimRequest; typedef struct _particle_ctrl_cellular_GetAccessPointReply { - bool has_access_point; particle_ctrl_cellular_AccessPoint access_point; } particle_ctrl_cellular_GetAccessPointReply; @@ -84,7 +83,6 @@ typedef struct _particle_ctrl_cellular_GetAccessPointReply { Set access point settings. */ typedef struct _particle_ctrl_cellular_SetAccessPointRequest { particle_ctrl_cellular_SimType sim_type; - bool has_access_point; particle_ctrl_cellular_AccessPoint access_point; } particle_ctrl_cellular_SetAccessPointRequest; @@ -101,10 +99,10 @@ extern "C" { /* Initializer values for message structs */ #define particle_ctrl_cellular_AccessPoint_init_default {{{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, 0} -#define particle_ctrl_cellular_SetAccessPointRequest_init_default {_particle_ctrl_cellular_SimType_MIN, false, particle_ctrl_cellular_AccessPoint_init_default} +#define particle_ctrl_cellular_SetAccessPointRequest_init_default {_particle_ctrl_cellular_SimType_MIN, particle_ctrl_cellular_AccessPoint_init_default} #define particle_ctrl_cellular_SetAccessPointReply_init_default {0} #define particle_ctrl_cellular_GetAccessPointRequest_init_default {_particle_ctrl_cellular_SimType_MIN} -#define particle_ctrl_cellular_GetAccessPointReply_init_default {false, particle_ctrl_cellular_AccessPoint_init_default} +#define particle_ctrl_cellular_GetAccessPointReply_init_default {particle_ctrl_cellular_AccessPoint_init_default} #define particle_ctrl_cellular_SetActiveSimRequest_init_default {_particle_ctrl_cellular_SimType_MIN} #define particle_ctrl_cellular_SetActiveSimReply_init_default {0} #define particle_ctrl_cellular_GetActiveSimRequest_init_default {0} @@ -112,10 +110,10 @@ extern "C" { #define particle_ctrl_cellular_GetIccidRequest_init_default {0} #define particle_ctrl_cellular_GetIccidReply_init_default {{{NULL}, NULL}} #define particle_ctrl_cellular_AccessPoint_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, 0} -#define particle_ctrl_cellular_SetAccessPointRequest_init_zero {_particle_ctrl_cellular_SimType_MIN, false, particle_ctrl_cellular_AccessPoint_init_zero} +#define particle_ctrl_cellular_SetAccessPointRequest_init_zero {_particle_ctrl_cellular_SimType_MIN, particle_ctrl_cellular_AccessPoint_init_zero} #define particle_ctrl_cellular_SetAccessPointReply_init_zero {0} #define particle_ctrl_cellular_GetAccessPointRequest_init_zero {_particle_ctrl_cellular_SimType_MIN} -#define particle_ctrl_cellular_GetAccessPointReply_init_zero {false, particle_ctrl_cellular_AccessPoint_init_zero} +#define particle_ctrl_cellular_GetAccessPointReply_init_zero {particle_ctrl_cellular_AccessPoint_init_zero} #define particle_ctrl_cellular_SetActiveSimRequest_init_zero {_particle_ctrl_cellular_SimType_MIN} #define particle_ctrl_cellular_SetActiveSimReply_init_zero {0} #define particle_ctrl_cellular_GetActiveSimRequest_init_zero {0} @@ -147,7 +145,7 @@ X(a, STATIC, SINGULAR, BOOL, use_defaults, 4) #define particle_ctrl_cellular_SetAccessPointRequest_FIELDLIST(X, a) \ X(a, STATIC, SINGULAR, UENUM, sim_type, 1) \ -X(a, STATIC, OPTIONAL, MESSAGE, access_point, 2) +X(a, STATIC, SINGULAR, MESSAGE, access_point, 2) #define particle_ctrl_cellular_SetAccessPointRequest_CALLBACK NULL #define particle_ctrl_cellular_SetAccessPointRequest_DEFAULT NULL #define particle_ctrl_cellular_SetAccessPointRequest_access_point_MSGTYPE particle_ctrl_cellular_AccessPoint @@ -163,7 +161,7 @@ X(a, STATIC, SINGULAR, UENUM, sim_type, 1) #define particle_ctrl_cellular_GetAccessPointRequest_DEFAULT NULL #define particle_ctrl_cellular_GetAccessPointReply_FIELDLIST(X, a) \ -X(a, STATIC, OPTIONAL, MESSAGE, access_point, 1) +X(a, STATIC, SINGULAR, MESSAGE, access_point, 1) #define particle_ctrl_cellular_GetAccessPointReply_CALLBACK NULL #define particle_ctrl_cellular_GetAccessPointReply_DEFAULT NULL #define particle_ctrl_cellular_GetAccessPointReply_access_point_MSGTYPE particle_ctrl_cellular_AccessPoint diff --git a/proto_defs/src/control/network.pb.h b/proto_defs/src/control/network.pb.h index 6bde073c7f..dbd6b6e1b8 100644 --- a/proto_defs/src/control/network.pb.h +++ b/proto_defs/src/control/network.pb.h @@ -87,19 +87,14 @@ typedef struct _particle_ctrl_GetInterfaceRequest { typedef struct _particle_ctrl_IPConfiguration { particle_ctrl_IPConfiguration_Type type; - bool has_address; particle_ctrl_IPAddress address; - bool has_netmask; particle_ctrl_IPAddress netmask; - bool has_gateway; particle_ctrl_IPAddress gateway; - bool has_dhcp_server; particle_ctrl_IPAddress dhcp_server; pb_callback_t hostname; } particle_ctrl_IPConfiguration; typedef struct _particle_ctrl_InterfaceAddress { - bool has_address; particle_ctrl_IpAddress address; uint32_t prefix_length; /* TODO: state, scope, lifetimes, etc. */ } particle_ctrl_InterfaceAddress; @@ -113,10 +108,8 @@ typedef struct _particle_ctrl_InterfaceEntry { typedef struct _particle_ctrl_Ipv4Config { pb_callback_t addresses; /* On P2P links */ - bool has_peer; particle_ctrl_Ipv4Address peer; /* Temporary, will be moved to routing table */ - bool has_gateway; particle_ctrl_Ipv4Address gateway; } particle_ctrl_Ipv4Config; @@ -136,9 +129,7 @@ typedef struct _particle_ctrl_Interface { particle_ctrl_InterfaceType type; uint32_t flags; /* InterfaceFlag */ uint32_t ext_flags; /* InterfaceExtFlag */ - bool has_ipv4_config; particle_ctrl_Ipv4Config ipv4_config; - bool has_ipv6_config; particle_ctrl_Ipv6Config ipv6_config; particle_ctrl_Interface_hw_address_t hw_address; uint32_t mtu; @@ -151,29 +142,23 @@ typedef struct _particle_ctrl_NetworkConfiguration { particle_ctrl_NetworkState state; pb_callback_t name; particle_ctrl_NetworkConfiguration_mac_t mac; - bool has_ipconfig; particle_ctrl_IPConfiguration ipconfig; - bool has_dnsconfig; particle_ctrl_DNSConfiguration dnsconfig; } particle_ctrl_NetworkConfiguration; typedef struct _particle_ctrl_GetInterfaceReply { - bool has_interface; particle_ctrl_Interface interface; } particle_ctrl_GetInterfaceReply; typedef struct _particle_ctrl_NetworkGetConfigurationReply { - bool has_config; particle_ctrl_NetworkConfiguration config; } particle_ctrl_NetworkGetConfigurationReply; typedef struct _particle_ctrl_NetworkGetStatusReply { - bool has_config; particle_ctrl_NetworkConfiguration config; } particle_ctrl_NetworkGetStatusReply; typedef struct _particle_ctrl_NetworkSetConfigurationRequest { - bool has_config; particle_ctrl_NetworkConfiguration config; } particle_ctrl_NetworkSetConfigurationRequest; @@ -206,41 +191,41 @@ extern "C" { /* Initializer values for message structs */ #define particle_ctrl_NetworkGetStatusRequest_init_default {0} -#define particle_ctrl_NetworkGetStatusReply_init_default {false, particle_ctrl_NetworkConfiguration_init_default} +#define particle_ctrl_NetworkGetStatusReply_init_default {particle_ctrl_NetworkConfiguration_init_default} #define particle_ctrl_NetworkGetConfigurationRequest_init_default {0} -#define particle_ctrl_NetworkGetConfigurationReply_init_default {false, particle_ctrl_NetworkConfiguration_init_default} -#define particle_ctrl_NetworkSetConfigurationRequest_init_default {false, particle_ctrl_NetworkConfiguration_init_default} +#define particle_ctrl_NetworkGetConfigurationReply_init_default {particle_ctrl_NetworkConfiguration_init_default} +#define particle_ctrl_NetworkSetConfigurationRequest_init_default {particle_ctrl_NetworkConfiguration_init_default} #define particle_ctrl_NetworkSetConfigurationReply_init_default {0} -#define particle_ctrl_IPConfiguration_init_default {_particle_ctrl_IPConfiguration_Type_MIN, false, particle_ctrl_IPAddress_init_default, false, particle_ctrl_IPAddress_init_default, false, particle_ctrl_IPAddress_init_default, false, particle_ctrl_IPAddress_init_default, {{NULL}, NULL}} +#define particle_ctrl_IPConfiguration_init_default {_particle_ctrl_IPConfiguration_Type_MIN, particle_ctrl_IPAddress_init_default, particle_ctrl_IPAddress_init_default, particle_ctrl_IPAddress_init_default, particle_ctrl_IPAddress_init_default, {{NULL}, NULL}} #define particle_ctrl_DNSConfiguration_init_default {{{NULL}, NULL}} -#define particle_ctrl_NetworkConfiguration_init_default {0, _particle_ctrl_NetworkState_MIN, {{NULL}, NULL}, {0, {0}}, false, particle_ctrl_IPConfiguration_init_default, false, particle_ctrl_DNSConfiguration_init_default} -#define particle_ctrl_InterfaceAddress_init_default {false, particle_ctrl_IpAddress_init_default, 0} -#define particle_ctrl_Ipv4Config_init_default {{{NULL}, NULL}, false, particle_ctrl_Ipv4Address_init_default, false, particle_ctrl_Ipv4Address_init_default} +#define particle_ctrl_NetworkConfiguration_init_default {0, _particle_ctrl_NetworkState_MIN, {{NULL}, NULL}, {0, {0}}, particle_ctrl_IPConfiguration_init_default, particle_ctrl_DNSConfiguration_init_default} +#define particle_ctrl_InterfaceAddress_init_default {particle_ctrl_IpAddress_init_default, 0} +#define particle_ctrl_Ipv4Config_init_default {{{NULL}, NULL}, particle_ctrl_Ipv4Address_init_default, particle_ctrl_Ipv4Address_init_default} #define particle_ctrl_Ipv6Config_init_default {{{NULL}, NULL}} -#define particle_ctrl_Interface_init_default {0, {{NULL}, NULL}, _particle_ctrl_InterfaceType_MIN, 0, 0, false, particle_ctrl_Ipv4Config_init_default, false, particle_ctrl_Ipv6Config_init_default, {0, {0}}, 0, 0} +#define particle_ctrl_Interface_init_default {0, {{NULL}, NULL}, _particle_ctrl_InterfaceType_MIN, 0, 0, particle_ctrl_Ipv4Config_init_default, particle_ctrl_Ipv6Config_init_default, {0, {0}}, 0, 0} #define particle_ctrl_InterfaceEntry_init_default {0, {{NULL}, NULL}, _particle_ctrl_InterfaceType_MIN} #define particle_ctrl_GetInterfaceListRequest_init_default {0} #define particle_ctrl_GetInterfaceListReply_init_default {{{NULL}, NULL}} #define particle_ctrl_GetInterfaceRequest_init_default {0} -#define particle_ctrl_GetInterfaceReply_init_default {false, particle_ctrl_Interface_init_default} +#define particle_ctrl_GetInterfaceReply_init_default {particle_ctrl_Interface_init_default} #define particle_ctrl_NetworkGetStatusRequest_init_zero {0} -#define particle_ctrl_NetworkGetStatusReply_init_zero {false, particle_ctrl_NetworkConfiguration_init_zero} +#define particle_ctrl_NetworkGetStatusReply_init_zero {particle_ctrl_NetworkConfiguration_init_zero} #define particle_ctrl_NetworkGetConfigurationRequest_init_zero {0} -#define particle_ctrl_NetworkGetConfigurationReply_init_zero {false, particle_ctrl_NetworkConfiguration_init_zero} -#define particle_ctrl_NetworkSetConfigurationRequest_init_zero {false, particle_ctrl_NetworkConfiguration_init_zero} +#define particle_ctrl_NetworkGetConfigurationReply_init_zero {particle_ctrl_NetworkConfiguration_init_zero} +#define particle_ctrl_NetworkSetConfigurationRequest_init_zero {particle_ctrl_NetworkConfiguration_init_zero} #define particle_ctrl_NetworkSetConfigurationReply_init_zero {0} -#define particle_ctrl_IPConfiguration_init_zero {_particle_ctrl_IPConfiguration_Type_MIN, false, particle_ctrl_IPAddress_init_zero, false, particle_ctrl_IPAddress_init_zero, false, particle_ctrl_IPAddress_init_zero, false, particle_ctrl_IPAddress_init_zero, {{NULL}, NULL}} +#define particle_ctrl_IPConfiguration_init_zero {_particle_ctrl_IPConfiguration_Type_MIN, particle_ctrl_IPAddress_init_zero, particle_ctrl_IPAddress_init_zero, particle_ctrl_IPAddress_init_zero, particle_ctrl_IPAddress_init_zero, {{NULL}, NULL}} #define particle_ctrl_DNSConfiguration_init_zero {{{NULL}, NULL}} -#define particle_ctrl_NetworkConfiguration_init_zero {0, _particle_ctrl_NetworkState_MIN, {{NULL}, NULL}, {0, {0}}, false, particle_ctrl_IPConfiguration_init_zero, false, particle_ctrl_DNSConfiguration_init_zero} -#define particle_ctrl_InterfaceAddress_init_zero {false, particle_ctrl_IpAddress_init_zero, 0} -#define particle_ctrl_Ipv4Config_init_zero {{{NULL}, NULL}, false, particle_ctrl_Ipv4Address_init_zero, false, particle_ctrl_Ipv4Address_init_zero} +#define particle_ctrl_NetworkConfiguration_init_zero {0, _particle_ctrl_NetworkState_MIN, {{NULL}, NULL}, {0, {0}}, particle_ctrl_IPConfiguration_init_zero, particle_ctrl_DNSConfiguration_init_zero} +#define particle_ctrl_InterfaceAddress_init_zero {particle_ctrl_IpAddress_init_zero, 0} +#define particle_ctrl_Ipv4Config_init_zero {{{NULL}, NULL}, particle_ctrl_Ipv4Address_init_zero, particle_ctrl_Ipv4Address_init_zero} #define particle_ctrl_Ipv6Config_init_zero {{{NULL}, NULL}} -#define particle_ctrl_Interface_init_zero {0, {{NULL}, NULL}, _particle_ctrl_InterfaceType_MIN, 0, 0, false, particle_ctrl_Ipv4Config_init_zero, false, particle_ctrl_Ipv6Config_init_zero, {0, {0}}, 0, 0} +#define particle_ctrl_Interface_init_zero {0, {{NULL}, NULL}, _particle_ctrl_InterfaceType_MIN, 0, 0, particle_ctrl_Ipv4Config_init_zero, particle_ctrl_Ipv6Config_init_zero, {0, {0}}, 0, 0} #define particle_ctrl_InterfaceEntry_init_zero {0, {{NULL}, NULL}, _particle_ctrl_InterfaceType_MIN} #define particle_ctrl_GetInterfaceListRequest_init_zero {0} #define particle_ctrl_GetInterfaceListReply_init_zero {{{NULL}, NULL}} #define particle_ctrl_GetInterfaceRequest_init_zero {0} -#define particle_ctrl_GetInterfaceReply_init_zero {false, particle_ctrl_Interface_init_zero} +#define particle_ctrl_GetInterfaceReply_init_zero {particle_ctrl_Interface_init_zero} /* Field tags (for use in manual encoding/decoding) */ #define particle_ctrl_DNSConfiguration_servers_tag 1 @@ -291,7 +276,7 @@ X(a, STATIC, SINGULAR, INT32, interface, 1) #define particle_ctrl_NetworkGetStatusRequest_DEFAULT NULL #define particle_ctrl_NetworkGetStatusReply_FIELDLIST(X, a) \ -X(a, STATIC, OPTIONAL, MESSAGE, config, 1) +X(a, STATIC, SINGULAR, MESSAGE, config, 1) #define particle_ctrl_NetworkGetStatusReply_CALLBACK NULL #define particle_ctrl_NetworkGetStatusReply_DEFAULT NULL #define particle_ctrl_NetworkGetStatusReply_config_MSGTYPE particle_ctrl_NetworkConfiguration @@ -302,13 +287,13 @@ X(a, STATIC, SINGULAR, INT32, interface, 1) #define particle_ctrl_NetworkGetConfigurationRequest_DEFAULT NULL #define particle_ctrl_NetworkGetConfigurationReply_FIELDLIST(X, a) \ -X(a, STATIC, OPTIONAL, MESSAGE, config, 1) +X(a, STATIC, SINGULAR, MESSAGE, config, 1) #define particle_ctrl_NetworkGetConfigurationReply_CALLBACK NULL #define particle_ctrl_NetworkGetConfigurationReply_DEFAULT NULL #define particle_ctrl_NetworkGetConfigurationReply_config_MSGTYPE particle_ctrl_NetworkConfiguration #define particle_ctrl_NetworkSetConfigurationRequest_FIELDLIST(X, a) \ -X(a, STATIC, OPTIONAL, MESSAGE, config, 1) +X(a, STATIC, SINGULAR, MESSAGE, config, 1) #define particle_ctrl_NetworkSetConfigurationRequest_CALLBACK NULL #define particle_ctrl_NetworkSetConfigurationRequest_DEFAULT NULL #define particle_ctrl_NetworkSetConfigurationRequest_config_MSGTYPE particle_ctrl_NetworkConfiguration @@ -320,10 +305,10 @@ X(a, STATIC, OPTIONAL, MESSAGE, config, 1) #define particle_ctrl_IPConfiguration_FIELDLIST(X, a) \ X(a, STATIC, SINGULAR, UENUM, type, 1) \ -X(a, STATIC, OPTIONAL, MESSAGE, address, 2) \ -X(a, STATIC, OPTIONAL, MESSAGE, netmask, 3) \ -X(a, STATIC, OPTIONAL, MESSAGE, gateway, 4) \ -X(a, STATIC, OPTIONAL, MESSAGE, dhcp_server, 5) \ +X(a, STATIC, SINGULAR, MESSAGE, address, 2) \ +X(a, STATIC, SINGULAR, MESSAGE, netmask, 3) \ +X(a, STATIC, SINGULAR, MESSAGE, gateway, 4) \ +X(a, STATIC, SINGULAR, MESSAGE, dhcp_server, 5) \ X(a, CALLBACK, SINGULAR, STRING, hostname, 6) #define particle_ctrl_IPConfiguration_CALLBACK pb_default_field_callback #define particle_ctrl_IPConfiguration_DEFAULT NULL @@ -343,15 +328,15 @@ X(a, STATIC, SINGULAR, INT32, interface, 1) \ X(a, STATIC, SINGULAR, UENUM, state, 2) \ X(a, CALLBACK, SINGULAR, STRING, name, 3) \ X(a, STATIC, SINGULAR, BYTES, mac, 4) \ -X(a, STATIC, OPTIONAL, MESSAGE, ipconfig, 5) \ -X(a, STATIC, OPTIONAL, MESSAGE, dnsconfig, 6) +X(a, STATIC, SINGULAR, MESSAGE, ipconfig, 5) \ +X(a, STATIC, SINGULAR, MESSAGE, dnsconfig, 6) #define particle_ctrl_NetworkConfiguration_CALLBACK pb_default_field_callback #define particle_ctrl_NetworkConfiguration_DEFAULT NULL #define particle_ctrl_NetworkConfiguration_ipconfig_MSGTYPE particle_ctrl_IPConfiguration #define particle_ctrl_NetworkConfiguration_dnsconfig_MSGTYPE particle_ctrl_DNSConfiguration #define particle_ctrl_InterfaceAddress_FIELDLIST(X, a) \ -X(a, STATIC, OPTIONAL, MESSAGE, address, 1) \ +X(a, STATIC, SINGULAR, MESSAGE, address, 1) \ X(a, STATIC, SINGULAR, UINT32, prefix_length, 2) #define particle_ctrl_InterfaceAddress_CALLBACK NULL #define particle_ctrl_InterfaceAddress_DEFAULT NULL @@ -359,8 +344,8 @@ X(a, STATIC, SINGULAR, UINT32, prefix_length, 2) #define particle_ctrl_Ipv4Config_FIELDLIST(X, a) \ X(a, CALLBACK, REPEATED, MESSAGE, addresses, 1) \ -X(a, STATIC, OPTIONAL, MESSAGE, peer, 2) \ -X(a, STATIC, OPTIONAL, MESSAGE, gateway, 3) +X(a, STATIC, SINGULAR, MESSAGE, peer, 2) \ +X(a, STATIC, SINGULAR, MESSAGE, gateway, 3) #define particle_ctrl_Ipv4Config_CALLBACK pb_default_field_callback #define particle_ctrl_Ipv4Config_DEFAULT NULL #define particle_ctrl_Ipv4Config_addresses_MSGTYPE particle_ctrl_InterfaceAddress @@ -379,8 +364,8 @@ X(a, CALLBACK, SINGULAR, STRING, name, 2) \ X(a, STATIC, SINGULAR, UENUM, type, 3) \ X(a, STATIC, SINGULAR, UINT32, flags, 4) \ X(a, STATIC, SINGULAR, UINT32, ext_flags, 5) \ -X(a, STATIC, OPTIONAL, MESSAGE, ipv4_config, 6) \ -X(a, STATIC, OPTIONAL, MESSAGE, ipv6_config, 7) \ +X(a, STATIC, SINGULAR, MESSAGE, ipv4_config, 6) \ +X(a, STATIC, SINGULAR, MESSAGE, ipv6_config, 7) \ X(a, STATIC, SINGULAR, BYTES, hw_address, 8) \ X(a, STATIC, SINGULAR, UINT32, mtu, 9) \ X(a, STATIC, SINGULAR, UINT32, metric, 10) @@ -413,7 +398,7 @@ X(a, STATIC, SINGULAR, UINT32, index, 1) #define particle_ctrl_GetInterfaceRequest_DEFAULT NULL #define particle_ctrl_GetInterfaceReply_FIELDLIST(X, a) \ -X(a, STATIC, OPTIONAL, MESSAGE, interface, 1) +X(a, STATIC, SINGULAR, MESSAGE, interface, 1) #define particle_ctrl_GetInterfaceReply_CALLBACK NULL #define particle_ctrl_GetInterfaceReply_DEFAULT NULL #define particle_ctrl_GetInterfaceReply_interface_MSGTYPE particle_ctrl_Interface diff --git a/proto_defs/src/control/storage.pb.h b/proto_defs/src/control/storage.pb.h index 7c896303b9..d7c0664ba9 100644 --- a/proto_defs/src/control/storage.pb.h +++ b/proto_defs/src/control/storage.pb.h @@ -182,7 +182,6 @@ typedef struct _particle_ctrl_DescribeStorageReply_Section { particle_ctrl_SectionType type; /* Storage index */ uint32_t size; /* Section index */ uint32_t flags; /* Offset */ - bool has_firmware_module; particle_ctrl_DescribeStorageReply_Section_FirmwareModule firmware_module; /* Size */ } particle_ctrl_DescribeStorageReply_Section; @@ -228,7 +227,7 @@ extern "C" { #define particle_ctrl_FirmwareUpdateDataReply_init_default {0} #define particle_ctrl_DescribeStorageRequest_init_default {0} #define particle_ctrl_DescribeStorageReply_init_default {{{NULL}, NULL}} -#define particle_ctrl_DescribeStorageReply_Section_init_default {_particle_ctrl_SectionType_MIN, 0, 0, false, particle_ctrl_DescribeStorageReply_Section_FirmwareModule_init_default} +#define particle_ctrl_DescribeStorageReply_Section_init_default {_particle_ctrl_SectionType_MIN, 0, 0, particle_ctrl_DescribeStorageReply_Section_FirmwareModule_init_default} #define particle_ctrl_DescribeStorageReply_Section_FirmwareModule_init_default {_particle_ctrl_FirmwareModuleType_MIN, 0} #define particle_ctrl_DescribeStorageReply_Storage_init_default {_particle_ctrl_StorageType_MIN, 0, {{NULL}, NULL}} #define particle_ctrl_ReadSectionDataRequest_init_default {0, 0, 0, 0} @@ -253,7 +252,7 @@ extern "C" { #define particle_ctrl_FirmwareUpdateDataReply_init_zero {0} #define particle_ctrl_DescribeStorageRequest_init_zero {0} #define particle_ctrl_DescribeStorageReply_init_zero {{{NULL}, NULL}} -#define particle_ctrl_DescribeStorageReply_Section_init_zero {_particle_ctrl_SectionType_MIN, 0, 0, false, particle_ctrl_DescribeStorageReply_Section_FirmwareModule_init_zero} +#define particle_ctrl_DescribeStorageReply_Section_init_zero {_particle_ctrl_SectionType_MIN, 0, 0, particle_ctrl_DescribeStorageReply_Section_FirmwareModule_init_zero} #define particle_ctrl_DescribeStorageReply_Section_FirmwareModule_init_zero {_particle_ctrl_FirmwareModuleType_MIN, 0} #define particle_ctrl_DescribeStorageReply_Storage_init_zero {_particle_ctrl_StorageType_MIN, 0, {{NULL}, NULL}} #define particle_ctrl_ReadSectionDataRequest_init_zero {0, 0, 0, 0} @@ -367,7 +366,7 @@ X(a, CALLBACK, REPEATED, MESSAGE, storage, 1) X(a, STATIC, SINGULAR, UENUM, type, 1) \ X(a, STATIC, SINGULAR, UINT32, size, 2) \ X(a, STATIC, SINGULAR, UINT32, flags, 3) \ -X(a, STATIC, OPTIONAL, MESSAGE, firmware_module, 4) +X(a, STATIC, SINGULAR, MESSAGE, firmware_module, 4) #define particle_ctrl_DescribeStorageReply_Section_CALLBACK NULL #define particle_ctrl_DescribeStorageReply_Section_DEFAULT NULL #define particle_ctrl_DescribeStorageReply_Section_firmware_module_MSGTYPE particle_ctrl_DescribeStorageReply_Section_FirmwareModule diff --git a/proto_defs/src/control/wifi.pb.h b/proto_defs/src/control/wifi.pb.h index 33f9232afe..bee6cccec5 100644 --- a/proto_defs/src/control/wifi.pb.h +++ b/proto_defs/src/control/wifi.pb.h @@ -97,12 +97,10 @@ typedef struct _particle_ctrl_WiFiGetAntennaReply { } particle_ctrl_WiFiGetAntennaReply; typedef struct _particle_ctrl_WiFiGetCredentialsReply { - bool has_list; particle_ctrl_WiFiAccessPointList list; } particle_ctrl_WiFiGetCredentialsReply; typedef struct _particle_ctrl_WiFiScanReply { - bool has_list; particle_ctrl_WiFiAccessPointList list; } particle_ctrl_WiFiScanReply; @@ -111,7 +109,6 @@ typedef struct _particle_ctrl_WiFiSetAntennaRequest { } particle_ctrl_WiFiSetAntennaRequest; typedef struct _particle_ctrl_WiFiSetCredentialsRequest { - bool has_ap; particle_ctrl_WiFiAccessPoint ap; } particle_ctrl_WiFiSetCredentialsRequest; @@ -144,10 +141,10 @@ extern "C" { #define particle_ctrl_WiFiSetAntennaRequest_init_default {_particle_ctrl_WiFiAntenna_MIN} #define particle_ctrl_WiFiSetAntennaReply_init_default {0} #define particle_ctrl_WiFiScanRequest_init_default {0} -#define particle_ctrl_WiFiScanReply_init_default {false, particle_ctrl_WiFiAccessPointList_init_default} +#define particle_ctrl_WiFiScanReply_init_default {particle_ctrl_WiFiAccessPointList_init_default} #define particle_ctrl_WiFiGetCredentialsRequest_init_default {0} -#define particle_ctrl_WiFiGetCredentialsReply_init_default {false, particle_ctrl_WiFiAccessPointList_init_default} -#define particle_ctrl_WiFiSetCredentialsRequest_init_default {false, particle_ctrl_WiFiAccessPoint_init_default} +#define particle_ctrl_WiFiGetCredentialsReply_init_default {particle_ctrl_WiFiAccessPointList_init_default} +#define particle_ctrl_WiFiSetCredentialsRequest_init_default {particle_ctrl_WiFiAccessPoint_init_default} #define particle_ctrl_WiFiSetCredentialsReply_init_default {0} #define particle_ctrl_WiFiClearCredentialsRequest_init_default {0} #define particle_ctrl_WiFiClearCredentialsReply_init_default {0} @@ -158,10 +155,10 @@ extern "C" { #define particle_ctrl_WiFiSetAntennaRequest_init_zero {_particle_ctrl_WiFiAntenna_MIN} #define particle_ctrl_WiFiSetAntennaReply_init_zero {0} #define particle_ctrl_WiFiScanRequest_init_zero {0} -#define particle_ctrl_WiFiScanReply_init_zero {false, particle_ctrl_WiFiAccessPointList_init_zero} +#define particle_ctrl_WiFiScanReply_init_zero {particle_ctrl_WiFiAccessPointList_init_zero} #define particle_ctrl_WiFiGetCredentialsRequest_init_zero {0} -#define particle_ctrl_WiFiGetCredentialsReply_init_zero {false, particle_ctrl_WiFiAccessPointList_init_zero} -#define particle_ctrl_WiFiSetCredentialsRequest_init_zero {false, particle_ctrl_WiFiAccessPoint_init_zero} +#define particle_ctrl_WiFiGetCredentialsReply_init_zero {particle_ctrl_WiFiAccessPointList_init_zero} +#define particle_ctrl_WiFiSetCredentialsRequest_init_zero {particle_ctrl_WiFiAccessPoint_init_zero} #define particle_ctrl_WiFiSetCredentialsReply_init_zero {0} #define particle_ctrl_WiFiClearCredentialsRequest_init_zero {0} #define particle_ctrl_WiFiClearCredentialsReply_init_zero {0} @@ -217,7 +214,7 @@ X(a, STATIC, SINGULAR, UENUM, antenna, 1) #define particle_ctrl_WiFiScanRequest_DEFAULT NULL #define particle_ctrl_WiFiScanReply_FIELDLIST(X, a) \ -X(a, STATIC, OPTIONAL, MESSAGE, list, 1) +X(a, STATIC, SINGULAR, MESSAGE, list, 1) #define particle_ctrl_WiFiScanReply_CALLBACK NULL #define particle_ctrl_WiFiScanReply_DEFAULT NULL #define particle_ctrl_WiFiScanReply_list_MSGTYPE particle_ctrl_WiFiAccessPointList @@ -228,13 +225,13 @@ X(a, STATIC, OPTIONAL, MESSAGE, list, 1) #define particle_ctrl_WiFiGetCredentialsRequest_DEFAULT NULL #define particle_ctrl_WiFiGetCredentialsReply_FIELDLIST(X, a) \ -X(a, STATIC, OPTIONAL, MESSAGE, list, 1) +X(a, STATIC, SINGULAR, MESSAGE, list, 1) #define particle_ctrl_WiFiGetCredentialsReply_CALLBACK NULL #define particle_ctrl_WiFiGetCredentialsReply_DEFAULT NULL #define particle_ctrl_WiFiGetCredentialsReply_list_MSGTYPE particle_ctrl_WiFiAccessPointList #define particle_ctrl_WiFiSetCredentialsRequest_FIELDLIST(X, a) \ -X(a, STATIC, OPTIONAL, MESSAGE, ap, 1) +X(a, STATIC, SINGULAR, MESSAGE, ap, 1) #define particle_ctrl_WiFiSetCredentialsRequest_CALLBACK NULL #define particle_ctrl_WiFiSetCredentialsRequest_DEFAULT NULL #define particle_ctrl_WiFiSetCredentialsRequest_ap_MSGTYPE particle_ctrl_WiFiAccessPoint diff --git a/proto_defs/src/control/wifi_new.pb.h b/proto_defs/src/control/wifi_new.pb.h index 6107273f8f..8e58701603 100644 --- a/proto_defs/src/control/wifi_new.pb.h +++ b/proto_defs/src/control/wifi_new.pb.h @@ -136,7 +136,6 @@ typedef struct _particle_ctrl_wifi_JoinNewNetworkRequest { pb_callback_t ssid; /* Network SSID */ particle_ctrl_wifi_JoinNewNetworkRequest_bssid_t bssid; /* Network address */ particle_ctrl_wifi_Security security; /* Network security */ - bool has_credentials; particle_ctrl_wifi_Credentials credentials; /* Network credentials */ } particle_ctrl_wifi_JoinNewNetworkRequest; @@ -157,7 +156,7 @@ extern "C" { /* Initializer values for message structs */ #define particle_ctrl_wifi_Credentials_init_default {_particle_ctrl_wifi_CredentialsType_MIN, {{NULL}, NULL}} -#define particle_ctrl_wifi_JoinNewNetworkRequest_init_default {{{NULL}, NULL}, {0, {0}}, _particle_ctrl_wifi_Security_MIN, false, particle_ctrl_wifi_Credentials_init_default} +#define particle_ctrl_wifi_JoinNewNetworkRequest_init_default {{{NULL}, NULL}, {0, {0}}, _particle_ctrl_wifi_Security_MIN, particle_ctrl_wifi_Credentials_init_default} #define particle_ctrl_wifi_JoinNewNetworkReply_init_default {0} #define particle_ctrl_wifi_JoinKnownNetworkRequest_init_default {{{NULL}, NULL}} #define particle_ctrl_wifi_JoinKnownNetworkReply_init_default {0} @@ -174,7 +173,7 @@ extern "C" { #define particle_ctrl_wifi_ScanNetworksReply_init_default {{{NULL}, NULL}} #define particle_ctrl_wifi_ScanNetworksReply_Network_init_default {{{NULL}, NULL}, {0, {0}}, _particle_ctrl_wifi_Security_MIN, 0, 0} #define particle_ctrl_wifi_Credentials_init_zero {_particle_ctrl_wifi_CredentialsType_MIN, {{NULL}, NULL}} -#define particle_ctrl_wifi_JoinNewNetworkRequest_init_zero {{{NULL}, NULL}, {0, {0}}, _particle_ctrl_wifi_Security_MIN, false, particle_ctrl_wifi_Credentials_init_zero} +#define particle_ctrl_wifi_JoinNewNetworkRequest_init_zero {{{NULL}, NULL}, {0, {0}}, _particle_ctrl_wifi_Security_MIN, particle_ctrl_wifi_Credentials_init_zero} #define particle_ctrl_wifi_JoinNewNetworkReply_init_zero {0} #define particle_ctrl_wifi_JoinKnownNetworkRequest_init_zero {{{NULL}, NULL}} #define particle_ctrl_wifi_JoinKnownNetworkReply_init_zero {0} @@ -226,7 +225,7 @@ X(a, CALLBACK, SINGULAR, STRING, password, 2) X(a, CALLBACK, SINGULAR, STRING, ssid, 1) \ X(a, STATIC, SINGULAR, BYTES, bssid, 2) \ X(a, STATIC, SINGULAR, UENUM, security, 3) \ -X(a, STATIC, OPTIONAL, MESSAGE, credentials, 4) +X(a, STATIC, SINGULAR, MESSAGE, credentials, 4) #define particle_ctrl_wifi_JoinNewNetworkRequest_CALLBACK pb_default_field_callback #define particle_ctrl_wifi_JoinNewNetworkRequest_DEFAULT NULL #define particle_ctrl_wifi_JoinNewNetworkRequest_credentials_MSGTYPE particle_ctrl_wifi_Credentials diff --git a/proto_defs/src/network_config.pb.h b/proto_defs/src/network_config.pb.h index 3957b45d02..11203122e5 100644 --- a/proto_defs/src/network_config.pb.h +++ b/proto_defs/src/network_config.pb.h @@ -17,9 +17,7 @@ typedef struct _particle_firmware_WifiConfig { } particle_firmware_WifiConfig; typedef struct _particle_firmware_CellularConfig { - bool has_internal_sim; particle_ctrl_cellular_AccessPoint internal_sim; - bool has_external_sim; particle_ctrl_cellular_AccessPoint external_sim; particle_ctrl_cellular_SimType active_sim; } particle_firmware_CellularConfig; @@ -29,7 +27,6 @@ typedef struct _particle_firmware_WifiConfig_Network { pb_callback_t ssid; particle_firmware_WifiConfig_Network_bssid_t bssid; particle_ctrl_wifi_Security security; - bool has_credentials; particle_ctrl_wifi_Credentials credentials; } particle_firmware_WifiConfig_Network; @@ -40,11 +37,11 @@ extern "C" { /* Initializer values for message structs */ #define particle_firmware_WifiConfig_init_default {{{NULL}, NULL}} -#define particle_firmware_WifiConfig_Network_init_default {{{NULL}, NULL}, {0, {0}}, _particle_ctrl_wifi_Security_MIN, false, particle_ctrl_wifi_Credentials_init_default} -#define particle_firmware_CellularConfig_init_default {false, particle_ctrl_cellular_AccessPoint_init_default, false, particle_ctrl_cellular_AccessPoint_init_default, _particle_ctrl_cellular_SimType_MIN} +#define particle_firmware_WifiConfig_Network_init_default {{{NULL}, NULL}, {0, {0}}, _particle_ctrl_wifi_Security_MIN, particle_ctrl_wifi_Credentials_init_default} +#define particle_firmware_CellularConfig_init_default {particle_ctrl_cellular_AccessPoint_init_default, particle_ctrl_cellular_AccessPoint_init_default, _particle_ctrl_cellular_SimType_MIN} #define particle_firmware_WifiConfig_init_zero {{{NULL}, NULL}} -#define particle_firmware_WifiConfig_Network_init_zero {{{NULL}, NULL}, {0, {0}}, _particle_ctrl_wifi_Security_MIN, false, particle_ctrl_wifi_Credentials_init_zero} -#define particle_firmware_CellularConfig_init_zero {false, particle_ctrl_cellular_AccessPoint_init_zero, false, particle_ctrl_cellular_AccessPoint_init_zero, _particle_ctrl_cellular_SimType_MIN} +#define particle_firmware_WifiConfig_Network_init_zero {{{NULL}, NULL}, {0, {0}}, _particle_ctrl_wifi_Security_MIN, particle_ctrl_wifi_Credentials_init_zero} +#define particle_firmware_CellularConfig_init_zero {particle_ctrl_cellular_AccessPoint_init_zero, particle_ctrl_cellular_AccessPoint_init_zero, _particle_ctrl_cellular_SimType_MIN} /* Field tags (for use in manual encoding/decoding) */ #define particle_firmware_WifiConfig_networks_tag 1 @@ -67,14 +64,14 @@ X(a, CALLBACK, REPEATED, MESSAGE, networks, 1) X(a, CALLBACK, SINGULAR, STRING, ssid, 1) \ X(a, STATIC, SINGULAR, BYTES, bssid, 2) \ X(a, STATIC, SINGULAR, UENUM, security, 3) \ -X(a, STATIC, OPTIONAL, MESSAGE, credentials, 4) +X(a, STATIC, SINGULAR, MESSAGE, credentials, 4) #define particle_firmware_WifiConfig_Network_CALLBACK pb_default_field_callback #define particle_firmware_WifiConfig_Network_DEFAULT NULL #define particle_firmware_WifiConfig_Network_credentials_MSGTYPE particle_ctrl_wifi_Credentials #define particle_firmware_CellularConfig_FIELDLIST(X, a) \ -X(a, STATIC, OPTIONAL, MESSAGE, internal_sim, 1) \ -X(a, STATIC, OPTIONAL, MESSAGE, external_sim, 2) \ +X(a, STATIC, SINGULAR, MESSAGE, internal_sim, 1) \ +X(a, STATIC, SINGULAR, MESSAGE, external_sim, 2) \ X(a, STATIC, SINGULAR, UENUM, active_sim, 3) #define particle_firmware_CellularConfig_CALLBACK NULL #define particle_firmware_CellularConfig_DEFAULT NULL From f5eee0eb5badd8f39a5f177d1ecb8ad18811cb8e Mon Sep 17 00:00:00 2001 From: Technobly Date: Wed, 16 Nov 2022 17:32:54 -0600 Subject: [PATCH 049/112] [rtl872x] fixes pinResetFast clearing too many pins and improves speed --- wiring/inc/fast_pin.h | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/wiring/inc/fast_pin.h b/wiring/inc/fast_pin.h index ca2ec419ac..efd7959237 100644 --- a/wiring/inc/fast_pin.h +++ b/wiring/inc/fast_pin.h @@ -68,21 +68,9 @@ inline void pinSetFast(hal_pin_t _pin) __attribute__((always_inline)); inline void pinResetFast(hal_pin_t _pin) __attribute__((always_inline)); inline int32_t pinReadFast(hal_pin_t _pin) __attribute__((always_inline)); -inline void pinConfigure(hal_pin_info_t _pin){ - int padMuxIndex = (32 * _pin.gpio_port) + _pin.gpio_pin; - uint32_t Temp = PINMUX->PADCTR[padMuxIndex]; - - Temp &= ~PAD_BIT_MASK_FUNCTION_ID; - Temp |= (PINMUX_FUNCTION_GPIO & PAD_BIT_MASK_FUNCTION_ID); - Temp &= ~PAD_BIT_SHUT_DWON; - - PINMUX->PADCTR[padMuxIndex] = Temp; -} - inline void pinSetFast(hal_pin_t _pin) { hal_pin_info_t pin_info = fastPinGetPinmap()[_pin]; - pinConfigure(pin_info); GPIO_TypeDef* gpiobase = ((pin_info.gpio_port == RTL_PORT_A) ? GPIOA_BASE : GPIOB_BASE); if (pin_info.pin_mode == OUTPUT_OPEN_DRAIN || pin_info.pin_mode == OUTPUT_OPEN_DRAIN_PULLUP) { @@ -96,18 +84,16 @@ inline void pinSetFast(hal_pin_t _pin) inline void pinResetFast(hal_pin_t _pin) { hal_pin_info_t pin_info = fastPinGetPinmap()[_pin]; - pinConfigure(pin_info); GPIO_TypeDef* gpiobase = ((pin_info.gpio_port == RTL_PORT_A) ? GPIOA_BASE : GPIOB_BASE); - gpiobase->PORT[0].DR &= (0 << pin_info.gpio_pin); + gpiobase->PORT[0].DR &= ~(1 << pin_info.gpio_pin); gpiobase->PORT[0].DDR |= (1 << pin_info.gpio_pin); } inline int32_t pinReadFast(hal_pin_t _pin) { hal_pin_info_t pin_info = fastPinGetPinmap()[_pin]; - pinConfigure(pin_info); - + GPIO_TypeDef* gpiobase = ((pin_info.gpio_port == RTL_PORT_A) ? GPIOA_BASE : GPIOB_BASE); return ((gpiobase->EXT_PORT[0] >> pin_info.gpio_pin) & 1UL); } From 26b873c609eea2d48459a2ece78f9a529915df6e Mon Sep 17 00:00:00 2001 From: Technobly Date: Wed, 16 Nov 2022 17:35:04 -0600 Subject: [PATCH 050/112] [gen3] fixes TEST=wiring/no_fixture fastpin tests --- user/tests/wiring/no_fixture/fastpin.cpp | 85 ++++++++++++++---------- 1 file changed, 51 insertions(+), 34 deletions(-) diff --git a/user/tests/wiring/no_fixture/fastpin.cpp b/user/tests/wiring/no_fixture/fastpin.cpp index 688cded676..a12bd622b9 100644 --- a/user/tests/wiring/no_fixture/fastpin.cpp +++ b/user/tests/wiring/no_fixture/fastpin.cpp @@ -1,69 +1,86 @@ - #include "application.h" #include "unit-test/unit-test.h" - - test(FASTPIN_01_MaxDuration_PinSet) { - // Attempt pinSetFast and pinResetFast numerous times and check speed. + // Attempt pinSetFast numerous times and check speed. #if HAL_PLATFORM_GEN == 3 - // expected max ticks of pinSetFast / pinResetFast on Gen3 - const uint32_t MAX_DURATION_PINSET_TICKS = 70; +#if PLATFORM_ID == PLATFORM_ESOMX + const pin_t pin = D5; +#else + const pin_t pin = D7; +#endif // PLATFORM_ID == PLATFORM_ESOMX + +#if HAL_PLATFORM_RTL872X + const uint32_t MAX_DURATION_PINSET_NS = 3050; // 1% higher than measured (includes for() loop overhead) +#else + const uint32_t MAX_DURATION_PINSET_NS = 1030; // 1% higher than measured (includes for() loop overhead) +#endif // HAL_PLATFORM_RTL872X #else #error "No gpio fastpin timing benchmark yet measured for this platform" -#endif +#endif // HAL_PLATFORM_GEN == 3 + + SCOPE_GUARD ({ + pinMode(pin, INPUT); + }); const uint32_t NUM_ITERATIONS = 100; uint32_t start, finish; + pinMode(pin, OUTPUT); ATOMIC_BLOCK() { - start = System.ticks(); + start = HAL_Timer_Get_Micro_Seconds() * 1000; for (uint32_t i = 0; i < NUM_ITERATIONS; i++) { - #if PLATFORM_ID == PLATFORM_ESOMX - pinSetFast(D5); - #else - pinSetFast(D7); - #endif - //pinResetFast(D7); + pinSetFast(pin); + // pinResetFast(pin); } - finish = System.ticks(); + finish = HAL_Timer_Get_Micro_Seconds() * 1000; } uint32_t duration = finish - start; -// Serial.print("Set duration:"); -// Serial.println(duration); - assertLessOrEqual(duration, NUM_ITERATIONS*MAX_DURATION_PINSET_TICKS); + uint32_t expected = NUM_ITERATIONS * MAX_DURATION_PINSET_NS; + // Serial.printlnf("pinSetFast total duration: %lu vs. expected duration: %lu", duration, expected); + assertNotEqual(duration, 0); + assertLessOrEqual(duration, expected); } test(FASTPIN_02_MaxDuration_PinReset) { // Attempt pinResetFast numerous times and check speed. #if HAL_PLATFORM_GEN == 3 - // expected max ticks of pinResetFast on Gen3 - const uint32_t MAX_DURATION_PINRESET_TICKS = 70; +#if PLATFORM_ID == PLATFORM_ESOMX + const pin_t pin = D5; +#else + const pin_t pin = D7; +#endif // PLATFORM_ID == PLATFORM_ESOMX + +#if HAL_PLATFORM_RTL872X + const uint32_t MAX_DURATION_PINRESET_NS = 3000; // 1% higher than measured (includes for() loop overhead) +#else + const uint32_t MAX_DURATION_PINRESET_NS = 1030; // 1% higher than measured (includes for() loop overhead) +#endif // HAL_PLATFORM_RTL872X #else #error "No gpio fastpin timing benchmark yet measured for this platform" -#endif +#endif // HAL_PLATFORM_GEN == 3 + + SCOPE_GUARD ({ + pinMode(pin, INPUT); + }); const uint32_t NUM_ITERATIONS = 100; uint32_t start, finish; + pinMode(pin, OUTPUT); ATOMIC_BLOCK() { - start = System.ticks(); + start = HAL_Timer_Get_Micro_Seconds() * 1000; for (uint32_t i = 0; i < NUM_ITERATIONS; i++) { - #if PLATFORM_ID == PLATFORM_ESOMX - pinResetFast(D5); - #else - pinResetFast(D7); - #endif + // pinSetFast(pin); + pinResetFast(pin); } - finish = System.ticks(); + finish = HAL_Timer_Get_Micro_Seconds() * 1000; } uint32_t duration = finish - start; -// Serial.print("Reset duration:"); -// Serial.println(duration); - assertLessOrEqual(duration, NUM_ITERATIONS*MAX_DURATION_PINRESET_TICKS); + uint32_t expected = NUM_ITERATIONS * MAX_DURATION_PINRESET_NS; + // Serial.printlnf("pinResetFast total duration: %lu vs. expected duration: %lu", duration, expected); + assertNotEqual(duration, 0); + assertLessOrEqual(duration, expected); } - - - From 6f51f35d5d2edcb7a65533a51723c59aca9e24b4 Mon Sep 17 00:00:00 2001 From: Sergey Polyakov Date: Thu, 17 Nov 2022 15:28:26 +0400 Subject: [PATCH 051/112] Allow setting an ICCID for a virtual device --- hal/src/gcc/device_config.cpp | 8 ++++++++ hal/src/gcc/device_config.h | 14 ++++++++++++++ hal/src/gcc/ota_flash_hal.cpp | 22 ++++++++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/hal/src/gcc/device_config.cpp b/hal/src/gcc/device_config.cpp index fa1fd07348..875a93834d 100644 --- a/hal/src/gcc/device_config.cpp +++ b/hal/src/gcc/device_config.cpp @@ -218,6 +218,10 @@ std::string Describe::toString() const { jsonModules.push_back(jsonModule); } jsonDesc["m"] = jsonModules; + // ICCID + if (iccid_.has_value()) { + jsonDesc["iccid"] = iccid_.value(); + } return boost::json::serialize(jsonDesc); } @@ -302,6 +306,10 @@ Describe Describe::fromString(const std::string& str) { modules.push_back(module); } desc.modules(modules); + // ICCID + if (jsonDesc.contains("iccid")) { + desc.iccid(std::string(jsonDesc.at("iccid").as_string())); + } return desc; } diff --git a/hal/src/gcc/device_config.h b/hal/src/gcc/device_config.h index 4b93d7d962..dafed93a95 100644 --- a/hal/src/gcc/device_config.h +++ b/hal/src/gcc/device_config.h @@ -207,6 +207,19 @@ class Describe { return modules_; } + Describe& iccid(std::string iccid) { + iccid_ = std::move(iccid); + return *this; + } + + std::string_view iccid() const { + return iccid_.has_value() ? iccid_.value() : std::string_view(); + } + + bool has_iccid() const { + return iccid_.has_value(); + } + bool isValid() const { return platformId_.has_value(); } @@ -218,6 +231,7 @@ class Describe { private: Modules modules_; + std::optional iccid_; std::optional platformId_; }; diff --git a/hal/src/gcc/ota_flash_hal.cpp b/hal/src/gcc/ota_flash_hal.cpp index 7112b3039d..2fd2011029 100644 --- a/hal/src/gcc/ota_flash_hal.cpp +++ b/hal/src/gcc/ota_flash_hal.cpp @@ -499,4 +499,26 @@ extern "C" void random_seed_from_cloud(unsigned int value) void HAL_OTA_Add_System_Info(hal_system_info_t* info, bool create, void* reserved) { + if (create) { + size_t count = 0; + const auto& desc = deviceConfig.describe; + if (desc.has_iccid()) { + ++count; + } + std::unique_ptr keyValues(new(std::nothrow) key_value[count]); + if (keyValues) { + memset(keyValues.get(), 0, sizeof(key_value) * count); + if (desc.has_iccid()) { + keyValues[0].key = "iccid"; + auto iccid = desc.iccid(); + memcpy(keyValues[0].value, iccid.data(), std::min(iccid.size(), sizeof(key_value::value) - 1)); + } + info->key_values = keyValues.release(); + info->key_value_count = count; + } + } else { + std::unique_ptr keyValues(info->key_values); + info->key_values = nullptr; + info->key_value_count = 0; + } } From b9dab384c3edeab318f977879ddec1feec82a928 Mon Sep 17 00:00:00 2001 From: Sergey Polyakov Date: Thu, 17 Nov 2022 16:44:56 +0400 Subject: [PATCH 052/112] Bugfixes --- hal/src/gcc/ota_flash_hal.cpp | 45 +++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/hal/src/gcc/ota_flash_hal.cpp b/hal/src/gcc/ota_flash_hal.cpp index 2fd2011029..0261cc9312 100644 --- a/hal/src/gcc/ota_flash_hal.cpp +++ b/hal/src/gcc/ota_flash_hal.cpp @@ -151,6 +151,7 @@ size_t g_updateSize = 0; int HAL_System_Info(hal_system_info_t* info, bool create, void* reserved) { if (!create) { + HAL_OTA_Add_System_Info(info, false /* create */, nullptr /* reserved */); delete[] info->modules; return 0; } @@ -218,6 +219,9 @@ int HAL_System_Info(hal_system_info_t* info, bool create, void* reserved) info->platform_id = deviceConfig.platform_id; info->module_count = desc.modules().size(); info->modules = halModules.release(); + info->key_values = nullptr; + info->key_value_count = 0; + HAL_OTA_Add_System_Info(info, true /* create */, nullptr /* reserved */); return 0; } @@ -499,26 +503,25 @@ extern "C" void random_seed_from_cloud(unsigned int value) void HAL_OTA_Add_System_Info(hal_system_info_t* info, bool create, void* reserved) { - if (create) { - size_t count = 0; - const auto& desc = deviceConfig.describe; - if (desc.has_iccid()) { - ++count; - } - std::unique_ptr keyValues(new(std::nothrow) key_value[count]); - if (keyValues) { - memset(keyValues.get(), 0, sizeof(key_value) * count); - if (desc.has_iccid()) { - keyValues[0].key = "iccid"; - auto iccid = desc.iccid(); - memcpy(keyValues[0].value, iccid.data(), std::min(iccid.size(), sizeof(key_value::value) - 1)); - } - info->key_values = keyValues.release(); - info->key_value_count = count; - } - } else { - std::unique_ptr keyValues(info->key_values); - info->key_values = nullptr; - info->key_value_count = 0; + if (!create) { + delete[] info->key_values; + return; + } + size_t count = 0; + const auto& desc = deviceConfig.describe; + if (desc.has_iccid()) { + ++count; + } + std::unique_ptr keyValues(new(std::nothrow) key_value[count]); + if (!keyValues) { + return; + } + memset(keyValues.get(), 0, sizeof(key_value) * count); + if (desc.has_iccid()) { + keyValues[0].key = "iccid"; + auto iccid = desc.iccid(); + memcpy(keyValues[0].value, iccid.data(), std::min(iccid.size(), sizeof(key_value::value) - 1)); } + info->key_value_count = count; + info->key_values = keyValues.release(); } From f1dff84bb192fcdeeda19802825063308977fd61 Mon Sep 17 00:00:00 2001 From: James Wilson Date: Tue, 15 Nov 2022 09:33:31 -0800 Subject: [PATCH 053/112] Open drain output option for IO expander interrupt --- hal/inc/hal_platform.h | 3 +++ hal/shared/mcp23s17.cpp | 12 +++++++++++- hal/src/trackerm/hal_platform_config.h | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/hal/inc/hal_platform.h b/hal/inc/hal_platform.h index 6fbf73d808..3d8cc68167 100644 --- a/hal/inc/hal_platform.h +++ b/hal/inc/hal_platform.h @@ -354,6 +354,9 @@ # ifndef HAL_PLATFORM_MCP23S17_MIRROR_INTERRUPTS # define HAL_PLATFORM_MCP23S17_MIRROR_INTERRUPTS (0) # endif // HAL_PLATFORM_MCP23S17_MIRROR_INTERRUPTS +# ifndef HAL_PLATFORM_MCP23S17_OPEN_DRAIN_INT +# define HAL_PLATFORM_MCP23S17_OPEN_DRAIN_INT (0) +# endif // HAL_PLATFORM_MCP23S17_OPEN_DRAIN_INT #endif /* HAL_PLATFORM_MCP23S17 */ #ifndef HAL_PLATFORM_DEMUX diff --git a/hal/shared/mcp23s17.cpp b/hal/shared/mcp23s17.cpp index 7004df0333..9fb8ad0543 100644 --- a/hal/shared/mcp23s17.cpp +++ b/hal/shared/mcp23s17.cpp @@ -135,9 +135,19 @@ int Mcp23s17::reset(bool verify) { hal_gpio_write(IOE_RST, 1); HAL_Delay_Milliseconds(10); +#if HAL_PLATFORM_MCP23S17_MIRROR_INTERRUPTS || HAL_PLATFORM_MCP23S17_OPEN_DRAIN_INT + uint8_t iocon {}; + #if HAL_PLATFORM_MCP23S17_MIRROR_INTERRUPTS - CHECK(writeRegister(IOCON_ADDR[0], 1u << 6)); + iocon |= 1u << 6; +#endif +#if HAL_PLATFORM_MCP23S17_OPEN_DRAIN_INT + iocon |= 1u << 2; #endif + + CHECK(writeRegister(IOCON_ADDR[0], iocon)); +#endif + if (verify) { uint8_t tmp[22] = {0x00}; CHECK(readContinuousRegisters(IODIR_ADDR[0], tmp, sizeof(tmp))); diff --git a/hal/src/trackerm/hal_platform_config.h b/hal/src/trackerm/hal_platform_config.h index 2eea5cc1c4..5dd89ae6b2 100644 --- a/hal/src/trackerm/hal_platform_config.h +++ b/hal/src/trackerm/hal_platform_config.h @@ -34,6 +34,7 @@ #define HAL_PLATFORM_MCP23S17_SPI (HAL_SPI_INTERFACE1) #define HAL_PLATFORM_MCP23S17_SPI_CLOCK (16000000) #define HAL_PLATFORM_MCP23S17_MIRROR_INTERRUPTS (1) +#define HAL_PLATFORM_MCP23S17_OPEN_DRAIN_INT (1) #define HAL_PLATFORM_DEMUX (1) #if defined(MODULE_FUNCTION) && MODULE_FUNCTION != 2 // MOD_FUNC_BOOTLOADER From b06b1b1f9f23e673770ccb77df5e0a1d6f65a8a9 Mon Sep 17 00:00:00 2001 From: James Wilson Date: Tue, 15 Nov 2022 09:34:09 -0800 Subject: [PATCH 054/112] Separate cell reset and power for Tracker M proto 3 --- hal/src/trackerm/pinmap_defines.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hal/src/trackerm/pinmap_defines.h b/hal/src/trackerm/pinmap_defines.h index 229bc52b3b..f705e0dab0 100644 --- a/hal/src/trackerm/pinmap_defines.h +++ b/hal/src/trackerm/pinmap_defines.h @@ -141,7 +141,7 @@ #define Y7 49 // Cellular -#define BGRST P2_CELL_PWR +#define BGRST P2_CELL_RST #define BGPWR P2_CELL_PWR #define BGVINT P2_CELL_STATUS #define BGDTR P2_CELL_DTR From e42bf690d7dfa7d13a53c550947b4e428a499fea Mon Sep 17 00:00:00 2001 From: keeramis Date: Mon, 3 Oct 2022 21:07:11 -0500 Subject: [PATCH 055/112] [tests] Modify pins for trackerM spix tests --- user/tests/wiring/no_fixture_spi/spix.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/user/tests/wiring/no_fixture_spi/spix.cpp b/user/tests/wiring/no_fixture_spi/spix.cpp index 836bf2a77e..7bc98d187f 100644 --- a/user/tests/wiring/no_fixture_spi/spix.cpp +++ b/user/tests/wiring/no_fixture_spi/spix.cpp @@ -42,8 +42,10 @@ test(SPIX_01_SPI_Begin_Without_Argument) assertEqual(info.ss_pin, D8); #elif PLATFORM_ID == PLATFORM_TRACKER assertEqual(info.ss_pin, D7); -#elif HAL_PLATFORM_RTL872X +#elif PLATFORM_ID == PLATFORM_P2 assertEqual(info.ss_pin, S3); +#elif PLATFORM_ID == PLATFORM_TRACKERM + assertEqual(info.ss_pin, A2); #elif PLATFORM_ID == PLATFORM_ESOMX assertEqual(info.ss_pin, A2); #else @@ -69,8 +71,10 @@ test(SPIX_02_SPI_Begin_With_Ss_Pin) assertEqual(info.ss_pin, D8); #elif PLATFORM_ID == PLATFORM_TRACKER assertEqual(info.ss_pin, D7); -#elif HAL_PLATFORM_RTL872X +#elif PLATFORM_ID == PLATFORM_P2 assertEqual(info.ss_pin, S3); +#elif PLATFORM_ID == PLATFORM_TRACKERM + assertEqual(info.ss_pin, A2); #elif PLATFORM_ID == PLATFORM_ESOMX assertEqual(info.ss_pin, A2); #else @@ -123,8 +127,10 @@ test(SPIX_03_SPI_Begin_With_Mode) assertEqual(info.ss_pin,D8); #elif PLATFORM_ID == PLATFORM_TRACKER assertEqual(info.ss_pin, D7); -#elif HAL_PLATFORM_RTL872X +#elif PLATFORM_ID == PLATFORM_P2 assertEqual(info.ss_pin, S3); +#elif PLATFORM_ID == PLATFORM_TRACKERM + assertEqual(info.ss_pin, A2); #elif PLATFORM_ID == PLATFORM_ESOMX assertEqual(info.ss_pin, A2); #else @@ -162,8 +168,10 @@ test(SPIX_04_SPI_Begin_With_Master_Ss_Pin) assertEqual(info.ss_pin, D8); #elif PLATFORM_ID == PLATFORM_TRACKER assertEqual(info.ss_pin, D7); -#elif HAL_PLATFORM_RTL872X +#elif PLATFORM_ID == PLATFORM_P2 assertEqual(info.ss_pin, S3); +#elif PLATFORM_ID == PLATFORM_TRACKERM + assertEqual(info.ss_pin, A2); #elif PLATFORM_ID == PLATFORM_ESOMX assertEqual(info.ss_pin, A2); #else From 713a788c726de98d5e9a7d0322906f0d3de4b80b Mon Sep 17 00:00:00 2001 From: Scott Brust Date: Thu, 17 Nov 2022 15:51:54 -0800 Subject: [PATCH 056/112] bump module version number to 2.3.1 (2302) --- CHANGELOG.md | 7 +++++++ system/inc/system_version.h | 2 ++ system/system-versions.md | 1 + 3 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ead0e144e1..4daa8b8d7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -639,6 +639,13 @@ - [Gen 2] Fix D0 alternate-function being unconditionally reset when calling `Serial1.end()` [#2256](https://github.com/particle-iot/device-os/pull/2256) - [Gen 3] Fix an issue with `BLE.scan()` deadlocking [#2220](https://github.com/particle-iot/device-os/pull/2220) +## 2.3.1 + +### BUGFIXES + +- [Cellular] R410 initialization SIM failure workaround [#2573](https://github.com/particle-iot/device-os/pull/2573) +- [Boron / B SoM] R410 PPP crash in network phase workaround [#2571](https://github.com/particle-iot/device-os/pull/2571) + ## 2.3.0 ### FEATURES diff --git a/system/inc/system_version.h b/system/inc/system_version.h index 08662fc863..9372d01bf8 100644 --- a/system/inc/system_version.h +++ b/system/inc/system_version.h @@ -174,6 +174,7 @@ extern "C" { #define SYSTEM_VERSION_v220 SYSTEM_VERSION_DEFAULT(2, 2, 0) #define SYSTEM_VERSION_v230RC1 SYSTEM_VERSION_RC(2, 3, 0, 1) #define SYSTEM_VERSION_v230 SYSTEM_VERSION_DEFAULT(2, 3, 0) +#define SYSTEM_VERSION_v231 SYSTEM_VERSION_DEFAULT(2, 3, 1) #define SYSTEM_VERSION_v300ALPHA1 SYSTEM_VERSION_ALPHA(3, 0, 0, 1) #define SYSTEM_VERSION_v300ALPHA2 SYSTEM_VERSION_ALPHA(3, 0, 0, 2) #define SYSTEM_VERSION_v300BETA1 SYSTEM_VERSION_BETA(3, 0, 0, 1) @@ -336,6 +337,7 @@ extern "C" { #define SYSTEM_VERSION_220 #define SYSTEM_VERSION_230RC1 #define SYSTEM_VERSION_230 +#define SYSTEM_VERSION_231 #define SYSTEM_VERSION_300ALPHA1 #define SYSTEM_VERSION_300ALPHA2 #define SYSTEM_VERSION_300BETA1 diff --git a/system/system-versions.md b/system/system-versions.md index 598f8616d7..b2218993f0 100644 --- a/system/system-versions.md +++ b/system/system-versions.md @@ -140,6 +140,7 @@ | 1006 | 2202 | 2.2.0 | Photon, P1, Electron, Argon, Boron, B SoM, B5 SoM, Tracker | | 1006 | 2300 | 2.3.0-rc.1 | Photon, P1, Electron, Argon, Boron, B SoM, B5 SoM, Tracker | | 1006 | 2301 | 2.3.0 | Photon, P1, Electron, Argon, Boron, B SoM, B5 SoM, Tracker | +| 1006 | 2302 | 2.3.1 | Photon, P1, Electron, Argon, Boron, B SoM, B5 SoM, Tracker | | 1005 | 3000 | 3.0.0-alpha.1 | Photon, P1, Electron, Argon, Boron, B SoM, B5 SoM, Tracker | | 1005 | 3001 | 3.0.0-alpha.2 | Photon, P1, Electron, Argon, Boron, B SoM, B5 SoM, Tracker | | 1005 | 3002 | 3.0.0-beta.1 | Photon, P1, Electron, Argon, Boron, B SoM, B5 SoM, Tracker | From 55a3917b4b3f31c74e38042c9316d45adb457b38 Mon Sep 17 00:00:00 2001 From: Scott Brust Date: Thu, 17 Nov 2022 15:54:12 -0800 Subject: [PATCH 057/112] bump module version to 3.3.1 (3302) --- CHANGELOG.md | 7 +++++++ system/inc/system_version.h | 2 ++ system/system-versions.md | 1 + 3 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4daa8b8d7b..5b99f1ad05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -267,6 +267,13 @@ - [ci] feature/sc-100324/ci-build-cross-platform [#2418](https://github.com/particle-iot/device-os/pull/2418) - [test] Wi-Fi resolve test improvements [#2454](https://github.com/particle-iot/device-os/pull/2454) +## 3.3.1 + +### BUGFIXES + +- [Boron / B SoM] R410 PPP crash in network phase workaround [#2571](https://github.com/particle-iot/device-os/pull/2571) +- [Cellular] R410 initialization SIM failure workaround [#2573](https://github.com/particle-iot/device-os/pull/2573) + ## 3.3.0 ### FEATURES diff --git a/system/inc/system_version.h b/system/inc/system_version.h index 9372d01bf8..0def6c337b 100644 --- a/system/inc/system_version.h +++ b/system/inc/system_version.h @@ -189,6 +189,7 @@ extern "C" { #define SYSTEM_VERSION_v320 SYSTEM_VERSION_DEFAULT(3, 2, 0) #define SYSTEM_VERSION_v330RC1 SYSTEM_VERSION_RC(3, 3, 0, 1) #define SYSTEM_VERSION_v330 SYSTEM_VERSION_DEFAULT(3, 3, 0) +#define SYSTEM_VERSION_v331 SYSTEM_VERSION_DEFAULT(3, 3, 1) #define SYSTEM_VERSION_v400ALPHA1 SYSTEM_VERSION_ALPHA(4, 0, 0, 1) #define SYSTEM_VERSION_v400ALPHA2 SYSTEM_VERSION_ALPHA(4, 0, 0, 2) #define SYSTEM_VERSION_v400BETA1 SYSTEM_VERSION_BETA(4, 0, 0, 1) @@ -352,6 +353,7 @@ extern "C" { #define SYSTEM_VERSION_320 #define SYSTEM_VERSION_330RC1 #define SYSTEM_VERSION_330 +#define SYSTEM_VERSION_331 #define SYSTEM_VERSION_400ALPHA1 #define SYSTEM_VERSION_400ALPHA2 #define SYSTEM_VERSION_400BETA1 diff --git a/system/system-versions.md b/system/system-versions.md index b2218993f0..6573ab11e2 100644 --- a/system/system-versions.md +++ b/system/system-versions.md @@ -164,6 +164,7 @@ | 1009 | 3213 | 3.2.1-p2.4 | P2 | | 1100 | 3300 | 3.3.0-rc.1 | Photon, P1, Electron, Argon, Boron, B SoM, B5 SoM, Tracker | | 1100 | 3301 | 3.3.0 | Photon, P1, Electron, Argon, Boron, B SoM, B5 SoM, Tracker | +| 1100 | 3302 | 3.3.1 | Photon, P1, Electron, Argon, Boron, B SoM, B5 SoM, Tracker | | 1100 | 4000 | 4.0.0-alpha.1 | Argon, Boron, B SoM, B5 SoM, Tracker | | 1101 | 4001 | 4.0.0-alpha.2 | Argon, Boron, B SoM, B5 SoM, Tracker, E Som X | | 1101 | 4002 | 4.0.0-beta.1 | Argon, Boron, B SoM, B5 SoM, Tracker, E Som X | From 8b4b55b4af9865b58ebf31d1a60acaa295e4acfa Mon Sep 17 00:00:00 2001 From: Scott Brust Date: Thu, 17 Nov 2022 16:07:49 -0800 Subject: [PATCH 058/112] bump module version to 4.0.1 (4005) --- CHANGELOG.md | 16 ++++++++++++++++ system/inc/system_version.h | 4 ++++ system/system-versions.md | 2 ++ 3 files changed, 22 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b99f1ad05..3239ccb109 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -136,6 +136,22 @@ - [tests] Fix broken tone and servo tests for p2 platform, also EEPROM_03 for all. [#2469](https://github.com/particle-iot/device-os/pull/2469) - [workbench] Stop ignoring device os scripts directory [#2471](https://github.com/particle-iot/device-os/pull/2471) +## 4.0.1 + +### BUGFIXES +- [wiring] ApplicationWatchdog: fixes potential 2x timeout required to fire [#2536](https://github.com/particle-iot/device-os/pull/2536) +- [gen3]Fix BLE control request channel sending malformed packets [#2538](https://github.com/particle-iot/device-os/pull/2538) +- Fix issue with platform_ncp_get_info(0) for quectel platforms [#2532](https://github.com/particle-iot/device-os/pull/2532/) +- Secures DCT initialization from getting interrupted between creating DCT file and filling it with 0xff to default state [#2530](https://github.com/particle-iot/device-os/pull/2530) +- [Boron / B SoM] R410 PPP crash in network phase workaround [#2571](https://github.com/particle-iot/device-os/pull/2571) +- [Cellular] R410 initialization SIM failure workaround [#2573](https://github.com/particle-iot/device-os/pull/2573) + +### INTERNAL +- Use new `prtcl` compile/clean commands for internal CI builds [#2543](https://github.com/particle-iot/device-os/pull/2543) +- Increase timeouts for internal CI builds on windows [#2545](https://github.com/particle-iot/device-os/pull/2545) +- HAL wiring api calls to access exflash read/write functions for OTP flash page [#2540](https://github.com/particle-iot/device-os/pull/2540) +- [hal] wifi: add generic 'world' country code as not every country code is exposed through API [#2539](https://github.com/particle-iot/device-os/pull/2539) + ## 4.0.0 ### DEPRECATION diff --git a/system/inc/system_version.h b/system/inc/system_version.h index 0def6c337b..9eaa01ba00 100644 --- a/system/inc/system_version.h +++ b/system/inc/system_version.h @@ -194,6 +194,8 @@ extern "C" { #define SYSTEM_VERSION_v400ALPHA2 SYSTEM_VERSION_ALPHA(4, 0, 0, 2) #define SYSTEM_VERSION_v400BETA1 SYSTEM_VERSION_BETA(4, 0, 0, 1) #define SYSTEM_VERSION_v400 SYSTEM_VERSION_DEFAULT(4, 0, 0) +#define SYSTEM_VERSION_v401RC1 SYSTEM_VERSION_RC(4, 0, 1, 1) +#define SYSTEM_VERSION_v401 SYSTEM_VERSION_DEFAULT(4, 0, 1) #define SYSTEM_VERSION_v500ALPHA1 SYSTEM_VERSION_ALPHA(5, 0, 0, 1) #define SYSTEM_VERSION_v500ALPHA2 SYSTEM_VERSION_ALPHA(5, 0, 0, 2) #define SYSTEM_VERSION_v500 SYSTEM_VERSION_DEFAULT(5, 0, 0) @@ -358,6 +360,8 @@ extern "C" { #define SYSTEM_VERSION_400ALPHA2 #define SYSTEM_VERSION_400BETA1 #define SYSTEM_VERSION_400 +#define SYSTEM_VERSION_401RC1 +#define SYSTEM_VERSION_401 #define SYSTEM_VERSION_500ALPHA1 #define SYSTEM_VERSION_500ALPHA2 #define SYSTEM_VERSION_500 diff --git a/system/system-versions.md b/system/system-versions.md index 6573ab11e2..ac9a90fa2d 100644 --- a/system/system-versions.md +++ b/system/system-versions.md @@ -169,6 +169,8 @@ | 1101 | 4001 | 4.0.0-alpha.2 | Argon, Boron, B SoM, B5 SoM, Tracker, E Som X | | 1101 | 4002 | 4.0.0-beta.1 | Argon, Boron, B SoM, B5 SoM, Tracker, E Som X | | 1101 | 4003 | 4.0.0 | Argon, Boron, B SoM, B5 SoM, Tracker, E Som X | +| 1101 | 4004 | 4.0.1-rc.1 | Argon, Boron, B SoM, B5 SoM, Tracker, E Som X | +| 1101 | 4005 | 4.0.1 | Argon, Boron, B SoM, B5 SoM, Tracker, E Som X | | 2000 | 5000 | 5.0.0-alpha.1 | Argon, Boron, B SoM, B5 SoM, Tracker, E Som X, P2 | | 2000 | 5001 | 5.0.0-alpha.2 | Argon, Boron, B SoM, B5 SoM, Tracker, E Som X, P2 | | 2000 | 5002 | 5.0.0 | Argon, Boron, B SoM, B5 SoM, Tracker, Tracker M, E Som X, P2 | From edc3e489ed47279180f70e70af4c937ee8df5d26 Mon Sep 17 00:00:00 2001 From: Eugene Date: Wed, 19 Oct 2022 14:25:26 +0800 Subject: [PATCH 059/112] [rtl872x] hal: rework flash_mal and temporarily remove rsip stuff --- platform/MCU/rtl872x/src/flash_mal.c | 217 ++++++++++++--------------- 1 file changed, 98 insertions(+), 119 deletions(-) diff --git a/platform/MCU/rtl872x/src/flash_mal.c b/platform/MCU/rtl872x/src/flash_mal.c index aa46a8fc36..3af2ca4fd1 100644 --- a/platform/MCU/rtl872x/src/flash_mal.c +++ b/platform/MCU/rtl872x/src/flash_mal.c @@ -53,11 +53,34 @@ static int hal_memory_read(uintptr_t addr, uint8_t* data_buf, size_t data_size) return 0; } +static int hal_memory_write(uintptr_t addr, const uint8_t* data_buf, size_t data_size) { + memcpy((void*)addr, data_buf, data_size); + return 0; +} + #if MODULE_FUNCTION == MOD_FUNC_BOOTLOADER #define FLASH_MAL_OTA_TEMPORARY_MEMORY_BUFFER (2 * 1024 * 1024) static uint8_t otaTemporaryMemoryBuffer[FLASH_MAL_OTA_TEMPORARY_MEMORY_BUFFER] __attribute__((section(".psram"))); #endif // MODULE_FUNCTION == MOD_FUNC_BOOTLOADER +bool is_encrypted_region(uint32_t address) { + uint8_t userEfuse0 = 0xFF; + EFUSE_PMAP_READ8(0, USER_KEY_0_EFUSE_ADDRESS, &userEfuse0, L25EOUTVOLTAGE); + bool part1_encryption_enabled = !(userEfuse0 & PART1_ENCRYPTED_BIT); + + if (part1_encryption_enabled) { + if (!(address >= KM0_MBR_START_ADDRESS && address < (KM0_MBR_START_ADDRESS + KM0_MBR_IMAGE_SIZE)) /* MBR */ + && !(address >= KM0_PART1_START_ADDRESS && address < (KM0_PART1_START_ADDRESS + KM0_PART1_IMAGE_SIZE)) /* part1 */) { + return false; + } + } else { + if (!(address >= KM0_MBR_START_ADDRESS && address < (KM0_MBR_START_ADDRESS + KM0_MBR_IMAGE_SIZE)) /* MBR */) { + return false; + } + } + return true; +} + /* WARNING: enable_rsip_if_disabled() and disable_rsip_if_enabled() must be used in pair. * They can be called recursively. * @@ -69,10 +92,7 @@ bool enable_rsip_if_disabled(uint32_t address, int* is) { if ((HAL_READ32(SYSTEM_CTRL_BASE_LP, REG_SYS_EFUSE_SYSCFG3) & BIT_SYS_FLASH_ENCRYPT_EN) == 0) { return false; } - if (!(address >= KM0_MBR_START_ADDRESS && address < (KM0_MBR_START_ADDRESS + KM0_MBR_IMAGE_SIZE)) /* MBR */ - && !(address >= KM0_PART1_START_ADDRESS && address < (KM0_PART1_START_ADDRESS + KM0_PART1_IMAGE_SIZE)) /* part1 */) { - return false; - } + uint32_t km0_system_control = HAL_READ32(SYSTEM_CTRL_BASE_LP, REG_LP_KM0_CTRL); if ((km0_system_control & BIT_LSYS_PLFM_FLASH_SCE) != 0) { return false; @@ -129,8 +149,7 @@ static bool flash_write(flash_device_t dev, uintptr_t addr, const uint8_t* buf, } #endif // USE_SERIAL_FLASH case FLASH_ADDRESS: { - memcpy((void*)addr, buf, size); - ok = true; + ok = (hal_memory_write(addr, buf, size) == 0); break; } } @@ -307,16 +326,18 @@ static bool parse_compressed_module_header(flash_device_t dev, uintptr_t addr, s #endif // HAS_COMPRESSED_OTA bool FLASH_CheckValidAddressRange(flash_device_t flashDeviceID, uint32_t startAddress, uint32_t length) { +#ifndef USE_SERIAL_FLASH + if (flashDeviceID == FLASH_SERIAL) { + return false; + } +#endif + // FIXME: remove magic numbers uint32_t endAddress = startAddress + length - 1; if (flashDeviceID == FLASH_INTERNAL) { - return (startAddress >= 0x08000000 && endAddress <= 0x08800000); + return (startAddress >= 0x08000000 && endAddress < 0x08800000); } else if (flashDeviceID == FLASH_SERIAL) { -#ifdef USE_SERIAL_FLASH - return startAddress >= 0x00000000 && endAddress <= EXTERNAL_FLASH_SIZE; -#else - return false; -#endif + return startAddress >= 0x00000000 && endAddress < EXTERNAL_FLASH_SIZE; } else if (flashDeviceID == FLASH_ADDRESS) { // FIXME: #if MODULE_FUNCTION == MOD_FUNC_BOOTLOADER @@ -331,6 +352,12 @@ bool FLASH_CheckValidAddressRange(flash_device_t flashDeviceID, uint32_t startAd } bool FLASH_EraseMemory(flash_device_t flashDeviceID, uint32_t startAddress, uint32_t length) { +#ifndef USE_SERIAL_FLASH + if (flashDeviceID == FLASH_SERIAL) { + return false; + } +#endif + uint32_t numSectors; if (FLASH_CheckValidAddressRange(flashDeviceID, startAddress, length) != true) { return false; @@ -342,15 +369,11 @@ bool FLASH_EraseMemory(flash_device_t flashDeviceID, uint32_t startAddress, uint } return true; } else if (flashDeviceID == FLASH_SERIAL) { -#ifdef USE_SERIAL_FLASH numSectors = CEIL_DIV(length, sFLASH_PAGESIZE); if (hal_exflash_erase_sector(startAddress, numSectors) != 0) { return false; } return true; -#else - return false; -#endif } else if (flashDeviceID == FLASH_ADDRESS) { // Not supported return true; @@ -413,6 +436,12 @@ int FLASH_CopyMemory(flash_device_t sourceDeviceID, uint32_t sourceAddress, bool FLASH_CompareMemory(flash_device_t sourceDeviceID, uint32_t sourceAddress, flash_device_t destinationDeviceID, uint32_t destinationAddress, uint32_t length) { +#ifndef USE_SERIAL_FLASH + if (flashDeviceID == FLASH_SERIAL) { + return false; + } +#endif + uint32_t endAddress = sourceAddress + length; // check address range if (FLASH_CheckValidAddressRange(sourceDeviceID, sourceAddress, length) != true) { @@ -427,41 +456,11 @@ bool FLASH_CompareMemory(flash_device_t sourceDeviceID, uint32_t sourceAddress, /* Program source to destination */ while (sourceAddress < endAddress) { copy_len = (endAddress - sourceAddress) >= COPY_BLOCK_SIZE ? COPY_BLOCK_SIZE : (endAddress - sourceAddress); - // Read data from source memory address - if (sourceDeviceID == FLASH_INTERNAL) { - if (hal_flash_read(sourceAddress, src_buf, copy_len)) { - return false; - } - } else if (sourceDeviceID == FLASH_SERIAL) { -#ifdef USE_SERIAL_FLASH - if (hal_exflash_read(sourceAddress, src_buf, copy_len)) { - return false; - } -#else + if(!flash_read(sourceDeviceID, sourceAddress, src_buf, copy_len)) { return false; -#endif - } else if (sourceDeviceID == FLASH_ADDRESS) { - if (hal_memory_read(sourceAddress, src_buf, copy_len)) { - return false; - } } - // Read data from destination memory address - if (sourceDeviceID == FLASH_INTERNAL) { - if (hal_flash_read(destinationAddress, dest_buf, copy_len)) { - return false; - } - } else if (sourceDeviceID == FLASH_SERIAL) { -#ifdef USE_SERIAL_FLASH - if (hal_exflash_read(destinationAddress, dest_buf, copy_len)) { - return false; - } -#else + if(!flash_read(destinationDeviceID, destinationAddress, dest_buf, copy_len)) { return false; -#endif - } else if (sourceDeviceID == FLASH_ADDRESS) { - if (hal_memory_read(destinationAddress, dest_buf, copy_len)) { - return false; - } } if (memcmp(src_buf, dest_buf, copy_len)) { /* Failed comparison check */ @@ -697,7 +696,7 @@ int FLASH_UpdateModules(void (*flashModulesCallback)(bool isUpdating)) { result = FLASH_ACCESS_RESULT_BADARG; } #else - result = FLASH_ACCESS_RESULT_BADARG; + result = FLASH_ACCESS_RESULT_BADARG; #endif } if (resetSlot) { @@ -723,43 +722,23 @@ int FLASH_UpdateModules(void (*flashModulesCallback)(bool isUpdating)) { } int FLASH_ModuleInfo(module_info_t* const infoOut, uint8_t flashDeviceID, uint32_t startAddress, uint32_t* infoOffset) { +#ifndef USE_SERIAL_FLASH + if (flashDeviceID == FLASH_SERIAL) { + return false; + } +#endif CHECK_TRUE(infoOut, SYSTEM_ERROR_INVALID_ARGUMENT); uint32_t offset = 0; - if (flashDeviceID == FLASH_INTERNAL) { - int is = 0; - bool enableRsip = enable_rsip_if_disabled(startAddress, &is); - rtl_binary_header* header = (rtl_binary_header*)startAddress; - if (header->signature_high == RTL_HEADER_SIGNATURE_HIGH && header->signature_low == RTL_HEADER_SIGNATURE_LOW) { - offset = sizeof(rtl_binary_header); - } - int ret = hal_flash_read(startAddress + offset, (uint8_t*)infoOut, sizeof(module_info_t)); - disable_rsip_if_enabled(enableRsip, is); - if (ret != SYSTEM_ERROR_NONE) { - return ret; - } - } else if (flashDeviceID == FLASH_SERIAL) { -#ifdef USE_SERIAL_FLASH - rtl_binary_header header = {}; - int ret = hal_exflash_read(startAddress, (uint8_t*)&header, sizeof(rtl_binary_header)); - if (ret != SYSTEM_ERROR_NONE) { - return ret; - } - if (header.signature_high == RTL_HEADER_SIGNATURE_HIGH && header.signature_low == RTL_HEADER_SIGNATURE_LOW) { - offset = sizeof(rtl_binary_header); - } - ret = hal_exflash_read(startAddress + offset, (uint8_t*)infoOut, sizeof(module_info_t)); - if (ret != SYSTEM_ERROR_NONE) { - return ret; - } -#else - return SYSTEM_ERROR_NOT_SUPPORTED; -#endif - } else if (flashDeviceID == FLASH_ADDRESS) { - rtl_binary_header* header = (rtl_binary_header*)startAddress; - if (header->signature_high == RTL_HEADER_SIGNATURE_HIGH && header->signature_low == RTL_HEADER_SIGNATURE_LOW) { - offset = sizeof(rtl_binary_header); - } - memcpy(infoOut, (void*)(startAddress + offset), sizeof(module_info_t)); + + rtl_binary_header header = {}; + if (!flash_read(flashDeviceID, startAddress, (uint8_t*)&header, sizeof(rtl_binary_header))) { + return SYSTEM_ERROR_INTERNAL; + } + if (header.signature_high == RTL_HEADER_SIGNATURE_HIGH && header.signature_low == RTL_HEADER_SIGNATURE_LOW) { + offset = sizeof(rtl_binary_header); + } + if (!flash_read(flashDeviceID, startAddress + offset, (uint8_t*)infoOut, sizeof(module_info_t))) { + return SYSTEM_ERROR_INTERNAL; } if (infoOffset) { *infoOffset = offset; @@ -768,40 +747,24 @@ int FLASH_ModuleInfo(module_info_t* const infoOut, uint8_t flashDeviceID, uint32 } int FLASH_ModuleCrcSuffix(module_info_crc_t* crc, module_info_suffix_t* suffix, uint8_t flashDeviceID, uint32_t endAddress) { - typedef int (*readFn_t)(uintptr_t addr, uint8_t* data_buf, size_t size); - readFn_t read = NULL; - - int is = 0; - bool enableRsip = false; - if (flashDeviceID == FLASH_INTERNAL) { - enableRsip = enable_rsip_if_disabled(endAddress, &is); - read = hal_flash_read; - } else if (flashDeviceID == FLASH_SERIAL) { -#ifdef USE_SERIAL_FLASH - read = hal_exflash_read; -#else - returrn SYSTEM_ERROR_NOT_SUPPORTED; -#endif - } else if (flashDeviceID == FLASH_ADDRESS) { - read = hal_memory_read; +#ifndef USE_SERIAL_FLASH + if (flashDeviceID == FLASH_SERIAL) { + return SYSTEM_ERROR_NOT_SUPPORTED; } - int ret = SYSTEM_ERROR_NONE; - if (read) { - if (crc) { - ret = read(endAddress, (uint8_t*)crc, sizeof(module_info_crc_t)); - if (ret != SYSTEM_ERROR_NONE) { - goto done; - } +#endif + if (crc) { + if(!flash_read(flashDeviceID, endAddress, (uint8_t*)crc, sizeof(module_info_crc_t))) { + return SYSTEM_ERROR_INTERNAL; } - if (suffix) { - // suffix [endAddress] crc32 - endAddress = endAddress - sizeof(module_info_suffix_t); - ret = read(endAddress, (uint8_t*)suffix, sizeof(module_info_suffix_t)); + } + if (suffix) { + // suffix [endAddress] crc32 + endAddress = endAddress - sizeof(module_info_suffix_t); + if(!flash_read(flashDeviceID, endAddress, (uint8_t*)suffix, sizeof(module_info_suffix_t))) { + return SYSTEM_ERROR_INTERNAL; } } -done: - disable_rsip_if_enabled(enableRsip, is); - return ret; + return SYSTEM_ERROR_NONE; } uint32_t FLASH_ModuleAddress(uint8_t flashDeviceID, uint32_t startAddress) { @@ -838,12 +801,28 @@ bool FLASH_isUserModuleInfoValid(uint8_t flashDeviceID, uint32_t startAddress, u } bool FLASH_VerifyCRC32(uint8_t flashDeviceID, uint32_t startAddress, uint32_t length) { +#ifndef USE_SERIAL_FLASH + if (flashDeviceID == FLASH_SERIAL) { + return false; + } +#endif + if (flashDeviceID == FLASH_INTERNAL && length > 0) { - int is = 0; - bool enableRsip = enable_rsip_if_disabled(startAddress, &is); - uint32_t expectedCRC = __REV((*(__IO uint32_t*)(startAddress + length))); - uint32_t computedCRC = Compute_CRC32((uint8_t*)startAddress, length, NULL); - disable_rsip_if_enabled(enableRsip, is); + uint8_t internalFlashData[4]; + hal_flash_read((startAddress + length), internalFlashData, 4); + uint32_t expectedCRC = (uint32_t)(internalFlashData[3] | (internalFlashData[2] << 8) | (internalFlashData[1] << 16) | (internalFlashData[0] << 24)); + uint32_t endAddress = startAddress + length; + uint32_t len = 0; + uint32_t computedCRC = 0; + do { + len = endAddress - startAddress; + if (len > sizeof(internalFlashData)) { + len = sizeof(internalFlashData); + } + hal_flash_read(startAddress, internalFlashData, len); + computedCRC = Compute_CRC32(internalFlashData, len, &computedCRC); + startAddress += len; + } while (startAddress < endAddress); if (expectedCRC == computedCRC) { return true; } From db87c8420b82fed36ae4c638363c299e5056aed5 Mon Sep 17 00:00:00 2001 From: Eugene Date: Wed, 19 Oct 2022 20:52:31 +0800 Subject: [PATCH 060/112] [rtl872x] handle rsip region --- platform/MCU/rtl872x/src/flash_mal.c | 74 +++++++++++++++------------- 1 file changed, 39 insertions(+), 35 deletions(-) diff --git a/platform/MCU/rtl872x/src/flash_mal.c b/platform/MCU/rtl872x/src/flash_mal.c index 3af2ca4fd1..847fdc4606 100644 --- a/platform/MCU/rtl872x/src/flash_mal.c +++ b/platform/MCU/rtl872x/src/flash_mal.c @@ -32,6 +32,7 @@ #include "km0_km4_ipc.h" #include "interrupts_hal.h" #include "ota_flash_hal.h" +#include // Decompression of firmware modules is only supported in the bootloader #if (HAL_PLATFORM_COMPRESSED_OTA) && (MODULE_FUNCTION == MOD_FUNC_BOOTLOADER) @@ -98,6 +99,10 @@ bool enable_rsip_if_disabled(uint32_t address, int* is) { return false; } + if (!is_encrypted_region(address)) { + return false; + } + // Make the following operation atomic *is = HAL_disable_irq(); @@ -728,22 +733,29 @@ int FLASH_ModuleInfo(module_info_t* const infoOut, uint8_t flashDeviceID, uint32 } #endif CHECK_TRUE(infoOut, SYSTEM_ERROR_INVALID_ARGUMENT); - uint32_t offset = 0; + int is = 0; + bool enableRsip = enable_rsip_if_disabled(startAddress, &is); rtl_binary_header header = {}; if (!flash_read(flashDeviceID, startAddress, (uint8_t*)&header, sizeof(rtl_binary_header))) { - return SYSTEM_ERROR_INTERNAL; + goto error_return; } + uint32_t offset = 0; if (header.signature_high == RTL_HEADER_SIGNATURE_HIGH && header.signature_low == RTL_HEADER_SIGNATURE_LOW) { offset = sizeof(rtl_binary_header); } if (!flash_read(flashDeviceID, startAddress + offset, (uint8_t*)infoOut, sizeof(module_info_t))) { - return SYSTEM_ERROR_INTERNAL; + goto error_return; } if (infoOffset) { *infoOffset = offset; } + disable_rsip_if_enabled(enableRsip, is); return SYSTEM_ERROR_NONE; + +error_return: + disable_rsip_if_enabled(enableRsip, is); + return SYSTEM_ERROR_INTERNAL; } int FLASH_ModuleCrcSuffix(module_info_crc_t* crc, module_info_suffix_t* suffix, uint8_t flashDeviceID, uint32_t endAddress) { @@ -752,19 +764,26 @@ int FLASH_ModuleCrcSuffix(module_info_crc_t* crc, module_info_suffix_t* suffix, return SYSTEM_ERROR_NOT_SUPPORTED; } #endif + int is = 0; + bool enableRsip = enable_rsip_if_disabled(endAddress, &is); if (crc) { if(!flash_read(flashDeviceID, endAddress, (uint8_t*)crc, sizeof(module_info_crc_t))) { - return SYSTEM_ERROR_INTERNAL; + goto error_return; } } if (suffix) { // suffix [endAddress] crc32 endAddress = endAddress - sizeof(module_info_suffix_t); if(!flash_read(flashDeviceID, endAddress, (uint8_t*)suffix, sizeof(module_info_suffix_t))) { - return SYSTEM_ERROR_INTERNAL; + goto error_return; } } + disable_rsip_if_enabled(enableRsip, is); return SYSTEM_ERROR_NONE; + +error_return: + disable_rsip_if_enabled(enableRsip, is); + return SYSTEM_ERROR_INTERNAL; } uint32_t FLASH_ModuleAddress(uint8_t flashDeviceID, uint32_t startAddress) { @@ -807,48 +826,33 @@ bool FLASH_VerifyCRC32(uint8_t flashDeviceID, uint32_t startAddress, uint32_t le } #endif - if (flashDeviceID == FLASH_INTERNAL && length > 0) { - uint8_t internalFlashData[4]; - hal_flash_read((startAddress + length), internalFlashData, 4); - uint32_t expectedCRC = (uint32_t)(internalFlashData[3] | (internalFlashData[2] << 8) | (internalFlashData[1] << 16) | (internalFlashData[0] << 24)); - uint32_t endAddress = startAddress + length; - uint32_t len = 0; - uint32_t computedCRC = 0; - do { - len = endAddress - startAddress; - if (len > sizeof(internalFlashData)) { - len = sizeof(internalFlashData); - } - hal_flash_read(startAddress, internalFlashData, len); - computedCRC = Compute_CRC32(internalFlashData, len, &computedCRC); - startAddress += len; - } while (startAddress < endAddress); - if (expectedCRC == computedCRC) { - return true; + if ((flashDeviceID == FLASH_INTERNAL && length > 0) || (flashDeviceID == FLASH_SERIAL && length > 0)) { + const int dataBufferSize = 256; + uint8_t* dataBuffer = malloc(dataBufferSize); + if (dataBuffer == NULL) { + return false; } - } else if (flashDeviceID == FLASH_SERIAL && length > 0) { -#ifdef USE_SERIAL_FLASH - uint8_t serialFlashData[4]; // FIXME: Use XIP or a larger buffer - hal_exflash_read((startAddress + length), serialFlashData, 4); - uint32_t expectedCRC = (uint32_t)(serialFlashData[3] | (serialFlashData[2] << 8) | (serialFlashData[1] << 16) | (serialFlashData[0] << 24)); + int is = 0; + bool enableRsip = enable_rsip_if_disabled(startAddress, &is); + flash_read(flashDeviceID, (startAddress + length), dataBuffer, 4); + uint32_t expectedCRC = (uint32_t)(dataBuffer[3] | (dataBuffer[2] << 8) | (dataBuffer[1] << 16) | (dataBuffer[0] << 24)); uint32_t endAddress = startAddress + length; uint32_t len = 0; uint32_t computedCRC = 0; do { len = endAddress - startAddress; - if (len > sizeof(serialFlashData)) { - len = sizeof(serialFlashData); + if (len > dataBufferSize) { + len = dataBufferSize; } - hal_exflash_read(startAddress, serialFlashData, len); - computedCRC = Compute_CRC32(serialFlashData, len, &computedCRC); + flash_read(flashDeviceID, startAddress, dataBuffer, len); + computedCRC = Compute_CRC32(dataBuffer, len, &computedCRC); startAddress += len; } while (startAddress < endAddress); + disable_rsip_if_enabled(enableRsip, is); + free(dataBuffer); if (expectedCRC == computedCRC) { return true; } -#else - return false; -#endif } else if (flashDeviceID == FLASH_ADDRESS && length > 0) { uint32_t expectedCRC = __REV((*(__IO uint32_t*)(startAddress + length))); uint32_t computedCRC = Compute_CRC32((uint8_t*)startAddress, length, NULL); From d5c00a064a4291fde62e688084490a0247b2bb5b Mon Sep 17 00:00:00 2001 From: Eugene Date: Wed, 19 Oct 2022 22:59:28 +0800 Subject: [PATCH 061/112] [rtl872x] disable XIP at boot and enable it when necessary --- hal/src/rtl872x/exflash_hal.cpp | 78 +++++++++++++++++----------- platform/MCU/rtl872x/src/hw_config.c | 8 +-- 2 files changed, 52 insertions(+), 34 deletions(-) diff --git a/hal/src/rtl872x/exflash_hal.cpp b/hal/src/rtl872x/exflash_hal.cpp index 42fe0380b9..730ab6afda 100644 --- a/hal/src/rtl872x/exflash_hal.cpp +++ b/hal/src/rtl872x/exflash_hal.cpp @@ -41,6 +41,9 @@ extern "C" { extern uintptr_t platform_system_part1_flash_start; extern uintptr_t platform_flash_end; +static char gMpuEntry = -1; +static void enable_xip(bool enable); + #if HAL_PLATFORM_FLASH_MX25R6435FZNIL0 typedef enum { MXIC_FLASH_CMD_ENSO = 0xB1, @@ -109,6 +112,18 @@ class ExFlashLock { bool threading_; }; +// We are safe to run the constructor/destructor, cos they are copied to PSRAM to run. +class EnableXip { +public: + EnableXip() { + enable_xip(true); + } + + ~EnableXip() { + enable_xip(false); + } +}; + static bool is_block_erased(uintptr_t addr, size_t size); __attribute__((section(".ram.text"), noinline)) @@ -125,11 +140,40 @@ static int perform_write(uintptr_t addr, const uint8_t* data, size_t size) { return SYSTEM_ERROR_NONE; } +static void enable_xip(bool enable) { + if (-1 < gMpuEntry && gMpuEntry < MPU_MAX_REGION) { + mpu_entry_free(gMpuEntry); + } + gMpuEntry = mpu_entry_alloc(); + SPARK_ASSERT(-1 < gMpuEntry && gMpuEntry < MPU_MAX_REGION); + + mpu_region_config mpu_cfg = {}; + mpu_cfg.region_base = (uintptr_t)&platform_system_part1_flash_start; + mpu_cfg.region_size = (uintptr_t)&platform_flash_end - (uintptr_t)&platform_system_part1_flash_start; // System part1, OTA region, user part and filesystem + if (enable) { + mpu_cfg.xn = MPU_EXEC_ALLOW; + mpu_cfg.ap = MPU_UN_PRIV_RW; + mpu_cfg.sh = MPU_NON_SHAREABLE; + mpu_cfg.attr_idx = MPU_MEM_ATTR_IDX_WB_T_RWA; + } else { + mpu_cfg.xn = MPU_EXEC_NEVER; + mpu_cfg.ap = MPU_PRIV_R; + mpu_cfg.sh = MPU_NON_SHAREABLE; + mpu_cfg.attr_idx = MPU_MEM_ATTR_IDX_NC; + } + mpu_region_cfg(gMpuEntry, &mpu_cfg); +} + int hal_exflash_init(void) { + enable_xip(false); return SYSTEM_ERROR_NONE; } int hal_exflash_uninit(void) { + if (-1 < gMpuEntry && gMpuEntry < MPU_MAX_REGION) { + mpu_entry_free(gMpuEntry); + gMpuEntry = -1; + } return SYSTEM_ERROR_NONE; } @@ -137,13 +181,13 @@ __attribute__((section(".ram.text"), noinline)) int hal_exflash_write(uintptr_t addr, const uint8_t* data_buf, size_t data_size) { ExFlashLock lk; CHECK(hal_flash_common_write(addr, data_buf, data_size, &perform_write, &hal_flash_common_dummy_read)); - DCache_CleanInvalidate(SPI_FLASH_BASE + addr, data_size); return SYSTEM_ERROR_NONE; } __attribute__((section(".ram.text"), noinline)) int hal_exflash_read(uintptr_t addr, uint8_t* data_buf, size_t data_size) { ExFlashLock lk; + EnableXip xiplk; addr += SPI_FLASH_BASE; memcpy(data_buf, (void*)addr, data_size); return SYSTEM_ERROR_NONE; @@ -151,6 +195,8 @@ int hal_exflash_read(uintptr_t addr, uint8_t* data_buf, size_t data_size) { __attribute__((section(".ram.text"), noinline)) static bool is_block_erased(uintptr_t addr, size_t size) { + ExFlashLock lk; + EnableXip xiplk; uint8_t* ptr = (uint8_t*)(SPI_FLASH_BASE + addr); for (size_t i = 0; i < size; i++) { if (ptr[i] != 0xff) { @@ -177,7 +223,6 @@ static int erase_common(uintptr_t start_addr, size_t num_blocks, int len) { // LOG_DEBUG(ERROR, "Erased %lu %lukB blocks starting from %" PRIxPTR, // num_blocks, block_length / 1024, start_addr); - DCache_CleanInvalidate(SPI_FLASH_BASE + start_addr, block_length * num_blocks); return SYSTEM_ERROR_NONE; } @@ -240,31 +285,6 @@ static bool isSecureOtpMode(uint32_t normalContent) { #endif // MODULE_FUNCTION != MOD_FUNC_BOOTLOADER -// We are safe to run the constructor/destructor, cos they are copied to PSRAM to run. -class ProhibitXip { -public: - ProhibitXip() - : mpuCfg_{}, - mpuEntry_(0) { - mpuEntry_ = mpu_entry_alloc(); - SPARK_ASSERT(mpuEntry_ < MPU_MAX_REGION); - mpuCfg_.region_base = (uintptr_t)&platform_system_part1_flash_start; - mpuCfg_.region_size = (uintptr_t)&platform_flash_end - (uintptr_t)&platform_system_part1_flash_start; // System part1, OTA region, user part and filesystem - mpuCfg_.xn = MPU_EXEC_NEVER; - mpuCfg_.ap = MPU_PRIV_R; - mpuCfg_.sh = MPU_NON_SHAREABLE; - mpuCfg_.attr_idx = MPU_MEM_ATTR_IDX_NC; - mpu_region_cfg(mpuEntry_, &mpuCfg_); - } - - ~ProhibitXip() { - mpu_entry_free(mpuEntry_); - } -private: - mpu_region_config mpuCfg_; - uint32_t mpuEntry_; -}; - #if MODULE_FUNCTION != MOD_FUNC_BOOTLOADER __attribute__((section(".ram.text"), noinline)) @@ -278,8 +298,6 @@ int hal_exflash_read_special(hal_exflash_special_sector_t sp, uintptr_t addr, ui uint32_t normalContent = 0; FLASH_RxData(0, (uint32_t)0, sizeof(normalContent), (uint8_t*)&normalContent); { - ProhibitXip lk; - SCOPE_GUARD({ // Just in case, even if it might have failed to enter the secure OTP mode. FLASH_TxCmd(MXIC_FLASH_CMD_EXSO, 0, nullptr); @@ -309,8 +327,6 @@ int hal_exflash_write_special(hal_exflash_special_sector_t sp, uintptr_t addr, c uint32_t normalContent = 0; FLASH_RxData(0, (uint32_t)0, sizeof(normalContent), (uint8_t*)&normalContent); { - ProhibitXip lk; - SCOPE_GUARD({ // Just in case, even if it might have failed to enter the secure OTP mode. FLASH_TxCmd(MXIC_FLASH_CMD_EXSO, 0, nullptr); diff --git a/platform/MCU/rtl872x/src/hw_config.c b/platform/MCU/rtl872x/src/hw_config.c index 8658f6a886..61353f10df 100644 --- a/platform/MCU/rtl872x/src/hw_config.c +++ b/platform/MCU/rtl872x/src/hw_config.c @@ -288,9 +288,9 @@ void Set_System(void) SystemCoreClockUpdate(); // force SP align to 8 byte not 4 byte (initial SP is 4 byte align) - // asm volatile( + // asm volatile( // "mov r0, sp\n" - // "bic r0, r0, #7\n" + // "bic r0, r0, #7\n" // "mov sp, r0\n" // ); @@ -305,6 +305,9 @@ void Set_System(void) DWT_Init(); + // Enable MPU + mpu_init(); + /* Configure flash */ SPARK_ASSERT(!hal_exflash_init()); @@ -339,7 +342,6 @@ void Set_System(void) Cache_Enable(0); // Enable MPU and configure the nocache region - mpu_init(); app_mpu_nocache_init(); // Enable cache From 1977b5736de02944f2b00dc9467f73ba3abc2658 Mon Sep 17 00:00:00 2001 From: Eugene Date: Fri, 21 Oct 2022 09:39:24 +0800 Subject: [PATCH 062/112] [rtl872x] malloc may be not available at boot, use local buffer instead --- platform/MCU/rtl872x/src/flash_mal.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/platform/MCU/rtl872x/src/flash_mal.c b/platform/MCU/rtl872x/src/flash_mal.c index 847fdc4606..b7650688da 100644 --- a/platform/MCU/rtl872x/src/flash_mal.c +++ b/platform/MCU/rtl872x/src/flash_mal.c @@ -828,7 +828,7 @@ bool FLASH_VerifyCRC32(uint8_t flashDeviceID, uint32_t startAddress, uint32_t le if ((flashDeviceID == FLASH_INTERNAL && length > 0) || (flashDeviceID == FLASH_SERIAL && length > 0)) { const int dataBufferSize = 256; - uint8_t* dataBuffer = malloc(dataBufferSize); + uint8_t dataBuffer[dataBufferSize]; if (dataBuffer == NULL) { return false; } @@ -849,7 +849,6 @@ bool FLASH_VerifyCRC32(uint8_t flashDeviceID, uint32_t startAddress, uint32_t le startAddress += len; } while (startAddress < endAddress); disable_rsip_if_enabled(enableRsip, is); - free(dataBuffer); if (expectedCRC == computedCRC) { return true; } From 438438ab070f8110b1ea2108164ffe6be2deafde Mon Sep 17 00:00:00 2001 From: Eugene Date: Fri, 21 Oct 2022 09:40:50 +0800 Subject: [PATCH 063/112] [rtl872x] fixes checkname --- dynalib/inc/dynalib.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dynalib/inc/dynalib.h b/dynalib/inc/dynalib.h index 7380c9d7ad..671da4d454 100644 --- a/dynalib/inc/dynalib.h +++ b/dynalib/inc/dynalib.h @@ -128,7 +128,7 @@ constexpr T2* dynalib_checked_cast(T2 *p) { #if PLATFORM_ID == 32 || PLATFORM_ID == 28 #define DYNALIB_FN_IMPORT(index, tablename, name, counter) \ DYNALIB_STATIC_ASSERT(index == counter, "Index of the dynamically exported function has changed"); \ - const char check_name_##tablename_##name[0]={}; /* this will fail if the name is already defined */ \ + const char check_name_## tablename ## _ ## name[0]={}; /* this will fail if the name is already defined */ \ void name() __attribute__((naked)); \ void name() { \ asm volatile ( \ From 88acf80f81559fa08cfcccbd961d5c8f45c3e59e Mon Sep 17 00:00:00 2001 From: Eugene Date: Fri, 21 Oct 2022 09:45:42 +0800 Subject: [PATCH 064/112] [rtl872x] disable XIP after user module pre_init --- hal/src/rtl872x/core_hal.c | 20 +++++++++++++------- hal/src/rtl872x/exflash_hal.cpp | 27 +++++++++++++++++++-------- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/hal/src/rtl872x/core_hal.c b/hal/src/rtl872x/core_hal.c index ee2bf5dc24..a315cd7003 100644 --- a/hal/src/rtl872x/core_hal.c +++ b/hal/src/rtl872x/core_hal.c @@ -80,6 +80,8 @@ extern uintptr_t platform_system_backup_ram_start; extern uintptr_t link_heap_location, link_heap_location_end; extern uintptr_t link_heap_location_alt, link_heap_location_end_alt; +extern int hal_exflash_disable_xip(void); + static malloc_heap_region heap_regions[HEAP_REGIONS] = { [HEAP_REGION_PSRAM] = { // PSRAM @@ -138,19 +140,19 @@ __attribute__((externally_visible)) void prvGetRegistersFromStack(uint32_t *pulF switch (panicCode) { case HardFault: { PANIC(panicCode, "HardFault"); - break; + break; } case MemManage: { PANIC(panicCode, "MemManage"); - break; + break; } case BusFault: { PANIC(panicCode, "BusFault"); - break; + break; } case UsageFault: { PANIC(panicCode, "UsageFault"); - break; + break; } default: { // Shouldn't enter this case @@ -282,7 +284,7 @@ static void prohibit_xip(void) { sd_nvic_critical_region_exit(st); - // Use a DSB followed by an ISB instruction to ensure that the new MPU configuration is used by subsequent instructions. + // Use a DSB followed by an ISB instruction to ensure that the new MPU configuration is used by subsequent instructions. __DSB(); __ISB(); @@ -317,7 +319,7 @@ void HAL_Core_Config(void) { #if HAL_PLATFORM_PROHIBIT_XIP prohibit_xip(); #endif - + Set_System(); hal_timer_init(NULL); @@ -379,6 +381,10 @@ void HAL_Core_Config(void) { } } #endif + + // Disable XIP after user module pre_init + hal_exflash_disable_xip(); + malloc_set_heap_regions(heap_regions, HEAP_REGIONS); // Enable malloc before littlefs initialization. @@ -701,7 +707,7 @@ void __malloc_unlock(struct _reent *ptr) { */ void application_start() { rtos_started = 1; - + // one the key is sent to the cloud, this can be removed, since the key is fetched in // Spark_Protocol_init(). This is just a temporary measure while the key still needs // to be fetched via DFU. diff --git a/hal/src/rtl872x/exflash_hal.cpp b/hal/src/rtl872x/exflash_hal.cpp index 730ab6afda..9f8683908e 100644 --- a/hal/src/rtl872x/exflash_hal.cpp +++ b/hal/src/rtl872x/exflash_hal.cpp @@ -41,7 +41,8 @@ extern "C" { extern uintptr_t platform_system_part1_flash_start; extern uintptr_t platform_flash_end; -static char gMpuEntry = -1; +static bool gXipControl = false; +static signed char gMpuEntry = -1; static void enable_xip(bool enable); #if HAL_PLATFORM_FLASH_MX25R6435FZNIL0 @@ -116,11 +117,15 @@ class ExFlashLock { class EnableXip { public: EnableXip() { - enable_xip(true); + if (gXipControl) { + enable_xip(true); + } } ~EnableXip() { - enable_xip(false); + if (gXipControl) { + enable_xip(false); + } } }; @@ -165,15 +170,10 @@ static void enable_xip(bool enable) { } int hal_exflash_init(void) { - enable_xip(false); return SYSTEM_ERROR_NONE; } int hal_exflash_uninit(void) { - if (-1 < gMpuEntry && gMpuEntry < MPU_MAX_REGION) { - mpu_entry_free(gMpuEntry); - gMpuEntry = -1; - } return SYSTEM_ERROR_NONE; } @@ -181,6 +181,7 @@ __attribute__((section(".ram.text"), noinline)) int hal_exflash_write(uintptr_t addr, const uint8_t* data_buf, size_t data_size) { ExFlashLock lk; CHECK(hal_flash_common_write(addr, data_buf, data_size, &perform_write, &hal_flash_common_dummy_read)); + DCache_CleanInvalidate(SPI_FLASH_BASE + addr, data_size); return SYSTEM_ERROR_NONE; } @@ -190,6 +191,7 @@ int hal_exflash_read(uintptr_t addr, uint8_t* data_buf, size_t data_size) { EnableXip xiplk; addr += SPI_FLASH_BASE; memcpy(data_buf, (void*)addr, data_size); + DCache_CleanInvalidate((uint32_t)data_buf, data_size); return SYSTEM_ERROR_NONE; } @@ -224,6 +226,8 @@ static int erase_common(uintptr_t start_addr, size_t num_blocks, int len) { // LOG_DEBUG(ERROR, "Erased %lu %lukB blocks starting from %" PRIxPTR, // num_blocks, block_length / 1024, start_addr); + DCache_CleanInvalidate(SPI_FLASH_BASE + start_addr, block_length * num_blocks); + return SYSTEM_ERROR_NONE; } @@ -398,3 +402,10 @@ int hal_exflash_sleep(bool sleep, void* reserved) { // Note: HAL sleep driver uses SDK API to suspend external flash. return SYSTEM_ERROR_NONE; } + +extern "C" int hal_exflash_disable_xip(void) { + ExFlashLock lk; + enable_xip(false); + gXipControl = true; + return SYSTEM_ERROR_NONE; +} From b70226c80036d48f834eb94264aaee0c17ba747a Mon Sep 17 00:00:00 2001 From: Eugene Date: Fri, 21 Oct 2022 10:52:36 +0800 Subject: [PATCH 065/112] [rtl872x] disable XIP control in the bootloader --- hal/src/rtl872x/exflash_hal.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hal/src/rtl872x/exflash_hal.cpp b/hal/src/rtl872x/exflash_hal.cpp index 9f8683908e..6c841a6a7e 100644 --- a/hal/src/rtl872x/exflash_hal.cpp +++ b/hal/src/rtl872x/exflash_hal.cpp @@ -146,6 +146,8 @@ static int perform_write(uintptr_t addr, const uint8_t* data, size_t size) { } static void enable_xip(bool enable) { + (void)gMpuEntry; +#if MODULE_FUNCTION != MOD_FUNC_BOOTLOADER if (-1 < gMpuEntry && gMpuEntry < MPU_MAX_REGION) { mpu_entry_free(gMpuEntry); } @@ -167,6 +169,7 @@ static void enable_xip(bool enable) { mpu_cfg.attr_idx = MPU_MEM_ATTR_IDX_NC; } mpu_region_cfg(gMpuEntry, &mpu_cfg); +#endif // MODULE_FUNCTION != MOD_FUNC_BOOTLOADER } int hal_exflash_init(void) { @@ -403,9 +406,11 @@ int hal_exflash_sleep(bool sleep, void* reserved) { return SYSTEM_ERROR_NONE; } +#if MODULE_FUNCTION != MOD_FUNC_BOOTLOADER extern "C" int hal_exflash_disable_xip(void) { ExFlashLock lk; enable_xip(false); gXipControl = true; return SYSTEM_ERROR_NONE; } +#endif // MODULE_FUNCTION != MOD_FUNC_BOOTLOADER From 576102e578694d5f8a92d763aa887f363d02fa60 Mon Sep 17 00:00:00 2001 From: Eugene Date: Mon, 24 Oct 2022 10:20:33 +0800 Subject: [PATCH 066/112] [rtl872x] rework XIP control --- hal/src/rtl872x/exflash_hal.cpp | 92 ++++++++++++++++++--------------- 1 file changed, 50 insertions(+), 42 deletions(-) diff --git a/hal/src/rtl872x/exflash_hal.cpp b/hal/src/rtl872x/exflash_hal.cpp index 6c841a6a7e..1785aeb7b1 100644 --- a/hal/src/rtl872x/exflash_hal.cpp +++ b/hal/src/rtl872x/exflash_hal.cpp @@ -41,10 +41,6 @@ extern "C" { extern uintptr_t platform_system_part1_flash_start; extern uintptr_t platform_flash_end; -static bool gXipControl = false; -static signed char gMpuEntry = -1; -static void enable_xip(bool enable); - #if HAL_PLATFORM_FLASH_MX25R6435FZNIL0 typedef enum { MXIC_FLASH_CMD_ENSO = 0xB1, @@ -114,20 +110,60 @@ class ExFlashLock { }; // We are safe to run the constructor/destructor, cos they are copied to PSRAM to run. -class EnableXip { +class XipControl { public: - EnableXip() { - if (gXipControl) { - enable_xip(true); + XipControl() { + if (controlled_) { + enableXip(true); } } - ~EnableXip() { - if (gXipControl) { - enable_xip(false); + ~XipControl() { + if (controlled_) { + enableXip(false); } } + + static int initXipOff() { + enableXip(false); + controlled_ = true; + return 0; + } + +private: + static void enableXip(bool enable) { + (void)mpuEntry_; +#if MODULE_FUNCTION != MOD_FUNC_BOOTLOADER + if (-1 < mpuEntry_ && mpuEntry_ < MPU_MAX_REGION) { + mpu_entry_free(mpuEntry_); + } + mpuEntry_ = mpu_entry_alloc(); + SPARK_ASSERT(-1 < mpuEntry_ && mpuEntry_ < MPU_MAX_REGION); + + mpu_region_config mpu_cfg = {}; + mpu_cfg.region_base = (uintptr_t)&platform_system_part1_flash_start; + mpu_cfg.region_size = (uintptr_t)&platform_flash_end - (uintptr_t)&platform_system_part1_flash_start; // System part1, OTA region, user part and filesystem + if (enable) { + mpu_cfg.xn = MPU_EXEC_ALLOW; + mpu_cfg.ap = MPU_UN_PRIV_RW; + mpu_cfg.sh = MPU_NON_SHAREABLE; + mpu_cfg.attr_idx = MPU_MEM_ATTR_IDX_WB_T_RWA; + } else { + mpu_cfg.xn = MPU_EXEC_NEVER; + mpu_cfg.ap = MPU_PRIV_R; + mpu_cfg.sh = MPU_NON_SHAREABLE; + mpu_cfg.attr_idx = MPU_MEM_ATTR_IDX_NC; + } + mpu_region_cfg(mpuEntry_, &mpu_cfg); +#endif // MODULE_FUNCTION != MOD_FUNC_BOOTLOADER + } + +private: + static bool controlled_; + static signed char mpuEntry_; }; +bool XipControl::controlled_ = false; +signed char XipControl::mpuEntry_ = -1; static bool is_block_erased(uintptr_t addr, size_t size); @@ -145,33 +181,6 @@ static int perform_write(uintptr_t addr, const uint8_t* data, size_t size) { return SYSTEM_ERROR_NONE; } -static void enable_xip(bool enable) { - (void)gMpuEntry; -#if MODULE_FUNCTION != MOD_FUNC_BOOTLOADER - if (-1 < gMpuEntry && gMpuEntry < MPU_MAX_REGION) { - mpu_entry_free(gMpuEntry); - } - gMpuEntry = mpu_entry_alloc(); - SPARK_ASSERT(-1 < gMpuEntry && gMpuEntry < MPU_MAX_REGION); - - mpu_region_config mpu_cfg = {}; - mpu_cfg.region_base = (uintptr_t)&platform_system_part1_flash_start; - mpu_cfg.region_size = (uintptr_t)&platform_flash_end - (uintptr_t)&platform_system_part1_flash_start; // System part1, OTA region, user part and filesystem - if (enable) { - mpu_cfg.xn = MPU_EXEC_ALLOW; - mpu_cfg.ap = MPU_UN_PRIV_RW; - mpu_cfg.sh = MPU_NON_SHAREABLE; - mpu_cfg.attr_idx = MPU_MEM_ATTR_IDX_WB_T_RWA; - } else { - mpu_cfg.xn = MPU_EXEC_NEVER; - mpu_cfg.ap = MPU_PRIV_R; - mpu_cfg.sh = MPU_NON_SHAREABLE; - mpu_cfg.attr_idx = MPU_MEM_ATTR_IDX_NC; - } - mpu_region_cfg(gMpuEntry, &mpu_cfg); -#endif // MODULE_FUNCTION != MOD_FUNC_BOOTLOADER -} - int hal_exflash_init(void) { return SYSTEM_ERROR_NONE; } @@ -191,7 +200,7 @@ int hal_exflash_write(uintptr_t addr, const uint8_t* data_buf, size_t data_size) __attribute__((section(".ram.text"), noinline)) int hal_exflash_read(uintptr_t addr, uint8_t* data_buf, size_t data_size) { ExFlashLock lk; - EnableXip xiplk; + XipControl xiplk; addr += SPI_FLASH_BASE; memcpy(data_buf, (void*)addr, data_size); DCache_CleanInvalidate((uint32_t)data_buf, data_size); @@ -201,7 +210,7 @@ int hal_exflash_read(uintptr_t addr, uint8_t* data_buf, size_t data_size) { __attribute__((section(".ram.text"), noinline)) static bool is_block_erased(uintptr_t addr, size_t size) { ExFlashLock lk; - EnableXip xiplk; + XipControl xiplk; uint8_t* ptr = (uint8_t*)(SPI_FLASH_BASE + addr); for (size_t i = 0; i < size; i++) { if (ptr[i] != 0xff) { @@ -409,8 +418,7 @@ int hal_exflash_sleep(bool sleep, void* reserved) { #if MODULE_FUNCTION != MOD_FUNC_BOOTLOADER extern "C" int hal_exflash_disable_xip(void) { ExFlashLock lk; - enable_xip(false); - gXipControl = true; + XipControl::initXipOff(); return SYSTEM_ERROR_NONE; } #endif // MODULE_FUNCTION != MOD_FUNC_BOOTLOADER From 2009a9eeb20c9d325809cc08b3c7223cb8535d08 Mon Sep 17 00:00:00 2001 From: Eugene Date: Mon, 24 Oct 2022 10:38:36 +0800 Subject: [PATCH 067/112] [rtl872x] Remove unnecessary DCache clean/invalidate --- hal/src/rtl872x/exflash_hal.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/hal/src/rtl872x/exflash_hal.cpp b/hal/src/rtl872x/exflash_hal.cpp index 1785aeb7b1..81ba1b92e0 100644 --- a/hal/src/rtl872x/exflash_hal.cpp +++ b/hal/src/rtl872x/exflash_hal.cpp @@ -203,7 +203,6 @@ int hal_exflash_read(uintptr_t addr, uint8_t* data_buf, size_t data_size) { XipControl xiplk; addr += SPI_FLASH_BASE; memcpy(data_buf, (void*)addr, data_size); - DCache_CleanInvalidate((uint32_t)data_buf, data_size); return SYSTEM_ERROR_NONE; } From 7c98243421d88abf6415bce56b79b48103780ccf Mon Sep 17 00:00:00 2001 From: Eugene Date: Mon, 24 Oct 2022 14:41:25 +0800 Subject: [PATCH 068/112] [rtl872x] minor fixes --- platform/MCU/rtl872x/src/flash_mal.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/platform/MCU/rtl872x/src/flash_mal.c b/platform/MCU/rtl872x/src/flash_mal.c index b7650688da..dcc4e39456 100644 --- a/platform/MCU/rtl872x/src/flash_mal.c +++ b/platform/MCU/rtl872x/src/flash_mal.c @@ -69,16 +69,12 @@ bool is_encrypted_region(uint32_t address) { EFUSE_PMAP_READ8(0, USER_KEY_0_EFUSE_ADDRESS, &userEfuse0, L25EOUTVOLTAGE); bool part1_encryption_enabled = !(userEfuse0 & PART1_ENCRYPTED_BIT); - if (part1_encryption_enabled) { - if (!(address >= KM0_MBR_START_ADDRESS && address < (KM0_MBR_START_ADDRESS + KM0_MBR_IMAGE_SIZE)) /* MBR */ - && !(address >= KM0_PART1_START_ADDRESS && address < (KM0_PART1_START_ADDRESS + KM0_PART1_IMAGE_SIZE)) /* part1 */) { - return false; - } - } else { - if (!(address >= KM0_MBR_START_ADDRESS && address < (KM0_MBR_START_ADDRESS + KM0_MBR_IMAGE_SIZE)) /* MBR */) { - return false; - } + if (address >= KM0_MBR_START_ADDRESS && address < (KM0_MBR_START_ADDRESS + KM0_MBR_IMAGE_SIZE) /* MBR */) { + return false; + } else if (part1_encryption_enabled && (address >= KM0_PART1_START_ADDRESS && address < (KM0_PART1_START_ADDRESS + KM0_PART1_IMAGE_SIZE)) /* part1 */) { + return false; } + return true; } @@ -729,7 +725,7 @@ int FLASH_UpdateModules(void (*flashModulesCallback)(bool isUpdating)) { int FLASH_ModuleInfo(module_info_t* const infoOut, uint8_t flashDeviceID, uint32_t startAddress, uint32_t* infoOffset) { #ifndef USE_SERIAL_FLASH if (flashDeviceID == FLASH_SERIAL) { - return false; + return SYSTEM_ERROR_NOT_SUPPORTED; } #endif CHECK_TRUE(infoOut, SYSTEM_ERROR_INVALID_ARGUMENT); From a150a61cb282f9cf137203f5a5abc66038e233fb Mon Sep 17 00:00:00 2001 From: Eugene Date: Thu, 27 Oct 2022 11:47:00 +0800 Subject: [PATCH 069/112] [rtl872x] minor, fixes return value --- platform/MCU/rtl872x/src/flash_mal.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/platform/MCU/rtl872x/src/flash_mal.c b/platform/MCU/rtl872x/src/flash_mal.c index dcc4e39456..60063f0d54 100644 --- a/platform/MCU/rtl872x/src/flash_mal.c +++ b/platform/MCU/rtl872x/src/flash_mal.c @@ -70,12 +70,12 @@ bool is_encrypted_region(uint32_t address) { bool part1_encryption_enabled = !(userEfuse0 & PART1_ENCRYPTED_BIT); if (address >= KM0_MBR_START_ADDRESS && address < (KM0_MBR_START_ADDRESS + KM0_MBR_IMAGE_SIZE) /* MBR */) { - return false; + return true; } else if (part1_encryption_enabled && (address >= KM0_PART1_START_ADDRESS && address < (KM0_PART1_START_ADDRESS + KM0_PART1_IMAGE_SIZE)) /* part1 */) { - return false; + return true; } - return true; + return false; } /* WARNING: enable_rsip_if_disabled() and disable_rsip_if_enabled() must be used in pair. From 19b35f7d443665b62aae9dbde3de7546c4aa674e Mon Sep 17 00:00:00 2001 From: Eugene Date: Thu, 24 Nov 2022 10:46:36 +0800 Subject: [PATCH 070/112] [rtl872x] hal: remove unnecessary DCache API --- hal/src/rtl872x/exflash_hal.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/hal/src/rtl872x/exflash_hal.cpp b/hal/src/rtl872x/exflash_hal.cpp index 81ba1b92e0..0a8f4d8af1 100644 --- a/hal/src/rtl872x/exflash_hal.cpp +++ b/hal/src/rtl872x/exflash_hal.cpp @@ -193,7 +193,6 @@ __attribute__((section(".ram.text"), noinline)) int hal_exflash_write(uintptr_t addr, const uint8_t* data_buf, size_t data_size) { ExFlashLock lk; CHECK(hal_flash_common_write(addr, data_buf, data_size, &perform_write, &hal_flash_common_dummy_read)); - DCache_CleanInvalidate(SPI_FLASH_BASE + addr, data_size); return SYSTEM_ERROR_NONE; } @@ -237,8 +236,6 @@ static int erase_common(uintptr_t start_addr, size_t num_blocks, int len) { // LOG_DEBUG(ERROR, "Erased %lu %lukB blocks starting from %" PRIxPTR, // num_blocks, block_length / 1024, start_addr); - DCache_CleanInvalidate(SPI_FLASH_BASE + start_addr, block_length * num_blocks); - return SYSTEM_ERROR_NONE; } From 1ab4e747a7d18ba1e6a838783619366efb3d825c Mon Sep 17 00:00:00 2001 From: XuGuohui Date: Mon, 31 Oct 2022 15:06:14 +0800 Subject: [PATCH 071/112] [rtl872x] hal: fix the issue that P2 may leak current under some circumstances --- hal/src/rtl872x/sleep_hal.cpp | 2 +- hal/src/rtl872x/usart_hal.cpp | 18 ++++++++++++++---- system/src/system_sleep.cpp | 5 ----- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/hal/src/rtl872x/sleep_hal.cpp b/hal/src/rtl872x/sleep_hal.cpp index dcb63f9e18..02e1fa3b30 100644 --- a/hal/src/rtl872x/sleep_hal.cpp +++ b/hal/src/rtl872x/sleep_hal.cpp @@ -102,7 +102,7 @@ class SleepClass { hal_ble_gap_is_connected(nullptr, nullptr); hal_ble_stack_deinit(nullptr); // The delay is essential to make sure the resources are successfully freed. - DelayMs(1500); + DelayMs(2000); HAL_USB_Detach(); diff --git a/hal/src/rtl872x/usart_hal.cpp b/hal/src/rtl872x/usart_hal.cpp index f30b67713d..8aa3df9b98 100644 --- a/hal/src/rtl872x/usart_hal.cpp +++ b/hal/src/rtl872x/usart_hal.cpp @@ -310,6 +310,7 @@ class Usart { } ssize_t write(const uint8_t* buffer, size_t size) { + CHECK_TRUE(isEnabled(), SYSTEM_ERROR_INVALID_STATE); CHECK_TRUE(buffer, SYSTEM_ERROR_INVALID_ARGUMENT); const ssize_t canWrite = CHECK(space()); const size_t writeSize = std::min((size_t)canWrite, size); @@ -326,15 +327,18 @@ class Usart { } ssize_t flush() { - startTransmission(); + CHECK_TRUE(isEnabled(), SYSTEM_ERROR_INVALID_STATE); while (true) { + while (transmitting_) { + HAL_Delay_Milliseconds(5); + // FIXME: busy loop + } { - TxLock lk(this); + AtomicBlock atomic(this); if (!isEnabled() || txBuffer_.empty()) { break; } } - CHECK(pollStatus()); } return 0; } @@ -415,6 +419,7 @@ class Usart { } int pollStatus() { + CHECK_TRUE(isEnabled(), SYSTEM_ERROR_INVALID_STATE); if (!useInterrupt()) { TxLock lk(this); uartTxDmaCompleteHandler(this); @@ -430,6 +435,7 @@ class Usart { } int enableEvent(HAL_USART_Pvt_Events event) { + CHECK_TRUE(isEnabled(), SYSTEM_ERROR_INVALID_STATE); CHECK_FALSE(useInterrupt(), SYSTEM_ERROR_NOT_SUPPORTED); auto uartInstance = uartTable_[index_].UARTx; @@ -464,6 +470,7 @@ class Usart { } int disableEvent(HAL_USART_Pvt_Events event) { + CHECK_TRUE(isEnabled(), SYSTEM_ERROR_INVALID_STATE); CHECK_FALSE(useInterrupt(), SYSTEM_ERROR_NOT_SUPPORTED); auto uartInstance = uartTable_[index_].UARTx; @@ -1057,7 +1064,10 @@ uint32_t hal_usart_write_nine_bits(hal_usart_interface_t serial, uint16_t data) uint32_t hal_usart_write(hal_usart_interface_t serial, uint8_t data) { auto usart = CHECK_TRUE_RETURN(Usart::getInstance(serial), SYSTEM_ERROR_NOT_FOUND); // Blocking! - while (usart->space() <= 0) { + if (!usart->isEnabled()) { + return 0; + } + while (usart->isEnabled() && usart->space() <= 0) { CHECK_RETURN(usart->pollStatus(), 0); } return CHECK_RETURN(usart->write(&data, sizeof(data)), 0); diff --git a/system/src/system_sleep.cpp b/system/src/system_sleep.cpp index 364f2d1458..fb08735b65 100644 --- a/system/src/system_sleep.cpp +++ b/system/src/system_sleep.cpp @@ -80,15 +80,10 @@ network_status_t system_sleep_network_suspend(network_interface_index index) { } } #endif -#if HAL_PLATFORM_RTL872X - // P2 doesn't need to turn off the modem manually - system_notify_event(network_status, network_status_off); -#else network_off(index, 0, 0, NULL); LOG(TRACE, "Waiting interface %d to be off...", (int)index); // There might be up to 30s delay to turn off the modem for particular platforms. network_wait_off(index, 120000/*ms*/, nullptr); -#endif } else { LOG(TRACE, "Interface %d is off already", (int)index); } From 1d1d55b3e457f1c2a96544ca6b5b525bfe8786e0 Mon Sep 17 00:00:00 2001 From: XuGuohui Date: Fri, 18 Nov 2022 13:49:23 +0800 Subject: [PATCH 072/112] pppncpnetif minor. --- hal/network/lwip/cellular/pppncpnetif.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hal/network/lwip/cellular/pppncpnetif.cpp b/hal/network/lwip/cellular/pppncpnetif.cpp index 1c9b525f9e..e6adc05a57 100644 --- a/hal/network/lwip/cellular/pppncpnetif.cpp +++ b/hal/network/lwip/cellular/pppncpnetif.cpp @@ -166,8 +166,8 @@ void PppNcpNetif::loop(void* arg) { PppNcpNetif* self = static_cast(arg); unsigned int timeout = 100; while(!self->exit_) { - self->celMan_->ncpClient()->enable(); // Make sure the client is enabled os_semaphore_take(self->netifSemaphore_, timeout, false); + self->celMan_->ncpClient()->enable(); // Make sure the client is enabled // We shouldn't be enforcing state on boot! if (self->lastNetifEvent_ != NetifEvent::None) { From fda3514255613da721ff39f028a1d6db764cc308 Mon Sep 17 00:00:00 2001 From: XuGuohui Date: Tue, 29 Nov 2022 14:48:06 +0800 Subject: [PATCH 073/112] [rtl872x]: sleep minor --- hal/src/rtl872x/sleep_hal.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hal/src/rtl872x/sleep_hal.cpp b/hal/src/rtl872x/sleep_hal.cpp index 02e1fa3b30..a40ac1dbf7 100644 --- a/hal/src/rtl872x/sleep_hal.cpp +++ b/hal/src/rtl872x/sleep_hal.cpp @@ -51,6 +51,7 @@ extern "C" { #include "dct.h" #include "dct_hal.h" #include "align_util.h" +#include "delay_hal.h" using namespace particle; @@ -102,7 +103,7 @@ class SleepClass { hal_ble_gap_is_connected(nullptr, nullptr); hal_ble_stack_deinit(nullptr); // The delay is essential to make sure the resources are successfully freed. - DelayMs(2000); + HAL_Delay_Milliseconds(2000); HAL_USB_Detach(); From 9a3d1fc7fa6c759f7ef546028bb6605ef052bc34 Mon Sep 17 00:00:00 2001 From: Eugene Date: Tue, 29 Nov 2022 15:14:45 +0800 Subject: [PATCH 074/112] [nrf52840] hal: use the internal ADC reference on BRN404X --- hal/inc/adc_hal.h | 5 +++++ hal/src/nRF52840/adc_hal.cpp | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/hal/inc/adc_hal.h b/hal/inc/adc_hal.h index 2cbab82361..57084b29d8 100644 --- a/hal/inc/adc_hal.h +++ b/hal/inc/adc_hal.h @@ -26,6 +26,11 @@ typedef enum hal_adc_state_t { HAL_ADC_STATE_SUSPENDED } hal_adc_state_t; +typedef enum hal_adc_reference_t { + HAL_ADC_REFERENCE_EXTERNAL, + HAL_ADC_REFERENCE_INTERNAL +} hal_adc_reference_t; + #ifdef __cplusplus extern "C" { #endif diff --git a/hal/src/nRF52840/adc_hal.cpp b/hal/src/nRF52840/adc_hal.cpp index 11defd9919..8cfd7218e0 100644 --- a/hal/src/nRF52840/adc_hal.cpp +++ b/hal/src/nRF52840/adc_hal.cpp @@ -20,6 +20,7 @@ #include "adc_hal.h" #include "pinmap_impl.h" #include "check.h" +#include "deviceid_hal.h" static volatile hal_adc_state_t adcState = HAL_ADC_STATE_DISABLED; @@ -30,6 +31,9 @@ static const nrfx_saadc_config_t saadcConfig = { .low_power_mode = false }; +static hal_adc_reference_t adcReference = HAL_ADC_REFERENCE_EXTERNAL; +static constexpr uint32_t HAL_VERSION_BRN404X_V003 = 0x03; + static void analog_in_event_handler(nrfx_saadc_evt_t const *p_event) { (void) p_event; } @@ -82,6 +86,11 @@ int32_t hal_adc_read(uint16_t pin) { .pin_n = NRF_SAADC_INPUT_DISABLED \ }; + if (adcReference == HAL_ADC_REFERENCE_INTERNAL) { + channelConfig.gain = NRF_SAADC_GAIN1_6; + channelConfig.reference = NRF_SAADC_REFERENCE_INTERNAL; + } + ret = nrfx_saadc_channel_init(PIN_MAP[pin].adc_channel, &channelConfig); if (ret) { goto err_ret; @@ -97,6 +106,10 @@ int32_t hal_adc_read(uint16_t pin) { goto err_ret; } else { nrfx_saadc_channel_uninit(PIN_MAP[pin].adc_channel); + if (adcReference == HAL_ADC_REFERENCE_INTERNAL) { + // With the internal reference (0.6V) and GAIN1_6, the 12bit ADC range is 0~4095 -> 0V~3.6V, need a conversion + adcValue = (int16_t)(adcValue * 3.6 / 3.3); + } return (uint16_t) adcValue; } @@ -112,6 +125,16 @@ void hal_adc_dma_init() { adcState = HAL_ADC_STATE_ENABLED; uint32_t err_code = nrfx_saadc_init(&saadcConfig, analog_in_event_handler); SPARK_ASSERT(err_code == NRF_SUCCESS); + +#if PLATFORM_ID == PLATFORM_BORON + uint32_t hwVersion = 0xFF; + auto ret = hal_get_device_hw_version(&hwVersion, nullptr); + if (ret == SYSTEM_ERROR_NONE && hwVersion == HAL_VERSION_BRN404X_V003) { + adcReference = HAL_ADC_REFERENCE_INTERNAL; + } +#else + (void)adcReference; +#endif // PLATFORM_ID == PLATFORM_BORON } /* From 2851d37c0aa1403052bca9cdca502ad5c1148b13 Mon Sep 17 00:00:00 2001 From: Eugene Date: Tue, 29 Nov 2022 15:34:48 +0800 Subject: [PATCH 075/112] [nrf52840] hal: fixes comments --- hal/inc/adc_hal.h | 5 ----- hal/src/nRF52840/adc_hal.cpp | 7 ++++++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hal/inc/adc_hal.h b/hal/inc/adc_hal.h index 57084b29d8..2cbab82361 100644 --- a/hal/inc/adc_hal.h +++ b/hal/inc/adc_hal.h @@ -26,11 +26,6 @@ typedef enum hal_adc_state_t { HAL_ADC_STATE_SUSPENDED } hal_adc_state_t; -typedef enum hal_adc_reference_t { - HAL_ADC_REFERENCE_EXTERNAL, - HAL_ADC_REFERENCE_INTERNAL -} hal_adc_reference_t; - #ifdef __cplusplus extern "C" { #endif diff --git a/hal/src/nRF52840/adc_hal.cpp b/hal/src/nRF52840/adc_hal.cpp index 8cfd7218e0..4e5af84ef9 100644 --- a/hal/src/nRF52840/adc_hal.cpp +++ b/hal/src/nRF52840/adc_hal.cpp @@ -22,6 +22,11 @@ #include "check.h" #include "deviceid_hal.h" +typedef enum hal_adc_reference_t { + HAL_ADC_REFERENCE_EXTERNAL, + HAL_ADC_REFERENCE_INTERNAL +} hal_adc_reference_t; + static volatile hal_adc_state_t adcState = HAL_ADC_STATE_DISABLED; static const nrfx_saadc_config_t saadcConfig = { @@ -108,7 +113,7 @@ int32_t hal_adc_read(uint16_t pin) { nrfx_saadc_channel_uninit(PIN_MAP[pin].adc_channel); if (adcReference == HAL_ADC_REFERENCE_INTERNAL) { // With the internal reference (0.6V) and GAIN1_6, the 12bit ADC range is 0~4095 -> 0V~3.6V, need a conversion - adcValue = (int16_t)(adcValue * 3.6 / 3.3); + adcValue = (int16_t)(adcValue * 3600 / 3300); } return (uint16_t) adcValue; } From 2823505d625570952f8d299cff396abaa991e13e Mon Sep 17 00:00:00 2001 From: keeramis Date: Tue, 29 Nov 2022 04:27:41 -0600 Subject: [PATCH 076/112] [test] Add entry for trackerM for slo tests --- user/tests/integration/slo/startup/startup-slos.spec.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/user/tests/integration/slo/startup/startup-slos.spec.js b/user/tests/integration/slo/startup/startup-slos.spec.js index 501bb3431f..823af179fb 100644 --- a/user/tests/integration/slo/startup/startup-slos.spec.js +++ b/user/tests/integration/slo/startup/startup-slos.spec.js @@ -19,6 +19,10 @@ const THRESHOLDS = { targetAppFlashSize: 21 * 1024, // 21KB targetFreeRam: 3 * 1024 * 1024 // 3MB }, + trackerm: { + targetAppFlashSize: 21 * 1024, // 21KB + targetFreeRam: 3 * 1024 * 1024 // 3MB + }, // See rational on this magic number: https://app.clubhouse.io/particle/story/72460/build-device-os-test-runner-integration-test-that-validates-the-minimum-flash-space-and-connects-quickly-slo#activity-72937 default: { targetAppFlashSize: 18105, From 1a2f68a4980d6f7dff6a7987b15a58d4f4712572 Mon Sep 17 00:00:00 2001 From: Technobly Date: Tue, 29 Nov 2022 09:53:45 -0600 Subject: [PATCH 077/112] [test] bump fastpin max limit to 10% --- user/tests/wiring/no_fixture/fastpin.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/user/tests/wiring/no_fixture/fastpin.cpp b/user/tests/wiring/no_fixture/fastpin.cpp index a12bd622b9..1211e5a77e 100644 --- a/user/tests/wiring/no_fixture/fastpin.cpp +++ b/user/tests/wiring/no_fixture/fastpin.cpp @@ -12,9 +12,9 @@ test(FASTPIN_01_MaxDuration_PinSet) { #endif // PLATFORM_ID == PLATFORM_ESOMX #if HAL_PLATFORM_RTL872X - const uint32_t MAX_DURATION_PINSET_NS = 3050; // 1% higher than measured (includes for() loop overhead) + const uint32_t MAX_DURATION_PINSET_NS = 3020 * 110 / 100; // 10% higher than measured (includes for() loop overhead) #else - const uint32_t MAX_DURATION_PINSET_NS = 1030; // 1% higher than measured (includes for() loop overhead) + const uint32_t MAX_DURATION_PINSET_NS = 1030 * 110 / 100; // 10% higher than measured (includes for() loop overhead) #endif // HAL_PLATFORM_RTL872X #else #error "No gpio fastpin timing benchmark yet measured for this platform" @@ -38,7 +38,7 @@ test(FASTPIN_01_MaxDuration_PinSet) { } uint32_t duration = finish - start; uint32_t expected = NUM_ITERATIONS * MAX_DURATION_PINSET_NS; - // Serial.printlnf("pinSetFast total duration: %lu vs. expected duration: %lu", duration, expected); + // Serial.printlnf("pinSetFast total duration: %lu vs. expected max duration: %lu", duration, expected); assertNotEqual(duration, 0); assertLessOrEqual(duration, expected); } @@ -54,9 +54,9 @@ test(FASTPIN_02_MaxDuration_PinReset) { #endif // PLATFORM_ID == PLATFORM_ESOMX #if HAL_PLATFORM_RTL872X - const uint32_t MAX_DURATION_PINRESET_NS = 3000; // 1% higher than measured (includes for() loop overhead) + const uint32_t MAX_DURATION_PINRESET_NS = 2970 * 110 / 100; // 10% higher than measured (includes for() loop overhead) #else - const uint32_t MAX_DURATION_PINRESET_NS = 1030; // 1% higher than measured (includes for() loop overhead) + const uint32_t MAX_DURATION_PINRESET_NS = 1030 * 110 / 100; // 10% higher than measured (includes for() loop overhead) #endif // HAL_PLATFORM_RTL872X #else #error "No gpio fastpin timing benchmark yet measured for this platform" @@ -80,7 +80,7 @@ test(FASTPIN_02_MaxDuration_PinReset) { } uint32_t duration = finish - start; uint32_t expected = NUM_ITERATIONS * MAX_DURATION_PINRESET_NS; - // Serial.printlnf("pinResetFast total duration: %lu vs. expected duration: %lu", duration, expected); + // Serial.printlnf("pinResetFast total duration: %lu vs. expected max duration: %lu", duration, expected); assertNotEqual(duration, 0); assertLessOrEqual(duration, expected); } From 0ef7764e5c8dbf2a2e09a0f3f5ed81357e9d4a0e Mon Sep 17 00:00:00 2001 From: keeramis Date: Tue, 29 Nov 2022 01:49:28 -0600 Subject: [PATCH 078/112] Account for eMTC sysmode while getting signal values --- hal/network/ncp_client/quectel/quectel_ncp_client.cpp | 4 +++- .../integration/slo/connect_time/connect_time.cpp | 11 ++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/hal/network/ncp_client/quectel/quectel_ncp_client.cpp b/hal/network/ncp_client/quectel/quectel_ncp_client.cpp index 670e127e07..c129504bf5 100644 --- a/hal/network/ncp_client/quectel/quectel_ncp_client.cpp +++ b/hal/network/ncp_client/quectel/quectel_ncp_client.cpp @@ -695,7 +695,9 @@ int QuectelNcpClient::getSignalQuality(CellularSignalQuality* qual) { {"TDSCDMA", CellularAccessTechnology::UTRAN}, {"LTE", CellularAccessTechnology::LTE}, {"CAT-M1", CellularAccessTechnology::LTE_CAT_M1}, - {"CAT-NB1", CellularAccessTechnology::LTE_NB_IOT} + {"eMTC", CellularAccessTechnology::LTE_CAT_M1}, + {"CAT-NB1", CellularAccessTechnology::LTE_NB_IOT}, + {"NBIoT", CellularAccessTechnology::LTE_NB_IOT}, }; int vals[5] = {}; diff --git a/user/tests/integration/slo/connect_time/connect_time.cpp b/user/tests/integration/slo/connect_time/connect_time.cpp index 9cb6b98384..8803ec0166 100644 --- a/user/tests/integration/slo/connect_time/connect_time.cpp +++ b/user/tests/integration/slo/connect_time/connect_time.cpp @@ -55,6 +55,15 @@ inline auto& network() { #endif } +#if Wiring_Cellular +bool isQuectelRadio(int radioType) { + return (radioType == DEV_QUECTEL_BG96 || radioType == DEV_QUECTEL_EG91_E || + radioType == DEV_QUECTEL_EG91_NA || radioType == DEV_QUECTEL_EG91_EX || + radioType == DEV_QUECTEL_BG95_M1 || radioType == DEV_QUECTEL_EG91_NAX || + radioType == DEV_QUECTEL_BG77 || radioType == DEV_QUECTEL_BG95_MF); +} +#endif + const char* ratToString(hal_net_access_tech_t rat) { switch (rat) { case NET_ACCESS_TECHNOLOGY_WIFI: @@ -191,7 +200,7 @@ bool testCloudConnectTimeFromColdBoot() { Test::out->println("Failed to retreive cellular_device_info!"); return false; } - if (devInfo.dev == DEV_QUECTEL_BG96 || devInfo.dev == DEV_QUECTEL_EG91_NA) { + if (isQuectelRadio(devInfo.dev)) { delay(6000); } signal = network().RSSI(); From 533175648b0910cfdcad24caf5867fbc700faa76 Mon Sep 17 00:00:00 2001 From: Andrey Tolstoy Date: Wed, 16 Nov 2022 09:38:31 +0700 Subject: [PATCH 079/112] [freertos] multi-step priority disinheritance --- hal/src/rtl872x/freertos/FreeRTOSConfig.h | 1 + third_party/freertos/freertos | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/hal/src/rtl872x/freertos/FreeRTOSConfig.h b/hal/src/rtl872x/freertos/FreeRTOSConfig.h index 282df5aa0b..84c59d727b 100644 --- a/hal/src/rtl872x/freertos/FreeRTOSConfig.h +++ b/hal/src/rtl872x/freertos/FreeRTOSConfig.h @@ -108,6 +108,7 @@ extern void vApplicationTaskDeleteHook(void *pvTaskToDelete, volatile long* pxPe /* Constants that build features in or out. */ #define configUSE_MUTEXES 1 +#define configMUTEX_MULTI_STEP_PRIORITY_DISINHERITANCE 1 #define configUSE_APPLICATION_TASK_TAG 0 #define configUSE_NEWLIB_REENTRANT 1 diff --git a/third_party/freertos/freertos b/third_party/freertos/freertos index 60dd05d4f0..6c7c6d03ae 160000 --- a/third_party/freertos/freertos +++ b/third_party/freertos/freertos @@ -1 +1 @@ -Subproject commit 60dd05d4f0265ee00d6370b96edc79f86f4a271c +Subproject commit 6c7c6d03ae5797feed0867d33f8ec5415ff6d9ca From d323c7dc5aaba96ac4c88d388f35fcc49e4022d8 Mon Sep 17 00:00:00 2001 From: Andrey Tolstoy Date: Thu, 17 Nov 2022 03:16:21 +0700 Subject: [PATCH 080/112] [third_party] ambd_sdk: bump submodule --- third_party/ambd_sdk/ambd_sdk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/ambd_sdk/ambd_sdk b/third_party/ambd_sdk/ambd_sdk index 36aa84c123..eb54fb5280 160000 --- a/third_party/ambd_sdk/ambd_sdk +++ b/third_party/ambd_sdk/ambd_sdk @@ -1 +1 @@ -Subproject commit 36aa84c123c67e74779db8d06c38d0d0ee199259 +Subproject commit eb54fb5280ccf2c3b6af26cca4796ae2a00c6115 From 34a09dcfb22f68c0f7577244267dd89034f07d44 Mon Sep 17 00:00:00 2001 From: Andrey Tolstoy Date: Thu, 17 Nov 2022 03:54:49 +0700 Subject: [PATCH 081/112] [hal] concurrent: add priorites into os_thread_dump(), enable for P2 --- hal/inc/concurrent_hal.h | 2 ++ hal/inc/hal_platform.h | 2 +- hal/src/nRF52840/concurrent_hal.cpp | 2 ++ hal/src/nRF52840/hal_platform_nrf52840_config.h | 2 -- hal/src/rtl872x/concurrent_hal.cpp | 2 ++ 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/hal/inc/concurrent_hal.h b/hal/inc/concurrent_hal.h index d71ce7ba32..67de7d2ede 100644 --- a/hal/inc/concurrent_hal.h +++ b/hal/inc/concurrent_hal.h @@ -148,6 +148,8 @@ typedef struct { size_t stack_size; void* stack_current; //the current tasks stack pointer size_t stack_high_watermark; //the max amount of free stack memory that the RTOS has recorded + uint32_t priority; + uint32_t base_priority; } os_thread_dump_info_t; typedef os_result_t (*os_thread_dump_callback_t)(os_thread_dump_info_t*, void *reserved); diff --git a/hal/inc/hal_platform.h b/hal/inc/hal_platform.h index 3d8cc68167..70e6cc1cd7 100644 --- a/hal/inc/hal_platform.h +++ b/hal/inc/hal_platform.h @@ -510,7 +510,7 @@ #endif // HAL_PLATFORM_MAX_CLOUD_CONNECT_TIME #ifndef HAL_PLATFORM_CONCURRENT_DUMP_THREADS -#define HAL_PLATFORM_CONCURRENT_DUMP_THREADS (0) +#define HAL_PLATFORM_CONCURRENT_DUMP_THREADS (1) #endif // HAL_PLATFORM_CONCURRENT_DUMP_THREADS #ifndef HAL_PLATFORM_LED_THEME diff --git a/hal/src/nRF52840/concurrent_hal.cpp b/hal/src/nRF52840/concurrent_hal.cpp index 33ca27a444..980eb56274 100644 --- a/hal/src/nRF52840/concurrent_hal.cpp +++ b/hal/src/nRF52840/concurrent_hal.cpp @@ -128,6 +128,8 @@ static BaseType_t os_thread_dump_helper(TaskStatus_t* const status, void* data) info.name = status->pcTaskName; info.id = status->xTaskNumber; info.stack_high_watermark = status->usStackHighWaterMark; + info.priority = status->uxCurrentPriority; + info.base_priority = status->uxBasePriority; void *stack_end = NULL; vTaskGetStackInfoParticle(status->xHandle, &info.stack_base, &info.stack_current, &stack_end); diff --git a/hal/src/nRF52840/hal_platform_nrf52840_config.h b/hal/src/nRF52840/hal_platform_nrf52840_config.h index 02273391fb..b4419a22e5 100644 --- a/hal/src/nRF52840/hal_platform_nrf52840_config.h +++ b/hal/src/nRF52840/hal_platform_nrf52840_config.h @@ -107,5 +107,3 @@ #define HAL_PLATFORM_ERROR_MESSAGES (1) #define HAL_PLATFORM_PROHIBIT_XIP (1) - -#define HAL_PLATFORM_CONCURRENT_DUMP_THREADS (1) \ No newline at end of file diff --git a/hal/src/rtl872x/concurrent_hal.cpp b/hal/src/rtl872x/concurrent_hal.cpp index 84c1b7abc5..007c45f413 100644 --- a/hal/src/rtl872x/concurrent_hal.cpp +++ b/hal/src/rtl872x/concurrent_hal.cpp @@ -134,6 +134,8 @@ static BaseType_t os_thread_dump_helper(TaskStatus_t* const status, void* data) info.name = status->pcTaskName; info.id = status->xTaskNumber; info.stack_high_watermark = status->usStackHighWaterMark; + info.priority = status->uxCurrentPriority; + info.base_priority = status->uxBasePriority; void *stack_end = NULL; vTaskGetStackInfoParticle(status->xHandle, &info.stack_base, &info.stack_current, &stack_end); From bc78477e62ff3663cffaf3479d97fc66d3bc0a3e Mon Sep 17 00:00:00 2001 From: Andrey Tolstoy Date: Thu, 17 Nov 2022 03:55:43 +0700 Subject: [PATCH 082/112] [tests] wiring/no_fixture: add CONCURRENT_MUTEX_01_priority_inheritance_two_threads --- user/tests/wiring/no_fixture/thread.cpp | 129 ++++++++++++++++++++++++ 1 file changed, 129 insertions(+) diff --git a/user/tests/wiring/no_fixture/thread.cpp b/user/tests/wiring/no_fixture/thread.cpp index 7423f82077..9974c9fcf2 100644 --- a/user/tests/wiring/no_fixture/thread.cpp +++ b/user/tests/wiring/no_fixture/thread.cpp @@ -3,6 +3,10 @@ #include "unit-test/unit-test.h" #include "scope_guard.h" +#if HAL_PLATFORM_FREERTOS +#include +#endif // HAL_PLATFORM_FREERTOS + namespace { template @@ -309,4 +313,129 @@ test(APPLICATION_WATCHDOG_03_doesnt_leak_memory) assertMoreOrEqual(System.freeMemory(), s_ram_free_before - ((APPLICATION_WDT_STACK_SIZE * APPLICATION_WDT_TEST_RUNS)/2)); } +#if defined(configMUTEX_MULTI_STEP_PRIORITY_DISINHERITANCE) && configMUTEX_MULTI_STEP_PRIORITY_DISINHERITANCE + +struct ThreadPriority { + uint32_t base; + uint32_t prio; +}; + +ThreadPriority getThreadPriority() { + os_thread_dump_info_t info = {}; + + os_thread_dump(os_thread_current(nullptr), [](os_thread_dump_info_t* info, void* ptr) -> os_result_t { + if (info) { + memcpy(ptr, info, sizeof(*info)); + } + return 0; + }, &info); + ThreadPriority p; + p.base = info.base_priority; + p.prio = info.priority; + return p; +} + +test(CONCURRENT_MUTEX_01_priority_inheritance_two_threads) +{ + struct State { + State() = default; + ~State() = default; + Mutex mutex1; + Mutex mutex2; + bool state1 = false; + bool state2 = false; + volatile int done = 0; + }; + + State state; + const auto startPriority = OS_THREAD_PRIORITY_DEFAULT + 1; + + Thread lowPriorityThread("low", [](void* ptr) -> void { + auto state = (State*)ptr; + SCOPE_GUARD({ + ++state->done; + }); + + // Acquire first mutex + std::unique_lock mutex1(state->mutex1); + // Check that we are at the base priority and nothing has affected us + auto prio = getThreadPriority(); + assertEqual(prio.base, prio.prio); + + // Keep holding the first mutex and acquire the second one + std::unique_lock mutex2(state->mutex2); + // Somewhere at this point the second thread will try to acquire the second mutex + // and because we are holding it and are of lower priority, our priority + // should be bumped to that of thread2. + delay(1000); + + // Verify that our priority has been bumped to that of thread2 + prio = getThreadPriority(); + assertEqual(prio.prio, prio.base + 1); + + // Unlock mutex2, this should allow the second thread to finally + // acquire it. + mutex2.unlock(); + + // After we've released mutex2 and let the second thread to + // acquire it, our priority should be dropped to the 'normal' or base priority + // Validate that + prio = getThreadPriority(); + assertEqual(prio.prio, prio.base); + + // Everything is good + + state->state1 = true; + }, &state, startPriority); + Thread highPriorityThread("high", [](void* ptr) -> void { + auto state = (State*)ptr; + SCOPE_GUARD({ + ++state->done; + }); + + // Wait a bit for thread1 to acquire both mutexes + delay(500); + + // Check that we are at the base priority and nothing has affected us + auto prio = getThreadPriority(); + assertEqual(prio.base, prio.prio); + + // Attempt to acquire the second mutex, at this point the first thread + // should be holding it. Because we are at higher priority, the priority + // of the first thread should be bumped. + std::unique_lock mutex2(state->mutex2); + + // We've finally acquired the mutex and at this point the priority + // of the first thread should have dropped back to the base priority + + // Our priority should stay the same throughout all of this (base) + prio = getThreadPriority(); + assertEqual(prio.base, prio.prio); + + // Unlock second mutex + mutex2.unlock(); + + // Nothing should have changed, we should still be at our own base priority + prio = getThreadPriority(); + assertEqual(prio.base, prio.prio); + + // All done + state->state2 = true; + }, &state, startPriority + 1); + + for (auto start = millis(); millis() - start <= 2000;) { + if (state.done == 2) { + break; + } + delay(100); + } + + assertTrue(state.state1); + assertTrue(state.state2); +} + +// TODO: more complex examples with 3 threads etc + +#endif // defined(configMUTEX_MULTI_STEP_PRIORITY_DISINHERITANCE) && configMUTEX_MULTI_STEP_PRIORITY_DISINHERITANCE + #endif From 2c1bd176a93c76271bde34d71b5bbdc9438066bd Mon Sep 17 00:00:00 2001 From: Andrey Tolstoy Date: Thu, 17 Nov 2022 07:57:37 +0700 Subject: [PATCH 083/112] [third_party] freertos: update submodule reference --- third_party/freertos/freertos | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/freertos/freertos b/third_party/freertos/freertos index 6c7c6d03ae..44381d9eb6 160000 --- a/third_party/freertos/freertos +++ b/third_party/freertos/freertos @@ -1 +1 @@ -Subproject commit 6c7c6d03ae5797feed0867d33f8ec5415ff6d9ca +Subproject commit 44381d9eb60d4c2461ffcbf4fa3a13724444f1f9 From ae6568d9cf7df8ee3d3c93a5c4e8ad2ae57fac36 Mon Sep 17 00:00:00 2001 From: Eugene Date: Tue, 22 Nov 2022 16:15:39 +0800 Subject: [PATCH 084/112] [tests] wiring/no_fixture: add CONCURRENT_MUTEX_02_priority_inheritance_three_threads --- user/tests/wiring/no_fixture/thread.cpp | 140 +++++++++++++++++++++++- 1 file changed, 139 insertions(+), 1 deletion(-) diff --git a/user/tests/wiring/no_fixture/thread.cpp b/user/tests/wiring/no_fixture/thread.cpp index 9974c9fcf2..6f9cd6b3f5 100644 --- a/user/tests/wiring/no_fixture/thread.cpp +++ b/user/tests/wiring/no_fixture/thread.cpp @@ -434,7 +434,145 @@ test(CONCURRENT_MUTEX_01_priority_inheritance_two_threads) assertTrue(state.state2); } -// TODO: more complex examples with 3 threads etc +test(CONCURRENT_MUTEX_02_priority_inheritance_three_threads) +{ + struct State { + State() = default; + ~State() = default; + Mutex mutex1; + Mutex mutex2; + bool state1 = false; + bool state2 = false; + bool state3 = false; + volatile int done = 0; + }; + + State state; + const auto startPriority = OS_THREAD_PRIORITY_DEFAULT + 1; + + Thread lowPriorityThread("low", [](void* ptr) -> void { + auto state = (State*)ptr; + SCOPE_GUARD({ + ++state->done; + }); + + // Acquire first mutex + std::unique_lock mutex1(state->mutex1); + // Check that we are at the base priority and nothing has affected us + auto prio = getThreadPriority(); + assertEqual(prio.base, prio.prio); + + // Keep holding the first mutex and acquire the second one + std::unique_lock mutex2(state->mutex2); + // Somewhere at this point the high priority thread will try to acquire the mutex2 + // and middle priority thread will try to acquire the mutex1, our priority should + // be bumped to that of high priority thread. + delay(500); + + // Verify that our priority has been bumped to that of high priority thread + prio = getThreadPriority(); + assertEqual(prio.prio, prio.base + 2); + + // Unlock mutex2, this should allow the high priority thread to finally + // acquire it, and our priority should be decreased to middle priority + mutex2.unlock(); + delay(500); + prio = getThreadPriority(); + assertEqual(prio.prio, prio.base + 1); + + // Unlock mutex1, this should allow the middle priority thread to finally + // acquire it, and our priority should be decreased to low priority + mutex1.unlock(); + delay(500); + prio = getThreadPriority(); + assertEqual(prio.prio, prio.base); + + // Everything is good + + state->state1 = true; + }, &state, startPriority); + Thread middlePriorityThread("middle", [](void* ptr) -> void { + auto state = (State*)ptr; + SCOPE_GUARD({ + ++state->done; + }); + + // Wait a bit for low priority thread to acquire both mutexes + delay(500); + + // Check that we are at the base priority and nothing has affected us + auto prio = getThreadPriority(); + assertEqual(prio.base, prio.prio); + + // Attempt to acquire the mutex1, at this point the low priority thread + // should be holding it. Because we are at higher priority, the priority + // of the low priority thread should be bumped. + std::unique_lock mutex1(state->mutex1); + + // We've finally acquired the mutex and at this point the priority + // of the low priority thread should have dropped back to the base priority + + // Our priority should stay the same throughout all of this (base) + prio = getThreadPriority(); + assertEqual(prio.base, prio.prio); + + // Unlock second mutex + mutex1.unlock(); + + // Nothing should have changed, we should still be at our own base priority + prio = getThreadPriority(); + assertEqual(prio.base, prio.prio); + + // All done + state->state2 = true; + }, &state, startPriority + 1); + Thread highPriorityThread("high", [](void* ptr) -> void { + auto state = (State*)ptr; + SCOPE_GUARD({ + ++state->done; + }); + + // Wait a bit for low priority thread to acquire both mutexes + delay(500); + + // Check that we are at the base priority and nothing has affected us + auto prio = getThreadPriority(); + assertEqual(prio.base, prio.prio); + + // Attempt to acquire the second mutex, at this point the low priority thread + // should be holding it. Because we are at higher priority, the priority + // of the low priority thread should be bumped. + std::unique_lock mutex2(state->mutex2); + + // We've finally acquired the mutex and at this point the priority + // of the low priority thread should have dropped back to the base priority + + // Our priority should stay the same throughout all of this (base) + prio = getThreadPriority(); + assertEqual(prio.base, prio.prio); + + // Unlock second mutex + mutex2.unlock(); + + // Nothing should have changed, we should still be at our own base priority + prio = getThreadPriority(); + assertEqual(prio.base, prio.prio); + + // All done + state->state3 = true; + }, &state, startPriority + 2); + + for (auto start = millis(); millis() - start <= 2000;) { + if (state.done == 3) { + break; + } + delay(100); + } + + assertTrue(state.state1); + assertTrue(state.state2); + assertTrue(state.state3); +} #endif // defined(configMUTEX_MULTI_STEP_PRIORITY_DISINHERITANCE) && configMUTEX_MULTI_STEP_PRIORITY_DISINHERITANCE From 38d968b5c0e3c79d7ead6416bdba5c929a7c298d Mon Sep 17 00:00:00 2001 From: XuGuohui Date: Sat, 19 Nov 2022 03:23:07 +0800 Subject: [PATCH 085/112] [rtl872x] BLE HAL improvements --- hal/src/rtl872x/ble_hal.cpp | 149 ++++++++++++++++++++++++++++-------- 1 file changed, 115 insertions(+), 34 deletions(-) diff --git a/hal/src/rtl872x/ble_hal.cpp b/hal/src/rtl872x/ble_hal.cpp index cca34aa658..9ea9f15a33 100644 --- a/hal/src/rtl872x/ble_hal.cpp +++ b/hal/src/rtl872x/ble_hal.cpp @@ -154,6 +154,8 @@ constexpr uint32_t BLE_OPERATION_TIMEOUT_MS = 60000; StaticRecursiveMutex s_bleMutex; +bool bleInLockedMode = false; + void rtwCoexRunDisable() { os_thread_scheduling(false, nullptr); auto p = pcoex[0]; @@ -394,8 +396,9 @@ class BleGap { ssize_t getAdvertisingData(uint8_t* buf, size_t len) const; int setScanResponseData(const uint8_t* buf, size_t len); ssize_t getScanResponseData(uint8_t* buf, size_t len) const; - int startAdvertising(bool wait = true); - int stopAdvertising(bool wait = true); + int startAdvertising(bool wait = true); // TODO: always wait, now we have command thread to execute asynchronously + int stopAdvertising(bool wait = true); // TODO: always wait, now we have command thread to execute asynchronously + int notifyAdvStop(); bool isAdvertising() const { return isAdvertising_; @@ -457,6 +460,15 @@ class BleGap { return SYSTEM_ERROR_NONE; } + int enqueue(uint8_t cmd) { + CHECK_TRUE(cmdQueue_, SYSTEM_ERROR_INVALID_STATE); + if (os_queue_put(cmdQueue_, &cmd, 0, nullptr)) { + LOG(ERROR, "os_queue_put() failed."); + SPARK_ASSERT(false); + } + return SYSTEM_ERROR_NONE; + } + static BleGap& getInstance() { static BleGap instance; return instance; @@ -483,13 +495,14 @@ class BleGap { }; BleGap() - : initialized_(false), + : cmdThread_(nullptr), + cmdQueue_(nullptr), + initialized_(false), btStackStarted_(false), state_{}, addr_{}, advParams_{}, advTimeoutTimer_(nullptr), - advScheduled_(false), isScanning_(false), scanParams_{}, scanSemaphore_(nullptr), @@ -604,19 +617,21 @@ class BleGap { static T_APP_RESULT gapEventCallback(uint8_t type, void *data); static void onAdvTimeoutTimerExpired(os_timer_t timer); + static void bleCommandThread(void *context); struct BleAdvEventHandler { hal_ble_on_adv_evt_cb_t callback; void* context; }; + void* cmdThread_; + void* cmdQueue_; bool initialized_; bool btStackStarted_; volatile RtlGapDevState state_; /**< This should be atomically r/w as the struct is <= uint32_t */ hal_ble_addr_t addr_; hal_ble_adv_params_t advParams_; os_timer_t advTimeoutTimer_; /**< Timer for advertising timeout. */ - volatile bool advScheduled_; volatile bool isScanning_; /**< If it is scanning or not. */ hal_ble_scan_params_t scanParams_; /**< BLE scanning parameters. */ os_semaphore_t scanSemaphore_; /**< Semaphore to wait until the scan procedure completed. */ @@ -649,6 +664,15 @@ class BleGap { static constexpr system_tick_t BLE_WAIT_STATE_POLL_PERIOD_MS = 10; static constexpr system_tick_t BLE_STATE_DEFAULT_TIMEOUT = 5000; + + static constexpr uint8_t BLE_CMD_THREAD_PRIORITY = 2; + static constexpr uint16_t BLE_CMD_THREAD_STACK_SIZE = 2048; + static constexpr uint8_t BLE_CMD_QUEUE_SIZE = 0x20; + + static constexpr uint8_t BLE_CMD_EXIT_THREAD = 0xff; + static constexpr uint8_t BLE_CMD_STOP_ADV = 0xfe; + static constexpr uint8_t BLE_CMD_STOP_ADV_NOTIFY = 0xfd; + static constexpr uint8_t BLE_CMD_START_ADV = 0xfc; }; @@ -843,7 +867,9 @@ int BleEventDispatcher::start() { }); CHECK_TRUE(os_msg_queue_create(&ioEvtQueue_, MAX_NUMBER_OF_IO_MESSAGE, sizeof(T_IO_MSG)), SYSTEM_ERROR_INTERNAL); CHECK_TRUE(os_msg_queue_create(&allEvtQueue_, MAX_NUMBER_OF_EVENT_MESSAGE, sizeof(uint8_t)), SYSTEM_ERROR_INTERNAL); - CHECK_TRUE(os_thread_create(&thread_, "bleEvtThread", BLE_EVENT_THREAD_PRIORITY, bleEventDispatchThread, this, BLE_EVENT_THREAD_STACK_SIZE) == 0, SYSTEM_ERROR_INTERNAL); + if (!thread_) { + CHECK_TRUE(os_thread_create(&thread_, "bleEvtThread", BLE_EVENT_THREAD_PRIORITY, bleEventDispatchThread, this, BLE_EVENT_THREAD_STACK_SIZE) == 0, SYSTEM_ERROR_INTERNAL); + } CHECK_TRUE(gap_start_bt_stack(allEvtQueue_, ioEvtQueue_, MAX_NUMBER_OF_GAP_MESSAGE), SYSTEM_ERROR_INTERNAL); ok = true; return SYSTEM_ERROR_NONE; @@ -856,7 +882,7 @@ int BleEventDispatcher::stop() { } void BleEventDispatcher::cleanup() { - if (thread_ && allEvtQueue_) { + if (thread_ && allEvtQueue_ && !isThreadCurrent()) { uint8_t ev = BLE_EVENT_STOP; SPARK_ASSERT(os_msg_send(allEvtQueue_, &ev, BLE_EVENT_SEND_TIMEOUT_MS)); os_thread_join(thread_); @@ -975,6 +1001,28 @@ void BleEventDispatcher::bleEventDispatchThread(void *context) { os_thread_exit(nullptr); } +void BleGap::bleCommandThread(void *context) { + BleGap* gap = (BleGap*)context; + while (true) { + uint8_t command; + if (!os_queue_take(gap->cmdQueue_, &command, CONCURRENT_WAIT_FOREVER, nullptr)) { + if (command == BLE_CMD_STOP_ADV || command == BLE_CMD_STOP_ADV_NOTIFY) { + if (gap->isAdvertising()) { + gap->stopAdvertising(); + if (command == BLE_CMD_STOP_ADV_NOTIFY) { + gap->notifyAdvStop(); + } + } + } else if (command == BLE_CMD_START_ADV) { + gap->startAdvertising(); + } else if (command == BLE_CMD_EXIT_THREAD) { + break; + } + } + } + os_thread_exit(nullptr); +} + int BleGap::init() { if (initialized_) { return SYSTEM_ERROR_NONE; @@ -995,6 +1043,10 @@ int BleGap::init() { RCC_PeriphClockCmd(APBPeriph_UART1, APBPeriph_UART1_CLOCK, ENABLE); + CHECK_TRUE(os_msg_queue_create(&cmdQueue_, BLE_CMD_QUEUE_SIZE, sizeof(uint8_t)), SYSTEM_ERROR_INTERNAL); + if (!cmdThread_) { + CHECK_TRUE(os_thread_create(&cmdThread_, "bleCommandThread", BLE_CMD_THREAD_PRIORITY, bleCommandThread, this, BLE_CMD_THREAD_STACK_SIZE) == 0, SYSTEM_ERROR_INTERNAL); + } CHECK_TRUE(os_semaphore_create(&scanSemaphore_, 1, 0) == 0, SYSTEM_ERROR_INTERNAL); CHECK_TRUE(os_semaphore_create(&stateSemaphore_, 1, 0) == 0, SYSTEM_ERROR_INTERNAL); CHECK_TRUE(os_semaphore_create(&connectSemaphore_, 1, 0) == 0, SYSTEM_ERROR_INTERNAL); @@ -1120,6 +1172,17 @@ int BleGap::stop() { bte_deinit(); BleEventDispatcher::getInstance().stop(); + if (cmdThread_ && !os_thread_is_current(cmdThread_)) { + if (enqueue(BLE_CMD_EXIT_THREAD) == SYSTEM_ERROR_NONE) { + os_thread_join(cmdThread_); + cmdThread_ = nullptr; + } + } + if (cmdQueue_) { + os_queue_destroy(cmdQueue_, nullptr); + cmdQueue_ = nullptr; + } + initialized_ = false; btStackStarted_ = false; @@ -1425,7 +1488,7 @@ int BleGap::startAdvertising(bool wait) { } } ok = true; - LOG(TRACE, "Advertising started"); + LOG_DEBUG(TRACE, "Advertising started"); return SYSTEM_ERROR_NONE; } @@ -1440,11 +1503,12 @@ int BleGap::stopAdvertising(bool wait) { return SYSTEM_ERROR_NONE; } // In case of invoking startAdvertising(false) previously - if (wait && state_.state.gap_adv_state != GAP_ADV_STATE_ADVERTISING) { - if (waitState(BleGapDevState().adv(GAP_ADV_STATE_ADVERTISING), BLE_STATE_DEFAULT_TIMEOUT, true)) { - LOG(ERROR, "Failed to get notified that advertising has started"); - } - } + // Update: now we use BLE command queue to make sure adv state is correctly set + // if (wait && state_.state.gap_adv_state != GAP_ADV_STATE_ADVERTISING) { + // if (waitState(BleGapDevState().adv(GAP_ADV_STATE_ADVERTISING), BLE_STATE_DEFAULT_TIMEOUT, true)) { + // LOG(ERROR, "Failed to get notified that advertising has started"); + // } + // } isAdvertising_ = false; CHECK_RTL(le_adv_stop()); if (os_timer_is_active(advTimeoutTimer_, nullptr)) { @@ -1460,21 +1524,23 @@ int BleGap::stopAdvertising(bool wait) { return SYSTEM_ERROR_NONE; } +int BleGap::notifyAdvStop() { + hal_ble_adv_evt_t advEvent = {}; + advEvent.type = BLE_EVT_ADV_STOPPED; + advEvent.params.reason = BLE_ADV_STOPPED_REASON_TIMEOUT; + std::lock_guard lk(advEventMutex_); + for (const auto& handler : advEventHandlers_) { + if (handler.callback) { + handler.callback(&advEvent, handler.context); + } + } + return SYSTEM_ERROR_NONE; +} + void BleGap::onAdvTimeoutTimerExpired(os_timer_t timer) { BleGap* gap; os_timer_get_id(timer, (void**)&gap); - if (gap->isAdvertising()) { - gap->stopAdvertising(); - hal_ble_adv_evt_t advEvent = {}; - advEvent.type = BLE_EVT_ADV_STOPPED; - advEvent.params.reason = BLE_ADV_STOPPED_REASON_TIMEOUT; - std::lock_guard lk(gap->advEventMutex_); - for (const auto& handler : gap->advEventHandlers_) { - if (handler.callback) { - handler.callback(&advEvent, handler.context); - } - } - } + gap->enqueue(BLE_CMD_STOP_ADV_NOTIFY); } bool BleGap::scanning() { @@ -2041,10 +2107,13 @@ void BleGap::handleDevStateChanged(T_GAP_DEV_STATE newState, uint16_t cause) { // NOTE: this event is generated before the connection is established if (newState.gap_adv_state != state_.state.gap_adv_state && newState.gap_adv_state == GAP_ADV_STATE_IDLE) { if (newState.gap_adv_sub_state == GAP_ADV_TO_IDLE_CAUSE_CONN) { - stopAdvertising(false); - } else if (advScheduled_) { - advScheduled_ = false; - startAdvertising(false); + isAdvertising_ = false; // adv timer has higher priority, just in case that the BLE_CMD_STOP_ADV_NOTIFY + // has been enqueued, followed by nontifying the ADV stopped event. Under + // certain circumstance notifying the ADV stopped event will cause BLE re-adv, + // e.g. in BLE listening mode. + if (os_timer_is_active(advTimeoutTimer_, nullptr)) { + os_timer_change(advTimeoutTimer_, OS_TIMER_CHANGE_STOP, hal_interrupt_is_isr() ? true : false, 0, 0, nullptr); + } } } state_.raw = nState.raw; @@ -2102,12 +2171,9 @@ void BleGap::handleConnectionStateChanged(uint8_t connHandle, T_GAP_CONN_STATE n if (role == BLE_ROLE_PERIPHERAL) { // FIXME: check whether it's enabled? if (isAdvertising()) { - stopAdvertising(false); - // Re-start advertising after the adv-stopped event received - advScheduled_ = true; - } else { - startAdvertising(false); + enqueue(BLE_CMD_STOP_ADV); } + enqueue(BLE_CMD_START_ADV); } break; } @@ -3323,10 +3389,12 @@ int hal_ble_unlock(void* reserved) { } int hal_ble_enter_locked_mode(void* reserved) { + bleInLockedMode = true; return SYSTEM_ERROR_NONE; } int hal_ble_exit_locked_mode(void* reserved) { + bleInLockedMode = false; return SYSTEM_ERROR_NONE; } @@ -3422,6 +3490,7 @@ int hal_ble_gap_set_ppcp(const hal_ble_conn_params_t* ppcp, void* reserved) { BleLock lk; LOG_DEBUG(TRACE, "hal_ble_gap_set_ppcp()."); CHECK_TRUE(BleGap::getInstance().initialized(), SYSTEM_ERROR_INVALID_STATE); + CHECK_FALSE(bleInLockedMode, SYSTEM_ERROR_INVALID_STATE); return BleGap::getInstance().setPpcp(ppcp); } @@ -3447,6 +3516,7 @@ int hal_ble_gap_delete_whitelist(void* reserved) { int hal_ble_gap_set_tx_power(int8_t tx_power, void* reserved) { BleLock lk; LOG_DEBUG(TRACE, "hal_ble_gap_set_tx_power()."); + CHECK_FALSE(bleInLockedMode, SYSTEM_ERROR_INVALID_STATE); return SYSTEM_ERROR_NONE; } @@ -3460,6 +3530,7 @@ int hal_ble_gap_set_advertising_parameters(const hal_ble_adv_params_t* adv_param BleLock lk; LOG_DEBUG(TRACE, "hal_ble_gap_set_advertising_parameters()."); CHECK_TRUE(BleGap::getInstance().initialized(), SYSTEM_ERROR_INVALID_STATE); + CHECK_FALSE(bleInLockedMode, SYSTEM_ERROR_INVALID_STATE); return BleGap::getInstance().setAdvertisingParameters(adv_params); } @@ -3474,6 +3545,7 @@ int hal_ble_gap_set_advertising_data(const uint8_t* buf, size_t len, void* reser BleLock lk; LOG_DEBUG(TRACE, "hal_ble_gap_set_advertising_data()."); CHECK_TRUE(BleGap::getInstance().initialized(), SYSTEM_ERROR_INVALID_STATE); + CHECK_FALSE(bleInLockedMode, SYSTEM_ERROR_INVALID_STATE); return BleGap::getInstance().setAdvertisingData(buf, len); } @@ -3488,6 +3560,7 @@ int hal_ble_gap_set_scan_response_data(const uint8_t* buf, size_t len, void* res BleLock lk; LOG_DEBUG(TRACE, "hal_ble_gap_set_scan_response_data()."); CHECK_TRUE(BleGap::getInstance().initialized(), SYSTEM_ERROR_INVALID_STATE); + CHECK_FALSE(bleInLockedMode, SYSTEM_ERROR_INVALID_STATE); return BleGap::getInstance().setScanResponseData(buf, len); } @@ -3508,6 +3581,7 @@ int hal_ble_gap_start_advertising(void* reserved) { int hal_ble_gap_set_auto_advertise(hal_ble_auto_adv_cfg_t config, void* reserved) { BleLock lk; LOG_DEBUG(TRACE, "hal_ble_gap_set_auto_advertise()."); + CHECK_FALSE(bleInLockedMode, SYSTEM_ERROR_INVALID_STATE); return SYSTEM_ERROR_NONE; } @@ -3521,6 +3595,7 @@ int hal_ble_gap_stop_advertising(void* reserved) { BleLock lk; LOG_DEBUG(TRACE, "hal_ble_gap_stop_advertising()."); CHECK_TRUE(BleGap::getInstance().initialized(), SYSTEM_ERROR_INVALID_STATE); + CHECK_FALSE(bleInLockedMode, SYSTEM_ERROR_INVALID_STATE); return BleGap::getInstance().stopAdvertising(); } @@ -3593,12 +3668,18 @@ int hal_ble_gap_disconnect(hal_ble_conn_handle_t conn_handle, void* reserved) { BleLock lk; LOG_DEBUG(TRACE, "hal_ble_gap_disconnect()."); CHECK_TRUE(BleGap::getInstance().initialized(), SYSTEM_ERROR_INVALID_STATE); + hal_ble_conn_info_t info = {}; + CHECK(BleGap::getInstance().getConnectionInfo(conn_handle, &info)); + CHECK_FALSE(bleInLockedMode && info.role == BLE_ROLE_PERIPHERAL, SYSTEM_ERROR_INVALID_STATE); return BleGap::getInstance().disconnect(conn_handle); } int hal_ble_gap_update_connection_params(hal_ble_conn_handle_t conn_handle, const hal_ble_conn_params_t* conn_params, void* reserved) { BleLock lk; LOG_DEBUG(TRACE, "hal_ble_gap_update_connection_params()."); + hal_ble_conn_info_t info = {}; + CHECK(BleGap::getInstance().getConnectionInfo(conn_handle, &info)); + CHECK_FALSE(bleInLockedMode && info.role == BLE_ROLE_PERIPHERAL, SYSTEM_ERROR_INVALID_STATE); return SYSTEM_ERROR_NOT_SUPPORTED; } From fb6f240e7ed13122f16ab7c6e41d81d50e454621 Mon Sep 17 00:00:00 2001 From: XuGuohui Date: Sat, 19 Nov 2022 03:23:42 +0800 Subject: [PATCH 086/112] System setup improvements. --- system/inc/system_setup.h | 2 ++ system/src/ble_provisioning_mode_handler.cpp | 3 +- system/src/system_setup.cpp | 31 +++++++++++++++++--- wiring/inc/spark_wiring.h | 2 +- wiring/src/spark_wiring_stream.cpp | 13 ++++++-- 5 files changed, 42 insertions(+), 9 deletions(-) diff --git a/system/inc/system_setup.h b/system/inc/system_setup.h index 5529abe1f8..9d81d4e77e 100644 --- a/system/inc/system_setup.h +++ b/system/inc/system_setup.h @@ -92,6 +92,8 @@ template class SystemSetupConsole : public SystemSetupConsoleBa virtual void cleanup(); private: + void read_line_gracefully(char *dst, int max_len); + USBSerial serial; }; diff --git a/system/src/ble_provisioning_mode_handler.cpp b/system/src/ble_provisioning_mode_handler.cpp index 3999be8187..ee690873ff 100644 --- a/system/src/ble_provisioning_mode_handler.cpp +++ b/system/src/ble_provisioning_mode_handler.cpp @@ -344,6 +344,8 @@ int BleProvisioningModeHandler::exit() { // Do not allow other thread to modify the BLE configurations until this function exits. BleLock lk; + hal_ble_cancel_callback_on_adv_events(onBleAdvEvents, this, nullptr); + SCOPE_GUARD ({ preAdvData_.clear(); preSrData_.clear(); @@ -359,7 +361,6 @@ int BleProvisioningModeHandler::exit() { LOG(ERROR, "Failed to restore user configuration."); } } - hal_ble_cancel_callback_on_adv_events(onBleAdvEvents, this, nullptr); exited_ = true; return SYSTEM_ERROR_NONE; diff --git a/system/src/system_setup.cpp b/system/src/system_setup.cpp index 83a7bde499..9ed5a2a3b7 100644 --- a/system/src/system_setup.cpp +++ b/system/src/system_setup.cpp @@ -39,6 +39,9 @@ #include "system_ymodem.h" #include "mbedtls_util.h" #include "ota_flash_hal.h" +#include "system_threading.h" + +using namespace particle; #ifndef SETUP_LISTEN_MAGIC #define SETUP_LISTEN_MAGIC 0 @@ -324,9 +327,29 @@ template void SystemSetupConsole::print(const char *s) } } +template void SystemSetupConsole::read_line_gracefully(char *dst, int max_len) +{ + int total_len = 0; + do { + int len = 0; + if (serialReadLine(&serial, dst, max_len - total_len, 100, &len)) { + break; + } else { // timeout + total_len += len; + dst += len; + } +#if PLATFORM_THREADING + SystemISRTaskQueue.process(); + if (!APPLICATION_THREAD_CURRENT()) { + SystemThread.process(); + } +#endif + } while (1); +} + template void SystemSetupConsole::read_line(char *dst, int max_len) { - serialReadLine(&serial, dst, max_len, 0); //no timeout + read_line_gracefully(dst, max_len); //no timeout print("\r\n"); while (0 < serial.available()) serial.read(); @@ -337,7 +360,7 @@ template void SystemSetupConsole::read_multiline(char * char *ptr = dst; int len = max_len; while(len > 3) { - serialReadLine(&serial, ptr, len, 0); //no timeout + read_line_gracefully(ptr, len); //no timeout print("\r\n"); int l = strlen(ptr); len -= l; @@ -386,8 +409,8 @@ void WiFiSetupConsole::handle(char c) WLanCredentials creds; do { - print("SSID: "); - read_line(ssid, 32); + print("SSID: "); + read_line(ssid, 32); } while (strlen(ssid) == 0); wlan_scan([](WiFiAccessPoint* ap, void* ptr) { diff --git a/wiring/inc/spark_wiring.h b/wiring/inc/spark_wiring.h index 9841d18c91..379ec0c777 100644 --- a/wiring/inc/spark_wiring.h +++ b/wiring/inc/spark_wiring.h @@ -89,7 +89,7 @@ int pinSetDriveStrength(hal_pin_t pin, DriveStrength drive); void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val); uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder); -void serialReadLine(Stream *serialObj, char *dst, int max_len, system_tick_t timeout); +bool serialReadLine(Stream *serialObj, char *dst, int max_len, system_tick_t timeout, int* read_len = nullptr); uint32_t pulseIn(hal_pin_t pin, uint16_t value); diff --git a/wiring/src/spark_wiring_stream.cpp b/wiring/src/spark_wiring_stream.cpp index 6098c6c257..dcde7d75a2 100644 --- a/wiring/src/spark_wiring_stream.cpp +++ b/wiring/src/spark_wiring_stream.cpp @@ -279,17 +279,21 @@ String Stream::readStringUntil(char terminator) return ret; } -void serialReadLine(Stream *serialObj, char *dst, int max_len, system_tick_t timeout) +bool serialReadLine(Stream *serialObj, char *dst, int max_len, system_tick_t timeout, int* read_len) { char c = 0, i = 0; system_tick_t last_millis = millis(); + *read_len = 0; while (1) { if((timeout > 0) && ((millis()-last_millis) > timeout)) { //Abort after a specified timeout - break; + if (read_len) { + *read_len = i; + } + return false; } if (0 < serialObj->available()) @@ -299,7 +303,10 @@ void serialReadLine(Stream *serialObj, char *dst, int max_len, system_tick_t tim if (i == max_len || c == '\r' || c == '\n') { *dst = '\0'; - break; + if (read_len) { + *read_len = i; + } + return true; } if (c == 8 || c == 127) From 175224156d1afced1b19b096c9bb1d629d93c2f3 Mon Sep 17 00:00:00 2001 From: XuGuohui Date: Wed, 23 Nov 2022 16:28:59 +0800 Subject: [PATCH 087/112] resolve review comments. --- hal/src/rtl872x/ble_hal.cpp | 106 +++++++++++++++++++---------- system/inc/system_setup.h | 2 - system/src/system_setup.cpp | 28 +++----- wiring/inc/spark_wiring.h | 2 +- wiring/src/spark_wiring_stream.cpp | 19 +++--- 5 files changed, 91 insertions(+), 66 deletions(-) diff --git a/hal/src/rtl872x/ble_hal.cpp b/hal/src/rtl872x/ble_hal.cpp index 9ea9f15a33..2c7de39642 100644 --- a/hal/src/rtl872x/ble_hal.cpp +++ b/hal/src/rtl872x/ble_hal.cpp @@ -151,11 +151,10 @@ namespace { }) constexpr uint32_t BLE_OPERATION_TIMEOUT_MS = 60000; +constexpr system_tick_t BLE_ENQUEUE_TIMEOUT_MS = 5000; StaticRecursiveMutex s_bleMutex; -bool bleInLockedMode = false; - void rtwCoexRunDisable() { os_thread_scheduling(false, nullptr); auto p = pcoex[0]; @@ -247,7 +246,8 @@ class BleEventDispatcher { BleEventDispatcher() : thread_(nullptr), allEvtQueue_(nullptr), - ioEvtQueue_(nullptr) { + ioEvtQueue_(nullptr), + started_(false) { } ~BleEventDispatcher() = default; @@ -259,12 +259,12 @@ class BleEventDispatcher { void* thread_; void* allEvtQueue_; void* ioEvtQueue_; + bool started_; static constexpr uint8_t BLE_EVENT_THREAD_PRIORITY = 3; // Higher than application thread priority, which is 2 static constexpr uint8_t MAX_NUMBER_OF_GAP_MESSAGE = 0x20; static constexpr uint8_t MAX_NUMBER_OF_IO_MESSAGE = 0x20; static constexpr uint8_t MAX_NUMBER_OF_EVENT_MESSAGE = (MAX_NUMBER_OF_GAP_MESSAGE + MAX_NUMBER_OF_IO_MESSAGE); static constexpr uint8_t BLE_EVENT_STOP = 0xff; - static constexpr system_tick_t BLE_EVENT_SEND_TIMEOUT_MS = 5000; }; union RtlGapDevState { @@ -462,13 +462,21 @@ class BleGap { int enqueue(uint8_t cmd) { CHECK_TRUE(cmdQueue_, SYSTEM_ERROR_INVALID_STATE); - if (os_queue_put(cmdQueue_, &cmd, 0, nullptr)) { + if (os_queue_put(cmdQueue_, &cmd, BLE_ENQUEUE_TIMEOUT_MS, nullptr)) { LOG(ERROR, "os_queue_put() failed."); SPARK_ASSERT(false); } return SYSTEM_ERROR_NONE; } + void lockMode(bool lock) { + bleInLockedMode_ = lock; + } + + bool lockMode() { + return bleInLockedMode_; + } + static BleGap& getInstance() { static BleGap instance; return instance; @@ -488,6 +496,13 @@ class BleGap { BLE_PAIRING_STATE_PAIRED }; + enum BleGapCommand { + BLE_CMD_EXIT_THREAD, + BLE_CMD_STOP_ADV, + BLE_CMD_STOP_ADV_NOTIFY, + BLE_CMD_START_ADV + }; + struct BleConnection { hal_ble_conn_info_t info; std::pair handler; // It is used for central link only. @@ -519,7 +534,8 @@ class BleGap { devNameLen_(0), isAdvertising_(false), stateSemaphore_(nullptr), - pairingLesc_(false) { + pairingLesc_(false), + bleInLockedMode_(false) { advParams_.version = BLE_API_VERSION; advParams_.size = sizeof(hal_ble_adv_params_t); advParams_.interval = BLE_DEFAULT_ADVERTISING_INTERVAL; @@ -658,6 +674,7 @@ class BleGap { volatile bool isAdvertising_; os_semaphore_t stateSemaphore_; uint8_t pairingLesc_; + bool bleInLockedMode_; Vector advEventHandlers_; Mutex advEventMutex_; RecursiveMutex connectionsMutex_; @@ -668,11 +685,6 @@ class BleGap { static constexpr uint8_t BLE_CMD_THREAD_PRIORITY = 2; static constexpr uint16_t BLE_CMD_THREAD_STACK_SIZE = 2048; static constexpr uint8_t BLE_CMD_QUEUE_SIZE = 0x20; - - static constexpr uint8_t BLE_CMD_EXIT_THREAD = 0xff; - static constexpr uint8_t BLE_CMD_STOP_ADV = 0xfe; - static constexpr uint8_t BLE_CMD_STOP_ADV_NOTIFY = 0xfd; - static constexpr uint8_t BLE_CMD_START_ADV = 0xfc; }; @@ -855,46 +867,60 @@ class BleGatt { }; int BleEventDispatcher::start() { - if (thread_) { + if (started_) { // Already running return SYSTEM_ERROR_NONE; } - bool ok = false; SCOPE_GUARD({ - if (!ok) { + if (!started_) { cleanup(); } }); - CHECK_TRUE(os_msg_queue_create(&ioEvtQueue_, MAX_NUMBER_OF_IO_MESSAGE, sizeof(T_IO_MSG)), SYSTEM_ERROR_INTERNAL); - CHECK_TRUE(os_msg_queue_create(&allEvtQueue_, MAX_NUMBER_OF_EVENT_MESSAGE, sizeof(uint8_t)), SYSTEM_ERROR_INTERNAL); + if (!ioEvtQueue_) { + CHECK_TRUE(os_msg_queue_create(&ioEvtQueue_, MAX_NUMBER_OF_IO_MESSAGE, sizeof(T_IO_MSG)), SYSTEM_ERROR_INTERNAL); + } + if (!allEvtQueue_) { + CHECK_TRUE(os_msg_queue_create(&allEvtQueue_, MAX_NUMBER_OF_EVENT_MESSAGE, sizeof(uint8_t)), SYSTEM_ERROR_INTERNAL); + } if (!thread_) { CHECK_TRUE(os_thread_create(&thread_, "bleEvtThread", BLE_EVENT_THREAD_PRIORITY, bleEventDispatchThread, this, BLE_EVENT_THREAD_STACK_SIZE) == 0, SYSTEM_ERROR_INTERNAL); } CHECK_TRUE(gap_start_bt_stack(allEvtQueue_, ioEvtQueue_, MAX_NUMBER_OF_GAP_MESSAGE), SYSTEM_ERROR_INTERNAL); - ok = true; + started_ = true; return SYSTEM_ERROR_NONE; } int BleEventDispatcher::stop() { gap_start_bt_stack(nullptr, nullptr, 0); cleanup(); + started_ = false; return SYSTEM_ERROR_NONE; } void BleEventDispatcher::cleanup() { if (thread_ && allEvtQueue_ && !isThreadCurrent()) { uint8_t ev = BLE_EVENT_STOP; - SPARK_ASSERT(os_msg_send(allEvtQueue_, &ev, BLE_EVENT_SEND_TIMEOUT_MS)); + SPARK_ASSERT(os_msg_send(allEvtQueue_, &ev, BLE_ENQUEUE_TIMEOUT_MS)); os_thread_join(thread_); thread_ = nullptr; } if (allEvtQueue_) { - os_msg_queue_delete(allEvtQueue_); - allEvtQueue_ = nullptr; + if (!thread_) { + os_msg_queue_delete(allEvtQueue_); + allEvtQueue_ = nullptr; + } else { + uint8_t event; + while (os_msg_recv(allEvtQueue_, &event, 0) == true) {} + } } if (ioEvtQueue_) { - os_msg_queue_delete(ioEvtQueue_); - ioEvtQueue_ = nullptr; + if (!thread_) { + os_msg_queue_delete(ioEvtQueue_); + ioEvtQueue_ = nullptr; + } else { + T_IO_MSG message; + while (os_msg_recv(ioEvtQueue_, &message, 0) == true) {} + } } } @@ -1043,7 +1069,9 @@ int BleGap::init() { RCC_PeriphClockCmd(APBPeriph_UART1, APBPeriph_UART1_CLOCK, ENABLE); - CHECK_TRUE(os_msg_queue_create(&cmdQueue_, BLE_CMD_QUEUE_SIZE, sizeof(uint8_t)), SYSTEM_ERROR_INTERNAL); + if (!cmdQueue_) { + CHECK_TRUE(os_msg_queue_create(&cmdQueue_, BLE_CMD_QUEUE_SIZE, sizeof(uint8_t)), SYSTEM_ERROR_INTERNAL); + } if (!cmdThread_) { CHECK_TRUE(os_thread_create(&cmdThread_, "bleCommandThread", BLE_CMD_THREAD_PRIORITY, bleCommandThread, this, BLE_CMD_THREAD_STACK_SIZE) == 0, SYSTEM_ERROR_INTERNAL); } @@ -1170,6 +1198,7 @@ int BleGap::stop() { } } bte_deinit(); + // This shoulld be called after BT stack is stopped so that BLE events in queue can be safely cleared. BleEventDispatcher::getInstance().stop(); if (cmdThread_ && !os_thread_is_current(cmdThread_)) { @@ -1179,8 +1208,13 @@ int BleGap::stop() { } } if (cmdQueue_) { - os_queue_destroy(cmdQueue_, nullptr); - cmdQueue_ = nullptr; + if (!cmdThread_) { + os_queue_destroy(cmdQueue_, nullptr); + cmdQueue_ = nullptr; + } else { + uint8_t command; + while (!os_queue_take(cmdQueue_, &command, 0, nullptr)) {} + } } initialized_ = false; @@ -3389,12 +3423,12 @@ int hal_ble_unlock(void* reserved) { } int hal_ble_enter_locked_mode(void* reserved) { - bleInLockedMode = true; + BleGap::getInstance().lockMode(true); return SYSTEM_ERROR_NONE; } int hal_ble_exit_locked_mode(void* reserved) { - bleInLockedMode = false; + BleGap::getInstance().lockMode(false); return SYSTEM_ERROR_NONE; } @@ -3490,7 +3524,7 @@ int hal_ble_gap_set_ppcp(const hal_ble_conn_params_t* ppcp, void* reserved) { BleLock lk; LOG_DEBUG(TRACE, "hal_ble_gap_set_ppcp()."); CHECK_TRUE(BleGap::getInstance().initialized(), SYSTEM_ERROR_INVALID_STATE); - CHECK_FALSE(bleInLockedMode, SYSTEM_ERROR_INVALID_STATE); + CHECK_FALSE(BleGap::getInstance().lockMode(), SYSTEM_ERROR_INVALID_STATE); return BleGap::getInstance().setPpcp(ppcp); } @@ -3516,7 +3550,7 @@ int hal_ble_gap_delete_whitelist(void* reserved) { int hal_ble_gap_set_tx_power(int8_t tx_power, void* reserved) { BleLock lk; LOG_DEBUG(TRACE, "hal_ble_gap_set_tx_power()."); - CHECK_FALSE(bleInLockedMode, SYSTEM_ERROR_INVALID_STATE); + CHECK_FALSE(BleGap::getInstance().lockMode(), SYSTEM_ERROR_INVALID_STATE); return SYSTEM_ERROR_NONE; } @@ -3530,7 +3564,7 @@ int hal_ble_gap_set_advertising_parameters(const hal_ble_adv_params_t* adv_param BleLock lk; LOG_DEBUG(TRACE, "hal_ble_gap_set_advertising_parameters()."); CHECK_TRUE(BleGap::getInstance().initialized(), SYSTEM_ERROR_INVALID_STATE); - CHECK_FALSE(bleInLockedMode, SYSTEM_ERROR_INVALID_STATE); + CHECK_FALSE(BleGap::getInstance().lockMode(), SYSTEM_ERROR_INVALID_STATE); return BleGap::getInstance().setAdvertisingParameters(adv_params); } @@ -3545,7 +3579,7 @@ int hal_ble_gap_set_advertising_data(const uint8_t* buf, size_t len, void* reser BleLock lk; LOG_DEBUG(TRACE, "hal_ble_gap_set_advertising_data()."); CHECK_TRUE(BleGap::getInstance().initialized(), SYSTEM_ERROR_INVALID_STATE); - CHECK_FALSE(bleInLockedMode, SYSTEM_ERROR_INVALID_STATE); + CHECK_FALSE(BleGap::getInstance().lockMode(), SYSTEM_ERROR_INVALID_STATE); return BleGap::getInstance().setAdvertisingData(buf, len); } @@ -3560,7 +3594,7 @@ int hal_ble_gap_set_scan_response_data(const uint8_t* buf, size_t len, void* res BleLock lk; LOG_DEBUG(TRACE, "hal_ble_gap_set_scan_response_data()."); CHECK_TRUE(BleGap::getInstance().initialized(), SYSTEM_ERROR_INVALID_STATE); - CHECK_FALSE(bleInLockedMode, SYSTEM_ERROR_INVALID_STATE); + CHECK_FALSE(BleGap::getInstance().lockMode(), SYSTEM_ERROR_INVALID_STATE); return BleGap::getInstance().setScanResponseData(buf, len); } @@ -3581,7 +3615,7 @@ int hal_ble_gap_start_advertising(void* reserved) { int hal_ble_gap_set_auto_advertise(hal_ble_auto_adv_cfg_t config, void* reserved) { BleLock lk; LOG_DEBUG(TRACE, "hal_ble_gap_set_auto_advertise()."); - CHECK_FALSE(bleInLockedMode, SYSTEM_ERROR_INVALID_STATE); + CHECK_FALSE(BleGap::getInstance().lockMode(), SYSTEM_ERROR_INVALID_STATE); return SYSTEM_ERROR_NONE; } @@ -3595,7 +3629,7 @@ int hal_ble_gap_stop_advertising(void* reserved) { BleLock lk; LOG_DEBUG(TRACE, "hal_ble_gap_stop_advertising()."); CHECK_TRUE(BleGap::getInstance().initialized(), SYSTEM_ERROR_INVALID_STATE); - CHECK_FALSE(bleInLockedMode, SYSTEM_ERROR_INVALID_STATE); + CHECK_FALSE(BleGap::getInstance().lockMode(), SYSTEM_ERROR_INVALID_STATE); return BleGap::getInstance().stopAdvertising(); } @@ -3670,7 +3704,7 @@ int hal_ble_gap_disconnect(hal_ble_conn_handle_t conn_handle, void* reserved) { CHECK_TRUE(BleGap::getInstance().initialized(), SYSTEM_ERROR_INVALID_STATE); hal_ble_conn_info_t info = {}; CHECK(BleGap::getInstance().getConnectionInfo(conn_handle, &info)); - CHECK_FALSE(bleInLockedMode && info.role == BLE_ROLE_PERIPHERAL, SYSTEM_ERROR_INVALID_STATE); + CHECK_FALSE(BleGap::getInstance().lockMode() && info.role == BLE_ROLE_PERIPHERAL, SYSTEM_ERROR_INVALID_STATE); return BleGap::getInstance().disconnect(conn_handle); } @@ -3679,7 +3713,7 @@ int hal_ble_gap_update_connection_params(hal_ble_conn_handle_t conn_handle, cons LOG_DEBUG(TRACE, "hal_ble_gap_update_connection_params()."); hal_ble_conn_info_t info = {}; CHECK(BleGap::getInstance().getConnectionInfo(conn_handle, &info)); - CHECK_FALSE(bleInLockedMode && info.role == BLE_ROLE_PERIPHERAL, SYSTEM_ERROR_INVALID_STATE); + CHECK_FALSE(BleGap::getInstance().lockMode() && info.role == BLE_ROLE_PERIPHERAL, SYSTEM_ERROR_INVALID_STATE); return SYSTEM_ERROR_NOT_SUPPORTED; } diff --git a/system/inc/system_setup.h b/system/inc/system_setup.h index 9d81d4e77e..5529abe1f8 100644 --- a/system/inc/system_setup.h +++ b/system/inc/system_setup.h @@ -92,8 +92,6 @@ template class SystemSetupConsole : public SystemSetupConsoleBa virtual void cleanup(); private: - void read_line_gracefully(char *dst, int max_len); - USBSerial serial; }; diff --git a/system/src/system_setup.cpp b/system/src/system_setup.cpp index 9ed5a2a3b7..c29bec3843 100644 --- a/system/src/system_setup.cpp +++ b/system/src/system_setup.cpp @@ -327,29 +327,16 @@ template void SystemSetupConsole::print(const char *s) } } -template void SystemSetupConsole::read_line_gracefully(char *dst, int max_len) +template void SystemSetupConsole::read_line(char *dst, int max_len) { - int total_len = 0; - do { - int len = 0; - if (serialReadLine(&serial, dst, max_len - total_len, 100, &len)) { - break; - } else { // timeout - total_len += len; - dst += len; - } + serialReadLine(&serial, dst, max_len, 0/*no timeout*/, [](int count) -> void { #if PLATFORM_THREADING SystemISRTaskQueue.process(); if (!APPLICATION_THREAD_CURRENT()) { SystemThread.process(); } #endif - } while (1); -} - -template void SystemSetupConsole::read_line(char *dst, int max_len) -{ - read_line_gracefully(dst, max_len); //no timeout + }); print("\r\n"); while (0 < serial.available()) serial.read(); @@ -360,7 +347,14 @@ template void SystemSetupConsole::read_multiline(char * char *ptr = dst; int len = max_len; while(len > 3) { - read_line_gracefully(ptr, len); //no timeout + serialReadLine(&serial, ptr, len, 0/*no timeout*/, [](int count) -> void { +#if PLATFORM_THREADING + SystemISRTaskQueue.process(); + if (!APPLICATION_THREAD_CURRENT()) { + SystemThread.process(); + } +#endif + }); print("\r\n"); int l = strlen(ptr); len -= l; diff --git a/wiring/inc/spark_wiring.h b/wiring/inc/spark_wiring.h index 379ec0c777..99f3a1a92c 100644 --- a/wiring/inc/spark_wiring.h +++ b/wiring/inc/spark_wiring.h @@ -89,7 +89,7 @@ int pinSetDriveStrength(hal_pin_t pin, DriveStrength drive); void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val); uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder); -bool serialReadLine(Stream *serialObj, char *dst, int max_len, system_tick_t timeout, int* read_len = nullptr); +void serialReadLine(Stream *serialObj, char *dst, int max_len, system_tick_t timeout, void(*idle_cb)(int count) = nullptr); uint32_t pulseIn(hal_pin_t pin, uint16_t value); diff --git a/wiring/src/spark_wiring_stream.cpp b/wiring/src/spark_wiring_stream.cpp index dcde7d75a2..677479d919 100644 --- a/wiring/src/spark_wiring_stream.cpp +++ b/wiring/src/spark_wiring_stream.cpp @@ -279,21 +279,23 @@ String Stream::readStringUntil(char terminator) return ret; } -bool serialReadLine(Stream *serialObj, char *dst, int max_len, system_tick_t timeout, int* read_len) +void serialReadLine(Stream *serialObj, char *dst, int max_len, system_tick_t timeout, void(*idle_cb)(int count)) { char c = 0, i = 0; system_tick_t last_millis = millis(); - *read_len = 0; + system_tick_t cb_millis = last_millis; while (1) { if((timeout > 0) && ((millis()-last_millis) > timeout)) { //Abort after a specified timeout - if (read_len) { - *read_len = i; - } - return false; + break; + } + + if ((millis()-cb_millis) > 100 && idle_cb) { + idle_cb(i); + cb_millis = millis(); } if (0 < serialObj->available()) @@ -303,10 +305,7 @@ bool serialReadLine(Stream *serialObj, char *dst, int max_len, system_tick_t tim if (i == max_len || c == '\r' || c == '\n') { *dst = '\0'; - if (read_len) { - *read_len = i; - } - return true; + break; } if (c == 8 || c == 127) From 09245396310b237f94230a3e437880a69d121971 Mon Sep 17 00:00:00 2001 From: Todd Stellanova Date: Thu, 13 Oct 2022 10:09:05 -0700 Subject: [PATCH 088/112] initial support for BG95-M6 modem --- .../ncp_client/quectel/quectel_ncp_client.cpp | 19 ++++++++++++++----- .../ncp_client/quectel/quectel_ncp_client.h | 2 ++ hal/shared/cellular_enums_hal.h | 4 +++- hal/shared/cellular_ncp_dev_mapping.h | 3 +++ hal/shared/platform_ncp.h | 1 + hal/src/b5som/platform_ncp_quectel.cpp | 1 + hal/src/tracker/platform_ncp_quectel.cpp | 1 + hal/src/trackerm/platform_ncp_quectel.cpp | 2 ++ 8 files changed, 27 insertions(+), 6 deletions(-) diff --git a/hal/network/ncp_client/quectel/quectel_ncp_client.cpp b/hal/network/ncp_client/quectel/quectel_ncp_client.cpp index c129504bf5..2a73a0b1a3 100644 --- a/hal/network/ncp_client/quectel/quectel_ncp_client.cpp +++ b/hal/network/ncp_client/quectel/quectel_ncp_client.cpp @@ -1026,6 +1026,7 @@ int QuectelNcpClient::changeBaudRate(unsigned int baud) { bool QuectelNcpClient::isQuecCatM1Device() { int ncp_id = ncpId(); return (ncp_id == PLATFORM_NCP_QUECTEL_BG96 || + ncp_id == PLATFORM_NCP_QUECTEL_BG95_M6 || ncp_id == PLATFORM_NCP_QUECTEL_BG95_M1 || ncp_id == PLATFORM_NCP_QUECTEL_BG95_MF || ncp_id == PLATFORM_NCP_QUECTEL_BG77) ; @@ -1039,6 +1040,14 @@ bool QuectelNcpClient::isQuecCat1Device() { ncp_id == PLATFORM_NCP_QUECTEL_EG91_NAX); } +bool QuectelNcpClient::isQuecLPWADevice() { + int ncp_id = ncpId(); + return (ncp_id == PLATFORM_NCP_QUECTEL_BG95_M6 || + ncp_id == PLATFORM_NCP_QUECTEL_BG95_M1 || + ncp_id == PLATFORM_NCP_QUECTEL_BG95_MF || + ncp_id == PLATFORM_NCP_QUECTEL_BG77) ; +} + int QuectelNcpClient::initReady(ModemState state) { // Set modem full functionality int r = CHECK_PARSER(parser_.execCommand("AT+CFUN=1,0")); @@ -1365,7 +1374,7 @@ int QuectelNcpClient::registerNet() { } } - if (ncpId() != PLATFORM_NCP_QUECTEL_BG95_M1) { + if (!isQuecLPWADevice()) { // Configure Network Category to be searched // Set to use LTE Cat M1 if not already set, take effect immediately auto respOpMode = parser_.sendCommand("AT+QCFG=\"iotopmode\"") ; @@ -1796,7 +1805,7 @@ int QuectelNcpClient::processEventsImpl() { SCOPE_GUARD({ regCheckTime_ = millis(); }); // Check GPRS, LET, NB-IOT network registration status - if (ncpId() != PLATFORM_NCP_QUECTEL_BG95_M1) { + if (!isQuecLPWADevice()) { CHECK_PARSER(parser_.execCommand("AT+CEER")); // Seems to stall the modem on BG95-MF CHECK_PARSER(parser_.execCommand("AT+CMEE?")); // Seems to stall the modem on BG95-MF CHECK_PARSER_OK(parser_.execCommand("AT+CREG?")); @@ -1884,7 +1893,7 @@ int QuectelNcpClient::modemPowerOn() { if (!modemPowerState()) { ncpPowerState(NcpPowerState::TRANSIENT_ON); - if (ncpId() != PLATFORM_NCP_QUECTEL_BG95_M1 && ncpId() != PLATFORM_NCP_QUECTEL_BG95_MF) { + if (!isQuecLPWADevice()) { // Power on, power on pulse >= 100ms // NOTE: The BGPWR pin is inverted hal_gpio_write(BGPWR, 1); @@ -1925,7 +1934,7 @@ int QuectelNcpClient::modemPowerOff() { LOG(TRACE, "Powering modem off"); - if (ncpId() != PLATFORM_NCP_QUECTEL_BG95_M1 && ncpId() != PLATFORM_NCP_QUECTEL_BG95_MF) { + if (!isQuecLPWADevice()) { // Power off, power off pulse >= 650ms // NOTE: The BGRST pin is inverted hal_gpio_write(BGPWR, 1); @@ -1998,7 +2007,7 @@ int QuectelNcpClient::modemSoftPowerOff() { int QuectelNcpClient::modemHardReset(bool powerOff) { LOG(TRACE, "Hard resetting the modem"); - if (ncpId() != PLATFORM_NCP_QUECTEL_BG95_M1 && ncpId() != PLATFORM_NCP_QUECTEL_BG95_MF) { + if (!isQuecLPWADevice()) { // BG96 reset, 150ms <= reset pulse <= 460ms // NOTE: The BGRST pin is inverted hal_gpio_write(BGRST, 1); diff --git a/hal/network/ncp_client/quectel/quectel_ncp_client.h b/hal/network/ncp_client/quectel/quectel_ncp_client.h index cdd23e8733..1485429265 100644 --- a/hal/network/ncp_client/quectel/quectel_ncp_client.h +++ b/hal/network/ncp_client/quectel/quectel_ncp_client.h @@ -147,6 +147,8 @@ class QuectelNcpClient: public CellularNcpClient { bool isQuecCatM1Device(); /** Is this a Quectel CAT-1 devices ? */ bool isQuecCat1Device(); + /** Is this device part of the Quectel LPWA series? */ + bool isQuecLPWADevice(); int modemInit() const; bool waitModemPowerState(bool onOff, system_tick_t timeout); int modemPowerOn(); diff --git a/hal/shared/cellular_enums_hal.h b/hal/shared/cellular_enums_hal.h index f6e8ed363e..ac15db2029 100644 --- a/hal/shared/cellular_enums_hal.h +++ b/hal/shared/cellular_enums_hal.h @@ -46,7 +46,9 @@ typedef enum { DEV_QUECTEL_BG95_M1 = 14, DEV_QUECTEL_EG91_NAX = 15, DEV_QUECTEL_BG77 = 16, - DEV_QUECTEL_BG95_MF = 17 + DEV_QUECTEL_BG95_MF = 17, + DEV_QUECTEL_BG95_M6 = 18 + } Dev; //! SIM Status typedef enum { diff --git a/hal/shared/cellular_ncp_dev_mapping.h b/hal/shared/cellular_ncp_dev_mapping.h index d6b1e5cc31..262f8a3bcd 100644 --- a/hal/shared/cellular_ncp_dev_mapping.h +++ b/hal/shared/cellular_ncp_dev_mapping.h @@ -59,6 +59,9 @@ inline Dev cellular_dev_from_ncp(PlatformNCPIdentifier identifer) { case PLATFORM_NCP_QUECTEL_BG77: device = DEV_QUECTEL_BG77; break; + case PLATFORM_NCP_QUECTEL_BG95_M6: + device = DEV_QUECTEL_BG95_M6; + break; default: device = DEV_UNKNOWN; break; diff --git a/hal/shared/platform_ncp.h b/hal/shared/platform_ncp.h index 93c5304908..250e67c246 100644 --- a/hal/shared/platform_ncp.h +++ b/hal/shared/platform_ncp.h @@ -61,6 +61,7 @@ typedef enum PlatformNCPIdentifier { PLATFORM_NCP_QUECTEL_EG91_NAX = PLATFORM_NCP_IDENTIFIER(PLATFORM_NCP_MANUFACTURER_QUECTEL, 6), PLATFORM_NCP_QUECTEL_BG77 = PLATFORM_NCP_IDENTIFIER(PLATFORM_NCP_MANUFACTURER_QUECTEL, 7), PLATFORM_NCP_QUECTEL_BG95_MF = PLATFORM_NCP_IDENTIFIER(PLATFORM_NCP_MANUFACTURER_QUECTEL, 8), + PLATFORM_NCP_QUECTEL_BG95_M6 = PLATFORM_NCP_IDENTIFIER(PLATFORM_NCP_MANUFACTURER_QUECTEL, 9), // 0x8x PLATFORM_NCP_BROADCOM_BCM9WCDUSI09 = PLATFORM_NCP_IDENTIFIER(PLATFORM_NCP_MANUFACTURER_BROADCOM, 1), diff --git a/hal/src/b5som/platform_ncp_quectel.cpp b/hal/src/b5som/platform_ncp_quectel.cpp index 06908129e3..cf3d890e35 100644 --- a/hal/src/b5som/platform_ncp_quectel.cpp +++ b/hal/src/b5som/platform_ncp_quectel.cpp @@ -34,6 +34,7 @@ bool isValidNcpId(uint8_t id) { case PlatformNCPIdentifier::PLATFORM_NCP_QUECTEL_BG95_MF: case PlatformNCPIdentifier::PLATFORM_NCP_QUECTEL_EG91_NAX: case PlatformNCPIdentifier::PLATFORM_NCP_QUECTEL_BG77: + case PlatformNCPIdentifier::PLATFORM_NCP_QUECTEL_BG95_M6: return true; default: return false; diff --git a/hal/src/tracker/platform_ncp_quectel.cpp b/hal/src/tracker/platform_ncp_quectel.cpp index 91e1abdafc..f9b191905e 100644 --- a/hal/src/tracker/platform_ncp_quectel.cpp +++ b/hal/src/tracker/platform_ncp_quectel.cpp @@ -35,6 +35,7 @@ bool isValidNcpId(uint8_t id) { case PlatformNCPIdentifier::PLATFORM_NCP_QUECTEL_BG95_MF: case PlatformNCPIdentifier::PLATFORM_NCP_QUECTEL_EG91_NAX: case PlatformNCPIdentifier::PLATFORM_NCP_QUECTEL_BG77: + case PlatformNCPIdentifier::PLATFORM_NCP_QUECTEL_BG95_M6: return true; default: return false; diff --git a/hal/src/trackerm/platform_ncp_quectel.cpp b/hal/src/trackerm/platform_ncp_quectel.cpp index 2fffa740a4..49dc109918 100644 --- a/hal/src/trackerm/platform_ncp_quectel.cpp +++ b/hal/src/trackerm/platform_ncp_quectel.cpp @@ -36,6 +36,8 @@ bool isValidNcpId(uint8_t id) { case PlatformNCPIdentifier::PLATFORM_NCP_QUECTEL_EG91_NA: case PlatformNCPIdentifier::PLATFORM_NCP_QUECTEL_EG91_EX: case PlatformNCPIdentifier::PLATFORM_NCP_QUECTEL_BG95_M1: + case PlatformNCPIdentifier::PLATFORM_NCP_QUECTEL_BG77: + case PlatformNCPIdentifier::PLATFORM_NCP_QUECTEL_BG95_M6: return true; default: return false; From 807375997452933501fee1bbd3cacc33881bfaff Mon Sep 17 00:00:00 2001 From: Todd Stellanova Date: Fri, 14 Oct 2022 12:58:56 -0700 Subject: [PATCH 089/112] only exclude GPRS +CEER call --- .../ncp_client/quectel/quectel_ncp_client.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/hal/network/ncp_client/quectel/quectel_ncp_client.cpp b/hal/network/ncp_client/quectel/quectel_ncp_client.cpp index 2a73a0b1a3..39db42053d 100644 --- a/hal/network/ncp_client/quectel/quectel_ncp_client.cpp +++ b/hal/network/ncp_client/quectel/quectel_ncp_client.cpp @@ -1804,13 +1804,17 @@ int QuectelNcpClient::processEventsImpl() { } SCOPE_GUARD({ regCheckTime_ = millis(); }); - // Check GPRS, LET, NB-IOT network registration status + // Check GPRS network registration status if (!isQuecLPWADevice()) { - CHECK_PARSER(parser_.execCommand("AT+CEER")); // Seems to stall the modem on BG95-MF - CHECK_PARSER(parser_.execCommand("AT+CMEE?")); // Seems to stall the modem on BG95-MF - CHECK_PARSER_OK(parser_.execCommand("AT+CREG?")); + // only BG95-M3 and BG95-M5 have GPRS, neither of which we support currently + CHECK_PARSER(parser_.execCommand("AT+CEER")); // GPRS only } - //CHECK_PARSER_OK(parser_.execCommand("AT+CGREG?")); + + // Check NBIoT or LTE network reg status + CHECK_PARSER(parser_.execCommand("AT+CMEE?")); + CHECK_PARSER_OK(parser_.execCommand("AT+CREG?")); + + CHECK_PARSER_OK(parser_.execCommand("AT+CEREG?")); // Check the signal seen by the module while trying to register // Do not need to check for an OK, as this is just for debugging purpose From 26c0863f680775f11a3a6f8c272e94e19ec2053e Mon Sep 17 00:00:00 2001 From: Technobly Date: Mon, 28 Nov 2022 16:13:36 -0600 Subject: [PATCH 090/112] final cleanup for BG95-M6 support --- .../ncp_client/quectel/quectel_ncp_client.cpp | 112 ++++++++++-------- .../ncp_client/quectel/quectel_ncp_client.h | 10 +- 2 files changed, 67 insertions(+), 55 deletions(-) diff --git a/hal/network/ncp_client/quectel/quectel_ncp_client.cpp b/hal/network/ncp_client/quectel/quectel_ncp_client.cpp index 39db42053d..48fe8fdbf2 100644 --- a/hal/network/ncp_client/quectel/quectel_ncp_client.cpp +++ b/hal/network/ncp_client/quectel/quectel_ncp_client.cpp @@ -1040,14 +1040,20 @@ bool QuectelNcpClient::isQuecCat1Device() { ncp_id == PLATFORM_NCP_QUECTEL_EG91_NAX); } -bool QuectelNcpClient::isQuecLPWADevice() { +bool QuectelNcpClient::isQuecCatNBxDevice() { int ncp_id = ncpId(); return (ncp_id == PLATFORM_NCP_QUECTEL_BG95_M6 || - ncp_id == PLATFORM_NCP_QUECTEL_BG95_M1 || ncp_id == PLATFORM_NCP_QUECTEL_BG95_MF || ncp_id == PLATFORM_NCP_QUECTEL_BG77) ; } +bool QuectelNcpClient::isQuecBG95xDevice() { + int ncp_id = ncpId(); + return (ncp_id == PLATFORM_NCP_QUECTEL_BG95_M6 || + ncp_id == PLATFORM_NCP_QUECTEL_BG95_M1 || + ncp_id == PLATFORM_NCP_QUECTEL_BG95_MF) ; +} + int QuectelNcpClient::initReady(ModemState state) { // Set modem full functionality int r = CHECK_PARSER(parser_.execCommand("AT+CFUN=1,0")); @@ -1361,6 +1367,7 @@ int QuectelNcpClient::registerNet() { if (isQuecCatM1Device()) { if (ncpId() == PLATFORM_NCP_QUECTEL_BG96) { + // NOTE: BG96 supports 2G fallback which we disable explicitly so that a 10W power supply is not required // Configure RATs to be searched // Set to scan LTE only if not already set, take effect immediately auto respNwMode = parser_.sendCommand("AT+QCFG=\"nwscanmode\""); @@ -1374,9 +1381,9 @@ int QuectelNcpClient::registerNet() { } } - if (!isQuecLPWADevice()) { + if (isQuecCatNBxDevice()) { // Configure Network Category to be searched - // Set to use LTE Cat M1 if not already set, take effect immediately + // Set to use LTE Cat-M1 ONLY if not already set, take effect immediately auto respOpMode = parser_.sendCommand("AT+QCFG=\"iotopmode\"") ; int iotOpMode = -1; @@ -1390,12 +1397,12 @@ int QuectelNcpClient::registerNet() { } } } - + // Check GSM, GPRS, and LTE network registration status + CHECK_PARSER_OK(parser_.execCommand("AT+CEREG?")); if (isQuecCat1Device()) { CHECK_PARSER_OK(parser_.execCommand("AT+CREG?")); CHECK_PARSER_OK(parser_.execCommand("AT+CGREG?")); } - CHECK_PARSER_OK(parser_.execCommand("AT+CEREG?")); regStartTime_ = millis(); regCheckTime_ = regStartTime_; @@ -1804,18 +1811,21 @@ int QuectelNcpClient::processEventsImpl() { } SCOPE_GUARD({ regCheckTime_ = millis(); }); - // Check GPRS network registration status - if (!isQuecLPWADevice()) { - // only BG95-M3 and BG95-M5 have GPRS, neither of which we support currently - CHECK_PARSER(parser_.execCommand("AT+CEER")); // GPRS only + // Log extended errors for modems that support AT+CEER + if (isQuecCat1Device()) { + CHECK_PARSER(parser_.execCommand("AT+CEER")); } - - // Check NBIoT or LTE network reg status - CHECK_PARSER(parser_.execCommand("AT+CMEE?")); - CHECK_PARSER_OK(parser_.execCommand("AT+CREG?")); + // Log error level (will be factory default) + // CHECK_PARSER(parser_.execCommand("AT+CMEE?")); + // Check GSM, GPRS, and LTE network registration status CHECK_PARSER_OK(parser_.execCommand("AT+CEREG?")); + if (isQuecCat1Device()) { + CHECK_PARSER_OK(parser_.execCommand("AT+CREG?")); + CHECK_PARSER_OK(parser_.execCommand("AT+CGREG?")); + } + // Check the signal seen by the module while trying to register // Do not need to check for an OK, as this is just for debugging purpose CHECK_PARSER(parser_.execCommand("AT+QCSQ")); @@ -1866,7 +1876,7 @@ int QuectelNcpClient::modemInit() const { // DTR=0: normal mode, DTR=1: sleep mode // NOTE: The BGDTR pins is inverted - conf.value = 1; + conf.value = 1; CHECK(hal_gpio_configure(BGDTR, &conf, nullptr)); LOG(TRACE, "Modem low level initialization OK"); @@ -1897,26 +1907,26 @@ int QuectelNcpClient::modemPowerOn() { if (!modemPowerState()) { ncpPowerState(NcpPowerState::TRANSIENT_ON); - if (!isQuecLPWADevice()) { - // Power on, power on pulse >= 100ms - // NOTE: The BGPWR pin is inverted - hal_gpio_write(BGPWR, 1); - HAL_Delay_Milliseconds(200); - hal_gpio_write(BGPWR, 0); - } else { - // Power on, power on pulse 500ms - 1000ms - // XXX: Keeping it halfway between 500ms and 650ms, to avoid the power OFF timing of >=650ms - // NOTE: The BGPWR pin is inverted - hal_gpio_write(BGPWR, 1); - HAL_Delay_Milliseconds(575); - hal_gpio_write(BGPWR, 0); - } + // EG91, BG96, BG95, BG77: Power on, power on pulse 500ms - 1000ms + // XXX: Keeping it halfway between 500ms and 650ms, to avoid the power OFF timing of >=650ms + // NOTE: The BGPWR pin is inverted + hal_gpio_write(BGPWR, 1); + HAL_Delay_Milliseconds(575); + hal_gpio_write(BGPWR, 0); // After power on the device, we can't assume the device is ready for operation: - // BG95: status pin ready requires >= 2.1s, uart ready requires >= 2.5s + // BG95/BG77: status pin ready requires >= 2.1s, uart ready requires >= 2.5s // BG96: status pin ready requires >= 4.8s, uart ready requires >= 4.9s // EG91: status pin ready requires >= 10s, uart ready requires >= 12s - if (waitModemPowerState(1, 15000)) { + // Wait 3 seconds longer than minimum spec + int ncp_id = ncpId(); + system_tick_t powerOffWaitMs = 15000; // EG91 + if (isQuecBG95xDevice() || ncp_id == PLATFORM_NCP_QUECTEL_BG77) { + powerOffWaitMs = 5500; // BG95/BG77 + } else if (ncp_id == PLATFORM_NCP_QUECTEL_BG96) { + powerOffWaitMs = 7900; // BG96 + } + if (waitModemPowerState(1, powerOffWaitMs)) { LOG(TRACE, "Modem powered on"); } else { LOG(ERROR, "Failed to power on modem, try hard reset"); @@ -1938,25 +1948,25 @@ int QuectelNcpClient::modemPowerOff() { LOG(TRACE, "Powering modem off"); - if (!isQuecLPWADevice()) { - // Power off, power off pulse >= 650ms - // NOTE: The BGRST pin is inverted - hal_gpio_write(BGPWR, 1); - HAL_Delay_Milliseconds(650); - hal_gpio_write(BGPWR, 0); - } else { - // Power off, power off pulse >= 650ms - // NOTE: The BGRST pin is inverted - hal_gpio_write(BGPWR, 1); - HAL_Delay_Milliseconds(650); - hal_gpio_write(BGPWR, 0); - } + // Power off, power off pulse >= 650ms + // NOTE: The BGRST pin is inverted + hal_gpio_write(BGPWR, 1); + HAL_Delay_Milliseconds(650); + hal_gpio_write(BGPWR, 0); // Verify that the module was powered down by checking the status pin (BGVINT) - // BG95: >=1.3s + // BG95/BG77: >=1.3s // BG96: >=2s // EG91: >=30s - if (waitModemPowerState(0, 30000)) { + // Wait 3 seconds longer than minimum spec + int ncp_id = ncpId(); + system_tick_t powerOnWaitMs = 33000; // EG91 + if (isQuecBG95xDevice() || ncp_id == PLATFORM_NCP_QUECTEL_BG77) { + powerOnWaitMs = 4300; // BG95/BG77 + } else if (ncp_id == PLATFORM_NCP_QUECTEL_BG96) { + powerOnWaitMs = 5000; // BG96 + } + if (waitModemPowerState(0, powerOnWaitMs)) { LOG(TRACE, "Modem powered off"); } else { LOG(ERROR, "Failed to power off modem, try hard reset"); @@ -2011,17 +2021,17 @@ int QuectelNcpClient::modemSoftPowerOff() { int QuectelNcpClient::modemHardReset(bool powerOff) { LOG(TRACE, "Hard resetting the modem"); - if (!isQuecLPWADevice()) { - // BG96 reset, 150ms <= reset pulse <= 460ms + if (isQuecBG95xDevice() || ncpId() == PLATFORM_NCP_QUECTEL_BG77) { + // BG95/BG77 reset, 2s <= reset pulse <= 3.8s // NOTE: The BGRST pin is inverted hal_gpio_write(BGRST, 1); - HAL_Delay_Milliseconds(400); + HAL_Delay_Milliseconds(2900); hal_gpio_write(BGRST, 0); } else { - // BG95 reset, 2s <= reset pulse <= 3.8s + // BG96/EG91 reset, 150ms <= reset pulse <= 460ms // NOTE: The BGRST pin is inverted hal_gpio_write(BGRST, 1); - HAL_Delay_Milliseconds(2900); + HAL_Delay_Milliseconds(400); hal_gpio_write(BGRST, 0); } diff --git a/hal/network/ncp_client/quectel/quectel_ncp_client.h b/hal/network/ncp_client/quectel/quectel_ncp_client.h index 1485429265..75b0b0cf4d 100644 --- a/hal/network/ncp_client/quectel/quectel_ncp_client.h +++ b/hal/network/ncp_client/quectel/quectel_ncp_client.h @@ -143,12 +143,14 @@ class QuectelNcpClient: public CellularNcpClient { int checkRunningImsi(); int processEventsImpl(); int getIccidImpl(char* buf, size_t size); - /** Is this a Quectel CAT-M1 device ? */ + /** Is this a Quectel Cat-M1 device ? */ bool isQuecCatM1Device(); - /** Is this a Quectel CAT-1 devices ? */ + /** Is this a Quectel Cat-1 device ? */ bool isQuecCat1Device(); - /** Is this device part of the Quectel LPWA series? */ - bool isQuecLPWADevice(); + /** Is this a Quectel Cat-NB1/Cat-NB2 device ? */ + bool isQuecCatNBxDevice(); + /** Is this a Quectel BG95* device ? */ + bool isQuecBG95xDevice(); int modemInit() const; bool waitModemPowerState(bool onOff, system_tick_t timeout); int modemPowerOn(); From bee7ca9ccee36be591bc013c35fd195eb0d22c0d Mon Sep 17 00:00:00 2001 From: Technobly Date: Tue, 29 Nov 2022 10:54:45 -0600 Subject: [PATCH 091/112] minor --- hal/network/ncp_client/quectel/quectel_ncp_client.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/hal/network/ncp_client/quectel/quectel_ncp_client.cpp b/hal/network/ncp_client/quectel/quectel_ncp_client.cpp index 48fe8fdbf2..574c4102e6 100644 --- a/hal/network/ncp_client/quectel/quectel_ncp_client.cpp +++ b/hal/network/ncp_client/quectel/quectel_ncp_client.cpp @@ -1919,11 +1919,10 @@ int QuectelNcpClient::modemPowerOn() { // BG96: status pin ready requires >= 4.8s, uart ready requires >= 4.9s // EG91: status pin ready requires >= 10s, uart ready requires >= 12s // Wait 3 seconds longer than minimum spec - int ncp_id = ncpId(); system_tick_t powerOffWaitMs = 15000; // EG91 - if (isQuecBG95xDevice() || ncp_id == PLATFORM_NCP_QUECTEL_BG77) { + if (isQuecBG95xDevice() || ncpId() == PLATFORM_NCP_QUECTEL_BG77) { powerOffWaitMs = 5500; // BG95/BG77 - } else if (ncp_id == PLATFORM_NCP_QUECTEL_BG96) { + } else if (ncpId() == PLATFORM_NCP_QUECTEL_BG96) { powerOffWaitMs = 7900; // BG96 } if (waitModemPowerState(1, powerOffWaitMs)) { @@ -1959,11 +1958,10 @@ int QuectelNcpClient::modemPowerOff() { // BG96: >=2s // EG91: >=30s // Wait 3 seconds longer than minimum spec - int ncp_id = ncpId(); system_tick_t powerOnWaitMs = 33000; // EG91 - if (isQuecBG95xDevice() || ncp_id == PLATFORM_NCP_QUECTEL_BG77) { + if (isQuecBG95xDevice() || ncpId() == PLATFORM_NCP_QUECTEL_BG77) { powerOnWaitMs = 4300; // BG95/BG77 - } else if (ncp_id == PLATFORM_NCP_QUECTEL_BG96) { + } else if (ncpId() == PLATFORM_NCP_QUECTEL_BG96) { powerOnWaitMs = 5000; // BG96 } if (waitModemPowerState(0, powerOnWaitMs)) { From 5931e339c85bbe2677d359d78cf38282c53252e8 Mon Sep 17 00:00:00 2001 From: Technobly Date: Tue, 29 Nov 2022 23:30:02 -0600 Subject: [PATCH 092/112] [freertos] checkout particle branch --- third_party/freertos/freertos | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/freertos/freertos b/third_party/freertos/freertos index 44381d9eb6..ffaf90692d 160000 --- a/third_party/freertos/freertos +++ b/third_party/freertos/freertos @@ -1 +1 @@ -Subproject commit 44381d9eb60d4c2461ffcbf4fa3a13724444f1f9 +Subproject commit ffaf90692d78d53b6c867dda8de1b4d605e72bd3 From 329aa095031a7b8ba02b3e1fdf4b23cad1828245 Mon Sep 17 00:00:00 2001 From: Andrey Tolstoy Date: Thu, 1 Dec 2022 03:30:11 +0700 Subject: [PATCH 093/112] [rtl872x] hal: remove an assert in read()/peek() and instead adjust read/peek size --- hal/src/rtl872x/usart_hal.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/hal/src/rtl872x/usart_hal.cpp b/hal/src/rtl872x/usart_hal.cpp index 8aa3df9b98..029bb7af20 100644 --- a/hal/src/rtl872x/usart_hal.cpp +++ b/hal/src/rtl872x/usart_hal.cpp @@ -391,13 +391,16 @@ class Usart { ssize_t read(uint8_t* buffer, size_t size) { CHECK_TRUE(isEnabled(), SYSTEM_ERROR_INVALID_STATE); const ssize_t maxRead = CHECK(data()); - const ssize_t readSize = std::min((size_t)maxRead, size); + ssize_t readSize = std::min((size_t)maxRead, size); CHECK_TRUE(readSize > 0, SYSTEM_ERROR_NO_MEMORY); RxLock lk(this); if (readSize > rxBuffer_.data()) { dataInFlight(true /* commit */); + // Adjust read size, as dataInFlight() might have committed a bit less + // as not to stop the DMA transfer unnecessarily if there is already + // data transferred into the buffer. + readSize = std::min(CHECK(rxBuffer_.data()), size); } - SPARK_ASSERT(rxBuffer_.data() >= readSize); ssize_t r = CHECK(rxBuffer_.get(buffer, readSize)); if (!receiving_) { startReceiver(); @@ -408,13 +411,16 @@ class Usart { ssize_t peek(uint8_t* buffer, size_t size) { CHECK_TRUE(isEnabled(), SYSTEM_ERROR_INVALID_STATE); const ssize_t maxRead = CHECK(data()); - const ssize_t peekSize = std::min((size_t)maxRead, size); + ssize_t peekSize = std::min((size_t)maxRead, size); CHECK_TRUE(peekSize > 0, SYSTEM_ERROR_NO_MEMORY); RxLock lk(this); if (peekSize > rxBuffer_.data()) { dataInFlight(true /* commit */); + // Adjust peek size, as dataInFlight() might have committed a bit less + // as not to stop the DMA transfer unnecessarily if there is already + // data transferred into the buffer. + peekSize = std::min(CHECK(rxBuffer_.data()), size); } - SPARK_ASSERT(rxBuffer_.data() >= peekSize); return rxBuffer_.peek(buffer, peekSize); } From f453ec46492399a9646ee074b57e21b53be42d28 Mon Sep 17 00:00:00 2001 From: keeramis Date: Tue, 29 Nov 2022 22:46:47 -0600 Subject: [PATCH 094/112] [tests] Use pin A2 instead of D5 for trackerM analog tests --- user/tests/wiring/no_fixture_long_running/pwm.cpp | 4 +++- user/tests/wiring/no_fixture_long_running/servo.cpp | 4 +++- user/tests/wiring/no_fixture_long_running/tone.cpp | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/user/tests/wiring/no_fixture_long_running/pwm.cpp b/user/tests/wiring/no_fixture_long_running/pwm.cpp index 5a07faf520..3e75516a85 100644 --- a/user/tests/wiring/no_fixture_long_running/pwm.cpp +++ b/user/tests/wiring/no_fixture_long_running/pwm.cpp @@ -34,8 +34,10 @@ const PinMapping pwm_pins[] = { // cause problems if the RGB led is enabled. // PWM HAL also is not interrupt safe and RGB pins are modified in SysTick PIN(D2), PIN(D3), PIN(D4), PIN(D5), PIN(D6), /* PIN(D7), */ PIN(D8), PIN(A0), PIN(A1), PIN(A2), PIN(A3), PIN(A4), PIN(A5) /* , PIN(RGBR), PIN(RGBG), PIN(RGBB) */ -#elif HAL_PLATFORM_RTL872X // double check. Run tests etc +#elif (PLATFORM_ID == PLATFORM_P2) // double check. Run tests etc PIN(D1), PIN(A2), PIN(A5), PIN(S0), PIN(S1) /* , PIN(RGBR), PIN(RGBG), PIN(RGBB) */ +#elif (PLATFORM_ID == PLATFORM_TRACKERM) + PIN(A2), PIN(A5) /* , PIN(RGBR), PIN(RGBG), PIN(RGBB) */ #elif (PLATFORM_ID == PLATFORM_ESOMX) PIN(D0), PIN(D1), PIN(D2), PIN(A3), PIN(A4), PIN(A5), PIN(A6), PIN(TX), PIN(RX), PIN(B2), PIN(B3), PIN(C4), PIN(C5) /* , PIN(RGBR), PIN(RGBG), PIN(RGBB) */ #else diff --git a/user/tests/wiring/no_fixture_long_running/servo.cpp b/user/tests/wiring/no_fixture_long_running/servo.cpp index 63543136b8..0e11b03129 100644 --- a/user/tests/wiring/no_fixture_long_running/servo.cpp +++ b/user/tests/wiring/no_fixture_long_running/servo.cpp @@ -28,8 +28,10 @@ #include "unit-test/unit-test.h" #if HAL_PLATFORM_GEN == 3 -#if PLATFORM_ID == PLATFORM_ESOMX || HAL_PLATFORM_RTL872X +#if PLATFORM_ID == PLATFORM_ESOMX || PLATFORM_ID == PLATFORM_P2 static const hal_pin_t pin = D1, pin2 = D8; +#elif PLATFORM_ID == PLATFORM_TRACKERM +static const hal_pin_t pin = A2, pin2 = D8; #else static const hal_pin_t pin = A0, pin2 = A1; #endif diff --git a/user/tests/wiring/no_fixture_long_running/tone.cpp b/user/tests/wiring/no_fixture_long_running/tone.cpp index 8f2e91eadd..efeb671cfe 100644 --- a/user/tests/wiring/no_fixture_long_running/tone.cpp +++ b/user/tests/wiring/no_fixture_long_running/tone.cpp @@ -27,8 +27,10 @@ #include "tone_hal.h" #include "unit-test/unit-test.h" -#if HAL_PLATFORM_RTL872X +#if PLATFORM_ID == PLATFORM_P2 static const hal_pin_t pin = D1;//pin under test +#elif PLATFORM_ID == PLATFORM_TRACKERM +static const hal_pin_t pin = A2;//pin under test #elif PLATFORM_ID == PLATFORM_ESOMX static const hal_pin_t pin = A3;//pin under test #else From bfc504369ed3cdc819c8e6853b2546aab992d817 Mon Sep 17 00:00:00 2001 From: keeramis Date: Wed, 30 Nov 2022 11:16:31 -0600 Subject: [PATCH 095/112] Remove D1 as PWM pin since it's used as an SCL --- hal/src/trackerm/pinmap_defines.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hal/src/trackerm/pinmap_defines.cpp b/hal/src/trackerm/pinmap_defines.cpp index d23193a2b3..4ab603230b 100644 --- a/hal/src/trackerm/pinmap_defines.cpp +++ b/hal/src/trackerm/pinmap_defines.cpp @@ -26,7 +26,7 @@ namespace { static hal_pin_info_t pinmap[TOTAL_PINS] = { /* User space */ /* D0 / A3 - 00 */ { RTL_PORT_B, 6, PIN_MODE_NONE, PF_NONE, 2, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_MCU, 0}, -/* D1 / A4 - 01 */ { RTL_PORT_B, 5, PIN_MODE_NONE, PF_NONE, 1, 1, 9, HAL_PIN_TYPE_MCU, 0}, +/* D1 / A4 - 01 */ { RTL_PORT_B, 5, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_MCU, 0}, /* D2 - 02 */ { RTL_PORT_A, 16, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_MCU, 0}, /* D3 - 03 */ { RTL_PORT_A, 17, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_MCU, 0}, /* D4 - 04 */ { RTL_PORT_A, 18, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_MCU, 0}, From 51ddb560a3457fa2ea0cf5955f95c80348d2e233 Mon Sep 17 00:00:00 2001 From: keeramis Date: Wed, 30 Nov 2022 14:11:31 -0600 Subject: [PATCH 096/112] Remove S0/S1 pins as PWM --- hal/src/trackerm/pinmap_defines.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hal/src/trackerm/pinmap_defines.cpp b/hal/src/trackerm/pinmap_defines.cpp index 4ab603230b..ce2bb25531 100644 --- a/hal/src/trackerm/pinmap_defines.cpp +++ b/hal/src/trackerm/pinmap_defines.cpp @@ -40,8 +40,8 @@ static hal_pin_info_t pinmap[TOTAL_PINS] = { /* A1 - 12 */ { RTL_PORT_B, 2, PIN_MODE_NONE, PF_NONE, 5, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_MCU, 0}, /* A2 - 13 */ { RTL_PORT_B, 7, PIN_MODE_NONE, PF_NONE, 3, 1, 17, HAL_PIN_TYPE_MCU, 0}, /* A5 - 14 */ { RTL_PORT_B, 4, PIN_MODE_NONE, PF_NONE, 0, 1, 8, HAL_PIN_TYPE_MCU, 0}, -/* S0 - 15 */ { RTL_PORT_A, 12, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, 1, 0, HAL_PIN_TYPE_MCU, 0}, -/* S1 - 16 */ { RTL_PORT_A, 13, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, 1, 1, HAL_PIN_TYPE_MCU, 0}, +/* S0 - 15 */ { RTL_PORT_A, 12, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_MCU, 0}, +/* S1 - 16 */ { RTL_PORT_A, 13, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_MCU, 0}, /* S2 - 17 */ { RTL_PORT_A, 14, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_MCU, 0}, /* S3 - 18 */ { RTL_PORT_B, 26, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_MCU, 0}, /* S4 - 19 */ { RTL_PORT_A, 0, PIN_MODE_NONE, PF_NONE, ADC_CHANNEL_NONE, PWM_INSTANCE_NONE, PWM_CHANNEL_NONE, HAL_PIN_TYPE_MCU, 0}, From c15493a7a7d61cfa4cd7aa5c5a30577db4d8fcb7 Mon Sep 17 00:00:00 2001 From: Scott Brust Date: Thu, 1 Dec 2022 13:28:07 -0800 Subject: [PATCH 097/112] Check feature flags for ADC reference bit on all NRF platforms --- hal/src/nRF52840/adc_hal.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hal/src/nRF52840/adc_hal.cpp b/hal/src/nRF52840/adc_hal.cpp index 4e5af84ef9..1ecbd1b24c 100644 --- a/hal/src/nRF52840/adc_hal.cpp +++ b/hal/src/nRF52840/adc_hal.cpp @@ -38,6 +38,7 @@ static const nrfx_saadc_config_t saadcConfig = { static hal_adc_reference_t adcReference = HAL_ADC_REFERENCE_EXTERNAL; static constexpr uint32_t HAL_VERSION_BRN404X_V003 = 0x03; +static constexpr uint32_t HW_FEATURE_FLAG_USE_INTERNAL_ADC_REFERENCE_BIT = (1<<15); static void analog_in_event_handler(nrfx_saadc_evt_t const *p_event) { (void) p_event; @@ -138,7 +139,11 @@ void hal_adc_dma_init() { adcReference = HAL_ADC_REFERENCE_INTERNAL; } #else - (void)adcReference; + hal_device_hw_info hwInfo = {}; + hal_get_device_hw_info(&hwInfo, nullptr); + if ((hwInfo.features & HW_FEATURE_FLAG_USE_INTERNAL_ADC_REFERENCE_BIT) == 0) { + adcReference = HAL_ADC_REFERENCE_INTERNAL; + } #endif // PLATFORM_ID == PLATFORM_BORON } From 6585b7e8d8fcbb2f46b402f5d82b0cb363020197 Mon Sep 17 00:00:00 2001 From: Scott Brust Date: Thu, 1 Dec 2022 13:43:59 -0800 Subject: [PATCH 098/112] Check ADC OTP Bit on all NRF platforms --- hal/src/nRF52840/adc_hal.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hal/src/nRF52840/adc_hal.cpp b/hal/src/nRF52840/adc_hal.cpp index 1ecbd1b24c..f6c2f74074 100644 --- a/hal/src/nRF52840/adc_hal.cpp +++ b/hal/src/nRF52840/adc_hal.cpp @@ -138,13 +138,13 @@ void hal_adc_dma_init() { if (ret == SYSTEM_ERROR_NONE && hwVersion == HAL_VERSION_BRN404X_V003) { adcReference = HAL_ADC_REFERENCE_INTERNAL; } -#else +#endif // PLATFORM_ID == PLATFORM_BORON + hal_device_hw_info hwInfo = {}; hal_get_device_hw_info(&hwInfo, nullptr); if ((hwInfo.features & HW_FEATURE_FLAG_USE_INTERNAL_ADC_REFERENCE_BIT) == 0) { adcReference = HAL_ADC_REFERENCE_INTERNAL; } -#endif // PLATFORM_ID == PLATFORM_BORON } /* From 2f61eecf7d21948e168c976a7e5efc25622def2c Mon Sep 17 00:00:00 2001 From: Scott Brust Date: Thu, 1 Dec 2022 13:50:49 -0800 Subject: [PATCH 099/112] Specify size --- hal/src/nRF52840/adc_hal.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/hal/src/nRF52840/adc_hal.cpp b/hal/src/nRF52840/adc_hal.cpp index f6c2f74074..1c159f5762 100644 --- a/hal/src/nRF52840/adc_hal.cpp +++ b/hal/src/nRF52840/adc_hal.cpp @@ -141,6 +141,7 @@ void hal_adc_dma_init() { #endif // PLATFORM_ID == PLATFORM_BORON hal_device_hw_info hwInfo = {}; + hwInfo.size = sizeof(hwInfo); hal_get_device_hw_info(&hwInfo, nullptr); if ((hwInfo.features & HW_FEATURE_FLAG_USE_INTERNAL_ADC_REFERENCE_BIT) == 0) { adcReference = HAL_ADC_REFERENCE_INTERNAL; From 15eee5fa54d1ce5057d1782ef435f43695d3a074 Mon Sep 17 00:00:00 2001 From: Andrey Tolstoy Date: Thu, 1 Dec 2022 17:30:24 +0700 Subject: [PATCH 100/112] [rtl872x] move rsip management into exflash_hal now that we don't allow XIP access anywhere other than exflash hal itself --- hal/src/rtl872x/core_hal.c | 4 -- hal/src/rtl872x/exflash_hal.cpp | 61 +++++++++++++++++++++++++-- platform/MCU/rtl872x/src/flash_mal.c | 62 ---------------------------- 3 files changed, 57 insertions(+), 70 deletions(-) diff --git a/hal/src/rtl872x/core_hal.c b/hal/src/rtl872x/core_hal.c index a315cd7003..c9973e3ca0 100644 --- a/hal/src/rtl872x/core_hal.c +++ b/hal/src/rtl872x/core_hal.c @@ -651,11 +651,7 @@ int HAL_Core_Get_Last_Reset_Info(int *reason, uint32_t *data, void *reserved) { * @retval 32-bit CRC */ uint32_t HAL_Core_Compute_CRC32(const uint8_t *pBuffer, uint32_t bufferSize) { - // TODO: Use the peripheral lock? - int is = 0; - bool enableRsip = enable_rsip_if_disabled((uint32_t)pBuffer, &is); uint32_t crc32 = Compute_CRC32(pBuffer, bufferSize, NULL); - disable_rsip_if_enabled(enableRsip, is); return crc32; } diff --git a/hal/src/rtl872x/exflash_hal.cpp b/hal/src/rtl872x/exflash_hal.cpp index 0a8f4d8af1..391c01f326 100644 --- a/hal/src/rtl872x/exflash_hal.cpp +++ b/hal/src/rtl872x/exflash_hal.cpp @@ -58,6 +58,56 @@ typedef enum { #error "Unsupported external flash" #endif +class RsipIfRequired { +public: + RsipIfRequired(uint32_t address) { + if ((HAL_READ32(SYSTEM_CTRL_BASE_LP, REG_SYS_EFUSE_SYSCFG3) & BIT_SYS_FLASH_ENCRYPT_EN) == 0) { + return; + } + + uint32_t km0_system_control = HAL_READ32(SYSTEM_CTRL_BASE_LP, REG_LP_KM0_CTRL); + if ((km0_system_control & BIT_LSYS_PLFM_FLASH_SCE) != 0) { + return; + } + + if (!isEncryptedRegion(address)) { + return; + } + + interruptState_ = HAL_disable_irq(); + + HAL_WRITE32(SYSTEM_CTRL_BASE_LP, REG_LP_KM0_CTRL, (km0_system_control | BIT_LSYS_PLFM_FLASH_SCE)); + enabled_ = true; + } + + ~RsipIfRequired() { + if (enabled_) { + uint32_t km0_system_control = HAL_READ32(SYSTEM_CTRL_BASE_LP, REG_LP_KM0_CTRL); + HAL_WRITE32(SYSTEM_CTRL_BASE_LP, REG_LP_KM0_CTRL, (km0_system_control & (~BIT_LSYS_PLFM_FLASH_SCE))); + HAL_enable_irq(interruptState_); + } + } + +private: + bool isEncryptedRegion(uint32_t address) { + uint8_t userEfuse0 = 0xFF; + EFUSE_PMAP_READ8(0, USER_KEY_0_EFUSE_ADDRESS, &userEfuse0, L25EOUTVOLTAGE); + bool part1_encryption_enabled = !(userEfuse0 & PART1_ENCRYPTED_BIT); + + if (address >= KM0_MBR_START_ADDRESS && address < (KM0_MBR_START_ADDRESS + KM0_MBR_IMAGE_SIZE) /* MBR */) { + return true; + } else if (part1_encryption_enabled && (address >= KM0_PART1_START_ADDRESS && address < (KM0_PART1_START_ADDRESS + KM0_PART1_IMAGE_SIZE)) /* part1 */) { + return true; + } + + return false; + } + + bool enabled_ = false; + int interruptState_ = 0; +}; + + // Constructor, destructors and methods are executed from PSRAM. class ExFlashLock { public: @@ -134,11 +184,12 @@ class XipControl { static void enableXip(bool enable) { (void)mpuEntry_; #if MODULE_FUNCTION != MOD_FUNC_BOOTLOADER - if (-1 < mpuEntry_ && mpuEntry_ < MPU_MAX_REGION) { - mpu_entry_free(mpuEntry_); + if (mpuEntry_ < 0) { + // Allocate entry, but just once + // This is safe and done under an exflash lock normally + mpuEntry_ = mpu_entry_alloc(); } - mpuEntry_ = mpu_entry_alloc(); - SPARK_ASSERT(-1 < mpuEntry_ && mpuEntry_ < MPU_MAX_REGION); + SPARK_ASSERT(mpuEntry_ >= 0); mpu_region_config mpu_cfg = {}; mpu_cfg.region_base = (uintptr_t)&platform_system_part1_flash_start; @@ -201,6 +252,8 @@ int hal_exflash_read(uintptr_t addr, uint8_t* data_buf, size_t data_size) { ExFlashLock lk; XipControl xiplk; addr += SPI_FLASH_BASE; + + RsipIfRequired rsip(addr); // FIXME: data_size as well? memcpy(data_buf, (void*)addr, data_size); return SYSTEM_ERROR_NONE; } diff --git a/platform/MCU/rtl872x/src/flash_mal.c b/platform/MCU/rtl872x/src/flash_mal.c index 60063f0d54..ff7717884f 100644 --- a/platform/MCU/rtl872x/src/flash_mal.c +++ b/platform/MCU/rtl872x/src/flash_mal.c @@ -64,57 +64,6 @@ static int hal_memory_write(uintptr_t addr, const uint8_t* data_buf, size_t data static uint8_t otaTemporaryMemoryBuffer[FLASH_MAL_OTA_TEMPORARY_MEMORY_BUFFER] __attribute__((section(".psram"))); #endif // MODULE_FUNCTION == MOD_FUNC_BOOTLOADER -bool is_encrypted_region(uint32_t address) { - uint8_t userEfuse0 = 0xFF; - EFUSE_PMAP_READ8(0, USER_KEY_0_EFUSE_ADDRESS, &userEfuse0, L25EOUTVOLTAGE); - bool part1_encryption_enabled = !(userEfuse0 & PART1_ENCRYPTED_BIT); - - if (address >= KM0_MBR_START_ADDRESS && address < (KM0_MBR_START_ADDRESS + KM0_MBR_IMAGE_SIZE) /* MBR */) { - return true; - } else if (part1_encryption_enabled && (address >= KM0_PART1_START_ADDRESS && address < (KM0_PART1_START_ADDRESS + KM0_PART1_IMAGE_SIZE)) /* part1 */) { - return true; - } - - return false; -} - -/* WARNING: enable_rsip_if_disabled() and disable_rsip_if_enabled() must be used in pair. - * They can be called recursively. - * - * FIXME: we only check the address when it is called. We assume that the address used in the following - * flash read operation is within the encrypted image's address range. Reading un-encrypted image - * if RSIP is enabled may return garbage data. For example, take care Compute_CRC32(). - */ -bool enable_rsip_if_disabled(uint32_t address, int* is) { - if ((HAL_READ32(SYSTEM_CTRL_BASE_LP, REG_SYS_EFUSE_SYSCFG3) & BIT_SYS_FLASH_ENCRYPT_EN) == 0) { - return false; - } - - uint32_t km0_system_control = HAL_READ32(SYSTEM_CTRL_BASE_LP, REG_LP_KM0_CTRL); - if ((km0_system_control & BIT_LSYS_PLFM_FLASH_SCE) != 0) { - return false; - } - - if (!is_encrypted_region(address)) { - return false; - } - - // Make the following operation atomic - *is = HAL_disable_irq(); - - HAL_WRITE32(SYSTEM_CTRL_BASE_LP, REG_LP_KM0_CTRL, (km0_system_control | BIT_LSYS_PLFM_FLASH_SCE)); - return true; -} - -void disable_rsip_if_enabled(bool enabled, int is) { - if (enabled) { - uint32_t km0_system_control = HAL_READ32(SYSTEM_CTRL_BASE_LP, REG_LP_KM0_CTRL); - HAL_WRITE32(SYSTEM_CTRL_BASE_LP, REG_LP_KM0_CTRL, (km0_system_control & (~BIT_LSYS_PLFM_FLASH_SCE))); - - HAL_enable_irq(is); - } -} - static bool flash_read(flash_device_t dev, uintptr_t addr, uint8_t* buf, size_t size) { bool ok = false; switch (dev) { @@ -730,8 +679,6 @@ int FLASH_ModuleInfo(module_info_t* const infoOut, uint8_t flashDeviceID, uint32 #endif CHECK_TRUE(infoOut, SYSTEM_ERROR_INVALID_ARGUMENT); - int is = 0; - bool enableRsip = enable_rsip_if_disabled(startAddress, &is); rtl_binary_header header = {}; if (!flash_read(flashDeviceID, startAddress, (uint8_t*)&header, sizeof(rtl_binary_header))) { goto error_return; @@ -746,11 +693,9 @@ int FLASH_ModuleInfo(module_info_t* const infoOut, uint8_t flashDeviceID, uint32 if (infoOffset) { *infoOffset = offset; } - disable_rsip_if_enabled(enableRsip, is); return SYSTEM_ERROR_NONE; error_return: - disable_rsip_if_enabled(enableRsip, is); return SYSTEM_ERROR_INTERNAL; } @@ -760,8 +705,6 @@ int FLASH_ModuleCrcSuffix(module_info_crc_t* crc, module_info_suffix_t* suffix, return SYSTEM_ERROR_NOT_SUPPORTED; } #endif - int is = 0; - bool enableRsip = enable_rsip_if_disabled(endAddress, &is); if (crc) { if(!flash_read(flashDeviceID, endAddress, (uint8_t*)crc, sizeof(module_info_crc_t))) { goto error_return; @@ -774,11 +717,9 @@ int FLASH_ModuleCrcSuffix(module_info_crc_t* crc, module_info_suffix_t* suffix, goto error_return; } } - disable_rsip_if_enabled(enableRsip, is); return SYSTEM_ERROR_NONE; error_return: - disable_rsip_if_enabled(enableRsip, is); return SYSTEM_ERROR_INTERNAL; } @@ -828,8 +769,6 @@ bool FLASH_VerifyCRC32(uint8_t flashDeviceID, uint32_t startAddress, uint32_t le if (dataBuffer == NULL) { return false; } - int is = 0; - bool enableRsip = enable_rsip_if_disabled(startAddress, &is); flash_read(flashDeviceID, (startAddress + length), dataBuffer, 4); uint32_t expectedCRC = (uint32_t)(dataBuffer[3] | (dataBuffer[2] << 8) | (dataBuffer[1] << 16) | (dataBuffer[0] << 24)); uint32_t endAddress = startAddress + length; @@ -844,7 +783,6 @@ bool FLASH_VerifyCRC32(uint8_t flashDeviceID, uint32_t startAddress, uint32_t le computedCRC = Compute_CRC32(dataBuffer, len, &computedCRC); startAddress += len; } while (startAddress < endAddress); - disable_rsip_if_enabled(enableRsip, is); if (expectedCRC == computedCRC) { return true; } From eb6cbdb42476cd51c48740b97e8c8713ab9d0bd7 Mon Sep 17 00:00:00 2001 From: Andrey Tolstoy Date: Thu, 1 Dec 2022 18:58:03 +0700 Subject: [PATCH 101/112] [test] wiring/no_fixture: make CONCURRENT_MUTEX_02_priority_inheritance_three_threads less flaky --- user/tests/wiring/no_fixture/thread.cpp | 37 ++++++++++++++++++++----- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/user/tests/wiring/no_fixture/thread.cpp b/user/tests/wiring/no_fixture/thread.cpp index 6f9cd6b3f5..db561bbb8a 100644 --- a/user/tests/wiring/no_fixture/thread.cpp +++ b/user/tests/wiring/no_fixture/thread.cpp @@ -441,6 +441,7 @@ test(CONCURRENT_MUTEX_02_priority_inheritance_three_threads) ~State() = default; Mutex mutex1; Mutex mutex2; + volatile int state = 0; bool state1 = false; bool state2 = false; bool state3 = false; @@ -467,23 +468,32 @@ test(CONCURRENT_MUTEX_02_priority_inheritance_three_threads) // Somewhere at this point the high priority thread will try to acquire the mutex2 // and middle priority thread will try to acquire the mutex1, our priority should // be bumped to that of high priority thread. - delay(500); + state->state = 1; + delay(2000); + + // Verify that our priority has been bumped to that of middle priority thread + prio = getThreadPriority(); + assertEqual(prio.prio, prio.base + 1); + + state->state = 2; + delay(2000); // Verify that our priority has been bumped to that of high priority thread prio = getThreadPriority(); assertEqual(prio.prio, prio.base + 2); + state->state = 3; // Unlock mutex2, this should allow the high priority thread to finally // acquire it, and our priority should be decreased to middle priority mutex2.unlock(); - delay(500); + delay(1000); prio = getThreadPriority(); assertEqual(prio.prio, prio.base + 1); // Unlock mutex1, this should allow the middle priority thread to finally // acquire it, and our priority should be decreased to low priority mutex1.unlock(); - delay(500); + delay(1000); prio = getThreadPriority(); assertEqual(prio.prio, prio.base); @@ -497,8 +507,12 @@ test(CONCURRENT_MUTEX_02_priority_inheritance_three_threads) ++state->done; }); - // Wait a bit for low priority thread to acquire both mutexes - delay(500); + auto start = millis(); + + // Wait a bit for low priority thread to acquire both mutexes + while (state->state == 0 && millis() - start <= 5000) { + delay(10); + } // Check that we are at the base priority and nothing has affected us auto prio = getThreadPriority(); @@ -532,13 +546,22 @@ test(CONCURRENT_MUTEX_02_priority_inheritance_three_threads) ++state->done; }); + auto start = millis(); + // Wait a bit for low priority thread to acquire both mutexes - delay(500); + while (state->state == 0 && millis() - start <= 5000) { + delay(10); + } // Check that we are at the base priority and nothing has affected us auto prio = getThreadPriority(); assertEqual(prio.base, prio.prio); + // Wait for middle thread to attempt to acquire the mutex + while (state->state == 1) { + delay(10); + } + // Attempt to acquire the second mutex, at this point the low priority thread // should be holding it. Because we are at higher priority, the priority // of the low priority thread should be bumped. @@ -562,7 +585,7 @@ test(CONCURRENT_MUTEX_02_priority_inheritance_three_threads) state->state3 = true; }, &state, startPriority + 2); - for (auto start = millis(); millis() - start <= 2000;) { + for (auto start = millis(); millis() - start <= 10000;) { if (state.done == 3) { break; } From eb37d529a64942f8db98167fd507c11cded095f1 Mon Sep 17 00:00:00 2001 From: Andrey Tolstoy Date: Thu, 1 Dec 2022 18:58:26 +0700 Subject: [PATCH 102/112] [tests] wiring/no_fixture: tabs -> spaces --- user/tests/wiring/no_fixture/thread.cpp | 630 ++++++++++++------------ 1 file changed, 315 insertions(+), 315 deletions(-) diff --git a/user/tests/wiring/no_fixture/thread.cpp b/user/tests/wiring/no_fixture/thread.cpp index db561bbb8a..8417659c53 100644 --- a/user/tests/wiring/no_fixture/thread.cpp +++ b/user/tests/wiring/no_fixture/thread.cpp @@ -11,7 +11,7 @@ namespace { template bool isInRangeIncl(T value, T min, T max) { - return (value >= min) && (value <= max); + return (value >= min) && (value <= max); } const auto APPLICATION_WDT_STACK_SIZE = 2048; @@ -44,81 +44,81 @@ test(THREAD_01_creation) test(THREAD_02_thread_doesnt_leak_memory) { - // 1024 less to account for fragmentation and other allocations - delay(1000); - assertMoreOrEqual(System.freeMemory(), s_ram_free_before - 1024); + // 1024 less to account for fragmentation and other allocations + delay(1000); + assertMoreOrEqual(System.freeMemory(), s_ram_free_before - 1024); } test(THREAD_03_SingleThreadedBlock) { - SINGLE_THREADED_BLOCK() { + SINGLE_THREADED_BLOCK() { - } - SINGLE_THREADED_BLOCK() { + } + SINGLE_THREADED_BLOCK() { - } + } } test(THREAD_04_with_lock) { - WITH_LOCK(Serial) { + WITH_LOCK(Serial) { - } + } - WITH_LOCK(Serial) { + WITH_LOCK(Serial) { - } + } } test(THREAD_05_try_lock) { - TRY_LOCK(Serial) { + TRY_LOCK(Serial) { - } + } } // With THREADING DISABLED, checks that behavior of Particle.process() is as expected // when run from main loop and custom threads test(THREAD_06_particle_process_behavior_when_threading_disabled) { - /* This test should only be run with threading disabled */ - if (system_thread_get_state(nullptr) == spark::feature::ENABLED) { - skip(); - return; - } - - // Make sure Particle is connected - Particle.connect(); - waitFor(Particle.connected,HAL_PLATFORM_MAX_CLOUD_CONNECT_TIME); - assertTrue(Particle.connected()); - - // Call disconnect from main thread - Particle.disconnect(); - SCOPE_GUARD({ - // Make sure we restore cloud connection after exiting this test - Particle.connect(); - waitFor(Particle.connected, HAL_PLATFORM_MAX_CLOUD_CONNECT_TIME); - assertTrue(Particle.connected()); - }); - - HAL_Delay_Milliseconds(2000); // wait sometime to confirm delay will not disconnect - assertTrue(Particle.connected()); - - // Run Particle.process from a custom thread - Thread* th = new Thread("name", []{ - Particle.process(); - },OS_THREAD_PRIORITY_DEFAULT); - assertTrue(bool(th)); - th->join(); - delete th; - - // Particle.process() should not do anything from custom thread, hence particle should be still connected - assertTrue(Particle.connected()); - // Run Particle.process() from main thread - Particle.process(); - HAL_Delay_Milliseconds(200); - assertFalse(Particle.connected()); + /* This test should only be run with threading disabled */ + if (system_thread_get_state(nullptr) == spark::feature::ENABLED) { + skip(); + return; + } + + // Make sure Particle is connected + Particle.connect(); + waitFor(Particle.connected,HAL_PLATFORM_MAX_CLOUD_CONNECT_TIME); + assertTrue(Particle.connected()); + + // Call disconnect from main thread + Particle.disconnect(); + SCOPE_GUARD({ + // Make sure we restore cloud connection after exiting this test + Particle.connect(); + waitFor(Particle.connected, HAL_PLATFORM_MAX_CLOUD_CONNECT_TIME); + assertTrue(Particle.connected()); + }); + + HAL_Delay_Milliseconds(2000); // wait sometime to confirm delay will not disconnect + assertTrue(Particle.connected()); + + // Run Particle.process from a custom thread + Thread* th = new Thread("name", []{ + Particle.process(); + },OS_THREAD_PRIORITY_DEFAULT); + assertTrue(bool(th)); + th->join(); + delete th; + + // Particle.process() should not do anything from custom thread, hence particle should be still connected + assertTrue(Particle.connected()); + // Run Particle.process() from main thread + Particle.process(); + HAL_Delay_Milliseconds(200); + assertFalse(Particle.connected()); } namespace { @@ -128,20 +128,20 @@ volatile int test_val_fn2; static int test_val = 1; void increment(void) { - test_val_fn1++; + test_val_fn1++; } void sys_particle_process_increment(void) { - Particle.process(); - test_val_fn2++; + Particle.process(); + test_val_fn2++; } void sys_thr_block(void) { - while(test_val) { - HAL_Delay_Milliseconds(1); - } + while(test_val) { + HAL_Delay_Milliseconds(1); + } } } // anonymous @@ -150,99 +150,99 @@ void sys_thr_block(void) // when run from system, app, and custom threads test(THREAD_07_particle_process_behavior_when_threading_enabled) { - /* This test should only be run with threading disabled */ - if (system_thread_get_state(nullptr) == spark::feature::DISABLED) { - skip(); - return; - } - - // Make sure Particle is connected - Particle.connect(); - waitFor(Particle.connected,HAL_PLATFORM_MAX_CLOUD_CONNECT_TIME); - assertTrue(Particle.connected()); - - // Schedule function on application thread that does not run for sometime because of hard delays - test_val_fn1 = 0; - ActiveObjectBase* app = (ActiveObjectBase*)system_internal(0, nullptr); // Returns application thread instance - std::function fn = increment; - app->invoke_async(fn); - HAL_Delay_Milliseconds(10); - assertEqual((int)test_val_fn1, 0); - - // Schedule particle.process on system thread - test_val_fn2 = 0; - ActiveObjectBase* system = (ActiveObjectBase*)system_internal(1, nullptr); // Returns system thread instance - system->invoke_async(std::function(sys_particle_process_increment)); - HAL_Delay_Milliseconds(10); - assertEqual((int)test_val_fn2, 1); - - // Schedule function on system thread that blocks for a variable (test_val) - ActiveObjectBase* system2 = (ActiveObjectBase*)system_internal(1, nullptr); // Returns system thread instance - system2->invoke_async(std::function(sys_thr_block)); - HAL_Delay_Milliseconds(10); - - // Call disconnect from main thread - Particle.disconnect(); - SCOPE_GUARD({ - // Make sure we unblock the system thread and restore cloud connection after exiting this test - test_val = 0; - Particle.connect(); - // Address this comment before merging! Replace 20s with 9m? - waitFor(Particle.connected,HAL_PLATFORM_MAX_CLOUD_CONNECT_TIME); - assertTrue(Particle.connected()); - }); - - // Run Particle.process from a custom thread - Thread* th = new Thread("name", []{ - Particle.process(); - },OS_THREAD_PRIORITY_DEFAULT); - assertTrue(bool(th)); - th->join(); - delete th; - // Particle.process() should not do anything from custom thread, hence particle should be still connected - assertTrue(Particle.connected()); - - assertEqual((int)test_val_fn1, 0); - Particle.process(); - assertEqual((int)test_val_fn1, 1); - // Unblock system thread - test_val = 0; - HAL_Delay_Milliseconds(5000); - assertFalse(Particle.connected()); + /* This test should only be run with threading disabled */ + if (system_thread_get_state(nullptr) == spark::feature::DISABLED) { + skip(); + return; + } + + // Make sure Particle is connected + Particle.connect(); + waitFor(Particle.connected,HAL_PLATFORM_MAX_CLOUD_CONNECT_TIME); + assertTrue(Particle.connected()); + + // Schedule function on application thread that does not run for sometime because of hard delays + test_val_fn1 = 0; + ActiveObjectBase* app = (ActiveObjectBase*)system_internal(0, nullptr); // Returns application thread instance + std::function fn = increment; + app->invoke_async(fn); + HAL_Delay_Milliseconds(10); + assertEqual((int)test_val_fn1, 0); + + // Schedule particle.process on system thread + test_val_fn2 = 0; + ActiveObjectBase* system = (ActiveObjectBase*)system_internal(1, nullptr); // Returns system thread instance + system->invoke_async(std::function(sys_particle_process_increment)); + HAL_Delay_Milliseconds(10); + assertEqual((int)test_val_fn2, 1); + + // Schedule function on system thread that blocks for a variable (test_val) + ActiveObjectBase* system2 = (ActiveObjectBase*)system_internal(1, nullptr); // Returns system thread instance + system2->invoke_async(std::function(sys_thr_block)); + HAL_Delay_Milliseconds(10); + + // Call disconnect from main thread + Particle.disconnect(); + SCOPE_GUARD({ + // Make sure we unblock the system thread and restore cloud connection after exiting this test + test_val = 0; + Particle.connect(); + // Address this comment before merging! Replace 20s with 9m? + waitFor(Particle.connected,HAL_PLATFORM_MAX_CLOUD_CONNECT_TIME); + assertTrue(Particle.connected()); + }); + + // Run Particle.process from a custom thread + Thread* th = new Thread("name", []{ + Particle.process(); + },OS_THREAD_PRIORITY_DEFAULT); + assertTrue(bool(th)); + th->join(); + delete th; + // Particle.process() should not do anything from custom thread, hence particle should be still connected + assertTrue(Particle.connected()); + + assertEqual((int)test_val_fn1, 0); + Particle.process(); + assertEqual((int)test_val_fn1, 1); + // Unblock system thread + test_val = 0; + HAL_Delay_Milliseconds(5000); + assertFalse(Particle.connected()); } test(THREAD_08_newlib_reent_impure_ptr_changes_on_context_switch) { - extern uintptr_t link_global_data_start; - extern uintptr_t link_global_data_end; - - extern uintptr_t link_bss_location; - extern uintptr_t link_bss_end; - - volatile bool threadRan = false; - volatile struct _reent* threadImpure = nullptr; - struct _reent* testImpure = _impure_ptr; - - assertFalse(isInRangeIncl((uintptr_t)testImpure, (uintptr_t)&link_global_data_start, (uintptr_t)&link_global_data_end)); - assertFalse(isInRangeIncl((uintptr_t)testImpure, (uintptr_t)&link_bss_location, (uintptr_t)&link_bss_end)); - - testThread = Thread("test", [&]() { - threadImpure = _impure_ptr; - threadRan = true; - }, OS_THREAD_PRIORITY_DEFAULT, 4096); - - for(int tries = 5; !threadRan && tries >= 0; tries--) { - delay(100); - } - testThread.dispose(); - - assertTrue((bool)threadRan); - assertNotEqual((uintptr_t)threadImpure, (uintptr_t)nullptr); - assertNotEqual((uintptr_t)_impure_ptr, (uintptr_t)nullptr); - assertNotEqual((uintptr_t)_impure_ptr, (uintptr_t)threadImpure); - assertFalse(isInRangeIncl((uintptr_t)threadImpure, (uintptr_t)&link_global_data_start, (uintptr_t)&link_global_data_end)); - assertFalse(isInRangeIncl((uintptr_t)threadImpure, (uintptr_t)&link_bss_location, (uintptr_t)&link_bss_end)); - assertEqual((uintptr_t)testImpure, (uintptr_t)_impure_ptr); + extern uintptr_t link_global_data_start; + extern uintptr_t link_global_data_end; + + extern uintptr_t link_bss_location; + extern uintptr_t link_bss_end; + + volatile bool threadRan = false; + volatile struct _reent* threadImpure = nullptr; + struct _reent* testImpure = _impure_ptr; + + assertFalse(isInRangeIncl((uintptr_t)testImpure, (uintptr_t)&link_global_data_start, (uintptr_t)&link_global_data_end)); + assertFalse(isInRangeIncl((uintptr_t)testImpure, (uintptr_t)&link_bss_location, (uintptr_t)&link_bss_end)); + + testThread = Thread("test", [&]() { + threadImpure = _impure_ptr; + threadRan = true; + }, OS_THREAD_PRIORITY_DEFAULT, 4096); + + for(int tries = 5; !threadRan && tries >= 0; tries--) { + delay(100); + } + testThread.dispose(); + + assertTrue((bool)threadRan); + assertNotEqual((uintptr_t)threadImpure, (uintptr_t)nullptr); + assertNotEqual((uintptr_t)_impure_ptr, (uintptr_t)nullptr); + assertNotEqual((uintptr_t)_impure_ptr, (uintptr_t)threadImpure); + assertFalse(isInRangeIncl((uintptr_t)threadImpure, (uintptr_t)&link_global_data_start, (uintptr_t)&link_global_data_end)); + assertFalse(isInRangeIncl((uintptr_t)threadImpure, (uintptr_t)&link_bss_location, (uintptr_t)&link_bss_end)); + assertEqual((uintptr_t)testImpure, (uintptr_t)_impure_ptr); } // todo - test for SingleThreadedSection @@ -252,186 +252,186 @@ test(THREAD_08_newlib_reent_impure_ptr_changes_on_context_switch) volatile int timeout_called = 0; void timeout() { - timeout_called++; + timeout_called++; } void waitForComplete(ApplicationWatchdog& wd) { - while (!wd.isComplete()) { - HAL_Delay_Milliseconds(0); - } + while (!wd.isComplete()) { + HAL_Delay_Milliseconds(0); + } } test(APPLICATION_WATCHDOG_01_fires_timeout) { - s_ram_free_before = System.freeMemory(); - timeout_called = 0; - ApplicationWatchdog wd(50, timeout); - HAL_Delay_Milliseconds(60); + s_ram_free_before = System.freeMemory(); + timeout_called = 0; + ApplicationWatchdog wd(50, timeout); + HAL_Delay_Milliseconds(60); - assertEqual((int)timeout_called, 1); - waitForComplete(wd); + assertEqual((int)timeout_called, 1); + waitForComplete(wd); } test(APPLICATION_WATCHDOG_02_doesnt_fire_when_app_checks_in) { - for (int x=0; x os_result_t { - if (info) { - memcpy(ptr, info, sizeof(*info)); - } - return 0; - }, &info); - ThreadPriority p; - p.base = info.base_priority; - p.prio = info.priority; - return p; + os_thread_dump_info_t info = {}; + + os_thread_dump(os_thread_current(nullptr), [](os_thread_dump_info_t* info, void* ptr) -> os_result_t { + if (info) { + memcpy(ptr, info, sizeof(*info)); + } + return 0; + }, &info); + ThreadPriority p; + p.base = info.base_priority; + p.prio = info.priority; + return p; } test(CONCURRENT_MUTEX_01_priority_inheritance_two_threads) { - struct State { - State() = default; - ~State() = default; - Mutex mutex1; - Mutex mutex2; - bool state1 = false; - bool state2 = false; - volatile int done = 0; - }; - - State state; - const auto startPriority = OS_THREAD_PRIORITY_DEFAULT + 1; - - Thread lowPriorityThread("low", [](void* ptr) -> void { - auto state = (State*)ptr; - SCOPE_GUARD({ - ++state->done; - }); - - // Acquire first mutex - std::unique_lock mutex1(state->mutex1); - // Check that we are at the base priority and nothing has affected us - auto prio = getThreadPriority(); - assertEqual(prio.base, prio.prio); - - // Keep holding the first mutex and acquire the second one - std::unique_lock mutex2(state->mutex2); - // Somewhere at this point the second thread will try to acquire the second mutex - // and because we are holding it and are of lower priority, our priority - // should be bumped to that of thread2. - delay(1000); - - // Verify that our priority has been bumped to that of thread2 - prio = getThreadPriority(); - assertEqual(prio.prio, prio.base + 1); - - // Unlock mutex2, this should allow the second thread to finally - // acquire it. - mutex2.unlock(); - - // After we've released mutex2 and let the second thread to - // acquire it, our priority should be dropped to the 'normal' or base priority - // Validate that - prio = getThreadPriority(); - assertEqual(prio.prio, prio.base); - - // Everything is good - - state->state1 = true; - }, &state, startPriority); - Thread highPriorityThread("high", [](void* ptr) -> void { - auto state = (State*)ptr; - SCOPE_GUARD({ - ++state->done; - }); - - // Wait a bit for thread1 to acquire both mutexes - delay(500); - - // Check that we are at the base priority and nothing has affected us - auto prio = getThreadPriority(); - assertEqual(prio.base, prio.prio); - - // Attempt to acquire the second mutex, at this point the first thread - // should be holding it. Because we are at higher priority, the priority - // of the first thread should be bumped. - std::unique_lock mutex2(state->mutex2); - - // We've finally acquired the mutex and at this point the priority - // of the first thread should have dropped back to the base priority - - // Our priority should stay the same throughout all of this (base) - prio = getThreadPriority(); - assertEqual(prio.base, prio.prio); - - // Unlock second mutex - mutex2.unlock(); - - // Nothing should have changed, we should still be at our own base priority - prio = getThreadPriority(); - assertEqual(prio.base, prio.prio); - - // All done - state->state2 = true; - }, &state, startPriority + 1); - - for (auto start = millis(); millis() - start <= 2000;) { - if (state.done == 2) { - break; - } - delay(100); - } - - assertTrue(state.state1); - assertTrue(state.state2); + struct State { + State() = default; + ~State() = default; + Mutex mutex1; + Mutex mutex2; + bool state1 = false; + bool state2 = false; + volatile int done = 0; + }; + + State state; + const auto startPriority = OS_THREAD_PRIORITY_DEFAULT + 1; + + Thread lowPriorityThread("low", [](void* ptr) -> void { + auto state = (State*)ptr; + SCOPE_GUARD({ + ++state->done; + }); + + // Acquire first mutex + std::unique_lock mutex1(state->mutex1); + // Check that we are at the base priority and nothing has affected us + auto prio = getThreadPriority(); + assertEqual(prio.base, prio.prio); + + // Keep holding the first mutex and acquire the second one + std::unique_lock mutex2(state->mutex2); + // Somewhere at this point the second thread will try to acquire the second mutex + // and because we are holding it and are of lower priority, our priority + // should be bumped to that of thread2. + delay(1000); + + // Verify that our priority has been bumped to that of thread2 + prio = getThreadPriority(); + assertEqual(prio.prio, prio.base + 1); + + // Unlock mutex2, this should allow the second thread to finally + // acquire it. + mutex2.unlock(); + + // After we've released mutex2 and let the second thread to + // acquire it, our priority should be dropped to the 'normal' or base priority + // Validate that + prio = getThreadPriority(); + assertEqual(prio.prio, prio.base); + + // Everything is good + + state->state1 = true; + }, &state, startPriority); + Thread highPriorityThread("high", [](void* ptr) -> void { + auto state = (State*)ptr; + SCOPE_GUARD({ + ++state->done; + }); + + // Wait a bit for thread1 to acquire both mutexes + delay(500); + + // Check that we are at the base priority and nothing has affected us + auto prio = getThreadPriority(); + assertEqual(prio.base, prio.prio); + + // Attempt to acquire the second mutex, at this point the first thread + // should be holding it. Because we are at higher priority, the priority + // of the first thread should be bumped. + std::unique_lock mutex2(state->mutex2); + + // We've finally acquired the mutex and at this point the priority + // of the first thread should have dropped back to the base priority + + // Our priority should stay the same throughout all of this (base) + prio = getThreadPriority(); + assertEqual(prio.base, prio.prio); + + // Unlock second mutex + mutex2.unlock(); + + // Nothing should have changed, we should still be at our own base priority + prio = getThreadPriority(); + assertEqual(prio.base, prio.prio); + + // All done + state->state2 = true; + }, &state, startPriority + 1); + + for (auto start = millis(); millis() - start <= 2000;) { + if (state.done == 2) { + break; + } + delay(100); + } + + assertTrue(state.state1); + assertTrue(state.state2); } test(CONCURRENT_MUTEX_02_priority_inheritance_three_threads) @@ -441,7 +441,7 @@ test(CONCURRENT_MUTEX_02_priority_inheritance_three_threads) ~State() = default; Mutex mutex1; Mutex mutex2; - volatile int state = 0; + volatile int state = 0; bool state1 = false; bool state2 = false; bool state3 = false; @@ -468,20 +468,20 @@ test(CONCURRENT_MUTEX_02_priority_inheritance_three_threads) // Somewhere at this point the high priority thread will try to acquire the mutex2 // and middle priority thread will try to acquire the mutex1, our priority should // be bumped to that of high priority thread. - state->state = 1; + state->state = 1; delay(2000); - // Verify that our priority has been bumped to that of middle priority thread + // Verify that our priority has been bumped to that of middle priority thread prio = getThreadPriority(); assertEqual(prio.prio, prio.base + 1); - state->state = 2; - delay(2000); + state->state = 2; + delay(2000); // Verify that our priority has been bumped to that of high priority thread prio = getThreadPriority(); assertEqual(prio.prio, prio.base + 2); - state->state = 3; + state->state = 3; // Unlock mutex2, this should allow the high priority thread to finally // acquire it, and our priority should be decreased to middle priority @@ -507,12 +507,12 @@ test(CONCURRENT_MUTEX_02_priority_inheritance_three_threads) ++state->done; }); - auto start = millis(); + auto start = millis(); - // Wait a bit for low priority thread to acquire both mutexes - while (state->state == 0 && millis() - start <= 5000) { - delay(10); - } + // Wait a bit for low priority thread to acquire both mutexes + while (state->state == 0 && millis() - start <= 5000) { + delay(10); + } // Check that we are at the base priority and nothing has affected us auto prio = getThreadPriority(); @@ -546,21 +546,21 @@ test(CONCURRENT_MUTEX_02_priority_inheritance_three_threads) ++state->done; }); - auto start = millis(); + auto start = millis(); // Wait a bit for low priority thread to acquire both mutexes while (state->state == 0 && millis() - start <= 5000) { - delay(10); - } + delay(10); + } // Check that we are at the base priority and nothing has affected us auto prio = getThreadPriority(); assertEqual(prio.base, prio.prio); - // Wait for middle thread to attempt to acquire the mutex - while (state->state == 1) { - delay(10); - } + // Wait for middle thread to attempt to acquire the mutex + while (state->state == 1) { + delay(10); + } // Attempt to acquire the second mutex, at this point the low priority thread // should be holding it. Because we are at higher priority, the priority From cddd78ea71b1659d07db0aebc88163cfdfce5cf2 Mon Sep 17 00:00:00 2001 From: Andrey Tolstoy Date: Sat, 3 Dec 2022 06:03:11 +0700 Subject: [PATCH 103/112] [rtl872x] exflash: revert dcache invalidate calls after writes/erasures --- hal/src/rtl872x/exflash_hal.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hal/src/rtl872x/exflash_hal.cpp b/hal/src/rtl872x/exflash_hal.cpp index 391c01f326..74cd293304 100644 --- a/hal/src/rtl872x/exflash_hal.cpp +++ b/hal/src/rtl872x/exflash_hal.cpp @@ -33,6 +33,7 @@ extern "C" { #include "service_debug.h" #include "check.h" #include "scope_guard.h" +#include // for portBYTE_ALIGNMENT // TODO: move it to header file #define HAL_EXFLASH_OTP_MAGIC_NUMBER_ADDR 0x0 @@ -58,6 +59,13 @@ typedef enum { #error "Unsupported external flash" #endif +void dcacheInvalidateAligned(uintptr_t ptr, size_t size) { + uintptr_t alignedPtr = ptr & ~(portBYTE_ALIGNMENT_MASK); + uintptr_t end = ptr + size; + size_t alignedSize = CEIL_DIV(end - alignedPtr, portBYTE_ALIGNMENT) * portBYTE_ALIGNMENT; + DCache_Invalidate(alignedPtr, alignedSize); +} + class RsipIfRequired { public: RsipIfRequired(uint32_t address) { @@ -244,6 +252,7 @@ __attribute__((section(".ram.text"), noinline)) int hal_exflash_write(uintptr_t addr, const uint8_t* data_buf, size_t data_size) { ExFlashLock lk; CHECK(hal_flash_common_write(addr, data_buf, data_size, &perform_write, &hal_flash_common_dummy_read)); + dcacheInvalidateAligned(addr + SPI_FLASH_BASE, data_size); return SYSTEM_ERROR_NONE; } @@ -289,6 +298,8 @@ static int erase_common(uintptr_t start_addr, size_t num_blocks, int len) { // LOG_DEBUG(ERROR, "Erased %lu %lukB blocks starting from %" PRIxPTR, // num_blocks, block_length / 1024, start_addr); + dcacheInvalidateAligned(SPI_FLASH_BASE + start_addr, block_length * num_blocks); + return SYSTEM_ERROR_NONE; } From fe2671a16d7c4b8f61158a0dbeebb90827920335 Mon Sep 17 00:00:00 2001 From: Scott Brust Date: Wed, 7 Dec 2022 11:49:34 -0800 Subject: [PATCH 104/112] Free memory from rtl sdk in SystemISRTaskQueue --- system/src/system_task.cpp | 20 ++++++++++++++++++++ third_party/ambd_sdk/ambd_sdk | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/system/src/system_task.cpp b/system/src/system_task.cpp index 95f489f867..4a109bc586 100644 --- a/system/src/system_task.cpp +++ b/system/src/system_task.cpp @@ -467,6 +467,26 @@ void manage_ble_prov_mode() { #endif } +extern "C" void system_isr_task_queue_free_memory(uint8_t *ptrToFree) { + struct FreeTask : ISRTaskQueue::Task { + uint8_t *arg; + }; + + auto task = static_cast(system_pool_alloc(sizeof(FreeTask), nullptr)); + if (!task) + { + return; + } + task->arg = ptrToFree; + task->func = [](ISRTaskQueue::Task * task) { + auto freeTask = reinterpret_cast(task); + free(freeTask->arg); + system_pool_free(task, nullptr); + }; + + SystemISRTaskQueue.enqueue(task); +} + static void process_isr_task_queue() { SystemISRTaskQueue.process(); diff --git a/third_party/ambd_sdk/ambd_sdk b/third_party/ambd_sdk/ambd_sdk index eb54fb5280..653833c32d 160000 --- a/third_party/ambd_sdk/ambd_sdk +++ b/third_party/ambd_sdk/ambd_sdk @@ -1 +1 @@ -Subproject commit eb54fb5280ccf2c3b6af26cca4796ae2a00c6115 +Subproject commit 653833c32dad4abc04d3af915cfe4219cd5d685b From 78fac702337fb1a0f3097941ad59540426ff1c3c Mon Sep 17 00:00:00 2001 From: Scott Brust Date: Wed, 7 Dec 2022 13:59:48 -0800 Subject: [PATCH 105/112] Review feedback --- hal/src/rtl872x/rtl_sdk_support.cpp | 10 ++++++++++ system/inc/system_task.h | 2 ++ system/src/system_task.cpp | 11 ++++++----- third_party/ambd_sdk/ambd_sdk | 2 +- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/hal/src/rtl872x/rtl_sdk_support.cpp b/hal/src/rtl872x/rtl_sdk_support.cpp index 2cadeb5141..0004368730 100644 --- a/hal/src/rtl872x/rtl_sdk_support.cpp +++ b/hal/src/rtl872x/rtl_sdk_support.cpp @@ -34,6 +34,7 @@ extern "C" { #include "interrupts_hal.h" #include "osdep_service.h" #include "concurrent_hal.h" +#include "system_task.h" extern "C" { @@ -221,6 +222,15 @@ extern "C" void HAL_Core_System_Reset(void) { } } +extern "C" void _freertos_mfree(uint8_t *pbuf, u32 sz) { + if (__get_BASEPRI() != 0) { + // Defer freeing of memory to the SystemISRTaskQueue to be processed outside of this critical section + SPARK_ASSERT(system_isr_task_queue_free_memory((void*)pbuf) == 0); + } else { + vPortFree(pbuf); + } +} + extern "C" { #if 0 // Enable to get btgap logs diff --git a/system/inc/system_task.h b/system/inc/system_task.h index 55fdd1f9c3..38d3947025 100644 --- a/system/inc/system_task.h +++ b/system/inc/system_task.h @@ -114,6 +114,8 @@ int system_invoke_event_handler(uint16_t handlerInfoSize, FilteringEventHandler* typedef int (*system_task_fn)(); +int system_isr_task_queue_free_memory(void *ptrToFree); + #ifdef __cplusplus } #endif diff --git a/system/src/system_task.cpp b/system/src/system_task.cpp index 4a109bc586..316cfa8f75 100644 --- a/system/src/system_task.cpp +++ b/system/src/system_task.cpp @@ -467,16 +467,16 @@ void manage_ble_prov_mode() { #endif } -extern "C" void system_isr_task_queue_free_memory(uint8_t *ptrToFree) { +int system_isr_task_queue_free_memory(void *ptrToFree) { struct FreeTask : ISRTaskQueue::Task { - uint8_t *arg; + void *arg; }; auto task = static_cast(system_pool_alloc(sizeof(FreeTask), nullptr)); - if (!task) - { - return; + if (!task) { + return SYSTEM_ERROR_NO_MEMORY; } + task->arg = ptrToFree; task->func = [](ISRTaskQueue::Task * task) { auto freeTask = reinterpret_cast(task); @@ -485,6 +485,7 @@ extern "C" void system_isr_task_queue_free_memory(uint8_t *ptrToFree) { }; SystemISRTaskQueue.enqueue(task); + return 0; } static void process_isr_task_queue() diff --git a/third_party/ambd_sdk/ambd_sdk b/third_party/ambd_sdk/ambd_sdk index 653833c32d..7e148162ed 160000 --- a/third_party/ambd_sdk/ambd_sdk +++ b/third_party/ambd_sdk/ambd_sdk @@ -1 +1 @@ -Subproject commit 653833c32dad4abc04d3af915cfe4219cd5d685b +Subproject commit 7e148162ed6b06a72b1b44332da321d6e26c095f From 97d4b76748140ef5b3159c70827fc3d2d8743620 Mon Sep 17 00:00:00 2001 From: Scott Brust Date: Wed, 7 Dec 2022 14:13:50 -0800 Subject: [PATCH 106/112] minor --- hal/src/rtl872x/rtl_sdk_support.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hal/src/rtl872x/rtl_sdk_support.cpp b/hal/src/rtl872x/rtl_sdk_support.cpp index 0004368730..9c58b9fb82 100644 --- a/hal/src/rtl872x/rtl_sdk_support.cpp +++ b/hal/src/rtl872x/rtl_sdk_support.cpp @@ -222,17 +222,16 @@ extern "C" void HAL_Core_System_Reset(void) { } } -extern "C" void _freertos_mfree(uint8_t *pbuf, u32 sz) { +extern "C" { +void _freertos_mfree(uint8_t *pbuf, u32 sz) { if (__get_BASEPRI() != 0) { // Defer freeing of memory to the SystemISRTaskQueue to be processed outside of this critical section SPARK_ASSERT(system_isr_task_queue_free_memory((void*)pbuf) == 0); } else { - vPortFree(pbuf); + free(pbuf); } } -extern "C" { - #if 0 // Enable to get btgap logs /* Internal function that is used by internal macro DBG_DIRECT. */ From bbc036651646d894e8612f432e19aa368d7e3362 Mon Sep 17 00:00:00 2001 From: Scott Brust Date: Wed, 7 Dec 2022 15:20:52 -0800 Subject: [PATCH 107/112] Only use _freertos_mfree in system build, dont bring it + system_task.h into bootloader --- hal/src/rtl872x/rtl_osdep.cpp | 13 +++++++++++++ hal/src/rtl872x/rtl_sdk_support.cpp | 9 --------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/hal/src/rtl872x/rtl_osdep.cpp b/hal/src/rtl872x/rtl_osdep.cpp index 0c329d7d0e..13470ff183 100644 --- a/hal/src/rtl872x/rtl_osdep.cpp +++ b/hal/src/rtl872x/rtl_osdep.cpp @@ -15,6 +15,19 @@ * License along with this library; if not, see . */ +extern "C" { +#include "rtl8721d.h" +} +#include "system_task.h" + +extern "C" void _freertos_mfree(u8 *pbuf, u32 sz) { + if (__get_BASEPRI() != 0) { + // Defer freeing of memory to the SystemISRTaskQueue to be processed outside of this critical section + SPARK_ASSERT(system_isr_task_queue_free_memory((void*)pbuf) == 0); + } else { + free(pbuf); + } +} // namespace osdep { // u8* malloc(u32 sz) { diff --git a/hal/src/rtl872x/rtl_sdk_support.cpp b/hal/src/rtl872x/rtl_sdk_support.cpp index 9c58b9fb82..2cadeb5141 100644 --- a/hal/src/rtl872x/rtl_sdk_support.cpp +++ b/hal/src/rtl872x/rtl_sdk_support.cpp @@ -34,7 +34,6 @@ extern "C" { #include "interrupts_hal.h" #include "osdep_service.h" #include "concurrent_hal.h" -#include "system_task.h" extern "C" { @@ -223,14 +222,6 @@ extern "C" void HAL_Core_System_Reset(void) { } extern "C" { -void _freertos_mfree(uint8_t *pbuf, u32 sz) { - if (__get_BASEPRI() != 0) { - // Defer freeing of memory to the SystemISRTaskQueue to be processed outside of this critical section - SPARK_ASSERT(system_isr_task_queue_free_memory((void*)pbuf) == 0); - } else { - free(pbuf); - } -} #if 0 // Enable to get btgap logs From 4b4c3fa80fceb7955bb9d44d9687c04c7d47298f Mon Sep 17 00:00:00 2001 From: Technobly Date: Fri, 9 Dec 2022 00:23:45 -0600 Subject: [PATCH 108/112] [rtl872x] fixes System.ticks() --- hal/inc/hal_platform.h | 5 ++ .../nRF52840/hal_platform_nrf52840_config.h | 3 ++ platform/MCU/newhal-mcu/inc/hw_ticks.h | 4 +- platform/MCU/rtl872x/inc/hw_ticks.h | 6 +-- platform/MCU/rtl872x/src/hw_ticks.c | 5 -- user/tests/wiring/no_fixture/system.cpp | 48 +++++++++++++++++++ user/tests/wiring/no_fixture_spi/spix.cpp | 13 +++-- wiring/inc/spark_wiring_system.h | 12 ++++- 8 files changed, 79 insertions(+), 17 deletions(-) diff --git a/hal/inc/hal_platform.h b/hal/inc/hal_platform.h index 70e6cc1cd7..db42ff3ce7 100644 --- a/hal/inc/hal_platform.h +++ b/hal/inc/hal_platform.h @@ -541,4 +541,9 @@ #define HAL_PLATFORM_I2C_BUFFER_SIZE(x) (HAL_PLATFORM_I2C_BUFFER_SIZE_DEFAULT) #endif // HAL_PLATFORM_I2C_BUFFER_SIZE +// hardware counter for System.ticks() +#ifndef HAL_PLATFORM_SYSTEM_HW_TICKS +#define HAL_PLATFORM_SYSTEM_HW_TICKS (0) +#endif // HAL_PLATFORM_SYSTEM_HW_TICKS + #endif /* HAL_PLATFORM_H */ diff --git a/hal/src/nRF52840/hal_platform_nrf52840_config.h b/hal/src/nRF52840/hal_platform_nrf52840_config.h index b4419a22e5..163554c7d1 100644 --- a/hal/src/nRF52840/hal_platform_nrf52840_config.h +++ b/hal/src/nRF52840/hal_platform_nrf52840_config.h @@ -107,3 +107,6 @@ #define HAL_PLATFORM_ERROR_MESSAGES (1) #define HAL_PLATFORM_PROHIBIT_XIP (1) + +// hardware counter for System.ticks() supported +#define HAL_PLATFORM_SYSTEM_HW_TICKS (1) diff --git a/platform/MCU/newhal-mcu/inc/hw_ticks.h b/platform/MCU/newhal-mcu/inc/hw_ticks.h index 37b936f130..f376bdbd1b 100644 --- a/platform/MCU/newhal-mcu/inc/hw_ticks.h +++ b/platform/MCU/newhal-mcu/inc/hw_ticks.h @@ -28,10 +28,10 @@ extern "C" { * The number of ticks per microsecond of the system counter. * SYSTEM_TICK_COUNTER */ -#define SYSTEM_US_TICKS 100 // cycles per microsecond +#define SYSTEM_US_TICKS (1) // cycles per microsecond /** - * Should return a value from a system counter. + * Should return a value from a system hardware counter if supported. */ #define SYSTEM_TICK_COUNTER 0 diff --git a/platform/MCU/rtl872x/inc/hw_ticks.h b/platform/MCU/rtl872x/inc/hw_ticks.h index adb07333cd..3b25a657bf 100644 --- a/platform/MCU/rtl872x/inc/hw_ticks.h +++ b/platform/MCU/rtl872x/inc/hw_ticks.h @@ -23,8 +23,8 @@ #include "platform_config.h" #include "system_tick_hal.h" -#define SYSTEM_US_TICKS (SystemCoreClock / 1000000) //cycles per microsecond -#define SYSTEM_TICK_COUNTER GetDwtCounter() +#define SYSTEM_US_TICKS (1) //cycles per microsecond +#define SYSTEM_TICK_COUNTER HAL_Timer_Get_Micro_Seconds() #ifdef __cplusplus extern "C" { @@ -62,8 +62,6 @@ uint64_t GetSystem1MsTick64(); */ system_tick_t GetSystem1UsTick(); -uint32_t GetDwtCounter(); - #ifdef __cplusplus } #endif diff --git a/platform/MCU/rtl872x/src/hw_ticks.c b/platform/MCU/rtl872x/src/hw_ticks.c index 72ceb0b160..6e14eec760 100644 --- a/platform/MCU/rtl872x/src/hw_ticks.c +++ b/platform/MCU/rtl872x/src/hw_ticks.c @@ -17,7 +17,6 @@ #include "hw_ticks.h" #include "timer_hal.h" -#include "rtl8721d.h" void System1MsTick(void) { @@ -50,7 +49,3 @@ void __advance_system1MsTick(uint64_t millis, system_tick_t micros_from_rollover { // Unsupported } - -uint32_t GetDwtCounter() { - return DWT->CYCCNT; -} diff --git a/user/tests/wiring/no_fixture/system.cpp b/user/tests/wiring/no_fixture/system.cpp index e9778900c2..aae38e922c 100644 --- a/user/tests/wiring/no_fixture/system.cpp +++ b/user/tests/wiring/no_fixture/system.cpp @@ -439,3 +439,51 @@ test(SYSTEM_08_hardware_info) { } #endif // HAL_PLATFORM_NCP } + +test(SYSTEM_09_system_ticks) { + // Serial.printlnf("ticksPerMicrosecond: %lu %lu", System.ticksPerMicrosecond(), System.ticksPerMicrosecond() * 100); + const uint32_t NUM_ITERATIONS = 100; + const uint32_t DURATION_US = 1000; // 10% higher than measured (includes for() loop overhead) + const uint32_t DURATION_TICKS = System.ticksPerMicrosecond() * DURATION_US; + const uint32_t MIN_DURATION_TICKS = DURATION_TICKS * 95 / 100; // 5% lower than measured (includes for() loop overhead) + const uint32_t MAX_DURATION_TICKS = DURATION_TICKS * 105 / 100; // 5% higher than measured (includes for() loop overhead) + uint32_t start; + uint32_t finish; + ATOMIC_BLOCK() { + start = System.ticks(); + for (uint32_t i = 0; i < NUM_ITERATIONS; i++) { + HAL_Delay_Microseconds(DURATION_US); + } + finish = System.ticks(); + } + uint32_t ticks = finish - start; + uint32_t expected_low = NUM_ITERATIONS * MIN_DURATION_TICKS; + uint32_t expected_high = NUM_ITERATIONS * MAX_DURATION_TICKS; + // Serial.printlnf("ticks: %lu <= %lu <= %lu", expected_low, ticks, expected_high); + assertLessOrEqual(ticks, expected_high); + assertMoreOrEqual(ticks, expected_low); +} + +test(SYSTEM_10_system_ticks_delay) { + // Serial.printlnf("ticksPerMicrosecond: %lu %lu", System.ticksPerMicrosecond(), System.ticksPerMicrosecond() * 100); + const uint32_t NUM_ITERATIONS = 100; + const uint32_t DURATION_US = 1000; // 10% higher than measured (includes for() loop overhead) + const uint32_t DURATION_TICKS = System.ticksPerMicrosecond() * DURATION_US; + const uint32_t MIN_DURATION_US = DURATION_US * 95 / 100; // 5% lower than measured (includes for() loop overhead) + const uint32_t MAX_DURATION_US = DURATION_US * 105 / 100; // 5% higher than measured (includes for() loop overhead) + uint32_t start; + uint32_t finish; + ATOMIC_BLOCK() { + start = HAL_Timer_Get_Micro_Seconds(); + for (uint32_t i = 0; i < NUM_ITERATIONS; i++) { + System.ticksDelay(DURATION_TICKS); + } + finish = HAL_Timer_Get_Micro_Seconds(); + } + uint32_t duration = finish - start; + uint32_t expected_low = NUM_ITERATIONS * MIN_DURATION_US; + uint32_t expected_high = NUM_ITERATIONS * MAX_DURATION_US; + // Serial.printlnf("duration: %lu <= %lu <= %lu", expected_low, duration, expected_high); + assertLessOrEqual(duration, expected_high); + assertMoreOrEqual(duration, expected_low); +} diff --git a/user/tests/wiring/no_fixture_spi/spix.cpp b/user/tests/wiring/no_fixture_spi/spix.cpp index 7bc98d187f..96d994c616 100644 --- a/user/tests/wiring/no_fixture_spi/spix.cpp +++ b/user/tests/wiring/no_fixture_spi/spix.cpp @@ -391,7 +391,12 @@ template Date: Wed, 14 Dec 2022 13:09:05 -0600 Subject: [PATCH 109/112] [trackerM] Collect cellular properties with system info --- hal/src/trackerm/ota_flash_hal.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/hal/src/trackerm/ota_flash_hal.cpp b/hal/src/trackerm/ota_flash_hal.cpp index 3c044809b5..c2a06d2061 100644 --- a/hal/src/trackerm/ota_flash_hal.cpp +++ b/hal/src/trackerm/ota_flash_hal.cpp @@ -19,8 +19,20 @@ #include "ota_flash_hal_impl.h" #include "platform_ncp.h" #include "platform_radio_stack.h" +#include "cellular_hal.h" void HAL_OTA_Add_System_Info(hal_system_info_t* info, bool create, void* reserved) { - add_system_properties(info, create, 0); + const int additional = 3; + int count = add_system_properties(info, create, additional); + if (create) { + info->key_value_count = count + additional; + + CellularDevice device = {}; + device.size = sizeof(device); + cellular_device_info(&device, NULL); + set_key_value(info->key_values+count, "imei", device.imei); + set_key_value(info->key_values+count+1, "iccid", device.iccid); + set_key_value(info->key_values+count+2, "cellfw", device.radiofw); + } } From c359f83167aaef646c7a99a79c47910ecdefe3e7 Mon Sep 17 00:00:00 2001 From: Scott Brust Date: Wed, 14 Dec 2022 16:56:18 -0800 Subject: [PATCH 110/112] Poll channel enable bit, exit when xfer finishes and channel is disabled --- hal/src/rtl872x/usart_hal.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hal/src/rtl872x/usart_hal.cpp b/hal/src/rtl872x/usart_hal.cpp index 029bb7af20..6e400e7357 100644 --- a/hal/src/rtl872x/usart_hal.cpp +++ b/hal/src/rtl872x/usart_hal.cpp @@ -743,8 +743,8 @@ class Usart { GDMA_BASE->CH[rxDmaInitStruct_.GDMA_ChNum].CFG_LOW |= BIT_CFGX_LO_CH_SUSP; __DSB(); __ISB(); - while (GDMA_GetDstAddr(rxDmaInitStruct_.GDMA_Index, rxDmaInitStruct_.GDMA_ChNum) < expectedDstAddr) { - // XXX: spin around, this should be pretty fast + while (GDMA_GetDstAddr(rxDmaInitStruct_.GDMA_Index, rxDmaInitStruct_.GDMA_ChNum) < expectedDstAddr && + (GDMA_BASE->ChEnReg & (1 << rxDmaInitStruct_.GDMA_ChNum))) { } GDMA_BASE->CH[rxDmaInitStruct_.GDMA_ChNum].CFG_LOW &= ~(BIT_CFGX_LO_CH_SUSP); __DSB(); From 51a0e637eada25b08e90d547c88a337df3eb9eac Mon Sep 17 00:00:00 2001 From: Scott Brust Date: Fri, 16 Dec 2022 09:29:31 -0800 Subject: [PATCH 111/112] comments --- hal/src/rtl872x/usart_hal.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hal/src/rtl872x/usart_hal.cpp b/hal/src/rtl872x/usart_hal.cpp index 6e400e7357..9b0b6d4e3a 100644 --- a/hal/src/rtl872x/usart_hal.cpp +++ b/hal/src/rtl872x/usart_hal.cpp @@ -740,11 +740,16 @@ class Usart { if ((GDMA_BASE->CH[rxDmaInitStruct_.GDMA_ChNum].CFG_LOW & BIT_CFGX_LO_FIFO_EMPTY) == 0) { if (GDMA_GetDstAddr(rxDmaInitStruct_.GDMA_Index, rxDmaInitStruct_.GDMA_ChNum) < expectedDstAddr) { // Suspending DMA channel forces flushing of data into destination from GDMA FIFO + // NOTE: The datasheet says that "there is no guarantee that the current transaction will complete", which is why we enter the busy loop below in these cases GDMA_BASE->CH[rxDmaInitStruct_.GDMA_ChNum].CFG_LOW |= BIT_CFGX_LO_CH_SUSP; __DSB(); __ISB(); while (GDMA_GetDstAddr(rxDmaInitStruct_.GDMA_Index, rxDmaInitStruct_.GDMA_ChNum) < expectedDstAddr && (GDMA_BASE->ChEnReg & (1 << rxDmaInitStruct_.GDMA_ChNum))) { + // This loop is intended to delay until the DMA controller transfers the expected number of bytes, based off of the address returned in GDMA_GetDstAddr() + // When a DMA transaction is near the end of a block (within the last 4 bytes), sometimes the address returned does not increment to the expected destination. In some cases it resets completely. + // To work around this, we poll the ChEnReg bit for the RX DMA channel. The data sheet says it is: "automatically cleared by hardware when the DMA transfer to the destination is complete". + // The assumption is that if we see this bit is cleared, then the transfer is complete, the data we wanted flushed is available, there is no point to waiting any longer and we can return. } GDMA_BASE->CH[rxDmaInitStruct_.GDMA_ChNum].CFG_LOW &= ~(BIT_CFGX_LO_CH_SUSP); __DSB(); From a6f8503820445c640ff7b2e01090910fb3ca3c6c Mon Sep 17 00:00:00 2001 From: Scott Brust Date: Fri, 16 Dec 2022 11:05:08 -0800 Subject: [PATCH 112/112] bump module version to 5.2.0 (5200) --- CHANGELOG.md | 53 +++++++++++++++++++++++++ build/release.sh | 2 +- build/version.mk | 4 +- modules/shared/system_module_version.mk | 10 ++--- system/inc/system_version.h | 4 +- system/system-versions.md | 1 + 6 files changed, 65 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3239ccb109..75c9ab78d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,50 @@ +## 5.2.0 + +### FEATURES +- Initial support for BG95-M6 modem [#2555](https://github.com/particle-iot/device-os/pull/2555) + +### ENHANCEMENTS +- [TrackerM] Collect cellular properties with system info [#2602](https://github.com/particle-iot/device-os/pull/2602) +- [rtl872x] fixes System.ticks() [#2600](https://github.com/particle-iot/device-os/pull/2600) +- System setup and BLE threading improvements [#2587](https://github.com/particle-iot/device-os/pull/2587) +- [rtl872x] [freertos] [experimental] multi-step priority disinheritance [#2581](https://github.com/particle-iot/device-os/pull/2581) +- [rtl872x] sleep improvements [#2586](https://github.com/particle-iot/device-os/pull/2586) +- [rtl872x] fixes pinResetFast clearing too many pins and improves speed [#2582](https://github.com/particle-iot/device-os/pull/2582) +- [rtl872x] prebootloader: enable BOR with lowest available thresholds [#2569](https://github.com/particle-iot/device-os/pull/2569) + +### BUGFIXES +- [rtl872x] Fix USART/DMA deadlock [#2603](https://github.com/particle-iot/device-os/pull/2603) +- [rtl872x] Free memory from rtl sdk in SystemISRTaskQueue [#2599](https://github.com/particle-iot/device-os/pull/2599) +- [rtl872x] exflash: revert dcache invalidate calls after writes/erasures [#2598](https://github.com/particle-iot/device-os/pull/2598) +- [rtl872x] Fixes a deadlock when requiring to enable RSIP [#2596](https://github.com/particle-iot/device-os/pull/2596) +- [gen3] Use OTP Feature flag to change ADC reference source [#2597](https://github.com/particle-iot/device-os/pull/2597) +- [rtl872x] hal: remove an assert in read()/peek() and instead adjust read/peek size [#2594](https://github.com/particle-iot/device-os/pull/2594) +- [boron]Use the internal ADC reference on BRN404X [#2588](https://github.com/particle-iot/device-os/pull/2588) +- [p2] Fixes the conflict between Flash API and XIP [#2561](https://github.com/particle-iot/device-os/pull/2561) +- [Quectel] Account for "eMTC" type while obtaining signal values [#2589](https://github.com/particle-iot/device-os/pull/2589) +- [Boron / B SoM] R410 PPP crash in network phase workaround [#2571](https://github.com/particle-iot/device-os/pull/2571) +- [Cellular] R410 initialization SIM failure workaround [#2573](https://github.com/particle-iot/device-os/pull/2573) +- [gen3] [p2] Fix i2c hal deadlock [#2572](https://github.com/particle-iot/device-os/pull/2572) +- [TrackerM] Prevent connection over wifi when configured in SCAN_ONLY mode [#2567](https://github.com/particle-iot/device-os/pull/2567) +- [p2] WiFi bugfixes [#2562](https://github.com/particle-iot/device-os/pull/2562) +- [tracker/trackerm] Fix acquireWireBuffer for platforms where system initializes I2C before user app [2551](https://github.com/particle-iot/device-os/pull/2551) +- [rtl872x] BLE Central connection failure when peer disconnects [#2552](https://github.com/particle-iot/device-os/pull/2552) + +### INTERNAL +- [test] Use compatible pins for PWM tests on TrackerM [#2592](https://github.com/particle-iot/device-os/pull/2592) +- [test] bump fastpin max limit to 10% [#2591](https://github.com/particle-iot/device-os/pull/2591) +- [test] Add thresholds for trackerM for slo tests [#2590](https://github.com/particle-iot/device-os/pull/2590) +- [test] Modify pins for trackerM spix tests [#2585](https://github.com/particle-iot/device-os/pull/2585) +- [trackerm] TrackerM EVT v0.0.3 pinmap update [#2580](https://github.com/particle-iot/device-os/pull/2580) +- Allow setting the ICCID of a virtual device [#2583](https://github.com/particle-iot/device-os/pull/2583) +- Protobuf defs refactor / fixes submessage encoding after nanopb 0.4.5 upgrade [#2578](https://github.com/particle-iot/device-os/pull/2578) +- Update nanopb to 0.4.5 [#2563](https://github.com/particle-iot/device-os/pull/2563) +- Fix no_fixture_i2c for esomx,boron,bsom platforms [#2559](https://github.com/particle-iot/device-os/pull/2559) +- [CI] fixes [#2564](https://github.com/particle-iot/device-os/pull/2564) +- Move no_fixture_i2c to correct dir and symlink to integration/wiring [#2558](https://github.com/particle-iot/device-os/pull/2558) +- [trackerm] TrackerM EVT v0.0.2 pinmap update [#2550](https://github.com/particle-iot/device-os/pull/2550) +- Increase timeouts for internal CI builds on windows [#2545](https://github.com/particle-iot/device-os/pull/2545) + ## 5.1.0 ### FEATURES @@ -136,6 +183,12 @@ - [tests] Fix broken tone and servo tests for p2 platform, also EEPROM_03 for all. [#2469](https://github.com/particle-iot/device-os/pull/2469) - [workbench] Stop ignoring device os scripts directory [#2471](https://github.com/particle-iot/device-os/pull/2471) +## 4.0.2 + +### BUGFIXES +- [gen3] Use OTP Feature flag to change ADC reference source [#2597](https://github.com/particle-iot/device-os/pull/2597) +- [boron]Use the internal ADC reference on some Gen 3 platforms [#2588](https://github.com/particle-iot/device-os/pull/2588) + ## 4.0.1 ### BUGFIXES diff --git a/build/release.sh b/build/release.sh index 469dea5427..288bf15d2e 100755 --- a/build/release.sh +++ b/build/release.sh @@ -1,7 +1,7 @@ #!/bin/bash set -o errexit -o pipefail -o noclobber -o nounset -VERSION=${VERSION:="5.1.0"} +VERSION=${VERSION:="5.2.0"} function display_help () { diff --git a/build/version.mk b/build/version.mk index 188222cfc5..1b3bc6fb82 100755 --- a/build/version.mk +++ b/build/version.mk @@ -1,7 +1,7 @@ -VERSION_STRING = 5.1.0 +VERSION_STRING = 5.2.0 # PRODUCT_FIRMWARE_VERSION reported by default # FIXME: Unclear if this is used, PRODUCT_FIRMWARE_VERSION defaults to 65535 every release -VERSION = 5004 +VERSION = 5200 CFLAGS += -DSYSTEM_VERSION_STRING=$(VERSION_STRING) diff --git a/modules/shared/system_module_version.mk b/modules/shared/system_module_version.mk index 0b502d15f5..86a8d47a4e 100644 --- a/modules/shared/system_module_version.mk +++ b/modules/shared/system_module_version.mk @@ -1,6 +1,6 @@ # Skip to next 100 every v0.x.0 release (e.g. 108 for v0.6.2 to 200 for v0.7.0-rc.1) # Bump by 1 for every prerelease or release with the same v0.x.* base. -COMMON_MODULE_VERSION ?= 5004 +COMMON_MODULE_VERSION ?= 5200 SYSTEM_PART1_MODULE_VERSION ?= $(COMMON_MODULE_VERSION) RELEASE_080_MODULE_VERSION_BASE ?= 300 @@ -14,24 +14,24 @@ USER_PART_MODULE_VERSION ?= 6 # Skip to next 100 every v0.x.0 release (e.g. 11 for v0.6.2 to 100 for v0.7.0-rc.1), # but only if the bootloader has changed since the last v0.x.0 release. # Bump by 1 for every updated bootloader image for a release with the same v0.x.* base. -BOOTLOADER_VERSION ?= 2001 +BOOTLOADER_VERSION ?= 2002 ifeq ($(PLATFORM_MCU),rtl872x) PREBOOTLOADER_MBR_VERSION ?= 2 -PREBOOTLOADER_PART1_VERSION ?= 3 +PREBOOTLOADER_PART1_VERSION ?= 4 endif # The version of the bootloader that the system firmware requires # NOTE: this will force the device into safe mode until this dependency is met, which is why # this version usually lags behind the current bootloader version, to avoid non-mandatory updates. ifeq ($(PLATFORM_GEN),3) -BOOTLOADER_DEPENDENCY = 2001 +BOOTLOADER_DEPENDENCY = 2002 else # Some sensible default BOOTLOADER_DEPENDENCY = 0 endif ifeq ($(PLATFORM_MCU),rtl872x) -PREBOOTLOADER_PART1_DEPENDENCY = 3 +PREBOOTLOADER_PART1_DEPENDENCY = 4 endif ifeq ($(PLATFORM_GEN),3) diff --git a/system/inc/system_version.h b/system/inc/system_version.h index 9eaa01ba00..7d312aecd1 100644 --- a/system/inc/system_version.h +++ b/system/inc/system_version.h @@ -201,7 +201,8 @@ extern "C" { #define SYSTEM_VERSION_v500 SYSTEM_VERSION_DEFAULT(5, 0, 0) #define SYSTEM_VERSION_v501 SYSTEM_VERSION_DEFAULT(5, 0, 1) #define SYSTEM_VERSION_v510 SYSTEM_VERSION_DEFAULT(5, 1, 0) -#define SYSTEM_VERSION SYSTEM_VERSION_v510 +#define SYSTEM_VERSION_v520 SYSTEM_VERSION_DEFAULT(5, 2, 0) +#define SYSTEM_VERSION SYSTEM_VERSION_v520 /** * Previously we would set the least significant byte to 0 for the final release, but to make @@ -367,6 +368,7 @@ extern "C" { #define SYSTEM_VERSION_500 #define SYSTEM_VERSION_501 #define SYSTEM_VERSION_510 +#define SYSTEM_VERSION_520 typedef struct __attribute__((packed)) SystemVersionInfo { diff --git a/system/system-versions.md b/system/system-versions.md index ac9a90fa2d..338795dbcb 100644 --- a/system/system-versions.md +++ b/system/system-versions.md @@ -176,6 +176,7 @@ | 2000 | 5002 | 5.0.0 | Argon, Boron, B SoM, B5 SoM, Tracker, Tracker M, E Som X, P2 | | 2001 | 5003 | 5.0.1 | Argon, Boron, B SoM, B5 SoM, Tracker, Tracker M, E Som X, P2 | | 2001 | 5004 | 5.1.0 | Argon, Boron, B SoM, B5 SoM, Tracker, Tracker M, E Som X, P2 | +| 2002 | 5200 | 5.2.0 | Argon, Boron, B SoM, B5 SoM, Tracker, Tracker M, E Som X, P2 | [1] For 0.8.0-rc.1, The v101 bootloader was also released in the Github releases as v200. Thus the next released bootloader in the 0.8.x line should be v201. As of 4/5/2018: 22 device had v200 bootloaders.