Skip to content

Commit 2cd5dc2

Browse files
committed
Fix build with idf v5.5+ and specific roles are defined.
1 parent 9df8cc7 commit 2cd5dc2

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/NimBLECharacteristic.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@
1818
# include "NimBLECharacteristic.h"
1919
#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL)
2020

21+
#if defined(ESP_IDF_VERSION_MAJOR)
22+
# if defined(CONFIG_NIMBLE_CPP_IDF) && ESP_IDF_VERSION_MAJOR < 5
23+
# define ble_gatts_notify_custom ble_gattc_notify_custom
24+
# define ble_gatts_indicate_custom ble_gattc_indicate_custom
25+
# endif
26+
#endif
27+
2128
# include "NimBLE2904.h"
2229
# include "NimBLEDevice.h"
2330
# include "NimBLELog.h"
@@ -278,9 +285,9 @@ bool NimBLECharacteristic::sendValue(const uint8_t* value, size_t length, bool i
278285

279286
// Null buffer will read the value from the characteristic
280287
if (isNotification) {
281-
rc = ble_gattc_notify_custom(connHandle, m_handle, om);
288+
rc = ble_gatts_notify_custom(connHandle, m_handle, om);
282289
} else {
283-
rc = ble_gattc_indicate_custom(connHandle, m_handle, om);
290+
rc = ble_gatts_indicate_custom(connHandle, m_handle, om);
284291
}
285292

286293
goto done;
@@ -296,17 +303,17 @@ bool NimBLECharacteristic::sendValue(const uint8_t* value, size_t length, bool i
296303
}
297304

298305
if (isNotification) {
299-
rc = ble_gattc_notify_custom(ch, m_handle, om);
306+
rc = ble_gatts_notify_custom(ch, m_handle, om);
300307
} else {
301-
rc = ble_gattc_indicate_custom(ch, m_handle, om);
308+
rc = ble_gatts_indicate_custom(ch, m_handle, om);
302309
}
303310
}
304311
} else if (connHandle != BLE_HS_CONN_HANDLE_NONE) {
305312
// Null buffer will read the value from the characteristic
306313
if (isNotification) {
307-
rc = ble_gattc_notify_custom(connHandle, m_handle, nullptr);
314+
rc = ble_gatts_notify_custom(connHandle, m_handle, nullptr);
308315
} else {
309-
rc = ble_gattc_indicate_custom(connHandle, m_handle, nullptr);
316+
rc = ble_gatts_indicate_custom(connHandle, m_handle, nullptr);
310317
}
311318
} else { // Notify or indicate to all connected peers the characteristic value
312319
ble_gatts_chr_updated(m_handle);

0 commit comments

Comments
 (0)