@@ -221,20 +221,20 @@ static const struct ble_gatt_svc_def new_ble_svc_gatt_defs[] = {
221
221
* @param data_len Length of send buffer
222
222
* @return 0 on success for all clients. -1 on failure to allocate buffer or ble_gatts_notify_custom return value
223
223
*/
224
- int db_ble_send_data (const uint8_t * data , uint16_t data_len ) {
224
+ int db_ble_send_data (const uint8_t * data , uint16_t data_len ) {
225
225
for (int i = 0 ; i < CONFIG_BT_NIMBLE_MAX_CONNECTIONS ; i ++ ) {
226
226
/* Check if the client has subscribed to notifications */
227
227
if (conn_handle_subs [i ]) {
228
- struct os_mbuf * txom ;
229
- // Convert BleData_t struct data into an os_mbuf buffer
230
- txom = ble_hs_mbuf_from_flat ( data , data_len );
231
- if (! txom ) {
232
- ESP_LOGE (TAG , "Failed to allocate os_mbuf (data length: %i )" , data_len );
233
- return -1 ; // maybe we ran out of memory
228
+
229
+ /* Write to the characteristics */
230
+ int rc = ble_gatts_write ( i , ble_spp_svc_gatt_notify_val_handle , data ,data_len );
231
+ if (rc != 0 ) {
232
+ ESP_LOGE (TAG , "Failed to write characteristic value (rc = %d )" , rc );
233
+ return rc ;
234
234
}
235
235
236
- // Send BLE notification
237
- int rc = ble_gatts_notify_custom (i , ble_spp_svc_gatt_notify_val_handle , txom );
236
+ /* Now send a notification with the updated characteristic value */
237
+ rc = ble_gatts_notify (i , ble_spp_svc_gatt_notify_val_handle );
238
238
if (rc != 0 ) {
239
239
ESP_LOGE (TAG , "Error sending BLE notification rc = %d" , rc );
240
240
return rc ;
0 commit comments