Skip to content

Commit bcfa678

Browse files
committed
fix(prov): Enable BLE provisioning with NimBLE
1 parent 974cc0b commit bcfa678

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

libraries/WiFiProv/examples/WiFiProv/WiFiProv.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ void setup() {
6262
WiFi.onEvent(SysProvEvent);
6363

6464
// BLE Provisioning using the ESP SoftAP Prov works fine for any BLE SoC, including ESP32, ESP32S3 and ESP32C3.
65-
#if CONFIG_BLUEDROID_ENABLED && !defined(USE_SOFT_AP)
65+
#if (defined(CONFIG_BLUEDROID_ENABLED) || defined(CONFIG_NIMBLE_ENABLED)) && __has_include("esp_bt.h") && !defined(USE_SOFT_AP)
6666
Serial.println("Begin Provisioning using BLE");
6767
// Sample uuid that user can pass during provisioning using BLE
6868
uint8_t uuid[16] = {0xb4, 0xdf, 0x5a, 0x1c, 0x3f, 0x6b, 0xf4, 0xbf, 0xea, 0x4a, 0x82, 0x03, 0x04, 0x90, 0x1a, 0x02};

libraries/WiFiProv/src/WiFiProv.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#endif
3535

3636
#include <nvs_flash.h>
37-
#if CONFIG_BLUEDROID_ENABLED
37+
#if (defined(CONFIG_BLUEDROID_ENABLED) || defined(CONFIG_NIMBLE_ENABLED)) && __has_include("esp_bt.h")
3838
#include "network_provisioning/scheme_ble.h"
3939
#endif
4040
#include <network_provisioning/scheme_softap.h>
@@ -47,7 +47,7 @@
4747

4848
bool wifiLowLevelInit(bool persistent);
4949

50-
#if CONFIG_BLUEDROID_ENABLED
50+
#if (defined(CONFIG_BLUEDROID_ENABLED) || defined(CONFIG_NIMBLE_ENABLED)) && __has_include("esp_bt.h")
5151
static const uint8_t custom_service_uuid[16] = {
5252
0xb4, 0xdf, 0x5a, 0x1c, 0x3f, 0x6b, 0xf4, 0xbf, 0xea, 0x4a, 0x82, 0x03, 0x04, 0x90, 0x1a, 0x02,
5353
};
@@ -61,13 +61,13 @@ static void get_device_service_name(prov_scheme_t prov_scheme, char *service_nam
6161
log_e("esp_wifi_get_mac failed!");
6262
return;
6363
}
64-
#if CONFIG_IDF_TARGET_ESP32 && defined(CONFIG_BLUEDROID_ENABLED)
64+
#if CONFIG_IDF_TARGET_ESP32 && (defined(CONFIG_BLUEDROID_ENABLED) || defined(CONFIG_NIMBLE_ENABLED)) && __has_include("esp_bt.h")
6565
if (prov_scheme == NETWORK_PROV_SCHEME_BLE) {
6666
snprintf(service_name, max, "%s%02X%02X%02X", SERV_NAME_PREFIX_PROV, eth_mac[3], eth_mac[4], eth_mac[5]);
6767
} else {
6868
#endif
6969
snprintf(service_name, max, "%s%02X%02X%02X", SERV_NAME_PREFIX_PROV, eth_mac[3], eth_mac[4], eth_mac[5]);
70-
#if CONFIG_IDF_TARGET_ESP32 && defined(CONFIG_BLUEDROID_ENABLED)
70+
#if CONFIG_IDF_TARGET_ESP32 && (defined(CONFIG_BLUEDROID_ENABLED) || defined(CONFIG_NIMBLE_ENABLED)) && __has_include("esp_bt.h")
7171
}
7272
#endif
7373
}
@@ -78,20 +78,20 @@ void WiFiProvClass ::initProvision(prov_scheme_t prov_scheme, scheme_handler_t s
7878
return;
7979
}
8080
network_prov_mgr_config_t config;
81-
#if CONFIG_BLUEDROID_ENABLED
81+
#if (defined(CONFIG_BLUEDROID_ENABLED) || defined(CONFIG_NIMBLE_ENABLED)) && __has_include("esp_bt.h")
8282
if (prov_scheme == NETWORK_PROV_SCHEME_BLE) {
8383
config.scheme = network_prov_scheme_ble;
8484
} else {
8585
#endif
8686
config.scheme = network_prov_scheme_softap;
87-
#if CONFIG_BLUEDROID_ENABLED
87+
#if (defined(CONFIG_BLUEDROID_ENABLED) || defined(CONFIG_NIMBLE_ENABLED)) && __has_include("esp_bt.h")
8888
}
8989

