Skip to content

Commit

Permalink
feat(provisioning): Modify component and example for ESP8266
Browse files Browse the repository at this point in the history
  • Loading branch information
ESP-YJM committed Aug 11, 2020
1 parent 08537e4 commit 82dcc3e
Show file tree
Hide file tree
Showing 51 changed files with 51 additions and 3,279 deletions.
11 changes: 3 additions & 8 deletions components/wifi_provisioning/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
if(CONFIG_ENABLE_UNIFIED_PROVISIONING)
set(srcs "src/wifi_config.c"
"src/wifi_scan.c"
"src/manager.c"
"src/handlers.c"
"src/scheme_softap.c"
"src/scheme_console.c"
"proto-c/wifi_config.pb-c.c"
"proto-c/wifi_scan.pb-c.c"
"proto-c/wifi_constants.pb-c.c")

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 ../protocomm/proto-c
REQUIRES lwip protocomm
PRIV_REQUIRES protobuf-c bt mdns json esp_timer)
PRIV_REQUIRES protobuf-c mdns json)

# To avoid warning for strncpy
set_source_files_properties(src/handlers.c src/scheme_softap.c
PROPERTIES COMPILE_FLAGS
-Wno-stringop-truncation
)

9 changes: 9 additions & 0 deletions components/wifi_provisioning/Kconfig
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
menu "Wi-Fi Provisioning Manager"

config ENABLE_UNIFIED_PROVISIONING
bool "Enable Unified Provisioning"
default n
select ENABLE_MDNS
help
This enables Unified Provisioning feature along with required components like Wifi-Provisioning, Protocomm and their mbedtls dependencies.

config WIFI_PROV_SCAN_MAX_ENTRIES
int "Max Wi-Fi Scan Result Entries"
default 16
range 1 255
depends on ENABLE_UNIFIED_PROVISIONING
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
depends on ENABLE_UNIFIED_PROVISIONING
help
Time (in seconds) after which the Wi-Fi provisioning manager will auto-stop after connecting to
a Wi-Fi network successfully.
Expand Down
10 changes: 4 additions & 6 deletions components/wifi_provisioning/component.mk
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
COMPONENT_SRCDIRS :=
COMPONENT_ADD_INCLUDEDIRS :=

ifdef CONFIG_ENABLE_UNIFIED_PROVISIONING
COMPONENT_SRCDIRS := src proto-c
COMPONENT_ADD_INCLUDEDIRS := include
COMPONENT_PRIV_INCLUDEDIRS := src proto-c ../protocomm/proto-c/

# To avoid warning for strncpy in "handlers.c" and "scheme_softap.c"
CPPFLAGS += -Wno-stringop-truncation

ifndef CONFIG_BT_BLUEDROID_ENABLED
ifndef CONFIG_BT_NIMBLE_ENABLED
COMPONENT_OBJEXCLUDE := src/scheme_ble.o
endif
endif

This file was deleted.

This file was deleted.

8 changes: 4 additions & 4 deletions components/wifi_provisioning/src/handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ static esp_err_t get_status_handler(wifi_prov_config_get_data_t *resp_data, wifi
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));

tcpip_adapter_ip_info_t ip_info;
tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &ip_info);
char *ip_addr = ip4addr_ntoa(&ip_info.ip);
strcpy(resp_data->conn_info.ip_addr, ip_addr);

/* AP information to which STA is connected */
wifi_ap_record_t ap_info;
Expand Down
4 changes: 4 additions & 0 deletions components/wifi_provisioning/src/manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,10 @@ static void wifi_prov_mgr_event_handler_internal(
/* If none of the expected reasons,
* retry connecting to host SSID */
prov_ctx->wifi_state = WIFI_PROV_STA_CONNECTING;
if (disconnected->reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) {
/*Switch to 802.11 bgn mode */
esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N);
}
esp_wifi_connect();
}

Expand Down
Loading

0 comments on commit 82dcc3e

Please sign in to comment.