Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ set(MAIN_INCLUDE_DIRS

set(MAIN_REQUIRES
qrcode
wifi_provisioning
coreMQTT
coreMQTT-Agent
corePKCS11
Expand All @@ -58,6 +57,8 @@ set(MAIN_REQUIRES
driver
)

set(EXCLUDE_COMPONENTS wifi_provisioning)

idf_component_register(
SRCS
${MAIN_SRCS}
Expand Down
1 change: 1 addition & 0 deletions main/idf_component.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ dependencies:
version: "^0.6.0"
rules:
- if: "idf_version >=5.0"
espressif/network_provisioning: "^1.2.0"
48 changes: 24 additions & 24 deletions main/networking/wifi/app_wifi.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
#include <tcpip_adapter.h>
#endif

#include <wifi_provisioning/manager.h>
#include <network_provisioning/manager.h>
#ifdef CONFIG_APP_WIFI_PROV_TRANSPORT_BLE
#include <wifi_provisioning/scheme_ble.h>
#include <network_provisioning/scheme_ble.h>
#else /* CONFIG_APP_WIFI_PROV_TRANSPORT_SOFTAP */
#include <wifi_provisioning/scheme_softap.h>
#include <network_provisioning/scheme_softap.h>
#endif /* CONFIG_APP_WIFI_PROV_TRANSPORT_BLE */

#include <qrcode.h>
Expand Down Expand Up @@ -76,15 +76,15 @@ static void event_handler( void * arg,
long int event_id,
void * event_data )
{
if( event_base == WIFI_PROV_EVENT )
if( event_base == NETWORK_PROV_EVENT )
{
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"
Expand All @@ -94,23 +94,23 @@ static void event_handler( void * arg,
break;
}

case WIFI_PROV_CRED_FAIL:
case NETWORK_PROV_WIFI_CRED_FAIL:
{
wifi_prov_sta_fail_reason_t * reason = ( wifi_prov_sta_fail_reason_t * ) event_data;
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" );
break;
}

case WIFI_PROV_CRED_SUCCESS:
case NETWORK_PROV_WIFI_CRED_SUCCESS:
ESP_LOGI( TAG, "Provisioning successful" );
break;

case WIFI_PROV_END:
case NETWORK_PROV_END:
/* De-initialize manager once provisioning is finished */
wifi_prov_mgr_deinit();
network_prov_mgr_deinit();
break;

default:
Expand Down Expand Up @@ -265,7 +265,7 @@ void app_wifi_init( void )
wifi_event_group = xEventGroupCreate();

/* Register our event handler for Wi-Fi, IP and Provisioning related events */
ESP_ERROR_CHECK( esp_event_handler_register( WIFI_PROV_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL ) );
ESP_ERROR_CHECK( esp_event_handler_register( NETWORK_PROV_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL ) );
ESP_ERROR_CHECK( esp_event_handler_register( WIFI_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL ) );
ESP_ERROR_CHECK( esp_event_handler_register( IP_EVENT, IP_EVENT_STA_GOT_IP, &event_handler, NULL ) );

Expand All @@ -280,14 +280,14 @@ void app_wifi_init( void )
esp_err_t app_wifi_start( app_wifi_pop_type_t pop_type )
{
/* Configuration for the provisioning manager */
wifi_prov_mgr_config_t config =
network_prov_mgr_config_t config =
{
/* What is the Provisioning Scheme that we want ?
* wifi_prov_scheme_softap or wifi_prov_scheme_ble */
#ifdef CONFIG_APP_WIFI_PROV_TRANSPORT_BLE
.scheme = wifi_prov_scheme_ble,
.scheme = network_prov_scheme_ble,
#else /* CONFIG_APP_WIFI_PROV_TRANSPORT_SOFTAP */
.scheme = wifi_prov_scheme_softap,
.scheme = network_prov_scheme_softap,
#endif /* CONFIG_APP_WIFI_PROV_TRANSPORT_BLE */

/* Any default scheme specific event handler that you would
Expand All @@ -299,19 +299,19 @@ esp_err_t app_wifi_start( app_wifi_pop_type_t pop_type )
* to take care of this automatically. This can be set to
* WIFI_PROV_EVENT_HANDLER_NONE when using wifi_prov_scheme_softap*/
#ifdef CONFIG_APP_WIFI_PROV_TRANSPORT_BLE
.scheme_event_handler = WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BTDM
.scheme_event_handler = NETWORK_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BTDM
#else /* CONFIG_APP_WIFI_PROV_TRANSPORT_SOFTAP */
.scheme_event_handler = WIFI_PROV_EVENT_HANDLER_NONE,
#endif /* CONFIG_APP_WIFI_PROV_TRANSPORT_BLE */
};

/* 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 ) );

bool provisioned = false;
/* Let's find out if the device is provisioned */
ESP_ERROR_CHECK( wifi_prov_mgr_is_provisioned( &provisioned ) );
ESP_ERROR_CHECK( network_prov_mgr_is_wifi_provisioned( &provisioned ) );

/* If device is not yet provisioned start provisioning service */
if( !provisioned )
Expand All @@ -335,7 +335,7 @@ esp_err_t app_wifi_start( app_wifi_pop_type_t pop_type )
* using X25519 key exchange and proof of possession (pop) and AES-CTR
* for encryption/decryption of messages.
*/
wifi_prov_security_t security = WIFI_PROV_SECURITY_1;
network_prov_security_t security = NETWORK_PROV_SECURITY_1;

/* Do we want a proof-of-possession (ignored if Security 0 is selected):
* - this should be a string with length > 0
Expand Down Expand Up @@ -374,7 +374,7 @@ esp_err_t app_wifi_start( app_wifi_pop_type_t pop_type )
0xb4, 0xdf, 0x5a, 0x1c, 0x3f, 0x6b, 0xf4, 0xbf,
0xea, 0x4a, 0x82, 0x03, 0x04, 0x90, 0x1a, 0x02,
};
err = wifi_prov_scheme_ble_set_service_uuid( custom_service_uuid );
err = network_prov_scheme_ble_set_service_uuid( custom_service_uuid );

if( err != ESP_OK )
{
Expand All @@ -384,7 +384,7 @@ esp_err_t app_wifi_start( app_wifi_pop_type_t pop_type )
#endif /* CONFIG_APP_WIFI_PROV_TRANSPORT_BLE */

/* Start provisioning service */
ESP_ERROR_CHECK( wifi_prov_mgr_start_provisioning( security, pop, service_name, service_key ) );
ESP_ERROR_CHECK( network_prov_mgr_start_provisioning( security, pop, service_name, service_key ) );
/* Print QR code for provisioning */
#ifdef CONFIG_APP_WIFI_PROV_TRANSPORT_BLE
app_wifi_print_qr( service_name, pop, PROV_TRANSPORT_BLE );
Expand All @@ -399,7 +399,7 @@ esp_err_t app_wifi_start( app_wifi_pop_type_t pop_type )

/* We don't need the manager as device is already provisioned,
* so let's release it's resources */
wifi_prov_mgr_deinit();
network_prov_mgr_deinit();

/* Start Wi-Fi station */
wifi_init_sta();
Expand All @@ -413,4 +413,4 @@ esp_err_t app_wifi_start( app_wifi_pop_type_t pop_type )
void vWaitOnWifiConnected( void )
{
xEventGroupWaitBits( wifi_event_group, WIFI_CONNECTED_EVENT, false, true, portMAX_DELAY );
}
}
Loading