Merge pull request #10677 from kvp1703/fix/wifi_provision
fix: Split provisioning into two parts for better synchronization
This commit is contained in:
commit
59d51de642
3 changed files with 30 additions and 8 deletions
|
|
@ -94,6 +94,12 @@ void setup() {
|
||||||
|
|
||||||
RMaker.enableSystemService(SYSTEM_SERV_FLAGS_ALL, 2, 2, 2);
|
RMaker.enableSystemService(SYSTEM_SERV_FLAGS_ALL, 2, 2, 2);
|
||||||
|
|
||||||
|
#if CONFIG_IDF_TARGET_ESP32S2
|
||||||
|
WiFiProv.initProvision(NETWORK_PROV_SCHEME_SOFTAP, NETWORK_PROV_SCHEME_HANDLER_NONE);
|
||||||
|
#else
|
||||||
|
WiFiProv.initProvision(NETWORK_PROV_SCHEME_BLE, NETWORK_PROV_SCHEME_HANDLER_FREE_BTDM);
|
||||||
|
#endif
|
||||||
|
|
||||||
RMaker.start();
|
RMaker.start();
|
||||||
|
|
||||||
WiFi.onEvent(sysProvEvent); // Will call sysProvEvent() from another thread.
|
WiFi.onEvent(sysProvEvent); // Will call sysProvEvent() from another thread.
|
||||||
|
|
|
||||||
|
|
@ -72,13 +72,11 @@ static void get_device_service_name(prov_scheme_t prov_scheme, char *service_nam
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void WiFiProvClass ::beginProvision(
|
void WiFiProvClass ::initProvision(prov_scheme_t prov_scheme, scheme_handler_t scheme_handler, bool reset_provisioned) {
|
||||||
prov_scheme_t prov_scheme, scheme_handler_t scheme_handler, network_prov_security_t security, const char *pop, const char *service_name,
|
if (this->provInitDone) {
|
||||||
const char *service_key, uint8_t *uuid, bool reset_provisioned
|
log_i("provInit was already done!");
|
||||||
) {
|
return;
|
||||||
bool provisioned = false;
|
}
|
||||||
static char service_name_temp[32];
|
|
||||||
|
|
||||||
network_prov_mgr_config_t config;
|
network_prov_mgr_config_t config;
|
||||||
#if CONFIG_BLUEDROID_ENABLED
|
#if CONFIG_BLUEDROID_ENABLED
|
||||||
if (prov_scheme == NETWORK_PROV_SCHEME_BLE) {
|
if (prov_scheme == NETWORK_PROV_SCHEME_BLE) {
|
||||||
|
|
@ -118,11 +116,22 @@ void WiFiProvClass ::beginProvision(
|
||||||
if (reset_provisioned) {
|
if (reset_provisioned) {
|
||||||
log_i("Resetting provisioned data.");
|
log_i("Resetting provisioned data.");
|
||||||
network_prov_mgr_reset_wifi_provisioning();
|
network_prov_mgr_reset_wifi_provisioning();
|
||||||
} else if (network_prov_mgr_is_wifi_provisioned(&provisioned) != ESP_OK) {
|
} else if (network_prov_mgr_is_wifi_provisioned(&(this->provisioned)) != ESP_OK) {
|
||||||
log_e("network_prov_mgr_is_wifi_provisioned failed!");
|
log_e("network_prov_mgr_is_wifi_provisioned failed!");
|
||||||
network_prov_mgr_deinit();
|
network_prov_mgr_deinit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this->provInitDone = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WiFiProvClass ::beginProvision(
|
||||||
|
prov_scheme_t prov_scheme, scheme_handler_t scheme_handler, network_prov_security_t security, const char *pop, const char *service_name,
|
||||||
|
const char *service_key, uint8_t *uuid, bool reset_provisioned
|
||||||
|
) {
|
||||||
|
if (!this->provInitDone) {
|
||||||
|
WiFiProvClass ::initProvision(prov_scheme, scheme_handler, reset_provisioned);
|
||||||
|
}
|
||||||
|
static char service_name_temp[32];
|
||||||
if (provisioned == false) {
|
if (provisioned == false) {
|
||||||
#if CONFIG_BLUEDROID_ENABLED
|
#if CONFIG_BLUEDROID_ENABLED
|
||||||
if (prov_scheme == NETWORK_PROV_SCHEME_BLE) {
|
if (prov_scheme == NETWORK_PROV_SCHEME_BLE) {
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,14 @@ typedef enum {
|
||||||
|
|
||||||
//Provisioning class
|
//Provisioning class
|
||||||
class WiFiProvClass {
|
class WiFiProvClass {
|
||||||
|
private:
|
||||||
|
bool provInitDone = false;
|
||||||
|
bool provisioned = false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
void initProvision(
|
||||||
|
prov_scheme_t prov_scheme = NETWORK_PROV_SCHEME_SOFTAP, scheme_handler_t scheme_handler = NETWORK_PROV_SCHEME_HANDLER_NONE, bool reset_provisioned = false
|
||||||
|
);
|
||||||
void beginProvision(
|
void beginProvision(
|
||||||
prov_scheme_t prov_scheme = NETWORK_PROV_SCHEME_SOFTAP, scheme_handler_t scheme_handler = NETWORK_PROV_SCHEME_HANDLER_NONE,
|
prov_scheme_t prov_scheme = NETWORK_PROV_SCHEME_SOFTAP, scheme_handler_t scheme_handler = NETWORK_PROV_SCHEME_HANDLER_NONE,
|
||||||
network_prov_security_t security = NETWORK_PROV_SECURITY_1, const char *pop = "abcd1234", const char *service_name = NULL, const char *service_key = NULL,
|
network_prov_security_t security = NETWORK_PROV_SECURITY_1, const char *pop = "abcd1234", const char *service_name = NULL, const char *service_key = NULL,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue