From 0f2c5e803f636ac2a9b4e27b4676e1ec758a81e1 Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Tue, 9 Mar 2021 10:44:01 +0100 Subject: [PATCH] custom prov --- src/CMakeLists.txt | 2 +- src/Makefile | 2 +- src/README.md | 268 +--- .../custom_provisioning/CMakeLists.txt | 5 + .../custom_provisioning/component.mk | 3 + .../custom_provisioning/custom_config.h | 44 + .../proto-c/custom_config.pb-c.c | 229 +++ .../proto-c/custom_config.pb-c.h | 113 ++ .../custom_provisioning/proto/CMakeLists.txt | 26 + .../custom_provisioning/proto/README.md | 27 + .../proto/custom_config.proto | 16 + .../custom_provisioning/proto/makefile | 7 + .../python/custom_config_pb2.py | 152 ++ .../custom_provisioning/src/custom_config.c | 68 + src/main/CMakeLists.txt | 2 + src/main/Kconfig.projbuild | 67 +- src/main/app_main.c | 286 +--- src/main/app_prov.c | 398 +++++ src/main/app_prov.h | 88 ++ src/main/app_prov_handlers.c | 147 ++ src/partitions.csv | 5 - src/sdkconfig | 1287 +++++++++++++++++ src/sdkconfig.defaults | 11 - src/wifi_prov_mgr_test.py | 100 -- 24 files changed, 2787 insertions(+), 566 deletions(-) create mode 100644 src/components/custom_provisioning/CMakeLists.txt create mode 100644 src/components/custom_provisioning/component.mk create mode 100644 src/components/custom_provisioning/include/custom_provisioning/custom_config.h create mode 100644 src/components/custom_provisioning/proto-c/custom_config.pb-c.c create mode 100644 src/components/custom_provisioning/proto-c/custom_config.pb-c.h create mode 100644 src/components/custom_provisioning/proto/CMakeLists.txt create mode 100644 src/components/custom_provisioning/proto/README.md create mode 100644 src/components/custom_provisioning/proto/custom_config.proto create mode 100644 src/components/custom_provisioning/proto/makefile create mode 100644 src/components/custom_provisioning/python/custom_config_pb2.py create mode 100644 src/components/custom_provisioning/src/custom_config.c create mode 100644 src/main/app_prov.c create mode 100644 src/main/app_prov.h create mode 100644 src/main/app_prov_handlers.c delete mode 100644 src/partitions.csv create mode 100644 src/sdkconfig delete mode 100644 src/sdkconfig.defaults delete mode 100644 src/wifi_prov_mgr_test.py diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b036d9c..ec9b0ce 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,4 +3,4 @@ cmake_minimum_required(VERSION 3.5) include($ENV{IDF_PATH}/tools/cmake/project.cmake) -project(wifi_prov_mgr) +project(custom_config) diff --git a/src/Makefile b/src/Makefile index cbd420b..40cfa8c 100644 --- a/src/Makefile +++ b/src/Makefile @@ -3,6 +3,6 @@ # project subdirectory. # -PROJECT_NAME := wifi_prov_mgr +PROJECT_NAME := custom_config include $(IDF_PATH)/make/project.mk diff --git a/src/README.md b/src/README.md index cf67e01..0af5006 100644 --- a/src/README.md +++ b/src/README.md @@ -1,59 +1,44 @@ -| Supported Targets | ESP32 | ESP32-S2 | -| ----------------- | ----- | -------- | -# Wi-Fi Provisioning Manager Example +# SoftAP + HTTPD based Provisioning Example featuring Custom configuration (Legacy) + +> Note: It is recommended to use the new `wifi_prov_mgr` example which is based on the simpler `wifi_provisioning` APIs. Check this example only if you wish to use lower level provisioning and protocomm APIs and want more control over the handlers. (See the README.md file in the upper level 'examples' directory for more information about examples.) -`wifi_prov_mgr` example demonstrates the usage of `wifi_provisioning` manager component for building a provisioning application. +(Please see the README.md under `softap_prov` example before this.) -For this example, BLE is chosen as the default mode of transport, over which the provisioning related communication is to take place. NimBLE has been configured as the default host, but you can also switch to Bluedroid using menuconfig -> Components -> Bluetooth -> Bluetooth Host. +`custom_config` example demonstrates the implementation and integration of various IDF components for building a provisioning application. -> Note: Since ESP32-S2 does not support BLE, the SoftAP will be the default mode of transport in that case. Even for ESP32, you can change to SoftAP transport from menuconfig. +This is same as `softap_prov` example, with added feature for configuration of some custom data (just like Wi-Fi configuration) during provisioning. The custom data provided during provisioning is simply printed on the serial monitor. The rest of the program functions just like `softap_prov`, ie. the device is configured as Wi-Fi station with supplied AP credentials. -In the provisioning process the device is configured as a Wi-Fi station with specified credentials. Once configured, the device will retain the Wi-Fi configuration, until a flash erase is performed. -Right after provisioning is complete, BLE is turned off and disabled to free the memory used by the BLE stack. Though, that is specific to this example, and the user can choose to keep BLE stack intact in their own application. - -`wifi_prov_mgr` uses the following components : -* `wifi_provisioning` : provides manager, data structures and protocomm endpoint handlers for Wi-Fi configuration +`custom_config` uses the following components : +* `wifi_provisioning` : provides data structures and protocomm endpoint handlers for Wi-Fi configuration * `protocomm` : for protocol based communication and secure session establishment * `protobuf` : Google's protocol buffer library for serialization of protocomm data structures -* `bt` : ESP32 BLE stack for transport of protobuf packets -This example can be used, as it is, for adding a provisioning service to any application intended for IoT. +Also, it uses a component provided with this example `custom_provisioning` which provides data structures and protocomm endpoint handlers for custom data configuration ## How to use example ### Hardware Required -Example should be able to run on any commonly available ESP32/ESP32-S2 development board. +Example should be able to run on any commonly available ESP32 development board. ### Application Required -Provisioning applications are available for various platforms. See below - -#### Platform : Android - -For Android, a provisioning application along with source code is available on GitHub : [esp-idf-provisioning-android](https://github.com/espressif/esp-idf-provisioning-android) - -#### Platform : iOS - -For iOS, a provisioning application along with source code is available on GitHub : [esp-idf-provisioning-ios](https://github.com/espressif/esp-idf-provisioning-ios) - -#### Platform : Linux / Windows / macOS - -To provision the device running this example, the `esp_prov.py` script needs to be run (found under `$IDF_PATH/tools/esp_prov`). Make sure to satisfy all the dependencies prior to running the script. - -Presently, `esp_prov` supports BLE transport only for Linux platform. For Windows/macOS it falls back to console mode and requires another application (for BLE) through which the communication can take place. - -There are various applications, specific to Windows and macOS platform which can be used. The `esp_prov` console will guide you through the provisioning process of locating the correct BLE GATT services and characteristics, the values to write, and input read values. +To provision the device running this example, the `esp_prov.py` script needs to be run (found under `$IDF_PATH/tools/esp_prov`). This feature of `esp_prov` should work on all platforms, given the dependencies are satisfied. ### Configure the project ``` idf.py menuconfig ``` -* Set the BLE/Soft AP transport under "Example Configuration" options. ESP32-S2 will have only SoftAP option. + +* Under Example Configuration set the following : + * SoftAP SSID (Defaults to PROV_) + * SoftAP Password (Defaults to PROV_PASS) + * Security Version (default 0) + * Proof of Possession (by default not needed for security version 0) ### Build and Flash @@ -70,219 +55,90 @@ See the Getting Started Guide for full steps to configure and use ESP-IDF to bui ## Example Output ``` -I (445) app: Starting provisioning -I (1035) app: Provisioning started -I (1045) wifi_prov_mgr: Provisioning started with service name : PROV_261FCC +I (1562) app: SoftAP started +I (1572) app_prov: SoftAP Provisioning started with SSID 'PROV_261FCC', Password 'PROV_PASS' ``` -Make sure to note down the BLE device name (starting with `PROV_`) displayed in the serial monitor log (eg. PROV_261FCC). This will depend on the MAC ID and will be unique for every device. - -In a separate terminal run the `esp_prov.py` script under `$IDP_PATH/tools/esp_prov` directory (make sure to replace `myssid` and `mypassword` with the credentials of the AP to which the device is supposed to connect to after provisioning). Assuming default example configuration, which uses protocomm security scheme 1 and proof of possession PoP based authentication : +Make sure to connect the client computer to the SoftAP network, whose SSID and Password are displayed in the serial monitor log. On successful connection the monitor log will show : ``` -python esp_prov.py --transport ble --service_name PROV_261FCC --sec_ver 1 --pop abcd1234 --ssid myssid --passphrase mypassword +I (519482) tcpip_adapter: softAP assign IP to station,IP is: 192.168.4.2 +``` + +In a separate terminal run the `esp_prov.py` script under `$IDP_PATH/tools/esp_prov` directory (please replace the values corresponding to the parameters `--custom_info` and `--custom_ver` with your desired values for the custom configuration). Assuming default example configuration, the script should be run as follows : + +``` +python esp_prov.py --transport softap --service_name "192.168.4.1:80" --sec_ver 0 --ssid myssid --passphrase mypassword --custom_config --custom_info "some string" --custom_ver 4321 ``` Above command will perform the provisioning steps, and the monitor log should display something like this : ``` -I (39725) app: Received Wi-Fi credentials - SSID : myssid - Password : mypassword +I (92734) app_prov_handler: Custom config received : + Info : some string + Version : 4321 . . . -I (45335) tcpip_adapter: sta ip: 192.168.43.243, mask: 255.255.255.0, gw: 192.168.43.1 -I (45345) app: Provisioning successful -I (45345) app: Connected with IP Address:192.168.43.243 -I (46355) app: Hello World! -I (47355) app: Hello World! -I (48355) app: Hello World! -I (49355) app: Hello World! +I (634572) app_prov_handler: WiFi Credentials Received : + ssid : myssid + password : mypassword . . . -I (52315) wifi_prov_mgr: Provisioning stopped +I (634652) app_prov_handler: WiFi Credentials Applied +I (634652) app_prov: STA Start . . . -I (52355) app: Hello World! -I (53355) app: Hello World! -I (54355) app: Hello World! -I (55355) app: Hello World! +I (688270) app_prov_handler: Connecting state +. +. +. +I (637732) app_prov: STA Got IP +I (637732) app: got ip:192.168.43.220 +. +. +. +I (654562) app_prov_handler: Connected state ``` -### Wi-Fi Scanning - -Provisioning manager also supports providing real-time Wi-Fi scan results (performed on the device) during provisioning. This allows the client side applications to choose the AP for which the device Wi-Fi station is to be configured. Various information about the visible APs is available, like signal strength (RSSI) and security type, etc. Also, the manager now provides capabilities information which can be used by client applications to determine the security type and availability of specific features (like `wifi_scan`). - -When using the scan based provisioning, we don't need to specify the `--ssid` and `--passphrase` fields explicitly: +After sometime the provisioning app will exit, SoftAP will be turned off and HTTP server will be stopped ``` -python esp_prov.py --transport ble --service_name PROV_261FCC --pop abcd1234 -``` - -See below the sample output from `esp_prov` tool on running above command: - -``` -Connecting... -Connected -Getting Services... -Security scheme determined to be : 1 - -==== Starting Session ==== -==== Session Established ==== - -==== Scanning Wi-Fi APs ==== -++++ Scan process executed in 1.9967520237 sec -++++ Scan results : 5 - -++++ Scan finished in 2.7374596596 sec -==== Wi-Fi Scan results ==== -S.N. SSID BSSID CHN RSSI AUTH -[ 1] MyHomeWiFiAP 788a20841996 1 -45 WPA2_PSK -[ 2] MobileHotspot 7a8a20841996 11 -46 WPA2_PSK -[ 3] MyHomeWiFiAP 788a208daa26 11 -54 WPA2_PSK -[ 4] NeighborsWiFiAP 8a8a20841996 6 -61 WPA2_PSK -[ 5] InsecureWiFiAP dca4caf1227c 7 -74 Open - -Select AP by number (0 to rescan) : 1 -Enter passphrase for MyHomeWiFiAP : - -==== Sending Wi-Fi credential to esp32 ==== -==== Wi-Fi Credentials sent successfully ==== - -==== Applying config to esp32 ==== -==== Apply config sent successfully ==== - -==== Wi-Fi connection state ==== -++++ WiFi state: connected ++++ -==== Provisioning was successful ==== -``` - -### Sending Custom Data - -The provisioning manager allows applications to send some custom data during provisioning, which may be -required for some other operations like connecting to some cloud service. This is achieved by creating -and registering additional endpoints using the below APIs - -``` -wifi_prov_mgr_endpoint_create(); -wifi_prov_mgr_endpoint_register(); -``` - -In this particular example, we have added an endpoint named "custom-data" which can be tested -by passing the `--custom_data ` option to the esp\_prov tool. Following output is -expected on success: - -``` -==== Sending Custom data to esp32 ==== -CustomData response: SUCCESS +I (667732) app_prov: Stopping provisioning +I (668732) app_prov: Provisioning stopped +I (668742) app: SoftAP stopped ``` ## Troubleshooting ### Provisioning failed -It is possible that the Wi-Fi credentials provided were incorrect, or the device was not able to establish connection to the network, in which the the `esp_prov` script will notify failure (with reason). Serial monitor log will display the failure along with disconnect reason : +It is possible that the Wi-Fi credentials provided were incorrect, or the device was not able to establish connection to the network, in which the the `esp_prov` script will notify failure (with reason) and the provisioning app will continue running, allowing the user to retry the process. Serial monitor log will display the failure along with disconnect reason : ``` -E (367015) app: Provisioning failed! - Reason : Wi-Fi AP password incorrect - Please reset to factory and retry provisioning +E (39291) app_prov: STA Disconnected +E (39291) app_prov: Disconnect reason : 201 +I (39291) app_prov: STA AP Not found +I (42021) app_prov_handler: Disconnected state ``` -Once credentials have been applied, even though wrong credentials were provided, the device will no longer go into provisioning mode on subsequent reboots until NVS is erased (see following section). - ### Provisioning does not start -If the serial monitor log shows the following : +If the serial monitor log is different, as shown below : ``` -I (465) app: Already provisioned, starting Wi-Fi STA +I (539) app_prov: Found ssid myssid +I (539) app_prov: Found password mypassword +I (549) app: Starting WiFi station ``` -it means either the device has been provisioned earlier with or without success (e.g. scenario covered in above section), or that the Wi-Fi credentials were already set by some other application flashed previously onto your device. On setting the log level to DEBUG this is clearly evident : +It means the Wi-Fi credentials were already set by some other application flashed previously to your device. To erase these credentials either do full erase and then flash the example ``` -D (455) wifi_prov_mgr: Found Wi-Fi SSID : myssid -D (465) wifi_prov_mgr: Found Wi-Fi Password : m********d -I (465) app: Already provisioned, starting Wi-Fi STA +make erase_flash +idf.py -p PORT flash monitor ``` -To fix this we simple need to erase the NVS partition from flash. First we need to find out its address and size. This can be seen from the monitor log on the top right after reboot. - -``` -I (47) boot: Partition Table: -I (50) boot: ## Label Usage Type ST Offset Length -I (58) boot: 0 nvs WiFi data 01 02 00009000 00006000 -I (65) boot: 1 phy_init RF data 01 01 0000f000 00001000 -I (73) boot: 2 factory factory app 00 00 00010000 00124f80 -I (80) boot: End of partition table -``` - -Now erase NVS partition by running the following commands : - -``` -$IDF_PATH/components/esptool_py/esptool/esptool.py erase_region 0x9000 0x6000 -``` - -### Unsupported platform - -If the platform requirement, for running `esp_prov` is not satisfied, then the script execution will fallback to console mode, in which case the full process (involving user inputs) will look like this : - -``` -==== Esp_Prov Version: v1.0 ==== -BLE client is running in console mode - This could be due to your platform not being supported or dependencies not being met - Please ensure all pre-requisites are met to run the full fledged client -BLECLI >> Please connect to BLE device `PROV_261FCC` manually using your tool of choice -BLECLI >> Was the device connected successfully? [y/n] y -BLECLI >> List available attributes of the connected device -BLECLI >> Is the service UUID '0000ffff-0000-1000-8000-00805f9b34fb' listed among available attributes? [y/n] y -BLECLI >> Is the characteristic UUID '0000ff53-0000-1000-8000-00805f9b34fb' listed among available attributes? [y/n] y -BLECLI >> Is the characteristic UUID '0000ff51-0000-1000-8000-00805f9b34fb' listed among available attributes? [y/n] y -BLECLI >> Is the characteristic UUID '0000ff52-0000-1000-8000-00805f9b34fb' listed among available attributes? [y/n] y - -==== Verifying protocol version ==== -BLECLI >> Write following data to characteristic with UUID '0000ff53-0000-1000-8000-00805f9b34fb' : - >> 56302e31 -BLECLI >> Enter data read from characteristic (in hex) : - << 53554343455353 -==== Verified protocol version successfully ==== - -==== Starting Session ==== -BLECLI >> Write following data to characteristic with UUID '0000ff51-0000-1000-8000-00805f9b34fb' : - >> 10015a25a201220a20ae6d9d5d1029f8c366892252d2d5a0ffa7ce1ee5829312545dd5f2aba057294d -BLECLI >> Enter data read from characteristic (in hex) : - << 10015a390801aa0134122048008bfc365fad4753dc75912e0c764d60749cb26dd609595b6fbc72e12614031a1089733af233c7448e7d7fb7963682c6d8 -BLECLI >> Write following data to characteristic with UUID '0000ff51-0000-1000-8000-00805f9b34fb' : - >> 10015a270802b2012212204051088dc294fe4621fac934a8ea22e948fcc3e8ac458aac088ce705c65dbfb9 -BLECLI >> Enter data read from characteristic (in hex) : - << 10015a270803ba01221a20c8d38059d5206a3d92642973ac6ba8ac2f6ecf2b7a3632964eb35a0f20133adb -==== Session Established ==== - -==== Sending Wifi credential to esp32 ==== -BLECLI >> Write following data to characteristic with UUID '0000ff52-0000-1000-8000-00805f9b34fb' : - >> 98471ac4019a46765c28d87df8c8ae71c1ae6cfe0bc9c615bc6d2c -BLECLI >> Enter data read from characteristic (in hex) : - << 3271f39a -==== Wifi Credentials sent successfully ==== - -==== Applying config to esp32 ==== -BLECLI >> Write following data to characteristic with UUID '0000ff52-0000-1000-8000-00805f9b34fb' : - >> 5355 -BLECLI >> Enter data read from characteristic (in hex) : - << 1664db24 -==== Apply config sent successfully ==== - -==== Wifi connection state ==== -BLECLI >> Write following data to characteristic with UUID '0000ff52-0000-1000-8000-00805f9b34fb' : - >> 290d -BLECLI >> Enter data read from characteristic (in hex) : - << 505f72a9f8521025c1964d7789c4d7edc56aedebd144e1b667bc7c0975757b80cc091aa9f3e95b06eaefbc30290fa1 -++++ WiFi state: connected ++++ -==== Provisioning was successful ==== -``` - -The write data is to be copied from the console output ```>>``` to the platform specific application and the data read from the application is to be pasted at the user input prompt ```<<``` of the console, in the format (hex) indicated in above sample log. +Or, enable `Reset Provisioning` option under `Example Configuration` under menuconfig. But this will erase the saved Wi-Fi credentials every time the device boots, so this is not the preferred solution. diff --git a/src/components/custom_provisioning/CMakeLists.txt b/src/components/custom_provisioning/CMakeLists.txt new file mode 100644 index 0000000..f758ee1 --- /dev/null +++ b/src/components/custom_provisioning/CMakeLists.txt @@ -0,0 +1,5 @@ +idf_component_register(SRCS "src/custom_config.c" + "proto-c/custom_config.pb-c.c" + INCLUDE_DIRS include + PRIV_INCLUDE_DIRS proto-c + PRIV_REQUIRES protobuf-c) diff --git a/src/components/custom_provisioning/component.mk b/src/components/custom_provisioning/component.mk new file mode 100644 index 0000000..69af7ef --- /dev/null +++ b/src/components/custom_provisioning/component.mk @@ -0,0 +1,3 @@ +COMPONENT_SRCDIRS := src proto-c +COMPONENT_ADD_INCLUDEDIRS := include +COMPONENT_PRIV_INCLUDEDIRS := proto-c diff --git a/src/components/custom_provisioning/include/custom_provisioning/custom_config.h b/src/components/custom_provisioning/include/custom_provisioning/custom_config.h new file mode 100644 index 0000000..a9b6214 --- /dev/null +++ b/src/components/custom_provisioning/include/custom_provisioning/custom_config.h @@ -0,0 +1,44 @@ +// Copyright 2018 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef _CUSTOM_PROV_CONFIG_H_ +#define _CUSTOM_PROV_CONFIG_H_ + +/** + * @brief Custom config data received by device + */ +typedef struct { + char info[128]; + int version; +} custom_config_t; + +/** + * @brief Internal handler for receiving and responding to protocomm + * requests from master + * + * This is to be passed as priv_data for protocomm request handler + * (refer to `custom_prov_config_data_handler()`) when calling `protocomm_add_endpoint()`. + */ +typedef esp_err_t (*custom_prov_config_handler_t) (const custom_config_t *config); + +/** + * @brief Handler for receiving and responding to requests from master + * + * This is to be registered as the `wifi_config` endpoint handler + * (protocomm `protocomm_req_handler_t`) using `protocomm_add_endpoint()` + */ +esp_err_t custom_prov_config_data_handler(uint32_t session_id, const uint8_t *inbuf, ssize_t inlen, + uint8_t **outbuf, ssize_t *outlen, void *priv_data); + +#endif diff --git a/src/components/custom_provisioning/proto-c/custom_config.pb-c.c b/src/components/custom_provisioning/proto-c/custom_config.pb-c.c new file mode 100644 index 0000000..6264057 --- /dev/null +++ b/src/components/custom_provisioning/proto-c/custom_config.pb-c.c @@ -0,0 +1,229 @@ +/* Generated by the protocol buffer compiler. DO NOT EDIT! */ +/* Generated from: custom_config.proto */ + +/* Do not generate deprecated warnings for self */ +#ifndef PROTOBUF_C__NO_DEPRECATED +#define PROTOBUF_C__NO_DEPRECATED +#endif + +#include "custom_config.pb-c.h" +void custom_config_request__init + (CustomConfigRequest *message) +{ + static const CustomConfigRequest init_value = CUSTOM_CONFIG_REQUEST__INIT; + *message = init_value; +} +size_t custom_config_request__get_packed_size + (const CustomConfigRequest *message) +{ + assert(message->base.descriptor == &custom_config_request__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t custom_config_request__pack + (const CustomConfigRequest *message, + uint8_t *out) +{ + assert(message->base.descriptor == &custom_config_request__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t custom_config_request__pack_to_buffer + (const CustomConfigRequest *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &custom_config_request__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +CustomConfigRequest * + custom_config_request__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (CustomConfigRequest *) + protobuf_c_message_unpack (&custom_config_request__descriptor, + allocator, len, data); +} +void custom_config_request__free_unpacked + (CustomConfigRequest *message, + ProtobufCAllocator *allocator) +{ + if(!message) + return; + assert(message->base.descriptor == &custom_config_request__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +void custom_config_response__init + (CustomConfigResponse *message) +{ + static const CustomConfigResponse init_value = CUSTOM_CONFIG_RESPONSE__INIT; + *message = init_value; +} +size_t custom_config_response__get_packed_size + (const CustomConfigResponse *message) +{ + assert(message->base.descriptor == &custom_config_response__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t custom_config_response__pack + (const CustomConfigResponse *message, + uint8_t *out) +{ + assert(message->base.descriptor == &custom_config_response__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t custom_config_response__pack_to_buffer + (const CustomConfigResponse *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &custom_config_response__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +CustomConfigResponse * + custom_config_response__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (CustomConfigResponse *) + protobuf_c_message_unpack (&custom_config_response__descriptor, + allocator, len, data); +} +void custom_config_response__free_unpacked + (CustomConfigResponse *message, + ProtobufCAllocator *allocator) +{ + if(!message) + return; + assert(message->base.descriptor == &custom_config_response__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +static const ProtobufCFieldDescriptor custom_config_request__field_descriptors[2] = +{ + { + "info", + 1, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_STRING, + 0, /* quantifier_offset */ + offsetof(CustomConfigRequest, info), + NULL, + &protobuf_c_empty_string, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "version", + 2, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT32, + 0, /* quantifier_offset */ + offsetof(CustomConfigRequest, version), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned custom_config_request__field_indices_by_name[] = { + 0, /* field[0] = info */ + 1, /* field[1] = version */ +}; +static const ProtobufCIntRange custom_config_request__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 2 } +}; +const ProtobufCMessageDescriptor custom_config_request__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "CustomConfigRequest", + "CustomConfigRequest", + "CustomConfigRequest", + "", + sizeof(CustomConfigRequest), + 2, + custom_config_request__field_descriptors, + custom_config_request__field_indices_by_name, + 1, custom_config_request__number_ranges, + (ProtobufCMessageInit) custom_config_request__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor custom_config_response__field_descriptors[2] = +{ + { + "status", + 1, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_ENUM, + 0, /* quantifier_offset */ + offsetof(CustomConfigResponse, status), + &custom_config_status__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "dummy", + 2, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT32, + 0, /* quantifier_offset */ + offsetof(CustomConfigResponse, dummy), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned custom_config_response__field_indices_by_name[] = { + 1, /* field[1] = dummy */ + 0, /* field[0] = status */ +}; +static const ProtobufCIntRange custom_config_response__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 2 } +}; +const ProtobufCMessageDescriptor custom_config_response__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "CustomConfigResponse", + "CustomConfigResponse", + "CustomConfigResponse", + "", + sizeof(CustomConfigResponse), + 2, + custom_config_response__field_descriptors, + custom_config_response__field_indices_by_name, + 1, custom_config_response__number_ranges, + (ProtobufCMessageInit) custom_config_response__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCEnumValue custom_config_status__enum_values_by_number[2] = +{ + { "ConfigSuccess", "CUSTOM_CONFIG_STATUS__ConfigSuccess", 0 }, + { "ConfigFail", "CUSTOM_CONFIG_STATUS__ConfigFail", 1 }, +}; +static const ProtobufCIntRange custom_config_status__value_ranges[] = { +{0, 0},{0, 2} +}; +static const ProtobufCEnumValueIndex custom_config_status__enum_values_by_name[2] = +{ + { "ConfigFail", 1 }, + { "ConfigSuccess", 0 }, +}; +const ProtobufCEnumDescriptor custom_config_status__descriptor = +{ + PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC, + "CustomConfigStatus", + "CustomConfigStatus", + "CustomConfigStatus", + "", + 2, + custom_config_status__enum_values_by_number, + 2, + custom_config_status__enum_values_by_name, + 1, + custom_config_status__value_ranges, + NULL,NULL,NULL,NULL /* reserved[1234] */ +}; diff --git a/src/components/custom_provisioning/proto-c/custom_config.pb-c.h b/src/components/custom_provisioning/proto-c/custom_config.pb-c.h new file mode 100644 index 0000000..fe1e0e4 --- /dev/null +++ b/src/components/custom_provisioning/proto-c/custom_config.pb-c.h @@ -0,0 +1,113 @@ +/* Generated by the protocol buffer compiler. DO NOT EDIT! */ +/* Generated from: custom_config.proto */ + +#ifndef PROTOBUF_C_custom_5fconfig_2eproto__INCLUDED +#define PROTOBUF_C_custom_5fconfig_2eproto__INCLUDED + +#include + +PROTOBUF_C__BEGIN_DECLS + +#if PROTOBUF_C_VERSION_NUMBER < 1003000 +# error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. +#elif 1003000 < PROTOBUF_C_MIN_COMPILER_VERSION +# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. +#endif + + +typedef struct _CustomConfigRequest CustomConfigRequest; +typedef struct _CustomConfigResponse CustomConfigResponse; + + +/* --- enums --- */ + +typedef enum _CustomConfigStatus { + CUSTOM_CONFIG_STATUS__ConfigSuccess = 0, + CUSTOM_CONFIG_STATUS__ConfigFail = 1 + PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(CUSTOM_CONFIG_STATUS) +} CustomConfigStatus; + +/* --- messages --- */ + +struct _CustomConfigRequest +{ + ProtobufCMessage base; + char *info; + int32_t version; +}; +#define CUSTOM_CONFIG_REQUEST__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&custom_config_request__descriptor) \ + , (char *)protobuf_c_empty_string, 0 } + + +struct _CustomConfigResponse +{ + ProtobufCMessage base; + CustomConfigStatus status; + int32_t dummy; +}; +#define CUSTOM_CONFIG_RESPONSE__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&custom_config_response__descriptor) \ + , CUSTOM_CONFIG_STATUS__ConfigSuccess, 0 } + + +/* CustomConfigRequest methods */ +void custom_config_request__init + (CustomConfigRequest *message); +size_t custom_config_request__get_packed_size + (const CustomConfigRequest *message); +size_t custom_config_request__pack + (const CustomConfigRequest *message, + uint8_t *out); +size_t custom_config_request__pack_to_buffer + (const CustomConfigRequest *message, + ProtobufCBuffer *buffer); +CustomConfigRequest * + custom_config_request__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void custom_config_request__free_unpacked + (CustomConfigRequest *message, + ProtobufCAllocator *allocator); +/* CustomConfigResponse methods */ +void custom_config_response__init + (CustomConfigResponse *message); +size_t custom_config_response__get_packed_size + (const CustomConfigResponse *message); +size_t custom_config_response__pack + (const CustomConfigResponse *message, + uint8_t *out); +size_t custom_config_response__pack_to_buffer + (const CustomConfigResponse *message, + ProtobufCBuffer *buffer); +CustomConfigResponse * + custom_config_response__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void custom_config_response__free_unpacked + (CustomConfigResponse *message, + ProtobufCAllocator *allocator); +/* --- per-message closures --- */ + +typedef void (*CustomConfigRequest_Closure) + (const CustomConfigRequest *message, + void *closure_data); +typedef void (*CustomConfigResponse_Closure) + (const CustomConfigResponse *message, + void *closure_data); + +/* --- services --- */ + + +/* --- descriptors --- */ + +extern const ProtobufCEnumDescriptor custom_config_status__descriptor; +extern const ProtobufCMessageDescriptor custom_config_request__descriptor; +extern const ProtobufCMessageDescriptor custom_config_response__descriptor; + +PROTOBUF_C__END_DECLS + + +#endif /* PROTOBUF_C_custom_5fconfig_2eproto__INCLUDED */ diff --git a/src/components/custom_provisioning/proto/CMakeLists.txt b/src/components/custom_provisioning/proto/CMakeLists.txt new file mode 100644 index 0000000..153cfdc --- /dev/null +++ b/src/components/custom_provisioning/proto/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 3.5) + +set(PROTO_COMPILER "protoc") +set(PROTO_C_COMPILER "protoc-c") +set(C_OUT_PATH "${CMAKE_CURRENT_LIST_DIR}/../proto-c") +set(PY_OUT_PATH "${CMAKE_CURRENT_LIST_DIR}/../python") + +set(PROTO_SRCS "custom_config.proto") + +add_custom_target(c_proto + COMMAND ${PROTO_C_COMPILER} --c_out=${C_OUT_PATH} -I . ${PROTO_SRCS} + VERBATIM + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + ) + +add_custom_target(python_proto + COMMAND ${PROTO_COMPILER} --python_out=${PY_OUT_PATH} -I . ${PROTO_SRCS} + VERBATIM + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + ) + +add_custom_target(proto ALL + DEPENDS c_proto python_proto + VERBATIM + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + ) diff --git a/src/components/custom_provisioning/proto/README.md b/src/components/custom_provisioning/proto/README.md new file mode 100644 index 0000000..933e82c --- /dev/null +++ b/src/components/custom_provisioning/proto/README.md @@ -0,0 +1,27 @@ +# Protobuf files for defining custom config-data packet structures + +This is an example proto file defining custom configuration related data packet structures, namely - +1. CustomConfigRequest - for sending configuration data consisting of various fields (Info and Version) +2. CustomConfigResponse - for receiving configuration status (fail/success) + +Note : These proto files are not automatically compiled during the build process. + +# Compilation + +Compilation requires protoc (Protobuf Compiler) and protoc-c (Protobuf C Compiler) installed. Since the generated files are to remain the same, as long as the proto files are not modified, therefore the generated files are already available under `examples/provisioning/custom_config/components/custom_provisioning/proto-c` and `examples/provisioning/custom_config/components/custom_provisioning/python` directories, and thus running cmake / make (and installing the Protobuf compilers) is optional. + +If using `cmake` follow the below steps. If using `make`, jump to Step 2 directly. + +## Step 1 (Only for cmake) + +When using cmake, first create a build directory and call cmake from inside: + +``` +mkdir build +cd build +cmake .. +``` + +## Step 2 + +Simply run `make` to generate the respective C and Python files. The newly created files will overwrite those under `examples/provisioning/custom_config/components/custom_provisioning/proto-c` and `examples/provisioning/custom_config/components/custom_provisioning/python` diff --git a/src/components/custom_provisioning/proto/custom_config.proto b/src/components/custom_provisioning/proto/custom_config.proto new file mode 100644 index 0000000..c6ae82e --- /dev/null +++ b/src/components/custom_provisioning/proto/custom_config.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; + +enum CustomConfigStatus { + ConfigSuccess = 0; + ConfigFail = 1; +} + +message CustomConfigRequest { + string info = 1; + int32 version = 2; +} + +message CustomConfigResponse { + CustomConfigStatus status = 1; + int32 dummy = 2; +} diff --git a/src/components/custom_provisioning/proto/makefile b/src/components/custom_provisioning/proto/makefile new file mode 100644 index 0000000..d0da1dd --- /dev/null +++ b/src/components/custom_provisioning/proto/makefile @@ -0,0 +1,7 @@ +all: c_proto python_proto + +c_proto: *.proto + @protoc-c --c_out=../proto-c/ *.proto + +python_proto: *.proto + @protoc --python_out=../python/ *.proto diff --git a/src/components/custom_provisioning/python/custom_config_pb2.py b/src/components/custom_provisioning/python/custom_config_pb2.py new file mode 100644 index 0000000..be60293 --- /dev/null +++ b/src/components/custom_provisioning/python/custom_config_pb2.py @@ -0,0 +1,152 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: custom_config.proto + +import sys + +_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from google.protobuf import reflection as _reflection +from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import enum_type_wrapper + +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + + + +DESCRIPTOR = _descriptor.FileDescriptor( + name='custom_config.proto', + package='', + syntax='proto3', + serialized_options=None, + serialized_pb=_b('\n\x13\x63ustom_config.proto\"4\n\x13\x43ustomConfigRequest\x12\x0c\n\x04info\x18\x01 \x01(\t\x12\x0f\n\x07version\x18\x02 \x01(\x05\"J\n\x14\x43ustomConfigResponse\x12#\n\x06status\x18\x01 \x01(\x0e\x32\x13.CustomConfigStatus\x12\r\n\x05\x64ummy\x18\x02 \x01(\x05*7\n\x12\x43ustomConfigStatus\x12\x11\n\rConfigSuccess\x10\x00\x12\x0e\n\nConfigFail\x10\x01\x62\x06proto3') +) + +_CUSTOMCONFIGSTATUS = _descriptor.EnumDescriptor( + name='CustomConfigStatus', + full_name='CustomConfigStatus', + filename=None, + file=DESCRIPTOR, + values=[ + _descriptor.EnumValueDescriptor( + name='ConfigSuccess', index=0, number=0, + serialized_options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='ConfigFail', index=1, number=1, + serialized_options=None, + type=None), + ], + containing_type=None, + serialized_options=None, + serialized_start=153, + serialized_end=208, +) +_sym_db.RegisterEnumDescriptor(_CUSTOMCONFIGSTATUS) + +CustomConfigStatus = enum_type_wrapper.EnumTypeWrapper(_CUSTOMCONFIGSTATUS) +ConfigSuccess = 0 +ConfigFail = 1 + + + +_CUSTOMCONFIGREQUEST = _descriptor.Descriptor( + name='CustomConfigRequest', + full_name='CustomConfigRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='info', full_name='CustomConfigRequest.info', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b('').decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='version', full_name='CustomConfigRequest.version', index=1, + number=2, type=5, cpp_type=1, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=23, + serialized_end=75, +) + + +_CUSTOMCONFIGRESPONSE = _descriptor.Descriptor( + name='CustomConfigResponse', + full_name='CustomConfigResponse', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='status', full_name='CustomConfigResponse.status', index=0, + number=1, type=14, cpp_type=8, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='dummy', full_name='CustomConfigResponse.dummy', index=1, + number=2, type=5, cpp_type=1, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=77, + serialized_end=151, +) + +_CUSTOMCONFIGRESPONSE.fields_by_name['status'].enum_type = _CUSTOMCONFIGSTATUS +DESCRIPTOR.message_types_by_name['CustomConfigRequest'] = _CUSTOMCONFIGREQUEST +DESCRIPTOR.message_types_by_name['CustomConfigResponse'] = _CUSTOMCONFIGRESPONSE +DESCRIPTOR.enum_types_by_name['CustomConfigStatus'] = _CUSTOMCONFIGSTATUS +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + +CustomConfigRequest = _reflection.GeneratedProtocolMessageType('CustomConfigRequest', (_message.Message,), dict( + DESCRIPTOR = _CUSTOMCONFIGREQUEST, + __module__ = 'custom_config_pb2' + # @@protoc_insertion_point(class_scope:CustomConfigRequest) + )) +_sym_db.RegisterMessage(CustomConfigRequest) + +CustomConfigResponse = _reflection.GeneratedProtocolMessageType('CustomConfigResponse', (_message.Message,), dict( + DESCRIPTOR = _CUSTOMCONFIGRESPONSE, + __module__ = 'custom_config_pb2' + # @@protoc_insertion_point(class_scope:CustomConfigResponse) + )) +_sym_db.RegisterMessage(CustomConfigResponse) + + +# @@protoc_insertion_point(module_scope) diff --git a/src/components/custom_provisioning/src/custom_config.c b/src/components/custom_provisioning/src/custom_config.c new file mode 100644 index 0000000..bf369aa --- /dev/null +++ b/src/components/custom_provisioning/src/custom_config.c @@ -0,0 +1,68 @@ +// Copyright 2018 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include +#include +#include + +#include + +#include "custom_config.pb-c.h" + +static const char *TAG = "custom_config"; + +int custom_prov_config_data_handler(uint32_t session_id, const uint8_t *inbuf, ssize_t inlen, uint8_t **outbuf, ssize_t *outlen, void *priv_data) +{ + CustomConfigRequest *req; + CustomConfigResponse resp; + custom_prov_config_handler_t app_handler_custom_config = (custom_prov_config_handler_t) priv_data; + + req = custom_config_request__unpack(NULL, inlen, inbuf); + if (!req) { + ESP_LOGE(TAG, "Unable to unpack config data"); + return ESP_ERR_INVALID_ARG; + } + + custom_config_response__init(&resp); + resp.status = CUSTOM_CONFIG_STATUS__ConfigFail; + + if (app_handler_custom_config) { + custom_config_t config; + strlcpy(config.info, req->info, sizeof(config.info)); + config.version = req->version; + + esp_err_t err = app_handler_custom_config(&config); + resp.status = (err == ESP_OK) ? CUSTOM_CONFIG_STATUS__ConfigSuccess : + CUSTOM_CONFIG_STATUS__ConfigFail; + } + custom_config_request__free_unpacked(req, NULL); + + resp.dummy = 47; // Set a non zero value of dummy + + *outlen = custom_config_response__get_packed_size(&resp); + if (*outlen <= 0) { + ESP_LOGE(TAG, "Invalid encoding for response"); + return ESP_FAIL; + } + + *outbuf = (uint8_t *) malloc(*outlen); + if (*outbuf == NULL) { + ESP_LOGE(TAG, "System out of memory"); + return ESP_ERR_NO_MEM; + } + + custom_config_response__pack(&resp, *outbuf); + return ESP_OK; +} diff --git a/src/main/CMakeLists.txt b/src/main/CMakeLists.txt index 61fac40..dae207e 100644 --- a/src/main/CMakeLists.txt +++ b/src/main/CMakeLists.txt @@ -1,2 +1,4 @@ idf_component_register(SRCS "app_main.c" + "app_prov.c" + "app_prov_handlers.c" INCLUDE_DIRS ".") diff --git a/src/main/Kconfig.projbuild b/src/main/Kconfig.projbuild index 3c27774..0d353fd 100644 --- a/src/main/Kconfig.projbuild +++ b/src/main/Kconfig.projbuild @@ -1,23 +1,58 @@ menu "Example Configuration" - choice EXAMPLE_PROV_TRANSPORT - bool "Provisioning Transport" - default EXAMPLE_PROV_TRANSPORT_SOFTAP if IDF_TARGET_ESP32S2 - default EXAMPLE_PROV_TRANSPORT_BLE + config EXAMPLE_SSID + string "Wi-Fi SSID" + default "myssid" help - Wi-Fi provisioning component offers both, SoftAP and BLE transports. Choose any one. + SSID (network name) for the example to connect to. - config EXAMPLE_PROV_TRANSPORT_BLE - bool "BLE" - select BT_ENABLED - depends on !IDF_TARGET_ESP32S2 - config EXAMPLE_PROV_TRANSPORT_SOFTAP - bool "Soft AP" - endchoice + config EXAMPLE_PASS + string "Wi-Fi Password" + default "mypassword" + help + Wi-Fi password (WPA or WPA2) for the example to use. - config EXAMPLE_PROV_TRANSPORT - int - default 1 if EXAMPLE_PROV_TRANSPORT_BLE - default 2 if EXAMPLE_PROV_TRANSPORT_SOFTAP + config EXAMPLE_USE_SEC_1 + bool + default n + prompt "Use Security Version 1" + help + Security version 1 used Curve25519 key exchange for establishing + secure session between device and client during provisioning + + config EXAMPLE_USE_POP + bool + depends on EXAMPLE_USE_SEC_1 + default n + prompt "Use proof-of-possession" + help + Proof-of-possession can be optionally used to prove that the device is indeed + in possession of the user who is provisioning the device. This proof-of-possession + is internally used to generate the shared secret through key exchange. + + config EXAMPLE_POP + string "Proof-of-possession" + default "abcd1234" + depends on EXAMPLE_USE_POP + + config EXAMPLE_PROTOCOMM_HTTPD_PORT + int "Protocomm HTTP Port" + default 80 + help + Port on which to run Protocomm HTTP based provisioning service + + config EXAMPLE_RESET_PROVISIONED + bool + default n + prompt "Reset provisioned status of the device" + help + This erases the NVS to reset provisioned status of the device on every reboot. + Provisioned status is determined by the Wi-Fi STA configuration, saved on the NVS. + + config EXAMPLE_AP_RECONN_ATTEMPTS + int "Maximum AP connection attempts" + default 5 + help + Set the maximum connection attempts to perform when connecting to a Wi-Fi AP. endmenu diff --git a/src/main/app_main.c b/src/main/app_main.c index e09e82e..f0f053d 100644 --- a/src/main/app_main.c +++ b/src/main/app_main.c @@ -1,4 +1,4 @@ -/* Wi-Fi Provisioning Manager Example +/* SoftAP based Custom Provisioning Example This example code is in the Public Domain (or CC0 licensed, at your option.) @@ -7,278 +7,112 @@ CONDITIONS OF ANY KIND, either express or implied. */ -#include #include - #include #include -#include - -#include +#include #include #include +#include #include -#include +#include +#include -#ifdef CONFIG_EXAMPLE_PROV_TRANSPORT_BLE -#include -#endif /* CONFIG_EXAMPLE_PROV_TRANSPORT_BLE */ +#include "app_prov.h" -#ifdef CONFIG_EXAMPLE_PROV_TRANSPORT_SOFTAP -#include -#endif /* CONFIG_EXAMPLE_PROV_TRANSPORT_SOFTAP */ +#define EXAMPLE_AP_RECONN_ATTEMPTS CONFIG_EXAMPLE_AP_RECONN_ATTEMPTS static const char *TAG = "app"; -/* Signal Wi-Fi events on this event-group */ -const int WIFI_CONNECTED_EVENT = BIT0; -static EventGroupHandle_t wifi_event_group; - -/* Event handler for catching system events */ static void event_handler(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data) { - if (event_base == WIFI_PROV_EVENT) { - switch (event_id) { - case WIFI_PROV_START: - ESP_LOGI(TAG, "Provisioning started"); - break; - case WIFI_PROV_CRED_RECV: { - wifi_sta_config_t *wifi_sta_cfg = (wifi_sta_config_t *)event_data; - ESP_LOGI(TAG, "Received Wi-Fi credentials" - "\n\tSSID : %s\n\tPassword : %s", - (const char *) wifi_sta_cfg->ssid, - (const char *) wifi_sta_cfg->password); - break; - } - case WIFI_PROV_CRED_FAIL: { - wifi_prov_sta_fail_reason_t *reason = (wifi_prov_sta_fail_reason_t *)event_data; - ESP_LOGE(TAG, "Provisioning failed!\n\tReason : %s" - "\n\tPlease reset to factory and retry provisioning", - (*reason == WIFI_PROV_STA_AUTH_ERROR) ? - "Wi-Fi station authentication failed" : "Wi-Fi access-point not found"); - break; - } - case WIFI_PROV_CRED_SUCCESS: - ESP_LOGI(TAG, "Provisioning successful"); - break; - case WIFI_PROV_END: - /* De-initialize manager once provisioning is finished */ - wifi_prov_mgr_deinit(); - break; - default: - break; - } - } else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) { + static int s_retry_num = 0; + + if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) { esp_wifi_connect(); + } else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) { + if (s_retry_num < EXAMPLE_AP_RECONN_ATTEMPTS) { + esp_wifi_connect(); + s_retry_num++; + ESP_LOGI(TAG, "retry to connect to the AP"); + } + ESP_LOGI(TAG,"connect to the AP fail"); } else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) { ip_event_got_ip_t* event = (ip_event_got_ip_t*) event_data; - ESP_LOGI(TAG, "Connected with IP Address:" IPSTR, IP2STR(&event->ip_info.ip)); - /* Signal main application to continue execution */ - xEventGroupSetBits(wifi_event_group, WIFI_CONNECTED_EVENT); - } else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) { - ESP_LOGI(TAG, "Disconnected. Connecting to the AP again..."); - esp_wifi_connect(); + ESP_LOGI(TAG, "got ip: " IPSTR, IP2STR(&event->ip_info.ip)); + s_retry_num = 0; } } static void wifi_init_sta(void) { - /* Start Wi-Fi in station mode */ + /* Set our event handling */ + ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, event_handler, NULL)); + ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, event_handler, NULL)); + + /* Start Wi-Fi in station mode with credentials set during provisioning */ ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA)); ESP_ERROR_CHECK(esp_wifi_start()); } -static void get_device_service_name(char *service_name, size_t max) +static void start_softap_provisioning(void) { - uint8_t eth_mac[6]; - const char *ssid_prefix = "PROV_"; - esp_wifi_get_mac(WIFI_IF_STA, eth_mac); - snprintf(service_name, max, "%s%02X%02X%02X", - ssid_prefix, eth_mac[3], eth_mac[4], eth_mac[5]); -} + /* Security version */ + int security = 0; + /* Proof of possession */ + const protocomm_security_pop_t *pop = NULL; -/* Handler for the optional provisioning endpoint registered by the application. - * The data format can be chosen by applications. Here, we are using plain ascii text. - * Applications can choose to use other formats like protobuf, JSON, XML, etc. - */ -esp_err_t custom_prov_data_handler(uint32_t session_id, const uint8_t *inbuf, ssize_t inlen, - uint8_t **outbuf, ssize_t *outlen, void *priv_data) -{ - if (inbuf) { - ESP_LOGI(TAG, "Received data: %.*s", inlen, (char *)inbuf); - } - char response[] = "SUCCESS"; - *outbuf = (uint8_t *)strdup(response); - if (*outbuf == NULL) { - ESP_LOGE(TAG, "System out of memory"); - return ESP_ERR_NO_MEM; - } - *outlen = strlen(response) + 1; /* +1 for NULL terminating byte */ +#ifdef CONFIG_EXAMPLE_USE_SEC_1 + security = 1; +#endif - return ESP_OK; + /* Having proof of possession is optional */ +#ifdef CONFIG_EXAMPLE_USE_POP + const static protocomm_security_pop_t app_pop = { + .data = (uint8_t *) CONFIG_EXAMPLE_POP, + .len = (sizeof(CONFIG_EXAMPLE_POP)-1) + }; + pop = &app_pop; +#endif + + ESP_ERROR_CHECK(app_prov_start_softap_provisioning( + CONFIG_EXAMPLE_SSID, CONFIG_EXAMPLE_PASS, security, pop)); } void app_main(void) { - /* Initialize NVS partition */ - esp_err_t ret = nvs_flash_init(); - if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) { - /* NVS partition was truncated - * and needs to be erased */ - ESP_ERROR_CHECK(nvs_flash_erase()); - - /* Retry nvs_flash_init */ - ESP_ERROR_CHECK(nvs_flash_init()); - } - - /* Initialize TCP/IP */ + /* Initialize networking stack */ ESP_ERROR_CHECK(esp_netif_init()); - /* Initialize the event loop */ + /* Create default event loop needed by the + * main app and the provisioning service */ ESP_ERROR_CHECK(esp_event_loop_create_default()); - wifi_event_group = xEventGroupCreate(); - /* Register our event handler for Wi-Fi, IP and Provisioning related events */ - ESP_ERROR_CHECK(esp_event_handler_register(WIFI_PROV_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL)); - ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL)); - ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &event_handler, NULL)); + /* Initialize NVS needed by Wi-Fi */ + ESP_ERROR_CHECK(nvs_flash_init()); /* Initialize Wi-Fi including netif with default config */ esp_netif_create_default_wifi_sta(); -#ifdef CONFIG_EXAMPLE_PROV_TRANSPORT_SOFTAP esp_netif_create_default_wifi_ap(); -#endif /* CONFIG_EXAMPLE_PROV_TRANSPORT_SOFTAP */ wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); ESP_ERROR_CHECK(esp_wifi_init(&cfg)); - /* Configuration for the provisioning manager */ - wifi_prov_mgr_config_t config = { - /* What is the Provisioning Scheme that we want ? - * wifi_prov_scheme_softap or wifi_prov_scheme_ble */ -#ifdef CONFIG_EXAMPLE_PROV_TRANSPORT_BLE - .scheme = wifi_prov_scheme_ble, -#endif /* CONFIG_EXAMPLE_PROV_TRANSPORT_BLE */ -#ifdef CONFIG_EXAMPLE_PROV_TRANSPORT_SOFTAP - .scheme = wifi_prov_scheme_softap, -#endif /* CONFIG_EXAMPLE_PROV_TRANSPORT_SOFTAP */ + /* Check if device is provisioned */ + bool provisioned; + if (app_prov_is_provisioned(&provisioned) != ESP_OK) { + ESP_LOGE(TAG, "Error getting device provisioning state"); + return; + } - /* Any default scheme specific event handler that you would - * like to choose. Since our example application requires - * neither BT nor BLE, we can choose to release the associated - * memory once provisioning is complete, or not needed - * (in case when device is already provisioned). Choosing - * appropriate scheme specific event handler allows the manager - * to take care of this automatically. This can be set to - * WIFI_PROV_EVENT_HANDLER_NONE when using wifi_prov_scheme_softap*/ -#ifdef CONFIG_EXAMPLE_PROV_TRANSPORT_BLE - .scheme_event_handler = WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BTDM -#endif /* CONFIG_EXAMPLE_PROV_TRANSPORT_BLE */ -#ifdef CONFIG_EXAMPLE_PROV_TRANSPORT_SOFTAP - .scheme_event_handler = WIFI_PROV_EVENT_HANDLER_NONE -#endif /* CONFIG_EXAMPLE_PROV_TRANSPORT_SOFTAP */ - }; - - /* Initialize provisioning manager with the - * configuration parameters set above */ - ESP_ERROR_CHECK(wifi_prov_mgr_init(config)); - - bool provisioned = false; - /* Let's find out if the device is provisioned */ - ESP_ERROR_CHECK(wifi_prov_mgr_is_provisioned(&provisioned)); -provisioned = false; - - /* If device is not yet provisioned start provisioning service */ - if (!provisioned) { - ESP_LOGI(TAG, "Starting provisioning"); - - /* What is the Device Service Name that we want - * This translates to : - * - Wi-Fi SSID when scheme is wifi_prov_scheme_softap - * - device name when scheme is wifi_prov_scheme_ble - */ - char service_name[12]; - get_device_service_name(service_name, sizeof(service_name)); - - /* What is the security level that we want (0 or 1): - * - WIFI_PROV_SECURITY_0 is simply plain text communication. - * - WIFI_PROV_SECURITY_1 is secure communication which consists of secure handshake - * using X25519 key exchange and proof of possession (pop) and AES-CTR - * for encryption/decryption of messages. - */ - wifi_prov_security_t security = WIFI_PROV_SECURITY_1; - - /* Do we want a proof-of-possession (ignored if Security 0 is selected): - * - this should be a string with length > 0 - * - NULL if not used - */ - const char *pop = "abcd1234"; - - /* What is the service key (could be NULL) - * This translates to : - * - Wi-Fi password when scheme is wifi_prov_scheme_softap - * - simply ignored when scheme is wifi_prov_scheme_ble - */ - const char *service_key = NULL; - -#ifdef CONFIG_EXAMPLE_PROV_TRANSPORT_BLE - /* This step is only useful when scheme is wifi_prov_scheme_ble. This will - * set a custom 128 bit UUID which will be included in the BLE advertisement - * and will correspond to the primary GATT service that provides provisioning - * endpoints as GATT characteristics. Each GATT characteristic will be - * formed using the primary service UUID as base, with different auto assigned - * 12th and 13th bytes (assume counting starts from 0th byte). The client side - * applications must identify the endpoints by reading the User Characteristic - * Description descriptor (0x2901) for each characteristic, which contains the - * endpoint name of the characteristic */ - uint8_t custom_service_uuid[] = { - /* LSB <--------------------------------------- - * ---------------------------------------> MSB */ - 0xb4, 0xdf, 0x5a, 0x1c, 0x3f, 0x6b, 0xf4, 0xbf, - 0xea, 0x4a, 0x82, 0x03, 0x04, 0x90, 0x1a, 0x02, - }; - wifi_prov_scheme_ble_set_service_uuid(custom_service_uuid); -#endif /* CONFIG_EXAMPLE_PROV_TRANSPORT_BLE */ - - /* An optional endpoint that applications can create if they expect to - * get some additional custom data during provisioning workflow. - * The endpoint name can be anything of your choice. - * This call must be made before starting the provisioning. - */ - wifi_prov_mgr_endpoint_create("custom-data"); - /* Start provisioning service */ - ESP_ERROR_CHECK(wifi_prov_mgr_start_provisioning(security, pop, service_name, service_key)); - - /* The handler for the optional endpoint created above. - * This call must be made after starting the provisioning, and only if the endpoint - * has already been created above. - */ - char privateData[32]; - wifi_prov_mgr_endpoint_register("custom-data", custom_prov_data_handler, (void*)privateData); - - /* Uncomment the following to wait for the provisioning to finish and then release - * the resources of the manager. Since in this case de-initialization is triggered - * by the default event loop handler, we don't need to call the following */ - // wifi_prov_mgr_wait(); - // wifi_prov_mgr_deinit(); + if (provisioned == false) { + /* If not provisioned, start provisioning via soft AP */ + ESP_LOGI(TAG, "Starting WiFi SoftAP provisioning"); + start_softap_provisioning(); } else { - ESP_LOGI(TAG, "Already provisioned, starting Wi-Fi STA"); - - /* We don't need the manager as device is already provisioned, - * so let's release it's resources */ - wifi_prov_mgr_deinit(); - - /* Start Wi-Fi station */ + /* Start WiFi station with credentials set during provisioning */ + ESP_LOGI(TAG, "Starting WiFi station"); wifi_init_sta(); } - - /* Wait for Wi-Fi connection */ - xEventGroupWaitBits(wifi_event_group, WIFI_CONNECTED_EVENT, false, true, portMAX_DELAY); - - /* Start main application now */ - while (1) { - ESP_LOGI(TAG, "Hello World!"); - vTaskDelay(1000 / portTICK_PERIOD_MS); - } } diff --git a/src/main/app_prov.c b/src/main/app_prov.c new file mode 100644 index 0000000..c81ab21 --- /dev/null +++ b/src/main/app_prov.c @@ -0,0 +1,398 @@ +/* SoftAP based Custom Provisioning Example + + This example code is in the Public Domain (or CC0 licensed, at your option.) + + Unless required by applicable law or agreed to in writing, this + software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + CONDITIONS OF ANY KIND, either express or implied. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "app_prov.h" + +static const char *TAG = "app_prov"; + +/* Handler for catching WiFi events */ +static void app_prov_event_handler(void* handler_arg, esp_event_base_t base, int32_t id, void* data); + +/* Handlers for provisioning endpoints */ +extern wifi_prov_config_handlers_t wifi_prov_handlers; +extern custom_prov_config_handler_t custom_prov_handler; + +/** + * @brief Data relevant to provisioning application + */ +struct app_prov_data { + protocomm_t *pc; /*!< Protocomm handler */ + int security; /*!< Type of security to use with protocomm */ + const protocomm_security_pop_t *pop; /*!< Pointer to proof of possession */ + esp_timer_handle_t timer; /*!< Handle to timer */ + + /* State of WiFi Station */ + wifi_prov_sta_state_t wifi_state; + + /* Code for WiFi station disconnection (if disconnected) */ + wifi_prov_sta_fail_reason_t wifi_disconnect_reason; +}; + +/* Pointer to provisioning application data */ +static struct app_prov_data *g_prov; + +static esp_err_t app_prov_start_service(void) +{ + /* Create new protocomm instance */ + g_prov->pc = protocomm_new(); + if (g_prov->pc == NULL) { + ESP_LOGE(TAG, "Failed to create new protocomm instance"); + return ESP_FAIL; + } + + /* Config for protocomm_httpd_start() */ + protocomm_httpd_config_t pc_config = { + .data = { + .config = PROTOCOMM_HTTPD_DEFAULT_CONFIG() + } + }; + + /* Start protocomm server on top of HTTP */ + if (protocomm_httpd_start(g_prov->pc, &pc_config) != ESP_OK) { + ESP_LOGE(TAG, "Failed to start protocomm HTTP server"); + return ESP_FAIL; + } + + /* Set protocomm version verification endpoint for protocol */ + protocomm_set_version(g_prov->pc, "proto-ver", "V0.1"); + + /* Set protocomm security type for endpoint */ + if (g_prov->security == 0) { + protocomm_set_security(g_prov->pc, "prov-session", &protocomm_security0, NULL); + } else if (g_prov->security == 1) { + protocomm_set_security(g_prov->pc, "prov-session", &protocomm_security1, g_prov->pop); + } + + /* Add endpoint for provisioning to set WiFi STA config */ + if (protocomm_add_endpoint(g_prov->pc, "prov-config", + wifi_prov_config_data_handler, + (void *) &wifi_prov_handlers) != ESP_OK) { + ESP_LOGE(TAG, "Failed to set WiFi provisioning endpoint"); + protocomm_httpd_stop(g_prov->pc); + return ESP_FAIL; + } + + /* Add endpoint for provisioning to set custom config */ + if (protocomm_add_endpoint(g_prov->pc, "custom-config", + custom_prov_config_data_handler, + (void *) custom_prov_handler) != ESP_OK) { + ESP_LOGE(TAG, "Failed to set custom provisioning endpoint"); + protocomm_httpd_stop(g_prov->pc); + return ESP_FAIL; + } + return ESP_OK; +} + +static void app_prov_stop_service(void) +{ + /* Remove provisioning endpoint for custom config */ + protocomm_remove_endpoint(g_prov->pc, "custom-config"); + /* Remove provisioning endpoint for WiFi STA config */ + protocomm_remove_endpoint(g_prov->pc, "prov-config"); + /* Unset provisioning security */ + protocomm_unset_security(g_prov->pc, "prov-session"); + /* Unset provisioning version endpoint */ + protocomm_unset_version(g_prov->pc, "proto-ver"); + /* Stop protocomm server */ + protocomm_httpd_stop(g_prov->pc); + /* Delete protocomm instance */ + protocomm_delete(g_prov->pc); + + /* Remove event handler */ + esp_event_handler_unregister(WIFI_EVENT, ESP_EVENT_ANY_ID, app_prov_event_handler); + esp_event_handler_unregister(IP_EVENT, IP_EVENT_STA_GOT_IP, app_prov_event_handler); +} + +/* Task spawned by timer callback */ +static void stop_prov_task(void * arg) +{ + ESP_LOGI(TAG, "Stopping provisioning"); + app_prov_stop_service(); + esp_wifi_set_mode(WIFI_MODE_STA); + + /* Timer not needed anymore */ + esp_timer_handle_t timer = g_prov->timer; + esp_timer_delete(timer); + g_prov->timer = NULL; + + /* Free provisioning process data */ + free(g_prov); + g_prov = NULL; + ESP_LOGI(TAG, "Provisioning stopped"); + + vTaskDelete(NULL); +} + +/* Callback to be invoked by timer */ +static void _stop_prov_cb(void * arg) +{ + xTaskCreate(&stop_prov_task, "stop_prov", 2048, NULL, tskIDLE_PRIORITY, NULL); +} + +/* Event handler for starting/stopping provisioning */ +static void app_prov_event_handler(void* handler_arg, esp_event_base_t event_base, + int32_t event_id, void* event_data) +{ + /* If pointer to provisioning application data is NULL + * then provisioning is not running */ + if (!g_prov) { + return; + } + + if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) { + ESP_LOGI(TAG, "STA Start"); + /* Once configuration is received through protocomm, + * device is started as station. Once station starts, + * wait for connection to establish with configured + * host SSID and password */ + g_prov->wifi_state = WIFI_PROV_STA_CONNECTING; + } else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) { + ESP_LOGI(TAG, "STA Got IP"); + /* Station got IP. That means configuration is successful. + * Schedule timer to stop provisioning app after 30 seconds. */ + g_prov->wifi_state = WIFI_PROV_STA_CONNECTED; + if (g_prov && g_prov->timer) { + /* Note that, after restarting the WiFi in Station + AP mode, the + * user gets disconnected from the AP for a while. But at the same + * time, the user app requests for status update from the device + * to verify that the provisioning was successful. Therefore, the + * turning off of the AP must be delayed long enough for the user + * to reconnect and get STA connection status from the device. + * Otherwise, the AP will be turned off before the user can + * reconnect and thus the user app will see connection timed out, + * signaling a failure in provisioning. */ + esp_timer_start_once(g_prov->timer, 30000*1000U); + } + } else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) { + ESP_LOGE(TAG, "STA Disconnected"); + /* Station couldn't connect to configured host SSID */ + g_prov->wifi_state = WIFI_PROV_STA_DISCONNECTED; + + wifi_event_sta_disconnected_t* disconnected = (wifi_event_sta_disconnected_t*) event_data; + ESP_LOGE(TAG, "Disconnect reason : %d", disconnected->reason); + + /* Set code corresponding to the reason for disconnection */ + switch (disconnected->reason) { + case WIFI_REASON_AUTH_EXPIRE: + case WIFI_REASON_4WAY_HANDSHAKE_TIMEOUT: + case WIFI_REASON_BEACON_TIMEOUT: + case WIFI_REASON_AUTH_FAIL: + case WIFI_REASON_ASSOC_FAIL: + case WIFI_REASON_HANDSHAKE_TIMEOUT: + ESP_LOGI(TAG, "STA Auth Error"); + g_prov->wifi_disconnect_reason = WIFI_PROV_STA_AUTH_ERROR; + break; + case WIFI_REASON_NO_AP_FOUND: + ESP_LOGI(TAG, "STA AP Not found"); + g_prov->wifi_disconnect_reason = WIFI_PROV_STA_AP_NOT_FOUND; + break; + default: + /* If none of the expected reasons, + * retry connecting to host SSID */ + g_prov->wifi_state = WIFI_PROV_STA_CONNECTING; + } + esp_wifi_connect(); + } +} + +esp_err_t app_prov_get_wifi_state(wifi_prov_sta_state_t* state) +{ + if (g_prov == NULL || state == NULL) { + return ESP_FAIL; + } + + *state = g_prov->wifi_state; + return ESP_OK; +} + +esp_err_t app_prov_get_wifi_disconnect_reason(wifi_prov_sta_fail_reason_t* reason) +{ + if (g_prov == NULL || reason == NULL) { + return ESP_FAIL; + } + + if (g_prov->wifi_state != WIFI_PROV_STA_DISCONNECTED) { + return ESP_FAIL; + } + + *reason = g_prov->wifi_disconnect_reason; + return ESP_OK; +} + +esp_err_t app_prov_is_provisioned(bool *provisioned) +{ + *provisioned = false; + +#ifdef CONFIG_EXAMPLE_RESET_PROVISIONED + nvs_flash_erase(); +#endif + + /* Get WiFi Station configuration */ + wifi_config_t wifi_cfg; + if (esp_wifi_get_config(WIFI_IF_STA, &wifi_cfg) != ESP_OK) { + return ESP_FAIL; + } + + if (strlen((const char*) wifi_cfg.sta.ssid)) { + *provisioned = true; + ESP_LOGI(TAG, "Found ssid %s", (const char*) wifi_cfg.sta.ssid); + ESP_LOGI(TAG, "Found password %s", (const char*) wifi_cfg.sta.password); + } + return ESP_OK; +} + +esp_err_t app_prov_configure_sta(wifi_config_t *wifi_cfg) +{ + /* Configure WiFi as both AP and Station */ + if (esp_wifi_set_mode(WIFI_MODE_APSTA) != ESP_OK) { + ESP_LOGE(TAG, "Failed to set WiFi mode"); + return ESP_FAIL; + } + /* Configure WiFi station with host credentials + * provided during provisioning */ + if (esp_wifi_set_config(WIFI_IF_STA, wifi_cfg) != ESP_OK) { + ESP_LOGE(TAG, "Failed to set WiFi configuration"); + return ESP_FAIL; + } + /* Restart WiFi */ + if (esp_wifi_start() != ESP_OK) { + ESP_LOGE(TAG, "Failed to restart WiFi"); + return ESP_FAIL; + } + /* Connect to AP */ + if (esp_wifi_connect() != ESP_OK) { + ESP_LOGE(TAG, "Failed to connect WiFi"); + return ESP_FAIL; + } + + if (g_prov) { + /* Reset wifi station state for provisioning app */ + g_prov->wifi_state = WIFI_PROV_STA_CONNECTING; + } + return ESP_OK; +} + +static esp_err_t start_wifi_ap(const char *ssid, const char *pass) +{ + /* Build WiFi configuration for AP mode */ + wifi_config_t wifi_config = { + .ap = { + .max_connection = 5, + }, + }; + + strlcpy((char *) wifi_config.ap.ssid, ssid, sizeof(wifi_config.ap.ssid)); + + if (strlen(pass) == 0) { + memset(wifi_config.ap.password, 0, sizeof(wifi_config.ap.password)); + wifi_config.ap.authmode = WIFI_AUTH_OPEN; + } else { + strlcpy((char *) wifi_config.ap.password, pass, sizeof(wifi_config.ap.password)); + wifi_config.ap.authmode = WIFI_AUTH_WPA_WPA2_PSK; + } + + /* Start WiFi in AP mode with configuration built above */ + esp_err_t err = esp_wifi_set_mode(WIFI_MODE_AP); + if (err != ESP_OK) { + ESP_LOGE(TAG, "Failed to set WiFi mode : %d", err); + return err; + } + err = esp_wifi_set_config(WIFI_IF_AP, &wifi_config); + if (err != ESP_OK) { + ESP_LOGE(TAG, "Failed to set WiFi config : %d", err); + return err; + } + err = esp_wifi_start(); + if (err != ESP_OK) { + ESP_LOGE(TAG, "Failed to start WiFi : %d", err); + return err; + } + + return ESP_OK; +} + +esp_err_t app_prov_start_softap_provisioning(const char *ssid, const char *pass, + int security, const protocomm_security_pop_t *pop) +{ + /* If provisioning app data present, + * means provisioning app is already running */ + if (g_prov) { + ESP_LOGI(TAG, "Invalid provisioning state"); + return ESP_FAIL; + } + + /* Allocate memory for provisioning app data */ + g_prov = (struct app_prov_data *) calloc(1, sizeof(struct app_prov_data)); + if (!g_prov) { + ESP_LOGI(TAG, "Unable to allocate prov data"); + return ESP_ERR_NO_MEM; + } + + /* Initialize app data */ + g_prov->pop = pop; + g_prov->security = security; + + /* Create timer object as a member of app data */ + esp_timer_create_args_t timer_conf = { + .callback = _stop_prov_cb, + .arg = NULL, + .dispatch_method = ESP_TIMER_TASK, + .name = "stop_softap_tm" + }; + esp_err_t err = esp_timer_create(&timer_conf, &g_prov->timer); + if (err != ESP_OK) { + ESP_LOGE(TAG, "Failed to create timer"); + return err; + } + + err = esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, app_prov_event_handler, NULL); + if (err != ESP_OK) { + ESP_LOGE(TAG, "Failed to register WiFi event handler"); + return err; + } + + err = esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, app_prov_event_handler, NULL); + if (err != ESP_OK) { + ESP_LOGE(TAG, "Failed to register IP event handler"); + return err; + } + + /* Start WiFi softAP with specified ssid and password */ + err = start_wifi_ap(ssid, pass); + if (err != ESP_OK) { + ESP_LOGE(TAG, "Failed to start WiFi AP"); + return err; + } + + /* Start provisioning service through HTTP */ + err = app_prov_start_service(); + if (err != ESP_OK) { + ESP_LOGE(TAG, "Failed to start provisioning app"); + return err; + } + + ESP_LOGI(TAG, "SoftAP Provisioning started with SSID %s, Password %s", ssid, pass); + return ESP_OK; +} diff --git a/src/main/app_prov.h b/src/main/app_prov.h new file mode 100644 index 0000000..be46b29 --- /dev/null +++ b/src/main/app_prov.h @@ -0,0 +1,88 @@ +/* SoftAP based Custom Provisioning Example + + This example code is in the Public Domain (or CC0 licensed, at your option.) + + Unless required by applicable law or agreed to in writing, this + software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + CONDITIONS OF ANY KIND, either express or implied. +*/ + +#pragma once + +#include + +#include +#include +#include + +/** + * @brief Get state of WiFi Station during provisioning + * + * @note WiFi is initially configured as AP, when + * provisioning starts. After provisioning data + * is provided by user, the WiFi is reconfigured + * to run as both AP and Station. + * + * @param[out] state Pointer to wifi_prov_sta_state_t variable to be filled + * + * @return + * - ESP_OK : Successfully retrieved wifi state + * - ESP_FAIL : Provisioning app not running + */ +esp_err_t app_prov_get_wifi_state(wifi_prov_sta_state_t* state); + +/** + * @brief Get reason code in case of WiFi station + * disconnection during provisioning + * +* @param[out] reason Pointer to wifi_prov_sta_fail_reason_t variable to be filled + * + * @return + * - ESP_OK : Successfully retrieved wifi disconnect reason + * - ESP_FAIL : Provisioning app not running + */ +esp_err_t app_prov_get_wifi_disconnect_reason(wifi_prov_sta_fail_reason_t* reason); + +/** + * @brief Checks if device is provisioned + * * + * @param[out] provisioned True if provisioned, else false + * + * @return + * - ESP_OK : Retrieved provision state successfully + * - ESP_FAIL : Failed to retrieve provision state + */ +esp_err_t app_prov_is_provisioned(bool *provisioned); + +/** + * @brief Runs WiFi as both AP and Station + * + * Configures the WiFi station mode to connect to the + * SSID and password specified in config structure, + * and restarts WiFi to run as both AP and station + * + * @param[in] wifi_cfg Pointer to WiFi cofiguration structure + * + * @return + * - ESP_OK : WiFi configured and restarted successfully + * - ESP_FAIL : Failed to set configuration + */ +esp_err_t app_prov_configure_sta(wifi_config_t *wifi_cfg); + +/** + * @brief Start provisioning via softAP + * + * Starts the WiFi softAP with specified ssid and pass, provisioning + * security mode and proof of possession (if any). + * + * @param[in] ssid SSID for SoftAP + * @param[in] pass Password for SoftAP + * @param[in] security Security mode + * @param[in] pop Pointer to proof of possession (NULL if not present) + * + * @return + * - ESP_OK : Provisioning started successfully + * - ESP_FAIL : Failed to start + */ +esp_err_t app_prov_start_softap_provisioning(const char *ssid, const char *pass, + int security, const protocomm_security_pop_t *pop); diff --git a/src/main/app_prov_handlers.c b/src/main/app_prov_handlers.c new file mode 100644 index 0000000..067c112 --- /dev/null +++ b/src/main/app_prov_handlers.c @@ -0,0 +1,147 @@ +/* SoftAP based Custom Provisioning Example + + This example code is in the Public Domain (or CC0 licensed, at your option.) + + Unless required by applicable law or agreed to in writing, this + software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + CONDITIONS OF ANY KIND, either express or implied. +*/ + +/* This file is mostly a boiler-plate code that applications can use without much change */ + +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include "app_prov.h" + +static const char* TAG = "app_prov_handler"; + +/* Provide definition of wifi_prov_ctx_t */ +struct wifi_prov_ctx { + wifi_config_t wifi_cfg; +}; + +static wifi_config_t *get_config(wifi_prov_ctx_t **ctx) +{ + return (*ctx ? &(*ctx)->wifi_cfg : NULL); +} + +static wifi_config_t *new_config(wifi_prov_ctx_t **ctx) +{ + free(*ctx); + (*ctx) = (wifi_prov_ctx_t *) calloc(1, sizeof(wifi_prov_ctx_t)); + return get_config(ctx); +} + +static void free_config(wifi_prov_ctx_t **ctx) +{ + free(*ctx); + *ctx = NULL; +} + +/****************** Handler for Custom Configuration *******************/ +static esp_err_t custom_config_handler(const custom_config_t *config) +{ + ESP_LOGI(TAG, "Custom config received :\n\tInfo : %s\n\tVersion : %d", + config->info, config->version); + return ESP_OK; +} + +custom_prov_config_handler_t custom_prov_handler = custom_config_handler; + +/****************** Handlers for Wi-Fi Configuration *******************/ +static esp_err_t get_status_handler(wifi_prov_config_get_data_t *resp_data, wifi_prov_ctx_t **ctx) +{ + /* Initialize to zero */ + memset(resp_data, 0, sizeof(wifi_prov_config_get_data_t)); + + if (app_prov_get_wifi_state(&resp_data->wifi_state) != ESP_OK) { + ESP_LOGW(TAG, "Prov app not running"); + return ESP_FAIL; + } + + if (resp_data->wifi_state == WIFI_PROV_STA_CONNECTED) { + ESP_LOGI(TAG, "Connected state"); + + /* IP Addr assigned to STA */ + esp_netif_ip_info_t ip_info; + esp_netif_get_ip_info(esp_netif_get_handle_from_ifkey("WIFI_STA_DEF"), &ip_info); + esp_ip4addr_ntoa(&ip_info.ip, resp_data->conn_info.ip_addr, sizeof(resp_data->conn_info.ip_addr)); + + /* AP information to which STA is connected */ + wifi_ap_record_t ap_info; + esp_wifi_sta_get_ap_info(&ap_info); + memcpy(resp_data->conn_info.bssid, (char *)ap_info.bssid, sizeof(ap_info.bssid)); + memcpy(resp_data->conn_info.ssid, (char *)ap_info.ssid, sizeof(ap_info.ssid)); + resp_data->conn_info.channel = ap_info.primary; + resp_data->conn_info.auth_mode = ap_info.authmode; + } else if (resp_data->wifi_state == WIFI_PROV_STA_DISCONNECTED) { + ESP_LOGI(TAG, "Disconnected state"); + + /* If disconnected, convey reason */ + app_prov_get_wifi_disconnect_reason(&resp_data->fail_reason); + } else { + ESP_LOGI(TAG, "Connecting state"); + } + return ESP_OK; +} + +static esp_err_t set_config_handler(const wifi_prov_config_set_data_t *req_data, wifi_prov_ctx_t **ctx) +{ + wifi_config_t *wifi_cfg = get_config(ctx); + if (wifi_cfg) { + free_config(ctx); + } + + wifi_cfg = new_config(ctx); + if (!wifi_cfg) { + ESP_LOGE(TAG, "Unable to alloc wifi config"); + return ESP_FAIL; + } + + ESP_LOGI(TAG, "WiFi Credentials Received : \n\tssid %s \n\tpassword %s", + req_data->ssid, req_data->password); + + /* Using memcpy allows the max SSID length to be 32 bytes (as per 802.11 standard). + * But this doesn't guarantee that the saved SSID will be null terminated, because + * wifi_cfg->sta.ssid is also 32 bytes long (without extra 1 byte for null character). + * Although, this is not a matter for concern because esp_wifi library reads the SSID + * upto 32 bytes in absence of null termination */ + const size_t ssid_len = strnlen(req_data->ssid, sizeof(wifi_cfg->sta.ssid)); + /* Ensure SSID less than 32 bytes is null terminated */ + memset(wifi_cfg->sta.ssid, 0, sizeof(wifi_cfg->sta.ssid)); + memcpy(wifi_cfg->sta.ssid, req_data->ssid, ssid_len); + + strlcpy((char *) wifi_cfg->sta.password, req_data->password, sizeof(wifi_cfg->sta.password)); + return ESP_OK; +} + +static esp_err_t apply_config_handler(wifi_prov_ctx_t **ctx) +{ + wifi_config_t *wifi_cfg = get_config(ctx); + if (!wifi_cfg) { + ESP_LOGE(TAG, "WiFi config not set"); + return ESP_FAIL; + } + + app_prov_configure_sta(wifi_cfg); + ESP_LOGI(TAG, "WiFi Credentials Applied"); + + free_config(ctx); + return ESP_OK; +} + +wifi_prov_config_handlers_t wifi_prov_handlers = { + .get_status_handler = get_status_handler, + .set_config_handler = set_config_handler, + .apply_config_handler = apply_config_handler, + .ctx = NULL +}; diff --git a/src/partitions.csv b/src/partitions.csv deleted file mode 100644 index 711637a..0000000 --- a/src/partitions.csv +++ /dev/null @@ -1,5 +0,0 @@ -# Name, Type, SubType, Offset, Size, Flags -# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap -nvs, data, nvs, 0x9000, 0x6000, -phy_init, data, phy, 0xf000, 0x1000, -factory, app, factory, 0x10000, 1300000, diff --git a/src/sdkconfig b/src/sdkconfig new file mode 100644 index 0000000..26c74d5 --- /dev/null +++ b/src/sdkconfig @@ -0,0 +1,1287 @@ +# +# Automatically generated file. DO NOT EDIT. +# Espressif IoT Development Framework (ESP-IDF) Project Configuration +# +CONFIG_IDF_CMAKE=y +CONFIG_IDF_TARGET_ARCH_XTENSA=y +CONFIG_IDF_TARGET="esp32" +CONFIG_IDF_TARGET_ESP32=y +CONFIG_IDF_FIRMWARE_CHIP_ID=0x0000 + +# +# SDK tool configuration +# +CONFIG_SDK_TOOLPREFIX="xtensa-esp32-elf-" +# CONFIG_SDK_TOOLCHAIN_SUPPORTS_TIME_WIDE_64_BITS is not set +# end of SDK tool configuration + +# +# Build type +# +CONFIG_APP_BUILD_TYPE_APP_2NDBOOT=y +# CONFIG_APP_BUILD_TYPE_ELF_RAM is not set +CONFIG_APP_BUILD_GENERATE_BINARIES=y +CONFIG_APP_BUILD_BOOTLOADER=y +CONFIG_APP_BUILD_USE_FLASH_SECTIONS=y +# end of Build type + +# +# Application manager +# +CONFIG_APP_COMPILE_TIME_DATE=y +# CONFIG_APP_EXCLUDE_PROJECT_VER_VAR is not set +# CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR is not set +# CONFIG_APP_PROJECT_VER_FROM_CONFIG is not set +CONFIG_APP_RETRIEVE_LEN_ELF_SHA=16 +# end of Application manager + +# +# Bootloader config +# +CONFIG_BOOTLOADER_OFFSET_IN_FLASH=0x1000 +CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y +# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_DEBUG is not set +# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_PERF is not set +# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_NONE is not set +# CONFIG_BOOTLOADER_LOG_LEVEL_NONE is not set +# CONFIG_BOOTLOADER_LOG_LEVEL_ERROR is not set +# CONFIG_BOOTLOADER_LOG_LEVEL_WARN is not set +CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y +# CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG is not set +# CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE is not set +CONFIG_BOOTLOADER_LOG_LEVEL=3 +# CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_8V is not set +CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V=y +# CONFIG_BOOTLOADER_FACTORY_RESET is not set +# CONFIG_BOOTLOADER_APP_TEST is not set +CONFIG_BOOTLOADER_WDT_ENABLE=y +# CONFIG_BOOTLOADER_WDT_DISABLE_IN_USER_CODE is not set +CONFIG_BOOTLOADER_WDT_TIME_MS=9000 +# CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE is not set +# CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP is not set +CONFIG_BOOTLOADER_RESERVE_RTC_SIZE=0 +# CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC is not set +# end of Bootloader config + +# +# Security features +# +# CONFIG_SECURE_SIGNED_APPS_NO_SECURE_BOOT is not set +# CONFIG_SECURE_BOOT is not set +# CONFIG_SECURE_FLASH_ENC_ENABLED is not set +# end of Security features + +# +# Serial flasher config +# +CONFIG_ESPTOOLPY_BAUD_OTHER_VAL=115200 +# CONFIG_ESPTOOLPY_NO_STUB is not set +# CONFIG_ESPTOOLPY_FLASHMODE_QIO is not set +# CONFIG_ESPTOOLPY_FLASHMODE_QOUT is not set +CONFIG_ESPTOOLPY_FLASHMODE_DIO=y +# CONFIG_ESPTOOLPY_FLASHMODE_DOUT is not set +CONFIG_ESPTOOLPY_FLASHMODE="dio" +# CONFIG_ESPTOOLPY_FLASHFREQ_80M is not set +CONFIG_ESPTOOLPY_FLASHFREQ_40M=y +# CONFIG_ESPTOOLPY_FLASHFREQ_26M is not set +# CONFIG_ESPTOOLPY_FLASHFREQ_20M is not set +CONFIG_ESPTOOLPY_FLASHFREQ="40m" +# CONFIG_ESPTOOLPY_FLASHSIZE_1MB is not set +CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y +# CONFIG_ESPTOOLPY_FLASHSIZE_4MB is not set +# CONFIG_ESPTOOLPY_FLASHSIZE_8MB is not set +# CONFIG_ESPTOOLPY_FLASHSIZE_16MB is not set +CONFIG_ESPTOOLPY_FLASHSIZE="2MB" +CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y +CONFIG_ESPTOOLPY_BEFORE_RESET=y +# CONFIG_ESPTOOLPY_BEFORE_NORESET is not set +CONFIG_ESPTOOLPY_BEFORE="default_reset" +CONFIG_ESPTOOLPY_AFTER_RESET=y +# CONFIG_ESPTOOLPY_AFTER_NORESET is not set +CONFIG_ESPTOOLPY_AFTER="hard_reset" +# CONFIG_ESPTOOLPY_MONITOR_BAUD_CONSOLE is not set +# CONFIG_ESPTOOLPY_MONITOR_BAUD_9600B is not set +# CONFIG_ESPTOOLPY_MONITOR_BAUD_57600B is not set +CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B=y +# CONFIG_ESPTOOLPY_MONITOR_BAUD_230400B is not set +# CONFIG_ESPTOOLPY_MONITOR_BAUD_921600B is not set +# CONFIG_ESPTOOLPY_MONITOR_BAUD_2MB is not set +# CONFIG_ESPTOOLPY_MONITOR_BAUD_OTHER is not set +CONFIG_ESPTOOLPY_MONITOR_BAUD_OTHER_VAL=115200 +CONFIG_ESPTOOLPY_MONITOR_BAUD=115200 +# end of Serial flasher config + +# +# Partition Table +# +CONFIG_PARTITION_TABLE_SINGLE_APP=y +# CONFIG_PARTITION_TABLE_TWO_OTA is not set +# CONFIG_PARTITION_TABLE_CUSTOM is not set +CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" +CONFIG_PARTITION_TABLE_FILENAME="partitions_singleapp.csv" +CONFIG_PARTITION_TABLE_OFFSET=0x8000 +CONFIG_PARTITION_TABLE_MD5=y +# end of Partition Table + +# +# Example Configuration +# +CONFIG_EXAMPLE_SSID="myssid" +CONFIG_EXAMPLE_PASS="mypassword" +# CONFIG_EXAMPLE_USE_SEC_1 is not set +CONFIG_EXAMPLE_PROTOCOMM_HTTPD_PORT=80 +# CONFIG_EXAMPLE_RESET_PROVISIONED is not set +CONFIG_EXAMPLE_AP_RECONN_ATTEMPTS=5 +# end of Example Configuration + +# +# Compiler options +# +CONFIG_COMPILER_OPTIMIZATION_DEFAULT=y +# CONFIG_COMPILER_OPTIMIZATION_SIZE is not set +# CONFIG_COMPILER_OPTIMIZATION_PERF is not set +# CONFIG_COMPILER_OPTIMIZATION_NONE is not set +CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y +# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT is not set +# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE is not set +# CONFIG_COMPILER_CXX_EXCEPTIONS is not set +# CONFIG_COMPILER_CXX_RTTI is not set +CONFIG_COMPILER_STACK_CHECK_MODE_NONE=y +# CONFIG_COMPILER_STACK_CHECK_MODE_NORM is not set +# CONFIG_COMPILER_STACK_CHECK_MODE_STRONG is not set +# CONFIG_COMPILER_STACK_CHECK_MODE_ALL is not set +# CONFIG_COMPILER_WARN_WRITE_STRINGS is not set +# CONFIG_COMPILER_DISABLE_GCC8_WARNINGS is not set +# CONFIG_COMPILER_DUMP_RTL_FILES is not set +# end of Compiler options + +# +# Component config +# + +# +# Application Level Tracing +# +# CONFIG_APPTRACE_DEST_TRAX is not set +CONFIG_APPTRACE_DEST_NONE=y +CONFIG_APPTRACE_LOCK_ENABLE=y +# end of Application Level Tracing + +# +# ESP-ASIO +# +# CONFIG_ASIO_SSL_SUPPORT is not set +# end of ESP-ASIO + +# +# Bluetooth +# +# CONFIG_BT_ENABLED is not set +CONFIG_BTDM_CTRL_BR_EDR_SCO_DATA_PATH_EFF=0 +CONFIG_BTDM_CTRL_PCM_ROLE_EFF=0 +CONFIG_BTDM_CTRL_PCM_POLAR_EFF=0 +CONFIG_BTDM_CTRL_BLE_MAX_CONN_EFF=0 +CONFIG_BTDM_CTRL_BR_EDR_MAX_ACL_CONN_EFF=0 +CONFIG_BTDM_CTRL_BR_EDR_MAX_SYNC_CONN_EFF=0 +CONFIG_BTDM_CTRL_PINNED_TO_CORE=0 +CONFIG_BTDM_BLE_SLEEP_CLOCK_ACCURACY_INDEX_EFF=1 +CONFIG_BT_CTRL_MODE_EFF=1 +CONFIG_BT_CTRL_BLE_MAX_ACT=10 +CONFIG_BT_CTRL_BLE_MAX_ACT_EFF=10 +CONFIG_BT_CTRL_BLE_STATIC_ACL_TX_BUF_NB=0 +CONFIG_BT_CTRL_PINNED_TO_CORE=0 +CONFIG_BT_CTRL_HCI_TL=1 +CONFIG_BT_CTRL_ADV_DUP_FILT_MAX=30 +CONFIG_BT_CTRL_HW_CCA_EFF=0 +CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_EFF=0 +CONFIG_BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_SUPP=y +CONFIG_BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_NUM=100 +CONFIG_BT_CTRL_BLE_ADV_REPORT_DISCARD_THRSHOLD=20 +CONFIG_BT_CTRL_BLE_SCAN_DUPL=y +CONFIG_BT_CTRL_SCAN_DUPL_TYPE=0 +CONFIG_BT_CTRL_SCAN_DUPL_CACHE_SIZE=100 +CONFIG_BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_EFF=0 +CONFIG_BT_CTRL_SLEEP_MODE_EFF=0 +CONFIG_BT_CTRL_SLEEP_CLOCK_EFF=0 +CONFIG_BT_CTRL_HCI_TL_EFF=1 +CONFIG_BT_RESERVE_DRAM=0 +# end of Bluetooth + +# +# CoAP Configuration +# +CONFIG_COAP_MBEDTLS_PSK=y +# CONFIG_COAP_MBEDTLS_PKI is not set +# CONFIG_COAP_MBEDTLS_DEBUG is not set +CONFIG_COAP_LOG_DEFAULT_LEVEL=0 +# end of CoAP Configuration + +# +# Driver configurations +# + +# +# ADC configuration +# +# CONFIG_ADC_FORCE_XPD_FSM is not set +CONFIG_ADC_DISABLE_DAC=y +# end of ADC configuration + +# +# SPI configuration +# +# CONFIG_SPI_MASTER_IN_IRAM is not set +CONFIG_SPI_MASTER_ISR_IN_IRAM=y +# CONFIG_SPI_SLAVE_IN_IRAM is not set +CONFIG_SPI_SLAVE_ISR_IN_IRAM=y +# end of SPI configuration + +# +# TWAI configuration +# +# CONFIG_TWAI_ISR_IN_IRAM is not set +# end of TWAI configuration + +# +# UART configuration +# +# CONFIG_UART_ISR_IN_IRAM is not set +# end of UART configuration + +# +# RTCIO configuration +# +# CONFIG_RTCIO_SUPPORT_RTC_GPIO_DESC is not set +# end of RTCIO configuration + +# +# GPIO Configuration +# +# CONFIG_GPIO_ESP32_SUPPORT_SWITCH_SLP_PULL is not set +# end of GPIO Configuration +# end of Driver configurations + +# +# eFuse Bit Manager +# +# CONFIG_EFUSE_CUSTOM_TABLE is not set +# CONFIG_EFUSE_VIRTUAL is not set +# CONFIG_EFUSE_CODE_SCHEME_COMPAT_NONE is not set +CONFIG_EFUSE_CODE_SCHEME_COMPAT_3_4=y +# CONFIG_EFUSE_CODE_SCHEME_COMPAT_REPEAT is not set +CONFIG_EFUSE_MAX_BLK_LEN=192 +# end of eFuse Bit Manager + +# +# ESP-TLS +# +CONFIG_ESP_TLS_USING_MBEDTLS=y +# CONFIG_ESP_TLS_USE_SECURE_ELEMENT is not set +# CONFIG_ESP_TLS_SERVER is not set +# CONFIG_ESP_TLS_PSK_VERIFICATION is not set +# CONFIG_ESP_TLS_INSECURE is not set +# end of ESP-TLS + +# +# ESP32-specific +# +CONFIG_ESP32_REV_MIN_0=y +# CONFIG_ESP32_REV_MIN_1 is not set +# CONFIG_ESP32_REV_MIN_2 is not set +# CONFIG_ESP32_REV_MIN_3 is not set +CONFIG_ESP32_REV_MIN=0 +CONFIG_ESP32_DPORT_WORKAROUND=y +# CONFIG_ESP32_DEFAULT_CPU_FREQ_80 is not set +CONFIG_ESP32_DEFAULT_CPU_FREQ_160=y +# CONFIG_ESP32_DEFAULT_CPU_FREQ_240 is not set +CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=160 +# CONFIG_ESP32_SPIRAM_SUPPORT is not set +# CONFIG_ESP32_TRAX is not set +CONFIG_ESP32_TRACEMEM_RESERVE_DRAM=0x0 +# CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES_TWO is not set +CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES_FOUR=y +CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES=4 +# CONFIG_ESP32_ULP_COPROC_ENABLED is not set +CONFIG_ESP32_ULP_COPROC_RESERVE_MEM=0 +CONFIG_ESP32_DEBUG_OCDAWARE=y +CONFIG_ESP32_BROWNOUT_DET=y +CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_0=y +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_1 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_2 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_3 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_4 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_5 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_6 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_7 is not set +CONFIG_ESP32_BROWNOUT_DET_LVL=0 +CONFIG_ESP32_REDUCE_PHY_TX_POWER=y +CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1=y +# CONFIG_ESP32_TIME_SYSCALL_USE_RTC is not set +# CONFIG_ESP32_TIME_SYSCALL_USE_FRC1 is not set +# CONFIG_ESP32_TIME_SYSCALL_USE_NONE is not set +CONFIG_ESP32_RTC_CLK_SRC_INT_RC=y +# CONFIG_ESP32_RTC_CLK_SRC_EXT_CRYS is not set +# CONFIG_ESP32_RTC_CLK_SRC_EXT_OSC is not set +# CONFIG_ESP32_RTC_CLK_SRC_INT_8MD256 is not set +CONFIG_ESP32_RTC_CLK_CAL_CYCLES=1024 +CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY=2000 +CONFIG_ESP32_XTAL_FREQ_40=y +# CONFIG_ESP32_XTAL_FREQ_26 is not set +# CONFIG_ESP32_XTAL_FREQ_AUTO is not set +CONFIG_ESP32_XTAL_FREQ=40 +# CONFIG_ESP32_DISABLE_BASIC_ROM_CONSOLE is not set +# CONFIG_ESP32_NO_BLOBS is not set +# CONFIG_ESP32_COMPATIBLE_PRE_V2_1_BOOTLOADERS is not set +# CONFIG_ESP32_USE_FIXED_STATIC_RAM_SIZE is not set +CONFIG_ESP32_DPORT_DIS_INTERRUPT_LVL=5 +# end of ESP32-specific + +# +# ADC-Calibration +# +CONFIG_ADC_CAL_EFUSE_TP_ENABLE=y +CONFIG_ADC_CAL_EFUSE_VREF_ENABLE=y +CONFIG_ADC_CAL_LUT_ENABLE=y +# end of ADC-Calibration + +# +# Common ESP-related +# +CONFIG_ESP_ERR_TO_NAME_LOOKUP=y +CONFIG_ESP_SYSTEM_EVENT_QUEUE_SIZE=32 +CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=2304 +CONFIG_ESP_MAIN_TASK_STACK_SIZE=3584 +CONFIG_ESP_IPC_TASK_STACK_SIZE=1024 +CONFIG_ESP_IPC_USES_CALLERS_PRIORITY=y +CONFIG_ESP_MINIMAL_SHARED_STACK_SIZE=2048 +CONFIG_ESP_CONSOLE_UART_DEFAULT=y +# CONFIG_ESP_CONSOLE_UART_CUSTOM is not set +# CONFIG_ESP_CONSOLE_NONE is not set +CONFIG_ESP_CONSOLE_UART=y +CONFIG_ESP_CONSOLE_MULTIPLE_UART=y +CONFIG_ESP_CONSOLE_UART_NUM=0 +CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200 +CONFIG_ESP_INT_WDT=y +CONFIG_ESP_INT_WDT_TIMEOUT_MS=300 +CONFIG_ESP_INT_WDT_CHECK_CPU1=y +CONFIG_ESP_TASK_WDT=y +# CONFIG_ESP_TASK_WDT_PANIC is not set +CONFIG_ESP_TASK_WDT_TIMEOUT_S=5 +CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=y +CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1=y +# CONFIG_ESP_PANIC_HANDLER_IRAM is not set +CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_STA=y +CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_AP=y +CONFIG_ESP_MAC_ADDR_UNIVERSE_BT=y +CONFIG_ESP_MAC_ADDR_UNIVERSE_BT_OFFSET=2 +CONFIG_ESP_MAC_ADDR_UNIVERSE_ETH=y +# end of Common ESP-related + +# +# Ethernet +# +CONFIG_ETH_ENABLED=y +CONFIG_ETH_USE_ESP32_EMAC=y +CONFIG_ETH_PHY_INTERFACE_RMII=y +# CONFIG_ETH_PHY_INTERFACE_MII is not set +CONFIG_ETH_RMII_CLK_INPUT=y +# CONFIG_ETH_RMII_CLK_OUTPUT is not set +CONFIG_ETH_RMII_CLK_IN_GPIO=0 +CONFIG_ETH_DMA_BUFFER_SIZE=512 +CONFIG_ETH_DMA_RX_BUFFER_NUM=10 +CONFIG_ETH_DMA_TX_BUFFER_NUM=10 +CONFIG_ETH_USE_SPI_ETHERNET=y +# CONFIG_ETH_SPI_ETHERNET_DM9051 is not set +# CONFIG_ETH_SPI_ETHERNET_W5500 is not set +# CONFIG_ETH_USE_OPENETH is not set +# end of Ethernet + +# +# Event Loop Library +# +# CONFIG_ESP_EVENT_LOOP_PROFILING is not set +CONFIG_ESP_EVENT_POST_FROM_ISR=y +CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR=y +# end of Event Loop Library + +# +# GDB Stub +# +# end of GDB Stub + +# +# ESP HTTP client +# +CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS=y +# CONFIG_ESP_HTTP_CLIENT_ENABLE_BASIC_AUTH is not set +# end of ESP HTTP client + +# +# HTTP Server +# +CONFIG_HTTPD_MAX_REQ_HDR_LEN=512 +CONFIG_HTTPD_MAX_URI_LEN=512 +CONFIG_HTTPD_ERR_RESP_NO_DELAY=y +CONFIG_HTTPD_PURGE_BUF_LEN=32 +# CONFIG_HTTPD_LOG_PURGE_DATA is not set +# CONFIG_HTTPD_WS_SUPPORT is not set +# end of HTTP Server + +# +# ESP HTTPS OTA +# +# CONFIG_OTA_ALLOW_HTTP is not set +# end of ESP HTTPS OTA + +# +# ESP HTTPS server +# +# CONFIG_ESP_HTTPS_SERVER_ENABLE is not set +# end of ESP HTTPS server + +# +# ESP NETIF Adapter +# +CONFIG_ESP_NETIF_IP_LOST_TIMER_INTERVAL=120 +CONFIG_ESP_NETIF_TCPIP_LWIP=y +# CONFIG_ESP_NETIF_LOOPBACK is not set +CONFIG_ESP_NETIF_TCPIP_ADAPTER_COMPATIBLE_LAYER=y +# end of ESP NETIF Adapter + +# +# Power Management +# +# CONFIG_PM_ENABLE is not set +# end of Power Management + +# +# ESP System Settings +# +# CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT is not set +CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT=y +# CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT is not set +# CONFIG_ESP_SYSTEM_PANIC_GDBSTUB is not set +CONFIG_ESP_SYSTEM_PD_FLASH=y + +# +# Memory protection +# +# end of Memory protection +# end of ESP System Settings + +# +# High resolution timer (esp_timer) +# +# CONFIG_ESP_TIMER_PROFILING is not set +CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER=y +CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER=y +CONFIG_ESP_TIMER_TASK_STACK_SIZE=3584 +# CONFIG_ESP_TIMER_IMPL_FRC2 is not set +CONFIG_ESP_TIMER_IMPL_TG0_LAC=y +# end of High resolution timer (esp_timer) + +# +# Wi-Fi +# +CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=10 +CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=32 +# CONFIG_ESP32_WIFI_STATIC_TX_BUFFER is not set +CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER=y +CONFIG_ESP32_WIFI_TX_BUFFER_TYPE=1 +CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=32 +# CONFIG_ESP32_WIFI_CSI_ENABLED is not set +CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=y +CONFIG_ESP32_WIFI_TX_BA_WIN=6 +CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y +CONFIG_ESP32_WIFI_RX_BA_WIN=6 +CONFIG_ESP32_WIFI_NVS_ENABLED=y +CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0=y +# CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1 is not set +CONFIG_ESP32_WIFI_SOFTAP_BEACON_MAX_LEN=752 +CONFIG_ESP32_WIFI_MGMT_SBUF_NUM=32 +# CONFIG_ESP32_WIFI_DEBUG_LOG_ENABLE is not set +CONFIG_ESP32_WIFI_IRAM_OPT=y +CONFIG_ESP32_WIFI_RX_IRAM_OPT=y +CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE=y +# CONFIG_ESP_WIFI_SLP_IRAM_OPT is not set +# end of Wi-Fi + +# +# PHY +# +CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE=y +# CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION is not set +CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER=20 +CONFIG_ESP32_PHY_MAX_TX_POWER=20 +# end of PHY + +# +# Core dump +# +# CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH is not set +# CONFIG_ESP_COREDUMP_ENABLE_TO_UART is not set +CONFIG_ESP_COREDUMP_ENABLE_TO_NONE=y +# end of Core dump + +# +# FAT Filesystem support +# +# CONFIG_FATFS_CODEPAGE_DYNAMIC is not set +CONFIG_FATFS_CODEPAGE_437=y +# CONFIG_FATFS_CODEPAGE_720 is not set +# CONFIG_FATFS_CODEPAGE_737 is not set +# CONFIG_FATFS_CODEPAGE_771 is not set +# CONFIG_FATFS_CODEPAGE_775 is not set +# CONFIG_FATFS_CODEPAGE_850 is not set +# CONFIG_FATFS_CODEPAGE_852 is not set +# CONFIG_FATFS_CODEPAGE_855 is not set +# CONFIG_FATFS_CODEPAGE_857 is not set +# CONFIG_FATFS_CODEPAGE_860 is not set +# CONFIG_FATFS_CODEPAGE_861 is not set +# CONFIG_FATFS_CODEPAGE_862 is not set +# CONFIG_FATFS_CODEPAGE_863 is not set +# CONFIG_FATFS_CODEPAGE_864 is not set +# CONFIG_FATFS_CODEPAGE_865 is not set +# CONFIG_FATFS_CODEPAGE_866 is not set +# CONFIG_FATFS_CODEPAGE_869 is not set +# CONFIG_FATFS_CODEPAGE_932 is not set +# CONFIG_FATFS_CODEPAGE_936 is not set +# CONFIG_FATFS_CODEPAGE_949 is not set +# CONFIG_FATFS_CODEPAGE_950 is not set +CONFIG_FATFS_CODEPAGE=437 +CONFIG_FATFS_LFN_NONE=y +# CONFIG_FATFS_LFN_HEAP is not set +# CONFIG_FATFS_LFN_STACK is not set +CONFIG_FATFS_FS_LOCK=0 +CONFIG_FATFS_TIMEOUT_MS=10000 +CONFIG_FATFS_PER_FILE_CACHE=y +# CONFIG_FATFS_USE_FASTSEEK is not set +# end of FAT Filesystem support + +# +# Modbus configuration +# +CONFIG_FMB_COMM_MODE_TCP_EN=y +CONFIG_FMB_TCP_PORT_DEFAULT=502 +CONFIG_FMB_TCP_PORT_MAX_CONN=5 +CONFIG_FMB_TCP_CONNECTION_TOUT_SEC=20 +CONFIG_FMB_COMM_MODE_RTU_EN=y +CONFIG_FMB_COMM_MODE_ASCII_EN=y +CONFIG_FMB_MASTER_TIMEOUT_MS_RESPOND=150 +CONFIG_FMB_MASTER_DELAY_MS_CONVERT=200 +CONFIG_FMB_QUEUE_LENGTH=20 +CONFIG_FMB_PORT_TASK_STACK_SIZE=4096 +CONFIG_FMB_SERIAL_BUF_SIZE=256 +CONFIG_FMB_SERIAL_ASCII_BITS_PER_SYMB=8 +CONFIG_FMB_SERIAL_ASCII_TIMEOUT_RESPOND_MS=1000 +CONFIG_FMB_PORT_TASK_PRIO=10 +CONFIG_FMB_CONTROLLER_SLAVE_ID_SUPPORT=y +CONFIG_FMB_CONTROLLER_SLAVE_ID=0x00112233 +CONFIG_FMB_CONTROLLER_NOTIFY_TIMEOUT=20 +CONFIG_FMB_CONTROLLER_NOTIFY_QUEUE_SIZE=20 +CONFIG_FMB_CONTROLLER_STACK_SIZE=4096 +CONFIG_FMB_EVENT_QUEUE_TIMEOUT=20 +CONFIG_FMB_TIMER_PORT_ENABLED=y +CONFIG_FMB_TIMER_GROUP=0 +CONFIG_FMB_TIMER_INDEX=0 +# CONFIG_FMB_TIMER_ISR_IN_IRAM is not set +# end of Modbus configuration + +# +# FreeRTOS +# +# CONFIG_FREERTOS_UNICORE is not set +CONFIG_FREERTOS_NO_AFFINITY=0x7FFFFFFF +CONFIG_FREERTOS_CORETIMER_0=y +# CONFIG_FREERTOS_CORETIMER_1 is not set +CONFIG_FREERTOS_HZ=100 +CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION=y +# CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE is not set +# CONFIG_FREERTOS_CHECK_STACKOVERFLOW_PTRVAL is not set +CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY=y +# CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK is not set +CONFIG_FREERTOS_INTERRUPT_BACKTRACE=y +CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS=1 +CONFIG_FREERTOS_ASSERT_FAIL_ABORT=y +# CONFIG_FREERTOS_ASSERT_FAIL_PRINT_CONTINUE is not set +# CONFIG_FREERTOS_ASSERT_DISABLE is not set +CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=2304 +CONFIG_FREERTOS_ISR_STACKSIZE=1536 +# CONFIG_FREERTOS_LEGACY_HOOKS is not set +CONFIG_FREERTOS_MAX_TASK_NAME_LEN=16 +CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y +# CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP is not set +CONFIG_FREERTOS_TIMER_TASK_PRIORITY=1 +CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=2048 +CONFIG_FREERTOS_TIMER_QUEUE_LENGTH=10 +CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=0 +# CONFIG_FREERTOS_USE_TRACE_FACILITY is not set +# CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS is not set +CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER=y +CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER=y +# CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE is not set +# CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH is not set +CONFIG_FREERTOS_DEBUG_OCDAWARE=y +# CONFIG_FREERTOS_FPU_IN_ISR is not set +# end of FreeRTOS + +# +# Heap memory debugging +# +CONFIG_HEAP_POISONING_DISABLED=y +# CONFIG_HEAP_POISONING_LIGHT is not set +# CONFIG_HEAP_POISONING_COMPREHENSIVE is not set +CONFIG_HEAP_TRACING_OFF=y +# CONFIG_HEAP_TRACING_STANDALONE is not set +# CONFIG_HEAP_TRACING_TOHOST is not set +# CONFIG_HEAP_ABORT_WHEN_ALLOCATION_FAILS is not set +# end of Heap memory debugging + +# +# jsmn +# +# CONFIG_JSMN_PARENT_LINKS is not set +# CONFIG_JSMN_STRICT is not set +# end of jsmn + +# +# libsodium +# +# end of libsodium + +# +# Log output +# +# CONFIG_LOG_DEFAULT_LEVEL_NONE is not set +# CONFIG_LOG_DEFAULT_LEVEL_ERROR is not set +# CONFIG_LOG_DEFAULT_LEVEL_WARN is not set +CONFIG_LOG_DEFAULT_LEVEL_INFO=y +# CONFIG_LOG_DEFAULT_LEVEL_DEBUG is not set +# CONFIG_LOG_DEFAULT_LEVEL_VERBOSE is not set +CONFIG_LOG_DEFAULT_LEVEL=3 +CONFIG_LOG_COLORS=y +CONFIG_LOG_TIMESTAMP_SOURCE_RTOS=y +# CONFIG_LOG_TIMESTAMP_SOURCE_SYSTEM is not set +# end of Log output + +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif" +CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y +# CONFIG_LWIP_L2_TO_L3_COPY is not set +# CONFIG_LWIP_IRAM_OPTIMIZATION is not set +CONFIG_LWIP_TIMERS_ONDEMAND=y +CONFIG_LWIP_MAX_SOCKETS=10 +# CONFIG_LWIP_USE_ONLY_LWIP_SELECT is not set +# CONFIG_LWIP_SO_LINGER is not set +CONFIG_LWIP_SO_REUSE=y +CONFIG_LWIP_SO_REUSE_RXTOALL=y +# CONFIG_LWIP_SO_RCVBUF is not set +# CONFIG_LWIP_NETBUF_RECVINFO is not set +CONFIG_LWIP_IP4_FRAG=y +CONFIG_LWIP_IP6_FRAG=y +# CONFIG_LWIP_IP4_REASSEMBLY is not set +# CONFIG_LWIP_IP6_REASSEMBLY is not set +# CONFIG_LWIP_IP_FORWARD is not set +# CONFIG_LWIP_STATS is not set +# CONFIG_LWIP_ETHARP_TRUST_IP_MAC is not set +CONFIG_LWIP_ESP_GRATUITOUS_ARP=y +CONFIG_LWIP_GARP_TMR_INTERVAL=60 +CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=32 +CONFIG_LWIP_DHCP_DOES_ARP_CHECK=y +# CONFIG_LWIP_DHCP_RESTORE_LAST_IP is not set + +# +# DHCP server +# +CONFIG_LWIP_DHCPS_LEASE_UNIT=60 +CONFIG_LWIP_DHCPS_MAX_STATION_NUM=8 +# end of DHCP server + +# CONFIG_LWIP_AUTOIP is not set +# CONFIG_LWIP_IPV6_AUTOCONFIG is not set +CONFIG_LWIP_NETIF_LOOPBACK=y +CONFIG_LWIP_LOOPBACK_MAX_PBUFS=8 + +# +# TCP +# +CONFIG_LWIP_MAX_ACTIVE_TCP=16 +CONFIG_LWIP_MAX_LISTENING_TCP=16 +CONFIG_LWIP_TCP_HIGH_SPEED_RETRANSMISSION=y +CONFIG_LWIP_TCP_MAXRTX=12 +CONFIG_LWIP_TCP_SYNMAXRTX=12 +CONFIG_LWIP_TCP_MSS=1440 +CONFIG_LWIP_TCP_TMR_INTERVAL=250 +CONFIG_LWIP_TCP_MSL=60000 +CONFIG_LWIP_TCP_SND_BUF_DEFAULT=5744 +CONFIG_LWIP_TCP_WND_DEFAULT=5744 +CONFIG_LWIP_TCP_RECVMBOX_SIZE=6 +CONFIG_LWIP_TCP_QUEUE_OOSEQ=y +# CONFIG_LWIP_TCP_SACK_OUT is not set +# CONFIG_LWIP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES is not set +CONFIG_LWIP_TCP_OVERSIZE_MSS=y +# CONFIG_LWIP_TCP_OVERSIZE_QUARTER_MSS is not set +# CONFIG_LWIP_TCP_OVERSIZE_DISABLE is not set +CONFIG_LWIP_TCP_RTO_TIME=1500 +# end of TCP + +# +# UDP +# +CONFIG_LWIP_MAX_UDP_PCBS=16 +CONFIG_LWIP_UDP_RECVMBOX_SIZE=6 +# end of UDP + +# +# Checksums +# +# CONFIG_LWIP_CHECKSUM_CHECK_IP is not set +# CONFIG_LWIP_CHECKSUM_CHECK_UDP is not set +CONFIG_LWIP_CHECKSUM_CHECK_ICMP=y +# end of Checksums + +CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=3072 +CONFIG_LWIP_TCPIP_TASK_AFFINITY_NO_AFFINITY=y +# CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU0 is not set +# CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU1 is not set +CONFIG_LWIP_TCPIP_TASK_AFFINITY=0x7FFFFFFF +# CONFIG_LWIP_PPP_SUPPORT is not set +CONFIG_LWIP_IPV6_MEMP_NUM_ND6_QUEUE=3 +CONFIG_LWIP_IPV6_ND6_NUM_NEIGHBORS=5 +# CONFIG_LWIP_SLIP_SUPPORT is not set + +# +# ICMP +# +# CONFIG_LWIP_MULTICAST_PING is not set +# CONFIG_LWIP_BROADCAST_PING is not set +# end of ICMP + +# +# LWIP RAW API +# +CONFIG_LWIP_MAX_RAW_PCBS=16 +# end of LWIP RAW API + +# +# SNTP +# +CONFIG_LWIP_DHCP_MAX_NTP_SERVERS=1 +CONFIG_LWIP_SNTP_UPDATE_DELAY=3600000 +# end of SNTP + +CONFIG_LWIP_ESP_LWIP_ASSERT=y + +# +# Hooks +# +# CONFIG_LWIP_HOOK_TCP_ISN_NONE is not set +CONFIG_LWIP_HOOK_TCP_ISN_DEFAULT=y +# CONFIG_LWIP_HOOK_TCP_ISN_CUSTOM is not set +CONFIG_LWIP_HOOK_IP6_ROUTE_NONE=y +# CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT is not set +# CONFIG_LWIP_HOOK_IP6_ROUTE_CUSTOM is not set +CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_NONE=y +# CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_DEFAULT is not set +# CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_CUSTOM is not set +# end of Hooks + +# +# Debug +# +# CONFIG_LWIP_NETIF_DEBUG is not set +# CONFIG_LWIP_PBUF_DEBUG is not set +# CONFIG_LWIP_ETHARP_DEBUG is not set +# CONFIG_LWIP_API_LIB_DEBUG is not set +# CONFIG_LWIP_SOCKETS_DEBUG is not set +# CONFIG_LWIP_IP_DEBUG is not set +# CONFIG_LWIP_ICMP_DEBUG is not set +# CONFIG_LWIP_DHCP_STATE_DEBUG is not set +# CONFIG_LWIP_DHCP_DEBUG is not set +# CONFIG_LWIP_IP6_DEBUG is not set +# CONFIG_LWIP_ICMP6_DEBUG is not set +# CONFIG_LWIP_TCP_DEBUG is not set +# end of Debug +# end of LWIP + +# +# mbedTLS +# +CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y +# CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC is not set +# CONFIG_MBEDTLS_CUSTOM_MEM_ALLOC is not set +CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN=y +CONFIG_MBEDTLS_SSL_IN_CONTENT_LEN=16384 +CONFIG_MBEDTLS_SSL_OUT_CONTENT_LEN=4096 +# CONFIG_MBEDTLS_DYNAMIC_BUFFER is not set +# CONFIG_MBEDTLS_DEBUG is not set + +# +# Certificate Bundle +# +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y +# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN is not set +# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE is not set +# CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE is not set +# end of Certificate Bundle + +# CONFIG_MBEDTLS_ECP_RESTARTABLE is not set +# CONFIG_MBEDTLS_CMAC_C is not set +CONFIG_MBEDTLS_HARDWARE_AES=y +CONFIG_MBEDTLS_HARDWARE_MPI=y +CONFIG_MBEDTLS_HARDWARE_SHA=y +# CONFIG_MBEDTLS_ATCA_HW_ECDSA_SIGN is not set +# CONFIG_MBEDTLS_ATCA_HW_ECDSA_VERIFY is not set +CONFIG_MBEDTLS_HAVE_TIME=y +# CONFIG_MBEDTLS_HAVE_TIME_DATE is not set +CONFIG_MBEDTLS_ECDSA_DETERMINISTIC=y +CONFIG_MBEDTLS_SHA512_C=y +CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT=y +# CONFIG_MBEDTLS_TLS_SERVER_ONLY is not set +# CONFIG_MBEDTLS_TLS_CLIENT_ONLY is not set +# CONFIG_MBEDTLS_TLS_DISABLED is not set +CONFIG_MBEDTLS_TLS_SERVER=y +CONFIG_MBEDTLS_TLS_CLIENT=y +CONFIG_MBEDTLS_TLS_ENABLED=y + +# +# TLS Key Exchange Methods +# +# CONFIG_MBEDTLS_PSK_MODES is not set +CONFIG_MBEDTLS_KEY_EXCHANGE_RSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_RSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ELLIPTIC_CURVE=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA=y +# end of TLS Key Exchange Methods + +CONFIG_MBEDTLS_SSL_RENEGOTIATION=y +# CONFIG_MBEDTLS_SSL_PROTO_SSL3 is not set +CONFIG_MBEDTLS_SSL_PROTO_TLS1=y +CONFIG_MBEDTLS_SSL_PROTO_TLS1_1=y +CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=y +# CONFIG_MBEDTLS_SSL_PROTO_DTLS is not set +CONFIG_MBEDTLS_SSL_ALPN=y +CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS=y +CONFIG_MBEDTLS_SERVER_SSL_SESSION_TICKETS=y + +# +# Symmetric Ciphers +# +CONFIG_MBEDTLS_AES_C=y +# CONFIG_MBEDTLS_CAMELLIA_C is not set +# CONFIG_MBEDTLS_DES_C is not set +CONFIG_MBEDTLS_RC4_DISABLED=y +# CONFIG_MBEDTLS_RC4_ENABLED_NO_DEFAULT is not set +# CONFIG_MBEDTLS_RC4_ENABLED is not set +# CONFIG_MBEDTLS_BLOWFISH_C is not set +# CONFIG_MBEDTLS_XTEA_C is not set +CONFIG_MBEDTLS_CCM_C=y +CONFIG_MBEDTLS_GCM_C=y +# end of Symmetric Ciphers + +# CONFIG_MBEDTLS_RIPEMD160_C is not set + +# +# Certificates +# +CONFIG_MBEDTLS_PEM_PARSE_C=y +CONFIG_MBEDTLS_PEM_WRITE_C=y +CONFIG_MBEDTLS_X509_CRL_PARSE_C=y +CONFIG_MBEDTLS_X509_CSR_PARSE_C=y +# end of Certificates + +CONFIG_MBEDTLS_ECP_C=y +CONFIG_MBEDTLS_ECDH_C=y +CONFIG_MBEDTLS_ECDSA_C=y +# CONFIG_MBEDTLS_ECJPAKE_C is not set +CONFIG_MBEDTLS_ECP_DP_SECP192R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP224R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP192K1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP224K1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED=y +CONFIG_MBEDTLS_ECP_NIST_OPTIM=y +# CONFIG_MBEDTLS_POLY1305_C is not set +# CONFIG_MBEDTLS_CHACHA20_C is not set +# CONFIG_MBEDTLS_HKDF_C is not set +# CONFIG_MBEDTLS_THREADING_C is not set +# CONFIG_MBEDTLS_LARGE_KEY_SOFTWARE_MPI is not set +# CONFIG_MBEDTLS_SECURITY_RISKS is not set +# end of mbedTLS + +# +# mDNS +# +CONFIG_MDNS_MAX_SERVICES=10 +CONFIG_MDNS_TASK_PRIORITY=1 +CONFIG_MDNS_TASK_STACK_SIZE=4096 +# CONFIG_MDNS_TASK_AFFINITY_NO_AFFINITY is not set +CONFIG_MDNS_TASK_AFFINITY_CPU0=y +# CONFIG_MDNS_TASK_AFFINITY_CPU1 is not set +CONFIG_MDNS_TASK_AFFINITY=0x0 +CONFIG_MDNS_SERVICE_ADD_TIMEOUT_MS=2000 +CONFIG_MDNS_TIMER_PERIOD_MS=100 +# end of mDNS + +# +# ESP-MQTT Configurations +# +CONFIG_MQTT_PROTOCOL_311=y +CONFIG_MQTT_TRANSPORT_SSL=y +CONFIG_MQTT_TRANSPORT_WEBSOCKET=y +CONFIG_MQTT_TRANSPORT_WEBSOCKET_SECURE=y +# CONFIG_MQTT_MSG_ID_INCREMENTAL is not set +# CONFIG_MQTT_SKIP_PUBLISH_IF_DISCONNECTED is not set +# CONFIG_MQTT_REPORT_DELETED_MESSAGES is not set +# CONFIG_MQTT_USE_CUSTOM_CONFIG is not set +# CONFIG_MQTT_TASK_CORE_SELECTION_ENABLED is not set +# CONFIG_MQTT_CUSTOM_OUTBOX is not set +# end of ESP-MQTT Configurations + +# +# Newlib +# +CONFIG_NEWLIB_STDOUT_LINE_ENDING_CRLF=y +# CONFIG_NEWLIB_STDOUT_LINE_ENDING_LF is not set +# CONFIG_NEWLIB_STDOUT_LINE_ENDING_CR is not set +# CONFIG_NEWLIB_STDIN_LINE_ENDING_CRLF is not set +# CONFIG_NEWLIB_STDIN_LINE_ENDING_LF is not set +CONFIG_NEWLIB_STDIN_LINE_ENDING_CR=y +# CONFIG_NEWLIB_NANO_FORMAT is not set +# end of Newlib + +# +# NVS +# +# end of NVS + +# +# OpenSSL +# +# CONFIG_OPENSSL_DEBUG is not set +CONFIG_OPENSSL_ERROR_STACK=y +# CONFIG_OPENSSL_ASSERT_DO_NOTHING is not set +CONFIG_OPENSSL_ASSERT_EXIT=y +# end of OpenSSL + +# +# PThreads +# +CONFIG_PTHREAD_TASK_PRIO_DEFAULT=5 +CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT=3072 +CONFIG_PTHREAD_STACK_MIN=768 +CONFIG_PTHREAD_DEFAULT_CORE_NO_AFFINITY=y +# CONFIG_PTHREAD_DEFAULT_CORE_0 is not set +# CONFIG_PTHREAD_DEFAULT_CORE_1 is not set +CONFIG_PTHREAD_TASK_CORE_DEFAULT=-1 +CONFIG_PTHREAD_TASK_NAME_DEFAULT="pthread" +# end of PThreads + +# +# SPI Flash driver +# +# CONFIG_SPI_FLASH_VERIFY_WRITE is not set +# CONFIG_SPI_FLASH_ENABLE_COUNTERS is not set +CONFIG_SPI_FLASH_ROM_DRIVER_PATCH=y +CONFIG_SPI_FLASH_DANGEROUS_WRITE_ABORTS=y +# CONFIG_SPI_FLASH_DANGEROUS_WRITE_FAILS is not set +# CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED is not set +# CONFIG_SPI_FLASH_USE_LEGACY_IMPL is not set +# CONFIG_SPI_FLASH_SHARE_SPI1_BUS is not set +# CONFIG_SPI_FLASH_BYPASS_BLOCK_ERASE is not set +CONFIG_SPI_FLASH_YIELD_DURING_ERASE=y +CONFIG_SPI_FLASH_ERASE_YIELD_DURATION_MS=20 +CONFIG_SPI_FLASH_ERASE_YIELD_TICKS=1 +CONFIG_SPI_FLASH_WRITE_CHUNK_SIZE=8192 +# CONFIG_SPI_FLASH_SIZE_OVERRIDE is not set +# CONFIG_SPI_FLASH_CHECK_ERASE_TIMEOUT_DISABLED is not set + +# +# Auto-detect flash chips +# +CONFIG_SPI_FLASH_SUPPORT_ISSI_CHIP=y +CONFIG_SPI_FLASH_SUPPORT_MXIC_CHIP=y +CONFIG_SPI_FLASH_SUPPORT_GD_CHIP=y +CONFIG_SPI_FLASH_SUPPORT_WINBOND_CHIP=y +# end of Auto-detect flash chips + +CONFIG_SPI_FLASH_ENABLE_ENCRYPTED_READ_WRITE=y +# end of SPI Flash driver + +# +# SPIFFS Configuration +# +CONFIG_SPIFFS_MAX_PARTITIONS=3 + +# +# SPIFFS Cache Configuration +# +CONFIG_SPIFFS_CACHE=y +CONFIG_SPIFFS_CACHE_WR=y +# CONFIG_SPIFFS_CACHE_STATS is not set +# end of SPIFFS Cache Configuration + +CONFIG_SPIFFS_PAGE_CHECK=y +CONFIG_SPIFFS_GC_MAX_RUNS=10 +# CONFIG_SPIFFS_GC_STATS is not set +CONFIG_SPIFFS_PAGE_SIZE=256 +CONFIG_SPIFFS_OBJ_NAME_LEN=32 +# CONFIG_SPIFFS_FOLLOW_SYMLINKS is not set +CONFIG_SPIFFS_USE_MAGIC=y +CONFIG_SPIFFS_USE_MAGIC_LENGTH=y +CONFIG_SPIFFS_META_LENGTH=4 +CONFIG_SPIFFS_USE_MTIME=y + +# +# Debug Configuration +# +# CONFIG_SPIFFS_DBG is not set +# CONFIG_SPIFFS_API_DBG is not set +# CONFIG_SPIFFS_GC_DBG is not set +# CONFIG_SPIFFS_CACHE_DBG is not set +# CONFIG_SPIFFS_CHECK_DBG is not set +# CONFIG_SPIFFS_TEST_VISUALISATION is not set +# end of Debug Configuration +# end of SPIFFS Configuration + +# +# TCP Transport +# +CONFIG_WS_BUFFER_SIZE=1024 +# end of TCP Transport + +# +# TinyUSB +# +# end of TinyUSB + +# +# Unity unit testing library +# +CONFIG_UNITY_ENABLE_FLOAT=y +CONFIG_UNITY_ENABLE_DOUBLE=y +# CONFIG_UNITY_ENABLE_COLOR is not set +CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=y +# CONFIG_UNITY_ENABLE_FIXTURE is not set +# CONFIG_UNITY_ENABLE_BACKTRACE_ON_FAIL is not set +# end of Unity unit testing library + +# +# Virtual file system +# +CONFIG_VFS_SUPPORT_IO=y +CONFIG_VFS_SUPPORT_DIR=y +CONFIG_VFS_SUPPORT_SELECT=y +CONFIG_VFS_SUPPRESS_SELECT_DEBUG_OUTPUT=y +CONFIG_VFS_SUPPORT_TERMIOS=y + +# +# Host File System I/O (Semihosting) +# +CONFIG_VFS_SEMIHOSTFS_MAX_MOUNT_POINTS=1 +CONFIG_VFS_SEMIHOSTFS_HOST_PATH_MAX_LEN=128 +# end of Host File System I/O (Semihosting) +# end of Virtual file system + +# +# Wear Levelling +# +# CONFIG_WL_SECTOR_SIZE_512 is not set +CONFIG_WL_SECTOR_SIZE_4096=y +CONFIG_WL_SECTOR_SIZE=4096 +# end of Wear Levelling + +# +# Wi-Fi Provisioning Manager +# +CONFIG_WIFI_PROV_SCAN_MAX_ENTRIES=16 +CONFIG_WIFI_PROV_AUTOSTOP_TIMEOUT=30 +# end of Wi-Fi Provisioning Manager + +# +# Supplicant +# +CONFIG_WPA_MBEDTLS_CRYPTO=y +# CONFIG_WPA_WAPI_PSK is not set +# CONFIG_WPA_DEBUG_PRINT is not set +# CONFIG_WPA_TESTING_OPTIONS is not set +# CONFIG_WPA_WPS_WARS is not set +# CONFIG_WPA_11KV_SUPPORT is not set +# end of Supplicant +# end of Component config + +# +# Compatibility options +# +# CONFIG_LEGACY_INCLUDE_COMMON_HEADERS is not set +# end of Compatibility options + +# Deprecated options for backward compatibility +CONFIG_TOOLPREFIX="xtensa-esp32-elf-" +# CONFIG_LOG_BOOTLOADER_LEVEL_NONE is not set +# CONFIG_LOG_BOOTLOADER_LEVEL_ERROR is not set +# CONFIG_LOG_BOOTLOADER_LEVEL_WARN is not set +CONFIG_LOG_BOOTLOADER_LEVEL_INFO=y +# CONFIG_LOG_BOOTLOADER_LEVEL_DEBUG is not set +# CONFIG_LOG_BOOTLOADER_LEVEL_VERBOSE is not set +CONFIG_LOG_BOOTLOADER_LEVEL=3 +# CONFIG_APP_ROLLBACK_ENABLE is not set +# CONFIG_FLASH_ENCRYPTION_ENABLED is not set +# CONFIG_FLASHMODE_QIO is not set +# CONFIG_FLASHMODE_QOUT is not set +CONFIG_FLASHMODE_DIO=y +# CONFIG_FLASHMODE_DOUT is not set +# CONFIG_MONITOR_BAUD_9600B is not set +# CONFIG_MONITOR_BAUD_57600B is not set +CONFIG_MONITOR_BAUD_115200B=y +# CONFIG_MONITOR_BAUD_230400B is not set +# CONFIG_MONITOR_BAUD_921600B is not set +# CONFIG_MONITOR_BAUD_2MB is not set +# CONFIG_MONITOR_BAUD_OTHER is not set +CONFIG_MONITOR_BAUD_OTHER_VAL=115200 +CONFIG_MONITOR_BAUD=115200 +CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG=y +# CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE is not set +CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED=y +# CONFIG_OPTIMIZATION_ASSERTIONS_SILENT is not set +# CONFIG_OPTIMIZATION_ASSERTIONS_DISABLED is not set +# CONFIG_CXX_EXCEPTIONS is not set +CONFIG_STACK_CHECK_NONE=y +# CONFIG_STACK_CHECK_NORM is not set +# CONFIG_STACK_CHECK_STRONG is not set +# CONFIG_STACK_CHECK_ALL is not set +# CONFIG_WARN_WRITE_STRINGS is not set +# CONFIG_DISABLE_GCC8_WARNINGS is not set +# CONFIG_ESP32_APPTRACE_DEST_TRAX is not set +CONFIG_ESP32_APPTRACE_DEST_NONE=y +CONFIG_ESP32_APPTRACE_LOCK_ENABLE=y +CONFIG_BTDM_CONTROLLER_BLE_MAX_CONN_EFF=0 +CONFIG_BTDM_CONTROLLER_BR_EDR_MAX_ACL_CONN_EFF=0 +CONFIG_BTDM_CONTROLLER_BR_EDR_MAX_SYNC_CONN_EFF=0 +CONFIG_BTDM_CONTROLLER_PINNED_TO_CORE=0 +CONFIG_ADC2_DISABLE_DAC=y +# CONFIG_SPIRAM_SUPPORT is not set +CONFIG_TRACEMEM_RESERVE_DRAM=0x0 +# CONFIG_TWO_UNIVERSAL_MAC_ADDRESS is not set +CONFIG_FOUR_UNIVERSAL_MAC_ADDRESS=y +CONFIG_NUMBER_OF_UNIVERSAL_MAC_ADDRESS=4 +# CONFIG_ULP_COPROC_ENABLED is not set +CONFIG_ULP_COPROC_RESERVE_MEM=0 +CONFIG_BROWNOUT_DET=y +CONFIG_BROWNOUT_DET_LVL_SEL_0=y +# CONFIG_BROWNOUT_DET_LVL_SEL_1 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_2 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_3 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_4 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_5 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_6 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_7 is not set +CONFIG_BROWNOUT_DET_LVL=0 +CONFIG_REDUCE_PHY_TX_POWER=y +CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_RC=y +# CONFIG_ESP32_RTC_CLOCK_SOURCE_EXTERNAL_CRYSTAL is not set +# CONFIG_ESP32_RTC_CLOCK_SOURCE_EXTERNAL_OSC is not set +# CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_8MD256 is not set +# CONFIG_DISABLE_BASIC_ROM_CONSOLE is not set +# CONFIG_NO_BLOBS is not set +# CONFIG_COMPATIBLE_PRE_V2_1_BOOTLOADERS is not set +CONFIG_SYSTEM_EVENT_QUEUE_SIZE=32 +CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE=2304 +CONFIG_MAIN_TASK_STACK_SIZE=3584 +CONFIG_IPC_TASK_STACK_SIZE=1024 +CONFIG_CONSOLE_UART_DEFAULT=y +# CONFIG_CONSOLE_UART_CUSTOM is not set +# CONFIG_ESP_CONSOLE_UART_NONE is not set +CONFIG_CONSOLE_UART=y +CONFIG_CONSOLE_UART_NUM=0 +CONFIG_CONSOLE_UART_BAUDRATE=115200 +CONFIG_INT_WDT=y +CONFIG_INT_WDT_TIMEOUT_MS=300 +CONFIG_INT_WDT_CHECK_CPU1=y +CONFIG_TASK_WDT=y +# CONFIG_TASK_WDT_PANIC is not set +CONFIG_TASK_WDT_TIMEOUT_S=5 +CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU0=y +CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1=y +# CONFIG_EVENT_LOOP_PROFILING is not set +CONFIG_POST_EVENTS_FROM_ISR=y +CONFIG_POST_EVENTS_FROM_IRAM_ISR=y +# CONFIG_ESP32S2_PANIC_PRINT_HALT is not set +CONFIG_ESP32S2_PANIC_PRINT_REBOOT=y +# CONFIG_ESP32S2_PANIC_SILENT_REBOOT is not set +# CONFIG_ESP32S2_PANIC_GDBSTUB is not set +CONFIG_TIMER_TASK_STACK_SIZE=3584 +# CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH is not set +# CONFIG_ESP32_ENABLE_COREDUMP_TO_UART is not set +CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE=y +CONFIG_MB_MASTER_TIMEOUT_MS_RESPOND=150 +CONFIG_MB_MASTER_DELAY_MS_CONVERT=200 +CONFIG_MB_QUEUE_LENGTH=20 +CONFIG_MB_SERIAL_TASK_STACK_SIZE=4096 +CONFIG_MB_SERIAL_BUF_SIZE=256 +CONFIG_MB_SERIAL_TASK_PRIO=10 +CONFIG_MB_CONTROLLER_SLAVE_ID_SUPPORT=y +CONFIG_MB_CONTROLLER_SLAVE_ID=0x00112233 +CONFIG_MB_CONTROLLER_NOTIFY_TIMEOUT=20 +CONFIG_MB_CONTROLLER_NOTIFY_QUEUE_SIZE=20 +CONFIG_MB_CONTROLLER_STACK_SIZE=4096 +CONFIG_MB_EVENT_QUEUE_TIMEOUT=20 +CONFIG_MB_TIMER_PORT_ENABLED=y +CONFIG_MB_TIMER_GROUP=0 +CONFIG_MB_TIMER_INDEX=0 +# CONFIG_ENABLE_STATIC_TASK_CLEAN_UP_HOOK is not set +CONFIG_TIMER_TASK_PRIORITY=1 +CONFIG_TIMER_TASK_STACK_DEPTH=2048 +CONFIG_TIMER_QUEUE_LENGTH=10 +# CONFIG_L2_TO_L3_COPY is not set +# CONFIG_USE_ONLY_LWIP_SELECT is not set +CONFIG_ESP_GRATUITOUS_ARP=y +CONFIG_GARP_TMR_INTERVAL=60 +CONFIG_TCPIP_RECVMBOX_SIZE=32 +CONFIG_TCP_MAXRTX=12 +CONFIG_TCP_SYNMAXRTX=12 +CONFIG_TCP_MSS=1440 +CONFIG_TCP_MSL=60000 +CONFIG_TCP_SND_BUF_DEFAULT=5744 +CONFIG_TCP_WND_DEFAULT=5744 +CONFIG_TCP_RECVMBOX_SIZE=6 +CONFIG_TCP_QUEUE_OOSEQ=y +# CONFIG_ESP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES is not set +CONFIG_TCP_OVERSIZE_MSS=y +# CONFIG_TCP_OVERSIZE_QUARTER_MSS is not set +# CONFIG_TCP_OVERSIZE_DISABLE is not set +CONFIG_UDP_RECVMBOX_SIZE=6 +CONFIG_TCPIP_TASK_STACK_SIZE=3072 +CONFIG_TCPIP_TASK_AFFINITY_NO_AFFINITY=y +# CONFIG_TCPIP_TASK_AFFINITY_CPU0 is not set +# CONFIG_TCPIP_TASK_AFFINITY_CPU1 is not set +CONFIG_TCPIP_TASK_AFFINITY=0x7FFFFFFF +# CONFIG_PPP_SUPPORT is not set +CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT=5 +CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT=3072 +CONFIG_ESP32_PTHREAD_STACK_MIN=768 +CONFIG_ESP32_DEFAULT_PTHREAD_CORE_NO_AFFINITY=y +# CONFIG_ESP32_DEFAULT_PTHREAD_CORE_0 is not set +# CONFIG_ESP32_DEFAULT_PTHREAD_CORE_1 is not set +CONFIG_ESP32_PTHREAD_TASK_CORE_DEFAULT=-1 +CONFIG_ESP32_PTHREAD_TASK_NAME_DEFAULT="pthread" +CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ABORTS=y +# CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_FAILS is not set +# CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ALLOWED is not set +CONFIG_SUPPRESS_SELECT_DEBUG_OUTPUT=y +CONFIG_SUPPORT_TERMIOS=y +CONFIG_SEMIHOSTFS_MAX_MOUNT_POINTS=1 +CONFIG_SEMIHOSTFS_HOST_PATH_MAX_LEN=128 +# End of deprecated options diff --git a/src/sdkconfig.defaults b/src/sdkconfig.defaults deleted file mode 100644 index 9125e67..0000000 --- a/src/sdkconfig.defaults +++ /dev/null @@ -1,11 +0,0 @@ -# Override some defaults so BT stack is enabled and -CONFIG_BT_ENABLED=y -CONFIG_BTDM_CTRL_MODE_BLE_ONLY=y -CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY=n -CONFIG_BTDM_CTRL_MODE_BTDM=n -CONFIG_BT_NIMBLE_ENABLED=y - -## For Bluedroid as binary is larger than default size -CONFIG_PARTITION_TABLE_CUSTOM=y -CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" -CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" diff --git a/src/wifi_prov_mgr_test.py b/src/wifi_prov_mgr_test.py deleted file mode 100644 index a516fbe..0000000 --- a/src/wifi_prov_mgr_test.py +++ /dev/null @@ -1,100 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2018 Espressif Systems (Shanghai) PTE LTD -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from __future__ import print_function - -import os -import re - -import esp_prov -import ttfw_idf - -# Have esp_prov throw exception -esp_prov.config_throw_except = True - - -@ttfw_idf.idf_example_test(env_tag='Example_WIFI_BT') -def test_examples_wifi_prov_mgr(env, extra_data): - # Acquire DUT - dut1 = env.get_dut('wifi_prov_mgr', 'examples/provisioning/wifi_prov_mgr', dut_class=ttfw_idf.ESP32DUT) - - # Get binary file - binary_file = os.path.join(dut1.app.binary_path, 'wifi_prov_mgr.bin') - bin_size = os.path.getsize(binary_file) - ttfw_idf.log_performance('wifi_prov_mgr_bin_size', '{}KB'.format(bin_size // 1024)) - - # Upload binary and start testing - dut1.start_app() - - # Check if BT memory is released before provisioning starts - dut1.expect('wifi_prov_scheme_ble: BT memory released', timeout=60) - - # Parse BLE devname - devname = dut1.expect(re.compile(r'Provisioning started with service name : (PROV_\S\S\S\S\S\S)'), timeout=30)[0] - print('BLE Device Alias for DUT :', devname) - - print('Starting Provisioning') - verbose = False - protover = 'v1.1' - secver = 1 - pop = 'abcd1234' - provmode = 'ble' - ap_ssid = 'myssid' - ap_password = 'mypassword' - - print('Getting security') - security = esp_prov.get_security(secver, pop, verbose) - if security is None: - raise RuntimeError('Failed to get security') - - print('Getting transport') - transport = esp_prov.get_transport(provmode, devname) - if transport is None: - raise RuntimeError('Failed to get transport') - - print('Verifying protocol version') - if not esp_prov.version_match(transport, protover): - raise RuntimeError('Mismatch in protocol version') - - print('Verifying scan list capability') - if not esp_prov.has_capability(transport, 'wifi_scan'): - raise RuntimeError('Capability not present') - - print('Starting Session') - if not esp_prov.establish_session(transport, security): - raise RuntimeError('Failed to start session') - - print('Sending Custom Data') - if not esp_prov.custom_data(transport, security, 'My Custom Data'): - raise RuntimeError('Failed to send custom data') - - print('Sending Wifi credential to DUT') - if not esp_prov.send_wifi_config(transport, security, ap_ssid, ap_password): - raise RuntimeError('Failed to send Wi-Fi config') - - print('Applying config') - if not esp_prov.apply_wifi_config(transport, security): - raise RuntimeError('Failed to send apply config') - - if not esp_prov.wait_wifi_connected(transport, security): - raise RuntimeError('Provisioning failed') - - # Check if BTDM memory is released after provisioning finishes - dut1.expect('wifi_prov_scheme_ble: BTDM memory released', timeout=30) - - -if __name__ == '__main__': - test_examples_wifi_prov_mgr()