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

Separate Provisioning library from WiFi library. #4550

Merged
merged 1 commit into from
Nov 18, 2020
Merged
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 CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ set(LIBRARY_SRCS
libraries/WiFi/src/WiFi.cpp
libraries/WiFi/src/WiFiGeneric.cpp
libraries/WiFi/src/WiFiMulti.cpp
libraries/WiFi/src/WiFiProv.cpp
libraries/WiFi/src/WiFiScan.cpp
libraries/WiFi/src/WiFiServer.cpp
libraries/WiFi/src/WiFiSTA.cpp
libraries/WiFi/src/WiFiUdp.cpp
libraries/WiFiProv/src/WiFiProv.cpp
libraries/Wire/src/Wire.cpp
)

Expand Down Expand Up @@ -145,6 +145,7 @@ set(includedirs
libraries/WebServer/src
libraries/WiFiClientSecure/src
libraries/WiFi/src
libraries/WiFiProv/src
libraries/Wire/src
)

Expand Down
3 changes: 1 addition & 2 deletions libraries/WiFi/src/WiFi.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@
#include "WiFiClient.h"
#include "WiFiServer.h"
#include "WiFiUdp.h"
#include "WiFiProv.h"

class WiFiClass : public WiFiGenericClass, public WiFiSTAClass, public WiFiScanClass, public WiFiAPClass, public WiFiProvClass
class WiFiClass : public WiFiGenericClass, public WiFiSTAClass, public WiFiScanClass, public WiFiAPClass
{
public:
using WiFiGenericClass::channel;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "WiFiProv.h"
#include "WiFi.h"
void SysProvEvent(arduino_event_t *sys_event)
{
Expand Down Expand Up @@ -46,9 +47,9 @@ void setup() {
0xea, 0x4a, 0x82, 0x03, 0x04, 0x90, 0x1a, 0x02 };*/
WiFi.onEvent(SysProvEvent);
#if CONFIG_IDF_TARGET_ESP32 && CONFIG_BLUEDROID_ENABLED
WiFi.beginProvision(WIFI_PROV_SCHEME_BLE, WIFI_PROV_SCHEME_HANDLER_FREE_BTDM, WIFI_PROV_SECURITY_1, "abcd1234", "Prov_123");
WiFiProv.beginProvision(WIFI_PROV_SCHEME_BLE, WIFI_PROV_SCHEME_HANDLER_FREE_BTDM, WIFI_PROV_SECURITY_1, "abcd1234", "Prov_123");
#else
WiFi.beginProvision(WIFI_PROV_SCHEME_SOFTAP, WIFI_PROV_SCHEME_HANDLER_NONE, WIFI_PROV_SECURITY_1, "abcd1234", "Prov_123");
WiFiProv.beginProvision(WIFI_PROV_SCHEME_SOFTAP, WIFI_PROV_SCHEME_HANDLER_NONE, WIFI_PROV_SECURITY_1, "abcd1234", "Prov_123");
#endif
}

Expand Down
8 changes: 8 additions & 0 deletions libraries/WiFiProv/library.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name=WiFiProv
version=1.0
author=Switi Mhaiske <[email protected]>
maintainer=Hristo Gochkov <[email protected]>
sentence=Enables provisioning.
paragraph=With this library you can perform provisioning on esp32 via SoftAP or BLE.
url=
architectures=esp32
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include <wifi_provisioning/scheme_softap.h>
#include <wifi_provisioning/manager.h>
#undef IPADDR_NONE
#include "WiFi.h"
#include "WiFiProv.h"
#if CONFIG_IDF_TARGET_ESP32
#include "SimpleBLE.h"
#endif
Expand All @@ -48,13 +48,6 @@ static const uint8_t custom_service_uuid[16] = { 0xb4, 0xdf, 0x5a, 0x1c, 0x3f,

#define SERV_NAME_PREFIX_PROV "PROV_"

bool WiFiProvClass::prov_enable = true;

bool WiFiProvClass::isProvEnabled()
{
return prov_enable;
}

static void get_device_service_name(prov_scheme_t prov_scheme, char *service_name, size_t max)
{
uint8_t eth_mac[6] = {0,0,0,0,0,0};
Expand Down Expand Up @@ -84,7 +77,6 @@ static esp_err_t custom_prov_data_handler(uint32_t session_id, const uint8_t *in

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

Expand Down Expand Up @@ -175,3 +167,4 @@ void WiFiProvClass :: beginProvision(prov_scheme_t prov_scheme, scheme_handler_t
}
}

WiFiProvClass WiFiProv;
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,11 @@ typedef enum {

//Provisioning class
class WiFiProvClass
{
protected:
static bool prov_enable;

{
public:
WiFiProvClass() {
prov_enable = false;
}

bool isProvEnabled();
void beginProvision(prov_scheme_t prov_scheme = WIFI_PROV_SCHEME_SOFTAP, scheme_handler_t scheme_handler = WIFI_PROV_SCHEME_HANDLER_NONE,
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);
};

extern WiFiProvClass WiFiProv;