mirror of
https://github.com/espressif/esp-idf.git
synced 2025-10-03 18:40:59 +02:00
Merge branch 'component/remove_wifi_prov' into 'master'
change(wifi_prov): Remove wifi_provisioning component and esp_prov tool See merge request espressif/esp-idf!41866
This commit is contained in:
@@ -162,7 +162,6 @@
|
||||
/components/usb/ @esp-idf-codeowners/peripherals/usb
|
||||
/components/vfs/ @esp-idf-codeowners/storage
|
||||
/components/wear_levelling/ @esp-idf-codeowners/storage
|
||||
/components/wifi_provisioning/ @esp-idf-codeowners/app-utilities/provisioning
|
||||
/components/wpa_supplicant/ @esp-idf-codeowners/wifi @esp-idf-codeowners/app-utilities/mbedtls
|
||||
/components/xtensa/ @esp-idf-codeowners/system
|
||||
|
||||
@@ -204,7 +203,6 @@
|
||||
/examples/peripherals/usb/ @esp-idf-codeowners/peripherals @esp-idf-codeowners/peripherals/usb
|
||||
/examples/phy/ @esp-idf-codeowners/bluetooth @esp-idf-codeowners/wifi @esp-idf-codeowners/ieee802154
|
||||
/examples/protocols/ @esp-idf-codeowners/network @esp-idf-codeowners/app-utilities
|
||||
/examples/provisioning/ @esp-idf-codeowners/app-utilities/provisioning
|
||||
/examples/security/ @esp-idf-codeowners/security
|
||||
/examples/storage/ @esp-idf-codeowners/storage
|
||||
/examples/system/ @esp-idf-codeowners/system
|
||||
@@ -219,7 +217,6 @@
|
||||
/tools/cmake/ @esp-idf-codeowners/build-config
|
||||
/tools/cmake/toolchain-*.cmake @esp-idf-codeowners/toolchain
|
||||
/tools/esp_app_trace/ @esp-idf-codeowners/debugging
|
||||
/tools/esp_prov/ @esp-idf-codeowners/app-utilities
|
||||
/tools/gdb_panic_server.py @esp-idf-codeowners/debugging
|
||||
/tools/kconfig*/ @esp-idf-codeowners/build-config
|
||||
/tools/ldgen/ @esp-idf-codeowners/build-config
|
||||
|
@@ -18,7 +18,7 @@ extern "C" {
|
||||
*
|
||||
* More information on protocol can be found: https://datatracker.ietf.org/doc/html/rfc5054
|
||||
*
|
||||
* This implementation is used by security2 of wifi_provisioning and local control features.
|
||||
* This implementation is used by security2 of network_provisioning and local control features.
|
||||
* Details on how these protocols use this feature can be found here: https://docs.espressif.com/projects/esp-idf/en/latest/esp32c3/api-reference/provisioning/provisioning.html#security-2-scheme
|
||||
*
|
||||
* Below is the example usage of the srp6a protocol in protocomm component,
|
||||
|
@@ -1,42 +0,0 @@
|
||||
idf_build_get_property(target IDF_TARGET)
|
||||
|
||||
if(${target} STREQUAL "linux")
|
||||
return() # This component is not supported by the POSIX/Linux simulator
|
||||
endif()
|
||||
|
||||
if( NOT CONFIG_ESP_WIFI_ENABLED
|
||||
AND NOT CONFIG_ESP_HOST_WIFI_ENABLED
|
||||
AND NOT CMAKE_BUILD_EARLY_EXPANSION )
|
||||
# This component provides only "esp_provisioning" headers if WiFi not enabled
|
||||
# (implementation supported optionally in a managed component esp_wifi_remote)
|
||||
idf_component_register(INCLUDE_DIRS include)
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(srcs "src/wifi_config.c"
|
||||
"src/wifi_scan.c"
|
||||
"src/wifi_ctrl.c"
|
||||
"src/manager.c"
|
||||
"src/handlers.c"
|
||||
"src/scheme_console.c"
|
||||
"proto-c/wifi_config.pb-c.c"
|
||||
"proto-c/wifi_scan.pb-c.c"
|
||||
"proto-c/wifi_ctrl.pb-c.c"
|
||||
"proto-c/wifi_constants.pb-c.c")
|
||||
|
||||
if(CONFIG_ESP_WIFI_SOFTAP_SUPPORT)
|
||||
list(APPEND srcs "src/scheme_softap.c")
|
||||
endif()
|
||||
|
||||
if(CONFIG_BT_ENABLED)
|
||||
if(CONFIG_BT_BLUEDROID_ENABLED OR CONFIG_BT_NIMBLE_ENABLED)
|
||||
list(APPEND srcs
|
||||
"src/scheme_ble.c")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
idf_component_register(SRCS "${srcs}"
|
||||
INCLUDE_DIRS include
|
||||
PRIV_INCLUDE_DIRS src proto-c
|
||||
REQUIRES lwip protocomm
|
||||
PRIV_REQUIRES protobuf-c bt json esp_timer esp_wifi)
|
@@ -1,70 +0,0 @@
|
||||
menu "Wi-Fi Provisioning Manager"
|
||||
visible if (SOC_WIFI_SUPPORTED || SOC_WIRELESS_HOST_SUPPORTED)
|
||||
config WIFI_PROV_SCAN_MAX_ENTRIES
|
||||
int "Max Wi-Fi Scan Result Entries"
|
||||
default 16
|
||||
range 1 255
|
||||
help
|
||||
This sets the maximum number of entries of Wi-Fi scan results that will be kept by the provisioning manager
|
||||
|
||||
config WIFI_PROV_AUTOSTOP_TIMEOUT
|
||||
int "Provisioning auto-stop timeout"
|
||||
default 30
|
||||
range 5 600
|
||||
help
|
||||
Time (in seconds) after which the Wi-Fi provisioning manager will auto-stop after connecting to
|
||||
a Wi-Fi network successfully.
|
||||
|
||||
config WIFI_PROV_BLE_BONDING
|
||||
bool
|
||||
prompt "Enable BLE bonding"
|
||||
depends on BT_ENABLED
|
||||
help
|
||||
This option is applicable only when provisioning transport is BLE.
|
||||
|
||||
config WIFI_PROV_BLE_SEC_CONN
|
||||
bool
|
||||
prompt "Enable BLE Secure connection flag"
|
||||
depends on BT_NIMBLE_ENABLED
|
||||
default y
|
||||
help
|
||||
Used to enable Secure connection support when provisioning transport is BLE.
|
||||
|
||||
config WIFI_PROV_BLE_FORCE_ENCRYPTION
|
||||
bool
|
||||
prompt "Force Link Encryption during characteristic Read / Write"
|
||||
depends on BT_ENABLED
|
||||
help
|
||||
Used to enforce link encryption when attempting to read / write characteristic
|
||||
|
||||
config WIFI_PROV_BLE_NOTIFY
|
||||
bool
|
||||
prompt "Add support for Notification for provisioning BLE descriptors"
|
||||
depends on BT_ENABLED
|
||||
help
|
||||
Used to enable support Notification in BLE descriptors of prov* characteristics
|
||||
|
||||
config WIFI_PROV_KEEP_BLE_ON_AFTER_PROV
|
||||
bool "Keep BT on after provisioning is done"
|
||||
depends on BT_ENABLED
|
||||
select ESP_PROTOCOMM_KEEP_BLE_ON_AFTER_BLE_STOP
|
||||
|
||||
config WIFI_PROV_DISCONNECT_AFTER_PROV
|
||||
bool "Terminate connection after provisioning is done"
|
||||
depends on WIFI_PROV_KEEP_BLE_ON_AFTER_PROV
|
||||
default y
|
||||
select ESP_PROTOCOMM_DISCONNECT_AFTER_BLE_STOP
|
||||
|
||||
choice WIFI_PROV_STA_SCAN_METHOD
|
||||
bool "Wifi Provisioning Scan Method"
|
||||
default WIFI_PROV_STA_ALL_CHANNEL_SCAN
|
||||
config WIFI_PROV_STA_ALL_CHANNEL_SCAN
|
||||
bool "All Channel Scan"
|
||||
help
|
||||
Scan will end after scanning the entire channel. This option is useful in Mesh WiFi Systems.
|
||||
config WIFI_PROV_STA_FAST_SCAN
|
||||
bool "Fast Scan"
|
||||
help
|
||||
Scan will end after an AP matching with the SSID has been detected.
|
||||
endchoice
|
||||
endmenu
|
@@ -1,639 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <protocomm.h>
|
||||
|
||||
#include "esp_event.h"
|
||||
#include "esp_wifi_types.h"
|
||||
#include "wifi_provisioning/wifi_config.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
ESP_EVENT_DECLARE_BASE(WIFI_PROV_EVENT);
|
||||
|
||||
/**
|
||||
* @brief Events generated by manager
|
||||
*
|
||||
* These events are generated in order of declaration and, for the
|
||||
* stretch of time between initialization and de-initialization of
|
||||
* the manager, each event is signaled only once
|
||||
*/
|
||||
typedef enum {
|
||||
/**
|
||||
* Emitted when the manager is initialized
|
||||
*/
|
||||
WIFI_PROV_INIT,
|
||||
|
||||
/**
|
||||
* Indicates that provisioning has started
|
||||
*/
|
||||
WIFI_PROV_START,
|
||||
|
||||
/**
|
||||
* Emitted before accepting the wifi credentials to
|
||||
* set the wifi configurations according to requirement.
|
||||
* NOTE - In this case event_data shall be populated with a pointer to `wifi_config_t`.
|
||||
*/
|
||||
WIFI_PROV_SET_STA_CONFIG,
|
||||
|
||||
/**
|
||||
* Emitted when Wi-Fi AP credentials are received via `protocomm`
|
||||
* endpoint `wifi_config`. The event data in this case is a pointer
|
||||
* to the corresponding `wifi_sta_config_t` structure
|
||||
*/
|
||||
WIFI_PROV_CRED_RECV,
|
||||
|
||||
/**
|
||||
* Emitted when device fails to connect to the AP of which the
|
||||
* credentials were received earlier on event `WIFI_PROV_CRED_RECV`.
|
||||
* The event data in this case is a pointer to the disconnection
|
||||
* reason code with type `wifi_prov_sta_fail_reason_t`
|
||||
*/
|
||||
WIFI_PROV_CRED_FAIL,
|
||||
|
||||
/**
|
||||
* Emitted when device successfully connects to the AP of which the
|
||||
* credentials were received earlier on event `WIFI_PROV_CRED_RECV`
|
||||
*/
|
||||
WIFI_PROV_CRED_SUCCESS,
|
||||
|
||||
/**
|
||||
* Signals that provisioning service has stopped
|
||||
*/
|
||||
WIFI_PROV_END,
|
||||
|
||||
/**
|
||||
* Signals that manager has been de-initialized
|
||||
*/
|
||||
WIFI_PROV_DEINIT,
|
||||
} wifi_prov_cb_event_t;
|
||||
|
||||
typedef void (*wifi_prov_cb_func_t)(void *user_data, wifi_prov_cb_event_t event, void *event_data);
|
||||
|
||||
/**
|
||||
* @brief Event handler that is used by the manager while
|
||||
* provisioning service is active
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* Callback function to be executed on provisioning events
|
||||
*/
|
||||
wifi_prov_cb_func_t event_cb;
|
||||
|
||||
/**
|
||||
* User context data to pass as parameter to callback function
|
||||
*/
|
||||
void *user_data;
|
||||
} wifi_prov_event_handler_t;
|
||||
|
||||
/**
|
||||
* @brief Event handler can be set to none if not used
|
||||
*/
|
||||
#define WIFI_PROV_EVENT_HANDLER_NONE { \
|
||||
.event_cb = NULL, \
|
||||
.user_data = NULL \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Structure holding the configuration related to Wi-Fi provisioning
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* Maximum number of allowed connection attempts for Wi-Fi. If value 0
|
||||
* same as legacy behavior of infinite connection attempts.
|
||||
*/
|
||||
uint32_t wifi_conn_attempts;
|
||||
} wifi_prov_conn_cfg_t;
|
||||
|
||||
/**
|
||||
* @brief Structure for specifying the provisioning scheme to be
|
||||
* followed by the manager
|
||||
*
|
||||
* @note Ready to use schemes are available:
|
||||
* - wifi_prov_scheme_ble : for provisioning over BLE transport + GATT server
|
||||
* - wifi_prov_scheme_softap : for provisioning over SoftAP transport + HTTP server
|
||||
* - wifi_prov_scheme_console : for provisioning over Serial UART transport + Console (for debugging)
|
||||
*/
|
||||
typedef struct wifi_prov_scheme {
|
||||
/**
|
||||
* Function which is to be called by the manager when it is to
|
||||
* start the provisioning service associated with a protocomm instance
|
||||
* and a scheme specific configuration
|
||||
*/
|
||||
esp_err_t (*prov_start) (protocomm_t *pc, void *config);
|
||||
|
||||
/**
|
||||
* Function which is to be called by the manager to stop the
|
||||
* provisioning service previously associated with a protocomm instance
|
||||
*/
|
||||
esp_err_t (*prov_stop) (protocomm_t *pc);
|
||||
|
||||
/**
|
||||
* Function which is to be called by the manager to generate
|
||||
* a new configuration for the provisioning service, that is
|
||||
* to be passed to prov_start()
|
||||
*/
|
||||
void *(*new_config) (void);
|
||||
|
||||
/**
|
||||
* Function which is to be called by the manager to delete a
|
||||
* configuration generated using new_config()
|
||||
*/
|
||||
void (*delete_config) (void *config);
|
||||
|
||||
/**
|
||||
* Function which is to be called by the manager to set the
|
||||
* service name and key values in the configuration structure
|
||||
*/
|
||||
esp_err_t (*set_config_service) (void *config, const char *service_name, const char *service_key);
|
||||
|
||||
/**
|
||||
* Function which is to be called by the manager to set a protocomm endpoint
|
||||
* with an identifying name and UUID in the configuration structure
|
||||
*/
|
||||
esp_err_t (*set_config_endpoint) (void *config, const char *endpoint_name, uint16_t uuid);
|
||||
|
||||
/**
|
||||
* Sets mode of operation of Wi-Fi during provisioning
|
||||
* This is set to :
|
||||
* - WIFI_MODE_APSTA for SoftAP transport
|
||||
* - WIFI_MODE_STA for BLE transport
|
||||
*/
|
||||
wifi_mode_t wifi_mode;
|
||||
} wifi_prov_scheme_t;
|
||||
|
||||
/**
|
||||
* @brief Structure for specifying the manager configuration
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* Provisioning scheme to use. Following schemes are already available:
|
||||
* - wifi_prov_scheme_ble : for provisioning over BLE transport + GATT server
|
||||
* - wifi_prov_scheme_softap : for provisioning over SoftAP transport + HTTP server + mDNS (optional)
|
||||
* - wifi_prov_scheme_console : for provisioning over Serial UART transport + Console (for debugging)
|
||||
*/
|
||||
wifi_prov_scheme_t scheme;
|
||||
|
||||
/**
|
||||
* Event handler required by the scheme for incorporating scheme specific
|
||||
* behavior while provisioning manager is running. Various options may be
|
||||
* provided by the scheme for setting this field. Use WIFI_PROV_EVENT_HANDLER_NONE
|
||||
* when not used. When using scheme wifi_prov_scheme_ble, the following
|
||||
* options are available:
|
||||
* - WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BTDM
|
||||
* - WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BLE
|
||||
* - WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BT
|
||||
*/
|
||||
wifi_prov_event_handler_t scheme_event_handler;
|
||||
|
||||
/**
|
||||
* Event handler that can be set for the purpose of incorporating application
|
||||
* specific behavior. Use WIFI_PROV_EVENT_HANDLER_NONE when not used.
|
||||
*/
|
||||
wifi_prov_event_handler_t app_event_handler;
|
||||
|
||||
/**
|
||||
* This config holds the Wi-Fi provisioning related configurations.
|
||||
*/
|
||||
wifi_prov_conn_cfg_t wifi_prov_conn_cfg;
|
||||
} wifi_prov_mgr_config_t;
|
||||
|
||||
/**
|
||||
* @brief Security modes supported by the Provisioning Manager.
|
||||
*
|
||||
* These are same as the security modes provided by protocomm
|
||||
*/
|
||||
typedef enum wifi_prov_security {
|
||||
#ifdef CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_0
|
||||
/**
|
||||
* No security (plain-text communication)
|
||||
*/
|
||||
WIFI_PROV_SECURITY_0 = 0,
|
||||
#endif
|
||||
#ifdef CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_1
|
||||
/**
|
||||
* This secure communication mode consists of
|
||||
* X25519 key exchange
|
||||
* + proof of possession (pop) based authentication
|
||||
* + AES-CTR encryption
|
||||
*/
|
||||
WIFI_PROV_SECURITY_1 = 1,
|
||||
#endif
|
||||
#ifdef CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_2
|
||||
/**
|
||||
* This secure communication mode consists of
|
||||
* SRP6a based authentication and key exchange
|
||||
* + AES-GCM encryption/decryption
|
||||
*/
|
||||
WIFI_PROV_SECURITY_2 = 2
|
||||
#endif
|
||||
#if !CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_0 && !CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_1 && !CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_2
|
||||
#error "All of the protocomm security versions are disabled. Make sure to enable at least one security version."
|
||||
#endif
|
||||
} wifi_prov_security_t;
|
||||
|
||||
/**
|
||||
* @brief Security 1 params structure
|
||||
* This needs to be passed when using WIFI_PROV_SECURITY_1
|
||||
*/
|
||||
typedef const char wifi_prov_security1_params_t;
|
||||
|
||||
/**
|
||||
* @brief Security 2 params structure
|
||||
* This needs to be passed when using WIFI_PROV_SECURITY_2
|
||||
*/
|
||||
typedef protocomm_security2_params_t wifi_prov_security2_params_t;
|
||||
|
||||
/**
|
||||
* @brief Initialize provisioning manager instance
|
||||
*
|
||||
* Configures the manager and allocates internal resources
|
||||
*
|
||||
* Configuration specifies the provisioning scheme (transport)
|
||||
* and event handlers
|
||||
*
|
||||
* Event WIFI_PROV_INIT is emitted right after initialization
|
||||
* is complete
|
||||
*
|
||||
* @param[in] config Configuration structure
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Success
|
||||
* - ESP_FAIL : Fail
|
||||
*/
|
||||
esp_err_t wifi_prov_mgr_init(wifi_prov_mgr_config_t config);
|
||||
|
||||
/**
|
||||
* @brief Stop provisioning (if running) and release
|
||||
* resource used by the manager
|
||||
*
|
||||
* Event WIFI_PROV_DEINIT is emitted right after de-initialization
|
||||
* is finished
|
||||
*
|
||||
* If provisioning service is still active when this API is called,
|
||||
* it first stops the service, hence emitting WIFI_PROV_END, and
|
||||
* then performs the de-initialization
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Success
|
||||
* - ESP_FAIL : Failed to post event WIFI_PROV_DEINIT or WIFI_PROV_END
|
||||
* - ESP_ERR_NO_MEM : Out of memory (as may be returned by esp_event_post)
|
||||
*/
|
||||
esp_err_t wifi_prov_mgr_deinit(void);
|
||||
|
||||
/**
|
||||
* @brief Checks if device is provisioned
|
||||
*
|
||||
* This checks if Wi-Fi credentials are present on the NVS
|
||||
*
|
||||
* The Wi-Fi credentials are assumed to be kept in the same
|
||||
* NVS namespace as used by esp_wifi component
|
||||
*
|
||||
* If one were to call esp_wifi_set_config() directly instead
|
||||
* of going through the provisioning process, this function will
|
||||
* still yield true (i.e. device will be found to be provisioned)
|
||||
*
|
||||
* @note Calling wifi_prov_mgr_start_provisioning() automatically
|
||||
* resets the provision state, irrespective of what the
|
||||
* state was prior to making the call.
|
||||
*
|
||||
* @param[out] provisioned True if provisioned, else false
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Retrieved provision state successfully
|
||||
* - ESP_FAIL : Wi-Fi not initialized
|
||||
* - ESP_ERR_INVALID_ARG : Null argument supplied
|
||||
*/
|
||||
esp_err_t wifi_prov_mgr_is_provisioned(bool *provisioned);
|
||||
|
||||
/**
|
||||
* @brief Checks whether the provisioning state machine is idle
|
||||
*
|
||||
* @return True if state machine is idle, else false
|
||||
*/
|
||||
bool wifi_prov_mgr_is_sm_idle(void);
|
||||
|
||||
/**
|
||||
* @brief Start provisioning service
|
||||
*
|
||||
* This starts the provisioning service according to the scheme
|
||||
* configured at the time of initialization. For scheme :
|
||||
* - wifi_prov_scheme_ble : This starts protocomm_ble, which internally initializes
|
||||
* BLE transport and starts GATT server for handling
|
||||
* provisioning requests
|
||||
* - wifi_prov_scheme_softap : This activates SoftAP mode of Wi-Fi and starts
|
||||
* protocomm_httpd, which internally starts an HTTP
|
||||
* server for handling provisioning requests (If mDNS is
|
||||
* active it also starts advertising service with type
|
||||
* _esp_wifi_prov._tcp)
|
||||
*
|
||||
* Event WIFI_PROV_START is emitted right after provisioning starts without failure
|
||||
*
|
||||
* @note This API will start provisioning service even if device is found to be
|
||||
* already provisioned, i.e. wifi_prov_mgr_is_provisioned() yields true
|
||||
*
|
||||
* @param[in] security Specify which protocomm security scheme to use :
|
||||
* - WIFI_PROV_SECURITY_0 : For no security
|
||||
* - WIFI_PROV_SECURITY_1 : x25519 secure handshake for session
|
||||
* establishment followed by AES-CTR encryption of provisioning messages
|
||||
* - WIFI_PROV_SECURITY_2: SRP6a based authentication and key exchange
|
||||
* followed by AES-GCM encryption/decryption of provisioning messages
|
||||
* @param[in] wifi_prov_sec_params
|
||||
* Pointer to security params (NULL if not needed).
|
||||
* This is not needed for protocomm security 0
|
||||
* This pointer should hold the struct of type
|
||||
* wifi_prov_security1_params_t for protocomm security 1
|
||||
* and wifi_prov_security2_params_t for protocomm security 2 respectively.
|
||||
* This pointer and its contents should be valid till the provisioning service is
|
||||
* running and has not been stopped or de-inited.
|
||||
* @param[in] service_name Unique name of the service. This translates to:
|
||||
* - Wi-Fi SSID when provisioning mode is softAP
|
||||
* - Device name when provisioning mode is BLE
|
||||
* @param[in] service_key Key required by client to access the service (NULL if not needed).
|
||||
* This translates to:
|
||||
* - Wi-Fi password when provisioning mode is softAP
|
||||
* - ignored when provisioning mode is BLE
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Provisioning started successfully
|
||||
* - ESP_FAIL : Failed to start provisioning service
|
||||
* - ESP_ERR_INVALID_STATE : Provisioning manager not initialized or already started
|
||||
*/
|
||||
esp_err_t wifi_prov_mgr_start_provisioning(wifi_prov_security_t security, const void *wifi_prov_sec_params, const char *service_name, const char *service_key);
|
||||
|
||||
/**
|
||||
* @brief Stop provisioning service
|
||||
*
|
||||
* If provisioning service is active, this API will initiate a process to stop
|
||||
* the service and return. Once the service actually stops, the event WIFI_PROV_END
|
||||
* will be emitted.
|
||||
*
|
||||
* If wifi_prov_mgr_deinit() is called without calling this API first, it will
|
||||
* automatically stop the provisioning service and emit the WIFI_PROV_END, followed
|
||||
* by WIFI_PROV_DEINIT, before returning.
|
||||
*
|
||||
* This API will generally be used along with wifi_prov_mgr_disable_auto_stop()
|
||||
* in the scenario when the main application has registered its own endpoints,
|
||||
* and wishes that the provisioning service is stopped only when some protocomm
|
||||
* command from the client side application is received.
|
||||
*
|
||||
* Calling this API inside an endpoint handler, with sufficient cleanup_delay,
|
||||
* will allow the response / acknowledgment to be sent successfully before the
|
||||
* underlying protocomm service is stopped.
|
||||
*
|
||||
* Cleaup_delay is set when calling wifi_prov_mgr_disable_auto_stop().
|
||||
* If not specified, it defaults to 1000ms.
|
||||
*
|
||||
* For straightforward cases, using this API is usually not necessary as
|
||||
* provisioning is stopped automatically once WIFI_PROV_CRED_SUCCESS is emitted.
|
||||
* Stopping is delayed (maximum 30 seconds) thus allowing the client side
|
||||
* application to query for Wi-Fi state, i.e. after receiving the first query
|
||||
* and sending `Wi-Fi state connected` response the service is stopped immediately.
|
||||
*/
|
||||
void wifi_prov_mgr_stop_provisioning(void);
|
||||
|
||||
/**
|
||||
* @brief Wait for provisioning service to finish
|
||||
*
|
||||
* Calling this API will block until provisioning service is stopped
|
||||
* i.e. till event WIFI_PROV_END is emitted.
|
||||
*
|
||||
* This will not block if provisioning is not started or not initialized.
|
||||
*/
|
||||
void wifi_prov_mgr_wait(void);
|
||||
|
||||
/**
|
||||
* @brief Disable auto stopping of provisioning service upon completion
|
||||
*
|
||||
* By default, once provisioning is complete, the provisioning service is automatically
|
||||
* stopped, and all endpoints (along with those registered by main application) are
|
||||
* deactivated.
|
||||
*
|
||||
* This API is useful in the case when main application wishes to close provisioning service
|
||||
* only after it receives some protocomm command from the client side app. For example, after
|
||||
* connecting to Wi-Fi, the device may want to connect to the cloud, and only once that is
|
||||
* successfully, the device is said to be fully configured. But, then it is upto the main
|
||||
* application to explicitly call wifi_prov_mgr_stop_provisioning() later when the device is
|
||||
* fully configured and the provisioning service is no longer required.
|
||||
*
|
||||
* @note This must be called before executing wifi_prov_mgr_start_provisioning()
|
||||
*
|
||||
* @param[in] cleanup_delay Sets the delay after which the actual cleanup of transport related
|
||||
* resources is done after a call to wifi_prov_mgr_stop_provisioning()
|
||||
* returns. Minimum allowed value is 100ms. If not specified, this will
|
||||
* default to 1000ms.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Success
|
||||
* - ESP_ERR_INVALID_STATE : Manager not initialized or
|
||||
* provisioning service already started
|
||||
*/
|
||||
esp_err_t wifi_prov_mgr_disable_auto_stop(uint32_t cleanup_delay);
|
||||
|
||||
/**
|
||||
* @brief Set application version and capabilities in the JSON data returned by
|
||||
* proto-ver endpoint
|
||||
*
|
||||
* This function can be called multiple times, to specify information about the various
|
||||
* application specific services running on the device, identified by unique labels.
|
||||
*
|
||||
* The provisioning service itself registers an entry in the JSON data, by the label "prov",
|
||||
* containing only provisioning service version and capabilities. Application services should
|
||||
* use a label other than "prov" so as not to overwrite this.
|
||||
*
|
||||
* @note This must be called before executing wifi_prov_mgr_start_provisioning()
|
||||
*
|
||||
* @param[in] label String indicating the application name.
|
||||
*
|
||||
* @param[in] version String indicating the application version.
|
||||
* There is no constraint on format.
|
||||
*
|
||||
* @param[in] capabilities Array of strings with capabilities.
|
||||
* These could be used by the client side app to know
|
||||
* the application registered endpoint capabilities
|
||||
*
|
||||
* @param[in] total_capabilities Size of capabilities array
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Success
|
||||
* - ESP_ERR_INVALID_STATE : Manager not initialized or
|
||||
* provisioning service already started
|
||||
* - ESP_ERR_NO_MEM : Failed to allocate memory for version string
|
||||
* - ESP_ERR_INVALID_ARG : Null argument
|
||||
*/
|
||||
esp_err_t wifi_prov_mgr_set_app_info(const char *label, const char *version,
|
||||
const char**capabilities, size_t total_capabilities);
|
||||
|
||||
/**
|
||||
* @brief Create an additional endpoint and allocate internal resources for it
|
||||
*
|
||||
* This API is to be called by the application if it wants to create an additional
|
||||
* endpoint. All additional endpoints will be assigned UUIDs starting from 0xFF54
|
||||
* and so on in the order of execution.
|
||||
*
|
||||
* protocomm handler for the created endpoint is to be registered later using
|
||||
* wifi_prov_mgr_endpoint_register() after provisioning has started.
|
||||
*
|
||||
* @note This API can only be called BEFORE provisioning is started
|
||||
*
|
||||
* @note Additional endpoints can be used for configuring client provided
|
||||
* parameters other than Wi-Fi credentials, that are necessary for the
|
||||
* main application and hence must be set prior to starting the application
|
||||
*
|
||||
* @note After session establishment, the additional endpoints must be targeted
|
||||
* first by the client side application before sending Wi-Fi configuration,
|
||||
* because once Wi-Fi configuration finishes the provisioning service is
|
||||
* stopped and hence all endpoints are unregistered
|
||||
*
|
||||
* @param[in] ep_name unique name of the endpoint
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Success
|
||||
* - ESP_FAIL : Failure
|
||||
*/
|
||||
esp_err_t wifi_prov_mgr_endpoint_create(const char *ep_name);
|
||||
|
||||
/**
|
||||
* @brief Register a handler for the previously created endpoint
|
||||
*
|
||||
* This API can be called by the application to register a protocomm handler
|
||||
* to any endpoint that was created using wifi_prov_mgr_endpoint_create().
|
||||
*
|
||||
* @note This API can only be called AFTER provisioning has started
|
||||
*
|
||||
* @note Additional endpoints can be used for configuring client provided
|
||||
* parameters other than Wi-Fi credentials, that are necessary for the
|
||||
* main application and hence must be set prior to starting the application
|
||||
*
|
||||
* @note After session establishment, the additional endpoints must be targeted
|
||||
* first by the client side application before sending Wi-Fi configuration,
|
||||
* because once Wi-Fi configuration finishes the provisioning service is
|
||||
* stopped and hence all endpoints are unregistered
|
||||
*
|
||||
* @param[in] ep_name Name of the endpoint
|
||||
* @param[in] handler Endpoint handler function
|
||||
* @param[in] user_ctx User data
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Success
|
||||
* - ESP_FAIL : Failure
|
||||
*/
|
||||
esp_err_t wifi_prov_mgr_endpoint_register(const char *ep_name,
|
||||
protocomm_req_handler_t handler,
|
||||
void *user_ctx);
|
||||
|
||||
/**
|
||||
* @brief Unregister the handler for an endpoint
|
||||
*
|
||||
* This API can be called if the application wants to selectively
|
||||
* unregister the handler of an endpoint while the provisioning
|
||||
* is still in progress.
|
||||
*
|
||||
* All the endpoint handlers are unregistered automatically when
|
||||
* the provisioning stops.
|
||||
*
|
||||
* @param[in] ep_name Name of the endpoint
|
||||
*/
|
||||
void wifi_prov_mgr_endpoint_unregister(const char *ep_name);
|
||||
|
||||
/**
|
||||
* @brief Get state of Wi-Fi Station during provisioning
|
||||
*
|
||||
* @param[out] state Pointer to wifi_prov_sta_state_t
|
||||
* variable to be filled
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Successfully retrieved Wi-Fi state
|
||||
* - ESP_FAIL : Provisioning app not running
|
||||
*/
|
||||
esp_err_t wifi_prov_mgr_get_wifi_state(wifi_prov_sta_state_t *state);
|
||||
|
||||
/**
|
||||
* @brief Get reason code in case of Wi-Fi station
|
||||
* disconnection during provisioning
|
||||
*
|
||||
* @param[out] reason Pointer to wifi_prov_sta_fail_reason_t
|
||||
* variable to be filled
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Successfully retrieved Wi-Fi disconnect reason
|
||||
* - ESP_FAIL : Provisioning app not running
|
||||
*/
|
||||
esp_err_t wifi_prov_mgr_get_wifi_disconnect_reason(wifi_prov_sta_fail_reason_t *reason);
|
||||
|
||||
/**
|
||||
* @brief Runs Wi-Fi as Station with the supplied configuration
|
||||
*
|
||||
* Configures the Wi-Fi station mode to connect to the AP with
|
||||
* SSID and password specified in config structure and sets
|
||||
* Wi-Fi to run as station.
|
||||
*
|
||||
* This is automatically called by provisioning service upon
|
||||
* receiving new credentials.
|
||||
*
|
||||
* If credentials are to be supplied to the manager via a
|
||||
* different mode other than through protocomm, then this
|
||||
* API needs to be called.
|
||||
*
|
||||
* Event WIFI_PROV_CRED_RECV is emitted after credentials have
|
||||
* been applied and Wi-Fi station started
|
||||
*
|
||||
* @param[in] wifi_cfg Pointer to Wi-Fi configuration structure
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Wi-Fi configured and started successfully
|
||||
* - ESP_FAIL : Failed to set configuration
|
||||
*/
|
||||
esp_err_t wifi_prov_mgr_configure_sta(wifi_config_t *wifi_cfg);
|
||||
|
||||
/**
|
||||
* @brief Reset Wi-Fi provisioning config
|
||||
*
|
||||
* Calling this API will restore WiFi stack persistent settings to default values.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Reset provisioning config successfully
|
||||
* - ESP_FAIL : Failed to reset provisioning config
|
||||
*/
|
||||
esp_err_t wifi_prov_mgr_reset_provisioning(void);
|
||||
|
||||
/**
|
||||
* @brief Reset internal state machine and clear provisioned credentials.
|
||||
*
|
||||
* This API should be used to restart provisioning ONLY in the case
|
||||
* of provisioning failures without rebooting the device.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Reset provisioning state machine successfully
|
||||
* - ESP_FAIL : Failed to reset provisioning state machine
|
||||
* - ESP_ERR_INVALID_STATE : Manager not initialized
|
||||
*/
|
||||
esp_err_t wifi_prov_mgr_reset_sm_state_on_failure(void);
|
||||
|
||||
/**
|
||||
* @brief Reset internal state machine and clear provisioned credentials.
|
||||
*
|
||||
* This API can be used to restart provisioning ONLY in case the device is
|
||||
* to be provisioned again for new credentials after a previous successful
|
||||
* provisioning without rebooting the device.
|
||||
*
|
||||
* @note This API can be used only if provisioning auto-stop has been
|
||||
* disabled using wifi_prov_mgr_disable_auto_stop()
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Reset provisioning state machine successfully
|
||||
* - ESP_FAIL : Failed to reset provisioning state machine
|
||||
* - ESP_ERR_INVALID_STATE : Manager not initialized
|
||||
*/
|
||||
esp_err_t wifi_prov_mgr_reset_sm_state_for_reprovision(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@@ -1,145 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <protocomm.h>
|
||||
#include <protocomm_ble.h>
|
||||
|
||||
#include "wifi_provisioning/manager.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Scheme that can be used by manager for provisioning
|
||||
* over BLE transport with GATT server
|
||||
*/
|
||||
extern const wifi_prov_scheme_t wifi_prov_scheme_ble;
|
||||
|
||||
/* This scheme specific event handler is to be used when application
|
||||
* doesn't require BT and BLE after provisioning has finished */
|
||||
#define WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BTDM { \
|
||||
.event_cb = wifi_prov_scheme_ble_event_cb_free_btdm, \
|
||||
.user_data = NULL \
|
||||
}
|
||||
|
||||
/* This scheme specific event handler is to be used when application
|
||||
* doesn't require BLE to be active after provisioning has finished */
|
||||
#define WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BLE { \
|
||||
.event_cb = wifi_prov_scheme_ble_event_cb_free_ble, \
|
||||
.user_data = NULL \
|
||||
}
|
||||
|
||||
/* This scheme specific event handler is to be used when application
|
||||
* doesn't require BT to be active after provisioning has finished */
|
||||
#define WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BT { \
|
||||
.event_cb = wifi_prov_scheme_ble_event_cb_free_bt, \
|
||||
.user_data = NULL \
|
||||
}
|
||||
|
||||
void wifi_prov_scheme_ble_event_cb_free_btdm(void *user_data, wifi_prov_cb_event_t event, void *event_data);
|
||||
void wifi_prov_scheme_ble_event_cb_free_ble (void *user_data, wifi_prov_cb_event_t event, void *event_data);
|
||||
void wifi_prov_scheme_ble_event_cb_free_bt (void *user_data, wifi_prov_cb_event_t event, void *event_data);
|
||||
|
||||
/**
|
||||
* @brief Set the 128 bit GATT service UUID used for provisioning
|
||||
*
|
||||
* This API is used to override the default 128 bit provisioning
|
||||
* service UUID, which is 0000ffff-0000-1000-8000-00805f9b34fb.
|
||||
*
|
||||
* This must be called before starting provisioning, i.e. before
|
||||
* making a call to wifi_prov_mgr_start_provisioning(), otherwise
|
||||
* the default UUID will be used.
|
||||
*
|
||||
* @note The data being pointed to by the argument must be valid
|
||||
* at least till provisioning is started. Upon start, the
|
||||
* manager will store an internal copy of this UUID, and
|
||||
* this data can be freed or invalidated afterwards.
|
||||
*
|
||||
* @param[in] uuid128 A custom 128 bit UUID
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Success
|
||||
* - ESP_ERR_INVALID_ARG : Null argument
|
||||
*/
|
||||
esp_err_t wifi_prov_scheme_ble_set_service_uuid(uint8_t *uuid128);
|
||||
|
||||
/**
|
||||
* @brief Keep the BLE on after provisioning
|
||||
*
|
||||
* This API is used to specify whether the BLE should remain on
|
||||
* after the provisioning process has stopped.
|
||||
*
|
||||
* This must be called before starting provisioning, i.e. before
|
||||
* making a call to wifi_prov_mgr_start_provisioning(), otherwise
|
||||
* the default behavior will be used.
|
||||
*
|
||||
* @note The value being pointed to by the argument must be valid
|
||||
* at least until provisioning is started. Upon start, the
|
||||
* manager will store an internal copy of this value, and
|
||||
* this data can be freed or invalidated afterwards.
|
||||
*
|
||||
* @param[in] is_on_after_ble_stop A boolean indicating if BLE should remain on after provisioning
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Success
|
||||
* - ESP_ERR_INVALID_ARG : Null argument
|
||||
*/
|
||||
esp_err_t wifi_prov_mgr_keep_ble_on(uint8_t is_on_after_ble_stop);
|
||||
|
||||
/**
|
||||
* @brief Set manufacturer specific data in scan response
|
||||
*
|
||||
* This must be called before starting provisioning, i.e. before
|
||||
* making a call to wifi_prov_mgr_start_provisioning().
|
||||
*
|
||||
* @note It is important to understand that length of custom manufacturer
|
||||
* data should be within limits. The manufacturer data goes into scan
|
||||
* response along with BLE device name. By default, BLE device name
|
||||
* length is of 11 Bytes, however it can vary as per application use
|
||||
* case. So, one has to honour the scan response data size limits i.e.
|
||||
* (mfg_data_len + 2) < 31 - (device_name_length + 2 ). If the
|
||||
* mfg_data length exceeds this limit, the length will be truncated.
|
||||
*
|
||||
* @param[in] mfg_data Custom manufacturer data
|
||||
* @param[in] mfg_data_len Manufacturer data length
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Success
|
||||
* - ESP_ERR_INVALID_ARG : Null argument
|
||||
*/
|
||||
esp_err_t wifi_prov_scheme_ble_set_mfg_data(uint8_t *mfg_data, ssize_t mfg_data_len);
|
||||
|
||||
/**
|
||||
* @brief Set Bluetooth Random address
|
||||
*
|
||||
* This must be called before starting provisioning, i.e. before
|
||||
* making a call to wifi_prov_mgr_start_provisioning().
|
||||
*
|
||||
* This API can be used in cases where a new identity address is to be used during
|
||||
* provisioning. This will result in this device being treated as a new device by remote
|
||||
* devices.
|
||||
*
|
||||
* @note This API will change the existing BD address for the device. The address once
|
||||
* set will remain unchanged until BLE stack tear down happens when
|
||||
* wifi_prov_mgr_deinit is invoked.
|
||||
*
|
||||
* This API is only to be called to set random address. Re-invoking this API
|
||||
* after provisioning is started will have no effect.
|
||||
*
|
||||
* @param[in] rand_addr The static random address to be set of length 6 bytes.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Success
|
||||
* - ESP_ERR_INVALID_ARG : Null argument
|
||||
*/
|
||||
esp_err_t wifi_prov_scheme_ble_set_random_addr(const uint8_t *rand_addr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@@ -1,34 +0,0 @@
|
||||
// Copyright 2019 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.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <protocomm.h>
|
||||
#include <protocomm_console.h>
|
||||
|
||||
#include "wifi_provisioning/manager.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Scheme that can be used by manager for provisioning
|
||||
* over console (Serial UART)
|
||||
*/
|
||||
extern const wifi_prov_scheme_t wifi_prov_scheme_console;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@@ -1,47 +0,0 @@
|
||||
// Copyright 2019 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.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <protocomm.h>
|
||||
#include <protocomm_httpd.h>
|
||||
|
||||
#include "wifi_provisioning/manager.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Scheme that can be used by manager for provisioning
|
||||
* over SoftAP transport with HTTP server
|
||||
*/
|
||||
extern const wifi_prov_scheme_t wifi_prov_scheme_softap;
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Provide HTTPD Server handle externally.
|
||||
*
|
||||
* Useful in cases wherein applications need the webserver for some
|
||||
* different operations, and do not want the wifi provisioning component
|
||||
* to start/stop a new instance.
|
||||
*
|
||||
* @note This API should be called before wifi_prov_mgr_start_provisioning()
|
||||
*
|
||||
* @param[in] handle Handle to HTTPD server instance
|
||||
*/
|
||||
void wifi_prov_scheme_softap_set_httpd_handle(void *handle);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@@ -1,150 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _WIFI_PROV_CONFIG_H_
|
||||
#define _WIFI_PROV_CONFIG_H_
|
||||
|
||||
#include "esp_netif_ip_addr.h"
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief WiFi STA status for conveying back to the provisioning master
|
||||
*/
|
||||
typedef enum {
|
||||
WIFI_PROV_STA_CONNECTING,
|
||||
WIFI_PROV_STA_CONNECTED,
|
||||
WIFI_PROV_STA_DISCONNECTED,
|
||||
WIFI_PROV_STA_CONN_ATTEMPT_FAILED
|
||||
} wifi_prov_sta_state_t;
|
||||
|
||||
/**
|
||||
* @brief WiFi STA connection fail reason
|
||||
*/
|
||||
typedef enum {
|
||||
WIFI_PROV_STA_AUTH_ERROR,
|
||||
WIFI_PROV_STA_AP_NOT_FOUND
|
||||
} wifi_prov_sta_fail_reason_t;
|
||||
|
||||
/**
|
||||
* @brief WiFi STA connected status information
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* IP Address received by station
|
||||
*/
|
||||
char ip_addr[IP4ADDR_STRLEN_MAX];
|
||||
|
||||
char bssid[6]; /*!< BSSID of the AP to which connection was estalished */
|
||||
char ssid[33]; /*!< SSID of the to which connection was estalished */
|
||||
uint8_t channel; /*!< Channel of the AP */
|
||||
uint8_t auth_mode; /*!< Authorization mode of the AP */
|
||||
} wifi_prov_sta_conn_info_t;
|
||||
|
||||
/**
|
||||
* @brief WiFi STA connecting status information
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t attempts_remaining; /*!< Number of Wi-Fi connection attempts remaining */
|
||||
} wifi_prov_sta_connecting_info_t;
|
||||
|
||||
/**
|
||||
* @brief WiFi status data to be sent in response to `get_status` request from master
|
||||
*/
|
||||
typedef struct {
|
||||
wifi_prov_sta_state_t wifi_state; /*!< WiFi state of the station */
|
||||
union {
|
||||
/**
|
||||
* Reason for disconnection (valid only when `wifi_state` is `WIFI_STATION_DISCONNECTED`)
|
||||
*/
|
||||
wifi_prov_sta_fail_reason_t fail_reason;
|
||||
|
||||
/**
|
||||
* Connection information (valid only when `wifi_state` is `WIFI_STATION_CONNECTED`)
|
||||
*/
|
||||
wifi_prov_sta_conn_info_t conn_info;
|
||||
|
||||
/**
|
||||
* Connecting information (valid only when `wifi_state` is `WIFI_STATION_CONNECTING`)
|
||||
*/
|
||||
wifi_prov_sta_connecting_info_t connecting_info;
|
||||
};
|
||||
} wifi_prov_config_get_data_t;
|
||||
|
||||
/**
|
||||
* @brief WiFi config data received by slave during `set_config` request from master
|
||||
*/
|
||||
typedef struct {
|
||||
char ssid[33]; /*!< SSID of the AP to which the slave is to be connected */
|
||||
char password[64]; /*!< Password of the AP */
|
||||
char bssid[6]; /*!< BSSID of the AP */
|
||||
uint8_t channel; /*!< Channel of the AP */
|
||||
} wifi_prov_config_set_data_t;
|
||||
|
||||
/**
|
||||
* @brief Type of context data passed to each get/set/apply handler
|
||||
* function set in `wifi_prov_config_handlers` structure.
|
||||
*
|
||||
* This is passed as an opaque pointer, thereby allowing it be defined
|
||||
* later in application code as per requirements.
|
||||
*/
|
||||
typedef struct wifi_prov_ctx wifi_prov_ctx_t;
|
||||
|
||||
/**
|
||||
* @brief Internal handlers for receiving and responding to protocomm
|
||||
* requests from master
|
||||
*
|
||||
* This is to be passed as priv_data for protocomm request handler
|
||||
* (refer to `wifi_prov_config_data_handler()`) when calling `protocomm_add_endpoint()`.
|
||||
*/
|
||||
typedef struct wifi_prov_config_handlers {
|
||||
/**
|
||||
* Handler function called when connection status
|
||||
* of the slave (in WiFi station mode) is requested
|
||||
*/
|
||||
esp_err_t (*get_status_handler)(wifi_prov_config_get_data_t *resp_data,
|
||||
wifi_prov_ctx_t **ctx);
|
||||
|
||||
/**
|
||||
* Handler function called when WiFi connection configuration
|
||||
* (eg. AP SSID, password, etc.) of the slave (in WiFi station mode)
|
||||
* is to be set to user provided values
|
||||
*/
|
||||
esp_err_t (*set_config_handler)(const wifi_prov_config_set_data_t *req_data,
|
||||
wifi_prov_ctx_t **ctx);
|
||||
|
||||
/**
|
||||
* Handler function for applying the configuration that was set in
|
||||
* `set_config_handler`. After applying the station may get connected to
|
||||
* the AP or may fail to connect. The slave must be ready to convey the
|
||||
* updated connection status information when `get_status_handler` is
|
||||
* invoked again by the master.
|
||||
*/
|
||||
esp_err_t (*apply_config_handler)(wifi_prov_ctx_t **ctx);
|
||||
|
||||
/**
|
||||
* Context pointer to be passed to above handler functions upon invocation
|
||||
*/
|
||||
wifi_prov_ctx_t *ctx;
|
||||
} wifi_prov_config_handlers_t;
|
||||
|
||||
/**
|
||||
* @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 wifi_prov_config_data_handler(uint32_t session_id, const uint8_t *inbuf, ssize_t inlen,
|
||||
uint8_t **outbuf, ssize_t *outlen, void *priv_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@@ -1,166 +0,0 @@
|
||||
// Copyright 2019 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 _PROV_WIFI_SCAN_H_
|
||||
#define _PROV_WIFI_SCAN_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <esp_wifi.h>
|
||||
|
||||
#define WIFI_SSID_LEN sizeof(((wifi_ap_record_t *)0)->ssid)
|
||||
#define WIFI_BSSID_LEN sizeof(((wifi_ap_record_t *)0)->bssid)
|
||||
|
||||
/**
|
||||
* @brief Type of context data passed to each get/set/apply handler
|
||||
* function set in `wifi_prov_scan_handlers` structure.
|
||||
*
|
||||
* This is passed as an opaque pointer, thereby allowing it be defined
|
||||
* later in application code as per requirements.
|
||||
*/
|
||||
typedef struct wifi_prov_scan_ctx wifi_prov_scan_ctx_t;
|
||||
|
||||
/**
|
||||
* @brief Structure of entries in the scan results list
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* SSID of Wi-Fi AP
|
||||
*/
|
||||
char ssid[WIFI_SSID_LEN];
|
||||
|
||||
/**
|
||||
* BSSID of Wi-Fi AP
|
||||
*/
|
||||
char bssid[WIFI_BSSID_LEN];
|
||||
|
||||
/**
|
||||
* Wi-Fi channel number
|
||||
*/
|
||||
uint8_t channel;
|
||||
|
||||
/**
|
||||
* Signal strength
|
||||
*/
|
||||
int rssi;
|
||||
|
||||
/**
|
||||
* Wi-Fi security mode
|
||||
*/
|
||||
uint8_t auth;
|
||||
} wifi_prov_scan_result_t;
|
||||
|
||||
/**
|
||||
* @brief Internal handlers for receiving and responding to protocomm
|
||||
* requests from client
|
||||
*
|
||||
* This is to be passed as priv_data for protocomm request handler
|
||||
* (refer to `wifi_prov_scan_handler()`) when calling `protocomm_add_endpoint()`.
|
||||
*/
|
||||
typedef struct wifi_prov_scan_handlers {
|
||||
/**
|
||||
* Handler function called when scan start command is received
|
||||
* with various scan parameters :
|
||||
*
|
||||
* blocking (input) - If true, the function should return only
|
||||
* when the scanning is finished
|
||||
*
|
||||
* passive (input) - If true, scan is to be started in passive
|
||||
* mode (this may be slower) instead of active mode
|
||||
*
|
||||
* group_channels (input) - This specifies whether to scan
|
||||
* all channels in one go (when zero) or perform scanning of
|
||||
* channels in groups, with 120ms delay between scanning of
|
||||
* consecutive groups, and the value of this parameter sets the
|
||||
* number of channels in each group. This is useful when transport
|
||||
* mode is SoftAP, where scanning all channels in one go may not
|
||||
* give the Wi-Fi driver enough time to send out beacons, and
|
||||
* hence may cause disconnection with any connected stations.
|
||||
* When scanning in groups, the manager will wait for atleast
|
||||
* 120ms after completing scan on a group of channels, and thus
|
||||
* allow the driver to send out the beacons. For example, given
|
||||
* that the total number of Wi-Fi channels is 14, then setting
|
||||
* group_channels to 4, will create 5 groups, with each group
|
||||
* having 3 channels, except the last one which will have
|
||||
* 14 % 3 = 2 channels. So, when scan is started, the first 3
|
||||
* channels will be scanned, followed by a 120ms delay, and then
|
||||
* the next 3 channels, and so on, until all the 14 channels have
|
||||
* been scanned. One may need to adjust this parameter as having
|
||||
* only few channels in a group may slow down the overall scan
|
||||
* time, while having too many may again cause disconnection.
|
||||
* Usually a value of 4 should work for most cases. Note that
|
||||
* for any other mode of transport, e.g. BLE, this can be safely
|
||||
* set to 0, and hence achieve the fastest overall scanning time.
|
||||
*
|
||||
* period_ms (input) - Scan parameter specifying how long to
|
||||
* wait on each channel (in milli-seconds)
|
||||
*/
|
||||
esp_err_t (*scan_start)(bool blocking, bool passive,
|
||||
uint8_t group_channels, uint32_t period_ms,
|
||||
wifi_prov_scan_ctx_t **ctx);
|
||||
|
||||
/**
|
||||
* Handler function called when scan status is requested. Status
|
||||
* is given the parameters :
|
||||
*
|
||||
* scan_finished (output) - When scan has finished this returns true
|
||||
*
|
||||
* result_count (output) - This gives the total number of results
|
||||
* obtained till now. If scan is yet happening this number will
|
||||
* keep on updating
|
||||
*/
|
||||
esp_err_t (*scan_status)(bool *scan_finished,
|
||||
uint16_t *result_count,
|
||||
wifi_prov_scan_ctx_t **ctx);
|
||||
|
||||
/**
|
||||
* Handler function called when scan result is requested. Parameters :
|
||||
*
|
||||
* scan_result - For fetching scan results. This can be called even
|
||||
* if scan is still on going
|
||||
*
|
||||
* start_index (input) - Starting index from where to fetch the
|
||||
* entries from the results list
|
||||
*
|
||||
* count (input) - Number of entries to fetch from the starting index
|
||||
*
|
||||
* entries (output) - List of entries returned. Each entry consists
|
||||
* of ssid, channel and rssi information
|
||||
*/
|
||||
esp_err_t (*scan_result)(uint16_t result_index,
|
||||
wifi_prov_scan_result_t *result,
|
||||
wifi_prov_scan_ctx_t **ctx);
|
||||
|
||||
/**
|
||||
* Context pointer to be passed to above handler functions upon invocation
|
||||
*/
|
||||
wifi_prov_scan_ctx_t *ctx;
|
||||
} wifi_prov_scan_handlers_t;
|
||||
|
||||
/**
|
||||
* @brief Handler for sending on demand Wi-Fi scan results
|
||||
*
|
||||
* This is to be registered as the `prov-scan` endpoint handler
|
||||
* (protocomm `protocomm_req_handler_t`) using `protocomm_add_endpoint()`
|
||||
*/
|
||||
esp_err_t wifi_prov_scan_handler(uint32_t session_id, const uint8_t *inbuf, ssize_t inlen,
|
||||
uint8_t **outbuf, ssize_t *outlen, void *priv_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@@ -1,757 +0,0 @@
|
||||
/* Generated by the protocol buffer compiler. DO NOT EDIT! */
|
||||
/* Generated from: wifi_config.proto */
|
||||
|
||||
/* Do not generate deprecated warnings for self */
|
||||
#ifndef PROTOBUF_C__NO_DEPRECATED
|
||||
#define PROTOBUF_C__NO_DEPRECATED
|
||||
#endif
|
||||
|
||||
#include "wifi_config.pb-c.h"
|
||||
void cmd_get_status__init
|
||||
(CmdGetStatus *message)
|
||||
{
|
||||
static const CmdGetStatus init_value = CMD_GET_STATUS__INIT;
|
||||
*message = init_value;
|
||||
}
|
||||
size_t cmd_get_status__get_packed_size
|
||||
(const CmdGetStatus *message)
|
||||
{
|
||||
assert(message->base.descriptor == &cmd_get_status__descriptor);
|
||||
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
|
||||
}
|
||||
size_t cmd_get_status__pack
|
||||
(const CmdGetStatus *message,
|
||||
uint8_t *out)
|
||||
{
|
||||
assert(message->base.descriptor == &cmd_get_status__descriptor);
|
||||
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
|
||||
}
|
||||
size_t cmd_get_status__pack_to_buffer
|
||||
(const CmdGetStatus *message,
|
||||
ProtobufCBuffer *buffer)
|
||||
{
|
||||
assert(message->base.descriptor == &cmd_get_status__descriptor);
|
||||
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
|
||||
}
|
||||
CmdGetStatus *
|
||||
cmd_get_status__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data)
|
||||
{
|
||||
return (CmdGetStatus *)
|
||||
protobuf_c_message_unpack (&cmd_get_status__descriptor,
|
||||
allocator, len, data);
|
||||
}
|
||||
void cmd_get_status__free_unpacked
|
||||
(CmdGetStatus *message,
|
||||
ProtobufCAllocator *allocator)
|
||||
{
|
||||
if(!message)
|
||||
return;
|
||||
assert(message->base.descriptor == &cmd_get_status__descriptor);
|
||||
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
|
||||
}
|
||||
void resp_get_status__init
|
||||
(RespGetStatus *message)
|
||||
{
|
||||
static const RespGetStatus init_value = RESP_GET_STATUS__INIT;
|
||||
*message = init_value;
|
||||
}
|
||||
size_t resp_get_status__get_packed_size
|
||||
(const RespGetStatus *message)
|
||||
{
|
||||
assert(message->base.descriptor == &resp_get_status__descriptor);
|
||||
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
|
||||
}
|
||||
size_t resp_get_status__pack
|
||||
(const RespGetStatus *message,
|
||||
uint8_t *out)
|
||||
{
|
||||
assert(message->base.descriptor == &resp_get_status__descriptor);
|
||||
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
|
||||
}
|
||||
size_t resp_get_status__pack_to_buffer
|
||||
(const RespGetStatus *message,
|
||||
ProtobufCBuffer *buffer)
|
||||
{
|
||||
assert(message->base.descriptor == &resp_get_status__descriptor);
|
||||
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
|
||||
}
|
||||
RespGetStatus *
|
||||
resp_get_status__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data)
|
||||
{
|
||||
return (RespGetStatus *)
|
||||
protobuf_c_message_unpack (&resp_get_status__descriptor,
|
||||
allocator, len, data);
|
||||
}
|
||||
void resp_get_status__free_unpacked
|
||||
(RespGetStatus *message,
|
||||
ProtobufCAllocator *allocator)
|
||||
{
|
||||
if(!message)
|
||||
return;
|
||||
assert(message->base.descriptor == &resp_get_status__descriptor);
|
||||
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
|
||||
}
|
||||
void cmd_set_config__init
|
||||
(CmdSetConfig *message)
|
||||
{
|
||||
static const CmdSetConfig init_value = CMD_SET_CONFIG__INIT;
|
||||
*message = init_value;
|
||||
}
|
||||
size_t cmd_set_config__get_packed_size
|
||||
(const CmdSetConfig *message)
|
||||
{
|
||||
assert(message->base.descriptor == &cmd_set_config__descriptor);
|
||||
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
|
||||
}
|
||||
size_t cmd_set_config__pack
|
||||
(const CmdSetConfig *message,
|
||||
uint8_t *out)
|
||||
{
|
||||
assert(message->base.descriptor == &cmd_set_config__descriptor);
|
||||
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
|
||||
}
|
||||
size_t cmd_set_config__pack_to_buffer
|
||||
(const CmdSetConfig *message,
|
||||
ProtobufCBuffer *buffer)
|
||||
{
|
||||
assert(message->base.descriptor == &cmd_set_config__descriptor);
|
||||
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
|
||||
}
|
||||
CmdSetConfig *
|
||||
cmd_set_config__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data)
|
||||
{
|
||||
return (CmdSetConfig *)
|
||||
protobuf_c_message_unpack (&cmd_set_config__descriptor,
|
||||
allocator, len, data);
|
||||
}
|
||||
void cmd_set_config__free_unpacked
|
||||
(CmdSetConfig *message,
|
||||
ProtobufCAllocator *allocator)
|
||||
{
|
||||
if(!message)
|
||||
return;
|
||||
assert(message->base.descriptor == &cmd_set_config__descriptor);
|
||||
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
|
||||
}
|
||||
void resp_set_config__init
|
||||
(RespSetConfig *message)
|
||||
{
|
||||
static const RespSetConfig init_value = RESP_SET_CONFIG__INIT;
|
||||
*message = init_value;
|
||||
}
|
||||
size_t resp_set_config__get_packed_size
|
||||
(const RespSetConfig *message)
|
||||
{
|
||||
assert(message->base.descriptor == &resp_set_config__descriptor);
|
||||
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
|
||||
}
|
||||
size_t resp_set_config__pack
|
||||
(const RespSetConfig *message,
|
||||
uint8_t *out)
|
||||
{
|
||||
assert(message->base.descriptor == &resp_set_config__descriptor);
|
||||
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
|
||||
}
|
||||
size_t resp_set_config__pack_to_buffer
|
||||
(const RespSetConfig *message,
|
||||
ProtobufCBuffer *buffer)
|
||||
{
|
||||
assert(message->base.descriptor == &resp_set_config__descriptor);
|
||||
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
|
||||
}
|
||||
RespSetConfig *
|
||||
resp_set_config__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data)
|
||||
{
|
||||
return (RespSetConfig *)
|
||||
protobuf_c_message_unpack (&resp_set_config__descriptor,
|
||||
allocator, len, data);
|
||||
}
|
||||
void resp_set_config__free_unpacked
|
||||
(RespSetConfig *message,
|
||||
ProtobufCAllocator *allocator)
|
||||
{
|
||||
if(!message)
|
||||
return;
|
||||
assert(message->base.descriptor == &resp_set_config__descriptor);
|
||||
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
|
||||
}
|
||||
void cmd_apply_config__init
|
||||
(CmdApplyConfig *message)
|
||||
{
|
||||
static const CmdApplyConfig init_value = CMD_APPLY_CONFIG__INIT;
|
||||
*message = init_value;
|
||||
}
|
||||
size_t cmd_apply_config__get_packed_size
|
||||
(const CmdApplyConfig *message)
|
||||
{
|
||||
assert(message->base.descriptor == &cmd_apply_config__descriptor);
|
||||
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
|
||||
}
|
||||
size_t cmd_apply_config__pack
|
||||
(const CmdApplyConfig *message,
|
||||
uint8_t *out)
|
||||
{
|
||||
assert(message->base.descriptor == &cmd_apply_config__descriptor);
|
||||
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
|
||||
}
|
||||
size_t cmd_apply_config__pack_to_buffer
|
||||
(const CmdApplyConfig *message,
|
||||
ProtobufCBuffer *buffer)
|
||||
{
|
||||
assert(message->base.descriptor == &cmd_apply_config__descriptor);
|
||||
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
|
||||
}
|
||||
CmdApplyConfig *
|
||||
cmd_apply_config__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data)
|
||||
{
|
||||
return (CmdApplyConfig *)
|
||||
protobuf_c_message_unpack (&cmd_apply_config__descriptor,
|
||||
allocator, len, data);
|
||||
}
|
||||
void cmd_apply_config__free_unpacked
|
||||
(CmdApplyConfig *message,
|
||||
ProtobufCAllocator *allocator)
|
||||
{
|
||||
if(!message)
|
||||
return;
|
||||
assert(message->base.descriptor == &cmd_apply_config__descriptor);
|
||||
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
|
||||
}
|
||||
void resp_apply_config__init
|
||||
(RespApplyConfig *message)
|
||||
{
|
||||
static const RespApplyConfig init_value = RESP_APPLY_CONFIG__INIT;
|
||||
*message = init_value;
|
||||
}
|
||||
size_t resp_apply_config__get_packed_size
|
||||
(const RespApplyConfig *message)
|
||||
{
|
||||
assert(message->base.descriptor == &resp_apply_config__descriptor);
|
||||
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
|
||||
}
|
||||
size_t resp_apply_config__pack
|
||||
(const RespApplyConfig *message,
|
||||
uint8_t *out)
|
||||
{
|
||||
assert(message->base.descriptor == &resp_apply_config__descriptor);
|
||||
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
|
||||
}
|
||||
size_t resp_apply_config__pack_to_buffer
|
||||
(const RespApplyConfig *message,
|
||||
ProtobufCBuffer *buffer)
|
||||
{
|
||||
assert(message->base.descriptor == &resp_apply_config__descriptor);
|
||||
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
|
||||
}
|
||||
RespApplyConfig *
|
||||
resp_apply_config__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data)
|
||||
{
|
||||
return (RespApplyConfig *)
|
||||
protobuf_c_message_unpack (&resp_apply_config__descriptor,
|
||||
allocator, len, data);
|
||||
}
|
||||
void resp_apply_config__free_unpacked
|
||||
(RespApplyConfig *message,
|
||||
ProtobufCAllocator *allocator)
|
||||
{
|
||||
if(!message)
|
||||
return;
|
||||
assert(message->base.descriptor == &resp_apply_config__descriptor);
|
||||
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
|
||||
}
|
||||
void wi_fi_config_payload__init
|
||||
(WiFiConfigPayload *message)
|
||||
{
|
||||
static const WiFiConfigPayload init_value = WI_FI_CONFIG_PAYLOAD__INIT;
|
||||
*message = init_value;
|
||||
}
|
||||
size_t wi_fi_config_payload__get_packed_size
|
||||
(const WiFiConfigPayload *message)
|
||||
{
|
||||
assert(message->base.descriptor == &wi_fi_config_payload__descriptor);
|
||||
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
|
||||
}
|
||||
size_t wi_fi_config_payload__pack
|
||||
(const WiFiConfigPayload *message,
|
||||
uint8_t *out)
|
||||
{
|
||||
assert(message->base.descriptor == &wi_fi_config_payload__descriptor);
|
||||
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
|
||||
}
|
||||
size_t wi_fi_config_payload__pack_to_buffer
|
||||
(const WiFiConfigPayload *message,
|
||||
ProtobufCBuffer *buffer)
|
||||
{
|
||||
assert(message->base.descriptor == &wi_fi_config_payload__descriptor);
|
||||
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
|
||||
}
|
||||
WiFiConfigPayload *
|
||||
wi_fi_config_payload__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data)
|
||||
{
|
||||
return (WiFiConfigPayload *)
|
||||
protobuf_c_message_unpack (&wi_fi_config_payload__descriptor,
|
||||
allocator, len, data);
|
||||
}
|
||||
void wi_fi_config_payload__free_unpacked
|
||||
(WiFiConfigPayload *message,
|
||||
ProtobufCAllocator *allocator)
|
||||
{
|
||||
if(!message)
|
||||
return;
|
||||
assert(message->base.descriptor == &wi_fi_config_payload__descriptor);
|
||||
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
|
||||
}
|
||||
#define cmd_get_status__field_descriptors NULL
|
||||
#define cmd_get_status__field_indices_by_name NULL
|
||||
#define cmd_get_status__number_ranges NULL
|
||||
const ProtobufCMessageDescriptor cmd_get_status__descriptor =
|
||||
{
|
||||
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
|
||||
"CmdGetStatus",
|
||||
"CmdGetStatus",
|
||||
"CmdGetStatus",
|
||||
"",
|
||||
sizeof(CmdGetStatus),
|
||||
0,
|
||||
cmd_get_status__field_descriptors,
|
||||
cmd_get_status__field_indices_by_name,
|
||||
0, cmd_get_status__number_ranges,
|
||||
(ProtobufCMessageInit) cmd_get_status__init,
|
||||
NULL,NULL,NULL /* reserved[123] */
|
||||
};
|
||||
static const ProtobufCFieldDescriptor resp_get_status__field_descriptors[5] =
|
||||
{
|
||||
{
|
||||
"status",
|
||||
1,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_ENUM,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(RespGetStatus, status),
|
||||
&status__descriptor,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"sta_state",
|
||||
2,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_ENUM,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(RespGetStatus, sta_state),
|
||||
&wifi_station_state__descriptor,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"fail_reason",
|
||||
10,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_ENUM,
|
||||
offsetof(RespGetStatus, state_case),
|
||||
offsetof(RespGetStatus, fail_reason),
|
||||
&wifi_connect_failed_reason__descriptor,
|
||||
NULL,
|
||||
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"connected",
|
||||
11,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_MESSAGE,
|
||||
offsetof(RespGetStatus, state_case),
|
||||
offsetof(RespGetStatus, connected),
|
||||
&wifi_connected_state__descriptor,
|
||||
NULL,
|
||||
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"attempt_failed",
|
||||
12,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_MESSAGE,
|
||||
offsetof(RespGetStatus, state_case),
|
||||
offsetof(RespGetStatus, attempt_failed),
|
||||
&wifi_attempt_failed__descriptor,
|
||||
NULL,
|
||||
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
};
|
||||
static const unsigned resp_get_status__field_indices_by_name[] = {
|
||||
4, /* field[4] = attempt_failed */
|
||||
3, /* field[3] = connected */
|
||||
2, /* field[2] = fail_reason */
|
||||
1, /* field[1] = sta_state */
|
||||
0, /* field[0] = status */
|
||||
};
|
||||
static const ProtobufCIntRange resp_get_status__number_ranges[2 + 1] =
|
||||
{
|
||||
{ 1, 0 },
|
||||
{ 10, 2 },
|
||||
{ 0, 5 }
|
||||
};
|
||||
const ProtobufCMessageDescriptor resp_get_status__descriptor =
|
||||
{
|
||||
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
|
||||
"RespGetStatus",
|
||||
"RespGetStatus",
|
||||
"RespGetStatus",
|
||||
"",
|
||||
sizeof(RespGetStatus),
|
||||
5,
|
||||
resp_get_status__field_descriptors,
|
||||
resp_get_status__field_indices_by_name,
|
||||
2, resp_get_status__number_ranges,
|
||||
(ProtobufCMessageInit) resp_get_status__init,
|
||||
NULL,NULL,NULL /* reserved[123] */
|
||||
};
|
||||
static const ProtobufCFieldDescriptor cmd_set_config__field_descriptors[4] =
|
||||
{
|
||||
{
|
||||
"ssid",
|
||||
1,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_BYTES,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(CmdSetConfig, ssid),
|
||||
NULL,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"passphrase",
|
||||
2,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_BYTES,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(CmdSetConfig, passphrase),
|
||||
NULL,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"bssid",
|
||||
3,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_BYTES,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(CmdSetConfig, bssid),
|
||||
NULL,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"channel",
|
||||
4,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_INT32,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(CmdSetConfig, channel),
|
||||
NULL,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
};
|
||||
static const unsigned cmd_set_config__field_indices_by_name[] = {
|
||||
2, /* field[2] = bssid */
|
||||
3, /* field[3] = channel */
|
||||
1, /* field[1] = passphrase */
|
||||
0, /* field[0] = ssid */
|
||||
};
|
||||
static const ProtobufCIntRange cmd_set_config__number_ranges[1 + 1] =
|
||||
{
|
||||
{ 1, 0 },
|
||||
{ 0, 4 }
|
||||
};
|
||||
const ProtobufCMessageDescriptor cmd_set_config__descriptor =
|
||||
{
|
||||
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
|
||||
"CmdSetConfig",
|
||||
"CmdSetConfig",
|
||||
"CmdSetConfig",
|
||||
"",
|
||||
sizeof(CmdSetConfig),
|
||||
4,
|
||||
cmd_set_config__field_descriptors,
|
||||
cmd_set_config__field_indices_by_name,
|
||||
1, cmd_set_config__number_ranges,
|
||||
(ProtobufCMessageInit) cmd_set_config__init,
|
||||
NULL,NULL,NULL /* reserved[123] */
|
||||
};
|
||||
static const ProtobufCFieldDescriptor resp_set_config__field_descriptors[1] =
|
||||
{
|
||||
{
|
||||
"status",
|
||||
1,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_ENUM,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(RespSetConfig, status),
|
||||
&status__descriptor,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
};
|
||||
static const unsigned resp_set_config__field_indices_by_name[] = {
|
||||
0, /* field[0] = status */
|
||||
};
|
||||
static const ProtobufCIntRange resp_set_config__number_ranges[1 + 1] =
|
||||
{
|
||||
{ 1, 0 },
|
||||
{ 0, 1 }
|
||||
};
|
||||
const ProtobufCMessageDescriptor resp_set_config__descriptor =
|
||||
{
|
||||
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
|
||||
"RespSetConfig",
|
||||
"RespSetConfig",
|
||||
"RespSetConfig",
|
||||
"",
|
||||
sizeof(RespSetConfig),
|
||||
1,
|
||||
resp_set_config__field_descriptors,
|
||||
resp_set_config__field_indices_by_name,
|
||||
1, resp_set_config__number_ranges,
|
||||
(ProtobufCMessageInit) resp_set_config__init,
|
||||
NULL,NULL,NULL /* reserved[123] */
|
||||
};
|
||||
#define cmd_apply_config__field_descriptors NULL
|
||||
#define cmd_apply_config__field_indices_by_name NULL
|
||||
#define cmd_apply_config__number_ranges NULL
|
||||
const ProtobufCMessageDescriptor cmd_apply_config__descriptor =
|
||||
{
|
||||
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
|
||||
"CmdApplyConfig",
|
||||
"CmdApplyConfig",
|
||||
"CmdApplyConfig",
|
||||
"",
|
||||
sizeof(CmdApplyConfig),
|
||||
0,
|
||||
cmd_apply_config__field_descriptors,
|
||||
cmd_apply_config__field_indices_by_name,
|
||||
0, cmd_apply_config__number_ranges,
|
||||
(ProtobufCMessageInit) cmd_apply_config__init,
|
||||
NULL,NULL,NULL /* reserved[123] */
|
||||
};
|
||||
static const ProtobufCFieldDescriptor resp_apply_config__field_descriptors[1] =
|
||||
{
|
||||
{
|
||||
"status",
|
||||
1,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_ENUM,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(RespApplyConfig, status),
|
||||
&status__descriptor,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
};
|
||||
static const unsigned resp_apply_config__field_indices_by_name[] = {
|
||||
0, /* field[0] = status */
|
||||
};
|
||||
static const ProtobufCIntRange resp_apply_config__number_ranges[1 + 1] =
|
||||
{
|
||||
{ 1, 0 },
|
||||
{ 0, 1 }
|
||||
};
|
||||
const ProtobufCMessageDescriptor resp_apply_config__descriptor =
|
||||
{
|
||||
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
|
||||
"RespApplyConfig",
|
||||
"RespApplyConfig",
|
||||
"RespApplyConfig",
|
||||
"",
|
||||
sizeof(RespApplyConfig),
|
||||
1,
|
||||
resp_apply_config__field_descriptors,
|
||||
resp_apply_config__field_indices_by_name,
|
||||
1, resp_apply_config__number_ranges,
|
||||
(ProtobufCMessageInit) resp_apply_config__init,
|
||||
NULL,NULL,NULL /* reserved[123] */
|
||||
};
|
||||
static const ProtobufCFieldDescriptor wi_fi_config_payload__field_descriptors[7] =
|
||||
{
|
||||
{
|
||||
"msg",
|
||||
1,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_ENUM,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(WiFiConfigPayload, msg),
|
||||
&wi_fi_config_msg_type__descriptor,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"cmd_get_status",
|
||||
10,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_MESSAGE,
|
||||
offsetof(WiFiConfigPayload, payload_case),
|
||||
offsetof(WiFiConfigPayload, cmd_get_status),
|
||||
&cmd_get_status__descriptor,
|
||||
NULL,
|
||||
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"resp_get_status",
|
||||
11,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_MESSAGE,
|
||||
offsetof(WiFiConfigPayload, payload_case),
|
||||
offsetof(WiFiConfigPayload, resp_get_status),
|
||||
&resp_get_status__descriptor,
|
||||
NULL,
|
||||
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"cmd_set_config",
|
||||
12,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_MESSAGE,
|
||||
offsetof(WiFiConfigPayload, payload_case),
|
||||
offsetof(WiFiConfigPayload, cmd_set_config),
|
||||
&cmd_set_config__descriptor,
|
||||
NULL,
|
||||
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"resp_set_config",
|
||||
13,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_MESSAGE,
|
||||
offsetof(WiFiConfigPayload, payload_case),
|
||||
offsetof(WiFiConfigPayload, resp_set_config),
|
||||
&resp_set_config__descriptor,
|
||||
NULL,
|
||||
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"cmd_apply_config",
|
||||
14,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_MESSAGE,
|
||||
offsetof(WiFiConfigPayload, payload_case),
|
||||
offsetof(WiFiConfigPayload, cmd_apply_config),
|
||||
&cmd_apply_config__descriptor,
|
||||
NULL,
|
||||
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"resp_apply_config",
|
||||
15,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_MESSAGE,
|
||||
offsetof(WiFiConfigPayload, payload_case),
|
||||
offsetof(WiFiConfigPayload, resp_apply_config),
|
||||
&resp_apply_config__descriptor,
|
||||
NULL,
|
||||
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
};
|
||||
static const unsigned wi_fi_config_payload__field_indices_by_name[] = {
|
||||
5, /* field[5] = cmd_apply_config */
|
||||
1, /* field[1] = cmd_get_status */
|
||||
3, /* field[3] = cmd_set_config */
|
||||
0, /* field[0] = msg */
|
||||
6, /* field[6] = resp_apply_config */
|
||||
2, /* field[2] = resp_get_status */
|
||||
4, /* field[4] = resp_set_config */
|
||||
};
|
||||
static const ProtobufCIntRange wi_fi_config_payload__number_ranges[2 + 1] =
|
||||
{
|
||||
{ 1, 0 },
|
||||
{ 10, 1 },
|
||||
{ 0, 7 }
|
||||
};
|
||||
const ProtobufCMessageDescriptor wi_fi_config_payload__descriptor =
|
||||
{
|
||||
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
|
||||
"WiFiConfigPayload",
|
||||
"WiFiConfigPayload",
|
||||
"WiFiConfigPayload",
|
||||
"",
|
||||
sizeof(WiFiConfigPayload),
|
||||
7,
|
||||
wi_fi_config_payload__field_descriptors,
|
||||
wi_fi_config_payload__field_indices_by_name,
|
||||
2, wi_fi_config_payload__number_ranges,
|
||||
(ProtobufCMessageInit) wi_fi_config_payload__init,
|
||||
NULL,NULL,NULL /* reserved[123] */
|
||||
};
|
||||
static const ProtobufCEnumValue wi_fi_config_msg_type__enum_values_by_number[6] =
|
||||
{
|
||||
{ "TypeCmdGetStatus", "WI_FI_CONFIG_MSG_TYPE__TypeCmdGetStatus", 0 },
|
||||
{ "TypeRespGetStatus", "WI_FI_CONFIG_MSG_TYPE__TypeRespGetStatus", 1 },
|
||||
{ "TypeCmdSetConfig", "WI_FI_CONFIG_MSG_TYPE__TypeCmdSetConfig", 2 },
|
||||
{ "TypeRespSetConfig", "WI_FI_CONFIG_MSG_TYPE__TypeRespSetConfig", 3 },
|
||||
{ "TypeCmdApplyConfig", "WI_FI_CONFIG_MSG_TYPE__TypeCmdApplyConfig", 4 },
|
||||
{ "TypeRespApplyConfig", "WI_FI_CONFIG_MSG_TYPE__TypeRespApplyConfig", 5 },
|
||||
};
|
||||
static const ProtobufCIntRange wi_fi_config_msg_type__value_ranges[] = {
|
||||
{0, 0},{0, 6}
|
||||
};
|
||||
static const ProtobufCEnumValueIndex wi_fi_config_msg_type__enum_values_by_name[6] =
|
||||
{
|
||||
{ "TypeCmdApplyConfig", 4 },
|
||||
{ "TypeCmdGetStatus", 0 },
|
||||
{ "TypeCmdSetConfig", 2 },
|
||||
{ "TypeRespApplyConfig", 5 },
|
||||
{ "TypeRespGetStatus", 1 },
|
||||
{ "TypeRespSetConfig", 3 },
|
||||
};
|
||||
const ProtobufCEnumDescriptor wi_fi_config_msg_type__descriptor =
|
||||
{
|
||||
PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC,
|
||||
"WiFiConfigMsgType",
|
||||
"WiFiConfigMsgType",
|
||||
"WiFiConfigMsgType",
|
||||
"",
|
||||
6,
|
||||
wi_fi_config_msg_type__enum_values_by_number,
|
||||
6,
|
||||
wi_fi_config_msg_type__enum_values_by_name,
|
||||
1,
|
||||
wi_fi_config_msg_type__value_ranges,
|
||||
NULL,NULL,NULL,NULL /* reserved[1234] */
|
||||
};
|
@@ -1,323 +0,0 @@
|
||||
/* Generated by the protocol buffer compiler. DO NOT EDIT! */
|
||||
/* Generated from: wifi_config.proto */
|
||||
|
||||
#ifndef PROTOBUF_C_wifi_5fconfig_2eproto__INCLUDED
|
||||
#define PROTOBUF_C_wifi_5fconfig_2eproto__INCLUDED
|
||||
|
||||
#include <protobuf-c/protobuf-c.h>
|
||||
|
||||
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 1004001 < 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
|
||||
|
||||
#include "constants.pb-c.h"
|
||||
#include "wifi_constants.pb-c.h"
|
||||
|
||||
typedef struct CmdGetStatus CmdGetStatus;
|
||||
typedef struct RespGetStatus RespGetStatus;
|
||||
typedef struct CmdSetConfig CmdSetConfig;
|
||||
typedef struct RespSetConfig RespSetConfig;
|
||||
typedef struct CmdApplyConfig CmdApplyConfig;
|
||||
typedef struct RespApplyConfig RespApplyConfig;
|
||||
typedef struct WiFiConfigPayload WiFiConfigPayload;
|
||||
|
||||
|
||||
/* --- enums --- */
|
||||
|
||||
typedef enum _WiFiConfigMsgType {
|
||||
WI_FI_CONFIG_MSG_TYPE__TypeCmdGetStatus = 0,
|
||||
WI_FI_CONFIG_MSG_TYPE__TypeRespGetStatus = 1,
|
||||
WI_FI_CONFIG_MSG_TYPE__TypeCmdSetConfig = 2,
|
||||
WI_FI_CONFIG_MSG_TYPE__TypeRespSetConfig = 3,
|
||||
WI_FI_CONFIG_MSG_TYPE__TypeCmdApplyConfig = 4,
|
||||
WI_FI_CONFIG_MSG_TYPE__TypeRespApplyConfig = 5
|
||||
PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(WI_FI_CONFIG_MSG_TYPE)
|
||||
} WiFiConfigMsgType;
|
||||
|
||||
/* --- messages --- */
|
||||
|
||||
struct CmdGetStatus
|
||||
{
|
||||
ProtobufCMessage base;
|
||||
};
|
||||
#define CMD_GET_STATUS__INIT \
|
||||
{ PROTOBUF_C_MESSAGE_INIT (&cmd_get_status__descriptor) \
|
||||
}
|
||||
|
||||
|
||||
typedef enum {
|
||||
RESP_GET_STATUS__STATE__NOT_SET = 0,
|
||||
RESP_GET_STATUS__STATE_FAIL_REASON = 10,
|
||||
RESP_GET_STATUS__STATE_CONNECTED = 11,
|
||||
RESP_GET_STATUS__STATE_ATTEMPT_FAILED = 12
|
||||
PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(RESP_GET_STATUS__STATE__CASE)
|
||||
} RespGetStatus__StateCase;
|
||||
|
||||
struct RespGetStatus
|
||||
{
|
||||
ProtobufCMessage base;
|
||||
Status status;
|
||||
WifiStationState sta_state;
|
||||
RespGetStatus__StateCase state_case;
|
||||
union {
|
||||
WifiConnectFailedReason fail_reason;
|
||||
WifiConnectedState *connected;
|
||||
WifiAttemptFailed *attempt_failed;
|
||||
};
|
||||
};
|
||||
#define RESP_GET_STATUS__INIT \
|
||||
{ PROTOBUF_C_MESSAGE_INIT (&resp_get_status__descriptor) \
|
||||
, STATUS__Success, WIFI_STATION_STATE__Connected, RESP_GET_STATUS__STATE__NOT_SET, {0} }
|
||||
|
||||
|
||||
struct CmdSetConfig
|
||||
{
|
||||
ProtobufCMessage base;
|
||||
ProtobufCBinaryData ssid;
|
||||
ProtobufCBinaryData passphrase;
|
||||
ProtobufCBinaryData bssid;
|
||||
int32_t channel;
|
||||
};
|
||||
#define CMD_SET_CONFIG__INIT \
|
||||
{ PROTOBUF_C_MESSAGE_INIT (&cmd_set_config__descriptor) \
|
||||
, {0,NULL}, {0,NULL}, {0,NULL}, 0 }
|
||||
|
||||
|
||||
struct RespSetConfig
|
||||
{
|
||||
ProtobufCMessage base;
|
||||
Status status;
|
||||
};
|
||||
#define RESP_SET_CONFIG__INIT \
|
||||
{ PROTOBUF_C_MESSAGE_INIT (&resp_set_config__descriptor) \
|
||||
, STATUS__Success }
|
||||
|
||||
|
||||
struct CmdApplyConfig
|
||||
{
|
||||
ProtobufCMessage base;
|
||||
};
|
||||
#define CMD_APPLY_CONFIG__INIT \
|
||||
{ PROTOBUF_C_MESSAGE_INIT (&cmd_apply_config__descriptor) \
|
||||
}
|
||||
|
||||
|
||||
struct RespApplyConfig
|
||||
{
|
||||
ProtobufCMessage base;
|
||||
Status status;
|
||||
};
|
||||
#define RESP_APPLY_CONFIG__INIT \
|
||||
{ PROTOBUF_C_MESSAGE_INIT (&resp_apply_config__descriptor) \
|
||||
, STATUS__Success }
|
||||
|
||||
|
||||
typedef enum {
|
||||
WI_FI_CONFIG_PAYLOAD__PAYLOAD__NOT_SET = 0,
|
||||
WI_FI_CONFIG_PAYLOAD__PAYLOAD_CMD_GET_STATUS = 10,
|
||||
WI_FI_CONFIG_PAYLOAD__PAYLOAD_RESP_GET_STATUS = 11,
|
||||
WI_FI_CONFIG_PAYLOAD__PAYLOAD_CMD_SET_CONFIG = 12,
|
||||
WI_FI_CONFIG_PAYLOAD__PAYLOAD_RESP_SET_CONFIG = 13,
|
||||
WI_FI_CONFIG_PAYLOAD__PAYLOAD_CMD_APPLY_CONFIG = 14,
|
||||
WI_FI_CONFIG_PAYLOAD__PAYLOAD_RESP_APPLY_CONFIG = 15
|
||||
PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(WI_FI_CONFIG_PAYLOAD__PAYLOAD__CASE)
|
||||
} WiFiConfigPayload__PayloadCase;
|
||||
|
||||
struct WiFiConfigPayload
|
||||
{
|
||||
ProtobufCMessage base;
|
||||
WiFiConfigMsgType msg;
|
||||
WiFiConfigPayload__PayloadCase payload_case;
|
||||
union {
|
||||
CmdGetStatus *cmd_get_status;
|
||||
RespGetStatus *resp_get_status;
|
||||
CmdSetConfig *cmd_set_config;
|
||||
RespSetConfig *resp_set_config;
|
||||
CmdApplyConfig *cmd_apply_config;
|
||||
RespApplyConfig *resp_apply_config;
|
||||
};
|
||||
};
|
||||
#define WI_FI_CONFIG_PAYLOAD__INIT \
|
||||
{ PROTOBUF_C_MESSAGE_INIT (&wi_fi_config_payload__descriptor) \
|
||||
, WI_FI_CONFIG_MSG_TYPE__TypeCmdGetStatus, WI_FI_CONFIG_PAYLOAD__PAYLOAD__NOT_SET, {0} }
|
||||
|
||||
|
||||
/* CmdGetStatus methods */
|
||||
void cmd_get_status__init
|
||||
(CmdGetStatus *message);
|
||||
size_t cmd_get_status__get_packed_size
|
||||
(const CmdGetStatus *message);
|
||||
size_t cmd_get_status__pack
|
||||
(const CmdGetStatus *message,
|
||||
uint8_t *out);
|
||||
size_t cmd_get_status__pack_to_buffer
|
||||
(const CmdGetStatus *message,
|
||||
ProtobufCBuffer *buffer);
|
||||
CmdGetStatus *
|
||||
cmd_get_status__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data);
|
||||
void cmd_get_status__free_unpacked
|
||||
(CmdGetStatus *message,
|
||||
ProtobufCAllocator *allocator);
|
||||
/* RespGetStatus methods */
|
||||
void resp_get_status__init
|
||||
(RespGetStatus *message);
|
||||
size_t resp_get_status__get_packed_size
|
||||
(const RespGetStatus *message);
|
||||
size_t resp_get_status__pack
|
||||
(const RespGetStatus *message,
|
||||
uint8_t *out);
|
||||
size_t resp_get_status__pack_to_buffer
|
||||
(const RespGetStatus *message,
|
||||
ProtobufCBuffer *buffer);
|
||||
RespGetStatus *
|
||||
resp_get_status__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data);
|
||||
void resp_get_status__free_unpacked
|
||||
(RespGetStatus *message,
|
||||
ProtobufCAllocator *allocator);
|
||||
/* CmdSetConfig methods */
|
||||
void cmd_set_config__init
|
||||
(CmdSetConfig *message);
|
||||
size_t cmd_set_config__get_packed_size
|
||||
(const CmdSetConfig *message);
|
||||
size_t cmd_set_config__pack
|
||||
(const CmdSetConfig *message,
|
||||
uint8_t *out);
|
||||
size_t cmd_set_config__pack_to_buffer
|
||||
(const CmdSetConfig *message,
|
||||
ProtobufCBuffer *buffer);
|
||||
CmdSetConfig *
|
||||
cmd_set_config__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data);
|
||||
void cmd_set_config__free_unpacked
|
||||
(CmdSetConfig *message,
|
||||
ProtobufCAllocator *allocator);
|
||||
/* RespSetConfig methods */
|
||||
void resp_set_config__init
|
||||
(RespSetConfig *message);
|
||||
size_t resp_set_config__get_packed_size
|
||||
(const RespSetConfig *message);
|
||||
size_t resp_set_config__pack
|
||||
(const RespSetConfig *message,
|
||||
uint8_t *out);
|
||||
size_t resp_set_config__pack_to_buffer
|
||||
(const RespSetConfig *message,
|
||||
ProtobufCBuffer *buffer);
|
||||
RespSetConfig *
|
||||
resp_set_config__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data);
|
||||
void resp_set_config__free_unpacked
|
||||
(RespSetConfig *message,
|
||||
ProtobufCAllocator *allocator);
|
||||
/* CmdApplyConfig methods */
|
||||
void cmd_apply_config__init
|
||||
(CmdApplyConfig *message);
|
||||
size_t cmd_apply_config__get_packed_size
|
||||
(const CmdApplyConfig *message);
|
||||
size_t cmd_apply_config__pack
|
||||
(const CmdApplyConfig *message,
|
||||
uint8_t *out);
|
||||
size_t cmd_apply_config__pack_to_buffer
|
||||
(const CmdApplyConfig *message,
|
||||
ProtobufCBuffer *buffer);
|
||||
CmdApplyConfig *
|
||||
cmd_apply_config__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data);
|
||||
void cmd_apply_config__free_unpacked
|
||||
(CmdApplyConfig *message,
|
||||
ProtobufCAllocator *allocator);
|
||||
/* RespApplyConfig methods */
|
||||
void resp_apply_config__init
|
||||
(RespApplyConfig *message);
|
||||
size_t resp_apply_config__get_packed_size
|
||||
(const RespApplyConfig *message);
|
||||
size_t resp_apply_config__pack
|
||||
(const RespApplyConfig *message,
|
||||
uint8_t *out);
|
||||
size_t resp_apply_config__pack_to_buffer
|
||||
(const RespApplyConfig *message,
|
||||
ProtobufCBuffer *buffer);
|
||||
RespApplyConfig *
|
||||
resp_apply_config__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data);
|
||||
void resp_apply_config__free_unpacked
|
||||
(RespApplyConfig *message,
|
||||
ProtobufCAllocator *allocator);
|
||||
/* WiFiConfigPayload methods */
|
||||
void wi_fi_config_payload__init
|
||||
(WiFiConfigPayload *message);
|
||||
size_t wi_fi_config_payload__get_packed_size
|
||||
(const WiFiConfigPayload *message);
|
||||
size_t wi_fi_config_payload__pack
|
||||
(const WiFiConfigPayload *message,
|
||||
uint8_t *out);
|
||||
size_t wi_fi_config_payload__pack_to_buffer
|
||||
(const WiFiConfigPayload *message,
|
||||
ProtobufCBuffer *buffer);
|
||||
WiFiConfigPayload *
|
||||
wi_fi_config_payload__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data);
|
||||
void wi_fi_config_payload__free_unpacked
|
||||
(WiFiConfigPayload *message,
|
||||
ProtobufCAllocator *allocator);
|
||||
/* --- per-message closures --- */
|
||||
|
||||
typedef void (*CmdGetStatus_Closure)
|
||||
(const CmdGetStatus *message,
|
||||
void *closure_data);
|
||||
typedef void (*RespGetStatus_Closure)
|
||||
(const RespGetStatus *message,
|
||||
void *closure_data);
|
||||
typedef void (*CmdSetConfig_Closure)
|
||||
(const CmdSetConfig *message,
|
||||
void *closure_data);
|
||||
typedef void (*RespSetConfig_Closure)
|
||||
(const RespSetConfig *message,
|
||||
void *closure_data);
|
||||
typedef void (*CmdApplyConfig_Closure)
|
||||
(const CmdApplyConfig *message,
|
||||
void *closure_data);
|
||||
typedef void (*RespApplyConfig_Closure)
|
||||
(const RespApplyConfig *message,
|
||||
void *closure_data);
|
||||
typedef void (*WiFiConfigPayload_Closure)
|
||||
(const WiFiConfigPayload *message,
|
||||
void *closure_data);
|
||||
|
||||
/* --- services --- */
|
||||
|
||||
|
||||
/* --- descriptors --- */
|
||||
|
||||
extern const ProtobufCEnumDescriptor wi_fi_config_msg_type__descriptor;
|
||||
extern const ProtobufCMessageDescriptor cmd_get_status__descriptor;
|
||||
extern const ProtobufCMessageDescriptor resp_get_status__descriptor;
|
||||
extern const ProtobufCMessageDescriptor cmd_set_config__descriptor;
|
||||
extern const ProtobufCMessageDescriptor resp_set_config__descriptor;
|
||||
extern const ProtobufCMessageDescriptor cmd_apply_config__descriptor;
|
||||
extern const ProtobufCMessageDescriptor resp_apply_config__descriptor;
|
||||
extern const ProtobufCMessageDescriptor wi_fi_config_payload__descriptor;
|
||||
|
||||
PROTOBUF_C__END_DECLS
|
||||
|
||||
|
||||
#endif /* PROTOBUF_C_wifi_5fconfig_2eproto__INCLUDED */
|
@@ -1,327 +0,0 @@
|
||||
/* Generated by the protocol buffer compiler. DO NOT EDIT! */
|
||||
/* Generated from: wifi_constants.proto */
|
||||
|
||||
/* Do not generate deprecated warnings for self */
|
||||
#ifndef PROTOBUF_C__NO_DEPRECATED
|
||||
#define PROTOBUF_C__NO_DEPRECATED
|
||||
#endif
|
||||
|
||||
#include "wifi_constants.pb-c.h"
|
||||
void wifi_attempt_failed__init
|
||||
(WifiAttemptFailed *message)
|
||||
{
|
||||
static const WifiAttemptFailed init_value = WIFI_ATTEMPT_FAILED__INIT;
|
||||
*message = init_value;
|
||||
}
|
||||
size_t wifi_attempt_failed__get_packed_size
|
||||
(const WifiAttemptFailed *message)
|
||||
{
|
||||
assert(message->base.descriptor == &wifi_attempt_failed__descriptor);
|
||||
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
|
||||
}
|
||||
size_t wifi_attempt_failed__pack
|
||||
(const WifiAttemptFailed *message,
|
||||
uint8_t *out)
|
||||
{
|
||||
assert(message->base.descriptor == &wifi_attempt_failed__descriptor);
|
||||
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
|
||||
}
|
||||
size_t wifi_attempt_failed__pack_to_buffer
|
||||
(const WifiAttemptFailed *message,
|
||||
ProtobufCBuffer *buffer)
|
||||
{
|
||||
assert(message->base.descriptor == &wifi_attempt_failed__descriptor);
|
||||
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
|
||||
}
|
||||
WifiAttemptFailed *
|
||||
wifi_attempt_failed__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data)
|
||||
{
|
||||
return (WifiAttemptFailed *)
|
||||
protobuf_c_message_unpack (&wifi_attempt_failed__descriptor,
|
||||
allocator, len, data);
|
||||
}
|
||||
void wifi_attempt_failed__free_unpacked
|
||||
(WifiAttemptFailed *message,
|
||||
ProtobufCAllocator *allocator)
|
||||
{
|
||||
if(!message)
|
||||
return;
|
||||
assert(message->base.descriptor == &wifi_attempt_failed__descriptor);
|
||||
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
|
||||
}
|
||||
void wifi_connected_state__init
|
||||
(WifiConnectedState *message)
|
||||
{
|
||||
static const WifiConnectedState init_value = WIFI_CONNECTED_STATE__INIT;
|
||||
*message = init_value;
|
||||
}
|
||||
size_t wifi_connected_state__get_packed_size
|
||||
(const WifiConnectedState *message)
|
||||
{
|
||||
assert(message->base.descriptor == &wifi_connected_state__descriptor);
|
||||
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
|
||||
}
|
||||
size_t wifi_connected_state__pack
|
||||
(const WifiConnectedState *message,
|
||||
uint8_t *out)
|
||||
{
|
||||
assert(message->base.descriptor == &wifi_connected_state__descriptor);
|
||||
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
|
||||
}
|
||||
size_t wifi_connected_state__pack_to_buffer
|
||||
(const WifiConnectedState *message,
|
||||
ProtobufCBuffer *buffer)
|
||||
{
|
||||
assert(message->base.descriptor == &wifi_connected_state__descriptor);
|
||||
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
|
||||
}
|
||||
WifiConnectedState *
|
||||
wifi_connected_state__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data)
|
||||
{
|
||||
return (WifiConnectedState *)
|
||||
protobuf_c_message_unpack (&wifi_connected_state__descriptor,
|
||||
allocator, len, data);
|
||||
}
|
||||
void wifi_connected_state__free_unpacked
|
||||
(WifiConnectedState *message,
|
||||
ProtobufCAllocator *allocator)
|
||||
{
|
||||
if(!message)
|
||||
return;
|
||||
assert(message->base.descriptor == &wifi_connected_state__descriptor);
|
||||
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
|
||||
}
|
||||
static const ProtobufCFieldDescriptor wifi_attempt_failed__field_descriptors[1] =
|
||||
{
|
||||
{
|
||||
"attempts_remaining",
|
||||
1,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_UINT32,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(WifiAttemptFailed, attempts_remaining),
|
||||
NULL,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
};
|
||||
static const unsigned wifi_attempt_failed__field_indices_by_name[] = {
|
||||
0, /* field[0] = attempts_remaining */
|
||||
};
|
||||
static const ProtobufCIntRange wifi_attempt_failed__number_ranges[1 + 1] =
|
||||
{
|
||||
{ 1, 0 },
|
||||
{ 0, 1 }
|
||||
};
|
||||
const ProtobufCMessageDescriptor wifi_attempt_failed__descriptor =
|
||||
{
|
||||
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
|
||||
"WifiAttemptFailed",
|
||||
"WifiAttemptFailed",
|
||||
"WifiAttemptFailed",
|
||||
"",
|
||||
sizeof(WifiAttemptFailed),
|
||||
1,
|
||||
wifi_attempt_failed__field_descriptors,
|
||||
wifi_attempt_failed__field_indices_by_name,
|
||||
1, wifi_attempt_failed__number_ranges,
|
||||
(ProtobufCMessageInit) wifi_attempt_failed__init,
|
||||
NULL,NULL,NULL /* reserved[123] */
|
||||
};
|
||||
static const ProtobufCFieldDescriptor wifi_connected_state__field_descriptors[5] =
|
||||
{
|
||||
{
|
||||
"ip4_addr",
|
||||
1,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_STRING,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(WifiConnectedState, ip4_addr),
|
||||
NULL,
|
||||
&protobuf_c_empty_string,
|
||||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"auth_mode",
|
||||
2,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_ENUM,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(WifiConnectedState, auth_mode),
|
||||
&wifi_auth_mode__descriptor,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"ssid",
|
||||
3,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_BYTES,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(WifiConnectedState, ssid),
|
||||
NULL,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"bssid",
|
||||
4,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_BYTES,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(WifiConnectedState, bssid),
|
||||
NULL,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"channel",
|
||||
5,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_INT32,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(WifiConnectedState, channel),
|
||||
NULL,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
};
|
||||
static const unsigned wifi_connected_state__field_indices_by_name[] = {
|
||||
1, /* field[1] = auth_mode */
|
||||
3, /* field[3] = bssid */
|
||||
4, /* field[4] = channel */
|
||||
0, /* field[0] = ip4_addr */
|
||||
2, /* field[2] = ssid */
|
||||
};
|
||||
static const ProtobufCIntRange wifi_connected_state__number_ranges[1 + 1] =
|
||||
{
|
||||
{ 1, 0 },
|
||||
{ 0, 5 }
|
||||
};
|
||||
const ProtobufCMessageDescriptor wifi_connected_state__descriptor =
|
||||
{
|
||||
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
|
||||
"WifiConnectedState",
|
||||
"WifiConnectedState",
|
||||
"WifiConnectedState",
|
||||
"",
|
||||
sizeof(WifiConnectedState),
|
||||
5,
|
||||
wifi_connected_state__field_descriptors,
|
||||
wifi_connected_state__field_indices_by_name,
|
||||
1, wifi_connected_state__number_ranges,
|
||||
(ProtobufCMessageInit) wifi_connected_state__init,
|
||||
NULL,NULL,NULL /* reserved[123] */
|
||||
};
|
||||
static const ProtobufCEnumValue wifi_station_state__enum_values_by_number[4] =
|
||||
{
|
||||
{ "Connected", "WIFI_STATION_STATE__Connected", 0 },
|
||||
{ "Connecting", "WIFI_STATION_STATE__Connecting", 1 },
|
||||
{ "Disconnected", "WIFI_STATION_STATE__Disconnected", 2 },
|
||||
{ "ConnectionFailed", "WIFI_STATION_STATE__ConnectionFailed", 3 },
|
||||
};
|
||||
static const ProtobufCIntRange wifi_station_state__value_ranges[] = {
|
||||
{0, 0},{0, 4}
|
||||
};
|
||||
static const ProtobufCEnumValueIndex wifi_station_state__enum_values_by_name[4] =
|
||||
{
|
||||
{ "Connected", 0 },
|
||||
{ "Connecting", 1 },
|
||||
{ "ConnectionFailed", 3 },
|
||||
{ "Disconnected", 2 },
|
||||
};
|
||||
const ProtobufCEnumDescriptor wifi_station_state__descriptor =
|
||||
{
|
||||
PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC,
|
||||
"WifiStationState",
|
||||
"WifiStationState",
|
||||
"WifiStationState",
|
||||
"",
|
||||
4,
|
||||
wifi_station_state__enum_values_by_number,
|
||||
4,
|
||||
wifi_station_state__enum_values_by_name,
|
||||
1,
|
||||
wifi_station_state__value_ranges,
|
||||
NULL,NULL,NULL,NULL /* reserved[1234] */
|
||||
};
|
||||
static const ProtobufCEnumValue wifi_connect_failed_reason__enum_values_by_number[2] =
|
||||
{
|
||||
{ "AuthError", "WIFI_CONNECT_FAILED_REASON__AuthError", 0 },
|
||||
{ "NetworkNotFound", "WIFI_CONNECT_FAILED_REASON__NetworkNotFound", 1 },
|
||||
};
|
||||
static const ProtobufCIntRange wifi_connect_failed_reason__value_ranges[] = {
|
||||
{0, 0},{0, 2}
|
||||
};
|
||||
static const ProtobufCEnumValueIndex wifi_connect_failed_reason__enum_values_by_name[2] =
|
||||
{
|
||||
{ "AuthError", 0 },
|
||||
{ "NetworkNotFound", 1 },
|
||||
};
|
||||
const ProtobufCEnumDescriptor wifi_connect_failed_reason__descriptor =
|
||||
{
|
||||
PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC,
|
||||
"WifiConnectFailedReason",
|
||||
"WifiConnectFailedReason",
|
||||
"WifiConnectFailedReason",
|
||||
"",
|
||||
2,
|
||||
wifi_connect_failed_reason__enum_values_by_number,
|
||||
2,
|
||||
wifi_connect_failed_reason__enum_values_by_name,
|
||||
1,
|
||||
wifi_connect_failed_reason__value_ranges,
|
||||
NULL,NULL,NULL,NULL /* reserved[1234] */
|
||||
};
|
||||
static const ProtobufCEnumValue wifi_auth_mode__enum_values_by_number[8] =
|
||||
{
|
||||
{ "Open", "WIFI_AUTH_MODE__Open", 0 },
|
||||
{ "WEP", "WIFI_AUTH_MODE__WEP", 1 },
|
||||
{ "WPA_PSK", "WIFI_AUTH_MODE__WPA_PSK", 2 },
|
||||
{ "WPA2_PSK", "WIFI_AUTH_MODE__WPA2_PSK", 3 },
|
||||
{ "WPA_WPA2_PSK", "WIFI_AUTH_MODE__WPA_WPA2_PSK", 4 },
|
||||
{ "WPA2_ENTERPRISE", "WIFI_AUTH_MODE__WPA2_ENTERPRISE", 5 },
|
||||
{ "WPA3_PSK", "WIFI_AUTH_MODE__WPA3_PSK", 6 },
|
||||
{ "WPA2_WPA3_PSK", "WIFI_AUTH_MODE__WPA2_WPA3_PSK", 7 },
|
||||
};
|
||||
static const ProtobufCIntRange wifi_auth_mode__value_ranges[] = {
|
||||
{0, 0},{0, 8}
|
||||
};
|
||||
static const ProtobufCEnumValueIndex wifi_auth_mode__enum_values_by_name[8] =
|
||||
{
|
||||
{ "Open", 0 },
|
||||
{ "WEP", 1 },
|
||||
{ "WPA2_ENTERPRISE", 5 },
|
||||
{ "WPA2_PSK", 3 },
|
||||
{ "WPA2_WPA3_PSK", 7 },
|
||||
{ "WPA3_PSK", 6 },
|
||||
{ "WPA_PSK", 2 },
|
||||
{ "WPA_WPA2_PSK", 4 },
|
||||
};
|
||||
const ProtobufCEnumDescriptor wifi_auth_mode__descriptor =
|
||||
{
|
||||
PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC,
|
||||
"WifiAuthMode",
|
||||
"WifiAuthMode",
|
||||
"WifiAuthMode",
|
||||
"",
|
||||
8,
|
||||
wifi_auth_mode__enum_values_by_number,
|
||||
8,
|
||||
wifi_auth_mode__enum_values_by_name,
|
||||
1,
|
||||
wifi_auth_mode__value_ranges,
|
||||
NULL,NULL,NULL,NULL /* reserved[1234] */
|
||||
};
|
@@ -1,135 +0,0 @@
|
||||
/* Generated by the protocol buffer compiler. DO NOT EDIT! */
|
||||
/* Generated from: wifi_constants.proto */
|
||||
|
||||
#ifndef PROTOBUF_C_wifi_5fconstants_2eproto__INCLUDED
|
||||
#define PROTOBUF_C_wifi_5fconstants_2eproto__INCLUDED
|
||||
|
||||
#include <protobuf-c/protobuf-c.h>
|
||||
|
||||
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 1004001 < 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 WifiAttemptFailed WifiAttemptFailed;
|
||||
typedef struct WifiConnectedState WifiConnectedState;
|
||||
|
||||
|
||||
/* --- enums --- */
|
||||
|
||||
typedef enum _WifiStationState {
|
||||
WIFI_STATION_STATE__Connected = 0,
|
||||
WIFI_STATION_STATE__Connecting = 1,
|
||||
WIFI_STATION_STATE__Disconnected = 2,
|
||||
WIFI_STATION_STATE__ConnectionFailed = 3
|
||||
PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(WIFI_STATION_STATE)
|
||||
} WifiStationState;
|
||||
typedef enum _WifiConnectFailedReason {
|
||||
WIFI_CONNECT_FAILED_REASON__AuthError = 0,
|
||||
WIFI_CONNECT_FAILED_REASON__NetworkNotFound = 1
|
||||
PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(WIFI_CONNECT_FAILED_REASON)
|
||||
} WifiConnectFailedReason;
|
||||
typedef enum _WifiAuthMode {
|
||||
WIFI_AUTH_MODE__Open = 0,
|
||||
WIFI_AUTH_MODE__WEP = 1,
|
||||
WIFI_AUTH_MODE__WPA_PSK = 2,
|
||||
WIFI_AUTH_MODE__WPA2_PSK = 3,
|
||||
WIFI_AUTH_MODE__WPA_WPA2_PSK = 4,
|
||||
WIFI_AUTH_MODE__WPA2_ENTERPRISE = 5,
|
||||
WIFI_AUTH_MODE__WPA3_PSK = 6,
|
||||
WIFI_AUTH_MODE__WPA2_WPA3_PSK = 7
|
||||
PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(WIFI_AUTH_MODE)
|
||||
} WifiAuthMode;
|
||||
|
||||
/* --- messages --- */
|
||||
|
||||
struct WifiAttemptFailed
|
||||
{
|
||||
ProtobufCMessage base;
|
||||
uint32_t attempts_remaining;
|
||||
};
|
||||
#define WIFI_ATTEMPT_FAILED__INIT \
|
||||
{ PROTOBUF_C_MESSAGE_INIT (&wifi_attempt_failed__descriptor) \
|
||||
, 0 }
|
||||
|
||||
|
||||
struct WifiConnectedState
|
||||
{
|
||||
ProtobufCMessage base;
|
||||
char *ip4_addr;
|
||||
WifiAuthMode auth_mode;
|
||||
ProtobufCBinaryData ssid;
|
||||
ProtobufCBinaryData bssid;
|
||||
int32_t channel;
|
||||
};
|
||||
#define WIFI_CONNECTED_STATE__INIT \
|
||||
{ PROTOBUF_C_MESSAGE_INIT (&wifi_connected_state__descriptor) \
|
||||
, (char *)protobuf_c_empty_string, WIFI_AUTH_MODE__Open, {0,NULL}, {0,NULL}, 0 }
|
||||
|
||||
|
||||
/* WifiAttemptFailed methods */
|
||||
void wifi_attempt_failed__init
|
||||
(WifiAttemptFailed *message);
|
||||
size_t wifi_attempt_failed__get_packed_size
|
||||
(const WifiAttemptFailed *message);
|
||||
size_t wifi_attempt_failed__pack
|
||||
(const WifiAttemptFailed *message,
|
||||
uint8_t *out);
|
||||
size_t wifi_attempt_failed__pack_to_buffer
|
||||
(const WifiAttemptFailed *message,
|
||||
ProtobufCBuffer *buffer);
|
||||
WifiAttemptFailed *
|
||||
wifi_attempt_failed__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data);
|
||||
void wifi_attempt_failed__free_unpacked
|
||||
(WifiAttemptFailed *message,
|
||||
ProtobufCAllocator *allocator);
|
||||
/* WifiConnectedState methods */
|
||||
void wifi_connected_state__init
|
||||
(WifiConnectedState *message);
|
||||
size_t wifi_connected_state__get_packed_size
|
||||
(const WifiConnectedState *message);
|
||||
size_t wifi_connected_state__pack
|
||||
(const WifiConnectedState *message,
|
||||
uint8_t *out);
|
||||
size_t wifi_connected_state__pack_to_buffer
|
||||
(const WifiConnectedState *message,
|
||||
ProtobufCBuffer *buffer);
|
||||
WifiConnectedState *
|
||||
wifi_connected_state__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data);
|
||||
void wifi_connected_state__free_unpacked
|
||||
(WifiConnectedState *message,
|
||||
ProtobufCAllocator *allocator);
|
||||
/* --- per-message closures --- */
|
||||
|
||||
typedef void (*WifiAttemptFailed_Closure)
|
||||
(const WifiAttemptFailed *message,
|
||||
void *closure_data);
|
||||
typedef void (*WifiConnectedState_Closure)
|
||||
(const WifiConnectedState *message,
|
||||
void *closure_data);
|
||||
|
||||
/* --- services --- */
|
||||
|
||||
|
||||
/* --- descriptors --- */
|
||||
|
||||
extern const ProtobufCEnumDescriptor wifi_station_state__descriptor;
|
||||
extern const ProtobufCEnumDescriptor wifi_connect_failed_reason__descriptor;
|
||||
extern const ProtobufCEnumDescriptor wifi_auth_mode__descriptor;
|
||||
extern const ProtobufCMessageDescriptor wifi_attempt_failed__descriptor;
|
||||
extern const ProtobufCMessageDescriptor wifi_connected_state__descriptor;
|
||||
|
||||
PROTOBUF_C__END_DECLS
|
||||
|
||||
|
||||
#endif /* PROTOBUF_C_wifi_5fconstants_2eproto__INCLUDED */
|
@@ -1,444 +0,0 @@
|
||||
/* Generated by the protocol buffer compiler. DO NOT EDIT! */
|
||||
/* Generated from: wifi_ctrl.proto */
|
||||
|
||||
/* Do not generate deprecated warnings for self */
|
||||
#ifndef PROTOBUF_C__NO_DEPRECATED
|
||||
#define PROTOBUF_C__NO_DEPRECATED
|
||||
#endif
|
||||
|
||||
#include "wifi_ctrl.pb-c.h"
|
||||
void cmd_ctrl_reset__init
|
||||
(CmdCtrlReset *message)
|
||||
{
|
||||
static const CmdCtrlReset init_value = CMD_CTRL_RESET__INIT;
|
||||
*message = init_value;
|
||||
}
|
||||
size_t cmd_ctrl_reset__get_packed_size
|
||||
(const CmdCtrlReset *message)
|
||||
{
|
||||
assert(message->base.descriptor == &cmd_ctrl_reset__descriptor);
|
||||
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
|
||||
}
|
||||
size_t cmd_ctrl_reset__pack
|
||||
(const CmdCtrlReset *message,
|
||||
uint8_t *out)
|
||||
{
|
||||
assert(message->base.descriptor == &cmd_ctrl_reset__descriptor);
|
||||
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
|
||||
}
|
||||
size_t cmd_ctrl_reset__pack_to_buffer
|
||||
(const CmdCtrlReset *message,
|
||||
ProtobufCBuffer *buffer)
|
||||
{
|
||||
assert(message->base.descriptor == &cmd_ctrl_reset__descriptor);
|
||||
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
|
||||
}
|
||||
CmdCtrlReset *
|
||||
cmd_ctrl_reset__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data)
|
||||
{
|
||||
return (CmdCtrlReset *)
|
||||
protobuf_c_message_unpack (&cmd_ctrl_reset__descriptor,
|
||||
allocator, len, data);
|
||||
}
|
||||
void cmd_ctrl_reset__free_unpacked
|
||||
(CmdCtrlReset *message,
|
||||
ProtobufCAllocator *allocator)
|
||||
{
|
||||
if(!message)
|
||||
return;
|
||||
assert(message->base.descriptor == &cmd_ctrl_reset__descriptor);
|
||||
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
|
||||
}
|
||||
void resp_ctrl_reset__init
|
||||
(RespCtrlReset *message)
|
||||
{
|
||||
static const RespCtrlReset init_value = RESP_CTRL_RESET__INIT;
|
||||
*message = init_value;
|
||||
}
|
||||
size_t resp_ctrl_reset__get_packed_size
|
||||
(const RespCtrlReset *message)
|
||||
{
|
||||
assert(message->base.descriptor == &resp_ctrl_reset__descriptor);
|
||||
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
|
||||
}
|
||||
size_t resp_ctrl_reset__pack
|
||||
(const RespCtrlReset *message,
|
||||
uint8_t *out)
|
||||
{
|
||||
assert(message->base.descriptor == &resp_ctrl_reset__descriptor);
|
||||
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
|
||||
}
|
||||
size_t resp_ctrl_reset__pack_to_buffer
|
||||
(const RespCtrlReset *message,
|
||||
ProtobufCBuffer *buffer)
|
||||
{
|
||||
assert(message->base.descriptor == &resp_ctrl_reset__descriptor);
|
||||
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
|
||||
}
|
||||
RespCtrlReset *
|
||||
resp_ctrl_reset__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data)
|
||||
{
|
||||
return (RespCtrlReset *)
|
||||
protobuf_c_message_unpack (&resp_ctrl_reset__descriptor,
|
||||
allocator, len, data);
|
||||
}
|
||||
void resp_ctrl_reset__free_unpacked
|
||||
(RespCtrlReset *message,
|
||||
ProtobufCAllocator *allocator)
|
||||
{
|
||||
if(!message)
|
||||
return;
|
||||
assert(message->base.descriptor == &resp_ctrl_reset__descriptor);
|
||||
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
|
||||
}
|
||||
void cmd_ctrl_reprov__init
|
||||
(CmdCtrlReprov *message)
|
||||
{
|
||||
static const CmdCtrlReprov init_value = CMD_CTRL_REPROV__INIT;
|
||||
*message = init_value;
|
||||
}
|
||||
size_t cmd_ctrl_reprov__get_packed_size
|
||||
(const CmdCtrlReprov *message)
|
||||
{
|
||||
assert(message->base.descriptor == &cmd_ctrl_reprov__descriptor);
|
||||
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
|
||||
}
|
||||
size_t cmd_ctrl_reprov__pack
|
||||
(const CmdCtrlReprov *message,
|
||||
uint8_t *out)
|
||||
{
|
||||
assert(message->base.descriptor == &cmd_ctrl_reprov__descriptor);
|
||||
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
|
||||
}
|
||||
size_t cmd_ctrl_reprov__pack_to_buffer
|
||||
(const CmdCtrlReprov *message,
|
||||
ProtobufCBuffer *buffer)
|
||||
{
|
||||
assert(message->base.descriptor == &cmd_ctrl_reprov__descriptor);
|
||||
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
|
||||
}
|
||||
CmdCtrlReprov *
|
||||
cmd_ctrl_reprov__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data)
|
||||
{
|
||||
return (CmdCtrlReprov *)
|
||||
protobuf_c_message_unpack (&cmd_ctrl_reprov__descriptor,
|
||||
allocator, len, data);
|
||||
}
|
||||
void cmd_ctrl_reprov__free_unpacked
|
||||
(CmdCtrlReprov *message,
|
||||
ProtobufCAllocator *allocator)
|
||||
{
|
||||
if(!message)
|
||||
return;
|
||||
assert(message->base.descriptor == &cmd_ctrl_reprov__descriptor);
|
||||
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
|
||||
}
|
||||
void resp_ctrl_reprov__init
|
||||
(RespCtrlReprov *message)
|
||||
{
|
||||
static const RespCtrlReprov init_value = RESP_CTRL_REPROV__INIT;
|
||||
*message = init_value;
|
||||
}
|
||||
size_t resp_ctrl_reprov__get_packed_size
|
||||
(const RespCtrlReprov *message)
|
||||
{
|
||||
assert(message->base.descriptor == &resp_ctrl_reprov__descriptor);
|
||||
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
|
||||
}
|
||||
size_t resp_ctrl_reprov__pack
|
||||
(const RespCtrlReprov *message,
|
||||
uint8_t *out)
|
||||
{
|
||||
assert(message->base.descriptor == &resp_ctrl_reprov__descriptor);
|
||||
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
|
||||
}
|
||||
size_t resp_ctrl_reprov__pack_to_buffer
|
||||
(const RespCtrlReprov *message,
|
||||
ProtobufCBuffer *buffer)
|
||||
{
|
||||
assert(message->base.descriptor == &resp_ctrl_reprov__descriptor);
|
||||
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
|
||||
}
|
||||
RespCtrlReprov *
|
||||
resp_ctrl_reprov__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data)
|
||||
{
|
||||
return (RespCtrlReprov *)
|
||||
protobuf_c_message_unpack (&resp_ctrl_reprov__descriptor,
|
||||
allocator, len, data);
|
||||
}
|
||||
void resp_ctrl_reprov__free_unpacked
|
||||
(RespCtrlReprov *message,
|
||||
ProtobufCAllocator *allocator)
|
||||
{
|
||||
if(!message)
|
||||
return;
|
||||
assert(message->base.descriptor == &resp_ctrl_reprov__descriptor);
|
||||
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
|
||||
}
|
||||
void wi_fi_ctrl_payload__init
|
||||
(WiFiCtrlPayload *message)
|
||||
{
|
||||
static const WiFiCtrlPayload init_value = WI_FI_CTRL_PAYLOAD__INIT;
|
||||
*message = init_value;
|
||||
}
|
||||
size_t wi_fi_ctrl_payload__get_packed_size
|
||||
(const WiFiCtrlPayload *message)
|
||||
{
|
||||
assert(message->base.descriptor == &wi_fi_ctrl_payload__descriptor);
|
||||
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
|
||||
}
|
||||
size_t wi_fi_ctrl_payload__pack
|
||||
(const WiFiCtrlPayload *message,
|
||||
uint8_t *out)
|
||||
{
|
||||
assert(message->base.descriptor == &wi_fi_ctrl_payload__descriptor);
|
||||
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
|
||||
}
|
||||
size_t wi_fi_ctrl_payload__pack_to_buffer
|
||||
(const WiFiCtrlPayload *message,
|
||||
ProtobufCBuffer *buffer)
|
||||
{
|
||||
assert(message->base.descriptor == &wi_fi_ctrl_payload__descriptor);
|
||||
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
|
||||
}
|
||||
WiFiCtrlPayload *
|
||||
wi_fi_ctrl_payload__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data)
|
||||
{
|
||||
return (WiFiCtrlPayload *)
|
||||
protobuf_c_message_unpack (&wi_fi_ctrl_payload__descriptor,
|
||||
allocator, len, data);
|
||||
}
|
||||
void wi_fi_ctrl_payload__free_unpacked
|
||||
(WiFiCtrlPayload *message,
|
||||
ProtobufCAllocator *allocator)
|
||||
{
|
||||
if(!message)
|
||||
return;
|
||||
assert(message->base.descriptor == &wi_fi_ctrl_payload__descriptor);
|
||||
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
|
||||
}
|
||||
#define cmd_ctrl_reset__field_descriptors NULL
|
||||
#define cmd_ctrl_reset__field_indices_by_name NULL
|
||||
#define cmd_ctrl_reset__number_ranges NULL
|
||||
const ProtobufCMessageDescriptor cmd_ctrl_reset__descriptor =
|
||||
{
|
||||
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
|
||||
"CmdCtrlReset",
|
||||
"CmdCtrlReset",
|
||||
"CmdCtrlReset",
|
||||
"",
|
||||
sizeof(CmdCtrlReset),
|
||||
0,
|
||||
cmd_ctrl_reset__field_descriptors,
|
||||
cmd_ctrl_reset__field_indices_by_name,
|
||||
0, cmd_ctrl_reset__number_ranges,
|
||||
(ProtobufCMessageInit) cmd_ctrl_reset__init,
|
||||
NULL,NULL,NULL /* reserved[123] */
|
||||
};
|
||||
#define resp_ctrl_reset__field_descriptors NULL
|
||||
#define resp_ctrl_reset__field_indices_by_name NULL
|
||||
#define resp_ctrl_reset__number_ranges NULL
|
||||
const ProtobufCMessageDescriptor resp_ctrl_reset__descriptor =
|
||||
{
|
||||
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
|
||||
"RespCtrlReset",
|
||||
"RespCtrlReset",
|
||||
"RespCtrlReset",
|
||||
"",
|
||||
sizeof(RespCtrlReset),
|
||||
0,
|
||||
resp_ctrl_reset__field_descriptors,
|
||||
resp_ctrl_reset__field_indices_by_name,
|
||||
0, resp_ctrl_reset__number_ranges,
|
||||
(ProtobufCMessageInit) resp_ctrl_reset__init,
|
||||
NULL,NULL,NULL /* reserved[123] */
|
||||
};
|
||||
#define cmd_ctrl_reprov__field_descriptors NULL
|
||||
#define cmd_ctrl_reprov__field_indices_by_name NULL
|
||||
#define cmd_ctrl_reprov__number_ranges NULL
|
||||
const ProtobufCMessageDescriptor cmd_ctrl_reprov__descriptor =
|
||||
{
|
||||
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
|
||||
"CmdCtrlReprov",
|
||||
"CmdCtrlReprov",
|
||||
"CmdCtrlReprov",
|
||||
"",
|
||||
sizeof(CmdCtrlReprov),
|
||||
0,
|
||||
cmd_ctrl_reprov__field_descriptors,
|
||||
cmd_ctrl_reprov__field_indices_by_name,
|
||||
0, cmd_ctrl_reprov__number_ranges,
|
||||
(ProtobufCMessageInit) cmd_ctrl_reprov__init,
|
||||
NULL,NULL,NULL /* reserved[123] */
|
||||
};
|
||||
#define resp_ctrl_reprov__field_descriptors NULL
|
||||
#define resp_ctrl_reprov__field_indices_by_name NULL
|
||||
#define resp_ctrl_reprov__number_ranges NULL
|
||||
const ProtobufCMessageDescriptor resp_ctrl_reprov__descriptor =
|
||||
{
|
||||
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
|
||||
"RespCtrlReprov",
|
||||
"RespCtrlReprov",
|
||||
"RespCtrlReprov",
|
||||
"",
|
||||
sizeof(RespCtrlReprov),
|
||||
0,
|
||||
resp_ctrl_reprov__field_descriptors,
|
||||
resp_ctrl_reprov__field_indices_by_name,
|
||||
0, resp_ctrl_reprov__number_ranges,
|
||||
(ProtobufCMessageInit) resp_ctrl_reprov__init,
|
||||
NULL,NULL,NULL /* reserved[123] */
|
||||
};
|
||||
static const ProtobufCFieldDescriptor wi_fi_ctrl_payload__field_descriptors[6] =
|
||||
{
|
||||
{
|
||||
"msg",
|
||||
1,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_ENUM,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(WiFiCtrlPayload, msg),
|
||||
&wi_fi_ctrl_msg_type__descriptor,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"status",
|
||||
2,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_ENUM,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(WiFiCtrlPayload, status),
|
||||
&status__descriptor,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"cmd_ctrl_reset",
|
||||
11,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_MESSAGE,
|
||||
offsetof(WiFiCtrlPayload, payload_case),
|
||||
offsetof(WiFiCtrlPayload, cmd_ctrl_reset),
|
||||
&cmd_ctrl_reset__descriptor,
|
||||
NULL,
|
||||
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"resp_ctrl_reset",
|
||||
12,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_MESSAGE,
|
||||
offsetof(WiFiCtrlPayload, payload_case),
|
||||
offsetof(WiFiCtrlPayload, resp_ctrl_reset),
|
||||
&resp_ctrl_reset__descriptor,
|
||||
NULL,
|
||||
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"cmd_ctrl_reprov",
|
||||
13,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_MESSAGE,
|
||||
offsetof(WiFiCtrlPayload, payload_case),
|
||||
offsetof(WiFiCtrlPayload, cmd_ctrl_reprov),
|
||||
&cmd_ctrl_reprov__descriptor,
|
||||
NULL,
|
||||
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"resp_ctrl_reprov",
|
||||
14,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_MESSAGE,
|
||||
offsetof(WiFiCtrlPayload, payload_case),
|
||||
offsetof(WiFiCtrlPayload, resp_ctrl_reprov),
|
||||
&resp_ctrl_reprov__descriptor,
|
||||
NULL,
|
||||
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
};
|
||||
static const unsigned wi_fi_ctrl_payload__field_indices_by_name[] = {
|
||||
4, /* field[4] = cmd_ctrl_reprov */
|
||||
2, /* field[2] = cmd_ctrl_reset */
|
||||
0, /* field[0] = msg */
|
||||
5, /* field[5] = resp_ctrl_reprov */
|
||||
3, /* field[3] = resp_ctrl_reset */
|
||||
1, /* field[1] = status */
|
||||
};
|
||||
static const ProtobufCIntRange wi_fi_ctrl_payload__number_ranges[2 + 1] =
|
||||
{
|
||||
{ 1, 0 },
|
||||
{ 11, 2 },
|
||||
{ 0, 6 }
|
||||
};
|
||||
const ProtobufCMessageDescriptor wi_fi_ctrl_payload__descriptor =
|
||||
{
|
||||
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
|
||||
"WiFiCtrlPayload",
|
||||
"WiFiCtrlPayload",
|
||||
"WiFiCtrlPayload",
|
||||
"",
|
||||
sizeof(WiFiCtrlPayload),
|
||||
6,
|
||||
wi_fi_ctrl_payload__field_descriptors,
|
||||
wi_fi_ctrl_payload__field_indices_by_name,
|
||||
2, wi_fi_ctrl_payload__number_ranges,
|
||||
(ProtobufCMessageInit) wi_fi_ctrl_payload__init,
|
||||
NULL,NULL,NULL /* reserved[123] */
|
||||
};
|
||||
static const ProtobufCEnumValue wi_fi_ctrl_msg_type__enum_values_by_number[5] =
|
||||
{
|
||||
{ "TypeCtrlReserved", "WI_FI_CTRL_MSG_TYPE__TypeCtrlReserved", 0 },
|
||||
{ "TypeCmdCtrlReset", "WI_FI_CTRL_MSG_TYPE__TypeCmdCtrlReset", 1 },
|
||||
{ "TypeRespCtrlReset", "WI_FI_CTRL_MSG_TYPE__TypeRespCtrlReset", 2 },
|
||||
{ "TypeCmdCtrlReprov", "WI_FI_CTRL_MSG_TYPE__TypeCmdCtrlReprov", 3 },
|
||||
{ "TypeRespCtrlReprov", "WI_FI_CTRL_MSG_TYPE__TypeRespCtrlReprov", 4 },
|
||||
};
|
||||
static const ProtobufCIntRange wi_fi_ctrl_msg_type__value_ranges[] = {
|
||||
{0, 0},{0, 5}
|
||||
};
|
||||
static const ProtobufCEnumValueIndex wi_fi_ctrl_msg_type__enum_values_by_name[5] =
|
||||
{
|
||||
{ "TypeCmdCtrlReprov", 3 },
|
||||
{ "TypeCmdCtrlReset", 1 },
|
||||
{ "TypeCtrlReserved", 0 },
|
||||
{ "TypeRespCtrlReprov", 4 },
|
||||
{ "TypeRespCtrlReset", 2 },
|
||||
};
|
||||
const ProtobufCEnumDescriptor wi_fi_ctrl_msg_type__descriptor =
|
||||
{
|
||||
PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC,
|
||||
"WiFiCtrlMsgType",
|
||||
"WiFiCtrlMsgType",
|
||||
"WiFiCtrlMsgType",
|
||||
"",
|
||||
5,
|
||||
wi_fi_ctrl_msg_type__enum_values_by_number,
|
||||
5,
|
||||
wi_fi_ctrl_msg_type__enum_values_by_name,
|
||||
1,
|
||||
wi_fi_ctrl_msg_type__value_ranges,
|
||||
NULL,NULL,NULL,NULL /* reserved[1234] */
|
||||
};
|
@@ -1,230 +0,0 @@
|
||||
/* Generated by the protocol buffer compiler. DO NOT EDIT! */
|
||||
/* Generated from: wifi_ctrl.proto */
|
||||
|
||||
#ifndef PROTOBUF_C_wifi_5fctrl_2eproto__INCLUDED
|
||||
#define PROTOBUF_C_wifi_5fctrl_2eproto__INCLUDED
|
||||
|
||||
#include <protobuf-c/protobuf-c.h>
|
||||
|
||||
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 1004001 < 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
|
||||
|
||||
#include "constants.pb-c.h"
|
||||
|
||||
typedef struct CmdCtrlReset CmdCtrlReset;
|
||||
typedef struct RespCtrlReset RespCtrlReset;
|
||||
typedef struct CmdCtrlReprov CmdCtrlReprov;
|
||||
typedef struct RespCtrlReprov RespCtrlReprov;
|
||||
typedef struct WiFiCtrlPayload WiFiCtrlPayload;
|
||||
|
||||
|
||||
/* --- enums --- */
|
||||
|
||||
typedef enum _WiFiCtrlMsgType {
|
||||
WI_FI_CTRL_MSG_TYPE__TypeCtrlReserved = 0,
|
||||
WI_FI_CTRL_MSG_TYPE__TypeCmdCtrlReset = 1,
|
||||
WI_FI_CTRL_MSG_TYPE__TypeRespCtrlReset = 2,
|
||||
WI_FI_CTRL_MSG_TYPE__TypeCmdCtrlReprov = 3,
|
||||
WI_FI_CTRL_MSG_TYPE__TypeRespCtrlReprov = 4
|
||||
PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(WI_FI_CTRL_MSG_TYPE)
|
||||
} WiFiCtrlMsgType;
|
||||
|
||||
/* --- messages --- */
|
||||
|
||||
struct CmdCtrlReset
|
||||
{
|
||||
ProtobufCMessage base;
|
||||
};
|
||||
#define CMD_CTRL_RESET__INIT \
|
||||
{ PROTOBUF_C_MESSAGE_INIT (&cmd_ctrl_reset__descriptor) \
|
||||
}
|
||||
|
||||
|
||||
struct RespCtrlReset
|
||||
{
|
||||
ProtobufCMessage base;
|
||||
};
|
||||
#define RESP_CTRL_RESET__INIT \
|
||||
{ PROTOBUF_C_MESSAGE_INIT (&resp_ctrl_reset__descriptor) \
|
||||
}
|
||||
|
||||
|
||||
struct CmdCtrlReprov
|
||||
{
|
||||
ProtobufCMessage base;
|
||||
};
|
||||
#define CMD_CTRL_REPROV__INIT \
|
||||
{ PROTOBUF_C_MESSAGE_INIT (&cmd_ctrl_reprov__descriptor) \
|
||||
}
|
||||
|
||||
|
||||
struct RespCtrlReprov
|
||||
{
|
||||
ProtobufCMessage base;
|
||||
};
|
||||
#define RESP_CTRL_REPROV__INIT \
|
||||
{ PROTOBUF_C_MESSAGE_INIT (&resp_ctrl_reprov__descriptor) \
|
||||
}
|
||||
|
||||
|
||||
typedef enum {
|
||||
WI_FI_CTRL_PAYLOAD__PAYLOAD__NOT_SET = 0,
|
||||
WI_FI_CTRL_PAYLOAD__PAYLOAD_CMD_CTRL_RESET = 11,
|
||||
WI_FI_CTRL_PAYLOAD__PAYLOAD_RESP_CTRL_RESET = 12,
|
||||
WI_FI_CTRL_PAYLOAD__PAYLOAD_CMD_CTRL_REPROV = 13,
|
||||
WI_FI_CTRL_PAYLOAD__PAYLOAD_RESP_CTRL_REPROV = 14
|
||||
PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(WI_FI_CTRL_PAYLOAD__PAYLOAD__CASE)
|
||||
} WiFiCtrlPayload__PayloadCase;
|
||||
|
||||
struct WiFiCtrlPayload
|
||||
{
|
||||
ProtobufCMessage base;
|
||||
WiFiCtrlMsgType msg;
|
||||
Status status;
|
||||
WiFiCtrlPayload__PayloadCase payload_case;
|
||||
union {
|
||||
CmdCtrlReset *cmd_ctrl_reset;
|
||||
RespCtrlReset *resp_ctrl_reset;
|
||||
CmdCtrlReprov *cmd_ctrl_reprov;
|
||||
RespCtrlReprov *resp_ctrl_reprov;
|
||||
};
|
||||
};
|
||||
#define WI_FI_CTRL_PAYLOAD__INIT \
|
||||
{ PROTOBUF_C_MESSAGE_INIT (&wi_fi_ctrl_payload__descriptor) \
|
||||
, WI_FI_CTRL_MSG_TYPE__TypeCtrlReserved, STATUS__Success, WI_FI_CTRL_PAYLOAD__PAYLOAD__NOT_SET, {0} }
|
||||
|
||||
|
||||
/* CmdCtrlReset methods */
|
||||
void cmd_ctrl_reset__init
|
||||
(CmdCtrlReset *message);
|
||||
size_t cmd_ctrl_reset__get_packed_size
|
||||
(const CmdCtrlReset *message);
|
||||
size_t cmd_ctrl_reset__pack
|
||||
(const CmdCtrlReset *message,
|
||||
uint8_t *out);
|
||||
size_t cmd_ctrl_reset__pack_to_buffer
|
||||
(const CmdCtrlReset *message,
|
||||
ProtobufCBuffer *buffer);
|
||||
CmdCtrlReset *
|
||||
cmd_ctrl_reset__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data);
|
||||
void cmd_ctrl_reset__free_unpacked
|
||||
(CmdCtrlReset *message,
|
||||
ProtobufCAllocator *allocator);
|
||||
/* RespCtrlReset methods */
|
||||
void resp_ctrl_reset__init
|
||||
(RespCtrlReset *message);
|
||||
size_t resp_ctrl_reset__get_packed_size
|
||||
(const RespCtrlReset *message);
|
||||
size_t resp_ctrl_reset__pack
|
||||
(const RespCtrlReset *message,
|
||||
uint8_t *out);
|
||||
size_t resp_ctrl_reset__pack_to_buffer
|
||||
(const RespCtrlReset *message,
|
||||
ProtobufCBuffer *buffer);
|
||||
RespCtrlReset *
|
||||
resp_ctrl_reset__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data);
|
||||
void resp_ctrl_reset__free_unpacked
|
||||
(RespCtrlReset *message,
|
||||
ProtobufCAllocator *allocator);
|
||||
/* CmdCtrlReprov methods */
|
||||
void cmd_ctrl_reprov__init
|
||||
(CmdCtrlReprov *message);
|
||||
size_t cmd_ctrl_reprov__get_packed_size
|
||||
(const CmdCtrlReprov *message);
|
||||
size_t cmd_ctrl_reprov__pack
|
||||
(const CmdCtrlReprov *message,
|
||||
uint8_t *out);
|
||||
size_t cmd_ctrl_reprov__pack_to_buffer
|
||||
(const CmdCtrlReprov *message,
|
||||
ProtobufCBuffer *buffer);
|
||||
CmdCtrlReprov *
|
||||
cmd_ctrl_reprov__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data);
|
||||
void cmd_ctrl_reprov__free_unpacked
|
||||
(CmdCtrlReprov *message,
|
||||
ProtobufCAllocator *allocator);
|
||||
/* RespCtrlReprov methods */
|
||||
void resp_ctrl_reprov__init
|
||||
(RespCtrlReprov *message);
|
||||
size_t resp_ctrl_reprov__get_packed_size
|
||||
(const RespCtrlReprov *message);
|
||||
size_t resp_ctrl_reprov__pack
|
||||
(const RespCtrlReprov *message,
|
||||
uint8_t *out);
|
||||
size_t resp_ctrl_reprov__pack_to_buffer
|
||||
(const RespCtrlReprov *message,
|
||||
ProtobufCBuffer *buffer);
|
||||
RespCtrlReprov *
|
||||
resp_ctrl_reprov__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data);
|
||||
void resp_ctrl_reprov__free_unpacked
|
||||
(RespCtrlReprov *message,
|
||||
ProtobufCAllocator *allocator);
|
||||
/* WiFiCtrlPayload methods */
|
||||
void wi_fi_ctrl_payload__init
|
||||
(WiFiCtrlPayload *message);
|
||||
size_t wi_fi_ctrl_payload__get_packed_size
|
||||
(const WiFiCtrlPayload *message);
|
||||
size_t wi_fi_ctrl_payload__pack
|
||||
(const WiFiCtrlPayload *message,
|
||||
uint8_t *out);
|
||||
size_t wi_fi_ctrl_payload__pack_to_buffer
|
||||
(const WiFiCtrlPayload *message,
|
||||
ProtobufCBuffer *buffer);
|
||||
WiFiCtrlPayload *
|
||||
wi_fi_ctrl_payload__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data);
|
||||
void wi_fi_ctrl_payload__free_unpacked
|
||||
(WiFiCtrlPayload *message,
|
||||
ProtobufCAllocator *allocator);
|
||||
/* --- per-message closures --- */
|
||||
|
||||
typedef void (*CmdCtrlReset_Closure)
|
||||
(const CmdCtrlReset *message,
|
||||
void *closure_data);
|
||||
typedef void (*RespCtrlReset_Closure)
|
||||
(const RespCtrlReset *message,
|
||||
void *closure_data);
|
||||
typedef void (*CmdCtrlReprov_Closure)
|
||||
(const CmdCtrlReprov *message,
|
||||
void *closure_data);
|
||||
typedef void (*RespCtrlReprov_Closure)
|
||||
(const RespCtrlReprov *message,
|
||||
void *closure_data);
|
||||
typedef void (*WiFiCtrlPayload_Closure)
|
||||
(const WiFiCtrlPayload *message,
|
||||
void *closure_data);
|
||||
|
||||
/* --- services --- */
|
||||
|
||||
|
||||
/* --- descriptors --- */
|
||||
|
||||
extern const ProtobufCEnumDescriptor wi_fi_ctrl_msg_type__descriptor;
|
||||
extern const ProtobufCMessageDescriptor cmd_ctrl_reset__descriptor;
|
||||
extern const ProtobufCMessageDescriptor resp_ctrl_reset__descriptor;
|
||||
extern const ProtobufCMessageDescriptor cmd_ctrl_reprov__descriptor;
|
||||
extern const ProtobufCMessageDescriptor resp_ctrl_reprov__descriptor;
|
||||
extern const ProtobufCMessageDescriptor wi_fi_ctrl_payload__descriptor;
|
||||
|
||||
PROTOBUF_C__END_DECLS
|
||||
|
||||
|
||||
#endif /* PROTOBUF_C_wifi_5fctrl_2eproto__INCLUDED */
|
@@ -1,878 +0,0 @@
|
||||
/* Generated by the protocol buffer compiler. DO NOT EDIT! */
|
||||
/* Generated from: wifi_scan.proto */
|
||||
|
||||
/* Do not generate deprecated warnings for self */
|
||||
#ifndef PROTOBUF_C__NO_DEPRECATED
|
||||
#define PROTOBUF_C__NO_DEPRECATED
|
||||
#endif
|
||||
|
||||
#include "wifi_scan.pb-c.h"
|
||||
void cmd_scan_start__init
|
||||
(CmdScanStart *message)
|
||||
{
|
||||
static const CmdScanStart init_value = CMD_SCAN_START__INIT;
|
||||
*message = init_value;
|
||||
}
|
||||
size_t cmd_scan_start__get_packed_size
|
||||
(const CmdScanStart *message)
|
||||
{
|
||||
assert(message->base.descriptor == &cmd_scan_start__descriptor);
|
||||
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
|
||||
}
|
||||
size_t cmd_scan_start__pack
|
||||
(const CmdScanStart *message,
|
||||
uint8_t *out)
|
||||
{
|
||||
assert(message->base.descriptor == &cmd_scan_start__descriptor);
|
||||
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
|
||||
}
|
||||
size_t cmd_scan_start__pack_to_buffer
|
||||
(const CmdScanStart *message,
|
||||
ProtobufCBuffer *buffer)
|
||||
{
|
||||
assert(message->base.descriptor == &cmd_scan_start__descriptor);
|
||||
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
|
||||
}
|
||||
CmdScanStart *
|
||||
cmd_scan_start__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data)
|
||||
{
|
||||
return (CmdScanStart *)
|
||||
protobuf_c_message_unpack (&cmd_scan_start__descriptor,
|
||||
allocator, len, data);
|
||||
}
|
||||
void cmd_scan_start__free_unpacked
|
||||
(CmdScanStart *message,
|
||||
ProtobufCAllocator *allocator)
|
||||
{
|
||||
if(!message)
|
||||
return;
|
||||
assert(message->base.descriptor == &cmd_scan_start__descriptor);
|
||||
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
|
||||
}
|
||||
void resp_scan_start__init
|
||||
(RespScanStart *message)
|
||||
{
|
||||
static const RespScanStart init_value = RESP_SCAN_START__INIT;
|
||||
*message = init_value;
|
||||
}
|
||||
size_t resp_scan_start__get_packed_size
|
||||
(const RespScanStart *message)
|
||||
{
|
||||
assert(message->base.descriptor == &resp_scan_start__descriptor);
|
||||
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
|
||||
}
|
||||
size_t resp_scan_start__pack
|
||||
(const RespScanStart *message,
|
||||
uint8_t *out)
|
||||
{
|
||||
assert(message->base.descriptor == &resp_scan_start__descriptor);
|
||||
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
|
||||
}
|
||||
size_t resp_scan_start__pack_to_buffer
|
||||
(const RespScanStart *message,
|
||||
ProtobufCBuffer *buffer)
|
||||
{
|
||||
assert(message->base.descriptor == &resp_scan_start__descriptor);
|
||||
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
|
||||
}
|
||||
RespScanStart *
|
||||
resp_scan_start__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data)
|
||||
{
|
||||
return (RespScanStart *)
|
||||
protobuf_c_message_unpack (&resp_scan_start__descriptor,
|
||||
allocator, len, data);
|
||||
}
|
||||
void resp_scan_start__free_unpacked
|
||||
(RespScanStart *message,
|
||||
ProtobufCAllocator *allocator)
|
||||
{
|
||||
if(!message)
|
||||
return;
|
||||
assert(message->base.descriptor == &resp_scan_start__descriptor);
|
||||
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
|
||||
}
|
||||
void cmd_scan_status__init
|
||||
(CmdScanStatus *message)
|
||||
{
|
||||
static const CmdScanStatus init_value = CMD_SCAN_STATUS__INIT;
|
||||
*message = init_value;
|
||||
}
|
||||
size_t cmd_scan_status__get_packed_size
|
||||
(const CmdScanStatus *message)
|
||||
{
|
||||
assert(message->base.descriptor == &cmd_scan_status__descriptor);
|
||||
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
|
||||
}
|
||||
size_t cmd_scan_status__pack
|
||||
(const CmdScanStatus *message,
|
||||
uint8_t *out)
|
||||
{
|
||||
assert(message->base.descriptor == &cmd_scan_status__descriptor);
|
||||
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
|
||||
}
|
||||
size_t cmd_scan_status__pack_to_buffer
|
||||
(const CmdScanStatus *message,
|
||||
ProtobufCBuffer *buffer)
|
||||
{
|
||||
assert(message->base.descriptor == &cmd_scan_status__descriptor);
|
||||
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
|
||||
}
|
||||
CmdScanStatus *
|
||||
cmd_scan_status__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data)
|
||||
{
|
||||
return (CmdScanStatus *)
|
||||
protobuf_c_message_unpack (&cmd_scan_status__descriptor,
|
||||
allocator, len, data);
|
||||
}
|
||||
void cmd_scan_status__free_unpacked
|
||||
(CmdScanStatus *message,
|
||||
ProtobufCAllocator *allocator)
|
||||
{
|
||||
if(!message)
|
||||
return;
|
||||
assert(message->base.descriptor == &cmd_scan_status__descriptor);
|
||||
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
|
||||
}
|
||||
void resp_scan_status__init
|
||||
(RespScanStatus *message)
|
||||
{
|
||||
static const RespScanStatus init_value = RESP_SCAN_STATUS__INIT;
|
||||
*message = init_value;
|
||||
}
|
||||
size_t resp_scan_status__get_packed_size
|
||||
(const RespScanStatus *message)
|
||||
{
|
||||
assert(message->base.descriptor == &resp_scan_status__descriptor);
|
||||
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
|
||||
}
|
||||
size_t resp_scan_status__pack
|
||||
(const RespScanStatus *message,
|
||||
uint8_t *out)
|
||||
{
|
||||
assert(message->base.descriptor == &resp_scan_status__descriptor);
|
||||
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
|
||||
}
|
||||
size_t resp_scan_status__pack_to_buffer
|
||||
(const RespScanStatus *message,
|
||||
ProtobufCBuffer *buffer)
|
||||
{
|
||||
assert(message->base.descriptor == &resp_scan_status__descriptor);
|
||||
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
|
||||
}
|
||||
RespScanStatus *
|
||||
resp_scan_status__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data)
|
||||
{
|
||||
return (RespScanStatus *)
|
||||
protobuf_c_message_unpack (&resp_scan_status__descriptor,
|
||||
allocator, len, data);
|
||||
}
|
||||
void resp_scan_status__free_unpacked
|
||||
(RespScanStatus *message,
|
||||
ProtobufCAllocator *allocator)
|
||||
{
|
||||
if(!message)
|
||||
return;
|
||||
assert(message->base.descriptor == &resp_scan_status__descriptor);
|
||||
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
|
||||
}
|
||||
void cmd_scan_result__init
|
||||
(CmdScanResult *message)
|
||||
{
|
||||
static const CmdScanResult init_value = CMD_SCAN_RESULT__INIT;
|
||||
*message = init_value;
|
||||
}
|
||||
size_t cmd_scan_result__get_packed_size
|
||||
(const CmdScanResult *message)
|
||||
{
|
||||
assert(message->base.descriptor == &cmd_scan_result__descriptor);
|
||||
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
|
||||
}
|
||||
size_t cmd_scan_result__pack
|
||||
(const CmdScanResult *message,
|
||||
uint8_t *out)
|
||||
{
|
||||
assert(message->base.descriptor == &cmd_scan_result__descriptor);
|
||||
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
|
||||
}
|
||||
size_t cmd_scan_result__pack_to_buffer
|
||||
(const CmdScanResult *message,
|
||||
ProtobufCBuffer *buffer)
|
||||
{
|
||||
assert(message->base.descriptor == &cmd_scan_result__descriptor);
|
||||
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
|
||||
}
|
||||
CmdScanResult *
|
||||
cmd_scan_result__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data)
|
||||
{
|
||||
return (CmdScanResult *)
|
||||
protobuf_c_message_unpack (&cmd_scan_result__descriptor,
|
||||
allocator, len, data);
|
||||
}
|
||||
void cmd_scan_result__free_unpacked
|
||||
(CmdScanResult *message,
|
||||
ProtobufCAllocator *allocator)
|
||||
{
|
||||
if(!message)
|
||||
return;
|
||||
assert(message->base.descriptor == &cmd_scan_result__descriptor);
|
||||
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
|
||||
}
|
||||
void wi_fi_scan_result__init
|
||||
(WiFiScanResult *message)
|
||||
{
|
||||
static const WiFiScanResult init_value = WI_FI_SCAN_RESULT__INIT;
|
||||
*message = init_value;
|
||||
}
|
||||
size_t wi_fi_scan_result__get_packed_size
|
||||
(const WiFiScanResult *message)
|
||||
{
|
||||
assert(message->base.descriptor == &wi_fi_scan_result__descriptor);
|
||||
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
|
||||
}
|
||||
size_t wi_fi_scan_result__pack
|
||||
(const WiFiScanResult *message,
|
||||
uint8_t *out)
|
||||
{
|
||||
assert(message->base.descriptor == &wi_fi_scan_result__descriptor);
|
||||
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
|
||||
}
|
||||
size_t wi_fi_scan_result__pack_to_buffer
|
||||
(const WiFiScanResult *message,
|
||||
ProtobufCBuffer *buffer)
|
||||
{
|
||||
assert(message->base.descriptor == &wi_fi_scan_result__descriptor);
|
||||
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
|
||||
}
|
||||
WiFiScanResult *
|
||||
wi_fi_scan_result__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data)
|
||||
{
|
||||
return (WiFiScanResult *)
|
||||
protobuf_c_message_unpack (&wi_fi_scan_result__descriptor,
|
||||
allocator, len, data);
|
||||
}
|
||||
void wi_fi_scan_result__free_unpacked
|
||||
(WiFiScanResult *message,
|
||||
ProtobufCAllocator *allocator)
|
||||
{
|
||||
if(!message)
|
||||
return;
|
||||
assert(message->base.descriptor == &wi_fi_scan_result__descriptor);
|
||||
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
|
||||
}
|
||||
void resp_scan_result__init
|
||||
(RespScanResult *message)
|
||||
{
|
||||
static const RespScanResult init_value = RESP_SCAN_RESULT__INIT;
|
||||
*message = init_value;
|
||||
}
|
||||
size_t resp_scan_result__get_packed_size
|
||||
(const RespScanResult *message)
|
||||
{
|
||||
assert(message->base.descriptor == &resp_scan_result__descriptor);
|
||||
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
|
||||
}
|
||||
size_t resp_scan_result__pack
|
||||
(const RespScanResult *message,
|
||||
uint8_t *out)
|
||||
{
|
||||
assert(message->base.descriptor == &resp_scan_result__descriptor);
|
||||
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
|
||||
}
|
||||
size_t resp_scan_result__pack_to_buffer
|
||||
(const RespScanResult *message,
|
||||
ProtobufCBuffer *buffer)
|
||||
{
|
||||
assert(message->base.descriptor == &resp_scan_result__descriptor);
|
||||
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
|
||||
}
|
||||
RespScanResult *
|
||||
resp_scan_result__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data)
|
||||
{
|
||||
return (RespScanResult *)
|
||||
protobuf_c_message_unpack (&resp_scan_result__descriptor,
|
||||
allocator, len, data);
|
||||
}
|
||||
void resp_scan_result__free_unpacked
|
||||
(RespScanResult *message,
|
||||
ProtobufCAllocator *allocator)
|
||||
{
|
||||
if(!message)
|
||||
return;
|
||||
assert(message->base.descriptor == &resp_scan_result__descriptor);
|
||||
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
|
||||
}
|
||||
void wi_fi_scan_payload__init
|
||||
(WiFiScanPayload *message)
|
||||
{
|
||||
static const WiFiScanPayload init_value = WI_FI_SCAN_PAYLOAD__INIT;
|
||||
*message = init_value;
|
||||
}
|
||||
size_t wi_fi_scan_payload__get_packed_size
|
||||
(const WiFiScanPayload *message)
|
||||
{
|
||||
assert(message->base.descriptor == &wi_fi_scan_payload__descriptor);
|
||||
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
|
||||
}
|
||||
size_t wi_fi_scan_payload__pack
|
||||
(const WiFiScanPayload *message,
|
||||
uint8_t *out)
|
||||
{
|
||||
assert(message->base.descriptor == &wi_fi_scan_payload__descriptor);
|
||||
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
|
||||
}
|
||||
size_t wi_fi_scan_payload__pack_to_buffer
|
||||
(const WiFiScanPayload *message,
|
||||
ProtobufCBuffer *buffer)
|
||||
{
|
||||
assert(message->base.descriptor == &wi_fi_scan_payload__descriptor);
|
||||
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
|
||||
}
|
||||
WiFiScanPayload *
|
||||
wi_fi_scan_payload__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data)
|
||||
{
|
||||
return (WiFiScanPayload *)
|
||||
protobuf_c_message_unpack (&wi_fi_scan_payload__descriptor,
|
||||
allocator, len, data);
|
||||
}
|
||||
void wi_fi_scan_payload__free_unpacked
|
||||
(WiFiScanPayload *message,
|
||||
ProtobufCAllocator *allocator)
|
||||
{
|
||||
if(!message)
|
||||
return;
|
||||
assert(message->base.descriptor == &wi_fi_scan_payload__descriptor);
|
||||
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
|
||||
}
|
||||
static const ProtobufCFieldDescriptor cmd_scan_start__field_descriptors[4] =
|
||||
{
|
||||
{
|
||||
"blocking",
|
||||
1,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_BOOL,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(CmdScanStart, blocking),
|
||||
NULL,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"passive",
|
||||
2,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_BOOL,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(CmdScanStart, passive),
|
||||
NULL,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"group_channels",
|
||||
3,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_UINT32,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(CmdScanStart, group_channels),
|
||||
NULL,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"period_ms",
|
||||
4,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_UINT32,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(CmdScanStart, period_ms),
|
||||
NULL,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
};
|
||||
static const unsigned cmd_scan_start__field_indices_by_name[] = {
|
||||
0, /* field[0] = blocking */
|
||||
2, /* field[2] = group_channels */
|
||||
1, /* field[1] = passive */
|
||||
3, /* field[3] = period_ms */
|
||||
};
|
||||
static const ProtobufCIntRange cmd_scan_start__number_ranges[1 + 1] =
|
||||
{
|
||||
{ 1, 0 },
|
||||
{ 0, 4 }
|
||||
};
|
||||
const ProtobufCMessageDescriptor cmd_scan_start__descriptor =
|
||||
{
|
||||
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
|
||||
"CmdScanStart",
|
||||
"CmdScanStart",
|
||||
"CmdScanStart",
|
||||
"",
|
||||
sizeof(CmdScanStart),
|
||||
4,
|
||||
cmd_scan_start__field_descriptors,
|
||||
cmd_scan_start__field_indices_by_name,
|
||||
1, cmd_scan_start__number_ranges,
|
||||
(ProtobufCMessageInit) cmd_scan_start__init,
|
||||
NULL,NULL,NULL /* reserved[123] */
|
||||
};
|
||||
#define resp_scan_start__field_descriptors NULL
|
||||
#define resp_scan_start__field_indices_by_name NULL
|
||||
#define resp_scan_start__number_ranges NULL
|
||||
const ProtobufCMessageDescriptor resp_scan_start__descriptor =
|
||||
{
|
||||
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
|
||||
"RespScanStart",
|
||||
"RespScanStart",
|
||||
"RespScanStart",
|
||||
"",
|
||||
sizeof(RespScanStart),
|
||||
0,
|
||||
resp_scan_start__field_descriptors,
|
||||
resp_scan_start__field_indices_by_name,
|
||||
0, resp_scan_start__number_ranges,
|
||||
(ProtobufCMessageInit) resp_scan_start__init,
|
||||
NULL,NULL,NULL /* reserved[123] */
|
||||
};
|
||||
#define cmd_scan_status__field_descriptors NULL
|
||||
#define cmd_scan_status__field_indices_by_name NULL
|
||||
#define cmd_scan_status__number_ranges NULL
|
||||
const ProtobufCMessageDescriptor cmd_scan_status__descriptor =
|
||||
{
|
||||
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
|
||||
"CmdScanStatus",
|
||||
"CmdScanStatus",
|
||||
"CmdScanStatus",
|
||||
"",
|
||||
sizeof(CmdScanStatus),
|
||||
0,
|
||||
cmd_scan_status__field_descriptors,
|
||||
cmd_scan_status__field_indices_by_name,
|
||||
0, cmd_scan_status__number_ranges,
|
||||
(ProtobufCMessageInit) cmd_scan_status__init,
|
||||
NULL,NULL,NULL /* reserved[123] */
|
||||
};
|
||||
static const ProtobufCFieldDescriptor resp_scan_status__field_descriptors[2] =
|
||||
{
|
||||
{
|
||||
"scan_finished",
|
||||
1,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_BOOL,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(RespScanStatus, scan_finished),
|
||||
NULL,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"result_count",
|
||||
2,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_UINT32,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(RespScanStatus, result_count),
|
||||
NULL,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
};
|
||||
static const unsigned resp_scan_status__field_indices_by_name[] = {
|
||||
1, /* field[1] = result_count */
|
||||
0, /* field[0] = scan_finished */
|
||||
};
|
||||
static const ProtobufCIntRange resp_scan_status__number_ranges[1 + 1] =
|
||||
{
|
||||
{ 1, 0 },
|
||||
{ 0, 2 }
|
||||
};
|
||||
const ProtobufCMessageDescriptor resp_scan_status__descriptor =
|
||||
{
|
||||
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
|
||||
"RespScanStatus",
|
||||
"RespScanStatus",
|
||||
"RespScanStatus",
|
||||
"",
|
||||
sizeof(RespScanStatus),
|
||||
2,
|
||||
resp_scan_status__field_descriptors,
|
||||
resp_scan_status__field_indices_by_name,
|
||||
1, resp_scan_status__number_ranges,
|
||||
(ProtobufCMessageInit) resp_scan_status__init,
|
||||
NULL,NULL,NULL /* reserved[123] */
|
||||
};
|
||||
static const ProtobufCFieldDescriptor cmd_scan_result__field_descriptors[2] =
|
||||
{
|
||||
{
|
||||
"start_index",
|
||||
1,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_UINT32,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(CmdScanResult, start_index),
|
||||
NULL,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"count",
|
||||
2,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_UINT32,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(CmdScanResult, count),
|
||||
NULL,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
};
|
||||
static const unsigned cmd_scan_result__field_indices_by_name[] = {
|
||||
1, /* field[1] = count */
|
||||
0, /* field[0] = start_index */
|
||||
};
|
||||
static const ProtobufCIntRange cmd_scan_result__number_ranges[1 + 1] =
|
||||
{
|
||||
{ 1, 0 },
|
||||
{ 0, 2 }
|
||||
};
|
||||
const ProtobufCMessageDescriptor cmd_scan_result__descriptor =
|
||||
{
|
||||
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
|
||||
"CmdScanResult",
|
||||
"CmdScanResult",
|
||||
"CmdScanResult",
|
||||
"",
|
||||
sizeof(CmdScanResult),
|
||||
2,
|
||||
cmd_scan_result__field_descriptors,
|
||||
cmd_scan_result__field_indices_by_name,
|
||||
1, cmd_scan_result__number_ranges,
|
||||
(ProtobufCMessageInit) cmd_scan_result__init,
|
||||
NULL,NULL,NULL /* reserved[123] */
|
||||
};
|
||||
static const ProtobufCFieldDescriptor wi_fi_scan_result__field_descriptors[5] =
|
||||
{
|
||||
{
|
||||
"ssid",
|
||||
1,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_BYTES,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(WiFiScanResult, ssid),
|
||||
NULL,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"channel",
|
||||
2,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_UINT32,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(WiFiScanResult, channel),
|
||||
NULL,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"rssi",
|
||||
3,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_INT32,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(WiFiScanResult, rssi),
|
||||
NULL,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"bssid",
|
||||
4,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_BYTES,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(WiFiScanResult, bssid),
|
||||
NULL,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"auth",
|
||||
5,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_ENUM,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(WiFiScanResult, auth),
|
||||
&wifi_auth_mode__descriptor,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
};
|
||||
static const unsigned wi_fi_scan_result__field_indices_by_name[] = {
|
||||
4, /* field[4] = auth */
|
||||
3, /* field[3] = bssid */
|
||||
1, /* field[1] = channel */
|
||||
2, /* field[2] = rssi */
|
||||
0, /* field[0] = ssid */
|
||||
};
|
||||
static const ProtobufCIntRange wi_fi_scan_result__number_ranges[1 + 1] =
|
||||
{
|
||||
{ 1, 0 },
|
||||
{ 0, 5 }
|
||||
};
|
||||
const ProtobufCMessageDescriptor wi_fi_scan_result__descriptor =
|
||||
{
|
||||
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
|
||||
"WiFiScanResult",
|
||||
"WiFiScanResult",
|
||||
"WiFiScanResult",
|
||||
"",
|
||||
sizeof(WiFiScanResult),
|
||||
5,
|
||||
wi_fi_scan_result__field_descriptors,
|
||||
wi_fi_scan_result__field_indices_by_name,
|
||||
1, wi_fi_scan_result__number_ranges,
|
||||
(ProtobufCMessageInit) wi_fi_scan_result__init,
|
||||
NULL,NULL,NULL /* reserved[123] */
|
||||
};
|
||||
static const ProtobufCFieldDescriptor resp_scan_result__field_descriptors[1] =
|
||||
{
|
||||
{
|
||||
"entries",
|
||||
1,
|
||||
PROTOBUF_C_LABEL_REPEATED,
|
||||
PROTOBUF_C_TYPE_MESSAGE,
|
||||
offsetof(RespScanResult, n_entries),
|
||||
offsetof(RespScanResult, entries),
|
||||
&wi_fi_scan_result__descriptor,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
};
|
||||
static const unsigned resp_scan_result__field_indices_by_name[] = {
|
||||
0, /* field[0] = entries */
|
||||
};
|
||||
static const ProtobufCIntRange resp_scan_result__number_ranges[1 + 1] =
|
||||
{
|
||||
{ 1, 0 },
|
||||
{ 0, 1 }
|
||||
};
|
||||
const ProtobufCMessageDescriptor resp_scan_result__descriptor =
|
||||
{
|
||||
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
|
||||
"RespScanResult",
|
||||
"RespScanResult",
|
||||
"RespScanResult",
|
||||
"",
|
||||
sizeof(RespScanResult),
|
||||
1,
|
||||
resp_scan_result__field_descriptors,
|
||||
resp_scan_result__field_indices_by_name,
|
||||
1, resp_scan_result__number_ranges,
|
||||
(ProtobufCMessageInit) resp_scan_result__init,
|
||||
NULL,NULL,NULL /* reserved[123] */
|
||||
};
|
||||
static const ProtobufCFieldDescriptor wi_fi_scan_payload__field_descriptors[8] =
|
||||
{
|
||||
{
|
||||
"msg",
|
||||
1,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_ENUM,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(WiFiScanPayload, msg),
|
||||
&wi_fi_scan_msg_type__descriptor,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"status",
|
||||
2,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_ENUM,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(WiFiScanPayload, status),
|
||||
&status__descriptor,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"cmd_scan_start",
|
||||
10,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_MESSAGE,
|
||||
offsetof(WiFiScanPayload, payload_case),
|
||||
offsetof(WiFiScanPayload, cmd_scan_start),
|
||||
&cmd_scan_start__descriptor,
|
||||
NULL,
|
||||
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"resp_scan_start",
|
||||
11,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_MESSAGE,
|
||||
offsetof(WiFiScanPayload, payload_case),
|
||||
offsetof(WiFiScanPayload, resp_scan_start),
|
||||
&resp_scan_start__descriptor,
|
||||
NULL,
|
||||
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"cmd_scan_status",
|
||||
12,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_MESSAGE,
|
||||
offsetof(WiFiScanPayload, payload_case),
|
||||
offsetof(WiFiScanPayload, cmd_scan_status),
|
||||
&cmd_scan_status__descriptor,
|
||||
NULL,
|
||||
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"resp_scan_status",
|
||||
13,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_MESSAGE,
|
||||
offsetof(WiFiScanPayload, payload_case),
|
||||
offsetof(WiFiScanPayload, resp_scan_status),
|
||||
&resp_scan_status__descriptor,
|
||||
NULL,
|
||||
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"cmd_scan_result",
|
||||
14,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_MESSAGE,
|
||||
offsetof(WiFiScanPayload, payload_case),
|
||||
offsetof(WiFiScanPayload, cmd_scan_result),
|
||||
&cmd_scan_result__descriptor,
|
||||
NULL,
|
||||
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"resp_scan_result",
|
||||
15,
|
||||
PROTOBUF_C_LABEL_NONE,
|
||||
PROTOBUF_C_TYPE_MESSAGE,
|
||||
offsetof(WiFiScanPayload, payload_case),
|
||||
offsetof(WiFiScanPayload, resp_scan_result),
|
||||
&resp_scan_result__descriptor,
|
||||
NULL,
|
||||
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
};
|
||||
static const unsigned wi_fi_scan_payload__field_indices_by_name[] = {
|
||||
6, /* field[6] = cmd_scan_result */
|
||||
2, /* field[2] = cmd_scan_start */
|
||||
4, /* field[4] = cmd_scan_status */
|
||||
0, /* field[0] = msg */
|
||||
7, /* field[7] = resp_scan_result */
|
||||
3, /* field[3] = resp_scan_start */
|
||||
5, /* field[5] = resp_scan_status */
|
||||
1, /* field[1] = status */
|
||||
};
|
||||
static const ProtobufCIntRange wi_fi_scan_payload__number_ranges[2 + 1] =
|
||||
{
|
||||
{ 1, 0 },
|
||||
{ 10, 2 },
|
||||
{ 0, 8 }
|
||||
};
|
||||
const ProtobufCMessageDescriptor wi_fi_scan_payload__descriptor =
|
||||
{
|
||||
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
|
||||
"WiFiScanPayload",
|
||||
"WiFiScanPayload",
|
||||
"WiFiScanPayload",
|
||||
"",
|
||||
sizeof(WiFiScanPayload),
|
||||
8,
|
||||
wi_fi_scan_payload__field_descriptors,
|
||||
wi_fi_scan_payload__field_indices_by_name,
|
||||
2, wi_fi_scan_payload__number_ranges,
|
||||
(ProtobufCMessageInit) wi_fi_scan_payload__init,
|
||||
NULL,NULL,NULL /* reserved[123] */
|
||||
};
|
||||
static const ProtobufCEnumValue wi_fi_scan_msg_type__enum_values_by_number[6] =
|
||||
{
|
||||
{ "TypeCmdScanStart", "WI_FI_SCAN_MSG_TYPE__TypeCmdScanStart", 0 },
|
||||
{ "TypeRespScanStart", "WI_FI_SCAN_MSG_TYPE__TypeRespScanStart", 1 },
|
||||
{ "TypeCmdScanStatus", "WI_FI_SCAN_MSG_TYPE__TypeCmdScanStatus", 2 },
|
||||
{ "TypeRespScanStatus", "WI_FI_SCAN_MSG_TYPE__TypeRespScanStatus", 3 },
|
||||
{ "TypeCmdScanResult", "WI_FI_SCAN_MSG_TYPE__TypeCmdScanResult", 4 },
|
||||
{ "TypeRespScanResult", "WI_FI_SCAN_MSG_TYPE__TypeRespScanResult", 5 },
|
||||
};
|
||||
static const ProtobufCIntRange wi_fi_scan_msg_type__value_ranges[] = {
|
||||
{0, 0},{0, 6}
|
||||
};
|
||||
static const ProtobufCEnumValueIndex wi_fi_scan_msg_type__enum_values_by_name[6] =
|
||||
{
|
||||
{ "TypeCmdScanResult", 4 },
|
||||
{ "TypeCmdScanStart", 0 },
|
||||
{ "TypeCmdScanStatus", 2 },
|
||||
{ "TypeRespScanResult", 5 },
|
||||
{ "TypeRespScanStart", 1 },
|
||||
{ "TypeRespScanStatus", 3 },
|
||||
};
|
||||
const ProtobufCEnumDescriptor wi_fi_scan_msg_type__descriptor =
|
||||
{
|
||||
PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC,
|
||||
"WiFiScanMsgType",
|
||||
"WiFiScanMsgType",
|
||||
"WiFiScanMsgType",
|
||||
"",
|
||||
6,
|
||||
wi_fi_scan_msg_type__enum_values_by_number,
|
||||
6,
|
||||
wi_fi_scan_msg_type__enum_values_by_name,
|
||||
1,
|
||||
wi_fi_scan_msg_type__value_ranges,
|
||||
NULL,NULL,NULL,NULL /* reserved[1234] */
|
||||
};
|
@@ -1,350 +0,0 @@
|
||||
/* Generated by the protocol buffer compiler. DO NOT EDIT! */
|
||||
/* Generated from: wifi_scan.proto */
|
||||
|
||||
#ifndef PROTOBUF_C_wifi_5fscan_2eproto__INCLUDED
|
||||
#define PROTOBUF_C_wifi_5fscan_2eproto__INCLUDED
|
||||
|
||||
#include <protobuf-c/protobuf-c.h>
|
||||
|
||||
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 1004001 < 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
|
||||
|
||||
#include "constants.pb-c.h"
|
||||
#include "wifi_constants.pb-c.h"
|
||||
|
||||
typedef struct CmdScanStart CmdScanStart;
|
||||
typedef struct RespScanStart RespScanStart;
|
||||
typedef struct CmdScanStatus CmdScanStatus;
|
||||
typedef struct RespScanStatus RespScanStatus;
|
||||
typedef struct CmdScanResult CmdScanResult;
|
||||
typedef struct WiFiScanResult WiFiScanResult;
|
||||
typedef struct RespScanResult RespScanResult;
|
||||
typedef struct WiFiScanPayload WiFiScanPayload;
|
||||
|
||||
|
||||
/* --- enums --- */
|
||||
|
||||
typedef enum _WiFiScanMsgType {
|
||||
WI_FI_SCAN_MSG_TYPE__TypeCmdScanStart = 0,
|
||||
WI_FI_SCAN_MSG_TYPE__TypeRespScanStart = 1,
|
||||
WI_FI_SCAN_MSG_TYPE__TypeCmdScanStatus = 2,
|
||||
WI_FI_SCAN_MSG_TYPE__TypeRespScanStatus = 3,
|
||||
WI_FI_SCAN_MSG_TYPE__TypeCmdScanResult = 4,
|
||||
WI_FI_SCAN_MSG_TYPE__TypeRespScanResult = 5
|
||||
PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(WI_FI_SCAN_MSG_TYPE)
|
||||
} WiFiScanMsgType;
|
||||
|
||||
/* --- messages --- */
|
||||
|
||||
struct CmdScanStart
|
||||
{
|
||||
ProtobufCMessage base;
|
||||
protobuf_c_boolean blocking;
|
||||
protobuf_c_boolean passive;
|
||||
uint32_t group_channels;
|
||||
uint32_t period_ms;
|
||||
};
|
||||
#define CMD_SCAN_START__INIT \
|
||||
{ PROTOBUF_C_MESSAGE_INIT (&cmd_scan_start__descriptor) \
|
||||
, 0, 0, 0, 0 }
|
||||
|
||||
|
||||
struct RespScanStart
|
||||
{
|
||||
ProtobufCMessage base;
|
||||
};
|
||||
#define RESP_SCAN_START__INIT \
|
||||
{ PROTOBUF_C_MESSAGE_INIT (&resp_scan_start__descriptor) \
|
||||
}
|
||||
|
||||
|
||||
struct CmdScanStatus
|
||||
{
|
||||
ProtobufCMessage base;
|
||||
};
|
||||
#define CMD_SCAN_STATUS__INIT \
|
||||
{ PROTOBUF_C_MESSAGE_INIT (&cmd_scan_status__descriptor) \
|
||||
}
|
||||
|
||||
|
||||
struct RespScanStatus
|
||||
{
|
||||
ProtobufCMessage base;
|
||||
protobuf_c_boolean scan_finished;
|
||||
uint32_t result_count;
|
||||
};
|
||||
#define RESP_SCAN_STATUS__INIT \
|
||||
{ PROTOBUF_C_MESSAGE_INIT (&resp_scan_status__descriptor) \
|
||||
, 0, 0 }
|
||||
|
||||
|
||||
struct CmdScanResult
|
||||
{
|
||||
ProtobufCMessage base;
|
||||
uint32_t start_index;
|
||||
uint32_t count;
|
||||
};
|
||||
#define CMD_SCAN_RESULT__INIT \
|
||||
{ PROTOBUF_C_MESSAGE_INIT (&cmd_scan_result__descriptor) \
|
||||
, 0, 0 }
|
||||
|
||||
|
||||
struct WiFiScanResult
|
||||
{
|
||||
ProtobufCMessage base;
|
||||
ProtobufCBinaryData ssid;
|
||||
uint32_t channel;
|
||||
int32_t rssi;
|
||||
ProtobufCBinaryData bssid;
|
||||
WifiAuthMode auth;
|
||||
};
|
||||
#define WI_FI_SCAN_RESULT__INIT \
|
||||
{ PROTOBUF_C_MESSAGE_INIT (&wi_fi_scan_result__descriptor) \
|
||||
, {0,NULL}, 0, 0, {0,NULL}, WIFI_AUTH_MODE__Open }
|
||||
|
||||
|
||||
struct RespScanResult
|
||||
{
|
||||
ProtobufCMessage base;
|
||||
size_t n_entries;
|
||||
WiFiScanResult **entries;
|
||||
};
|
||||
#define RESP_SCAN_RESULT__INIT \
|
||||
{ PROTOBUF_C_MESSAGE_INIT (&resp_scan_result__descriptor) \
|
||||
, 0,NULL }
|
||||
|
||||
|
||||
typedef enum {
|
||||
WI_FI_SCAN_PAYLOAD__PAYLOAD__NOT_SET = 0,
|
||||
WI_FI_SCAN_PAYLOAD__PAYLOAD_CMD_SCAN_START = 10,
|
||||
WI_FI_SCAN_PAYLOAD__PAYLOAD_RESP_SCAN_START = 11,
|
||||
WI_FI_SCAN_PAYLOAD__PAYLOAD_CMD_SCAN_STATUS = 12,
|
||||
WI_FI_SCAN_PAYLOAD__PAYLOAD_RESP_SCAN_STATUS = 13,
|
||||
WI_FI_SCAN_PAYLOAD__PAYLOAD_CMD_SCAN_RESULT = 14,
|
||||
WI_FI_SCAN_PAYLOAD__PAYLOAD_RESP_SCAN_RESULT = 15
|
||||
PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(WI_FI_SCAN_PAYLOAD__PAYLOAD__CASE)
|
||||
} WiFiScanPayload__PayloadCase;
|
||||
|
||||
struct WiFiScanPayload
|
||||
{
|
||||
ProtobufCMessage base;
|
||||
WiFiScanMsgType msg;
|
||||
Status status;
|
||||
WiFiScanPayload__PayloadCase payload_case;
|
||||
union {
|
||||
CmdScanStart *cmd_scan_start;
|
||||
RespScanStart *resp_scan_start;
|
||||
CmdScanStatus *cmd_scan_status;
|
||||
RespScanStatus *resp_scan_status;
|
||||
CmdScanResult *cmd_scan_result;
|
||||
RespScanResult *resp_scan_result;
|
||||
};
|
||||
};
|
||||
#define WI_FI_SCAN_PAYLOAD__INIT \
|
||||
{ PROTOBUF_C_MESSAGE_INIT (&wi_fi_scan_payload__descriptor) \
|
||||
, WI_FI_SCAN_MSG_TYPE__TypeCmdScanStart, STATUS__Success, WI_FI_SCAN_PAYLOAD__PAYLOAD__NOT_SET, {0} }
|
||||
|
||||
|
||||
/* CmdScanStart methods */
|
||||
void cmd_scan_start__init
|
||||
(CmdScanStart *message);
|
||||
size_t cmd_scan_start__get_packed_size
|
||||
(const CmdScanStart *message);
|
||||
size_t cmd_scan_start__pack
|
||||
(const CmdScanStart *message,
|
||||
uint8_t *out);
|
||||
size_t cmd_scan_start__pack_to_buffer
|
||||
(const CmdScanStart *message,
|
||||
ProtobufCBuffer *buffer);
|
||||
CmdScanStart *
|
||||
cmd_scan_start__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data);
|
||||
void cmd_scan_start__free_unpacked
|
||||
(CmdScanStart *message,
|
||||
ProtobufCAllocator *allocator);
|
||||
/* RespScanStart methods */
|
||||
void resp_scan_start__init
|
||||
(RespScanStart *message);
|
||||
size_t resp_scan_start__get_packed_size
|
||||
(const RespScanStart *message);
|
||||
size_t resp_scan_start__pack
|
||||
(const RespScanStart *message,
|
||||
uint8_t *out);
|
||||
size_t resp_scan_start__pack_to_buffer
|
||||
(const RespScanStart *message,
|
||||
ProtobufCBuffer *buffer);
|
||||
RespScanStart *
|
||||
resp_scan_start__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data);
|
||||
void resp_scan_start__free_unpacked
|
||||
(RespScanStart *message,
|
||||
ProtobufCAllocator *allocator);
|
||||
/* CmdScanStatus methods */
|
||||
void cmd_scan_status__init
|
||||
(CmdScanStatus *message);
|
||||
size_t cmd_scan_status__get_packed_size
|
||||
(const CmdScanStatus *message);
|
||||
size_t cmd_scan_status__pack
|
||||
(const CmdScanStatus *message,
|
||||
uint8_t *out);
|
||||
size_t cmd_scan_status__pack_to_buffer
|
||||
(const CmdScanStatus *message,
|
||||
ProtobufCBuffer *buffer);
|
||||
CmdScanStatus *
|
||||
cmd_scan_status__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data);
|
||||
void cmd_scan_status__free_unpacked
|
||||
(CmdScanStatus *message,
|
||||
ProtobufCAllocator *allocator);
|
||||
/* RespScanStatus methods */
|
||||
void resp_scan_status__init
|
||||
(RespScanStatus *message);
|
||||
size_t resp_scan_status__get_packed_size
|
||||
(const RespScanStatus *message);
|
||||
size_t resp_scan_status__pack
|
||||
(const RespScanStatus *message,
|
||||
uint8_t *out);
|
||||
size_t resp_scan_status__pack_to_buffer
|
||||
(const RespScanStatus *message,
|
||||
ProtobufCBuffer *buffer);
|
||||
RespScanStatus *
|
||||
resp_scan_status__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data);
|
||||
void resp_scan_status__free_unpacked
|
||||
(RespScanStatus *message,
|
||||
ProtobufCAllocator *allocator);
|
||||
/* CmdScanResult methods */
|
||||
void cmd_scan_result__init
|
||||
(CmdScanResult *message);
|
||||
size_t cmd_scan_result__get_packed_size
|
||||
(const CmdScanResult *message);
|
||||
size_t cmd_scan_result__pack
|
||||
(const CmdScanResult *message,
|
||||
uint8_t *out);
|
||||
size_t cmd_scan_result__pack_to_buffer
|
||||
(const CmdScanResult *message,
|
||||
ProtobufCBuffer *buffer);
|
||||
CmdScanResult *
|
||||
cmd_scan_result__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data);
|
||||
void cmd_scan_result__free_unpacked
|
||||
(CmdScanResult *message,
|
||||
ProtobufCAllocator *allocator);
|
||||
/* WiFiScanResult methods */
|
||||
void wi_fi_scan_result__init
|
||||
(WiFiScanResult *message);
|
||||
size_t wi_fi_scan_result__get_packed_size
|
||||
(const WiFiScanResult *message);
|
||||
size_t wi_fi_scan_result__pack
|
||||
(const WiFiScanResult *message,
|
||||
uint8_t *out);
|
||||
size_t wi_fi_scan_result__pack_to_buffer
|
||||
(const WiFiScanResult *message,
|
||||
ProtobufCBuffer *buffer);
|
||||
WiFiScanResult *
|
||||
wi_fi_scan_result__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data);
|
||||
void wi_fi_scan_result__free_unpacked
|
||||
(WiFiScanResult *message,
|
||||
ProtobufCAllocator *allocator);
|
||||
/* RespScanResult methods */
|
||||
void resp_scan_result__init
|
||||
(RespScanResult *message);
|
||||
size_t resp_scan_result__get_packed_size
|
||||
(const RespScanResult *message);
|
||||
size_t resp_scan_result__pack
|
||||
(const RespScanResult *message,
|
||||
uint8_t *out);
|
||||
size_t resp_scan_result__pack_to_buffer
|
||||
(const RespScanResult *message,
|
||||
ProtobufCBuffer *buffer);
|
||||
RespScanResult *
|
||||
resp_scan_result__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data);
|
||||
void resp_scan_result__free_unpacked
|
||||
(RespScanResult *message,
|
||||
ProtobufCAllocator *allocator);
|
||||
/* WiFiScanPayload methods */
|
||||
void wi_fi_scan_payload__init
|
||||
(WiFiScanPayload *message);
|
||||
size_t wi_fi_scan_payload__get_packed_size
|
||||
(const WiFiScanPayload *message);
|
||||
size_t wi_fi_scan_payload__pack
|
||||
(const WiFiScanPayload *message,
|
||||
uint8_t *out);
|
||||
size_t wi_fi_scan_payload__pack_to_buffer
|
||||
(const WiFiScanPayload *message,
|
||||
ProtobufCBuffer *buffer);
|
||||
WiFiScanPayload *
|
||||
wi_fi_scan_payload__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data);
|
||||
void wi_fi_scan_payload__free_unpacked
|
||||
(WiFiScanPayload *message,
|
||||
ProtobufCAllocator *allocator);
|
||||
/* --- per-message closures --- */
|
||||
|
||||
typedef void (*CmdScanStart_Closure)
|
||||
(const CmdScanStart *message,
|
||||
void *closure_data);
|
||||
typedef void (*RespScanStart_Closure)
|
||||
(const RespScanStart *message,
|
||||
void *closure_data);
|
||||
typedef void (*CmdScanStatus_Closure)
|
||||
(const CmdScanStatus *message,
|
||||
void *closure_data);
|
||||
typedef void (*RespScanStatus_Closure)
|
||||
(const RespScanStatus *message,
|
||||
void *closure_data);
|
||||
typedef void (*CmdScanResult_Closure)
|
||||
(const CmdScanResult *message,
|
||||
void *closure_data);
|
||||
typedef void (*WiFiScanResult_Closure)
|
||||
(const WiFiScanResult *message,
|
||||
void *closure_data);
|
||||
typedef void (*RespScanResult_Closure)
|
||||
(const RespScanResult *message,
|
||||
void *closure_data);
|
||||
typedef void (*WiFiScanPayload_Closure)
|
||||
(const WiFiScanPayload *message,
|
||||
void *closure_data);
|
||||
|
||||
/* --- services --- */
|
||||
|
||||
|
||||
/* --- descriptors --- */
|
||||
|
||||
extern const ProtobufCEnumDescriptor wi_fi_scan_msg_type__descriptor;
|
||||
extern const ProtobufCMessageDescriptor cmd_scan_start__descriptor;
|
||||
extern const ProtobufCMessageDescriptor resp_scan_start__descriptor;
|
||||
extern const ProtobufCMessageDescriptor cmd_scan_status__descriptor;
|
||||
extern const ProtobufCMessageDescriptor resp_scan_status__descriptor;
|
||||
extern const ProtobufCMessageDescriptor cmd_scan_result__descriptor;
|
||||
extern const ProtobufCMessageDescriptor wi_fi_scan_result__descriptor;
|
||||
extern const ProtobufCMessageDescriptor resp_scan_result__descriptor;
|
||||
extern const ProtobufCMessageDescriptor wi_fi_scan_payload__descriptor;
|
||||
|
||||
PROTOBUF_C__END_DECLS
|
||||
|
||||
|
||||
#endif /* PROTOBUF_C_wifi_5fscan_2eproto__INCLUDED */
|
@@ -1,29 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
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(PROTOCOMM_INCL_PATH "${CMAKE_CURRENT_LIST_DIR}/../../protocomm/proto")
|
||||
|
||||
set(PROTO_SRCS "wifi_constants.proto"
|
||||
"wifi_config.proto"
|
||||
"wifi_scan.proto")
|
||||
|
||||
add_custom_target(c_proto
|
||||
COMMAND ${PROTO_C_COMPILER} --c_out=${C_OUT_PATH} -I . -I ${PROTOCOMM_INCL_PATH} ${PROTO_SRCS}
|
||||
VERBATIM
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
||||
)
|
||||
|
||||
add_custom_target(python_proto
|
||||
COMMAND ${PROTO_COMPILER} --python_out=${PY_OUT_PATH} -I . -I ${PROTOCOMM_INCL_PATH} ${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}
|
||||
)
|
@@ -1,28 +0,0 @@
|
||||
# Protobuf files for defining Wi-Fi provisioning packet structures
|
||||
|
||||
`wifi_provisioning` uses Google Protobuf for language, transport and architecture agnostic protocol communication. These proto files define the protocomm packet structure, separated across multiple files:
|
||||
* wifi_contants.proto - Defines the various enums for indicating state of Wi-Fi (connected / disconnect / connecting), diconnect reasons, auth modes, etc.
|
||||
* wifi_config.proto - Defines Wi-Fi configuration structures and commands for setting credentials (SSID, passphrase, BSSID), applying credentials and getting connection state.
|
||||
* wifi_scan.proto - Defines Wi-Fi scan commands and result structures
|
||||
|
||||
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 `components/wifi_provisioning/proto-c` and `components/wifi_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 `components/wifi_provisioning/proto-c` and `components/wifi_provisioning/python`
|
@@ -1,7 +0,0 @@
|
||||
all: c_proto python_proto
|
||||
|
||||
c_proto: *.proto
|
||||
@protoc-c --c_out=../proto-c/ -I . -I ../../protocomm/proto/ *.proto
|
||||
|
||||
python_proto: *.proto
|
||||
@protoc --python_out=../python/ -I . -I ../../protocomm/proto/ *.proto
|
@@ -1,58 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
import "constants.proto";
|
||||
import "wifi_constants.proto";
|
||||
|
||||
message CmdGetStatus {
|
||||
|
||||
}
|
||||
|
||||
message RespGetStatus {
|
||||
Status status = 1;
|
||||
WifiStationState sta_state = 2;
|
||||
oneof state {
|
||||
WifiConnectFailedReason fail_reason = 10;
|
||||
WifiConnectedState connected = 11;
|
||||
WifiAttemptFailed attempt_failed = 12;
|
||||
}
|
||||
}
|
||||
|
||||
message CmdSetConfig {
|
||||
bytes ssid = 1;
|
||||
bytes passphrase = 2;
|
||||
bytes bssid = 3;
|
||||
int32 channel = 4;
|
||||
}
|
||||
|
||||
message RespSetConfig {
|
||||
Status status = 1;
|
||||
}
|
||||
|
||||
message CmdApplyConfig {
|
||||
|
||||
}
|
||||
|
||||
message RespApplyConfig {
|
||||
Status status = 1;
|
||||
}
|
||||
|
||||
enum WiFiConfigMsgType {
|
||||
TypeCmdGetStatus = 0;
|
||||
TypeRespGetStatus = 1;
|
||||
TypeCmdSetConfig = 2;
|
||||
TypeRespSetConfig = 3;
|
||||
TypeCmdApplyConfig = 4;
|
||||
TypeRespApplyConfig = 5;
|
||||
}
|
||||
|
||||
message WiFiConfigPayload {
|
||||
WiFiConfigMsgType msg = 1;
|
||||
oneof payload {
|
||||
CmdGetStatus cmd_get_status = 10;
|
||||
RespGetStatus resp_get_status = 11;
|
||||
CmdSetConfig cmd_set_config = 12;
|
||||
RespSetConfig resp_set_config = 13;
|
||||
CmdApplyConfig cmd_apply_config = 14;
|
||||
RespApplyConfig resp_apply_config = 15;
|
||||
}
|
||||
}
|
@@ -1,36 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
enum WifiStationState {
|
||||
Connected = 0;
|
||||
Connecting = 1;
|
||||
Disconnected = 2;
|
||||
ConnectionFailed = 3;
|
||||
}
|
||||
|
||||
enum WifiConnectFailedReason {
|
||||
AuthError = 0;
|
||||
NetworkNotFound = 1;
|
||||
}
|
||||
|
||||
message WifiAttemptFailed {
|
||||
uint32 attempts_remaining = 1;
|
||||
}
|
||||
|
||||
enum WifiAuthMode {
|
||||
Open = 0;
|
||||
WEP = 1;
|
||||
WPA_PSK = 2;
|
||||
WPA2_PSK = 3;
|
||||
WPA_WPA2_PSK = 4;
|
||||
WPA2_ENTERPRISE = 5;
|
||||
WPA3_PSK = 6;
|
||||
WPA2_WPA3_PSK = 7;
|
||||
}
|
||||
|
||||
message WifiConnectedState {
|
||||
string ip4_addr = 1;
|
||||
WifiAuthMode auth_mode = 2;
|
||||
bytes ssid = 3;
|
||||
bytes bssid = 4;
|
||||
int32 channel = 5;
|
||||
}
|
@@ -1,38 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
import "constants.proto";
|
||||
|
||||
message CmdCtrlReset {
|
||||
|
||||
}
|
||||
|
||||
message RespCtrlReset {
|
||||
|
||||
}
|
||||
|
||||
message CmdCtrlReprov {
|
||||
|
||||
}
|
||||
|
||||
message RespCtrlReprov{
|
||||
|
||||
}
|
||||
|
||||
enum WiFiCtrlMsgType {
|
||||
TypeCtrlReserved = 0;
|
||||
TypeCmdCtrlReset = 1;
|
||||
TypeRespCtrlReset = 2;
|
||||
TypeCmdCtrlReprov = 3;
|
||||
TypeRespCtrlReprov = 4;
|
||||
}
|
||||
|
||||
message WiFiCtrlPayload {
|
||||
WiFiCtrlMsgType msg = 1;
|
||||
Status status = 2;
|
||||
oneof payload {
|
||||
CmdCtrlReset cmd_ctrl_reset = 11;
|
||||
RespCtrlReset resp_ctrl_reset = 12;
|
||||
CmdCtrlReprov cmd_ctrl_reprov = 13;
|
||||
RespCtrlReprov resp_ctrl_reprov = 14;
|
||||
}
|
||||
}
|
@@ -1,63 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
import "constants.proto";
|
||||
import "wifi_constants.proto";
|
||||
|
||||
message CmdScanStart {
|
||||
bool blocking = 1;
|
||||
bool passive = 2;
|
||||
uint32 group_channels = 3;
|
||||
uint32 period_ms = 4;
|
||||
}
|
||||
|
||||
message RespScanStart {
|
||||
|
||||
}
|
||||
|
||||
message CmdScanStatus {
|
||||
|
||||
}
|
||||
|
||||
message RespScanStatus {
|
||||
bool scan_finished = 1;
|
||||
uint32 result_count = 2;
|
||||
}
|
||||
|
||||
message CmdScanResult {
|
||||
uint32 start_index = 1;
|
||||
uint32 count = 2;
|
||||
}
|
||||
|
||||
message WiFiScanResult {
|
||||
bytes ssid = 1;
|
||||
uint32 channel = 2;
|
||||
int32 rssi = 3;
|
||||
bytes bssid = 4;
|
||||
WifiAuthMode auth = 5;
|
||||
}
|
||||
|
||||
message RespScanResult {
|
||||
repeated WiFiScanResult entries = 1;
|
||||
}
|
||||
|
||||
enum WiFiScanMsgType {
|
||||
TypeCmdScanStart = 0;
|
||||
TypeRespScanStart = 1;
|
||||
TypeCmdScanStatus = 2;
|
||||
TypeRespScanStatus = 3;
|
||||
TypeCmdScanResult = 4;
|
||||
TypeRespScanResult = 5;
|
||||
}
|
||||
|
||||
message WiFiScanPayload {
|
||||
WiFiScanMsgType msg = 1;
|
||||
Status status = 2;
|
||||
oneof payload {
|
||||
CmdScanStart cmd_scan_start = 10;
|
||||
RespScanStart resp_scan_start = 11;
|
||||
CmdScanStatus cmd_scan_status = 12;
|
||||
RespScanStatus resp_scan_status = 13;
|
||||
CmdScanResult cmd_scan_result = 14;
|
||||
RespScanResult resp_scan_result = 15;
|
||||
}
|
||||
}
|
@@ -1,41 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: wifi_config.proto
|
||||
"""Generated protocol buffer code."""
|
||||
from google.protobuf.internal import builder as _builder
|
||||
from google.protobuf import descriptor as _descriptor
|
||||
from google.protobuf import descriptor_pool as _descriptor_pool
|
||||
from google.protobuf import symbol_database as _symbol_database
|
||||
# @@protoc_insertion_point(imports)
|
||||
|
||||
_sym_db = _symbol_database.Default()
|
||||
|
||||
|
||||
import constants_pb2 as constants__pb2
|
||||
import wifi_constants_pb2 as wifi__constants__pb2
|
||||
|
||||
|
||||
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x11wifi_config.proto\x1a\x0f\x63onstants.proto\x1a\x14wifi_constants.proto\"\x0e\n\x0c\x43mdGetStatus\"\xe0\x01\n\rRespGetStatus\x12\x17\n\x06status\x18\x01 \x01(\x0e\x32\x07.Status\x12$\n\tsta_state\x18\x02 \x01(\x0e\x32\x11.WifiStationState\x12/\n\x0b\x66\x61il_reason\x18\n \x01(\x0e\x32\x18.WifiConnectFailedReasonH\x00\x12(\n\tconnected\x18\x0b \x01(\x0b\x32\x13.WifiConnectedStateH\x00\x12,\n\x0e\x61ttempt_failed\x18\x0c \x01(\x0b\x32\x12.WifiAttemptFailedH\x00\x42\x07\n\x05state\"P\n\x0c\x43mdSetConfig\x12\x0c\n\x04ssid\x18\x01 \x01(\x0c\x12\x12\n\npassphrase\x18\x02 \x01(\x0c\x12\r\n\x05\x62ssid\x18\x03 \x01(\x0c\x12\x0f\n\x07\x63hannel\x18\x04 \x01(\x05\"(\n\rRespSetConfig\x12\x17\n\x06status\x18\x01 \x01(\x0e\x32\x07.Status\"\x10\n\x0e\x43mdApplyConfig\"*\n\x0fRespApplyConfig\x12\x17\n\x06status\x18\x01 \x01(\x0e\x32\x07.Status\"\xc3\x02\n\x11WiFiConfigPayload\x12\x1f\n\x03msg\x18\x01 \x01(\x0e\x32\x12.WiFiConfigMsgType\x12\'\n\x0e\x63md_get_status\x18\n \x01(\x0b\x32\r.CmdGetStatusH\x00\x12)\n\x0fresp_get_status\x18\x0b \x01(\x0b\x32\x0e.RespGetStatusH\x00\x12\'\n\x0e\x63md_set_config\x18\x0c \x01(\x0b\x32\r.CmdSetConfigH\x00\x12)\n\x0fresp_set_config\x18\r \x01(\x0b\x32\x0e.RespSetConfigH\x00\x12+\n\x10\x63md_apply_config\x18\x0e \x01(\x0b\x32\x0f.CmdApplyConfigH\x00\x12-\n\x11resp_apply_config\x18\x0f \x01(\x0b\x32\x10.RespApplyConfigH\x00\x42\t\n\x07payload*\x9e\x01\n\x11WiFiConfigMsgType\x12\x14\n\x10TypeCmdGetStatus\x10\x00\x12\x15\n\x11TypeRespGetStatus\x10\x01\x12\x14\n\x10TypeCmdSetConfig\x10\x02\x12\x15\n\x11TypeRespSetConfig\x10\x03\x12\x16\n\x12TypeCmdApplyConfig\x10\x04\x12\x17\n\x13TypeRespApplyConfig\x10\x05\x62\x06proto3')
|
||||
|
||||
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
|
||||
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'wifi_config_pb2', globals())
|
||||
if _descriptor._USE_C_DESCRIPTORS == False:
|
||||
|
||||
DESCRIPTOR._options = None
|
||||
_WIFICONFIGMSGTYPE._serialized_start=816
|
||||
_WIFICONFIGMSGTYPE._serialized_end=974
|
||||
_CMDGETSTATUS._serialized_start=60
|
||||
_CMDGETSTATUS._serialized_end=74
|
||||
_RESPGETSTATUS._serialized_start=77
|
||||
_RESPGETSTATUS._serialized_end=301
|
||||
_CMDSETCONFIG._serialized_start=303
|
||||
_CMDSETCONFIG._serialized_end=383
|
||||
_RESPSETCONFIG._serialized_start=385
|
||||
_RESPSETCONFIG._serialized_end=425
|
||||
_CMDAPPLYCONFIG._serialized_start=427
|
||||
_CMDAPPLYCONFIG._serialized_end=443
|
||||
_RESPAPPLYCONFIG._serialized_start=445
|
||||
_RESPAPPLYCONFIG._serialized_end=487
|
||||
_WIFICONFIGPAYLOAD._serialized_start=490
|
||||
_WIFICONFIGPAYLOAD._serialized_end=813
|
||||
# @@protoc_insertion_point(module_scope)
|
@@ -1,33 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: wifi_constants.proto
|
||||
"""Generated protocol buffer code."""
|
||||
from google.protobuf.internal import builder as _builder
|
||||
from google.protobuf import descriptor as _descriptor
|
||||
from google.protobuf import descriptor_pool as _descriptor_pool
|
||||
from google.protobuf import symbol_database as _symbol_database
|
||||
# @@protoc_insertion_point(imports)
|
||||
|
||||
_sym_db = _symbol_database.Default()
|
||||
|
||||
|
||||
|
||||
|
||||
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x14wifi_constants.proto\"/\n\x11WifiAttemptFailed\x12\x1a\n\x12\x61ttempts_remaining\x18\x01 \x01(\r\"v\n\x12WifiConnectedState\x12\x10\n\x08ip4_addr\x18\x01 \x01(\t\x12 \n\tauth_mode\x18\x02 \x01(\x0e\x32\r.WifiAuthMode\x12\x0c\n\x04ssid\x18\x03 \x01(\x0c\x12\r\n\x05\x62ssid\x18\x04 \x01(\x0c\x12\x0f\n\x07\x63hannel\x18\x05 \x01(\x05*Y\n\x10WifiStationState\x12\r\n\tConnected\x10\x00\x12\x0e\n\nConnecting\x10\x01\x12\x10\n\x0c\x44isconnected\x10\x02\x12\x14\n\x10\x43onnectionFailed\x10\x03*=\n\x17WifiConnectFailedReason\x12\r\n\tAuthError\x10\x00\x12\x13\n\x0fNetworkNotFound\x10\x01*\x84\x01\n\x0cWifiAuthMode\x12\x08\n\x04Open\x10\x00\x12\x07\n\x03WEP\x10\x01\x12\x0b\n\x07WPA_PSK\x10\x02\x12\x0c\n\x08WPA2_PSK\x10\x03\x12\x10\n\x0cWPA_WPA2_PSK\x10\x04\x12\x13\n\x0fWPA2_ENTERPRISE\x10\x05\x12\x0c\n\x08WPA3_PSK\x10\x06\x12\x11\n\rWPA2_WPA3_PSK\x10\x07\x62\x06proto3')
|
||||
|
||||
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
|
||||
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'wifi_constants_pb2', globals())
|
||||
if _descriptor._USE_C_DESCRIPTORS == False:
|
||||
|
||||
DESCRIPTOR._options = None
|
||||
_WIFISTATIONSTATE._serialized_start=193
|
||||
_WIFISTATIONSTATE._serialized_end=282
|
||||
_WIFICONNECTFAILEDREASON._serialized_start=284
|
||||
_WIFICONNECTFAILEDREASON._serialized_end=345
|
||||
_WIFIAUTHMODE._serialized_start=348
|
||||
_WIFIAUTHMODE._serialized_end=480
|
||||
_WIFIATTEMPTFAILED._serialized_start=24
|
||||
_WIFIATTEMPTFAILED._serialized_end=71
|
||||
_WIFICONNECTEDSTATE._serialized_start=73
|
||||
_WIFICONNECTEDSTATE._serialized_end=191
|
||||
# @@protoc_insertion_point(module_scope)
|
@@ -1,36 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: wifi_ctrl.proto
|
||||
"""Generated protocol buffer code."""
|
||||
from google.protobuf.internal import builder as _builder
|
||||
from google.protobuf import descriptor as _descriptor
|
||||
from google.protobuf import descriptor_pool as _descriptor_pool
|
||||
from google.protobuf import symbol_database as _symbol_database
|
||||
# @@protoc_insertion_point(imports)
|
||||
|
||||
_sym_db = _symbol_database.Default()
|
||||
|
||||
|
||||
import constants_pb2 as constants__pb2
|
||||
|
||||
|
||||
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0fwifi_ctrl.proto\x1a\x0f\x63onstants.proto\"\x0e\n\x0c\x43mdCtrlReset\"\x0f\n\rRespCtrlReset\"\x0f\n\rCmdCtrlReprov\"\x10\n\x0eRespCtrlReprov\"\x80\x02\n\x0fWiFiCtrlPayload\x12\x1d\n\x03msg\x18\x01 \x01(\x0e\x32\x10.WiFiCtrlMsgType\x12\x17\n\x06status\x18\x02 \x01(\x0e\x32\x07.Status\x12\'\n\x0e\x63md_ctrl_reset\x18\x0b \x01(\x0b\x32\r.CmdCtrlResetH\x00\x12)\n\x0fresp_ctrl_reset\x18\x0c \x01(\x0b\x32\x0e.RespCtrlResetH\x00\x12)\n\x0f\x63md_ctrl_reprov\x18\r \x01(\x0b\x32\x0e.CmdCtrlReprovH\x00\x12+\n\x10resp_ctrl_reprov\x18\x0e \x01(\x0b\x32\x0f.RespCtrlReprovH\x00\x42\t\n\x07payload*\x83\x01\n\x0fWiFiCtrlMsgType\x12\x14\n\x10TypeCtrlReserved\x10\x00\x12\x14\n\x10TypeCmdCtrlReset\x10\x01\x12\x15\n\x11TypeRespCtrlReset\x10\x02\x12\x15\n\x11TypeCmdCtrlReprov\x10\x03\x12\x16\n\x12TypeRespCtrlReprov\x10\x04\x62\x06proto3')
|
||||
|
||||
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
|
||||
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'wifi_ctrl_pb2', globals())
|
||||
if _descriptor._USE_C_DESCRIPTORS == False:
|
||||
|
||||
DESCRIPTOR._options = None
|
||||
_WIFICTRLMSGTYPE._serialized_start=364
|
||||
_WIFICTRLMSGTYPE._serialized_end=495
|
||||
_CMDCTRLRESET._serialized_start=36
|
||||
_CMDCTRLRESET._serialized_end=50
|
||||
_RESPCTRLRESET._serialized_start=52
|
||||
_RESPCTRLRESET._serialized_end=67
|
||||
_CMDCTRLREPROV._serialized_start=69
|
||||
_CMDCTRLREPROV._serialized_end=84
|
||||
_RESPCTRLREPROV._serialized_start=86
|
||||
_RESPCTRLREPROV._serialized_end=102
|
||||
_WIFICTRLPAYLOAD._serialized_start=105
|
||||
_WIFICTRLPAYLOAD._serialized_end=361
|
||||
# @@protoc_insertion_point(module_scope)
|
@@ -1,43 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: wifi_scan.proto
|
||||
"""Generated protocol buffer code."""
|
||||
from google.protobuf.internal import builder as _builder
|
||||
from google.protobuf import descriptor as _descriptor
|
||||
from google.protobuf import descriptor_pool as _descriptor_pool
|
||||
from google.protobuf import symbol_database as _symbol_database
|
||||
# @@protoc_insertion_point(imports)
|
||||
|
||||
_sym_db = _symbol_database.Default()
|
||||
|
||||
|
||||
import constants_pb2 as constants__pb2
|
||||
import wifi_constants_pb2 as wifi__constants__pb2
|
||||
|
||||
|
||||
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0fwifi_scan.proto\x1a\x0f\x63onstants.proto\x1a\x14wifi_constants.proto\"\\\n\x0c\x43mdScanStart\x12\x10\n\x08\x62locking\x18\x01 \x01(\x08\x12\x0f\n\x07passive\x18\x02 \x01(\x08\x12\x16\n\x0egroup_channels\x18\x03 \x01(\r\x12\x11\n\tperiod_ms\x18\x04 \x01(\r\"\x0f\n\rRespScanStart\"\x0f\n\rCmdScanStatus\"=\n\x0eRespScanStatus\x12\x15\n\rscan_finished\x18\x01 \x01(\x08\x12\x14\n\x0cresult_count\x18\x02 \x01(\r\"3\n\rCmdScanResult\x12\x13\n\x0bstart_index\x18\x01 \x01(\r\x12\r\n\x05\x63ount\x18\x02 \x01(\r\"i\n\x0eWiFiScanResult\x12\x0c\n\x04ssid\x18\x01 \x01(\x0c\x12\x0f\n\x07\x63hannel\x18\x02 \x01(\r\x12\x0c\n\x04rssi\x18\x03 \x01(\x05\x12\r\n\x05\x62ssid\x18\x04 \x01(\x0c\x12\x1b\n\x04\x61uth\x18\x05 \x01(\x0e\x32\r.WifiAuthMode\"2\n\x0eRespScanResult\x12 \n\x07\x65ntries\x18\x01 \x03(\x0b\x32\x0f.WiFiScanResult\"\xd8\x02\n\x0fWiFiScanPayload\x12\x1d\n\x03msg\x18\x01 \x01(\x0e\x32\x10.WiFiScanMsgType\x12\x17\n\x06status\x18\x02 \x01(\x0e\x32\x07.Status\x12\'\n\x0e\x63md_scan_start\x18\n \x01(\x0b\x32\r.CmdScanStartH\x00\x12)\n\x0fresp_scan_start\x18\x0b \x01(\x0b\x32\x0e.RespScanStartH\x00\x12)\n\x0f\x63md_scan_status\x18\x0c \x01(\x0b\x32\x0e.CmdScanStatusH\x00\x12+\n\x10resp_scan_status\x18\r \x01(\x0b\x32\x0f.RespScanStatusH\x00\x12)\n\x0f\x63md_scan_result\x18\x0e \x01(\x0b\x32\x0e.CmdScanResultH\x00\x12+\n\x10resp_scan_result\x18\x0f \x01(\x0b\x32\x0f.RespScanResultH\x00\x42\t\n\x07payload*\x9c\x01\n\x0fWiFiScanMsgType\x12\x14\n\x10TypeCmdScanStart\x10\x00\x12\x15\n\x11TypeRespScanStart\x10\x01\x12\x15\n\x11TypeCmdScanStatus\x10\x02\x12\x16\n\x12TypeRespScanStatus\x10\x03\x12\x15\n\x11TypeCmdScanResult\x10\x04\x12\x16\n\x12TypeRespScanResult\x10\x05\x62\x06proto3')
|
||||
|
||||
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
|
||||
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'wifi_scan_pb2', globals())
|
||||
if _descriptor._USE_C_DESCRIPTORS == False:
|
||||
|
||||
DESCRIPTOR._options = None
|
||||
_WIFISCANMSGTYPE._serialized_start=809
|
||||
_WIFISCANMSGTYPE._serialized_end=965
|
||||
_CMDSCANSTART._serialized_start=58
|
||||
_CMDSCANSTART._serialized_end=150
|
||||
_RESPSCANSTART._serialized_start=152
|
||||
_RESPSCANSTART._serialized_end=167
|
||||
_CMDSCANSTATUS._serialized_start=169
|
||||
_CMDSCANSTATUS._serialized_end=184
|
||||
_RESPSCANSTATUS._serialized_start=186
|
||||
_RESPSCANSTATUS._serialized_end=247
|
||||
_CMDSCANRESULT._serialized_start=249
|
||||
_CMDSCANRESULT._serialized_end=300
|
||||
_WIFISCANRESULT._serialized_start=302
|
||||
_WIFISCANRESULT._serialized_end=407
|
||||
_RESPSCANRESULT._serialized_start=409
|
||||
_RESPSCANRESULT._serialized_end=459
|
||||
_WIFISCANPAYLOAD._serialized_start=462
|
||||
_WIFISCANPAYLOAD._serialized_end=806
|
||||
# @@protoc_insertion_point(module_scope)
|
@@ -1,230 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <esp_err.h>
|
||||
#include <esp_log.h>
|
||||
|
||||
#include <esp_wifi.h>
|
||||
#include <esp_netif.h>
|
||||
|
||||
#include "wifi_provisioning/wifi_config.h"
|
||||
#include "wifi_provisioning/wifi_scan.h"
|
||||
#include "wifi_ctrl.h"
|
||||
#include "wifi_provisioning/manager.h"
|
||||
#include "wifi_provisioning_priv.h"
|
||||
|
||||
static const char *TAG = "wifi_prov_handlers";
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
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 (wifi_prov_mgr_get_wifi_state(&resp_data->wifi_state) != ESP_OK) {
|
||||
ESP_LOGW(TAG, "Wi-Fi provisioning manager not running");
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (resp_data->wifi_state == WIFI_PROV_STA_CONNECTED) {
|
||||
ESP_LOGD(TAG, "Got state : connected");
|
||||
|
||||
/* 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;
|
||||
|
||||
/* Tell manager to stop provisioning service */
|
||||
wifi_prov_mgr_done();
|
||||
} else if (resp_data->wifi_state == WIFI_PROV_STA_DISCONNECTED) {
|
||||
ESP_LOGD(TAG, "Got state : disconnected");
|
||||
|
||||
/* If disconnected, convey reason */
|
||||
wifi_prov_mgr_get_wifi_disconnect_reason(&resp_data->fail_reason);
|
||||
} else {
|
||||
if (wifi_prov_mgr_get_remaining_conn_attempts(&resp_data->connecting_info.attempts_remaining) != ESP_OK) {
|
||||
ESP_LOGW(TAG, "Wi-Fi provisioning manager not running");
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
ESP_LOGD(TAG, "Got state : connecting");
|
||||
}
|
||||
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 allocate Wi-Fi config");
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
ESP_LOGD(TAG, "Wi-Fi Credentials Received");
|
||||
|
||||
/* 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);
|
||||
|
||||
/* Using strlcpy allows both max passphrase length (63 bytes) and ensures null termination
|
||||
* because size of wifi_cfg->sta.password is 64 bytes (1 extra byte for null character) */
|
||||
strlcpy((char *) wifi_cfg->sta.password, req_data->password, sizeof(wifi_cfg->sta.password));
|
||||
|
||||
#ifdef CONFIG_WIFI_PROV_STA_ALL_CHANNEL_SCAN
|
||||
wifi_cfg->sta.scan_method = WIFI_ALL_CHANNEL_SCAN;
|
||||
#else /* CONFIG_WIFI_PROV_STA_FAST_SCAN */
|
||||
wifi_cfg->sta.scan_method = WIFI_FAST_SCAN;
|
||||
#endif
|
||||
|
||||
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, "Wi-Fi config not set");
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
esp_err_t ret = wifi_prov_mgr_configure_sta(wifi_cfg);
|
||||
if (ret == ESP_OK) {
|
||||
ESP_LOGD(TAG, "Wi-Fi Credentials Applied");
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Failed to apply Wi-Fi Credentials");
|
||||
}
|
||||
|
||||
free_config(ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t get_wifi_prov_handlers(wifi_prov_config_handlers_t *ptr)
|
||||
{
|
||||
if (!ptr) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
ptr->get_status_handler = get_status_handler;
|
||||
ptr->set_config_handler = set_config_handler;
|
||||
ptr->apply_config_handler = apply_config_handler;
|
||||
ptr->ctx = NULL;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
static esp_err_t scan_start(bool blocking, bool passive,
|
||||
uint8_t group_channels, uint32_t period_ms,
|
||||
wifi_prov_scan_ctx_t **ctx)
|
||||
{
|
||||
return wifi_prov_mgr_wifi_scan_start(blocking, passive, group_channels, period_ms);
|
||||
}
|
||||
|
||||
static esp_err_t scan_status(bool *scan_finished,
|
||||
uint16_t *result_count,
|
||||
wifi_prov_scan_ctx_t **ctx)
|
||||
{
|
||||
*scan_finished = wifi_prov_mgr_wifi_scan_finished();
|
||||
*result_count = wifi_prov_mgr_wifi_scan_result_count();
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t scan_result(uint16_t result_index,
|
||||
wifi_prov_scan_result_t *result,
|
||||
wifi_prov_scan_ctx_t **ctx)
|
||||
{
|
||||
const wifi_ap_record_t *record = wifi_prov_mgr_wifi_scan_result(result_index);
|
||||
if (!record) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
/* Compile time check ensures memory safety in case SSID length in
|
||||
* record / result structure definition changes in future */
|
||||
_Static_assert(sizeof(result->ssid) == sizeof(record->ssid),
|
||||
"source and destination should be of same size");
|
||||
memcpy(result->ssid, record->ssid, sizeof(record->ssid));
|
||||
memcpy(result->bssid, record->bssid, sizeof(record->bssid));
|
||||
result->channel = record->primary;
|
||||
result->rssi = record->rssi;
|
||||
result->auth = record->authmode;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t get_wifi_scan_handlers(wifi_prov_scan_handlers_t *ptr)
|
||||
{
|
||||
if (!ptr) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
ptr->scan_start = scan_start;
|
||||
ptr->scan_status = scan_status;
|
||||
ptr->scan_result = scan_result;
|
||||
ptr->ctx = NULL;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
static esp_err_t ctrl_reset(void)
|
||||
{
|
||||
return wifi_prov_mgr_reset_sm_state_on_failure();
|
||||
}
|
||||
|
||||
static esp_err_t ctrl_reprov(void)
|
||||
{
|
||||
return wifi_prov_mgr_reset_sm_state_for_reprovision();
|
||||
}
|
||||
|
||||
esp_err_t get_wifi_ctrl_handlers(wifi_ctrl_handlers_t *ptr)
|
||||
{
|
||||
if (!ptr) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
ptr->ctrl_reset = ctrl_reset;
|
||||
ptr->ctrl_reprov = ctrl_reprov;
|
||||
return ESP_OK;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -1,338 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <esp_log.h>
|
||||
#include <esp_err.h>
|
||||
#ifdef CONFIG_BT_CONTROLLER_ENABLED
|
||||
#include "esp_bt.h"
|
||||
#endif
|
||||
|
||||
#include <protocomm.h>
|
||||
#include <protocomm_ble.h>
|
||||
|
||||
#include "wifi_provisioning/scheme_ble.h"
|
||||
#include "wifi_provisioning_priv.h"
|
||||
|
||||
static const char *TAG = "wifi_prov_scheme_ble";
|
||||
|
||||
extern const wifi_prov_scheme_t wifi_prov_scheme_ble;
|
||||
|
||||
static uint8_t *custom_service_uuid;
|
||||
static uint8_t *custom_ble_addr;
|
||||
static uint8_t custom_keep_ble_on;
|
||||
|
||||
static uint8_t *custom_manufacturer_data;
|
||||
static size_t custom_manufacturer_data_len;
|
||||
|
||||
esp_err_t wifi_prov_mgr_keep_ble_on(uint8_t is_on_after_ble_stop)
|
||||
{
|
||||
if (!is_on_after_ble_stop) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
custom_keep_ble_on = is_on_after_ble_stop;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t prov_start(protocomm_t *pc, void *config)
|
||||
{
|
||||
if (!pc) {
|
||||
ESP_LOGE(TAG, "Protocomm handle cannot be null");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (!config) {
|
||||
ESP_LOGE(TAG, "Cannot start with null configuration");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
protocomm_ble_config_t *ble_config = (protocomm_ble_config_t *) config;
|
||||
|
||||
ble_config->keep_ble_on = custom_keep_ble_on;
|
||||
|
||||
#if defined(CONFIG_WIFI_PROV_BLE_BONDING)
|
||||
ble_config->ble_bonding = 1;
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_WIFI_PROV_BLE_SEC_CONN) || defined(CONFIG_BT_BLUEDROID_ENABLED)
|
||||
ble_config->ble_sm_sc = 1;
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_WIFI_PROV_BLE_FORCE_ENCRYPTION)
|
||||
ble_config->ble_link_encryption = 1;
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_WIFI_PROV_BLE_NOTIFY)
|
||||
ble_config->ble_notify = 1;
|
||||
#endif
|
||||
|
||||
/* Start protocomm as BLE service */
|
||||
if (protocomm_ble_start(pc, ble_config) != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to start protocomm BLE service");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t wifi_prov_scheme_ble_set_random_addr(const uint8_t *addr)
|
||||
{
|
||||
if (!addr) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
custom_ble_addr = (uint8_t *) malloc(BLE_ADDR_LEN);
|
||||
if (custom_ble_addr == NULL) {
|
||||
ESP_LOGE(TAG, "Error allocating memory for random address");
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
memcpy(custom_ble_addr, addr, BLE_ADDR_LEN);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t wifi_prov_scheme_ble_set_service_uuid(uint8_t *uuid128)
|
||||
{
|
||||
if (!uuid128) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
custom_service_uuid = uuid128;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t wifi_prov_scheme_ble_set_mfg_data(uint8_t *mfg_data, ssize_t mfg_data_len)
|
||||
{
|
||||
if (!mfg_data || !mfg_data_len) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
custom_manufacturer_data = (uint8_t *) malloc(mfg_data_len);
|
||||
if (custom_manufacturer_data == NULL) {
|
||||
ESP_LOGE(TAG, "Error allocating memory for mfg_data");
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
custom_manufacturer_data_len = mfg_data_len;
|
||||
memcpy(custom_manufacturer_data, mfg_data, mfg_data_len);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static void *new_config(void)
|
||||
{
|
||||
protocomm_ble_config_t *ble_config = calloc(1, sizeof(protocomm_ble_config_t));
|
||||
if (!ble_config) {
|
||||
ESP_LOGE(TAG, "Error allocating memory for new configuration");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* The default provisioning service UUID */
|
||||
const uint8_t service_uuid[16] = {
|
||||
/* LSB <---------------------------------------
|
||||
* ---------------------------------------> MSB */
|
||||
0x07, 0xed, 0x9b, 0x2d, 0x0f, 0x06, 0x7c, 0x87,
|
||||
0x9b, 0x43, 0x43, 0x6b, 0x4d, 0x24, 0x75, 0x17,
|
||||
};
|
||||
|
||||
memcpy(ble_config->service_uuid, service_uuid, sizeof(ble_config->service_uuid));
|
||||
return ble_config;
|
||||
}
|
||||
|
||||
static void delete_config(void *config)
|
||||
{
|
||||
if (!config) {
|
||||
ESP_LOGE(TAG, "Cannot delete null configuration");
|
||||
return;
|
||||
}
|
||||
|
||||
protocomm_ble_config_t *ble_config = (protocomm_ble_config_t *) config;
|
||||
for (unsigned int i = 0; i < ble_config->nu_lookup_count; i++) {
|
||||
free((void *)ble_config->nu_lookup[i].name);
|
||||
}
|
||||
free(ble_config->nu_lookup);
|
||||
free(ble_config);
|
||||
}
|
||||
|
||||
static esp_err_t set_config_service(void *config, const char *service_name, const char *service_key)
|
||||
{
|
||||
if (!config) {
|
||||
ESP_LOGE(TAG, "Cannot set null configuration");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (!service_name) {
|
||||
ESP_LOGE(TAG, "Service name cannot be NULL");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
protocomm_ble_config_t *ble_config = (protocomm_ble_config_t *) config;
|
||||
strlcpy(ble_config->device_name, service_name, sizeof(ble_config->device_name));
|
||||
|
||||
/* If a custom service UUID has been provided, override the default one */
|
||||
if (custom_service_uuid) {
|
||||
memcpy(ble_config->service_uuid, custom_service_uuid, sizeof(ble_config->service_uuid));
|
||||
}
|
||||
/* Set manufacturer data if it is provided by app */
|
||||
if (custom_manufacturer_data) {
|
||||
/* Manufacturer Data Length + 2 Byte header + BLE Device name + 2 Byte
|
||||
* header <= 31 Bytes */
|
||||
|
||||
size_t mfg_data_len = custom_manufacturer_data_len;
|
||||
size_t dev_name_len = strnlen(ble_config->device_name, MAX_BLE_DEVNAME_LEN);
|
||||
|
||||
if ((dev_name_len + 2) >= MAX_BLE_MANUFACTURER_DATA_LEN) {
|
||||
/* No space left for manufacturer data */
|
||||
ESP_LOGE(TAG, "No space left for Manufacturer data ");
|
||||
ble_config->manufacturer_data = NULL;
|
||||
ble_config->manufacturer_data_len = 0;
|
||||
} else {
|
||||
if ((mfg_data_len + (dev_name_len ? (dev_name_len + 2) : 0)) > MAX_BLE_MANUFACTURER_DATA_LEN) {
|
||||
ESP_LOGE(TAG, "Manufacturer data length is more than the max allowed size; expect truncated mfg_data ");
|
||||
/* Truncate the mfg_data to fit in the available length */
|
||||
mfg_data_len = MAX_BLE_MANUFACTURER_DATA_LEN - (dev_name_len ? (dev_name_len + 2) : 0);
|
||||
}
|
||||
|
||||
ble_config->manufacturer_data = custom_manufacturer_data;
|
||||
ble_config->manufacturer_data_len = mfg_data_len;
|
||||
}
|
||||
} else {
|
||||
ble_config->manufacturer_data = NULL;
|
||||
ble_config->manufacturer_data_len = 0;
|
||||
}
|
||||
|
||||
if (custom_ble_addr){
|
||||
ble_config->ble_addr = custom_ble_addr;
|
||||
} else {
|
||||
ble_config->ble_addr = NULL;
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t set_config_endpoint(void *config, const char *endpoint_name, uint16_t uuid)
|
||||
{
|
||||
if (!config) {
|
||||
ESP_LOGE(TAG, "Cannot set null configuration");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (!endpoint_name) {
|
||||
ESP_LOGE(TAG, "EP name cannot be null");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
protocomm_ble_config_t *ble_config = (protocomm_ble_config_t *) config;
|
||||
|
||||
char *copy_ep_name = strdup(endpoint_name);
|
||||
if (!copy_ep_name) {
|
||||
ESP_LOGE(TAG, "Error allocating memory for EP name");
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
protocomm_ble_name_uuid_t *lookup_table = (
|
||||
realloc(ble_config->nu_lookup, (ble_config->nu_lookup_count + 1) * sizeof(protocomm_ble_name_uuid_t)));
|
||||
if (!lookup_table) {
|
||||
ESP_LOGE(TAG, "Error allocating memory for EP-UUID lookup table");
|
||||
free(copy_ep_name);
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
lookup_table[ble_config->nu_lookup_count].name = copy_ep_name;
|
||||
lookup_table[ble_config->nu_lookup_count].uuid = uuid;
|
||||
ble_config->nu_lookup = lookup_table;
|
||||
ble_config->nu_lookup_count += 1;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
/* Used when both BT and BLE are not needed by application */
|
||||
void wifi_prov_scheme_ble_event_cb_free_btdm(void *user_data, wifi_prov_cb_event_t event, void *event_data)
|
||||
{
|
||||
switch (event) {
|
||||
case WIFI_PROV_INIT: {
|
||||
#ifdef CONFIG_BT_CONTROLLER_ENABLED
|
||||
/* Release BT memory, as we need only BLE */
|
||||
esp_err_t err = esp_bt_mem_release(ESP_BT_MODE_CLASSIC_BT);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "bt_mem_release of classic BT failed %d", err);
|
||||
} else {
|
||||
ESP_LOGI(TAG, "BT memory released");
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case WIFI_PROV_DEINIT: {
|
||||
#ifndef CONFIG_WIFI_PROV_KEEP_BLE_ON_AFTER_PROV
|
||||
#ifdef CONFIG_BT_CONTROLLER_ENABLED
|
||||
/* Release memory used by BLE and Bluedroid host stack */
|
||||
esp_err_t err = esp_bt_mem_release(ESP_BT_MODE_BTDM);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "bt_mem_release of BTDM failed %d", err);
|
||||
} else {
|
||||
ESP_LOGI(TAG, "BTDM memory released");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Used when BT is not needed by application */
|
||||
void wifi_prov_scheme_ble_event_cb_free_bt(void *user_data, wifi_prov_cb_event_t event, void *event_data)
|
||||
{
|
||||
switch (event) {
|
||||
case WIFI_PROV_INIT: {
|
||||
#ifdef CONFIG_BT_CONTROLLER_ENABLED
|
||||
esp_err_t err;
|
||||
/* Release BT memory, as we need only BLE */
|
||||
err = esp_bt_mem_release(ESP_BT_MODE_CLASSIC_BT);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "bt_mem_release of classic BT failed %d", err);
|
||||
} else {
|
||||
ESP_LOGI(TAG, "BT memory released");
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Used when BLE is not needed by application */
|
||||
void wifi_prov_scheme_ble_event_cb_free_ble(void *user_data, wifi_prov_cb_event_t event, void *event_data)
|
||||
{
|
||||
switch (event) {
|
||||
case WIFI_PROV_DEINIT: {
|
||||
#ifndef CONFIG_WIFI_PROV_KEEP_BLE_ON_AFTER_PROV
|
||||
#ifdef CONFIG_BT_CONTROLLER_ENABLED
|
||||
esp_err_t err;
|
||||
/* Release memory used by BLE stack */
|
||||
err = esp_bt_mem_release(ESP_BT_MODE_BLE);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "bt_mem_release of BLE failed %d", err);
|
||||
} else {
|
||||
ESP_LOGI(TAG, "BLE memory released");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const wifi_prov_scheme_t wifi_prov_scheme_ble = {
|
||||
.prov_start = prov_start,
|
||||
.prov_stop = protocomm_ble_stop,
|
||||
.new_config = new_config,
|
||||
.delete_config = delete_config,
|
||||
.set_config_service = set_config_service,
|
||||
.set_config_endpoint = set_config_endpoint,
|
||||
.wifi_mode = WIFI_MODE_STA
|
||||
};
|
@@ -1,92 +0,0 @@
|
||||
// Copyright 2019 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 <string.h>
|
||||
#include <esp_log.h>
|
||||
#include <esp_err.h>
|
||||
#include <esp_wifi.h>
|
||||
|
||||
#include <protocomm.h>
|
||||
#include <protocomm_console.h>
|
||||
|
||||
#include "wifi_provisioning/scheme_console.h"
|
||||
#include "wifi_provisioning_priv.h"
|
||||
|
||||
static const char *TAG = "wifi_prov_scheme_console";
|
||||
|
||||
extern const wifi_prov_scheme_t wifi_prov_scheme_console;
|
||||
|
||||
static esp_err_t prov_start(protocomm_t *pc, void *config)
|
||||
{
|
||||
if (!pc) {
|
||||
ESP_LOGE(TAG, "Protocomm handle cannot be null");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (!config) {
|
||||
ESP_LOGE(TAG, "Cannot start with null configuration");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
protocomm_console_config_t *console_config = (protocomm_console_config_t *) config;
|
||||
|
||||
/* Start protocomm console */
|
||||
esp_err_t err = protocomm_console_start(pc, console_config);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to start protocomm HTTP server");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static void *new_config(void)
|
||||
{
|
||||
protocomm_console_config_t *console_config = malloc(sizeof(protocomm_console_config_t));
|
||||
if (!console_config) {
|
||||
ESP_LOGE(TAG, "Error allocating memory for new configuration");
|
||||
return NULL;
|
||||
}
|
||||
protocomm_console_config_t default_config = PROTOCOMM_CONSOLE_DEFAULT_CONFIG();
|
||||
memcpy(console_config, &default_config, sizeof(default_config));
|
||||
return console_config;
|
||||
}
|
||||
|
||||
static void delete_config(void *config)
|
||||
{
|
||||
if (!config) {
|
||||
ESP_LOGE(TAG, "Cannot delete null configuration");
|
||||
return;
|
||||
}
|
||||
free(config);
|
||||
}
|
||||
|
||||
static esp_err_t set_config_service(void *config, const char *service_name, const char *service_key)
|
||||
{
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t set_config_endpoint(void *config, const char *endpoint_name, uint16_t uuid)
|
||||
{
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
const wifi_prov_scheme_t wifi_prov_scheme_console = {
|
||||
.prov_start = prov_start,
|
||||
.prov_stop = protocomm_console_stop,
|
||||
.new_config = new_config,
|
||||
.delete_config = delete_config,
|
||||
.set_config_service = set_config_service,
|
||||
.set_config_endpoint = set_config_endpoint,
|
||||
.wifi_mode = WIFI_MODE_STA
|
||||
};
|
@@ -1,186 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <esp_log.h>
|
||||
#include <esp_err.h>
|
||||
#include <esp_wifi.h>
|
||||
|
||||
#include <protocomm.h>
|
||||
#include <protocomm_httpd.h>
|
||||
|
||||
#include "wifi_provisioning/scheme_softap.h"
|
||||
#include "wifi_provisioning_priv.h"
|
||||
|
||||
typedef struct softap_config {
|
||||
protocomm_httpd_config_t httpd_config;
|
||||
char ssid[33];
|
||||
char password[65];
|
||||
} wifi_prov_softap_config_t;
|
||||
|
||||
static const char *TAG = "wifi_prov_scheme_softap";
|
||||
|
||||
extern const wifi_prov_scheme_t wifi_prov_scheme_softap;
|
||||
static void *scheme_softap_prov_httpd_handle;
|
||||
static esp_err_t start_wifi_ap(const char *ssid, const char *pass)
|
||||
{
|
||||
/* Build Wi-Fi configuration for AP mode */
|
||||
wifi_config_t wifi_config = {
|
||||
.ap = {
|
||||
.max_connection = 5,
|
||||
},
|
||||
};
|
||||
|
||||
/* SSID can be a non NULL terminated string if `ap.ssid_len` is specified
|
||||
* Hence, memcpy is used to support 32 bytes long SSID per 802.11 standard */
|
||||
const size_t ssid_len = strnlen(ssid, sizeof(wifi_config.ap.ssid));
|
||||
memcpy(wifi_config.ap.ssid, ssid, ssid_len);
|
||||
wifi_config.ap.ssid_len = ssid_len;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/* Run Wi-Fi in AP + STA mode with configuration built above */
|
||||
esp_err_t err = esp_wifi_set_mode(WIFI_MODE_APSTA);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to set Wi-Fi 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 Wi-Fi config : %d", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t prov_start(protocomm_t *pc, void *config)
|
||||
{
|
||||
if (!pc) {
|
||||
ESP_LOGE(TAG, "Protocomm handle cannot be null");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (!config) {
|
||||
ESP_LOGE(TAG, "Cannot start with null configuration");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
wifi_prov_softap_config_t *softap_config = (wifi_prov_softap_config_t *) config;
|
||||
|
||||
protocomm_httpd_config_t *httpd_config = &softap_config->httpd_config;
|
||||
|
||||
if (scheme_softap_prov_httpd_handle) {
|
||||
httpd_config->ext_handle_provided = true;
|
||||
httpd_config->data.handle = scheme_softap_prov_httpd_handle;
|
||||
}
|
||||
|
||||
/* Start protocomm server on top of HTTP */
|
||||
esp_err_t err = protocomm_httpd_start(pc, httpd_config);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to start protocomm HTTP server");
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Start Wi-Fi softAP with specified ssid and password */
|
||||
err = start_wifi_ap(softap_config->ssid, softap_config->password);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to start Wi-Fi AP");
|
||||
protocomm_httpd_stop(pc);
|
||||
return err;
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t prov_stop(protocomm_t *pc)
|
||||
{
|
||||
esp_err_t err = protocomm_httpd_stop(pc);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGW(TAG, "Error occurred while stopping protocomm_httpd");
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static void *new_config(void)
|
||||
{
|
||||
wifi_prov_softap_config_t *softap_config = calloc(1, sizeof(wifi_prov_softap_config_t));
|
||||
if (!softap_config) {
|
||||
ESP_LOGE(TAG, "Error allocating memory for new configuration");
|
||||
return NULL;
|
||||
}
|
||||
protocomm_httpd_config_t default_config = {
|
||||
.data = {
|
||||
.config = PROTOCOMM_HTTPD_DEFAULT_CONFIG()
|
||||
}
|
||||
};
|
||||
softap_config->httpd_config = default_config;
|
||||
return softap_config;
|
||||
}
|
||||
|
||||
static void delete_config(void *config)
|
||||
{
|
||||
if (!config) {
|
||||
ESP_LOGE(TAG, "Cannot delete null configuration");
|
||||
return;
|
||||
}
|
||||
|
||||
wifi_prov_softap_config_t *softap_config = (wifi_prov_softap_config_t *) config;
|
||||
free(softap_config);
|
||||
}
|
||||
|
||||
static esp_err_t set_config_service(void *config, const char *service_name, const char *service_key)
|
||||
{
|
||||
if (!config) {
|
||||
ESP_LOGE(TAG, "Cannot set null configuration");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (!service_name) {
|
||||
ESP_LOGE(TAG, "Service name cannot be NULL");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
wifi_prov_softap_config_t *softap_config = (wifi_prov_softap_config_t *) config;
|
||||
if (service_key) {
|
||||
const int service_key_len = strlen(service_key);
|
||||
if (service_key_len < 8 || service_key_len >= sizeof(softap_config->password)) {
|
||||
ESP_LOGE(TAG, "Incorrect passphrase length for softAP: %d (Expected: Min - 8, Max - 64)", service_key_len);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
strlcpy(softap_config->password, service_key, sizeof(softap_config->password));
|
||||
}
|
||||
strlcpy(softap_config->ssid, service_name, sizeof(softap_config->ssid));
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t set_config_endpoint(void *config, const char *endpoint_name, uint16_t uuid)
|
||||
{
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
void wifi_prov_scheme_softap_set_httpd_handle(void *handle)
|
||||
{
|
||||
scheme_softap_prov_httpd_handle = handle;
|
||||
}
|
||||
|
||||
const wifi_prov_scheme_t wifi_prov_scheme_softap = {
|
||||
.prov_start = prov_start,
|
||||
.prov_stop = prov_stop,
|
||||
.new_config = new_config,
|
||||
.delete_config = delete_config,
|
||||
.set_config_service = set_config_service,
|
||||
.set_config_endpoint = set_config_endpoint,
|
||||
.wifi_mode = WIFI_MODE_APSTA
|
||||
};
|
@@ -1,347 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <esp_err.h>
|
||||
#include <esp_log.h>
|
||||
|
||||
#include "wifi_constants.pb-c.h"
|
||||
#include "wifi_config.pb-c.h"
|
||||
|
||||
#include <wifi_provisioning/wifi_config.h>
|
||||
|
||||
static const char* TAG = "WiFiProvConfig";
|
||||
|
||||
typedef struct wifi_prov_config_cmd {
|
||||
int cmd_num;
|
||||
esp_err_t (*command_handler)(WiFiConfigPayload *req,
|
||||
WiFiConfigPayload *resp, void *priv_data);
|
||||
} wifi_prov_config_cmd_t;
|
||||
|
||||
static esp_err_t cmd_get_status_handler(WiFiConfigPayload *req,
|
||||
WiFiConfigPayload *resp, void *priv_data);
|
||||
|
||||
static esp_err_t cmd_set_config_handler(WiFiConfigPayload *req,
|
||||
WiFiConfigPayload *resp, void *priv_data);
|
||||
|
||||
static esp_err_t cmd_apply_config_handler(WiFiConfigPayload *req,
|
||||
WiFiConfigPayload *resp, void *priv_data);
|
||||
|
||||
static wifi_prov_config_cmd_t cmd_table[] = {
|
||||
{
|
||||
.cmd_num = WI_FI_CONFIG_MSG_TYPE__TypeCmdGetStatus,
|
||||
.command_handler = cmd_get_status_handler
|
||||
},
|
||||
{
|
||||
.cmd_num = WI_FI_CONFIG_MSG_TYPE__TypeCmdSetConfig,
|
||||
.command_handler = cmd_set_config_handler
|
||||
},
|
||||
{
|
||||
.cmd_num = WI_FI_CONFIG_MSG_TYPE__TypeCmdApplyConfig,
|
||||
.command_handler = cmd_apply_config_handler
|
||||
}
|
||||
};
|
||||
|
||||
static esp_err_t cmd_get_status_handler(WiFiConfigPayload *req,
|
||||
WiFiConfigPayload *resp, void *priv_data)
|
||||
{
|
||||
ESP_LOGD(TAG, "Enter cmd_get_status_handler");
|
||||
wifi_prov_config_handlers_t *h = (wifi_prov_config_handlers_t *) priv_data;
|
||||
if (!h) {
|
||||
ESP_LOGE(TAG, "Command invoked without handlers");
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
RespGetStatus *resp_payload = (RespGetStatus *) malloc(sizeof(RespGetStatus));
|
||||
if (!resp_payload) {
|
||||
ESP_LOGE(TAG, "Error allocating memory");
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
resp_get_status__init(resp_payload);
|
||||
|
||||
wifi_prov_config_get_data_t resp_data;
|
||||
if (h->get_status_handler(&resp_data, &h->ctx) == ESP_OK) {
|
||||
if (resp_data.wifi_state == WIFI_PROV_STA_CONNECTING) {
|
||||
resp_payload->sta_state = WIFI_STATION_STATE__Connecting;
|
||||
resp_payload->state_case = RESP_GET_STATUS__STATE_CONNECTED;
|
||||
} else if (resp_data.wifi_state == WIFI_PROV_STA_CONNECTED) {
|
||||
resp_payload->sta_state = WIFI_STATION_STATE__Connected;
|
||||
resp_payload->state_case = RESP_GET_STATUS__STATE_CONNECTED;
|
||||
WifiConnectedState *connected = (WifiConnectedState *)(
|
||||
malloc(sizeof(WifiConnectedState)));
|
||||
if (!connected) {
|
||||
free(resp_payload);
|
||||
ESP_LOGE(TAG, "Error allocating memory");
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
resp_payload->connected = connected;
|
||||
wifi_connected_state__init(connected);
|
||||
|
||||
connected->ip4_addr = strdup(resp_data.conn_info.ip_addr);
|
||||
if (connected->ip4_addr == NULL) {
|
||||
free(resp_payload);
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
connected->bssid.len = sizeof(resp_data.conn_info.bssid);
|
||||
connected->bssid.data = (uint8_t *) strndup(resp_data.conn_info.bssid,
|
||||
sizeof(resp_data.conn_info.bssid));
|
||||
if (connected->bssid.data == NULL) {
|
||||
free(connected->ip4_addr);
|
||||
free(resp_payload);
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
connected->ssid.len = strlen(resp_data.conn_info.ssid);
|
||||
connected->ssid.data = (uint8_t *) strdup(resp_data.conn_info.ssid);
|
||||
if (connected->ssid.data == NULL) {
|
||||
free(connected->bssid.data);
|
||||
free(connected->ip4_addr);
|
||||
free(resp_payload);
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
connected->channel = resp_data.conn_info.channel;
|
||||
connected->auth_mode = resp_data.conn_info.auth_mode;
|
||||
} else if (resp_data.wifi_state == WIFI_PROV_STA_DISCONNECTED) {
|
||||
resp_payload->sta_state = WIFI_STATION_STATE__ConnectionFailed;
|
||||
resp_payload->state_case = RESP_GET_STATUS__STATE_FAIL_REASON;
|
||||
|
||||
if (resp_data.fail_reason == WIFI_PROV_STA_AUTH_ERROR) {
|
||||
resp_payload->fail_reason = WIFI_CONNECT_FAILED_REASON__AuthError;
|
||||
} else if (resp_data.fail_reason == WIFI_PROV_STA_AP_NOT_FOUND) {
|
||||
resp_payload->fail_reason = WIFI_CONNECT_FAILED_REASON__NetworkNotFound;
|
||||
}
|
||||
} else if (resp_data.wifi_state == WIFI_PROV_STA_CONN_ATTEMPT_FAILED) {
|
||||
resp_payload->sta_state = WIFI_STATION_STATE__Connecting;
|
||||
resp_payload->state_case = RESP_GET_STATUS__STATE_ATTEMPT_FAILED;
|
||||
WifiAttemptFailed *attempt_failed = (WifiAttemptFailed *)(
|
||||
calloc(1, sizeof(WifiAttemptFailed)));
|
||||
if (!attempt_failed) {
|
||||
free(resp_payload);
|
||||
ESP_LOGE(TAG, "Error allocating memory");
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
wifi_attempt_failed__init(attempt_failed);
|
||||
attempt_failed->attempts_remaining = resp_data.connecting_info.attempts_remaining;
|
||||
resp_payload->attempt_failed = attempt_failed;
|
||||
}
|
||||
resp_payload->status = STATUS__Success;
|
||||
}
|
||||
|
||||
resp->payload_case = WI_FI_CONFIG_PAYLOAD__PAYLOAD_RESP_GET_STATUS;
|
||||
resp->resp_get_status = resp_payload;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t cmd_set_config_handler(WiFiConfigPayload *req,
|
||||
WiFiConfigPayload *resp, void *priv_data)
|
||||
{
|
||||
ESP_LOGD(TAG, "Enter cmd_set_config_handler");
|
||||
wifi_prov_config_handlers_t *h = (wifi_prov_config_handlers_t *) priv_data;
|
||||
if (!h) {
|
||||
ESP_LOGE(TAG, "Command invoked without handlers");
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
RespSetConfig *resp_payload = (RespSetConfig *) malloc(sizeof(RespSetConfig));
|
||||
if (resp_payload == NULL) {
|
||||
ESP_LOGE(TAG, "Error allocating memory");
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
resp_set_config__init(resp_payload);
|
||||
|
||||
wifi_prov_config_set_data_t req_data;
|
||||
memset(&req_data, 0, sizeof(req_data));
|
||||
|
||||
/* Check arguments provided in protobuf packet:
|
||||
* - SSID / Passphrase string length must be within the standard limits
|
||||
* - BSSID must either be NULL or have length equal to that imposed by the standard
|
||||
* If any of these conditions are not satisfied, don't invoke the handler and
|
||||
* send error status without closing connection */
|
||||
resp_payload->status = STATUS__InvalidArgument;
|
||||
if (req->cmd_set_config->bssid.len != 0 &&
|
||||
req->cmd_set_config->bssid.len != sizeof(req_data.bssid)) {
|
||||
ESP_LOGD(TAG, "Received invalid BSSID");
|
||||
} else if (req->cmd_set_config->ssid.len >= sizeof(req_data.ssid)) {
|
||||
ESP_LOGD(TAG, "Received invalid SSID");
|
||||
} else if (req->cmd_set_config->passphrase.len >= sizeof(req_data.password)) {
|
||||
ESP_LOGD(TAG, "Received invalid Passphrase");
|
||||
} else {
|
||||
/* The received SSID and Passphrase are not NULL terminated so
|
||||
* we memcpy over zeroed out arrays. Above length checks ensure
|
||||
* that there is at least 1 extra byte for null termination */
|
||||
memcpy(req_data.ssid, req->cmd_set_config->ssid.data,
|
||||
req->cmd_set_config->ssid.len);
|
||||
memcpy(req_data.password, req->cmd_set_config->passphrase.data,
|
||||
req->cmd_set_config->passphrase.len);
|
||||
memcpy(req_data.bssid, req->cmd_set_config->bssid.data,
|
||||
req->cmd_set_config->bssid.len);
|
||||
req_data.channel = req->cmd_set_config->channel;
|
||||
if (h->set_config_handler(&req_data, &h->ctx) == ESP_OK) {
|
||||
resp_payload->status = STATUS__Success;
|
||||
} else {
|
||||
resp_payload->status = STATUS__InternalError;
|
||||
}
|
||||
}
|
||||
|
||||
resp->payload_case = WI_FI_CONFIG_PAYLOAD__PAYLOAD_RESP_SET_CONFIG;
|
||||
resp->resp_set_config = resp_payload;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t cmd_apply_config_handler(WiFiConfigPayload *req,
|
||||
WiFiConfigPayload *resp, void *priv_data)
|
||||
{
|
||||
ESP_LOGD(TAG, "Enter cmd_apply_config_handler");
|
||||
wifi_prov_config_handlers_t *h = (wifi_prov_config_handlers_t *) priv_data;
|
||||
if (!h) {
|
||||
ESP_LOGE(TAG, "Command invoked without handlers");
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
RespApplyConfig *resp_payload = (RespApplyConfig *) malloc(sizeof(RespApplyConfig));
|
||||
if (!resp_payload) {
|
||||
ESP_LOGE(TAG, "Error allocating memory");
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
resp_apply_config__init(resp_payload);
|
||||
|
||||
if (h->apply_config_handler(&h->ctx) == ESP_OK) {
|
||||
resp_payload->status = STATUS__Success;
|
||||
} else {
|
||||
resp_payload->status = STATUS__InternalError;
|
||||
}
|
||||
|
||||
resp->payload_case = WI_FI_CONFIG_PAYLOAD__PAYLOAD_RESP_APPLY_CONFIG;
|
||||
resp->resp_apply_config = resp_payload;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static int lookup_cmd_handler(int cmd_id)
|
||||
{
|
||||
for (size_t i = 0; i < sizeof(cmd_table)/sizeof(wifi_prov_config_cmd_t); i++) {
|
||||
if (cmd_table[i].cmd_num == cmd_id) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
static void wifi_prov_config_command_cleanup(WiFiConfigPayload *resp, void *priv_data)
|
||||
{
|
||||
if (!resp) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (resp->msg) {
|
||||
case WI_FI_CONFIG_MSG_TYPE__TypeRespGetStatus:
|
||||
{
|
||||
switch (resp->resp_get_status->sta_state) {
|
||||
case WIFI_STATION_STATE__Connecting:
|
||||
break;
|
||||
case WIFI_STATION_STATE__Connected:
|
||||
if (resp->resp_get_status->connected) {
|
||||
if (resp->resp_get_status->connected->ip4_addr) {
|
||||
free(resp->resp_get_status->connected->ip4_addr);
|
||||
}
|
||||
if (resp->resp_get_status->connected->bssid.data) {
|
||||
free(resp->resp_get_status->connected->bssid.data);
|
||||
}
|
||||
if (resp->resp_get_status->connected->ssid.data) {
|
||||
free(resp->resp_get_status->connected->ssid.data);
|
||||
}
|
||||
free(resp->resp_get_status->connected);
|
||||
}
|
||||
break;
|
||||
case WIFI_STATION_STATE__ConnectionFailed:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
free(resp->resp_get_status);
|
||||
}
|
||||
break;
|
||||
case WI_FI_CONFIG_MSG_TYPE__TypeRespSetConfig:
|
||||
{
|
||||
free(resp->resp_set_config);
|
||||
}
|
||||
break;
|
||||
case WI_FI_CONFIG_MSG_TYPE__TypeRespApplyConfig:
|
||||
{
|
||||
free(resp->resp_apply_config);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ESP_LOGE(TAG, "Unsupported response type in cleanup_handler");
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static esp_err_t wifi_prov_config_command_dispatcher(WiFiConfigPayload *req,
|
||||
WiFiConfigPayload *resp, void *priv_data)
|
||||
{
|
||||
esp_err_t ret;
|
||||
|
||||
ESP_LOGD(TAG, "In wifi_prov_config_command_dispatcher Cmd=%d", req->msg);
|
||||
|
||||
int cmd_index = lookup_cmd_handler(req->msg);
|
||||
if (cmd_index < 0) {
|
||||
ESP_LOGE(TAG, "Invalid command handler lookup");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
ret = cmd_table[cmd_index].command_handler(req, resp, priv_data);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Error executing command handler");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t wifi_prov_config_data_handler(uint32_t session_id, const uint8_t *inbuf, ssize_t inlen,
|
||||
uint8_t **outbuf, ssize_t *outlen, void *priv_data)
|
||||
{
|
||||
WiFiConfigPayload *req;
|
||||
WiFiConfigPayload resp;
|
||||
esp_err_t ret;
|
||||
|
||||
req = wi_fi_config_payload__unpack(NULL, inlen, inbuf);
|
||||
if (!req) {
|
||||
ESP_LOGE(TAG, "Unable to unpack config data");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
wi_fi_config_payload__init(&resp);
|
||||
ret = wifi_prov_config_command_dispatcher(req, &resp, priv_data);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Proto command dispatcher error %d", ret);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
resp.msg = req->msg + 1; /* Response is request + 1 */
|
||||
wi_fi_config_payload__free_unpacked(req, NULL);
|
||||
|
||||
*outlen = wi_fi_config_payload__get_packed_size(&resp);
|
||||
if (*outlen <= 0) {
|
||||
ESP_LOGE(TAG, "Invalid encoding for response");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
*outbuf = (uint8_t *) malloc(*outlen);
|
||||
if (!*outbuf) {
|
||||
ESP_LOGE(TAG, "System out of memory");
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
wi_fi_config_payload__pack(&resp, *outbuf);
|
||||
wifi_prov_config_command_cleanup(&resp, priv_data);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
@@ -1,183 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <esp_log.h>
|
||||
#include <string.h>
|
||||
#include <esp_err.h>
|
||||
|
||||
#include "wifi_ctrl.pb-c.h"
|
||||
|
||||
#include "wifi_ctrl.h"
|
||||
|
||||
static const char *TAG = "proto_wifi_ctrl";
|
||||
|
||||
typedef struct wifi_ctrl_cmd {
|
||||
int cmd_id;
|
||||
esp_err_t (*command_handler)(WiFiCtrlPayload *req,
|
||||
WiFiCtrlPayload *resp, void *priv_data);
|
||||
} wifi_ctrl_cmd_t;
|
||||
|
||||
static esp_err_t cmd_ctrl_reset_handler(WiFiCtrlPayload *req,
|
||||
WiFiCtrlPayload *resp,
|
||||
void *priv_data);
|
||||
|
||||
static esp_err_t cmd_ctrl_reprov_handler(WiFiCtrlPayload *req,
|
||||
WiFiCtrlPayload *resp,
|
||||
void *priv_data);
|
||||
|
||||
static wifi_ctrl_cmd_t cmd_table[] = {
|
||||
{
|
||||
.cmd_id = WI_FI_CTRL_MSG_TYPE__TypeCmdCtrlReset,
|
||||
.command_handler = cmd_ctrl_reset_handler
|
||||
},
|
||||
{
|
||||
.cmd_id = WI_FI_CTRL_MSG_TYPE__TypeCmdCtrlReprov,
|
||||
.command_handler = cmd_ctrl_reprov_handler
|
||||
},
|
||||
};
|
||||
|
||||
static esp_err_t cmd_ctrl_reset_handler(WiFiCtrlPayload *req,
|
||||
WiFiCtrlPayload *resp, void *priv_data)
|
||||
{
|
||||
wifi_ctrl_handlers_t *h = (wifi_ctrl_handlers_t *) priv_data;
|
||||
if (!h) {
|
||||
ESP_LOGE(TAG, "Command invoked without handlers");
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
RespCtrlReset *resp_payload = (RespCtrlReset *) malloc(sizeof(RespCtrlReset));
|
||||
if (!resp_payload) {
|
||||
ESP_LOGE(TAG, "Error allocating memory");
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
resp_ctrl_reset__init(resp_payload);
|
||||
resp->status = (h->ctrl_reset() == ESP_OK ?
|
||||
STATUS__Success : STATUS__InternalError);
|
||||
resp->payload_case = WI_FI_CTRL_PAYLOAD__PAYLOAD_RESP_CTRL_RESET;
|
||||
resp->resp_ctrl_reset = resp_payload;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t cmd_ctrl_reprov_handler(WiFiCtrlPayload *req,
|
||||
WiFiCtrlPayload *resp, void *priv_data)
|
||||
{
|
||||
wifi_ctrl_handlers_t *h = (wifi_ctrl_handlers_t *) priv_data;
|
||||
if (!h) {
|
||||
ESP_LOGE(TAG, "Command invoked without handlers");
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
RespCtrlReprov *resp_payload = (RespCtrlReprov *) malloc(sizeof(RespCtrlReprov));
|
||||
if (!resp_payload) {
|
||||
ESP_LOGE(TAG, "Error allocating memory");
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
resp_ctrl_reprov__init(resp_payload);
|
||||
resp->status = (h->ctrl_reprov() == ESP_OK ?
|
||||
STATUS__Success : STATUS__InternalError);
|
||||
resp->payload_case = WI_FI_CTRL_PAYLOAD__PAYLOAD_RESP_CTRL_REPROV;
|
||||
resp->resp_ctrl_reprov = resp_payload;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static int lookup_cmd_handler(int cmd_id)
|
||||
{
|
||||
for (size_t i = 0; i < sizeof(cmd_table)/sizeof(wifi_ctrl_cmd_t); i++) {
|
||||
if (cmd_table[i].cmd_id == cmd_id) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void wifi_ctrl_cmd_cleanup(WiFiCtrlPayload *resp, void *priv_data)
|
||||
{
|
||||
switch (resp->msg) {
|
||||
case WI_FI_CTRL_MSG_TYPE__TypeRespCtrlReset:
|
||||
{
|
||||
free(resp->resp_ctrl_reset);
|
||||
}
|
||||
break;
|
||||
case WI_FI_CTRL_MSG_TYPE__TypeRespCtrlReprov:
|
||||
{
|
||||
free(resp->resp_ctrl_reprov);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ESP_LOGE(TAG, "Unsupported response type in cleanup_handler");
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static esp_err_t wifi_ctrl_cmd_dispatcher(WiFiCtrlPayload *req,
|
||||
WiFiCtrlPayload *resp, void *priv_data)
|
||||
{
|
||||
esp_err_t ret;
|
||||
|
||||
ESP_LOGD(TAG, "In wifi_ctrl_cmd_dispatcher Cmd=%d", req->msg);
|
||||
|
||||
int cmd_index = lookup_cmd_handler(req->msg);
|
||||
if (cmd_index < 0) {
|
||||
ESP_LOGE(TAG, "Failed to find cmd with ID = %d in the command table", req->msg);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
ret = cmd_table[cmd_index].command_handler(req, resp, priv_data);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Error executing command handler");
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t wifi_ctrl_handler(uint32_t session_id, const uint8_t *inbuf, ssize_t inlen,
|
||||
uint8_t **outbuf, ssize_t *outlen, void *priv_data)
|
||||
{
|
||||
WiFiCtrlPayload *req;
|
||||
WiFiCtrlPayload resp;
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
req = wi_fi_ctrl_payload__unpack(NULL, inlen, inbuf);
|
||||
if (!req) {
|
||||
ESP_LOGE(TAG, "Unable to unpack ctrl message");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
wi_fi_ctrl_payload__init(&resp);
|
||||
ret = wifi_ctrl_cmd_dispatcher(req, &resp, priv_data);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Command dispatcher error %02X", ret);
|
||||
ret = ESP_FAIL;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
resp.msg = req->msg + 1; /* Response is request + 1 */
|
||||
*outlen = wi_fi_ctrl_payload__get_packed_size(&resp);
|
||||
if (*outlen <= 0) {
|
||||
ESP_LOGE(TAG, "Invalid encoding for response");
|
||||
ret = ESP_FAIL;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
*outbuf = (uint8_t *) malloc(*outlen);
|
||||
if (!*outbuf) {
|
||||
ESP_LOGE(TAG, "Failed to allocate memory for the output buffer");
|
||||
ret = ESP_ERR_NO_MEM;
|
||||
goto exit;
|
||||
}
|
||||
wi_fi_ctrl_payload__pack(&resp, *outbuf);
|
||||
ESP_LOGD(TAG, "Response packet size : %d", *outlen);
|
||||
exit:
|
||||
|
||||
wi_fi_ctrl_payload__free_unpacked(req, NULL);
|
||||
wifi_ctrl_cmd_cleanup(&resp, priv_data);
|
||||
return ret;
|
||||
}
|
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _PROV_WIFI_CTRL_H_
|
||||
#define _PROV_WIFI_CTRL_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Internal handlers for receiving and responding to protocomm
|
||||
* requests from client
|
||||
*
|
||||
* This is to be passed as priv_data for protocomm request handler
|
||||
* (refer to `wifi_ctrl_handler()`) when calling `protocomm_add_endpoint()`.
|
||||
*/
|
||||
typedef struct wifi_ctrl_handlers {
|
||||
/**
|
||||
* Handler function called when ctrl reset command is received
|
||||
*/
|
||||
esp_err_t (*ctrl_reset)(void);
|
||||
|
||||
/**
|
||||
* Handler function called when ctrl reprov command is received
|
||||
*/
|
||||
esp_err_t (*ctrl_reprov)(void);
|
||||
|
||||
} wifi_ctrl_handlers_t;
|
||||
|
||||
/**
|
||||
* @brief Handler for sending on demand Wi-Fi ctrl results
|
||||
*
|
||||
* This is to be registered as the `prov-ctrl` endpoint handler
|
||||
* (protocomm `protocomm_req_handler_t`) using `protocomm_add_endpoint()`
|
||||
*/
|
||||
esp_err_t wifi_ctrl_handler(uint32_t session_id, const uint8_t *inbuf, ssize_t inlen,
|
||||
uint8_t **outbuf, ssize_t *outlen, void *priv_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@@ -1,121 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <protocomm.h>
|
||||
#include <protocomm_security.h>
|
||||
|
||||
#include "wifi_provisioning/manager.h"
|
||||
#include "wifi_provisioning/wifi_config.h"
|
||||
#include "wifi_provisioning/wifi_scan.h"
|
||||
#include "wifi_ctrl.h"
|
||||
|
||||
/**
|
||||
* @brief Notify manager that provisioning is done
|
||||
*
|
||||
* Stops the provisioning. This is called by the get_status_handler()
|
||||
* when the status is connected. This has no effect if main application
|
||||
* has disabled auto stop on completion by calling
|
||||
* wifi_prov_mgr_disable_auto_stop()
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Provisioning will be stopped
|
||||
* - ESP_FAIL : Failed to stop provisioning
|
||||
*/
|
||||
esp_err_t wifi_prov_mgr_done(void);
|
||||
|
||||
/**
|
||||
* @brief Start Wi-Fi AP Scan
|
||||
*
|
||||
* @param[in] blocking Set true to return only after scanning is complete
|
||||
* @param[in] passive Set true to perform passive scan instead of default active scan
|
||||
* @param[in] group_channels Number of channels to scan in one go
|
||||
* (set to 0 for scanning all channels in one go)
|
||||
* @param[in] period_ms Scan time (in milli-seconds) on each channel
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Successfully started Wi-Fi scanning
|
||||
* - ESP_FAIL : Provisioning app not running
|
||||
*/
|
||||
esp_err_t wifi_prov_mgr_wifi_scan_start(bool blocking, bool passive,
|
||||
uint8_t group_channels,
|
||||
uint32_t period_ms);
|
||||
|
||||
/**
|
||||
* @brief Use to query the state of Wi-Fi scan
|
||||
*
|
||||
* @return
|
||||
* - true : Scan finished
|
||||
* - false : Scan running
|
||||
*/
|
||||
bool wifi_prov_mgr_wifi_scan_finished(void);
|
||||
|
||||
/**
|
||||
* @brief Get the count of results in the scan list
|
||||
*
|
||||
* @return
|
||||
* - count : Number of Wi-Fi Access Points detected while scanning
|
||||
*/
|
||||
uint16_t wifi_prov_mgr_wifi_scan_result_count(void);
|
||||
|
||||
/**
|
||||
* @brief Get AP record for a particular index in the scan list result
|
||||
*
|
||||
* @param[out] index Index of the result to fetch
|
||||
*
|
||||
* @return
|
||||
* - result : Pointer to Access Point record
|
||||
*/
|
||||
const wifi_ap_record_t *wifi_prov_mgr_wifi_scan_result(uint16_t index);
|
||||
|
||||
/**
|
||||
* @brief Get protocomm handlers for wifi_config provisioning endpoint
|
||||
*
|
||||
* @param[out] ptr pointer to structure to be set
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - ESP_ERR_INVALID_ARG : null argument
|
||||
*/
|
||||
esp_err_t get_wifi_prov_handlers(wifi_prov_config_handlers_t *ptr);
|
||||
|
||||
/**
|
||||
* @brief Get protocomm handlers for wifi_scan provisioning endpoint
|
||||
*
|
||||
* @param[out] ptr pointer to structure to be set
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - ESP_ERR_INVALID_ARG : null argument
|
||||
*/
|
||||
esp_err_t get_wifi_scan_handlers(wifi_prov_scan_handlers_t *ptr);
|
||||
|
||||
/**
|
||||
* @brief Get protocomm handlers for wifi_ctrl provisioning endpoint
|
||||
*
|
||||
* @param[in] ptr pointer to structure to be set
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - ESP_ERR_INVALID_ARG : null argument
|
||||
*/
|
||||
esp_err_t get_wifi_ctrl_handlers(wifi_ctrl_handlers_t *ptr);
|
||||
|
||||
/**
|
||||
* @brief Retrieve the remaining number of Wi-Fi connection attempts
|
||||
*
|
||||
* This function provides the number of connection attempts left for
|
||||
* the Wi-Fi provisioning manager before reaching the maximum retry limit.
|
||||
*
|
||||
* @param[out] attempts_remaining Pointer to store the remaining connection attempts
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Success
|
||||
* - ESP_ERR_INVALID_ARG: Null pointer provided for attempts_remaining
|
||||
* - ESP_FAIL: Failed to retrieve the remaining attempts
|
||||
*/
|
||||
esp_err_t wifi_prov_mgr_get_remaining_conn_attempts(uint32_t *attempts_remaining);
|
@@ -1,300 +0,0 @@
|
||||
// Copyright 2019 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 <stdio.h>
|
||||
#include <esp_log.h>
|
||||
#include <string.h>
|
||||
#include <esp_err.h>
|
||||
#include <esp_wifi.h>
|
||||
|
||||
#include "wifi_scan.pb-c.h"
|
||||
|
||||
#include <wifi_provisioning/wifi_scan.h>
|
||||
|
||||
static const char *TAG = "proto_wifi_scan";
|
||||
|
||||
typedef struct wifi_prov_scan_cmd {
|
||||
int cmd_num;
|
||||
esp_err_t (*command_handler)(WiFiScanPayload *req,
|
||||
WiFiScanPayload *resp, void *priv_data);
|
||||
} wifi_prov_scan_cmd_t;
|
||||
|
||||
static esp_err_t cmd_scan_start_handler(WiFiScanPayload *req,
|
||||
WiFiScanPayload *resp,
|
||||
void *priv_data);
|
||||
|
||||
static esp_err_t cmd_scan_status_handler(WiFiScanPayload *req,
|
||||
WiFiScanPayload *resp,
|
||||
void *priv_data);
|
||||
|
||||
static esp_err_t cmd_scan_result_handler(WiFiScanPayload *req,
|
||||
WiFiScanPayload *resp,
|
||||
void *priv_data);
|
||||
|
||||
static wifi_prov_scan_cmd_t cmd_table[] = {
|
||||
{
|
||||
.cmd_num = WI_FI_SCAN_MSG_TYPE__TypeCmdScanStart,
|
||||
.command_handler = cmd_scan_start_handler
|
||||
},
|
||||
{
|
||||
.cmd_num = WI_FI_SCAN_MSG_TYPE__TypeCmdScanStatus,
|
||||
.command_handler = cmd_scan_status_handler
|
||||
},
|
||||
{
|
||||
.cmd_num = WI_FI_SCAN_MSG_TYPE__TypeCmdScanResult,
|
||||
.command_handler = cmd_scan_result_handler
|
||||
}
|
||||
};
|
||||
|
||||
static esp_err_t cmd_scan_start_handler(WiFiScanPayload *req,
|
||||
WiFiScanPayload *resp, void *priv_data)
|
||||
{
|
||||
wifi_prov_scan_handlers_t *h = (wifi_prov_scan_handlers_t *) priv_data;
|
||||
if (!h) {
|
||||
ESP_LOGE(TAG, "Command invoked without handlers");
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
RespScanStart *resp_payload = (RespScanStart *) malloc(sizeof(RespScanStart));
|
||||
if (!resp_payload) {
|
||||
ESP_LOGE(TAG, "Error allocating memory");
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
resp_scan_start__init(resp_payload);
|
||||
resp->status = (h->scan_start(req->cmd_scan_start->blocking,
|
||||
req->cmd_scan_start->passive,
|
||||
req->cmd_scan_start->group_channels,
|
||||
req->cmd_scan_start->period_ms,
|
||||
&h->ctx) == ESP_OK ?
|
||||
STATUS__Success : STATUS__InternalError);
|
||||
resp->payload_case = WI_FI_SCAN_PAYLOAD__PAYLOAD_RESP_SCAN_START;
|
||||
resp->resp_scan_start = resp_payload;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t cmd_scan_status_handler(WiFiScanPayload *req,
|
||||
WiFiScanPayload *resp, void *priv_data)
|
||||
{
|
||||
bool scan_finished = false;
|
||||
uint16_t result_count = 0;
|
||||
|
||||
wifi_prov_scan_handlers_t *h = (wifi_prov_scan_handlers_t *) priv_data;
|
||||
if (!h) {
|
||||
ESP_LOGE(TAG, "Command invoked without handlers");
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
RespScanStatus *resp_payload = (RespScanStatus *) malloc(sizeof(RespScanStatus));
|
||||
if (!resp_payload) {
|
||||
ESP_LOGE(TAG, "Error allocating memory");
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
resp_scan_status__init(resp_payload);
|
||||
resp->status = (h->scan_status(&scan_finished, &result_count, &h->ctx) == ESP_OK ?
|
||||
STATUS__Success : STATUS__InternalError);
|
||||
resp_payload->scan_finished = scan_finished;
|
||||
resp_payload->result_count = result_count;
|
||||
resp->payload_case = WI_FI_SCAN_PAYLOAD__PAYLOAD_RESP_SCAN_STATUS;
|
||||
resp->resp_scan_status = resp_payload;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t cmd_scan_result_handler(WiFiScanPayload *req,
|
||||
WiFiScanPayload *resp, void *priv_data)
|
||||
{
|
||||
esp_err_t err;
|
||||
wifi_prov_scan_result_t scan_result = {{0}, {0}, 0, 0, 0};
|
||||
WiFiScanResult **results = NULL;
|
||||
wifi_prov_scan_handlers_t *h = (wifi_prov_scan_handlers_t *) priv_data;
|
||||
if (!h) {
|
||||
ESP_LOGE(TAG, "Command invoked without handlers");
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
RespScanResult *resp_payload = (RespScanResult *) malloc(sizeof(RespScanResult));
|
||||
if (!resp_payload) {
|
||||
ESP_LOGE(TAG, "Error allocating memory");
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
resp_scan_result__init(resp_payload);
|
||||
|
||||
resp->status = STATUS__Success;
|
||||
resp->payload_case = WI_FI_SCAN_PAYLOAD__PAYLOAD_RESP_SCAN_RESULT;
|
||||
resp->resp_scan_result = resp_payload;
|
||||
/* Allocate memory only if there are non-zero scan results */
|
||||
if (req->cmd_scan_result->count) {
|
||||
results = (WiFiScanResult **) calloc(req->cmd_scan_result->count,
|
||||
sizeof(WiFiScanResult *));
|
||||
if (!results) {
|
||||
ESP_LOGE(TAG, "Failed to allocate memory for results array");
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
}
|
||||
resp_payload->entries = results;
|
||||
resp_payload->n_entries = req->cmd_scan_result->count;
|
||||
|
||||
/* If req->cmd_scan_result->count is 0, the below loop will
|
||||
* be skipped.
|
||||
*/
|
||||
for (uint16_t i = 0; i < req->cmd_scan_result->count; i++) {
|
||||
err = h->scan_result(i + req->cmd_scan_result->start_index,
|
||||
&scan_result, &h->ctx);
|
||||
if (err != ESP_OK) {
|
||||
resp->status = STATUS__InternalError;
|
||||
break;
|
||||
}
|
||||
|
||||
results[i] = (WiFiScanResult *) malloc(sizeof(WiFiScanResult));
|
||||
if (!results[i]) {
|
||||
ESP_LOGE(TAG, "Failed to allocate memory for result entry");
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
wi_fi_scan_result__init(results[i]);
|
||||
|
||||
results[i]->ssid.len = strnlen(scan_result.ssid, 32);
|
||||
results[i]->ssid.data = (uint8_t *) strndup(scan_result.ssid, 32);
|
||||
if (!results[i]->ssid.data) {
|
||||
ESP_LOGE(TAG, "Failed to allocate memory for scan result entry SSID");
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
results[i]->channel = scan_result.channel;
|
||||
results[i]->rssi = scan_result.rssi;
|
||||
results[i]->auth = scan_result.auth;
|
||||
|
||||
results[i]->bssid.len = sizeof(scan_result.bssid);
|
||||
results[i]->bssid.data = malloc(results[i]->bssid.len);
|
||||
if (!results[i]->bssid.data) {
|
||||
ESP_LOGE(TAG, "Failed to allocate memory for scan result entry BSSID");
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
memcpy(results[i]->bssid.data, scan_result.bssid, results[i]->bssid.len);
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
||||
static int lookup_cmd_handler(int cmd_id)
|
||||
{
|
||||
for (size_t i = 0; i < sizeof(cmd_table)/sizeof(wifi_prov_scan_cmd_t); i++) {
|
||||
if (cmd_table[i].cmd_num == cmd_id) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void wifi_prov_scan_cmd_cleanup(WiFiScanPayload *resp, void *priv_data)
|
||||
{
|
||||
switch (resp->msg) {
|
||||
case WI_FI_SCAN_MSG_TYPE__TypeRespScanStart:
|
||||
{
|
||||
free(resp->resp_scan_start);
|
||||
}
|
||||
break;
|
||||
case WI_FI_SCAN_MSG_TYPE__TypeRespScanStatus:
|
||||
{
|
||||
free(resp->resp_scan_status);
|
||||
}
|
||||
break;
|
||||
case WI_FI_SCAN_MSG_TYPE__TypeRespScanResult:
|
||||
{
|
||||
if (!resp->resp_scan_result) return;
|
||||
if (resp->resp_scan_result->entries) {
|
||||
for (uint16_t i = 0; i < resp->resp_scan_result->n_entries; i++) {
|
||||
if (!resp->resp_scan_result->entries[i]) continue;
|
||||
free(resp->resp_scan_result->entries[i]->ssid.data);
|
||||
free(resp->resp_scan_result->entries[i]->bssid.data);
|
||||
free(resp->resp_scan_result->entries[i]);
|
||||
}
|
||||
free(resp->resp_scan_result->entries);
|
||||
}
|
||||
free(resp->resp_scan_result);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ESP_LOGE(TAG, "Unsupported response type in cleanup_handler");
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static esp_err_t wifi_prov_scan_cmd_dispatcher(WiFiScanPayload *req,
|
||||
WiFiScanPayload *resp, void *priv_data)
|
||||
{
|
||||
esp_err_t ret;
|
||||
|
||||
ESP_LOGD(TAG, "In wifi_prov_scan_cmd_dispatcher Cmd=%d", req->msg);
|
||||
|
||||
int cmd_index = lookup_cmd_handler(req->msg);
|
||||
if (cmd_index < 0) {
|
||||
ESP_LOGE(TAG, "Invalid command handler lookup");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
ret = cmd_table[cmd_index].command_handler(req, resp, priv_data);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Error executing command handler");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t wifi_prov_scan_handler(uint32_t session_id, const uint8_t *inbuf, ssize_t inlen,
|
||||
uint8_t **outbuf, ssize_t *outlen, void *priv_data)
|
||||
{
|
||||
WiFiScanPayload *req;
|
||||
WiFiScanPayload resp;
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
req = wi_fi_scan_payload__unpack(NULL, inlen, inbuf);
|
||||
if (!req) {
|
||||
ESP_LOGE(TAG, "Unable to unpack scan message");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
wi_fi_scan_payload__init(&resp);
|
||||
ret = wifi_prov_scan_cmd_dispatcher(req, &resp, priv_data);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Command dispatcher error %d", ret);
|
||||
ret = ESP_FAIL;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
resp.msg = req->msg + 1; /* Response is request + 1 */
|
||||
*outlen = wi_fi_scan_payload__get_packed_size(&resp);
|
||||
if (*outlen <= 0) {
|
||||
ESP_LOGE(TAG, "Invalid encoding for response");
|
||||
ret = ESP_FAIL;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
*outbuf = (uint8_t *) malloc(*outlen);
|
||||
if (!*outbuf) {
|
||||
ESP_LOGE(TAG, "System out of memory");
|
||||
ret = ESP_ERR_NO_MEM;
|
||||
goto exit;
|
||||
}
|
||||
wi_fi_scan_payload__pack(&resp, *outbuf);
|
||||
ESP_LOGD(TAG, "Response packet size : %d", *outlen);
|
||||
exit:
|
||||
|
||||
wi_fi_scan_payload__free_unpacked(req, NULL);
|
||||
wifi_prov_scan_cmd_cleanup(&resp, priv_data);
|
||||
return ret;
|
||||
}
|
@@ -92,8 +92,6 @@ WIFI_DOCS = [
|
||||
'api-reference/network/esp_smartconfig.rst',
|
||||
'api-reference/network/esp_wifi.rst',
|
||||
'api-reference/network/esp_dpp.rst',
|
||||
'api-reference/provisioning/provisioning.rst',
|
||||
'api-reference/provisioning/wifi_provisioning.rst',
|
||||
'migration-guides/release-5.x/5.2/wifi.rst',
|
||||
'migration-guides/release-5.x/5.4/wifi.rst',
|
||||
'migration-guides/release-5.x/5.5/wifi.rst',
|
||||
@@ -447,7 +445,6 @@ linkcheck_anchors = False
|
||||
linkcheck_exclude_documents = [
|
||||
'index', # several false positives due to the way we link to different sections
|
||||
'api-reference/protocols/esp_local_ctrl', # Fails due to `https://<mdns-hostname>.local`
|
||||
'api-reference/provisioning/wifi_provisioning', # Fails due to `https://<mdns-hostname>.local`
|
||||
]
|
||||
|
||||
|
||||
|
@@ -59,7 +59,6 @@ api-reference/index.rst
|
||||
api-reference/provisioning/index.rst
|
||||
api-reference/provisioning/provisioning.rst
|
||||
api-reference/provisioning/protocomm.rst
|
||||
api-reference/provisioning/wifi_provisioning.rst
|
||||
api-reference/template.rst
|
||||
api-reference/kconfig-reference.rst
|
||||
api-reference/protocols/index.rst
|
||||
|
@@ -63,7 +63,6 @@ api-reference/network/esp_openthread.rst
|
||||
api-reference/provisioning/index.rst
|
||||
api-reference/provisioning/provisioning.rst
|
||||
api-reference/provisioning/protocomm.rst
|
||||
api-reference/provisioning/wifi_provisioning.rst
|
||||
api-reference/template.rst
|
||||
api-reference/kconfig-reference.rst
|
||||
api-reference/protocols/index.rst
|
||||
|
@@ -328,12 +328,6 @@ INPUT = \
|
||||
$(PROJECT_PATH)/components/vfs/include/esp_vfs_ops.h \
|
||||
$(PROJECT_PATH)/components/vfs/include/esp_vfs.h \
|
||||
$(PROJECT_PATH)/components/wear_levelling/include/wear_levelling.h \
|
||||
$(PROJECT_PATH)/components/wifi_provisioning/include/wifi_provisioning/manager.h \
|
||||
$(PROJECT_PATH)/components/wifi_provisioning/include/wifi_provisioning/scheme_ble.h \
|
||||
$(PROJECT_PATH)/components/wifi_provisioning/include/wifi_provisioning/scheme_console.h \
|
||||
$(PROJECT_PATH)/components/wifi_provisioning/include/wifi_provisioning/scheme_softap.h \
|
||||
$(PROJECT_PATH)/components/wifi_provisioning/include/wifi_provisioning/wifi_config.h \
|
||||
$(PROJECT_PATH)/components/wifi_provisioning/include/wifi_provisioning/wifi_scan.h \
|
||||
$(PROJECT_PATH)/components/wpa_supplicant/esp_supplicant/include/esp_dpp.h \
|
||||
$(PROJECT_PATH)/components/wpa_supplicant/esp_supplicant/include/esp_supplicant_utils.h \
|
||||
$(PROJECT_PATH)/components/esp_driver_uart/include/driver/uart_wakeup.h \
|
||||
|
@@ -3,17 +3,18 @@ Provisioning API
|
||||
|
||||
:link_to_translation:`zh_CN:[中文]`
|
||||
|
||||
This document describes methods to connect a device to `Wi-Fi <../network/esp_wifi.rst>`_ or `Thread <../network/esp_openthread.rst>`_ network.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
protocomm
|
||||
:SOC_WIFI_SUPPORTED: provisioning
|
||||
:SOC_WIFI_SUPPORTED: wifi_provisioning
|
||||
provisioning
|
||||
|
||||
Code examples for above API are provided in the `network_provisioning <https://github.com/espressif/idf-extra-components/tree/master/network_provisioning/examples>`_ component.
|
||||
|
||||
.. only:: SOC_WIFI_SUPPORTED
|
||||
|
||||
Code examples for above API are provided in the :example:`provisioning` directory of ESP-IDF examples.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
|
@@ -54,7 +54,7 @@ The protocomm component provides a project configuration menu to enable/disable
|
||||
SoftAP + HTTP Transport Example with Security 2
|
||||
-----------------------------------------------
|
||||
|
||||
For sample usage, see :component_file:`wifi_provisioning/src/scheme_softap.c`.
|
||||
For sample usage, see `network_provisioning/src/scheme_softap.c <https://github.com/espressif/idf-extra-components/blob/master/network_provisioning/src/scheme_softap.c>`_.
|
||||
|
||||
.. highlight:: c
|
||||
|
||||
@@ -161,7 +161,7 @@ The protocomm component provides a project configuration menu to enable/disable
|
||||
SoftAP + HTTP Transport Example with Security 1
|
||||
-----------------------------------------------
|
||||
|
||||
For sample usage, see :component_file:`wifi_provisioning/src/scheme_softap.c`.
|
||||
For sample usage, see `network_provisioning/src/scheme_softap.c <https://github.com/espressif/idf-extra-components/blob/master/network_provisioning/src/scheme_softap.c>`_.
|
||||
|
||||
.. highlight:: c
|
||||
|
||||
@@ -245,7 +245,7 @@ The protocomm component provides a project configuration menu to enable/disable
|
||||
Bluetooth LE Transport Example with Security 0
|
||||
----------------------------------------------
|
||||
|
||||
For sample usage, see :component_file:`wifi_provisioning/src/scheme_ble.c`.
|
||||
For sample usage, see `network_provisioning/src/scheme_ble.c <https://github.com/espressif/idf-extra-components/blob/master/network_provisioning/src/scheme_ble.c>`_.
|
||||
|
||||
.. highlight:: c
|
||||
|
||||
|
@@ -22,7 +22,7 @@ It is understood that each use case may require different security scheme to sec
|
||||
|
||||
4. **Compact Data Representation**
|
||||
|
||||
The protocol uses `Google Protobufs <https://developers.google.com/protocol-buffers/>`_ as a data representation for session setup and Wi-Fi provisioning. They provide a compact data representation and ability to parse the data in multiple programming languages in native format. Please note that this data representation is not forced on application-specific data and the developers may choose the representation of their choice.
|
||||
The protocol uses `Google Protobufs <https://developers.google.com/protocol-buffers/>`_ as a data representation for session setup and network provisioning. They provide a compact data representation and ability to parse the data in multiple programming languages in native format. Please note that this data representation is not forced on application-specific data and the developers may choose the representation of their choice.
|
||||
|
||||
Typical Provisioning Process
|
||||
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
@@ -57,12 +57,12 @@ Typical Provisioning Process
|
||||
=== 3. Configuration ===
|
||||
CLIENT --> DEVICE [label="App-specific Set Config (optional)"];
|
||||
DEVICE --> CLIENT [label="Set Config Response (optional)"];
|
||||
CLIENT -> DEVICE [label="Wi-Fi SetConfig(SSID, Passphrase...)"];
|
||||
DEVICE -> CLIENT [label="Wi-Fi SetConfig response"];
|
||||
CLIENT -> DEVICE [label="Wi-Fi ApplyConfig cmd"];
|
||||
DEVICE -> CLIENT [label="Wi-Fi ApplyConfig resp"];
|
||||
CLIENT -> DEVICE [label="Wi-Fi GetStatus cmd (repeated)"];
|
||||
DEVICE -> CLIENT [label="Wi-Fi GetStatus resp (repeated)"];
|
||||
CLIENT -> DEVICE [label="Wi-Fi/Thread SetConfig(SSID, Passphrase.../ThreadDataset)"];
|
||||
DEVICE -> CLIENT [label="Wi-Fi/Thread SetConfig response"];
|
||||
CLIENT -> DEVICE [label="Wi-Fi/Thread ApplyConfig cmd"];
|
||||
DEVICE -> CLIENT [label="Wi-Fi/Thread ApplyConfig resp"];
|
||||
CLIENT -> DEVICE [label="Wi-Fi/Thread GetStatus cmd (repeated)"];
|
||||
DEVICE -> CLIENT [label="Wi-Fi/Thread GetStatus resp (repeated)"];
|
||||
=== 4. Close connection ===
|
||||
DEVICE -> CLIENT [label="Close Connection"];
|
||||
}
|
||||
@@ -123,9 +123,9 @@ The below diagram shows the architecture of unified provisioning:
|
||||
|
||||
Unified Provisioning Architecture
|
||||
|
||||
It relies on the base layer called :doc:`protocomm` (protocomm) which provides a framework for security schemes and transport mechanisms. The Wi-Fi Provisioning layer uses protocomm to provide simple callbacks to the application for setting the configuration and getting the Wi-Fi status. The application has control over implementation of these callbacks. In addition, the application can directly use protocomm to register custom handlers.
|
||||
It relies on the base layer called :doc:`protocomm` (protocomm) which provides a framework for security schemes and transport mechanisms. The Network Provisioning layer uses protocomm to provide simple callbacks to the application for setting the configuration and getting the network status. The application has control over implementation of these callbacks. In addition, the application can directly use protocomm to register custom handlers.
|
||||
|
||||
The application creates a protocomm instance which is mapped to a specific transport and specific security scheme. Each transport in the protocomm has a concept of an "end-point" which corresponds to the logical channel for communication for specific type of information. For example, security handshake happens on a different endpoint from the Wi-Fi configuration endpoint. Each end-point is identified using a string and depending on the transport internal representation of the end-point changes. In case of the SoftAP+HTTP transport, the end-point corresponds to URI, whereas in case of Bluetooth LE, the end-point corresponds to the GATT characteristic with specific UUID. Developers can create custom end-points and implement handler for the data that is received or sent over the same end-point.
|
||||
The application creates a protocomm instance which is mapped to a specific transport and specific security scheme. Each transport in the protocomm has a concept of an "end-point" which corresponds to the logical channel for communication for specific type of information. For example, security handshake happens on a different endpoint from the network configuration endpoint. Each end-point is identified using a string and depending on the transport internal representation of the end-point changes. In case of the SoftAP+HTTP transport, the end-point corresponds to URI, whereas in case of Bluetooth LE, the end-point corresponds to the GATT characteristic with specific UUID. Developers can create custom end-points and implement handler for the data that is received or sent over the same end-point.
|
||||
|
||||
.. _provisioning_security_schemes:
|
||||
|
||||
@@ -302,9 +302,9 @@ The Security 2 scheme uses AES-GCM for encryption and decryption of the data. Th
|
||||
Sample Code
|
||||
>>>>>>>>>>>
|
||||
|
||||
Please refer to :doc:`protocomm` and :doc:`wifi_provisioning` for API guides and code snippets on example usage.
|
||||
Please refer to :doc:`protocomm` and `network_provisioning <https://github.com/espressif/idf-extra-components/tree/master/network_provisioning>`_ for API guides and code snippets on example usage.
|
||||
|
||||
Application implementation can be found as an example under :example:`provisioning`.
|
||||
Application implementation can be found as examples under `provisioning examples <https://github.com/espressif/idf-extra-components/tree/master/network_provisioning/examples>`_.
|
||||
|
||||
Provisioning Tools
|
||||
>>>>>>>>>>>>>>>>>>
|
||||
@@ -319,6 +319,6 @@ Provisioning applications are available for various platforms, along with source
|
||||
* `Bluetooth LE Provisioning app on App Store <https://apps.apple.com/in/app/esp-ble-provisioning/id1473590141>`_.
|
||||
* `SoftAP Provisioning app on App Store <https://apps.apple.com/in/app/esp-softap-provisioning/id1474040630>`_.
|
||||
* Source code on GitHub: `esp-idf-provisioning-ios <https://github.com/espressif/esp-idf-provisioning-ios>`_.
|
||||
* Linux/macOS/Windows: :idf:`tools/esp_prov`, a Python-based command line tool for provisioning.
|
||||
* Linux/macOS/Windows: `esp_prov <https://github.com/espressif/idf-extra-components/tree/master/network_provisioning/tool/esp_prov>`_, a Python-based command line tool for provisioning.
|
||||
|
||||
The phone applications offer simple UI and are thus more user centric, while the command-line application is useful as a debugging tool for developers.
|
||||
|
@@ -1,338 +0,0 @@
|
||||
Wi-Fi Provisioning
|
||||
==================
|
||||
|
||||
:link_to_translation:`zh_CN:[中文]`
|
||||
|
||||
Overview
|
||||
--------
|
||||
|
||||
This component provides APIs that control the Wi-Fi provisioning service for receiving and configuring Wi-Fi credentials over SoftAP or Bluetooth LE transport via secure :doc:`protocomm` sessions. The set of ``wifi_prov_mgr_`` APIs help quickly implement a provisioning service that has necessary features with minimal amount of code and sufficient flexibility.
|
||||
|
||||
.. _wifi-prov-mgr-init:
|
||||
|
||||
Initialization
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
:cpp:func:`wifi_prov_mgr_init()` is called to configure and initialize the provisioning manager, and thus must be called prior to invoking any other ``wifi_prov_mgr_`` APIs. Note that the manager relies on other components of ESP-IDF, namely NVS, TCP/IP, Event Loop and Wi-Fi, and optionally mDNS, hence these components must be initialized beforehand. The manager can be de-initialized at any moment by making a call to :cpp:func:`wifi_prov_mgr_deinit()`.
|
||||
|
||||
.. code-block:: c
|
||||
|
||||
wifi_prov_mgr_config_t config = {
|
||||
.scheme = wifi_prov_scheme_ble,
|
||||
.scheme_event_handler = WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BTDM
|
||||
};
|
||||
|
||||
ESP_ERROR_CHECK( wifi_prov_mgr_init(config) );
|
||||
|
||||
|
||||
The configuration structure :cpp:type:`wifi_prov_mgr_config_t` has a few fields to specify the desired behavior of the manager:
|
||||
|
||||
* :cpp:member:`wifi_prov_mgr_config_t::scheme` - This is used to specify the provisioning scheme. Each scheme corresponds to one of the modes of transport supported by protocomm. Hence, support the following options:
|
||||
|
||||
* ``wifi_prov_scheme_ble`` - Bluetooth LE transport and GATT Server for handling the provisioning commands.
|
||||
|
||||
* ``wifi_prov_scheme_softap`` - Wi-Fi SoftAP transport and HTTP Server for handling the provisioning commands.
|
||||
|
||||
* ``wifi_prov_scheme_console`` - Serial transport and console for handling the provisioning commands.
|
||||
|
||||
* :cpp:member:`wifi_prov_mgr_config_t::scheme_event_handler`: An event handler defined along with the scheme. Choosing the appropriate scheme-specific event handler allows the manager to take care of certain matters automatically. Presently, this option is not used for either the SoftAP or Console-based provisioning, but is very convenient for Bluetooth LE. To understand how, we must recall that Bluetooth requires a substantial amount of memory to function, and once the provisioning is finished, the main application may want to reclaim back this memory (or part of it) if it needs to use either Bluetooth LE or classic Bluetooth. Also, upon every future reboot of a provisioned device, this reclamation of memory needs to be performed again. To reduce this complication in using ``wifi_prov_scheme_ble``, the scheme-specific handlers have been defined, and depending upon the chosen handler, the Bluetooth LE/classic Bluetooth/BTDM memory is freed automatically when the provisioning manager is de-initialized. The available options are:
|
||||
|
||||
* ``WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BTDM`` - Free both classic Bluetooth and Bluetooth LE/BTDM memory. Used when the main application does not require Bluetooth at all.
|
||||
|
||||
* ``WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BLE`` - Free only Bluetooth LE memory. Used when main application requires classic Bluetooth.
|
||||
|
||||
* ``WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BT`` - Free only classic Bluetooth. Used when main application requires Bluetooth LE. In this case freeing happens right when the manager is initialized.
|
||||
|
||||
* ``WIFI_PROV_EVENT_HANDLER_NONE`` - Do not use any scheme specific handler. Used when the provisioning scheme is not Bluetooth LE, i.e., using SoftAP or Console, or when main application wants to handle the memory reclaiming on its own, or needs both Bluetooth LE and classic Bluetooth to function.
|
||||
|
||||
* :cpp:member:`wifi_prov_mgr_config_t::app_event_handler` (Deprecated) - It is now recommended to catch ``WIFI_PROV_EVENT`` that is emitted to the default event loop handler. See definition of ``wifi_prov_cb_event_t`` for the list of events that are generated by the provisioning service. Here is an excerpt showing some of the provisioning events:
|
||||
|
||||
.. code-block:: c
|
||||
|
||||
static void event_handler(void* arg, esp_event_base_t event_base,
|
||||
int 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 */
|
||||
esp_err_t err = wifi_prov_mgr_deinit();
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to de-initialize provisioning manager: %s", esp_err_to_name(err));
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
The manager can be de-initialized at any moment by making a call to :cpp:func:`wifi_prov_mgr_deinit()`.
|
||||
|
||||
.. _wifi-prov-check-state:
|
||||
|
||||
Check the Provisioning State
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Whether the device is provisioned or not can be checked at runtime by calling :cpp:func:`wifi_prov_mgr_is_provisioned()`. This internally checks if the Wi-Fi credentials are stored in NVS.
|
||||
|
||||
Note that presently the manager does not have its own NVS namespace for storage of Wi-Fi credentials, instead it relies on the ``esp_wifi_`` APIs to set and get the credentials stored in NVS from the default location.
|
||||
|
||||
If the provisioning state needs to be reset, any of the following approaches may be taken:
|
||||
|
||||
* The associated part of NVS partition has to be erased manually
|
||||
* The main application must implement some logic to call ``esp_wifi_`` APIs for erasing the credentials at runtime
|
||||
* The main application must implement some logic to force start the provisioning irrespective of the provisioning state
|
||||
|
||||
.. code-block:: c
|
||||
|
||||
bool provisioned = false;
|
||||
ESP_ERROR_CHECK( wifi_prov_mgr_is_provisioned(&provisioned) );
|
||||
|
||||
|
||||
Start the Provisioning Service
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
At the time of starting provisioning we need to specify a service name and the corresponding key, that is to say:
|
||||
|
||||
* A Wi-Fi SoftAP SSID and a passphrase, respectively, when the scheme is ``wifi_prov_scheme_softap``.
|
||||
* Bluetooth LE device name with the service key ignored when the scheme is ``wifi_prov_scheme_ble``.
|
||||
|
||||
Also, since internally the manager uses ``protocomm``, we have the option of choosing one of the security features provided by it:
|
||||
|
||||
* Security 1 is secure communication which consists of a prior handshake involving X25519 key exchange along with authentication using a proof of possession ``pop``, followed by AES-CTR for encryption or decryption of subsequent messages.
|
||||
* Security 0 is simply plain text communication. In this case the ``pop`` is simply ignored.
|
||||
|
||||
See :doc:`provisioning` for details about the security features.
|
||||
|
||||
.. highlight:: c
|
||||
|
||||
::
|
||||
|
||||
const char *service_name = "my_device";
|
||||
const char *service_key = "password";
|
||||
|
||||
wifi_prov_security_t security = WIFI_PROV_SECURITY_1;
|
||||
const char *pop = "abcd1234";
|
||||
|
||||
ESP_ERROR_CHECK( wifi_prov_mgr_start_provisioning(security, pop, service_name, service_key) );
|
||||
|
||||
|
||||
The provisioning service automatically finishes only if it receives valid Wi-Fi AP credentials followed by successful connection of device to the AP with IP obtained. Regardless of that, the provisioning service can be stopped at any moment by making a call to :cpp:func:`wifi_prov_mgr_stop_provisioning()`.
|
||||
|
||||
.. note::
|
||||
|
||||
If the device fails to connect with the provided credentials, it does not accept new credentials anymore, but the provisioning service keeps on running, only to convey failure to the client, until the device is restarted. Upon restart, the provisioning state turns out to be true this time, as credentials are found in NVS, but the device does fail again to connect with those same credentials, unless an AP with the matching credentials somehow does become available. This situation can be fixed by resetting the credentials in NVS or force starting the provisioning service. This has been explained above in :ref:`wifi-prov-check-state`.
|
||||
|
||||
|
||||
Waiting for Completion
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Typically, the main application waits for the provisioning to finish, then de-initializes the manager to free up resources, and finally starts executing its own logic.
|
||||
|
||||
There are two ways for making this possible. The simpler way is to use a blocking call to :cpp:func:`wifi_prov_mgr_wait()`.
|
||||
|
||||
.. code-block:: c
|
||||
|
||||
// Start provisioning service
|
||||
ESP_ERROR_CHECK( wifi_prov_mgr_start_provisioning(security, pop, service_name, service_key) );
|
||||
|
||||
// Wait for service to complete
|
||||
wifi_prov_mgr_wait();
|
||||
|
||||
// Finally de-initialize the manager
|
||||
wifi_prov_mgr_deinit();
|
||||
|
||||
|
||||
The other way is to use the default event loop handler to catch ``WIFI_PROV_EVENT`` and call :cpp:func:`wifi_prov_mgr_deinit()` when event ID is ``WIFI_PROV_END``:
|
||||
|
||||
.. code-block:: c
|
||||
|
||||
static void event_handler(void* arg, esp_event_base_t event_base,
|
||||
int event_id, void* event_data)
|
||||
{
|
||||
if (event_base == WIFI_PROV_EVENT && event_id == WIFI_PROV_END) {
|
||||
/* De-initialize the manager once the provisioning is finished */
|
||||
wifi_prov_mgr_deinit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
User Side Implementation
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
When the service is started, the device to be provisioned is identified by the advertised service name, which, depending upon the selected transport, is either the Bluetooth LE device name or the SoftAP SSID.
|
||||
|
||||
When using SoftAP transport, for allowing service discovery, mDNS must be initialized before starting provisioning. In this case, the host name set by the main application is used, and the service type is internally set to ``_esp_wifi_prov``.
|
||||
|
||||
When using Bluetooth LE transport, a custom 128-bit UUID should be set using :cpp:func:`wifi_prov_scheme_ble_set_service_uuid()`. This UUID is to be included in the Bluetooth LE advertisement and corresponds to the primary GATT service that provides provisioning endpoints as GATT characteristics. Each GATT characteristic is formed using the primary service UUID as the base, with different auto-assigned 12th and 13th bytes, presumably counting from the 0th byte. Since an endpoint characteristic UUID is auto-assigned, it should not be used to identify the endpoint. Instead, client-side applications should identify the endpoints by reading the User Characteristic Description (``0x2901``) descriptor for each characteristic, which contains the endpoint name of the characteristic. For example, if the service UUID is set to ``55cc035e-fb27-4f80-be02-3c60828b7451``, each endpoint characteristic is assigned a UUID like ``55cc____-fb27-4f80-be02-3c60828b7451``, with unique values at the 12th and 13th bytes.
|
||||
|
||||
Once connected to the device, the provisioning-related protocomm endpoints can be identified as follows:
|
||||
|
||||
.. |br| raw:: html
|
||||
|
||||
<br>
|
||||
|
||||
.. list-table:: Endpoints Provided by the Provisioning Service
|
||||
:widths: 35 35 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Endpoint Name |br| i.e., Bluetooth LE + GATT Server
|
||||
- URI, i.e., SoftAP |br| + HTTP Server + mDNS
|
||||
- Description
|
||||
* - prov-session
|
||||
- http://<mdns-hostname>.local/prov-session
|
||||
- Security endpoint used for session establishment
|
||||
* - prov-scan
|
||||
- http://wifi-prov.local/prov-scan
|
||||
- the endpoint used for starting Wi-Fi scan and receiving scan results
|
||||
* - prov-ctrl
|
||||
- http://wifi-prov.local/prov-ctrl
|
||||
- the endpoint used for controlling Wi-Fi provisioning state
|
||||
* - prov-config
|
||||
- http://<mdns-hostname>.local/prov-config
|
||||
- the endpoint used for configuring Wi-Fi credentials on device
|
||||
* - proto-ver
|
||||
- http://<mdns-hostname>.local/proto-ver
|
||||
- the endpoint for retrieving version info
|
||||
|
||||
Immediately after connecting, the client application may fetch the version/capabilities information from the ``proto-ver`` endpoint. All communications to this endpoint are unencrypted, hence necessary information, which may be relevant for deciding compatibility, can be retrieved before establishing a secure session. The response is in JSON format and looks like : ``prov: { ver: v1.1, sec_ver: 1, sec_patch_ver: 0, cap: [no_pop] }, my_app: { ver: 1.345, cap: [cloud, local_ctrl] },....``.
|
||||
|
||||
Here label ``prov`` provides:
|
||||
|
||||
- provisioning service version ``ver``
|
||||
- security version ``sec_ver``
|
||||
- security patch version ``sec_patch_ver`` (default is 0)
|
||||
- capabilities ``cap``
|
||||
|
||||
For now, only the ``no_pop`` capability is supported, which indicates that the service does not require proof of possession for authentication. Any application-related version or capabilities are given by other labels, e.g., ``my_app`` in this example. These additional fields are set using :cpp:func:`wifi_prov_mgr_set_app_info()`.
|
||||
|
||||
.. important::
|
||||
Client must take into account both the ``sec_ver`` and ``sec_patch_ver`` fields, as these are used to determine the security scheme to be used for the session establishment.
|
||||
|
||||
User side applications need to implement the signature handshaking required for establishing and authenticating secure protocomm sessions as per the security scheme configured for use, which is not needed when the manager is configured to use protocomm security 0.
|
||||
|
||||
See :doc:`provisioning` for more details about the secure handshake and encryption used. Applications must use the ``.proto`` files found under :component:`protocomm/proto`, which define the Protobuf message structures supported by ``prov-session`` endpoint.
|
||||
|
||||
Once a session is established, Wi-Fi credentials are configured using the following set of ``wifi_config`` commands, serialized as Protobuf messages with the corresponding ``.proto`` files that can be found under :component:`wifi_provisioning/proto`:
|
||||
|
||||
* ``get_status`` - For querying the Wi-Fi connection status. The device responds with a status which is one of connecting, connected or disconnected. If the status is disconnected, a disconnection reason is also to be included in the status response.
|
||||
|
||||
* ``set_config`` - For setting the Wi-Fi connection credentials.
|
||||
|
||||
* ``apply_config`` - For applying the credentials saved during ``set_config`` and starting the Wi-Fi station.
|
||||
|
||||
After session establishment, the client can also request Wi-Fi scan results from the device. The results returned is a list of AP SSIDs, sorted in descending order of signal strength. This allows client applications to display APs nearby to the device at the time of provisioning, and users can select one of the SSIDs and provide the password which is then sent using the ``wifi_config`` commands described above. The ``wifi_scan`` endpoint supports the following protobuf commands :
|
||||
|
||||
* ``scan_start`` - For starting Wi-Fi scan with various options:
|
||||
|
||||
* ``blocking`` (input) - If true, the command returns only when the scanning is finished.
|
||||
|
||||
* ``passive`` (input) - If true, the scan is started in passive mode, which may be slower, instead of active mode.
|
||||
|
||||
* ``group_channels`` (input) - This specifies whether to scan all channels in one go when zero, or perform scanning of channels in groups, with 120 ms delay between scanning of consecutive groups, and the value of this parameter sets the number of channels in each group. This is useful when transport mode is SoftAP, where scanning all channels in one go may not give the Wi-Fi driver enough time to send out beacons, and hence may cause disconnection with any connected stations. When scanning in groups, the manager waits for at least 120 ms after completing the scan on a group of channels, and thus allows the driver to send out the beacons. For example, given that the total number of Wi-Fi channels is 14, then setting ``group_channels`` to 3 creates 5 groups, with each group having 3 channels, except the last one which has 14 % 3 = 2 channels. So, when the scan is started, the first 3 channels will be scanned, followed by a 120 ms delay, and then the next 3 channels, and so on, until all the 14 channels have been scanned.One may need to adjust this parameter as having only a few channels in a group may increase the overall scan time, while having too many may again cause disconnection. Usually, a value of 4 should work for most cases. Note that for any other mode of transport, e.g., Bluetooth LE, this can be safely set to 0, and hence achieve the shortest overall scanning time.
|
||||
|
||||
* ``period_ms`` (input) - The scan parameter specifying how long to wait on each channel.
|
||||
|
||||
* ``scan_status`` - It gives the status of scanning process:
|
||||
|
||||
* ``scan_finished`` (output) - When the scan has finished, this returns true.
|
||||
|
||||
* ``result_count`` (output) - This gives the total number of results obtained till now. If the scan is yet happening, this number keeps on updating.
|
||||
|
||||
* ``scan_result`` - For fetching the scan results. This can be called even if the scan is still on going.
|
||||
|
||||
* ``start_index`` (input) - Where the index starts from to fetch the entries from the results list.
|
||||
|
||||
* ``count`` (input) - The number of entries to fetch from the starting index.
|
||||
|
||||
* ``entries`` (output) - The list of entries returned. Each entry consists of ``ssid``, ``channel`` and ``rssi`` information.
|
||||
|
||||
The client can also control the provisioning state of the device using ``wifi_ctrl`` endpoint. The ``wifi_ctrl`` endpoint supports the following protobuf commands:
|
||||
|
||||
* ``ctrl_reset`` - Resets internal state machine of the device and clears provisioned credentials only in case of provisioning failures.
|
||||
|
||||
* ``ctrl_reprov`` - Resets internal state machine of the device and clears provisioned credentials only in case the device is to be provisioned again for new credentials after a previous successful provisioning.
|
||||
|
||||
Additional Endpoints
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
In case users want to have some additional protocomm endpoints customized to their requirements, this is done in two steps. First is creation of an endpoint with a specific name, and the second step is the registration of a handler for this endpoint. See :doc:`protocomm` for the function signature of an endpoint handler. A custom endpoint must be created after initialization and before starting the provisioning service. Whereas, the protocomm handler is registered for this endpoint only after starting the provisioning service. Note that in the custom endpoint handler function, memory for the response of such protocomm endpoints should be allocated using heap as it gets freed by the protocomm layer once it has been sent by the transport layer.
|
||||
|
||||
.. code-block:: c
|
||||
|
||||
wifi_prov_mgr_init(config);
|
||||
wifi_prov_mgr_endpoint_create("custom-endpoint");
|
||||
wifi_prov_mgr_start_provisioning(security, pop, service_name, service_key);
|
||||
wifi_prov_mgr_endpoint_register("custom-endpoint", custom_ep_handler, custom_ep_data);
|
||||
|
||||
|
||||
When the provisioning service stops, the endpoint is unregistered automatically.
|
||||
|
||||
One can also choose to call :cpp:func:`wifi_prov_mgr_endpoint_unregister()` to manually deactivate an endpoint at runtime. This can also be used to deactivate the internal endpoints used by the provisioning service.
|
||||
|
||||
When/How to Stop the Provisioning Service?
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The default behavior is that once the device successfully connects using the Wi-Fi credentials set by the ``apply_config`` command, the provisioning service stops, and Bluetooth LE or SoftAP turns off, automatically after responding to the next ``get_status`` command. If ``get_status`` command is not received by the device, the service stops after a 30 s timeout.
|
||||
|
||||
On the other hand, if device is not able to connect using the provided Wi-Fi credentials, due to incorrect SSID or passphrase, the service keeps running, and ``get_status`` keeps responding with disconnected status and reason for disconnection. Any further attempts to provide another set of Wi-Fi credentials, are to be rejected. These credentials are preserved, unless the provisioning service is force started, or NVS erased.
|
||||
|
||||
If this default behavior is not desired, it can be disabled by calling :cpp:func:`wifi_prov_mgr_disable_auto_stop()`. Now the provisioning service stops only after an explicit call to :cpp:func:`wifi_prov_mgr_stop_provisioning()`, which returns immediately after scheduling a task for stopping the service. The service stops after a certain delay and ``WIFI_PROV_END`` event gets emitted. This delay is specified by the argument to :cpp:func:`wifi_prov_mgr_disable_auto_stop()`.
|
||||
|
||||
The customized behavior is useful for applications which want the provisioning service to be stopped some time after the Wi-Fi connection is successfully established. For example, if the application requires the device to connect to some cloud service and obtain another set of credentials, and exchange these credentials over a custom protocomm endpoint, then after successfully doing so, stop the provisioning service by calling :cpp:func:`wifi_prov_mgr_stop_provisioning()` inside the protocomm handler itself. The right amount of delay ensures that the transport resources are freed only after the response from the protocomm handler reaches the client side application.
|
||||
|
||||
Application Examples
|
||||
--------------------
|
||||
|
||||
- :example:`provisioning/wifi_prov_mgr` demonstrates how to use the `wifi_provisioning` manager component to configure {IDF_TARGET_NAME} as a Wi-Fi station with specified credentials, using Bluetooth LE as the default transport for provisioning.
|
||||
|
||||
Provisioning Tools
|
||||
--------------------
|
||||
|
||||
Provisioning applications are available for various platforms, along with source code:
|
||||
|
||||
* Android:
|
||||
* `Bluetooth LE Provisioning app on Play Store <https://play.google.com/store/apps/details?id=com.espressif.provble>`_.
|
||||
* `SoftAP Provisioning app on Play Store <https://play.google.com/store/apps/details?id=com.espressif.provsoftap>`_.
|
||||
* Source code on GitHub: `esp-idf-provisioning-android <https://github.com/espressif/esp-idf-provisioning-android>`_.
|
||||
* iOS:
|
||||
* `Bluetooth LE Provisioning app on App Store <https://apps.apple.com/in/app/esp-ble-provisioning/id1473590141>`_.
|
||||
* `SoftAP Provisioning app on App Store <https://apps.apple.com/in/app/esp-softap-provisioning/id1474040630>`_.
|
||||
* Source code on GitHub: `esp-idf-provisioning-ios <https://github.com/espressif/esp-idf-provisioning-ios>`_.
|
||||
* Linux/MacOS/Windows: :idf:`tools/esp_prov`, a Python-based command-line tool for provisioning.
|
||||
|
||||
The phone applications offer simple UI and are thus more user centric, while the command-line application is useful as a debugging tool for developers.
|
||||
|
||||
|
||||
API Reference
|
||||
-------------
|
||||
|
||||
.. include-build-file:: inc/manager.inc
|
||||
.. include-build-file:: inc/scheme_ble.inc
|
||||
.. include-build-file:: inc/scheme_softap.inc
|
||||
.. include-build-file:: inc/scheme_console.inc
|
||||
.. include-build-file:: inc/wifi_config.inc
|
@@ -6,7 +6,34 @@ Provisioning
|
||||
Breaking Changes
|
||||
----------------
|
||||
|
||||
The return type of :cpp:func:`wifi_prov_mgr_deinit` has been changed from ``void`` to :cpp:type:`esp_err_t`. This change allows applications to properly handle potential failures during provisioning manager deinitialization.
|
||||
The ESP-IDF component ``wifi_provisioning`` has been removed from ESP-IDF and is supported as a separate component. It has been renamed to ``network_provisioning`` and Thread network provisioning support has been added to the new component. Additional information for the ``network_provisioning`` component can be found in ESP Component Registry:
|
||||
|
||||
* `network_provisioning component <https://components.espressif.com/component/espressif/network_provisioning>`__
|
||||
|
||||
The ``main`` component folder of the new application shall include the component manager manifest file ``idf_component.yml`` as in the example below:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
dependencies:
|
||||
espressif/network_provisioning:
|
||||
version: "^1.1.0"
|
||||
|
||||
For applications targeting v5.x releases of ESP-IDF that need to use new ``network_provisioning`` component, adding the component manager manifest file ``idf_component.yml`` will be sufficient to pull in the new component. However, users should also exclude the legacy ``wifi_provisioning`` component from the build. This can be achieved using the statement below in the project's ``CMakeLists.txt``:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
set(EXCLUDE_COMPONENTS wifi_provisioning)
|
||||
|
||||
The API names have been updated after migrating to the new component. Most changes involve renaming API names from ``wifi_prov_xx`` to ``network_prov_xx``. The table below summarizes the remaining differences between the old APIs and their new counterparts.
|
||||
|
||||
.. csv-table::
|
||||
:header: "Previous API", "Current API"
|
||||
|
||||
"wifi_prov_mgr_is_provisioned", "network_prov_mgr_is_wifi_provisioned"
|
||||
"wifi_prov_mgr_configure_sta", "network_prov_mgr_configure_wifi_sta"
|
||||
"wifi_prov_mgr_reset_provisioning", "network_prov_mgr_reset_wifi_provisioning"
|
||||
"wifi_prov_mgr_reset_sm_state_on_failure", "network_prov_mgr_reset_wifi_sm_state_on_failure"
|
||||
"wifi_prov_mgr_reset_sm_state_for_reprovision", "network_prov_mgr_reset_wifi_sm_state_for_reprovision"
|
||||
|
||||
Configuration Changes
|
||||
---------------------
|
||||
|
@@ -265,7 +265,7 @@ Product Security
|
||||
|
||||
ESP-IDF provides various security schemes to establish a secure session between ESP and the provisioning entity, they are highlighted at :ref:`provisioning_security_schemes`.
|
||||
|
||||
Please refer to the :doc:`../api-reference/provisioning/wifi_provisioning` documentation for details and the example code for this feature.
|
||||
Please refer to `network_provisioning <https://github.com/espressif/idf-extra-components/tree/master/network_provisioning>`_ for details and the example code for this feature.
|
||||
|
||||
.. note::
|
||||
|
||||
|
@@ -3,17 +3,18 @@
|
||||
|
||||
:link_to_translation:`en:[English]`
|
||||
|
||||
本文介绍了将设备配入 `Wi-Fi <../network/esp_wifi.rst>`_ 或 `Thread <../network/esp_openthread.rst>`_ 网络中的方法。
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
protocomm
|
||||
:SOC_WIFI_SUPPORTED: provisioning
|
||||
:SOC_WIFI_SUPPORTED: wifi_provisioning
|
||||
provisioning
|
||||
|
||||
本部分的 API 示例代码存放在 idf-extra-compoenent 仓库的 `network_provisioning <https://github.com/espressif/idf-extra-components/tree/master/network_provisioning/examples>`_ 目录下。
|
||||
|
||||
.. only:: SOC_WIFI_SUPPORTED
|
||||
|
||||
本部分的 API 示例代码存放在 ESP-IDF 示例项目的 :example:`provisioning` 目录下。
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
|
@@ -54,7 +54,7 @@ Protocomm 为以下各种传输提供框架:
|
||||
使用 Security 2 的 SoftAP + HTTP 传输方案示例
|
||||
--------------------------------------------------
|
||||
|
||||
示例用法请参阅 :component_file:`wifi_provisioning/src/scheme_softap.c`。
|
||||
示例用法请参阅 `network_provisioning/src/scheme_softap.c <https://github.com/espressif/idf-extra-components/blob/master/network_provisioning/src/scheme_softap.c>`_。
|
||||
|
||||
.. highlight:: c
|
||||
|
||||
@@ -161,7 +161,7 @@ Protocomm 为以下各种传输提供框架:
|
||||
使用 Security 1 的 SoftAP + HTTP 传输方案示例
|
||||
-------------------------------------------------
|
||||
|
||||
示例用法请参阅 :component_file:`wifi_provisioning/src/scheme_softap.c`。
|
||||
示例用法请参阅 `network_provisioning/src/scheme_softap.c <https://github.com/espressif/idf-extra-components/blob/master/network_provisioning/src/scheme_softap.c>`_。
|
||||
|
||||
.. highlight:: c
|
||||
|
||||
@@ -245,7 +245,7 @@ Protocomm 为以下各种传输提供框架:
|
||||
使用 Security 0 的低功耗蓝牙传输方案示例
|
||||
-------------------------------------------
|
||||
|
||||
示例用法请参阅 :component_file:`wifi_provisioning/src/scheme_ble.c`。
|
||||
示例用法请参阅 `network_provisioning/src/scheme_ble.c <https://github.com/espressif/idf-extra-components/blob/master/network_provisioning/src/scheme_ble.c>`_。
|
||||
|
||||
.. highlight:: c
|
||||
|
||||
|
@@ -22,7 +22,7 @@ ESP-IDF 支持统一配网,提供可扩展的机制,支持开发者使用不
|
||||
|
||||
4. **数据格式紧凑**
|
||||
|
||||
该协议使用 `Google Protobufs <https://developers.google.com/protocol-buffers/>`_ 作为会话设置和 Wi-Fi 配网的数据格式。该方案提供紧凑的数据格式,并可以使用不同编程语言进行数据解析。请注意,该配网的应用数据格式并不只局限于 Protobufs,开发者可以自行选择自己想用的数据格式。
|
||||
该协议使用 `Google Protobufs <https://developers.google.com/protocol-buffers/>`_ 作为会话设置和网络配网的数据格式。该方案提供紧凑的数据格式,并可以使用不同编程语言进行数据解析。请注意,该配网的应用数据格式并不只局限于 Protobufs,开发者可以自行选择自己想用的数据格式。
|
||||
|
||||
配网过程示例
|
||||
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
@@ -57,12 +57,12 @@ ESP-IDF 支持统一配网,提供可扩展的机制,支持开发者使用不
|
||||
=== 3. 配置 ===
|
||||
CLIENT --> DEVICE [label="特定应用程序的配置设置(可选)"];
|
||||
DEVICE --> CLIENT [label="配置设置响应(可选)"];
|
||||
CLIENT -> DEVICE [label="Wi-Fi 配置设置(SSID、密码等)"];
|
||||
DEVICE -> CLIENT [label="Wi-Fi 配置设置响应"];
|
||||
CLIENT -> DEVICE [label="Wi-Fi 配置应用命令"];
|
||||
DEVICE -> CLIENT [label="Wi-Fi 配置应用响应"];
|
||||
CLIENT -> DEVICE [label="Wi-Fi 获取状态命令(重复)"];
|
||||
DEVICE -> CLIENT [label="Wi-Fi 获取状态响应(重复)"];
|
||||
CLIENT -> DEVICE [label="Wi-Fi/Thread 配置设置(SSID、密码等)"];
|
||||
DEVICE -> CLIENT [label="Wi-Fi/Thread 配置设置响应"];
|
||||
CLIENT -> DEVICE [label="Wi-Fi/Thread 配置应用命令"];
|
||||
DEVICE -> CLIENT [label="Wi-Fi/Thread 配置应用响应"];
|
||||
CLIENT -> DEVICE [label="Wi-Fi/Thread 获取状态命令(重复)"];
|
||||
DEVICE -> CLIENT [label="Wi-Fi/Thread 获取状态响应(重复)"];
|
||||
=== 4. 关闭连接 ===
|
||||
DEVICE -> CLIENT [label="关闭连接"];
|
||||
}
|
||||
@@ -123,7 +123,7 @@ ESP-IDF 支持统一配网,提供可扩展的机制,支持开发者使用不
|
||||
|
||||
统一配网架构
|
||||
|
||||
统一配网依赖名为 :doc:`protocomm` (protocomm) 的基础层,该层提供了安全方案和传输机制的框架。Wi-Fi 配网层使用 protocomm 提供简单的回调函数,供应用程序设置配置和获取 Wi-Fi 状态。应用程序可以控制这些回调的实现方式。此外,应用程序还可以直接使用 protocomm 来注册自定义处理程序。
|
||||
统一配网依赖名为 :doc:`protocomm` (protocomm) 的基础层,该层提供了安全方案和传输机制的框架。网络配网层使用 protocomm 提供简单的回调函数,供应用程序设置配置和获取网络状态。应用程序可以控制这些回调的实现方式。此外,应用程序还可以直接使用 protocomm 来注册自定义处理程序。
|
||||
|
||||
应用程序会创建一个 protocomm 实例,该实例会映射到特定传输方式和安全方案。protocomm 中的每个传输方式都有“端点”概念,对应特定类型信息通信的逻辑通道。例如,进行安全握手的端点与 Wi-Fi 配置端点不同。每个端点都用字符串标识,具体取决于传输内部对端点变化的表示方式。对于 SoftAP + HTTP 传输方式,端点对应 URI;而对于低功耗蓝牙,端点对应具有特定 UUID 的 GATT 特征。开发者可以创建自定义端点,为同一端点接收或发送的数据实现处理程序。
|
||||
|
||||
@@ -302,9 +302,9 @@ Security 2 方案使用 AES-GCM 对数据进行加密和解密。初始化向量
|
||||
示例代码
|
||||
>>>>>>>>>>>
|
||||
|
||||
关于 API 指南和示例用法的代码片段,请参阅 :doc:`protocomm` 和 :doc:`wifi_provisioning`。
|
||||
关于 API 指南和示例用法的代码片段,请参阅 :doc:`protocomm` 和 `network_provisioning <https://github.com/espressif/idf-extra-components/tree/master/network_provisioning>`_。
|
||||
|
||||
关于应用程序的实现示例,请参阅 :example:`provisioning`。
|
||||
关于应用程序的实现示例,请参阅 `provisioning examples <https://github.com/espressif/idf-extra-components/tree/master/network_provisioning/examples>`_。
|
||||
|
||||
配网工具
|
||||
>>>>>>>>>>>>>>>>>>
|
||||
@@ -319,6 +319,6 @@ Security 2 方案使用 AES-GCM 对数据进行加密和解密。初始化向量
|
||||
* `App Store 上的低功耗蓝牙配网应用程序 <https://apps.apple.com/in/app/esp-ble-provisioning/id1473590141>`_。
|
||||
* `App Store 上的 SoftAP 配网应用程序 <https://apps.apple.com/in/app/esp-softap-provisioning/id1474040630>`_。
|
||||
* GitHub 上的源代码:`esp-idf-provisioning-ios <https://github.com/espressif/esp-idf-provisioning-ios>`_。
|
||||
* Linux/macOS/Windows:基于 Python 的命令行工具 :idf:`tools/esp_prov`,可用于设备配网。
|
||||
* Linux/macOS/Windows:基于 Python 的命令行工具 `esp_prov <https://github.com/espressif/idf-extra-components/tree/master/network_provisioning/tool/esp_prov>`_,可用于设备配网。
|
||||
|
||||
手机应用程序界面简洁,便于用户使用,而开发者可以使用命令行应用程序,便于调试。
|
||||
|
@@ -1,338 +0,0 @@
|
||||
Wi-Fi 配网
|
||||
====================
|
||||
|
||||
:link_to_translation:`en:[English]`
|
||||
|
||||
概述
|
||||
----------
|
||||
|
||||
该组件提供控制 Wi-Fi 配网服务的 API,可以通过 SoftAP 或低功耗蓝牙建立 :doc:`protocomm` 安全会话,接收和配置 Wi-Fi 凭证。通过一组 ``wifi_prov_mgr_`` API,可以快速实现配网服务,该服务具备必要功能、代码量少且足够灵活。
|
||||
|
||||
.. _wifi-prov-mgr-init:
|
||||
|
||||
初始化
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
调用 :cpp:func:`wifi_prov_mgr_init()` 可以配置和初始化配网管理器,因此在调用任何其他 ``wifi_prov_mgr_`` API 之前必须先调用此函数。请注意,该管理器依赖于 ESP-IDF 的其他组件,包括 NVS、TCP/IP、Event Loop 和 Wi-Fi,以及可选的 mDNS,因此在调用之前必须先初始化这些组件。调用 :cpp:func:`wifi_prov_mgr_deinit()` 可以随时反初始化管理器。
|
||||
|
||||
.. code-block:: c
|
||||
|
||||
wifi_prov_mgr_config_t config = {
|
||||
.scheme = wifi_prov_scheme_ble,
|
||||
.scheme_event_handler = WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BTDM
|
||||
};
|
||||
|
||||
ESP_ERROR_CHECK( wifi_prov_mgr_init(config) );
|
||||
|
||||
|
||||
以下配置结构体 :cpp:type:`wifi_prov_mgr_config_t` 里包含的部分字段可用于指定特定管理器行为:
|
||||
|
||||
* :cpp:member:`wifi_prov_mgr_config_t::scheme` - 用于指定配网方案。每个方案对应一种 protocomm 支持的传输模式,因此支持三个选项:
|
||||
|
||||
* ``wifi_prov_scheme_ble`` - 使用低功耗蓝牙传输和 GATT 服务器来处理配网命令。
|
||||
|
||||
* ``wifi_prov_scheme_softap`` - 使用 Wi-Fi SoftAP 传输和 HTTP 服务器来处理配网命令。
|
||||
|
||||
* ``wifi_prov_scheme_console`` - 使用串口传输和控制台来处理配网命令。
|
||||
|
||||
* :cpp:member:`wifi_prov_mgr_config_t::scheme_event_handler` - 为方案定义的专属事件处理程序。选择适当方案后,其专属事件处理程序支持管理器自动处理特定事项。目前,该选项不适用于 SoftAP 或基于控制台的配网方案,但对于低功耗蓝牙配网方案来说非常方便。因为蓝牙需要相当多内存才能正常工作,所以配网完成后,主应用程序需要使用低功耗蓝牙或经典蓝牙时,可能需要回收配网所占的全部或部分内存。此外,未来每当配网设备重启时,都需要再次回收内存。为了便于使用 ``wifi_prov_scheme_ble`` 选项,各方案定义了专属处理程序。设备会根据所选处理程序,在反初始化配网管理器时自动释放低功耗蓝牙、经典蓝牙或蓝牙双模的内存。可用选项包括:
|
||||
|
||||
* ``WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BTDM`` - 同时释放经典蓝牙和低功耗蓝牙或蓝牙双模的内存,可以在主应用程序不需要蓝牙时使用该选项。
|
||||
|
||||
* ``WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BLE`` - 只释放低功耗蓝牙的内存,可以在主应用程序需要经典蓝牙时使用该选项。
|
||||
|
||||
* ``WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BT`` - 仅释放经典蓝牙的内存,可以在主应用程序需要低功耗蓝牙时使用该选项,内存会在初始化管理器时立即释放。
|
||||
|
||||
* ``WIFI_PROV_EVENT_HANDLER_NONE`` - 不使用任何特定方案的专属处理程序。以下情况可使用该选项:不使用低功耗蓝牙配网方案,即使用 SoftAP 或控制台方案;主应用程序需要自行回收内存;主应用程序需要同时使用低功耗蓝牙和经典蓝牙。
|
||||
|
||||
* :cpp:member:`wifi_prov_mgr_config_t::app_event_handler` (不推荐)- 目前建议使用默认的事件循环处理程序捕获生成的 ``WIFI_PROV_EVENT``。关于配网服务生成事件的列表,请参阅 ``wifi_prov_cb_event_t`` 的定义。以下是配网事件示例摘录:
|
||||
|
||||
.. code-block:: c
|
||||
|
||||
static void event_handler(void* arg, esp_event_base_t event_base,
|
||||
int 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:
|
||||
/*配网完成后,反初始化管理器。*/
|
||||
esp_err_t err = wifi_prov_mgr_deinit();
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to de-initialize provisioning manager: %s", esp_err_to_name(err));
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
调用 :cpp:func:`wifi_prov_mgr_deinit()` 可以随时反初始化管理器。
|
||||
|
||||
.. _wifi-prov-check-state:
|
||||
|
||||
检查配网状态
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
在运行时,可以调用 :cpp:func:`wifi_prov_mgr_is_provisioned()` 检查设备是否配网完成,该函数会在内部检查 Wi-Fi 凭据是否存储在 NVS 中。
|
||||
|
||||
请注意,目前管理器并没有自己的 NVS 命名空间来存储 Wi-Fi 凭据,而是依赖 ``esp_wifi_`` API 来设置和获取存储在默认位置的 NVS 中的凭据。
|
||||
|
||||
可以采用以下任一方法重置配网状态:
|
||||
|
||||
* 手动擦除 NVS 分区的配网相关部分。
|
||||
* 主应用程序必须实现某种逻辑,以在运行时调用 ``esp_wifi_`` API 来擦除凭据。
|
||||
* 主应用程序必须实现某种逻辑,以在不考虑配网状态的情况下,强制启动配网。
|
||||
|
||||
.. code-block:: c
|
||||
|
||||
bool provisioned = false;
|
||||
ESP_ERROR_CHECK( wifi_prov_mgr_is_provisioned(&provisioned) );
|
||||
|
||||
|
||||
启动配网服务
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
在启动配网服务时,需要指定服务名称和相应密钥,即:
|
||||
|
||||
* 使用 ``wifi_prov_scheme_softap`` 方案时,服务名称对应 Wi-Fi SoftAP 的 SSID,密钥对应密码。
|
||||
* 使用 ``wifi_prov_scheme_ble`` 方案时,服务名称对应低功耗蓝牙设备名称,无需指定密钥。
|
||||
|
||||
此外,由于管理器内部使用了 ``protocomm``,可以选择其提供的任一安全功能:
|
||||
|
||||
* Security 1 是安全通信,该安全通信需要先握手,其中涉及 X25519 密钥交换和使用所有权证明 ``pop`` 完成身份验证,随后使用 AES-CTR 加密或解密后续消息。
|
||||
* Security 0 是纯文本通信,会直接忽略 ``pop``。
|
||||
|
||||
关于安全功能的更多详情,请参阅 :doc:`provisioning`。
|
||||
|
||||
.. highlight:: c
|
||||
|
||||
::
|
||||
|
||||
const char *service_name = "my_device";
|
||||
const char *service_key = "password";
|
||||
|
||||
wifi_prov_security_t security = WIFI_PROV_SECURITY_1;
|
||||
const char *pop = "abcd1234";
|
||||
|
||||
ESP_ERROR_CHECK( wifi_prov_mgr_start_provisioning(security, pop, service_name, service_key) );
|
||||
|
||||
|
||||
如果收到有效的 Wi-Fi AP 凭据,且设备成功连接到该 AP 并获取了 IP,配网服务会自动结束。此外,调用 :cpp:func:`wifi_prov_mgr_stop_provisioning()` 可以随时停止配网服务。
|
||||
|
||||
.. note::
|
||||
|
||||
如果设备使用提供的凭据无法连接,则它不再接受新的凭据,但在设备重新启动前,配网服务仍然会继续运行,并向客户端传递连接失败的信息。设备重新启动后配网状态将变为已配网,因为在 NVS 中找到了凭据,但除非出现与凭据匹配的可用 AP,否则设备仍然无法使用原凭据进行连接。可以通过重置 NVS 中的凭据或强制启动配网服务来解决这个问题,详情请参阅上文 :ref:`wifi-prov-check-state`。
|
||||
|
||||
|
||||
等待配网完成
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
主应用程序通常会等待配网服务完成,然后反初始化管理器以释放资源,最后开始执行自己的逻辑。
|
||||
|
||||
有两种方法可以实现这一点,其中调用阻塞 :cpp:func:`wifi_prov_mgr_wait()` 更为简单。
|
||||
|
||||
.. code-block:: c
|
||||
|
||||
// 启动配网服务
|
||||
ESP_ERROR_CHECK( wifi_prov_mgr_start_provisioning(security, pop, service_name, service_key) );
|
||||
|
||||
// 等待服务完成
|
||||
wifi_prov_mgr_wait();
|
||||
|
||||
// 最后反初始化管理器
|
||||
wifi_prov_mgr_deinit();
|
||||
|
||||
|
||||
另一种方法是使用默认的事件循环处理程序捕获 ``WIFI_PROV_EVENT`` 并在事件 ID 为 ``WIFI_PROV_END`` 时调用 :cpp:func:`wifi_prov_mgr_deinit()`:
|
||||
|
||||
.. code-block:: c
|
||||
|
||||
static void event_handler(void* arg, esp_event_base_t event_base,
|
||||
int event_id, void* event_data)
|
||||
{
|
||||
if (event_base == WIFI_PROV_EVENT && event_id == WIFI_PROV_END) {
|
||||
/* 配网完成后反初始化管理器 */
|
||||
ESP_ERROR_CHECK( wifi_prov_mgr_deinit() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
用户端实现
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
启动服务时,通过广播服务名称识别即将配网的设备。根据选择的传输方式,该服务名称为低功耗蓝牙设备的名称或 SoftAP SSID。
|
||||
|
||||
使用 SoftAP 传输方式时,为便于服务发现,必须在启动配网之前初始化 mDNS。在这种情况下,应使用主应用程序设置的主机名,并且在内部将服务类型设置为 ``_esp_wifi_prov``。
|
||||
|
||||
使用低功耗蓝牙传输方式时,应使用 :cpp:func:`wifi_prov_scheme_ble_set_service_uuid()` 设置一个自定义的 128 位 UUID。该 UUID 将包含在低功耗蓝牙广播中,并对应于提供配网端点作为 GATT 特征的主要服务。每个 GATT 特征都基于主要服务 UUID 形成,其中从第 0 个字节开始计数,第 12 和第 13 个字节为自动分配的不同字节。由于端点特征 UUID 自动分配,因此不应将其用于识别端点。客户端应用程序应通过读取每个特征的用户特征描述符 (``0x2901``) 来识别端点,该描述符包含特征的端点名称。例如,如果将服务 UUID 设置为 ``55cc035e-fb27-4f80-be02-3c60828b7451``,每个端点特征将分配到一个类似于 ``55cc____-fb27-4f80-be02-3c60828b7451`` 的 UUID,其中第 12 和第 13 个字节具有唯一值。
|
||||
|
||||
连接设备后,可以通过以下方式识别与配网相关的 protocomm 端点:
|
||||
|
||||
.. |br| raw:: html
|
||||
|
||||
<br>
|
||||
|
||||
.. list-table:: 配网服务提供的端点
|
||||
:widths: 35 35 30
|
||||
:header-rows: 1
|
||||
|
||||
* - 端点名称 |br| 即低功耗蓝牙 + GATT 服务器
|
||||
- URI 即 SoftAP |br| + HTTP 服务器 + mDNS
|
||||
- 描述
|
||||
* - prov-session
|
||||
- http://<mdns-hostname>.local/prov-session
|
||||
- 用于建立会话的安全端点
|
||||
* - prov-scan
|
||||
- http://wifi-prov.local/prov-scan
|
||||
- 用于启动 Wi-Fi 扫描和接收扫描结果的端点
|
||||
* - prov-ctrl
|
||||
- http://wifi-prov.local/prov-ctrl
|
||||
- 用于控制 Wi-Fi 配网状态的端点
|
||||
* - prov-config
|
||||
- http://<mdns-hostname>.local/prov-config
|
||||
- 用于在设备上配置 Wi-Fi 凭据的端点
|
||||
* - proto-ver
|
||||
- http://<mdns-hostname>.local/proto-ver
|
||||
- 用于获取版本信息的端点
|
||||
|
||||
连接后,客户端应用程序可以立即从 ``proto-ver`` 端点获取版本或功能信息。所有与此端点的通信均未加密,因此在建立安全会话之前,可以检索相关必要信息,确保会话兼容。响应数据采用 JSON 格式,示例如下:``prov: { ver: v1.1, sec_ver: 1, sec_patch_ver: 0, cap: [no_pop] }, my_app: { ver: 1.345, cap: [cloud, local_ctrl] },....``。
|
||||
|
||||
其中,``prov`` 标签提供以下信息:
|
||||
|
||||
- 配网服务的版本 ``ver``
|
||||
- 安全版本 ``sec_ver``
|
||||
- 安全补丁版本 ``sec_patch_ver`` (默认为 0)
|
||||
- 功能 ``cap``
|
||||
|
||||
目前仅支持 ``no_pop`` 功能,该功能表示服务无需用户提供所有权证明即可进行身份验证。任何与应用程序相关的版本或功能将由其他标签提供,如上述示例中的 ``my_app``。使用 :cpp:func:`wifi_prov_mgr_set_app_info()` 可以设置这些附加字段。
|
||||
|
||||
.. important::
|
||||
建立会话时,客户端应依据 ``sec_ver`` 和 ``sec_patch_ver`` 字段来确定使用何种安全方案。
|
||||
|
||||
用户端应用程序需要根据所配置的安全方案实现签名握手,以建立和认证 protocomm 安全会话。当管理器配置为使用 protocomm security 0 时,则不需要实现签名握手。
|
||||
|
||||
关于安全握手和加密的详情,请参阅 :doc:`provisioning`。应用程序必须使用 :component:`protocomm/proto` 中的 ``.proto`` 文件。``.proto`` 文件定义了 ``prov-session`` 端点支持的 protobuf 消息结构。
|
||||
|
||||
建立会话后,以下 ``wifi_config`` 命令集可用于配置 Wi-Fi 凭据,这些命令会被序列化为 protobuf 消息,对应的 ``.proto`` 文件存放在 :component:`wifi_provisioning/proto` 中。
|
||||
|
||||
* ``get_status`` - 用于查询 Wi-Fi 连接状态。设备响应状态为连接中、已连接或已断开。如果状态为已断开,则还会包含断开原因。
|
||||
|
||||
* ``set_config`` - 用于设置 Wi-Fi 连接凭据。
|
||||
|
||||
* ``apply_config`` - 用于应用先前保存的凭据,即由 ``set_config`` 设置的凭据,并启动 Wi-Fi 站点。
|
||||
|
||||
建立会话后,客户端还可以从设备请求 Wi-Fi 扫描结果。返回结果为 AP SSID 的列表,按信号强度降序排序。由此,客户端应用程序可以在设备配网时显示附近的 AP,并且用户可以选择其中一个 SSID 并提供密码,然后使用上述 ``wifi_config`` 命令发送密码。``wifi_scan`` 端点支持以下 protobuf 命令:
|
||||
|
||||
* ``scan_start`` - 启动 Wi-Fi 扫描有多个选项,具体如下:
|
||||
|
||||
* ``blocking`` (输入)- 如果参数为 true,则命令只会在扫描完成后返回。
|
||||
|
||||
* ``passive`` (输入)- 如果参数为 true,则以被动模式启动扫描,扫描速度可能更慢。
|
||||
|
||||
* ``group_channels`` (输入)- 该参数用于指定是否分组扫描。如果参数为 0,表示一次性扫描所有信道;如果参数为非零值,则表示分组扫描信道且参数值为每组中的信道数,每个连续组之间有 120 毫秒的延迟。分组扫描非常适用于使用 SoftAP 的传输模式,因为一次性扫描所有信道可能会导致 Wi-Fi 驱动没有足够时间发送信标,进而导致与部分站点断连。分组扫描时,管理器每扫描完一组信道,至少会等待 120 毫秒,确保驱动程序有足够时间发送信标。例如,假设共有 14 个 Wi-Fi 信道,将 ``group_channels`` 设置为 3 则将创建 5 个分组,每个分组包含 3 个信道,最后一个分组则为 14 除以 3 余下的 2 个信道。因此,扫描开始时,首先会扫描前 3 个信道,然后等待 120 毫秒,再继续扫描后 3 个信道,以此类推,直到扫描完 14 个信道。可以根据实际情况调整此参数,因为分组中信道数量过少可能会增加整体扫描时间,而信道数量过多则可能会导致连接再次断开。大多数情况下,将参数值设置为 4 即可。请注意,对于低功耗蓝牙等其他传输模式,可以放心将该参数设置为 0,从而在最短时间内完成扫描。
|
||||
|
||||
* ``period_ms`` (输入)- 该扫描参数用于设置在每个信道上的等待时间。
|
||||
|
||||
* ``scan_status`` - 可以返回扫描过程的状态:
|
||||
|
||||
* ``scan_finished`` (输出)- 扫描完成时,该参数返回为 true。
|
||||
|
||||
* ``result_count`` (输出)- 该参数返回到目前为止获取的结果总数。如果扫描仍在进行,该数字会不断更新。
|
||||
|
||||
* ``scan_result`` - 用于获取扫描结果。即使扫描仍在进行,也可以调用此函数。
|
||||
|
||||
* ``start_index`` (输入)- 从结果列表中获取条目的起始索引位置。
|
||||
|
||||
* ``count`` (输入)- 从起始索引位置获取的条目数目。
|
||||
|
||||
* ``entries`` (输出)- 返回条目的列表。每个条目包含 ``ssid``、``channel`` 和 ``rssi`` 信息。
|
||||
|
||||
客户端还可以使用 ``wifi_ctrl`` 端点来控制设备的配网状态。``wifi_ctrl`` 端点支持的 protobuf 命令如下:
|
||||
|
||||
* ``ctrl_reset`` - 仅在配网失败时,重置设备的内部状态机并清除已配置的凭据。
|
||||
|
||||
* ``ctrl_reprov`` - 仅在设备已成功配网的前提下,设备需要重新配网获取新的凭据时,重置设备的内部状态机并清除已配置的凭据。
|
||||
|
||||
附加端点
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
如果用户想要根据自己的需求定制一些附加 protocomm 端点,可以通过两步完成。第一步是创建一个具有特定名称的端点,第二步是为该端点注册一个处理程序。关于端点处理程序的函数签名,请参阅 :doc:`protocomm`。自定义端点必须在初始化后、配网服务启动之前创建,但只能在配网服务启动后为该端点注册 protocomm 处理程序。注意在自定义端点处理程序的函数中,应使用堆来分配响应这些 protocomm 端点的内存,因为一旦传输层发送完毕,protocomm 层就会释放这部分内存。
|
||||
|
||||
.. code-block:: c
|
||||
|
||||
wifi_prov_mgr_init(config);
|
||||
wifi_prov_mgr_endpoint_create("custom-endpoint");
|
||||
wifi_prov_mgr_start_provisioning(security, pop, service_name, service_key);
|
||||
wifi_prov_mgr_endpoint_register("custom-endpoint", custom_ep_handler, custom_ep_data);
|
||||
|
||||
|
||||
配网服务停止时,端点会自动取消注册。
|
||||
|
||||
在运行时,可以调用 :cpp:func:`wifi_prov_mgr_endpoint_unregister()` 来手动停用某个端点。该函数也可以用于停用配网服务使用的内部端点。
|
||||
|
||||
何时以及如何停止配网服务?
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
当设备使用 ``apply_config`` 命令设置的 Wi-Fi 凭据成功连接,配网服务将默认停止,并在响应下一个 ``get_status`` 命令后自动关闭低功耗蓝牙或 softAP。如果设备没有收到 ``get_status`` 命令,配网服务将在超时 30 秒后停止。
|
||||
|
||||
如果设备因 SSID 或密码不正确等原因无法使用 Wi-Fi 凭据成功连接,配网服务将继续运行,并通过 ``get_status`` 命令持续响应为断连状态,并提供断连原因。此时设备不会再接受任何新的 Wi-Fi 凭据。除非强制启动配网服务或擦除 NVS 存储,这些凭据将保留。
|
||||
|
||||
可以调用 :cpp:func:`wifi_prov_mgr_disable_auto_stop()` 来禁用默认设置。禁用后,只有在显式调用 :cpp:func:`wifi_prov_mgr_stop_provisioning()` 之后,配网服务才会停止,且该函数会安排一个任务来停止配网服务,之后立即返回。配网服务将在一定延迟后停止,并触发 ``WIFI_PROV_END`` 事件。该延迟时间可以由 :cpp:func:`wifi_prov_mgr_disable_auto_stop()` 的参数指定。
|
||||
|
||||
如果需要在成功建立 Wi-Fi 连接后的某个时间再停止配网服务,应用程序可以采取定制行为。例如,如果应用程序需要设备连接到某个云服务并获取另一组凭证,继而通过自定义 protocomm 端点交换凭证,那么成功完成此操作后,可以在 protocomm 处理程序中调用 :cpp:func:`wifi_prov_mgr_stop_provisioning()` 来停止配网服务。设定适当的延迟时间可以确保 protocomm 处理程序的响应到达客户端应用程序后,才释放传输资源。
|
||||
|
||||
应用示例
|
||||
------------------
|
||||
|
||||
- :example:`provisioning/wifi_prov_mgr` 演示了如何使用 ``wifi_provisioning`` 组件将 {IDF_TARGET_NAME} 配置为带有凭证的 Wi-Fi station,使用低功耗蓝牙作为默认传输方式。
|
||||
|
||||
配网工具
|
||||
--------------------
|
||||
|
||||
以下为各平台相应的配网应用程序,并附带源代码:
|
||||
|
||||
* Android:
|
||||
* `Play Store 上的低功耗蓝牙配网应用程序 <https://play.google.com/store/apps/details?id=com.espressif.provble>`_。
|
||||
* `Play Store 上的 SoftAP 配网应用程序 <https://play.google.com/store/apps/details?id=com.espressif.provsoftap>`_。
|
||||
* GitHub 上的源代码: `esp-idf-provisioning-android <https://github.com/espressif/esp-idf-provisioning-android>`_。
|
||||
* iOS:
|
||||
* `App Store 上的低功耗蓝牙配网应用程序 <https://apps.apple.com/in/app/esp-ble-provisioning/id1473590141>`_。
|
||||
* `App Store 上的 SoftAP 配网应用程序 <https://apps.apple.com/in/app/esp-softap-provisioning/id1474040630>`_。
|
||||
* GitHub 上的源代码: `esp-idf-provisioning-ios <https://github.com/espressif/esp-idf-provisioning-ios>`_。
|
||||
* Linux/MacOS/Windows: 基于 Python 的命令行工具 :idf:`tools/esp_prov`,可用于设备配网。
|
||||
|
||||
手机应用程序界面简洁,便于用户使用,而开发者可以使用命令行应用程序,便于调试。
|
||||
|
||||
|
||||
API 参考
|
||||
-------------
|
||||
|
||||
.. include-build-file:: inc/manager.inc
|
||||
.. include-build-file:: inc/scheme_ble.inc
|
||||
.. include-build-file:: inc/scheme_softap.inc
|
||||
.. include-build-file:: inc/scheme_console.inc
|
||||
.. include-build-file:: inc/wifi_config.inc
|
@@ -6,7 +6,34 @@
|
||||
重大变更
|
||||
--------
|
||||
|
||||
函数 :cpp:func:`wifi_prov_mgr_deinit` 的返回值类型已从 ``void`` 变更为 :cpp:type:`esp_err_t`。此项变更使应用程序在反初始化配网管理器时能够妥善处理可能出现的故障。
|
||||
本次更新从 ESP-IDF 中移除了组件 ``wifi_provisioning``,更名为 ``network_provisioning`` 并作为一个独立组件受到支持。该组件增加了对Thread 配网的支持。可在乐鑫组件注册表中,查看更多有关 ``network_provisioning`` 的信息:
|
||||
|
||||
* `network_provisioning 组件 <https://components.espressif.com/component/espressif/network_provisioning>`__
|
||||
|
||||
在新版应用程序中, ``main`` 组件文件夹应包括组件管理器清单文件 ``idf_component.yml``,如下所示:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
dependencies:
|
||||
espressif/network_provisioning:
|
||||
version: "^1.0.5"
|
||||
|
||||
对于使用 ESP-IDF v5.x 及以后版本的应用程序,需要通过添加组件管理器清单文件 ``idf_component.yml`` 拉取新版 ``network_provisioning`` 组件。同时,在编译时,应去掉已过时的 ``wifi_provisioning`` 组件。此项操作可通过项目 ``CMakeLists.txt`` 中的以下语句实现:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
set(EXCLUDE_COMPONENTS wifi_provisioning)
|
||||
|
||||
在新版的组件中,组件接口名有所更新,绝大多数的改动是将原组件中的 ``wifi_prov_xx`` 改为 ``network_prov_xx`` 。下表展示了其余的应用程序接口在新旧组件中的变化:
|
||||
|
||||
.. csv-table::
|
||||
:header: "原组件接口", "现组件接口"
|
||||
|
||||
"wifi_prov_mgr_is_provisioned", "network_prov_mgr_is_wifi_provisioned"
|
||||
"wifi_prov_mgr_configure_sta", "network_prov_mgr_configure_wifi_sta"
|
||||
"wifi_prov_mgr_reset_provisioning", "network_prov_mgr_reset_wifi_provisioning"
|
||||
"wifi_prov_mgr_reset_sm_state_on_failure", "network_prov_mgr_reset_wifi_sm_state_on_failure"
|
||||
"wifi_prov_mgr_reset_sm_state_for_reprovision", "network_prov_mgr_reset_wifi_sm_state_for_reprovision"
|
||||
|
||||
配置变更
|
||||
--------
|
||||
|
@@ -265,7 +265,7 @@ UART 下载模式
|
||||
|
||||
ESP-IDF 提供了多种安全方案,可以在 ESP 设备和配网实体之间建立安全会话,具体方案请参阅 :ref:`provisioning_security_schemes`。
|
||||
|
||||
关于该功能的更多详情和代码示例,请参阅 :doc:`../api-reference/provisioning/wifi_provisioning`。
|
||||
关于该功能的更多详情和代码示例,请参阅 `network_provisioning <https://github.com/espressif/idf-extra-components/tree/master/network_provisioning>`_。
|
||||
|
||||
.. note::
|
||||
|
||||
|
@@ -20,7 +20,6 @@ The examples are grouped into subdirectories by category. Each category director
|
||||
- `openthread` OpenThread examples.
|
||||
- `peripherals` Examples showing driver functionality for the various onboard ESP32 peripherals.
|
||||
- `protocols` Examples showing network protocol interactions.
|
||||
- `provisioning` Wi-Fi provisioning examples.
|
||||
- `security` Examples about security features.
|
||||
- `storage` Examples showing data storage methods using SPI flash, external storage like the SD/MMC interface and flash partitioning.
|
||||
- `system` Demonstrates some internal chip features, or debugging & development tools.
|
||||
|
@@ -32,11 +32,11 @@ In the `Example Configuration` menu choose the provisioning method:
|
||||
* `EXAMPLE_WIFI_CONFIGURATION_MANUAL` for manual configuration using a webpage
|
||||
* `EXAMPLE_WIFI_CONFIGURATION_PROVISIONING` for standard provisioning over the virtual USB network
|
||||
|
||||
To provision the device using IDF provisioning tools (if `EXAMPLE_WIFI_CONFIGURATION_PROVISIONING` is selected) you can use idf provisioning utility with transport set to `softap`:
|
||||
To provision the device using network provisioning tools (if `EXAMPLE_WIFI_CONFIGURATION_PROVISIONING` is selected) you can use idf provisioning utility with transport set to `softap`:
|
||||
```bash
|
||||
esp-idf/tools/esp_prov$ python esp_prov.py --transport httpd ...
|
||||
network_provisioning/tool/esp_prov$ python esp_prov.py --transport httpd ...
|
||||
```
|
||||
Please refer to the provisioning documentation and `esp_prov` script [documentation](../../../tools/esp_prov/README.md) for more details.
|
||||
Please refer to the provisioning documentation and `esp_prov` script [documentation](https://github.com/espressif/idf-extra-components/blob/master/network_provisioning/tool/esp_prov/README.md) for more details.
|
||||
|
||||
### Build, Flash, and Run
|
||||
|
||||
|
@@ -14,5 +14,5 @@ idf_component_register(SRCS sta2eth_main.c
|
||||
${wired_iface}
|
||||
${config_method}
|
||||
PRIV_REQUIRES esp_wifi esp_timer esp_eth esp_http_server
|
||||
nvs_flash esp_driver_gpio wifi_provisioning
|
||||
nvs_flash esp_driver_gpio
|
||||
INCLUDE_DIRS "")
|
||||
|
@@ -21,7 +21,7 @@ menu "Example Configuration"
|
||||
depends on EXAMPLE_WIFI_CONFIGURATION_PROVISIONING
|
||||
default EXAMPLE_PROV_SECURITY_VERSION_1
|
||||
help
|
||||
Wi-Fi provisioning component offers 3 security versions.
|
||||
Network provisioning component offers 3 security versions.
|
||||
The example offers a choice between security version 1 and 2.
|
||||
You can also choose version 0, which is recommended only
|
||||
for testing (not secure, plain text communication)
|
||||
|
@@ -9,3 +9,5 @@ dependencies:
|
||||
path: ${IDF_PATH}/examples/protocols/http_server/captive_portal/components/dns_server
|
||||
espressif/ethernet_init:
|
||||
version: "0.7.0"
|
||||
espressif/network_provisioning:
|
||||
version: "^1.0.5"
|
||||
|
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
#include <wifi_provisioning/manager.h>
|
||||
#include <network_provisioning/manager.h>
|
||||
#include "esp_log.h"
|
||||
#include "esp_mac.h"
|
||||
#include "esp_event.h"
|
||||
@@ -93,10 +93,10 @@ static void event_handler(void *arg, esp_event_base_t event_base,
|
||||
{
|
||||
struct events *handler_args = arg;
|
||||
switch (event_id) {
|
||||
case WIFI_PROV_START:
|
||||
case NETWORK_PROV_START:
|
||||
ESP_LOGI(TAG, "Provisioning started");
|
||||
break;
|
||||
case WIFI_PROV_CRED_RECV: {
|
||||
case NETWORK_PROV_WIFI_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",
|
||||
@@ -104,26 +104,23 @@ static void event_handler(void *arg, esp_event_base_t event_base,
|
||||
(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;
|
||||
case NETWORK_PROV_WIFI_CRED_FAIL: {
|
||||
network_prov_wifi_sta_fail_reason_t *reason = (network_prov_wifi_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) ?
|
||||
(*reason == NETWORK_PROV_WIFI_STA_AUTH_ERROR) ?
|
||||
"Wi-Fi station authentication failed" : "Wi-Fi access-point not found");
|
||||
handler_args->success = false;
|
||||
|
||||
break;
|
||||
}
|
||||
case WIFI_PROV_CRED_SUCCESS:
|
||||
case NETWORK_PROV_WIFI_CRED_SUCCESS:
|
||||
ESP_LOGI(TAG, "Provisioning successful");
|
||||
handler_args->success = true;
|
||||
break;
|
||||
case WIFI_PROV_END:
|
||||
case NETWORK_PROV_END:
|
||||
/* De-initialize manager once provisioning is finished */
|
||||
esp_err_t err = wifi_prov_mgr_deinit();
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to de-initialize provisioning manager: %s", esp_err_to_name(err));
|
||||
}
|
||||
network_prov_mgr_deinit();
|
||||
xEventGroupSetBits(*handler_args->flags, handler_args->success ? handler_args->success_bit : handler_args->fail_bit);
|
||||
free(handler_args);
|
||||
break;
|
||||
@@ -132,7 +129,7 @@ static void event_handler(void *arg, esp_event_base_t event_base,
|
||||
}
|
||||
}
|
||||
|
||||
extern const wifi_prov_scheme_t wifi_prov_scheme_httpd;
|
||||
extern const network_prov_scheme_t network_prov_scheme_httpd;
|
||||
|
||||
esp_err_t start_provisioning(EventGroupHandle_t *flags, int success_bit, int fail_bit)
|
||||
{
|
||||
@@ -143,32 +140,32 @@ esp_err_t start_provisioning(EventGroupHandle_t *flags, int success_bit, int fai
|
||||
handler_args->flags = flags;
|
||||
handler_args->success_bit = success_bit;
|
||||
handler_args->fail_bit = fail_bit;
|
||||
ESP_ERROR_CHECK(esp_event_handler_register(WIFI_PROV_EVENT, ESP_EVENT_ANY_ID, event_handler, handler_args));
|
||||
ESP_ERROR_CHECK(esp_event_handler_register(NETWORK_PROV_EVENT, ESP_EVENT_ANY_ID, event_handler, handler_args));
|
||||
/* Configuration for the provisioning manager */
|
||||
wifi_prov_mgr_config_t config = {
|
||||
.scheme = wifi_prov_scheme_httpd,
|
||||
network_prov_mgr_config_t config = {
|
||||
.scheme = network_prov_scheme_httpd,
|
||||
};
|
||||
|
||||
/* Initialize provisioning manager with the
|
||||
* configuration parameters set above */
|
||||
ESP_ERROR_CHECK(wifi_prov_mgr_init(config));
|
||||
ESP_ERROR_CHECK(network_prov_mgr_init(config));
|
||||
|
||||
/* What is the security level that we want (0, 1, 2):
|
||||
* - WIFI_PROV_SECURITY_0 is simply plain text communication.
|
||||
* - WIFI_PROV_SECURITY_1 is secure communication which consists of secure handshake
|
||||
* - WIFI_PROV_SECURITY_2 SRP6a based authentication and key exchange
|
||||
* - NETWORK_PROV_SECURITY_0 is simply plain text communication.
|
||||
* - NETWORK_PROV_SECURITY_1 is secure communication which consists of secure handshake
|
||||
* - NETWORK_PROV_SECURITY_2 SRP6a based authentication and key exchange
|
||||
* Please check unified provisioning documentation for more details
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_EXAMPLE_PROV_SECURITY_VERSION_0
|
||||
wifi_prov_security_t security = WIFI_PROV_SECURITY_0;
|
||||
network_prov_security_t security = NETWORK_PROV_SECURITY_0;
|
||||
#elif CONFIG_EXAMPLE_PROV_SECURITY_VERSION_1
|
||||
wifi_prov_security_t security = WIFI_PROV_SECURITY_1;
|
||||
network_prov_security_t security = NETWORK_PROV_SECURITY_1;
|
||||
const char *pop = "abcd1234"; /* Proof of possession */
|
||||
wifi_prov_security1_params_t *sec_params = pop;
|
||||
network_prov_security1_params_t *sec_params = pop;
|
||||
|
||||
#elif CONFIG_EXAMPLE_PROV_SECURITY_VERSION_2
|
||||
wifi_prov_security_t security = WIFI_PROV_SECURITY_2;
|
||||
network_prov_security_t security = NETWORK_PROV_SECURITY_2;
|
||||
/* The username must be the same one, which has been used in the generation of salt and verifier */
|
||||
|
||||
#if CONFIG_EXAMPLE_PROV_SEC2_DEV_MODE
|
||||
@@ -185,23 +182,23 @@ esp_err_t start_provisioning(EventGroupHandle_t *flags, int success_bit, int fai
|
||||
/* This is the structure for passing security parameters
|
||||
* for the protocomm security 2.
|
||||
* If dynamically allocated, sec2_params pointer and its content
|
||||
* must be valid till WIFI_PROV_END event is triggered.
|
||||
* must be valid till NETWORK_PROV_END event is triggered.
|
||||
*/
|
||||
wifi_prov_security2_params_t sec2_params = {};
|
||||
network_prov_security2_params_t sec2_params = {};
|
||||
|
||||
ESP_ERROR_CHECK(example_get_sec2_salt(&sec2_params.salt, &sec2_params.salt_len));
|
||||
ESP_ERROR_CHECK(example_get_sec2_verifier(&sec2_params.verifier, &sec2_params.verifier_len));
|
||||
|
||||
wifi_prov_security2_params_t *sec_params = &sec2_params;
|
||||
network_prov_security2_params_t *sec_params = &sec2_params;
|
||||
#endif // CONFIG_EXAMPLE_PROV_SECURITY_VERSION_0 (VERSION_1, VERSION_2)
|
||||
|
||||
ESP_ERROR_CHECK(wifi_prov_mgr_start_provisioning(security, (const void *) sec_params, NULL, NULL)); // service name and key could be NULL
|
||||
ESP_ERROR_CHECK(network_prov_mgr_start_provisioning(security, (const void *) sec_params, NULL, NULL)); // service name and key could be NULL
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
bool is_provisioned(void)
|
||||
{
|
||||
bool provisioned = false;
|
||||
ESP_ERROR_CHECK(wifi_prov_mgr_is_provisioned(&provisioned));
|
||||
ESP_ERROR_CHECK(network_prov_mgr_is_wifi_provisioned(&provisioned));
|
||||
return provisioned;
|
||||
}
|
||||
|
@@ -7,11 +7,11 @@
|
||||
#include "sdkconfig.h"
|
||||
#include <esp_log.h>
|
||||
#include <esp_err.h>
|
||||
#include <wifi_provisioning/manager.h>
|
||||
#include <network_provisioning/manager.h>
|
||||
#include <protocomm.h>
|
||||
#include <protocomm_httpd.h>
|
||||
|
||||
static const char *TAG = "wifi_prov_scheme_httpd";
|
||||
static const char *TAG = "network_prov_scheme_httpd";
|
||||
|
||||
static esp_err_t prov_start(protocomm_t *pc, void *config)
|
||||
{
|
||||
@@ -56,7 +56,7 @@ static esp_err_t prov_stop(protocomm_t *pc)
|
||||
* We don't need to pass any config option at this moment, so we create
|
||||
* a dummy configuration since provisioning manager check for non-nullptr.
|
||||
* If needed we can extend this scheme to provide some options for httpd
|
||||
* or wifi provisioning.
|
||||
* or network provisioning.
|
||||
*/
|
||||
static void *new_config(void)
|
||||
{
|
||||
@@ -80,7 +80,7 @@ static esp_err_t set_config_endpoint(void *config, const char *endpoint_name, ui
|
||||
/**
|
||||
* @brief Creating a generic HTTPD scheme
|
||||
*/
|
||||
const wifi_prov_scheme_t wifi_prov_scheme_httpd = {
|
||||
const network_prov_scheme_t network_prov_scheme_httpd = {
|
||||
.prov_start = prov_start,
|
||||
.prov_stop = prov_stop,
|
||||
.new_config = new_config,
|
||||
|
@@ -16,15 +16,15 @@ from getpass import getpass
|
||||
import proto_lc
|
||||
|
||||
try:
|
||||
import esp_prov
|
||||
import security
|
||||
import transport
|
||||
except ImportError:
|
||||
idf_path = os.environ['IDF_PATH']
|
||||
sys.path.insert(0, idf_path + '/components/protocomm/python')
|
||||
sys.path.insert(1, idf_path + '/tools/esp_prov')
|
||||
sys.path.insert(1, idf_path + '/examples/protocols/esp_local_ctrl/scripts')
|
||||
|
||||
import esp_prov
|
||||
import security
|
||||
import transport
|
||||
|
||||
# Set this to true to allow exceptions to be thrown
|
||||
config_throw_except = False
|
||||
@@ -32,13 +32,13 @@ config_throw_except = False
|
||||
|
||||
# Property types enum
|
||||
PROP_TYPE_TIMESTAMP = 0
|
||||
PROP_TYPE_INT32 = 1
|
||||
PROP_TYPE_BOOLEAN = 2
|
||||
PROP_TYPE_STRING = 3
|
||||
PROP_TYPE_INT32 = 1
|
||||
PROP_TYPE_BOOLEAN = 2
|
||||
PROP_TYPE_STRING = 3
|
||||
|
||||
|
||||
# Property flags enum
|
||||
PROP_FLAG_READONLY = (1 << 0)
|
||||
PROP_FLAG_READONLY = 1 << 0
|
||||
|
||||
|
||||
def prop_typestr(prop):
|
||||
@@ -125,20 +125,22 @@ def get_security(secver, sec_patch_ver, username, password, pop='', verbose=Fals
|
||||
async def get_transport(sel_transport, service_name, check_hostname):
|
||||
try:
|
||||
tp = None
|
||||
if (sel_transport == 'http'):
|
||||
tp = esp_prov.transport.Transport_HTTP(service_name, None)
|
||||
elif (sel_transport == 'https'):
|
||||
if sel_transport == 'http':
|
||||
tp = transport.Transport_HTTP(service_name, None)
|
||||
elif sel_transport == 'https':
|
||||
example_path = os.environ['IDF_PATH'] + '/examples/protocols/esp_local_ctrl'
|
||||
cert_path = example_path + '/main/certs/rootCA.pem'
|
||||
ssl_ctx = ssl.create_default_context(cafile=cert_path)
|
||||
ssl_ctx.check_hostname = check_hostname
|
||||
tp = esp_prov.transport.Transport_HTTP(service_name, ssl_ctx)
|
||||
elif (sel_transport == 'ble'):
|
||||
tp = esp_prov.transport.Transport_BLE(
|
||||
tp = transport.Transport_HTTP(service_name, ssl_ctx)
|
||||
elif sel_transport == 'ble':
|
||||
tp = transport.Transport_BLE(
|
||||
service_uuid='3d981e4a-31eb-42b4-8a68-75bd8d3bd521',
|
||||
nu_lookup={'esp_local_ctrl/version': '0001',
|
||||
'esp_local_ctrl/session': '0002',
|
||||
'esp_local_ctrl/control': '0003'}
|
||||
nu_lookup={
|
||||
'esp_local_ctrl/version': '0001',
|
||||
'esp_local_ctrl/session': '0002',
|
||||
'esp_local_ctrl/control': '0003',
|
||||
},
|
||||
)
|
||||
await tp.connect(devname=service_name)
|
||||
return tp
|
||||
@@ -249,7 +251,7 @@ async def establish_session(tp, sec):
|
||||
if request is None:
|
||||
break
|
||||
response = await tp.send_data('esp_local_ctrl/session', request)
|
||||
if (response is None):
|
||||
if response is None:
|
||||
return False
|
||||
return True
|
||||
except RuntimeError as e:
|
||||
@@ -305,47 +307,67 @@ async def main():
|
||||
|
||||
parser = argparse.ArgumentParser(description='Control an ESP32 running esp_local_ctrl service')
|
||||
|
||||
parser.add_argument('--version', dest='version', type=str,
|
||||
help='Protocol version', default='')
|
||||
parser.add_argument('--version', dest='version', type=str, help='Protocol version', default='')
|
||||
|
||||
parser.add_argument('--transport', dest='transport', type=str,
|
||||
help='transport i.e http/https/ble', default='https')
|
||||
parser.add_argument('--transport', dest='transport', type=str, help='transport i.e http/https/ble', default='https')
|
||||
|
||||
parser.add_argument('--name', dest='service_name', type=str,
|
||||
help='BLE Device Name / HTTP Server hostname or IP', default='')
|
||||
parser.add_argument(
|
||||
'--name', dest='service_name', type=str, help='BLE Device Name / HTTP Server hostname or IP', default=''
|
||||
)
|
||||
|
||||
parser.add_argument('--sec_ver', dest='secver', type=int, default=None,
|
||||
help=desc_format(
|
||||
'Protocomm security scheme used for secure '
|
||||
'session establishment. Accepted values are :',
|
||||
'\t- 0 : No security',
|
||||
'\t- 1 : X25519 key exchange + AES-CTR encryption',
|
||||
'\t- 2 : SRP6a + AES-GCM encryption',
|
||||
'\t + Authentication using Proof of Possession (PoP)'))
|
||||
parser.add_argument(
|
||||
'--sec_ver',
|
||||
dest='secver',
|
||||
type=int,
|
||||
default=None,
|
||||
help=desc_format(
|
||||
'Protocomm security scheme used for secure session establishment. Accepted values are :',
|
||||
'\t- 0 : No security',
|
||||
'\t- 1 : X25519 key exchange + AES-CTR encryption',
|
||||
'\t- 2 : SRP6a + AES-GCM encryption',
|
||||
'\t + Authentication using Proof of Possession (PoP)',
|
||||
),
|
||||
)
|
||||
|
||||
parser.add_argument('--pop', dest='pop', type=str, default='',
|
||||
help=desc_format(
|
||||
'This specifies the Proof of possession (PoP) when security scheme 1 '
|
||||
'is used'))
|
||||
parser.add_argument(
|
||||
'--pop',
|
||||
dest='pop',
|
||||
type=str,
|
||||
default='',
|
||||
help=desc_format('This specifies the Proof of possession (PoP) when security scheme 1 is used'),
|
||||
)
|
||||
|
||||
parser.add_argument('--sec2_username', dest='sec2_usr', type=str, default='',
|
||||
help=desc_format(
|
||||
'Username for security scheme 2 (SRP6a)'))
|
||||
parser.add_argument(
|
||||
'--sec2_username',
|
||||
dest='sec2_usr',
|
||||
type=str,
|
||||
default='',
|
||||
help=desc_format('Username for security scheme 2 (SRP6a)'),
|
||||
)
|
||||
|
||||
parser.add_argument('--sec2_pwd', dest='sec2_pwd', type=str, default='',
|
||||
help=desc_format(
|
||||
'Password for security scheme 2 (SRP6a)'))
|
||||
parser.add_argument(
|
||||
'--sec2_pwd', dest='sec2_pwd', type=str, default='', help=desc_format('Password for security scheme 2 (SRP6a)')
|
||||
)
|
||||
|
||||
parser.add_argument('--sec2_gen_cred', help='Generate salt and verifier for security scheme 2 (SRP6a)', action='store_true')
|
||||
parser.add_argument(
|
||||
'--sec2_gen_cred', help='Generate salt and verifier for security scheme 2 (SRP6a)', action='store_true'
|
||||
)
|
||||
|
||||
parser.add_argument('--sec2_salt_len', dest='sec2_salt_len', type=int, default=16,
|
||||
help=desc_format(
|
||||
'Salt length for security scheme 2 (SRP6a)'))
|
||||
parser.add_argument(
|
||||
'--sec2_salt_len',
|
||||
dest='sec2_salt_len',
|
||||
type=int,
|
||||
default=16,
|
||||
help=desc_format('Salt length for security scheme 2 (SRP6a)'),
|
||||
)
|
||||
|
||||
parser.add_argument('--dont-check-hostname', action='store_true',
|
||||
# If enabled, the certificate won't be rejected for hostname mismatch.
|
||||
# This option is hidden because it should be used only for testing purposes.
|
||||
help=argparse.SUPPRESS)
|
||||
parser.add_argument(
|
||||
'--dont-check-hostname',
|
||||
action='store_true',
|
||||
# If enabled, the certificate won't be rejected for hostname mismatch.
|
||||
# This option is hidden because it should be used only for testing purposes.
|
||||
help=argparse.SUPPRESS,
|
||||
)
|
||||
|
||||
parser.add_argument('-v', '--verbose', dest='verbose', help='increase output verbosity', action='store_true')
|
||||
|
||||
@@ -383,7 +405,7 @@ async def main():
|
||||
args.secver = int(not await has_capability(obj_transport, 'no_sec'))
|
||||
print(f'==== Security Scheme: {args.secver} ====')
|
||||
|
||||
if (args.secver == 1):
|
||||
if args.secver == 1:
|
||||
if not await has_capability(obj_transport, 'no_pop'):
|
||||
if len(args.pop) == 0:
|
||||
print('---- Proof of Possession argument not provided ----')
|
||||
@@ -392,7 +414,7 @@ async def main():
|
||||
print('---- Proof of Possession will be ignored ----')
|
||||
args.pop = ''
|
||||
|
||||
if (args.secver == 2):
|
||||
if args.secver == 2:
|
||||
sec_patch_ver = await get_sec_patch_ver(obj_transport, args.verbose)
|
||||
if len(args.sec2_usr) == 0:
|
||||
args.sec2_usr = input('Security Scheme 2 - SRP6a Username required: ')
|
||||
@@ -422,18 +444,22 @@ async def main():
|
||||
raise RuntimeError('Error in reading property value')
|
||||
|
||||
print('\n==== Available Properties ====')
|
||||
print('{0: >4} {1: <16} {2: <10} {3: <16} {4: <16}'.format(
|
||||
'S.N.', 'Name', 'Type', 'Flags', 'Value'))
|
||||
print('{: >4} {: <16} {: <10} {: <16} {: <16}'.format('S.N.', 'Name', 'Type', 'Flags', 'Value'))
|
||||
for i in range(len(properties)):
|
||||
print('[{0: >2}] {1: <16} {2: <10} {3: <16} {4: <16}'.format(
|
||||
i + 1, properties[i]['name'], prop_typestr(properties[i]),
|
||||
['','Read-Only'][prop_is_readonly(properties[i])],
|
||||
str(properties[i]['value'])))
|
||||
print(
|
||||
'[{: >2}] {: <16} {: <10} {: <16} {: <16}'.format(
|
||||
i + 1,
|
||||
properties[i]['name'],
|
||||
prop_typestr(properties[i]),
|
||||
['', 'Read-Only'][prop_is_readonly(properties[i])],
|
||||
str(properties[i]['value']),
|
||||
)
|
||||
)
|
||||
|
||||
select = 0
|
||||
while True:
|
||||
try:
|
||||
inval = input('\nSelect properties to set (0 to re-read, \'q\' to quit) : ')
|
||||
inval = input("\nSelect properties to set (0 to re-read, 'q' to quit) : ")
|
||||
if inval.lower() == 'q':
|
||||
print('Quitting...')
|
||||
exit(0)
|
||||
@@ -453,8 +479,7 @@ async def main():
|
||||
for select in selections:
|
||||
while True:
|
||||
inval = input('Enter value to set for property (' + properties[select - 1]['name'] + ') : ')
|
||||
value = encode_prop_value(properties[select - 1],
|
||||
str_to_prop_value(properties[select - 1], inval))
|
||||
value = encode_prop_value(properties[select - 1], str_to_prop_value(properties[select - 1], inval))
|
||||
if value is None:
|
||||
print('Invalid input! Retry...')
|
||||
continue
|
||||
@@ -465,5 +490,6 @@ async def main():
|
||||
if not await set_property_values(obj_transport, obj_security, properties, set_indices, set_values):
|
||||
print('Failed to set values!')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
asyncio.run(main())
|
||||
|
31
examples/protocols/esp_local_ctrl/scripts/proto/__init__.py
Normal file
31
examples/protocols/esp_local_ctrl/scripts/proto/__init__.py
Normal file
@@ -0,0 +1,31 @@
|
||||
# SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
import importlib.util
|
||||
import os
|
||||
import sys
|
||||
from importlib.abc import Loader
|
||||
from typing import Any
|
||||
|
||||
|
||||
def _load_source(name: str, path: str) -> Any:
|
||||
spec = importlib.util.spec_from_file_location(name, path)
|
||||
if not spec:
|
||||
return None
|
||||
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
sys.modules[spec.name] = module
|
||||
assert isinstance(spec.loader, Loader)
|
||||
spec.loader.exec_module(module)
|
||||
return module
|
||||
|
||||
|
||||
idf_path = os.environ['IDF_PATH']
|
||||
|
||||
# protocomm component related python files generated from .proto files
|
||||
constants_pb2 = _load_source('constants_pb2', idf_path + '/components/protocomm/python/constants_pb2.py')
|
||||
sec0_pb2 = _load_source('sec0_pb2', idf_path + '/components/protocomm/python/sec0_pb2.py')
|
||||
sec1_pb2 = _load_source('sec1_pb2', idf_path + '/components/protocomm/python/sec1_pb2.py')
|
||||
sec2_pb2 = _load_source('sec2_pb2', idf_path + '/components/protocomm/python/sec2_pb2.py')
|
||||
session_pb2 = _load_source('session_pb2', idf_path + '/components/protocomm/python/session_pb2.py')
|
@@ -21,10 +21,10 @@ class Security0(Security):
|
||||
def security0_session(self, response_data):
|
||||
# protocomm security0 FSM which interprets/forms
|
||||
# protobuf packets according to present state of session
|
||||
if (self.session_state == 0):
|
||||
if self.session_state == 0:
|
||||
self.session_state = 1
|
||||
return self.setup0_request()
|
||||
if (self.session_state == 1):
|
||||
if self.session_state == 1:
|
||||
self.setup0_response(response_data)
|
||||
return None
|
||||
|
@@ -7,10 +7,15 @@
|
||||
|
||||
import proto
|
||||
from cryptography.hazmat.backends import default_backend
|
||||
from cryptography.hazmat.primitives import hashes, serialization
|
||||
from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey, X25519PublicKey
|
||||
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
|
||||
from utils import long_to_bytes, str_to_bytes
|
||||
from cryptography.hazmat.primitives import hashes
|
||||
from cryptography.hazmat.primitives import serialization
|
||||
from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey
|
||||
from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PublicKey
|
||||
from cryptography.hazmat.primitives.ciphers import Cipher
|
||||
from cryptography.hazmat.primitives.ciphers import algorithms
|
||||
from cryptography.hazmat.primitives.ciphers import modes
|
||||
from utils import long_to_bytes
|
||||
from utils import str_to_bytes
|
||||
|
||||
from .security import Security
|
||||
|
||||
@@ -38,14 +43,14 @@ class Security1(Security):
|
||||
def security1_session(self, response_data):
|
||||
# protocomm security1 FSM which interprets/forms
|
||||
# protobuf packets according to present state of session
|
||||
if (self.session_state == security_state.REQUEST1):
|
||||
if self.session_state == security_state.REQUEST1:
|
||||
self.session_state = security_state.RESPONSE1_REQUEST2
|
||||
return self.setup0_request()
|
||||
elif (self.session_state == security_state.RESPONSE1_REQUEST2):
|
||||
elif self.session_state == security_state.RESPONSE1_REQUEST2:
|
||||
self.session_state = security_state.RESPONSE2
|
||||
self.setup0_response(response_data)
|
||||
return self.setup1_request()
|
||||
elif (self.session_state == security_state.RESPONSE2):
|
||||
elif self.session_state == security_state.RESPONSE2:
|
||||
self.session_state = security_state.FINISHED
|
||||
self.setup1_response(response_data)
|
||||
return None
|
||||
@@ -57,11 +62,11 @@ class Security1(Security):
|
||||
# Generate private and public key pair for client
|
||||
self.client_private_key = X25519PrivateKey.generate()
|
||||
self.client_public_key = self.client_private_key.public_key().public_bytes(
|
||||
encoding=serialization.Encoding.Raw,
|
||||
format=serialization.PublicFormat.Raw)
|
||||
encoding=serialization.Encoding.Raw, format=serialization.PublicFormat.Raw
|
||||
)
|
||||
|
||||
def _print_verbose(self, data):
|
||||
if (self.verbose):
|
||||
if self.verbose:
|
||||
print(f'\x1b[32;20m++++ {data} ++++\x1b[0m')
|
||||
|
||||
def setup0_request(self):
|
||||
@@ -127,7 +132,7 @@ class Security1(Security):
|
||||
self._print_verbose(f'Device Proof:\t0x{device_verify.hex()}')
|
||||
# Decrypt the device verify string
|
||||
enc_client_pubkey = self.cipher.update(setup_resp.sec1.sr1.device_verify_data)
|
||||
# Match decryped string with client public key
|
||||
# Match decrypted string with client public key
|
||||
if enc_client_pubkey != self.client_public_key:
|
||||
raise RuntimeError('Failed to verify device!')
|
||||
else:
|
@@ -4,7 +4,6 @@
|
||||
# protocomm endpoint with security type protocomm_security2
|
||||
import struct
|
||||
from typing import Any
|
||||
from typing import Type
|
||||
|
||||
import proto
|
||||
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
|
||||
@@ -12,8 +11,8 @@ from utils import long_to_bytes
|
||||
from utils import str_to_bytes
|
||||
|
||||
from .security import Security
|
||||
from .srp6a import generate_salt_and_verifier
|
||||
from .srp6a import Srp6a
|
||||
from .srp6a import generate_salt_and_verifier
|
||||
|
||||
AES_KEY_LEN = 256 // 8
|
||||
|
||||
@@ -30,16 +29,16 @@ def sec2_gen_salt_verifier(username: str, password: str, salt_len: int) -> Any:
|
||||
salt, verifier = generate_salt_and_verifier(username, password, len_s=salt_len)
|
||||
|
||||
salt_str = ', '.join([format(b, '#04x') for b in salt])
|
||||
salt_c_arr = '\n '.join(salt_str[i: i + 96] for i in range(0, len(salt_str), 96))
|
||||
salt_c_arr = '\n '.join(salt_str[i : i + 96] for i in range(0, len(salt_str), 96))
|
||||
print(f'static const char sec2_salt[] = {{\n {salt_c_arr}\n}};\n') # noqa E702
|
||||
|
||||
verifier_str = ', '.join([format(b, '#04x') for b in verifier])
|
||||
verifier_c_arr = '\n '.join(verifier_str[i: i + 96] for i in range(0, len(verifier_str), 96))
|
||||
verifier_c_arr = '\n '.join(verifier_str[i : i + 96] for i in range(0, len(verifier_str), 96))
|
||||
print(f'static const char sec2_verifier[] = {{\n {verifier_c_arr}\n}};\n') # noqa E702
|
||||
|
||||
|
||||
class Security2(Security):
|
||||
def __init__(self, sec_patch_ver:int, username: str, password: str, verbose: bool) -> None:
|
||||
def __init__(self, sec_patch_ver: int, username: str, password: str, verbose: bool) -> None:
|
||||
# Initialize state of the security2 FSM
|
||||
self.session_state = security_state.REQUEST1
|
||||
self.sec_patch_ver = sec_patch_ver
|
||||
@@ -47,8 +46,8 @@ class Security2(Security):
|
||||
self.password = password
|
||||
self.verbose = verbose
|
||||
|
||||
self.srp6a_ctx: Type[Srp6a]
|
||||
self.cipher: Type[AESGCM]
|
||||
self.srp6a_ctx: type[Srp6a]
|
||||
self.cipher: type[AESGCM]
|
||||
|
||||
self.client_pop_key = None
|
||||
self.nonce = bytearray()
|
||||
@@ -58,16 +57,16 @@ class Security2(Security):
|
||||
def security2_session(self, response_data: bytes) -> Any:
|
||||
# protocomm security2 FSM which interprets/forms
|
||||
# protobuf packets according to present state of session
|
||||
if (self.session_state == security_state.REQUEST1):
|
||||
if self.session_state == security_state.REQUEST1:
|
||||
self.session_state = security_state.RESPONSE1_REQUEST2
|
||||
return self.setup0_request()
|
||||
|
||||
if (self.session_state == security_state.RESPONSE1_REQUEST2):
|
||||
if self.session_state == security_state.RESPONSE1_REQUEST2:
|
||||
self.session_state = security_state.RESPONSE2
|
||||
self.setup0_response(response_data)
|
||||
return self.setup1_request()
|
||||
|
||||
if (self.session_state == security_state.RESPONSE2):
|
||||
if self.session_state == security_state.RESPONSE2:
|
||||
self.session_state = security_state.FINISHED
|
||||
self.setup1_response(response_data)
|
||||
return None
|
||||
@@ -76,7 +75,7 @@ class Security2(Security):
|
||||
return None
|
||||
|
||||
def _print_verbose(self, data: str) -> None:
|
||||
if (self.verbose):
|
||||
if self.verbose:
|
||||
print(f'\x1b[32;20m++++ {data} ++++\x1b[0m') # noqa E702
|
||||
|
||||
def setup0_request(self) -> Any:
|
@@ -18,9 +18,11 @@
|
||||
|
||||
import hashlib
|
||||
import os
|
||||
from typing import Any, Callable, Optional, Tuple
|
||||
from collections.abc import Callable
|
||||
from typing import Any
|
||||
|
||||
from utils import bytes_to_long, long_to_bytes
|
||||
from utils import bytes_to_long
|
||||
from utils import long_to_bytes
|
||||
|
||||
SHA1 = 0
|
||||
SHA224 = 1
|
||||
@@ -34,33 +36,40 @@ NG_3072 = 2
|
||||
NG_4096 = 3
|
||||
NG_8192 = 4
|
||||
|
||||
_hash_map = {SHA1: hashlib.sha1,
|
||||
SHA224: hashlib.sha224,
|
||||
SHA256: hashlib.sha256,
|
||||
SHA384: hashlib.sha384,
|
||||
SHA512: hashlib.sha512}
|
||||
_hash_map = {
|
||||
SHA1: hashlib.sha1,
|
||||
SHA224: hashlib.sha224,
|
||||
SHA256: hashlib.sha256,
|
||||
SHA384: hashlib.sha384,
|
||||
SHA512: hashlib.sha512,
|
||||
}
|
||||
|
||||
|
||||
_ng_const = (
|
||||
# 1024-bit
|
||||
('''\
|
||||
(
|
||||
"""\
|
||||
EEAF0AB9ADB38DD69C33F80AFA8FC5E86072618775FF3C0B9EA2314C9C256576D674DF7496\
|
||||
EA81D3383B4813D692C6E0E0D5D8E250B98BE48E495C1D6089DAD15DC7D7B46154D6B6CE8E\
|
||||
F4AD69B15D4982559B297BCF1885C529F566660E57EC68EDBC3C05726CC02FD4CBF4976EAA\
|
||||
9AFD5138FE8376435B9FC61D2FC0EB06E3''',
|
||||
'2'),
|
||||
9AFD5138FE8376435B9FC61D2FC0EB06E3""",
|
||||
'2',
|
||||
),
|
||||
# 2048
|
||||
('''\
|
||||
(
|
||||
"""\
|
||||
AC6BDB41324A9A9BF166DE5E1389582FAF72B6651987EE07FC3192943DB56050A37329CBB4\
|
||||
A099ED8193E0757767A13DD52312AB4B03310DCD7F48A9DA04FD50E8083969EDB767B0CF60\
|
||||
95179A163AB3661A05FBD5FAAAE82918A9962F0B93B855F97993EC975EEAA80D740ADBF4FF\
|
||||
747359D041D5C33EA71D281E446B14773BCA97B43A23FB801676BD207A436C6481F1D2B907\
|
||||
8717461A5B9D32E688F87748544523B524B0D57D5EA77A2775D2ECFA032CFBDBF52FB37861\
|
||||
60279004E57AE6AF874E7303CE53299CCC041C7BC308D82A5698F3A8D0C38271AE35F8E9DB\
|
||||
FBB694B5C803D89F7AE435DE236D525F54759B65E372FCD68EF20FA7111F9E4AFF73''',
|
||||
'2'),
|
||||
FBB694B5C803D89F7AE435DE236D525F54759B65E372FCD68EF20FA7111F9E4AFF73""",
|
||||
'2',
|
||||
),
|
||||
# 3072
|
||||
('''\
|
||||
(
|
||||
"""\
|
||||
FFFFFFFFFFFFFFFFC90FDAA22168C2\
|
||||
34C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E\
|
||||
3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B5\
|
||||
@@ -74,10 +83,12 @@ FFFFFFFFFFFFFFFFC90FDAA22168C2\
|
||||
E1E4C7ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6BF12FFA\
|
||||
06D98A0864D87602733EC86A64521F2B18177B200CBBE117577A615D6C77\
|
||||
0988C0BAD946E208E24FA074E5AB3143DB5BFCE0FD108E4B82D120A93AD2\
|
||||
CAFFFFFFFFFFFFFFFF''',
|
||||
'5'),
|
||||
CAFFFFFFFFFFFFFFFF""",
|
||||
'5',
|
||||
),
|
||||
# 4096
|
||||
('''\
|
||||
(
|
||||
"""\
|
||||
FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E08\
|
||||
8A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B\
|
||||
302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9\
|
||||
@@ -96,10 +107,12 @@ E0FD108E4B82D120A92108011A723C12A787E6D788719A10BDBA5B26\
|
||||
04DE8EF92E8EFC141FBECAA6287C59474E6BC05D99B2964FA090C3A2\
|
||||
233BA186515BE7ED1F612970CEE2D7AFB81BDD762170481CD0069127\
|
||||
D5B05AA993B4EA988D8FDDC186FFB7DC90A6C08F4DF435C934063199\
|
||||
FFFFFFFFFFFFFFFF''',
|
||||
'5'),
|
||||
FFFFFFFFFFFFFFFF""",
|
||||
'5',
|
||||
),
|
||||
# 8192
|
||||
('''\
|
||||
(
|
||||
"""\
|
||||
FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E08\
|
||||
8A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B\
|
||||
302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9\
|
||||
@@ -136,12 +149,13 @@ B7C5DA76F550AA3D8A1FBFF0EB19CCB1A313D55CDA56C9EC2EF29632\
|
||||
0846851DF9AB48195DED7EA1B1D510BD7EE74D73FAF36BC31ECFA268\
|
||||
359046F4EB879F924009438B481C6CD7889A002ED5EE382BC9190DA6\
|
||||
FC026E479558E4475677E9AA9E3050E2765694DFC81F56E880B96E71\
|
||||
60C980DD98EDD3DFFFFFFFFFFFFFFFFF''',
|
||||
'0x13')
|
||||
60C980DD98EDD3DFFFFFFFFFFFFFFFFF""",
|
||||
'0x13',
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def get_ng(ng_type: int) -> Tuple[int, int]:
|
||||
def get_ng(ng_type: int) -> tuple[int, int]:
|
||||
n_hex, g_hex = _ng_const[ng_type]
|
||||
return int(n_hex, 16), int(g_hex, 16)
|
||||
|
||||
@@ -189,7 +203,9 @@ def calculate_x(hash_class: Callable, s: Any, Iu: str, p: str) -> int:
|
||||
return H(hash_class, s, H(hash_class, _Iu + b':' + _p))
|
||||
|
||||
|
||||
def generate_salt_and_verifier(Iu: str, p: str, len_s: int, hash_alg: int = SHA512, ng_type: int = NG_3072) -> Tuple[bytes, bytes]:
|
||||
def generate_salt_and_verifier(
|
||||
Iu: str, p: str, len_s: int, hash_alg: int = SHA512, ng_type: int = NG_3072
|
||||
) -> tuple[bytes, bytes]:
|
||||
hash_class = _hash_map[hash_alg]
|
||||
N, g = get_ng(ng_type)
|
||||
|
||||
@@ -219,7 +235,7 @@ def calculate_H_AMK(hash_class: Callable, A: int, M: bytes, K: bytes) -> Any:
|
||||
return h.digest()
|
||||
|
||||
|
||||
class Srp6a (object):
|
||||
class Srp6a:
|
||||
def __init__(self, username: str, password: str, hash_alg: int = SHA512, ng_type: int = NG_3072):
|
||||
hash_class = _hash_map[hash_alg]
|
||||
|
||||
@@ -232,8 +248,8 @@ class Srp6a (object):
|
||||
self.a = get_random_of_length(32)
|
||||
self.A = pow(g, self.a, N)
|
||||
|
||||
self.v: Optional[int] = None
|
||||
self.K: Optional[bytes] = None
|
||||
self.v: int | None = None
|
||||
self.K: bytes | None = None
|
||||
self.H_AMK = None
|
||||
self._authenticated = False
|
||||
|
||||
@@ -254,7 +270,7 @@ class Srp6a (object):
|
||||
def get_session_key(self) -> Any:
|
||||
return self.K if self._authenticated else None
|
||||
|
||||
def start_authentication(self) -> Tuple[str, bytes]:
|
||||
def start_authentication(self) -> tuple[str, bytes]:
|
||||
return (self.Iu, long_to_bytes(self.A))
|
||||
|
||||
# Returns M or None if SRP-6a safety check is violated
|
||||
@@ -297,5 +313,5 @@ class Srp6a (object):
|
||||
self._authenticated = True
|
||||
|
||||
|
||||
class AuthenticationFailed (Exception):
|
||||
class AuthenticationFailed(Exception):
|
||||
pass
|
@@ -4,7 +4,8 @@
|
||||
|
||||
import platform
|
||||
|
||||
from utils import hex_str_to_bytes, str_to_bytes
|
||||
from utils import hex_str_to_bytes
|
||||
from utils import str_to_bytes
|
||||
|
||||
fallback = True
|
||||
|
||||
@@ -13,6 +14,7 @@ fallback = True
|
||||
# else fallback to console mode
|
||||
try:
|
||||
import bleak
|
||||
|
||||
fallback = False
|
||||
except ImportError:
|
||||
pass
|
||||
@@ -20,6 +22,7 @@ except ImportError:
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
|
||||
def device_sort(device):
|
||||
return device[0].address
|
||||
|
||||
@@ -63,10 +66,11 @@ class BLE_Bleak_Client:
|
||||
while True:
|
||||
devices.sort(key=device_sort)
|
||||
print('==== BLE Discovery results ====')
|
||||
print('{0: >4} {1: <33} {2: <12}'.format(
|
||||
'S.N.', 'Name', 'Address'))
|
||||
print('{: >4} {: <33} {: <12}'.format('S.N.', 'Name', 'Address'))
|
||||
for i, _ in enumerate(devices):
|
||||
print('[{0: >2}] {1: <33} {2: <12}'.format(i + 1, devices[i][0].name or 'Unknown', devices[i][0].address))
|
||||
print(
|
||||
'[{: >2}] {: <33} {: <12}'.format(i + 1, devices[i][0].name or 'Unknown', devices[i][0].address)
|
||||
)
|
||||
|
||||
while True:
|
||||
try:
|
||||
@@ -164,6 +168,8 @@ class BLE_Bleak_Client:
|
||||
await self.device.write_gatt_char(characteristic_uuid, bytearray(data.encode('latin-1')), True)
|
||||
readval = await self.device.read_gatt_char(characteristic_uuid)
|
||||
return ''.join(chr(b) for b in readval)
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -178,7 +184,9 @@ class BLE_Console_Client:
|
||||
if resp != 'Y' and resp != 'y':
|
||||
return False
|
||||
print('BLECLI >> List available attributes of the connected device')
|
||||
resp = input("BLECLI >> Is the service UUID '" + fallback_srv_uuid + "' listed among available attributes? [y/n] ")
|
||||
resp = input(
|
||||
"BLECLI >> Is the service UUID '" + fallback_srv_uuid + "' listed among available attributes? [y/n] "
|
||||
)
|
||||
if resp != 'Y' and resp != 'y':
|
||||
return False
|
||||
return True
|
@@ -7,8 +7,7 @@
|
||||
import abc
|
||||
|
||||
|
||||
class Transport():
|
||||
|
||||
class Transport:
|
||||
@abc.abstractmethod
|
||||
def send_session_data(self, data):
|
||||
pass
|
@@ -14,17 +14,18 @@ class Transport_BLE(Transport):
|
||||
# Expect service UUID like '0000ffff-0000-1000-8000-00805f9b34fb'
|
||||
for name in nu_lookup.keys():
|
||||
# Calculate characteristic UUID for each endpoint
|
||||
nu_lookup[name] = service_uuid[:4] + '{:02x}'.format(
|
||||
int(nu_lookup[name], 16) & int(service_uuid[4:8], 16)) + service_uuid[8:]
|
||||
nu_lookup[name] = (
|
||||
service_uuid[:4] + f'{int(nu_lookup[name], 16) & int(service_uuid[4:8], 16):02x}' + service_uuid[8:]
|
||||
)
|
||||
|
||||
# Get BLE client module
|
||||
self.cli = ble_cli.get_client()
|
||||
|
||||
async def connect(self, devname):
|
||||
# Use client to connect to BLE device and bind to service
|
||||
if not await self.cli.connect(devname=devname, iface='hci0',
|
||||
chrc_names=self.nu_lookup.keys(),
|
||||
fallback_srv_uuid=self.service_uuid):
|
||||
if not await self.cli.connect(
|
||||
devname=devname, iface='hci0', chrc_names=self.nu_lookup.keys(), fallback_srv_uuid=self.service_uuid
|
||||
):
|
||||
raise RuntimeError('Failed to initialize transport')
|
||||
|
||||
# Irrespective of provided parameters, let the client
|
@@ -7,7 +7,6 @@ from .transport import Transport
|
||||
|
||||
|
||||
class Transport_Console(Transport):
|
||||
|
||||
async def send_data(self, path, data, session_id=0):
|
||||
print('Client->Device msg :', path, session_id, str_to_bytes(data).hex())
|
||||
try:
|
@@ -26,7 +26,7 @@ class Transport_HTTP(Transport):
|
||||
self.conn.connect()
|
||||
except Exception as err:
|
||||
raise RuntimeError('Connection Failure : ' + str(err))
|
||||
self.headers = {'Content-type': 'application/x-www-form-urlencoded','Accept': 'text/plain'}
|
||||
self.headers = {'Content-type': 'application/x-www-form-urlencoded', 'Accept': 'text/plain'}
|
||||
|
||||
def _send_post_request(self, path, data):
|
||||
data = str_to_bytes(data) if isinstance(data, str) else data
|
@@ -4,6 +4,7 @@
|
||||
|
||||
# Convenience functions for commonly used data type conversions
|
||||
|
||||
|
||||
def bytes_to_long(s: bytes) -> int:
|
||||
return int.from_bytes(s, 'big')
|
||||
|
@@ -1,9 +0,0 @@
|
||||
# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps
|
||||
|
||||
examples/provisioning/wifi_prov_mgr:
|
||||
disable:
|
||||
- if: SOC_WIFI_SUPPORTED != 1
|
||||
disable_test:
|
||||
- if: IDF_TARGET != "esp32"
|
||||
temporary: true
|
||||
reason: lack of runners
|
@@ -1,26 +0,0 @@
|
||||
# Provisioning Application Examples
|
||||
|
||||
This primarily consists of a single unified example wifi_prov_mgr
|
||||
|
||||
* wifi_prov_mgr
|
||||
Abstracts out most of the complexity of Wi-Fi provisioning and allows easy switching between the SoftAP (using HTTP) and BLE transports. It also demonstrates how applications can register and use additional custom data endpoints.
|
||||
|
||||
Provisioning applications are available for various platforms:
|
||||
|
||||
* Android:
|
||||
- [BLE Provisioning app on Play Store](https://play.google.com/store/apps/details?id=com.espressif.provble).
|
||||
- [SoftAP Provisioning app on Play Store](https://play.google.com/store/apps/details?id=com.espressif.provsoftap).
|
||||
- Source code on GitHub: [esp-idf-provisioning-android](https://github.com/espressif/esp-idf-provisioning-android).
|
||||
* iOS:
|
||||
- [BLE Provisioning app on app store](https://apps.apple.com/in/app/esp-ble-provisioning/id1473590141)
|
||||
- [SoftAP Provisioning app on app Store](https://apps.apple.com/in/app/esp-softap-provisioning/id1474040630)
|
||||
- Source code on GitHub: [esp-idf-provisioning-ios](https://github.com/espressif/esp-idf-provisioning-ios)
|
||||
* For all other platforms a python based command line tool is provided under "$IDF_PATH/tools/esp_prov"
|
||||
|
||||
The Android and iOS provisioning applications allow the user to configure the device manually or by scanning a QR code. QR codes can be generated by any online QR code generator. QR code payload is encoded with a JSON string containing the device name, proof-of-possession key (if used) and transport type (BLE or softAP), for example:
|
||||
|
||||
```
|
||||
{"ver":"v1","name":"PROV_000318","pop":"a1000318","transport":"softap"}
|
||||
```
|
||||
|
||||
The more details about QR code format, you can refer to [QR Code Scan](https://github.com/espressif/esp-idf-provisioning-android#qr-code-scan).
|
@@ -1,8 +0,0 @@
|
||||
# The following lines of boilerplate have to be in your project's CMakeLists
|
||||
# in this exact order for cmake to work correctly
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
# "Trim" the build. Include the minimal set of components, main, and anything it depends on.
|
||||
idf_build_set_property(MINIMAL_BUILD ON)
|
||||
project(wifi_prov_mgr)
|
@@ -1,461 +0,0 @@
|
||||
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-C61 | ESP32-S2 | ESP32-S3 |
|
||||
| ----------------- | ----- | -------- | -------- | -------- | -------- | --------- | -------- | -------- |
|
||||
|
||||
# Wi-Fi Provisioning Manager Example
|
||||
|
||||
(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.
|
||||
|
||||
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.
|
||||
|
||||
> 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.
|
||||
|
||||
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
|
||||
* `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.
|
||||
|
||||
> Note: If you use this example code in your own project, in BLE mode, then remember to enable the BT stack and BTDM BLE control settings in your SDK configuration (e.g. by using the `sdkconfig.defaults` file from this project).
|
||||
|
||||
## Transports
|
||||
|
||||
### SoftAP Transport
|
||||
- After successful provisioning, the SoftAP connection is not disconnected by default
|
||||
- Users can directly reconnect to the device for reprovisioning
|
||||
- It's the user's responsibility to manage connection memory and handle it according to application requirements
|
||||
- **HTTP**: `POST http://<server_name>:<port>/prov-ctrl`
|
||||
|
||||
### BLE Transport
|
||||
- By default, BT memory is released after successful provisioning
|
||||
- To keep BLE active after provisioning, enable `WIFI_PROV_KEEP_BLE_ON_AFTER_PROV` in menuconfig
|
||||
- This configuration ensures that BLE advertising is continued even after provisioning is completed.
|
||||
- For both SoftAP and BLE transports:
|
||||
- Enable `EXAMPLE_REPROVISIONING` in menuconfig to allow reprovisioning
|
||||
- Use the `esp_prov.py` tool for reprovisioning
|
||||
- Call `wifi_prov_mgr_disable_auto_stop()` API before initiating reprovisioning (already called in this example)
|
||||
- **BLE**: `GATT` characteristic for protocomm communication
|
||||
|
||||
**NOTE: The underlying transport (HTTP/BLE) must be kept enabled for external commands to be processed**.
|
||||
|
||||
## Reprovisioning
|
||||
|
||||
The example supports reprovisioning of Wi-Fi credentials through both SoftAP and BLE transports. Here are the key considerations for each transport:
|
||||
|
||||
### Commands
|
||||
|
||||
**Internal API**: `wifi_prov_mgr_reset_sm_state_for_reprovision()`
|
||||
- This API is can be called internally by the device firmware to reset WiFi credentials and restart provisioning mode.
|
||||
- For demonstration purposes, this API has been called directly in firmware code, In real-world scenarios following command based reprovisioning is preferred.
|
||||
|
||||
**External Command**:
|
||||
- **Endpoint**: `prov-ctrl`
|
||||
- **Command**: `TypeCmdCtrlReprov` (protobuf)
|
||||
- **Transport**: HTTP/BLE as configured
|
||||
- External clients (like Phone apps) can send this command via the transport layer to trigger the reprovisioning.
|
||||
|
||||
**Usage from esp_prov.py**:
|
||||
```bash
|
||||
python esp_prov.py --transport ble --service_name "PROV_DEVICE" --reprov
|
||||
```
|
||||
|
||||
### Use Cases for Reprovisioning
|
||||
|
||||
This flexibility is particularly useful when:
|
||||
- Network credentials need to be updated (password changes, SSID changes)
|
||||
- Device needs to connect to a different network environment
|
||||
- Troubleshooting connectivity issues requires fresh credential configuration
|
||||
- Moving devices between different locations with different network setups
|
||||
|
||||
For more details on the provisioning process and APIs, refer to the [Wi-Fi Provisioning Manager component documentation](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/provisioning/wifi_provisioning.html).
|
||||
|
||||
|
||||
## How to use example
|
||||
|
||||
### Hardware Required
|
||||
|
||||
Example should be able to run on any commonly available ESP32/ESP32-S2 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 install the dependency packages needed, please refer to the top level [README file](../../README.md#running-test-python-script-pytest).
|
||||
|
||||
`esp_prov` supports BLE and SoftAP transport for Linux, MacOS and Windows platforms. For BLE, however, if dependencies are not met, the script falls back to console mode and requires another application through which the communication can take place. 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.
|
||||
|
||||
### Configure the project
|
||||
|
||||
```
|
||||
idf.py menuconfig
|
||||
```
|
||||
* Set the BLE/Soft AP transport under "Example Configuration" options. ESP32-S2 will have only SoftAP option (SoftAP option cannot be used if IPv4 is disabled in lwIP)
|
||||
|
||||
### Build and Flash
|
||||
|
||||
Build the project and flash it to the board, then run monitor tool to view serial output:
|
||||
|
||||
```
|
||||
idf.py -p PORT flash monitor
|
||||
```
|
||||
|
||||
(To exit the serial monitor, type ``Ctrl-]``.)
|
||||
|
||||
See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.
|
||||
|
||||
## Example Output
|
||||
|
||||
```
|
||||
I (445) app: Starting provisioning
|
||||
I (1035) app: Provisioning started
|
||||
I (1045) wifi_prov_mgr: Provisioning started with service name : PROV_261FCC
|
||||
```
|
||||
|
||||
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 the protocomm security scheme 1 with PoP-based (proof-of-possession) authentication :
|
||||
|
||||
```
|
||||
python esp_prov.py --transport ble --service_name PROV_261FCC --sec_ver 1 --pop abcd1234 --ssid myssid --passphrase mypassword
|
||||
```
|
||||
|
||||
For security version 2, the following command can be used:
|
||||
```
|
||||
python esp_prov.py --transport ble --service_name PROV_261FCC --sec_ver 2 --sec2_username wifiprov --sec2_pwd abcd1234 --ssid myssid --passphrase mypassword
|
||||
```
|
||||
|
||||
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 (45335) esp_netif_handlers: 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 (52315) wifi_prov_mgr: Provisioning stopped
|
||||
.
|
||||
.
|
||||
.
|
||||
I (52355) app: Hello World!
|
||||
I (53355) app: Hello World!
|
||||
I (54355) app: Hello World!
|
||||
I (55355) app: Hello World!
|
||||
```
|
||||
|
||||
**Note:** For generating the credentials for security version 2 (`SRP6a` salt and verifier) for the device-side, the following example command can be used. The output can then directly be used in this example.
|
||||
|
||||
The config option `CONFIG_EXAMPLE_PROV_SEC2_DEV_MODE` should be enabled for the example and in `main/app_main.c`, the macro `EXAMPLE_PROV_SEC2_USERNAME` should be set to the same username used in the salt-verifier generation.
|
||||
|
||||
```log
|
||||
$ python esp_prov.py --transport softap --sec_ver 2 --sec2_gen_cred --sec2_username wifiprov --sec2_pwd abcd1234
|
||||
==== Salt-verifier for security scheme 2 (SRP6a) ====
|
||||
static const char sec2_salt[] = {
|
||||
0x03, 0x6e, 0xe0, 0xc7, 0xbc, 0xb9, 0xed, 0xa8, 0x4c, 0x9e, 0xac, 0x97, 0xd9, 0x3d, 0xec, 0xf4
|
||||
};
|
||||
|
||||
static const char sec2_verifier[] = {
|
||||
0x7c, 0x7c, 0x85, 0x47, 0x65, 0x08, 0x94, 0x6d, 0xd6, 0x36, 0xaf, 0x37, 0xd7, 0xe8, 0x91, 0x43,
|
||||
0x78, 0xcf, 0xfd, 0x61, 0x6c, 0x59, 0xd2, 0xf8, 0x39, 0x08, 0x12, 0x72, 0x38, 0xde, 0x9e, 0x24,
|
||||
.
|
||||
.
|
||||
.
|
||||
0xe6, 0xf6, 0x53, 0xc8, 0x31, 0xa8, 0x78, 0xde, 0x50, 0x40, 0xf7, 0x62, 0xde, 0x36, 0xb2, 0xba
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
### QR Code Scanning
|
||||
|
||||
Enabling `CONFIG_EXAMPLE_PROV_SHOW_QR` will display a QR code on the serial terminal, which can be scanned from the ESP Provisioning phone apps to start the Wi-Fi provisioning process.
|
||||
|
||||
The monitor log should display something like this :
|
||||
|
||||
```
|
||||
I (1462) app: Provisioning started
|
||||
I (1472) app: Scan this QR code from the provisioning application for Provisioning.
|
||||
I (1472) QRCODE: Encoding below text with ECC LVL 0 & QR Code Version 10
|
||||
I (1482) QRCODE: {"ver":"v1","name":"PROV_EA69FC","pop":"abcd1234","transport":"ble"}
|
||||
GAP procedure initiated: advertise; disc_mode=2 adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=256 adv_itvl_max=256
|
||||
|
||||
█▀▀▀▀▀█ ▀▀▀█▄█ ▀▀▄ █▄ ▀ █▀▀▀▀▀█
|
||||
█ ███ █ ▀▄█ █▄ ▀▄█ ▄██ █ █ ███ █
|
||||
█ ▀▀▀ █ ▄▀█▀▄▀ ▀█▄▀ ██ █ ▀▀▀ █
|
||||
▀▀▀▀▀▀▀ █▄▀ █▄█▄█ ▀ █ █ ▀ ▀▀▀▀▀▀▀
|
||||
▀▀ ▀▀ ▀ ▀▄ ▀▄ ▄▀▀▀█ ▀▄ ▀ ▀▄▄ ▄▄▀
|
||||
███▄█▄▀ █▀ ▀▀▀▀▄▄█ █▀ █ ▄█▄█▀
|
||||
▀███▀ ▀▄▄██ ▄▄██▄ ▀▀▀▀ ▄▀█ ▀▄▄▀
|
||||
▄███ ▀██▀▀ ▄ ▄█▄▀▀█▄ ▀▄▀▄▄█ ▄
|
||||
▀█▀ █▄▀▀ ▀▀█▀▀ █▀▄▀▄▀ ▄█ ███▄ ██
|
||||
██▀█ ▀▄█ █▄▀▄███▀▄▀█ ▀█ █▀▀ ▀▄▄▀
|
||||
█▄▀▄█▀▀ ▀▄ ▀▄▄█▄▀▀█▄█▄█▀▀█ ▀▄ ▄▀
|
||||
█ ▄█▄ ▀ ▄▀ █▄ ▀█▄█▄▀▀█▀█ ▄█ ▀▄▄█
|
||||
▀▀▀▀ ▀ █▀█▀▀▄▄██▄█▀█ ▀██▀▀▀█▄▄▀
|
||||
█▀▀▀▀▀█ ▄█▀▀▀██ ▄▀▄ █▄█ ▀ █ ▄ ▄
|
||||
█ ███ █ █ ▀▄█▀▀█▀▄█▄▄ ▀██▀▀▀▀▄▄▀▀
|
||||
█ ▀▀▀ █ ▄█ ▀ ▄█▀█ █▀ ▀▀███▄▀█ █▄█
|
||||
▀▀▀▀▀▀▀ ▀ ▀ ▀▀ ▀ ▀▀▀▀▀▀
|
||||
|
||||
|
||||
I (1702) app: If QR code is not visible, copy paste the below URL in a browser.
|
||||
https://espressif.github.io/esp-jumpstart/qrcode.html?data={"ver":"v1","name":"PROV_EA69FC","pop":"abcd1234","transport":"ble"}
|
||||
```
|
||||
|
||||
|
||||
### 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:
|
||||
|
||||
```
|
||||
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 Credentials to Target ====
|
||||
==== Wi-Fi Credentials sent successfully ====
|
||||
|
||||
==== Applying Wi-Fi Config to Target ====
|
||||
==== Apply config sent successfully ====
|
||||
|
||||
==== Wi-Fi connection state ====
|
||||
==== WiFi state: Connected ====
|
||||
==== Provisioning was successful ====
|
||||
```
|
||||
|
||||
### Interactive Provisioning
|
||||
|
||||
`esp_prov` supports interactive provisioning. You can trigger the script with a simplified command and input the necessary details
|
||||
(`Proof-of-possession` for security scheme 1 and `SRP6a username`, `SRP6a password` for security scheme 2) as the provisioning process advances.
|
||||
|
||||
The command `python esp_prov.py --transport ble --sec_ver 1` gives out the following sample output:
|
||||
|
||||
```
|
||||
Discovering...
|
||||
==== BLE Discovery results ====
|
||||
S.N. Name Address
|
||||
[ 1] PROV_4C33E8 01:02:03:04:05:06
|
||||
[ 1] BT_DEVICE_SBC 0A:0B:0C:0D:0E:0F
|
||||
Select device by number (0 to rescan) : 1
|
||||
Connecting...
|
||||
Getting Services...
|
||||
Proof of Possession required:
|
||||
|
||||
==== Starting Session ====
|
||||
==== Session Established ====
|
||||
|
||||
==== Scanning Wi-Fi APs ====
|
||||
++++ Scan process executed in 3.8695244789123535 sec
|
||||
++++ Scan results : 2
|
||||
|
||||
++++ Scan finished in 4.4132080078125 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
|
||||
|
||||
Select AP by number (0 to rescan) : 1
|
||||
Enter passphrase for myssid :
|
||||
|
||||
==== Sending Wi-Fi Credentials to Target ====
|
||||
==== Wi-Fi Credentials sent successfully ====
|
||||
|
||||
==== Applying Wi-Fi Config to Target ====
|
||||
==== 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 <MyCustomData>` option to the esp\_prov tool. Following output is
|
||||
expected on success:
|
||||
|
||||
```
|
||||
==== Sending Custom data to esp32 ====
|
||||
CustomData response: SUCCESS
|
||||
```
|
||||
|
||||
## 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 :
|
||||
|
||||
```
|
||||
E (367015) app: Provisioning failed!
|
||||
Reason : Wi-Fi AP password incorrect
|
||||
Please reset to factory and retry provisioning
|
||||
```
|
||||
|
||||
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 :
|
||||
|
||||
```
|
||||
I (465) app: Already provisioned, starting Wi-Fi STA
|
||||
```
|
||||
|
||||
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 :
|
||||
|
||||
```
|
||||
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
|
||||
```
|
||||
|
||||
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
|
||||
```
|
||||
|
||||
### Bluetooth Pairing Request during provisioning
|
||||
|
||||
ESP-IDF now has functionality to enforce link encryption requirement while performing GATT write on characteristics of provisioning service. This will however result in a pairing pop-up dialog, if link is not encrypted. This feature is disabled by default. In order to enable this feature, please set `CONFIG_WIFI_PROV_BLE_FORCE_ENCRYPTION=y` in the sdkconfig or select the configuration using "idf.py menuconfig" .
|
||||
|
||||
```
|
||||
Component Config --> Wi-Fi Provisioning Manager --> Force Link Encryption during Characteristic Read/Write
|
||||
|
||||
```
|
||||
Recompiling the application with above changes should suffice to enable this functionality.
|
||||
|
||||
|
||||
### 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.
|
@@ -1,3 +0,0 @@
|
||||
idf_component_register(SRCS "app_main.c"
|
||||
PRIV_REQUIRES esp_wifi nvs_flash wifi_provisioning
|
||||
INCLUDE_DIRS ".")
|
@@ -1,114 +0,0 @@
|
||||
menu "Example Configuration"
|
||||
|
||||
choice EXAMPLE_PROV_TRANSPORT
|
||||
bool "Provisioning Transport"
|
||||
default EXAMPLE_PROV_TRANSPORT_SOFTAP if IDF_TARGET_ESP32S2
|
||||
default EXAMPLE_PROV_TRANSPORT_BLE
|
||||
help
|
||||
Wi-Fi provisioning component offers both, SoftAP and BLE transports. Choose any one.
|
||||
|
||||
config EXAMPLE_PROV_TRANSPORT_BLE
|
||||
bool "BLE"
|
||||
select BT_ENABLED
|
||||
depends on !IDF_TARGET_ESP32S2
|
||||
config EXAMPLE_PROV_TRANSPORT_SOFTAP
|
||||
bool "Soft AP"
|
||||
select LWIP_IPV4
|
||||
endchoice
|
||||
|
||||
choice EXAMPLE_PROV_SECURITY_VERSION
|
||||
bool "Protocomm security version"
|
||||
default EXAMPLE_PROV_SECURITY_VERSION_2
|
||||
help
|
||||
Wi-Fi provisioning component offers 3 security versions.
|
||||
The example offers a choice between security version 1 and 2.
|
||||
|
||||
config EXAMPLE_PROV_SECURITY_VERSION_1
|
||||
bool "Security version 1"
|
||||
select ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_1
|
||||
|
||||
config EXAMPLE_PROV_SECURITY_VERSION_2
|
||||
bool "Security version 2"
|
||||
select ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_2
|
||||
endchoice
|
||||
|
||||
choice EXAMPLE_PROV_MODE
|
||||
bool "Security version 2 mode"
|
||||
depends on EXAMPLE_PROV_SECURITY_VERSION_2
|
||||
default EXAMPLE_PROV_SEC2_DEV_MODE
|
||||
|
||||
config EXAMPLE_PROV_SEC2_DEV_MODE
|
||||
bool "Security version 2 development mode"
|
||||
depends on EXAMPLE_PROV_SECURITY_VERSION_2
|
||||
help
|
||||
This enables the development mode for
|
||||
security version 2.
|
||||
Please note that this mode is NOT recommended for production purpose.
|
||||
|
||||
config EXAMPLE_PROV_SEC2_PROD_MODE
|
||||
bool "Security version 2 production mode"
|
||||
depends on EXAMPLE_PROV_SECURITY_VERSION_2
|
||||
help
|
||||
This enables the production mode for
|
||||
security version 2.
|
||||
endchoice
|
||||
|
||||
config EXAMPLE_PROV_TRANSPORT
|
||||
int
|
||||
default 1 if EXAMPLE_PROV_TRANSPORT_BLE
|
||||
default 2 if EXAMPLE_PROV_TRANSPORT_SOFTAP
|
||||
|
||||
config EXAMPLE_PROV_ENABLE_APP_CALLBACK
|
||||
bool "Enable provisioning manager app callback"
|
||||
default n
|
||||
help
|
||||
This is for advanced use-cases like modifying Wi-Fi configuration parameters. This
|
||||
executes a blocking app callback when any provisioning event is triggered.
|
||||
|
||||
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_RESET_PROV_MGR_ON_FAILURE
|
||||
bool
|
||||
default y
|
||||
prompt "Reset provisioned credentials and state machine after session failure"
|
||||
help
|
||||
Enable resetting provisioned credentials and state machine after session failure.
|
||||
This will restart the provisioning service after retries are exhausted.
|
||||
|
||||
config EXAMPLE_PROV_MGR_CONNECTION_CNT
|
||||
int
|
||||
default 5
|
||||
prompt "Max connection attempts before resetting provisioning state machine"
|
||||
depends on EXAMPLE_RESET_PROV_MGR_ON_FAILURE
|
||||
help
|
||||
Set the total number of connection attempts to avoid reconnecting to an inexistent AP or if credentials
|
||||
are misconfigured. Provisioned credentials are erased and internal state machine
|
||||
is reset after this threshold is reached.
|
||||
|
||||
config EXAMPLE_PROV_SHOW_QR
|
||||
bool "Show provisioning QR code"
|
||||
default y
|
||||
help
|
||||
Show the QR code for provisioning.
|
||||
|
||||
config EXAMPLE_PROV_USING_BLUEDROID
|
||||
bool
|
||||
depends on (BT_BLUEDROID_ENABLED && (IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32S3))
|
||||
select BT_BLE_42_FEATURES_SUPPORTED
|
||||
default y
|
||||
help
|
||||
This enables BLE 4.2 features for Bluedroid.
|
||||
|
||||
config EXAMPLE_REPROVISIONING
|
||||
bool "Re-provisioning"
|
||||
help
|
||||
Enable re-provisioning - allow the device to provision for new credentials
|
||||
after previous successful provisioning.
|
||||
|
||||
endmenu
|
@@ -1,563 +0,0 @@
|
||||
/* Wi-Fi Provisioning Manager 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 <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/task.h>
|
||||
#include <freertos/event_groups.h>
|
||||
|
||||
#include <esp_log.h>
|
||||
#include <esp_wifi.h>
|
||||
#include <esp_event.h>
|
||||
#include <nvs_flash.h>
|
||||
|
||||
#include <wifi_provisioning/manager.h>
|
||||
|
||||
#ifdef CONFIG_EXAMPLE_PROV_TRANSPORT_BLE
|
||||
#include <wifi_provisioning/scheme_ble.h>
|
||||
#endif /* CONFIG_EXAMPLE_PROV_TRANSPORT_BLE */
|
||||
|
||||
#ifdef CONFIG_EXAMPLE_PROV_TRANSPORT_SOFTAP
|
||||
#include <wifi_provisioning/scheme_softap.h>
|
||||
#endif /* CONFIG_EXAMPLE_PROV_TRANSPORT_SOFTAP */
|
||||
#include "qrcode.h"
|
||||
|
||||
static const char *TAG = "app";
|
||||
|
||||
#if CONFIG_EXAMPLE_PROV_SECURITY_VERSION_2
|
||||
#if CONFIG_EXAMPLE_PROV_SEC2_DEV_MODE
|
||||
#define EXAMPLE_PROV_SEC2_USERNAME "wifiprov"
|
||||
#define EXAMPLE_PROV_SEC2_PWD "abcd1234"
|
||||
|
||||
/* This salt,verifier has been generated for username = "wifiprov" and password = "abcd1234"
|
||||
* IMPORTANT NOTE: For production cases, this must be unique to every device
|
||||
* and should come from device manufacturing partition.*/
|
||||
static const char sec2_salt[] = {
|
||||
0x03, 0x6e, 0xe0, 0xc7, 0xbc, 0xb9, 0xed, 0xa8, 0x4c, 0x9e, 0xac, 0x97, 0xd9, 0x3d, 0xec, 0xf4
|
||||
};
|
||||
|
||||
static const char sec2_verifier[] = {
|
||||
0x7c, 0x7c, 0x85, 0x47, 0x65, 0x08, 0x94, 0x6d, 0xd6, 0x36, 0xaf, 0x37, 0xd7, 0xe8, 0x91, 0x43,
|
||||
0x78, 0xcf, 0xfd, 0x61, 0x6c, 0x59, 0xd2, 0xf8, 0x39, 0x08, 0x12, 0x72, 0x38, 0xde, 0x9e, 0x24,
|
||||
0xa4, 0x70, 0x26, 0x1c, 0xdf, 0xa9, 0x03, 0xc2, 0xb2, 0x70, 0xe7, 0xb1, 0x32, 0x24, 0xda, 0x11,
|
||||
0x1d, 0x97, 0x18, 0xdc, 0x60, 0x72, 0x08, 0xcc, 0x9a, 0xc9, 0x0c, 0x48, 0x27, 0xe2, 0xae, 0x89,
|
||||
0xaa, 0x16, 0x25, 0xb8, 0x04, 0xd2, 0x1a, 0x9b, 0x3a, 0x8f, 0x37, 0xf6, 0xe4, 0x3a, 0x71, 0x2e,
|
||||
0xe1, 0x27, 0x86, 0x6e, 0xad, 0xce, 0x28, 0xff, 0x54, 0x46, 0x60, 0x1f, 0xb9, 0x96, 0x87, 0xdc,
|
||||
0x57, 0x40, 0xa7, 0xd4, 0x6c, 0xc9, 0x77, 0x54, 0xdc, 0x16, 0x82, 0xf0, 0xed, 0x35, 0x6a, 0xc4,
|
||||
0x70, 0xad, 0x3d, 0x90, 0xb5, 0x81, 0x94, 0x70, 0xd7, 0xbc, 0x65, 0xb2, 0xd5, 0x18, 0xe0, 0x2e,
|
||||
0xc3, 0xa5, 0xf9, 0x68, 0xdd, 0x64, 0x7b, 0xb8, 0xb7, 0x3c, 0x9c, 0xfc, 0x00, 0xd8, 0x71, 0x7e,
|
||||
0xb7, 0x9a, 0x7c, 0xb1, 0xb7, 0xc2, 0xc3, 0x18, 0x34, 0x29, 0x32, 0x43, 0x3e, 0x00, 0x99, 0xe9,
|
||||
0x82, 0x94, 0xe3, 0xd8, 0x2a, 0xb0, 0x96, 0x29, 0xb7, 0xdf, 0x0e, 0x5f, 0x08, 0x33, 0x40, 0x76,
|
||||
0x52, 0x91, 0x32, 0x00, 0x9f, 0x97, 0x2c, 0x89, 0x6c, 0x39, 0x1e, 0xc8, 0x28, 0x05, 0x44, 0x17,
|
||||
0x3f, 0x68, 0x02, 0x8a, 0x9f, 0x44, 0x61, 0xd1, 0xf5, 0xa1, 0x7e, 0x5a, 0x70, 0xd2, 0xc7, 0x23,
|
||||
0x81, 0xcb, 0x38, 0x68, 0xe4, 0x2c, 0x20, 0xbc, 0x40, 0x57, 0x76, 0x17, 0xbd, 0x08, 0xb8, 0x96,
|
||||
0xbc, 0x26, 0xeb, 0x32, 0x46, 0x69, 0x35, 0x05, 0x8c, 0x15, 0x70, 0xd9, 0x1b, 0xe9, 0xbe, 0xcc,
|
||||
0xa9, 0x38, 0xa6, 0x67, 0xf0, 0xad, 0x50, 0x13, 0x19, 0x72, 0x64, 0xbf, 0x52, 0xc2, 0x34, 0xe2,
|
||||
0x1b, 0x11, 0x79, 0x74, 0x72, 0xbd, 0x34, 0x5b, 0xb1, 0xe2, 0xfd, 0x66, 0x73, 0xfe, 0x71, 0x64,
|
||||
0x74, 0xd0, 0x4e, 0xbc, 0x51, 0x24, 0x19, 0x40, 0x87, 0x0e, 0x92, 0x40, 0xe6, 0x21, 0xe7, 0x2d,
|
||||
0x4e, 0x37, 0x76, 0x2f, 0x2e, 0xe2, 0x68, 0xc7, 0x89, 0xe8, 0x32, 0x13, 0x42, 0x06, 0x84, 0x84,
|
||||
0x53, 0x4a, 0xb3, 0x0c, 0x1b, 0x4c, 0x8d, 0x1c, 0x51, 0x97, 0x19, 0xab, 0xae, 0x77, 0xff, 0xdb,
|
||||
0xec, 0xf0, 0x10, 0x95, 0x34, 0x33, 0x6b, 0xcb, 0x3e, 0x84, 0x0f, 0xb9, 0xd8, 0x5f, 0xb8, 0xa0,
|
||||
0xb8, 0x55, 0x53, 0x3e, 0x70, 0xf7, 0x18, 0xf5, 0xce, 0x7b, 0x4e, 0xbf, 0x27, 0xce, 0xce, 0xa8,
|
||||
0xb3, 0xbe, 0x40, 0xc5, 0xc5, 0x32, 0x29, 0x3e, 0x71, 0x64, 0x9e, 0xde, 0x8c, 0xf6, 0x75, 0xa1,
|
||||
0xe6, 0xf6, 0x53, 0xc8, 0x31, 0xa8, 0x78, 0xde, 0x50, 0x40, 0xf7, 0x62, 0xde, 0x36, 0xb2, 0xba
|
||||
};
|
||||
#endif
|
||||
|
||||
static esp_err_t example_get_sec2_salt(const char **salt, uint16_t *salt_len) {
|
||||
#if CONFIG_EXAMPLE_PROV_SEC2_DEV_MODE
|
||||
ESP_LOGI(TAG, "Development mode: using hard coded salt");
|
||||
*salt = sec2_salt;
|
||||
*salt_len = sizeof(sec2_salt);
|
||||
return ESP_OK;
|
||||
#elif CONFIG_EXAMPLE_PROV_SEC2_PROD_MODE
|
||||
ESP_LOGE(TAG, "Not implemented!");
|
||||
return ESP_FAIL;
|
||||
#endif
|
||||
}
|
||||
|
||||
static esp_err_t example_get_sec2_verifier(const char **verifier, uint16_t *verifier_len) {
|
||||
#if CONFIG_EXAMPLE_PROV_SEC2_DEV_MODE
|
||||
ESP_LOGI(TAG, "Development mode: using hard coded verifier");
|
||||
*verifier = sec2_verifier;
|
||||
*verifier_len = sizeof(sec2_verifier);
|
||||
return ESP_OK;
|
||||
#elif CONFIG_EXAMPLE_PROV_SEC2_PROD_MODE
|
||||
/* This code needs to be updated with appropriate implementation to provide verifier */
|
||||
ESP_LOGE(TAG, "Not implemented!");
|
||||
return ESP_FAIL;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Signal Wi-Fi events on this event-group */
|
||||
const int WIFI_CONNECTED_EVENT = BIT0;
|
||||
static EventGroupHandle_t wifi_event_group;
|
||||
|
||||
#define PROV_QR_VERSION "v1"
|
||||
#define PROV_TRANSPORT_SOFTAP "softap"
|
||||
#define PROV_TRANSPORT_BLE "ble"
|
||||
#define QRCODE_BASE_URL "https://espressif.github.io/esp-jumpstart/qrcode.html"
|
||||
|
||||
/* 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");
|
||||
#ifdef CONFIG_EXAMPLE_RESET_PROV_MGR_ON_FAILURE
|
||||
/* Reset the state machine on provisioning failure.
|
||||
* This is enabled by the CONFIG_EXAMPLE_RESET_PROV_MGR_ON_FAILURE configuration.
|
||||
* It allows the provisioning manager to retry the provisioning process
|
||||
* based on the number of attempts specified in wifi_conn_attempts. After attempting
|
||||
* the maximum number of retries, the provisioning manager will reset the state machine
|
||||
* and the provisioning process will be terminated.
|
||||
*/
|
||||
wifi_prov_mgr_reset_sm_state_on_failure();
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case WIFI_PROV_CRED_SUCCESS:
|
||||
ESP_LOGI(TAG, "Provisioning successful");
|
||||
break;
|
||||
case WIFI_PROV_END:
|
||||
/* De-initialize manager once provisioning is finished */
|
||||
esp_err_t err = wifi_prov_mgr_deinit();
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to de-initialize provisioning manager: %s", esp_err_to_name(err));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if (event_base == WIFI_EVENT) {
|
||||
switch (event_id) {
|
||||
case WIFI_EVENT_STA_START:
|
||||
esp_wifi_connect();
|
||||
break;
|
||||
case WIFI_EVENT_STA_DISCONNECTED:
|
||||
ESP_LOGI(TAG, "Disconnected. Connecting to the AP again...");
|
||||
esp_wifi_connect();
|
||||
break;
|
||||
#ifdef CONFIG_EXAMPLE_PROV_TRANSPORT_SOFTAP
|
||||
case WIFI_EVENT_AP_STACONNECTED:
|
||||
ESP_LOGI(TAG, "SoftAP transport: Connected!");
|
||||
break;
|
||||
case WIFI_EVENT_AP_STADISCONNECTED:
|
||||
ESP_LOGI(TAG, "SoftAP transport: Disconnected!");
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} 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);
|
||||
#ifdef CONFIG_EXAMPLE_PROV_TRANSPORT_BLE
|
||||
} else if (event_base == PROTOCOMM_TRANSPORT_BLE_EVENT) {
|
||||
switch (event_id) {
|
||||
case PROTOCOMM_TRANSPORT_BLE_CONNECTED:
|
||||
ESP_LOGI(TAG, "BLE transport: Connected!");
|
||||
break;
|
||||
case PROTOCOMM_TRANSPORT_BLE_DISCONNECTED:
|
||||
ESP_LOGI(TAG, "BLE transport: Disconnected!");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
} else if (event_base == PROTOCOMM_SECURITY_SESSION_EVENT) {
|
||||
switch (event_id) {
|
||||
case PROTOCOMM_SECURITY_SESSION_SETUP_OK:
|
||||
ESP_LOGI(TAG, "Secured session established!");
|
||||
break;
|
||||
case PROTOCOMM_SECURITY_SESSION_INVALID_SECURITY_PARAMS:
|
||||
ESP_LOGE(TAG, "Received invalid security parameters for establishing secure session!");
|
||||
break;
|
||||
case PROTOCOMM_SECURITY_SESSION_CREDENTIALS_MISMATCH:
|
||||
ESP_LOGE(TAG, "Received incorrect username and/or PoP for establishing secure session!");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void wifi_init_sta(void)
|
||||
{
|
||||
/* Start Wi-Fi in station mode */
|
||||
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)
|
||||
{
|
||||
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]);
|
||||
}
|
||||
|
||||
/* 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.
|
||||
* Note that memory for the response buffer must be allocated using heap as this buffer
|
||||
* gets freed by the protocomm layer once it has been sent by the transport layer.
|
||||
*/
|
||||
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 */
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static void wifi_prov_print_qr(const char *name, const char *username, const char *pop, const char *transport)
|
||||
{
|
||||
if (!name || !transport) {
|
||||
ESP_LOGW(TAG, "Cannot generate QR code payload. Data missing.");
|
||||
return;
|
||||
}
|
||||
char payload[150] = {0};
|
||||
if (pop) {
|
||||
#if CONFIG_EXAMPLE_PROV_SECURITY_VERSION_1
|
||||
snprintf(payload, sizeof(payload), "{\"ver\":\"%s\",\"name\":\"%s\"" \
|
||||
",\"pop\":\"%s\",\"transport\":\"%s\"}",
|
||||
PROV_QR_VERSION, name, pop, transport);
|
||||
#elif CONFIG_EXAMPLE_PROV_SECURITY_VERSION_2
|
||||
snprintf(payload, sizeof(payload), "{\"ver\":\"%s\",\"name\":\"%s\"" \
|
||||
",\"username\":\"%s\",\"pop\":\"%s\",\"transport\":\"%s\"}",
|
||||
PROV_QR_VERSION, name, username, pop, transport);
|
||||
#endif
|
||||
} else {
|
||||
snprintf(payload, sizeof(payload), "{\"ver\":\"%s\",\"name\":\"%s\"" \
|
||||
",\"transport\":\"%s\"}",
|
||||
PROV_QR_VERSION, name, transport);
|
||||
}
|
||||
#ifdef CONFIG_EXAMPLE_PROV_SHOW_QR
|
||||
ESP_LOGI(TAG, "Scan this QR code from the provisioning application for Provisioning.");
|
||||
esp_qrcode_config_t cfg = ESP_QRCODE_CONFIG_DEFAULT();
|
||||
esp_qrcode_generate(&cfg, payload);
|
||||
#endif /* CONFIG_APP_WIFI_PROV_SHOW_QR */
|
||||
ESP_LOGI(TAG, "If QR code is not visible, copy paste the below URL in a browser.\n%s?data=%s", QRCODE_BASE_URL, payload);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_EXAMPLE_PROV_ENABLE_APP_CALLBACK
|
||||
void wifi_prov_app_callback(void *user_data, wifi_prov_cb_event_t event, void *event_data)
|
||||
{
|
||||
/**
|
||||
* This is blocking callback, any configurations that needs to be set when a particular
|
||||
* provisioning event is triggered can be set here.
|
||||
*/
|
||||
switch (event) {
|
||||
case WIFI_PROV_SET_STA_CONFIG: {
|
||||
/**
|
||||
* Wi-Fi configurations can be set here before the Wi-Fi is enabled in
|
||||
* STA mode.
|
||||
*/
|
||||
wifi_config_t *wifi_config = (wifi_config_t*)event_data;
|
||||
(void) wifi_config;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const wifi_prov_event_handler_t wifi_prov_event_handler = {
|
||||
.event_cb = wifi_prov_app_callback,
|
||||
.user_data = NULL,
|
||||
};
|
||||
#endif /* EXAMPLE_PROV_ENABLE_APP_CALLBACK */
|
||||
|
||||
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 */
|
||||
ESP_ERROR_CHECK(esp_netif_init());
|
||||
|
||||
/* Initialize the event loop */
|
||||
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));
|
||||
#ifdef CONFIG_EXAMPLE_PROV_TRANSPORT_BLE
|
||||
ESP_ERROR_CHECK(esp_event_handler_register(PROTOCOMM_TRANSPORT_BLE_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL));
|
||||
#endif
|
||||
ESP_ERROR_CHECK(esp_event_handler_register(PROTOCOMM_SECURITY_SESSION_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 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 = {
|
||||
#ifdef CONFIG_EXAMPLE_RESET_PROV_MGR_ON_FAILURE
|
||||
.wifi_prov_conn_cfg = {
|
||||
.wifi_conn_attempts = CONFIG_EXAMPLE_PROV_MGR_CONNECTION_CNT,
|
||||
},
|
||||
#endif
|
||||
/* 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 */
|
||||
#ifdef CONFIG_EXAMPLE_PROV_ENABLE_APP_CALLBACK
|
||||
.app_event_handler = wifi_prov_event_handler,
|
||||
#endif /* EXAMPLE_PROV_ENABLE_APP_CALLBACK */
|
||||
|
||||
/* 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;
|
||||
#ifdef CONFIG_EXAMPLE_RESET_PROVISIONED
|
||||
wifi_prov_mgr_reset_provisioning();
|
||||
#else
|
||||
/* Let's find out if the device is provisioned */
|
||||
ESP_ERROR_CHECK(wifi_prov_mgr_is_provisioned(&provisioned));
|
||||
|
||||
#endif
|
||||
/* 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));
|
||||
|
||||
#ifdef CONFIG_EXAMPLE_PROV_SECURITY_VERSION_1
|
||||
/* What is the security level that we want (0, 1, 2):
|
||||
* - 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_2 SRP6a based authentication and key exchange
|
||||
* + AES-GCM 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";
|
||||
|
||||
/* This is the structure for passing security parameters
|
||||
* for the protocomm security 1.
|
||||
*/
|
||||
wifi_prov_security1_params_t *sec_params = pop;
|
||||
|
||||
const char *username = NULL;
|
||||
|
||||
#elif CONFIG_EXAMPLE_PROV_SECURITY_VERSION_2
|
||||
wifi_prov_security_t security = WIFI_PROV_SECURITY_2;
|
||||
/* The username must be the same one, which has been used in the generation of salt and verifier */
|
||||
|
||||
#if CONFIG_EXAMPLE_PROV_SEC2_DEV_MODE
|
||||
/* This pop field represents the password that will be used to generate salt and verifier.
|
||||
* The field is present here in order to generate the QR code containing password.
|
||||
* In production this password field shall not be stored on the device */
|
||||
const char *username = EXAMPLE_PROV_SEC2_USERNAME;
|
||||
const char *pop = EXAMPLE_PROV_SEC2_PWD;
|
||||
#elif CONFIG_EXAMPLE_PROV_SEC2_PROD_MODE
|
||||
/* The username and password shall not be embedded in the firmware,
|
||||
* they should be provided to the user by other means.
|
||||
* e.g. QR code sticker */
|
||||
const char *username = NULL;
|
||||
const char *pop = NULL;
|
||||
#endif
|
||||
/* This is the structure for passing security parameters
|
||||
* for the protocomm security 2.
|
||||
* If dynamically allocated, sec2_params pointer and its content
|
||||
* must be valid till WIFI_PROV_END event is triggered.
|
||||
*/
|
||||
wifi_prov_security2_params_t sec2_params = {};
|
||||
|
||||
ESP_ERROR_CHECK(example_get_sec2_salt(&sec2_params.salt, &sec2_params.salt_len));
|
||||
ESP_ERROR_CHECK(example_get_sec2_verifier(&sec2_params.verifier, &sec2_params.verifier_len));
|
||||
|
||||
wifi_prov_security2_params_t *sec_params = &sec2_params;
|
||||
#endif
|
||||
/* What is the service key (could be NULL)
|
||||
* This translates to :
|
||||
* - Wi-Fi password when scheme is wifi_prov_scheme_softap
|
||||
* (Minimum expected length: 8, maximum 64 for WPA2-PSK)
|
||||
* - 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,
|
||||
};
|
||||
|
||||
/* If your build fails with linker errors at this point, then you may have
|
||||
* forgotten to enable the BT stack or BTDM BLE settings in the SDK (e.g. see
|
||||
* the sdkconfig.defaults in the example project) */
|
||||
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");
|
||||
|
||||
/* Do not stop and de-init provisioning even after success,
|
||||
* so that we can restart it later. */
|
||||
#ifdef CONFIG_EXAMPLE_REPROVISIONING
|
||||
wifi_prov_mgr_disable_auto_stop(1000);
|
||||
#endif
|
||||
/* Start provisioning service */
|
||||
ESP_ERROR_CHECK(wifi_prov_mgr_start_provisioning(security, (const void *) sec_params, 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.
|
||||
*/
|
||||
wifi_prov_mgr_endpoint_register("custom-data", custom_prov_data_handler, NULL);
|
||||
|
||||
/* 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();
|
||||
/* Print QR code for provisioning */
|
||||
#ifdef CONFIG_EXAMPLE_PROV_TRANSPORT_BLE
|
||||
wifi_prov_print_qr(service_name, username, pop, PROV_TRANSPORT_BLE);
|
||||
#else /* CONFIG_EXAMPLE_PROV_TRANSPORT_SOFTAP */
|
||||
wifi_prov_print_qr(service_name, username, pop, PROV_TRANSPORT_SOFTAP);
|
||||
#endif /* CONFIG_EXAMPLE_PROV_TRANSPORT_BLE */
|
||||
} 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 */
|
||||
ESP_ERROR_CHECK(wifi_prov_mgr_deinit());
|
||||
|
||||
ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL));
|
||||
/* Start Wi-Fi station */
|
||||
wifi_init_sta();
|
||||
}
|
||||
|
||||
/* Wait for Wi-Fi connection */
|
||||
xEventGroupWaitBits(wifi_event_group, WIFI_CONNECTED_EVENT, true, true, portMAX_DELAY);
|
||||
|
||||
/* Start main application now */
|
||||
#if CONFIG_EXAMPLE_REPROVISIONING
|
||||
while (1) {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
ESP_LOGI(TAG, "Hello World!");
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
}
|
||||
|
||||
/* Resetting provisioning state machine to enable re-provisioning */
|
||||
/* NOTE: This API is used only for demonstration purposes in this example.
|
||||
* In real-world firmware applications, you should NOT call this API directly.
|
||||
* Instead, the external provisioning entity should trigger reprovisioning by sending
|
||||
* a command through the provisioning control endpoint, which will internally
|
||||
* trigger same behaviour to reset the provisioning state.
|
||||
*/
|
||||
wifi_prov_mgr_reset_sm_state_for_reprovision();
|
||||
|
||||
/* Wait for Wi-Fi connection */
|
||||
xEventGroupWaitBits(wifi_event_group, WIFI_CONNECTED_EVENT, true, true, portMAX_DELAY);
|
||||
}
|
||||
#else
|
||||
while (1) {
|
||||
ESP_LOGI(TAG, "Hello World!");
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
@@ -1,2 +0,0 @@
|
||||
dependencies:
|
||||
qrcode: "^0.1.0"
|
@@ -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, , 0x6000,
|
||||
phy_init, data, phy, , 0x1000,
|
||||
factory, app, factory, , 0x150000,
|
|
@@ -1,111 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2018-2025 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
from pytest_embedded_idf.utils import idf_parametrize
|
||||
|
||||
try:
|
||||
import esp_prov
|
||||
except ImportError:
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'tools'))
|
||||
import esp_prov
|
||||
|
||||
import pytest
|
||||
from pytest_embedded import Dut
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
|
||||
# Have esp_prov throw exception
|
||||
esp_prov.config_throw_except = True
|
||||
|
||||
|
||||
def test_wifi_prov_mgr(dut: Dut, sec_ver: int) -> None:
|
||||
# Check if BT memory is released before provisioning starts
|
||||
dut.expect('wifi_prov_scheme_ble: BT memory released', timeout=60)
|
||||
|
||||
# Parse BLE devname
|
||||
devname = dut.expect(b'Provisioning started with service name : PROV_(.{6})')[0].decode('utf-8').split(' : ')[1]
|
||||
logging.info('BLE Device Alias for DUT : {}'.format(devname))
|
||||
|
||||
logging.info('Starting Provisioning')
|
||||
verbose = False
|
||||
protover = 'v1.1'
|
||||
provmode = 'ble'
|
||||
ap_ssid = 'myssid'
|
||||
ap_password = 'mypassword'
|
||||
|
||||
logging.info('Getting security')
|
||||
if sec_ver == 1:
|
||||
pop = 'abcd1234'
|
||||
sec2_username = None
|
||||
sec2_password = None
|
||||
security = esp_prov.get_security(sec_ver, sec2_username, sec2_password, pop, verbose)
|
||||
elif sec_ver == 2:
|
||||
pop = None
|
||||
sec2_username = 'wifiprov'
|
||||
sec2_password = 'abcd1234'
|
||||
security = esp_prov.get_security(sec_ver, sec2_username, sec2_password, pop, verbose)
|
||||
|
||||
if security is None:
|
||||
raise RuntimeError('Failed to get security')
|
||||
|
||||
logging.info('Getting transport')
|
||||
transport = esp_prov.get_transport(provmode, devname)
|
||||
if transport is None:
|
||||
raise RuntimeError('Failed to get transport')
|
||||
|
||||
logging.info('Verifying protocol version')
|
||||
if not esp_prov.version_match(transport, protover):
|
||||
raise RuntimeError('Mismatch in protocol version')
|
||||
|
||||
logging.info('Verifying scan list capability')
|
||||
if not esp_prov.has_capability(transport, 'wifi_scan'):
|
||||
raise RuntimeError('Capability not present')
|
||||
|
||||
logging.info('Starting Session')
|
||||
if not esp_prov.establish_session(transport, security):
|
||||
raise RuntimeError('Failed to start session')
|
||||
|
||||
logging.info('Sending Custom Data')
|
||||
if not esp_prov.custom_data(transport, security, 'My Custom Data'):
|
||||
raise RuntimeError('Failed to send custom data')
|
||||
|
||||
logging.info('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')
|
||||
|
||||
logging.info('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
|
||||
dut.expect('wifi_prov_scheme_ble: BTDM memory released', timeout=30)
|
||||
|
||||
|
||||
@pytest.mark.generic
|
||||
@pytest.mark.parametrize(
|
||||
'config',
|
||||
[
|
||||
'security1',
|
||||
],
|
||||
indirect=True,
|
||||
)
|
||||
@pytest.mark.xfail(reason='Runner unable to connect to target over Bluetooth', run=False)
|
||||
@idf_parametrize('target', ['esp32'], indirect=['target'])
|
||||
def test_examples_wifi_prov_mgr_sec1(dut: Dut) -> None:
|
||||
test_wifi_prov_mgr(dut, 1)
|
||||
|
||||
|
||||
@pytest.mark.generic
|
||||
@pytest.mark.xfail(reason='Runner unable to connect to target over Bluetooth', run=False)
|
||||
@idf_parametrize('target', ['esp32'], indirect=['target'])
|
||||
def test_examples_wifi_prov_mgr_sec2(dut: Dut) -> None:
|
||||
test_wifi_prov_mgr(dut, 2)
|
@@ -1 +0,0 @@
|
||||
CONFIG_EXAMPLE_PROV_SECURITY_VERSION_1=y
|
@@ -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"
|
@@ -41,10 +41,6 @@ target-version = "py310"
|
||||
"components/protocomm/python/sec1_pb2.py",
|
||||
"components/protocomm/python/sec2_pb2.py",
|
||||
"components/protocomm/python/session_pb2.py",
|
||||
"components/wifi_provisioning/python/wifi_ctrl_pb2.py",
|
||||
"components/wifi_provisioning/python/wifi_scan_pb2.py",
|
||||
"components/wifi_provisioning/python/wifi_config_pb2.py",
|
||||
"components/wifi_provisioning/python/wifi_constants_pb2.py",
|
||||
"components/esp_local_ctrl/python/esp_local_ctrl_pb2.py",
|
||||
]
|
||||
|
||||
|
@@ -89,7 +89,6 @@ components_not_formatted_temporary:
|
||||
- "/components/unity/"
|
||||
- "/components/vfs/"
|
||||
- "/components/wear_levelling/"
|
||||
- "/components/wifi_provisioning/"
|
||||
- "/components/xtensa/"
|
||||
- "/examples/bluetooth/"
|
||||
- "/examples/build_system/"
|
||||
|
@@ -246,6 +246,4 @@ ignore:
|
||||
- components/esp_local_ctrl/python/
|
||||
- components/protocomm/proto-c/
|
||||
- components/protocomm/python/
|
||||
- components/wifi_provisioning/proto-c/
|
||||
- components/wifi_provisioning/python/
|
||||
- tools/templates/
|
||||
|
@@ -512,20 +512,6 @@ components/spi_flash/spi_flash_chip_boya.c
|
||||
components/spi_flash/spi_flash_chip_issi.c
|
||||
components/tcp_transport/include/esp_transport_ws.h
|
||||
components/vfs/include/esp_vfs_common.h
|
||||
components/wifi_provisioning/include/wifi_provisioning/scheme_console.h
|
||||
components/wifi_provisioning/include/wifi_provisioning/scheme_softap.h
|
||||
components/wifi_provisioning/include/wifi_provisioning/wifi_scan.h
|
||||
components/wifi_provisioning/proto-c/wifi_config.pb-c.c
|
||||
components/wifi_provisioning/proto-c/wifi_config.pb-c.h
|
||||
components/wifi_provisioning/proto-c/wifi_constants.pb-c.c
|
||||
components/wifi_provisioning/proto-c/wifi_constants.pb-c.h
|
||||
components/wifi_provisioning/proto-c/wifi_scan.pb-c.c
|
||||
components/wifi_provisioning/proto-c/wifi_scan.pb-c.h
|
||||
components/wifi_provisioning/python/wifi_config_pb2.py
|
||||
components/wifi_provisioning/python/wifi_constants_pb2.py
|
||||
components/wifi_provisioning/python/wifi_scan_pb2.py
|
||||
components/wifi_provisioning/src/scheme_console.c
|
||||
components/wifi_provisioning/src/wifi_scan.c
|
||||
components/wpa_supplicant/esp_supplicant/src/esp_wpa_err.h
|
||||
components/wpa_supplicant/include/utils/wpa_debug.h
|
||||
components/wpa_supplicant/include/utils/wpabuf.h
|
||||
@@ -892,7 +878,6 @@ examples/protocols/sockets/udp_client/main/udp_client.c
|
||||
examples/protocols/sockets/udp_multicast/main/udp_multicast_example_main.c
|
||||
examples/protocols/sockets/udp_server/main/udp_server.c
|
||||
examples/protocols/static_ip/main/static_ip_example_main.c
|
||||
examples/provisioning/wifi_prov_mgr/main/app_main.c
|
||||
examples/security/flash_encryption/main/flash_encrypt_main.c
|
||||
examples/storage/custom_flash_driver/main/main.c
|
||||
examples/storage/partition_api/partition_find/main/main.c
|
||||
|
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# Checks that all links in the readme markdown files are valid
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
@@ -14,12 +14,9 @@ import re
|
||||
import sys
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
from collections import defaultdict, namedtuple
|
||||
from collections import defaultdict
|
||||
from collections import namedtuple
|
||||
from pathlib import Path
|
||||
from typing import List
|
||||
|
||||
# The apple apps links are not accessible from the company network for some reason
|
||||
EXCLUDE_URL_LIST = ['https://apps.apple.com/in/app/esp-ble-provisioning/id1473590141', 'https://apps.apple.com/in/app/esp-softap-provisioning/id1474040630']
|
||||
|
||||
Link = namedtuple('Link', ['file', 'url'])
|
||||
|
||||
@@ -32,7 +29,7 @@ class ReadmeLinkError(Exception):
|
||||
|
||||
class RelativeLinkError(ReadmeLinkError):
|
||||
def __str__(self) -> str:
|
||||
return 'Relative link error, file - {} not found, linked from {}'.format(self.url, self.file)
|
||||
return f'Relative link error, file - {self.url} not found, linked from {self.file}'
|
||||
|
||||
|
||||
class UrlLinkError(ReadmeLinkError):
|
||||
@@ -42,7 +39,10 @@ class UrlLinkError(ReadmeLinkError):
|
||||
|
||||
def __str__(self) -> str:
|
||||
files = [str(f) for f in self.file]
|
||||
return 'URL error, url - {} in files - {} is not accessible, request returned {}'.format(self.url, ', '.join(files), self.error_code)
|
||||
files_str = ', '.join(files)
|
||||
return (
|
||||
f'URL error, url - {self.url} in files - {files_str} is not accessible, request returned {self.error_code}'
|
||||
)
|
||||
|
||||
|
||||
# we do not want a failed test just due to bad network conditions, for non 404 errors we simply print a warning
|
||||
@@ -54,16 +54,17 @@ def check_url(url: str, files: str, timeout: float) -> None:
|
||||
if e.code == 404:
|
||||
raise UrlLinkError(files, url, str(e))
|
||||
else:
|
||||
print('Unable to access {}, err = {}'.format(url, str(e)))
|
||||
print(f'Unable to access {url}, err = {str(e)}')
|
||||
except Exception as e:
|
||||
print('Unable to access {}, err = {}'.format(url, str(e)))
|
||||
print(f'Unable to access {url}, err = {str(e)}')
|
||||
|
||||
|
||||
def check_web_links(web_links: defaultdict) -> List:
|
||||
|
||||
def check_web_links(web_links: defaultdict) -> list:
|
||||
with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor:
|
||||
errors = []
|
||||
future_to_url = {executor.submit(check_url, url, files, timeout=30): (url, files) for url, files in web_links.items()}
|
||||
future_to_url = {
|
||||
executor.submit(check_url, url, files, timeout=30): (url, files) for url, files in web_links.items()
|
||||
}
|
||||
for future in concurrent.futures.as_completed(future_to_url):
|
||||
try:
|
||||
future.result()
|
||||
@@ -73,7 +74,7 @@ def check_web_links(web_links: defaultdict) -> List:
|
||||
return errors
|
||||
|
||||
|
||||
def check_file_links(file_links: List) -> List:
|
||||
def check_file_links(file_links: list) -> list:
|
||||
errors = []
|
||||
|
||||
for link in file_links:
|
||||
@@ -82,11 +83,11 @@ def check_file_links(file_links: List) -> List:
|
||||
if not Path.exists(link_path):
|
||||
errors.append(RelativeLinkError(link.file, link.url))
|
||||
|
||||
print('Found {} errors with relative links'.format(len(errors)))
|
||||
print(f'Found {len(errors)} errors with relative links')
|
||||
return errors
|
||||
|
||||
|
||||
def get_md_links(folder: str) -> List:
|
||||
def get_md_links(folder: str) -> list:
|
||||
MD_LINK_RE = r'\[.+?\]\((.+?)(#.+)?\)'
|
||||
|
||||
idf_path_str = os.getenv('IDF_PATH')
|
||||
@@ -109,9 +110,8 @@ def get_md_links(folder: str) -> List:
|
||||
|
||||
|
||||
def check_readme_links(args: argparse.Namespace) -> int:
|
||||
|
||||
links = get_md_links('examples')
|
||||
print('Found {} links'.format(len(links)))
|
||||
print(f'Found {len(links)} links')
|
||||
|
||||
errors = []
|
||||
|
||||
@@ -121,19 +121,16 @@ def check_readme_links(args: argparse.Namespace) -> int:
|
||||
# Sort links into file and web links
|
||||
for link in links:
|
||||
if link.url.startswith('http'):
|
||||
web_links[link.url].append(link.file)
|
||||
web_links[link.url].append(link.file)
|
||||
else:
|
||||
file_links.append(link)
|
||||
|
||||
for url in EXCLUDE_URL_LIST:
|
||||
del web_links[url]
|
||||
|
||||
errors.extend(check_file_links(file_links))
|
||||
|
||||
if not args.skip_weburl:
|
||||
errors.extend(check_web_links(web_links))
|
||||
|
||||
print('Found {} errors:'.format(len(errors)))
|
||||
print(f'Found {len(errors)} errors:')
|
||||
for e in errors:
|
||||
print(e)
|
||||
|
||||
@@ -141,9 +138,12 @@ def check_readme_links(args: argparse.Namespace) -> int:
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
parser = argparse.ArgumentParser(description='check_readme_links.py: Checks for dead links in example READMEs', prog='check_readme_links.py')
|
||||
parser.add_argument('--skip-weburl', '-w', action='store_true', help='Skip checking of web URLs, only check links to local files')
|
||||
parser = argparse.ArgumentParser(
|
||||
description='check_readme_links.py: Checks for dead links in example READMEs', prog='check_readme_links.py'
|
||||
)
|
||||
parser.add_argument(
|
||||
'--skip-weburl', '-w', action='store_true', help='Skip checking of web URLs, only check links to local files'
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
sys.exit(check_readme_links(args))
|
||||
|
@@ -41,7 +41,6 @@ tools/ci/sg_rules/*
|
||||
tools/ci/sort_yaml.py
|
||||
tools/ci/utils.sh
|
||||
tools/eclipse-code-style.xml
|
||||
tools/esp_prov/**/*
|
||||
tools/format.sh
|
||||
tools/gdb_panic_server.py
|
||||
tools/mocks/**/*
|
||||
|
@@ -12,13 +12,17 @@ components/protocomm/python/constants_pb2.py
|
||||
components/protocomm/python/sec0_pb2.py
|
||||
components/protocomm/python/sec1_pb2.py
|
||||
components/protocomm/python/session_pb2.py
|
||||
components/wifi_provisioning/python/wifi_config_pb2.py
|
||||
components/wifi_provisioning/python/wifi_constants_pb2.py
|
||||
components/wifi_provisioning/python/wifi_ctrl_pb2.py
|
||||
components/wifi_provisioning/python/wifi_scan_pb2.py
|
||||
components/xtensa/trax/traceparse.py
|
||||
examples/protocols/esp_local_ctrl/scripts/esp_local_ctrl.py
|
||||
examples/protocols/esp_local_ctrl/scripts/proto_lc.py
|
||||
examples/protocols/esp_local_ctrl/scripts/security/security.py
|
||||
examples/protocols/esp_local_ctrl/scripts/security/security0.py
|
||||
examples/protocols/esp_local_ctrl/scripts/security/security1.py
|
||||
examples/protocols/esp_local_ctrl/scripts/transport/ble_cli.py
|
||||
examples/protocols/esp_local_ctrl/scripts/transport/transport.py
|
||||
examples/protocols/esp_local_ctrl/scripts/transport/transport_ble.py
|
||||
examples/protocols/esp_local_ctrl/scripts/transport/transport_console.py
|
||||
examples/protocols/esp_local_ctrl/scripts/transport/transport_http.py
|
||||
examples/storage/parttool/parttool_example.py
|
||||
examples/system/ota/otatool/get_running_partition.py
|
||||
examples/system/ota/otatool/otatool_example.py
|
||||
@@ -37,19 +41,6 @@ tools/esp_app_trace/espytrace/apptrace.py
|
||||
tools/esp_app_trace/espytrace/sysview.py
|
||||
tools/esp_app_trace/logtrace_proc.py
|
||||
tools/esp_app_trace/sysviewtrace_proc.py
|
||||
tools/esp_prov/esp_prov.py
|
||||
tools/esp_prov/prov/custom_prov.py
|
||||
tools/esp_prov/prov/wifi_ctrl.py
|
||||
tools/esp_prov/prov/wifi_prov.py
|
||||
tools/esp_prov/prov/wifi_scan.py
|
||||
tools/esp_prov/security/security.py
|
||||
tools/esp_prov/security/security0.py
|
||||
tools/esp_prov/security/security1.py
|
||||
tools/esp_prov/transport/ble_cli.py
|
||||
tools/esp_prov/transport/transport.py
|
||||
tools/esp_prov/transport/transport_ble.py
|
||||
tools/esp_prov/transport/transport_console.py
|
||||
tools/esp_prov/transport/transport_http.py
|
||||
tools/gen_esp_err_to_name.py
|
||||
tools/gen_soc_caps_kconfig/test/test_gen_soc_caps_kconfig.py
|
||||
tools/ldgen/ldgen.py
|
||||
|
@@ -26,5 +26,3 @@ components/esp_local_ctrl/proto-c/**
|
||||
components/esp_local_ctrl/python/**
|
||||
components/protocomm/proto-c/**
|
||||
components/protocomm/python/**
|
||||
components/wifi_provisioning/proto-c/**
|
||||
components/wifi_provisioning/python/**
|
||||
|
@@ -38,4 +38,3 @@ skip:
|
||||
- "components/bt/host/bluedroid/stack/gatt/att_protocol.c"
|
||||
- "components/bt/host/bluedroid/stack/gatt/gatt_db.c"
|
||||
- "components/bt/host/bluedroid/stack/l2cap/l2c_utils.c"
|
||||
- "components/wifi_provisioning/src/scheme_ble.c"
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user