9090
if (scheme_handler == NETWORK_PROV_SCHEME_HANDLER_NONE) {
9191
#endif
9292
network_prov_event_handler_t scheme_event_handler = NETWORK_PROV_EVENT_HANDLER_NONE;
9393
memcpy(&config.scheme_event_handler, &scheme_event_handler, sizeof(network_prov_event_handler_t));
94-
#if CONFIG_BLUEDROID_ENABLED
94+
#if (defined(CONFIG_BLUEDROID_ENABLED) || defined(CONFIG_NIMBLE_ENABLED)) && __has_include("esp_bt.h")
9595
} else if (scheme_handler == NETWORK_PROV_SCHEME_HANDLER_FREE_BTDM) {
9696
network_prov_event_handler_t scheme_event_handler = NETWORK_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BTDM;
9797
memcpy(&config.scheme_event_handler, &scheme_event_handler, sizeof(network_prov_event_handler_t));
@@ -133,7 +133,7 @@ void WiFiProvClass ::beginProvision(
133133
}
134134
static char service_name_temp[32];
135135
if (provisioned == false) {
136-
#if CONFIG_BLUEDROID_ENABLED
136+
#if (defined(CONFIG_BLUEDROID_ENABLED) || defined(CONFIG_NIMBLE_ENABLED)) && __has_include("esp_bt.h")
137137
if (prov_scheme == NETWORK_PROV_SCHEME_BLE) {
138138
service_key = NULL;
139139
if (uuid == NULL) {
@@ -148,7 +148,7 @@ void WiFiProvClass ::beginProvision(
148148
service_name = (const char *)service_name_temp;
149149
}
150150

151-
#if CONFIG_BLUEDROID_ENABLED
151+
#if (defined(CONFIG_BLUEDROID_ENABLED) || defined(CONFIG_NIMBLE_ENABLED)) && __has_include("esp_bt.h")
152152
if (prov_scheme == NETWORK_PROV_SCHEME_BLE) {
153153
log_i("Starting AP using BLE. service_name : %s, pop : %s", service_name, pop);
154154
} else {
@@ -158,7 +158,7 @@ void WiFiProvClass ::beginProvision(
158158
} else {
159159
log_i("Starting provisioning AP using SOFTAP. service_name : %s, password : %s, pop : %s", service_name, service_key, pop);
160160
}
161-
#if CONFIG_BLUEDROID_ENABLED
161+
#if (defined(CONFIG_BLUEDROID_ENABLED) || defined(CONFIG_NIMBLE_ENABLED)) && __has_include("esp_bt.h")
162162
}
163163
#endif
164164
if (network_prov_mgr_start_provisioning(security, pop, service_name, service_key) != ESP_OK) {

libraries/WiFiProv/src/WiFiProv.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@
2929
//Select the scheme using which you want to provision
3030
typedef enum {
3131
NETWORK_PROV_SCHEME_SOFTAP,
32-
#if CONFIG_BLUEDROID_ENABLED
32+
#if (defined(CONFIG_BLUEDROID_ENABLED) || defined(CONFIG_NIMBLE_ENABLED)) && __has_include("esp_bt.h")
3333
NETWORK_PROV_SCHEME_BLE,
3434
#endif
3535
NETWORK_PROV_SCHEME_MAX
3636
} prov_scheme_t;
3737

3838
typedef enum {
3939
NETWORK_PROV_SCHEME_HANDLER_NONE,
40-
#if CONFIG_BLUEDROID_ENABLED
40+
#if (defined(CONFIG_BLUEDROID_ENABLED) || defined(CONFIG_NIMBLE_ENABLED)) && __has_include("esp_bt.h")
4141
NETWORK_PROV_SCHEME_HANDLER_FREE_BTDM,
4242
NETWORK_PROV_SCHEME_HANDLER_FREE_BLE,
4343
NETWORK_PROV_SCHEME_HANDLER_FREE_BT,

0 commit comments

Comments
 (0)