diff --git a/src/NimBLECharacteristic.cpp b/src/NimBLECharacteristic.cpp index 0e2736d..831f51d 100644 --- a/src/NimBLECharacteristic.cpp +++ b/src/NimBLECharacteristic.cpp @@ -18,6 +18,13 @@ # include "NimBLECharacteristic.h" #if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL) +#if defined(ESP_IDF_VERSION_MAJOR) +# if defined(CONFIG_NIMBLE_CPP_IDF) && ESP_IDF_VERSION_MAJOR < 5 +# define ble_gatts_notify_custom ble_gattc_notify_custom +# define ble_gatts_indicate_custom ble_gattc_indicate_custom +# endif +#endif + # include "NimBLE2904.h" # include "NimBLEDevice.h" # include "NimBLELog.h" @@ -278,9 +285,9 @@ bool NimBLECharacteristic::sendValue(const uint8_t* value, size_t length, bool i // Null buffer will read the value from the characteristic if (isNotification) { - rc = ble_gattc_notify_custom(connHandle, m_handle, om); + rc = ble_gatts_notify_custom(connHandle, m_handle, om); } else { - rc = ble_gattc_indicate_custom(connHandle, m_handle, om); + rc = ble_gatts_indicate_custom(connHandle, m_handle, om); } goto done; @@ -296,17 +303,17 @@ bool NimBLECharacteristic::sendValue(const uint8_t* value, size_t length, bool i } if (isNotification) { - rc = ble_gattc_notify_custom(ch, m_handle, om); + rc = ble_gatts_notify_custom(ch, m_handle, om); } else { - rc = ble_gattc_indicate_custom(ch, m_handle, om); + rc = ble_gatts_indicate_custom(ch, m_handle, om); } } } else if (connHandle != BLE_HS_CONN_HANDLE_NONE) { // Null buffer will read the value from the characteristic if (isNotification) { - rc = ble_gattc_notify_custom(connHandle, m_handle, nullptr); + rc = ble_gatts_notify_custom(connHandle, m_handle, nullptr); } else { - rc = ble_gattc_indicate_custom(connHandle, m_handle, nullptr); + rc = ble_gatts_indicate_custom(connHandle, m_handle, nullptr); } } else { // Notify or indicate to all connected peers the characteristic value ble_gatts_chr_updated(m_handle);