Skip to content

Commit c3b4291

Browse files
sweetymhaiskeme-no-dev
authored andcommitted
Separate Provisioning library from WiFi library to avoid unnecessary compilation while using WiFi library (#4550)
1 parent b405941 commit c3b4291

File tree

4 files changed

+8
-20
lines changed

4 files changed

+8
-20
lines changed

libraries/WiFiProv/examples/WiFiProv/WiFiProv.ino

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "WiFiProv.h"
12
#include "WiFi.h"
23
void SysProvEvent(arduino_event_t *sys_event)
34
{
@@ -46,9 +47,9 @@ void setup() {
4647
0xea, 0x4a, 0x82, 0x03, 0x04, 0x90, 0x1a, 0x02 };*/
4748
WiFi.onEvent(SysProvEvent);
4849
#if CONFIG_IDF_TARGET_ESP32 && CONFIG_BLUEDROID_ENABLED
49-
WiFi.beginProvision(WIFI_PROV_SCHEME_BLE, WIFI_PROV_SCHEME_HANDLER_FREE_BTDM, WIFI_PROV_SECURITY_1, "abcd1234", "Prov_123");
50+
WiFiProv.beginProvision(WIFI_PROV_SCHEME_BLE, WIFI_PROV_SCHEME_HANDLER_FREE_BTDM, WIFI_PROV_SECURITY_1, "abcd1234", "Prov_123");
5051
#else
51-
WiFi.beginProvision(WIFI_PROV_SCHEME_SOFTAP, WIFI_PROV_SCHEME_HANDLER_NONE, WIFI_PROV_SECURITY_1, "abcd1234", "Prov_123");
52+
WiFiProv.beginProvision(WIFI_PROV_SCHEME_SOFTAP, WIFI_PROV_SCHEME_HANDLER_NONE, WIFI_PROV_SECURITY_1, "abcd1234", "Prov_123");
5253
#endif
5354
}
5455

libraries/WiFiProv/library.properties

-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@ author=Switi Mhaiske <[email protected]>
44
maintainer=Hristo Gochkov <[email protected]>
55
sentence=Enables provisioning.
66
paragraph=With this library you can perform provisioning on esp32 via SoftAP or BLE.
7-
category=Communication
87
url=
98
architectures=esp32

libraries/WiFiProv/src/WiFiProv.cpp

+2-9
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include <wifi_provisioning/scheme_softap.h>
3535
#include <wifi_provisioning/manager.h>
3636
#undef IPADDR_NONE
37-
#include "WiFi.h"
37+
#include "WiFiProv.h"
3838
#if CONFIG_IDF_TARGET_ESP32
3939
#include "SimpleBLE.h"
4040
#endif
@@ -48,13 +48,6 @@ static const uint8_t custom_service_uuid[16] = { 0xb4, 0xdf, 0x5a, 0x1c, 0x3f,
4848

4949
#define SERV_NAME_PREFIX_PROV "PROV_"
5050

51-
bool WiFiProvClass::prov_enable = true;
52-
53-
bool WiFiProvClass::isProvEnabled()
54-
{
55-
return prov_enable;
56-
}
57-
5851
static void get_device_service_name(prov_scheme_t prov_scheme, char *service_name, size_t max)
5952
{
6053
uint8_t eth_mac[6] = {0,0,0,0,0,0};
@@ -84,7 +77,6 @@ static esp_err_t custom_prov_data_handler(uint32_t session_id, const uint8_t *in
8477

8578
void WiFiProvClass :: beginProvision(prov_scheme_t prov_scheme, scheme_handler_t scheme_handler, wifi_prov_security_t security, const char * pop, const char *service_name, const char *service_key, uint8_t * uuid)
8679
{
87-
prov_enable = true;
8880
bool provisioned = false;
8981
static char service_name_temp[32];
9082

@@ -175,3 +167,4 @@ void WiFiProvClass :: beginProvision(prov_scheme_t prov_scheme, scheme_handler_t
175167
}
176168
}
177169

170+
WiFiProvClass WiFiProv;

libraries/WiFiProv/src/WiFiProv.h

+3-8
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,11 @@ typedef enum {
4040

4141
//Provisioning class
4242
class WiFiProvClass
43-
{
44-
protected:
45-
static bool prov_enable;
46-
43+
{
4744
public:
48-
WiFiProvClass() {
49-
prov_enable = false;
50-
}
5145

52-
bool isProvEnabled();
5346
void beginProvision(prov_scheme_t prov_scheme = WIFI_PROV_SCHEME_SOFTAP, scheme_handler_t scheme_handler = WIFI_PROV_SCHEME_HANDLER_NONE,
5447
wifi_prov_security_t security = WIFI_PROV_SECURITY_1, const char * pop = "abcd1234", const char * service_name = NULL, const char * service_key = NULL, uint8_t *uuid = NULL);
5548
};
49+
50+
extern WiFiProvClass WiFiProv;

0 commit comments

Comments
 (0)