Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WiFiProv: Split provisioning into two parts for better synchronization. #10673

Closed
wants to merge 1 commit into from
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
2 changes: 2 additions & 0 deletions libraries/RainMaker/examples/RMakerSwitch/RMakerSwitch.ino
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ void setup() {

RMaker.enableSystemService(SYSTEM_SERV_FLAGS_ALL, 2, 2, 2);

WiFiProv.initProvision(NETWORK_PROV_SCHEME_BLE, NETWORK_PROV_SCHEME_HANDLER_FREE_BTDM);

RMaker.start();

WiFi.onEvent(sysProvEvent); // Will call sysProvEvent() from another thread.
Expand Down
27 changes: 20 additions & 7 deletions libraries/WiFiProv/src/WiFiProv.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
WiFiProv.cpp - WiFiProv class for provisioning
All rights reserved.

Expand Down Expand Up @@ -72,13 +72,14 @@ static void get_device_service_name(prov_scheme_t prov_scheme, char *service_nam
#endif
}

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
) {
bool provisioned = false;
static char service_name_temp[32];
bool provInitDone = false;
bool provisioned = false;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please make those static

void WiFiProvClass ::initProvision(prov_scheme_t prov_scheme, scheme_handler_t scheme_handler, bool reset_provisioned) {
if (provInitDone) {
log_i("provInit was already done!");
return;
}
network_prov_mgr_config_t config;
#if CONFIG_BLUEDROID_ENABLED
if (prov_scheme == NETWORK_PROV_SCHEME_BLE) {
Expand Down Expand Up @@ -123,6 +124,18 @@ void WiFiProvClass ::beginProvision(
network_prov_mgr_deinit();
return;
}
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 (!provInitDone) {
WiFiProvClass ::initProvision( prov_scheme, scheme_handler, reset_provisioned);
provInitDone = true;
}
static char service_name_temp[32];
if (provisioned == false) {
#if CONFIG_BLUEDROID_ENABLED
if (prov_scheme == NETWORK_PROV_SCHEME_BLE) {
Expand Down
4 changes: 4 additions & 0 deletions libraries/WiFiProv/src/WiFiProv.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ typedef enum {
//Provisioning class
class WiFiProvClass {
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(
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,
Expand Down
Loading