8000 Fixes for #308 · ViaMonkey/esp32-snippets@ba3d7ac · GitHub
[go: up one dir, main page]

Skip to content

Commit ba3d7ac

Browse files
committed
Fixes for nkolban#308
1 parent 95a20eb commit ba3d7ac

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

cpp_utils/BLEDevice.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,13 @@ bool initialized = false; // Have we been initialized?
4848
* @return A new instance of the client.
4949
*/
5050
/* STATIC */ BLEClient* BLEDevice::createClient() {
51+
ESP_LOGD(LOG_TAG, ">> createClient");
52+
#ifndef CONFIG_GATTC_ENABLE // Check that BLE GATTC is enabled in make menuconfig
53+
ESP_LOGE(LOG_TAG, "BLE GATTC is not enabled - CONFIG_GATTC_ENABLE not defined");
54+
abort();
55+
#endif // CONFIG_GATTC_ENABLE
5156
m_pClient = new BLEClient();
57+
ESP_LOGD(LOG_TAG, "<< createClient");
5258
return m_pClient;
5359
} // createClient
5460

@@ -59,6 +65,10 @@ bool initialized = false; // Have we been initialized?
5965
*/
6066
/* STATIC */ BLEServer* BLEDevice::createServer() {
6167
ESP_LOGD(LOG_TAG, ">> createServer");
68+
#ifndef CONFIG_GATTS_ENABLE // Check that BLE GATTS is enabled in make menuconfig
69+
ESP_LOGE(LOG_TAG, "BLE GATTS is not enabled - CONFIG_GATTS_ENABLE not defined");
70+
abort();
71+
#endif // CONFIG_GATTS_ENABLE
6272
m_pServer = new BLEServer();
6373
m_pServer->createApp(0);
6474
ESP_LOGD(LOG_TAG, "<< createServer");
@@ -260,17 +270,21 @@ bool initialized = false; // Have we been initialized?
260270
return;
261271
}
262272

273+
#ifdef CONFIG_GATTC_ENABLE // Check that BLE client is configured in make menuconfig
263274
errRc = esp_ble_gattc_register_callback(BLEDevice::gattClientEventHandler);
264275
if (errRc != ESP_OK) {
265276
ESP_LOGE(LOG_TAG, "esp_ble_gattc_register_callback: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
266277
return;
267278
}
279+
#endif // CONFIG_GATTC_ENABLE
268280

281+
#ifdef CONFIG_GATTS_ENABLE // Check that BLE server is configured in make menuconfig
269282
errRc = esp_ble_gatts_register_callback(BLEDevice::gattServerEventHandler);
270283
if (errRc != ESP_OK) {
271284
ESP_LOGE(LOG_TAG, "esp_ble_gatts_register_callback: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
272285
return;
273286
}
287+
#endif // CONFIG_GATTS_ENABLE
274288

275289
errRc = ::esp_ble_gap_set_device_name(deviceName.c_str());
276290
if (errRc != ESP_OK) {

0 commit comments

Comments
 (0)
0