You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
I have searched the issue tracker for a similar issue and not found a similar issue.
General issue report
When running the example code for the spp_server under Nimbke BLE, I receive an error when a device is disconnected and a notification is sent.
Once a device disconnects, and I send a notification, I get error #7 for the disconnected device notification. (Other connected devices receive the notification OK)
I see an array is made to keep track of the connected devices uint16_t connection_handle[CONFIG_BT_NIMBLE_MAX_CONNECTIONS];
and that array is populated when a device connects: connection_handle[event->connect.conn_handle - 1] = event->connect.conn_handle;
The connection never gets deleted from the connect_handle array on disconnect.
What is the proper way to remove the particular connection_handle when a device disconnects so that error #7 is not thrown when sending notifications.
Thanks!
The text was updated successfully, but these errors were encountered:
Hi @bheestandLMT ,
Can you tell me on which chip you are facing this issue?
After disconnecting with one device, the connection_handle array is not being updated and while sending notifications it's giving error as the connection is not present.
Can you try these two things:
In disconnect event, set connection_handle[event->connect.conn_handle - 1] as -1
Before sending notifications, add a check that if connection_handle[event->connect.conn_handle - 1] == -1 don't send the notification.
If the above doesn't work, can you please share the error logs with us?
Thank You.
Thanks for the reply.
I had to alter your code slightly to get it to work.
Since the code already checked if connection_handle[ ] was = 0 in a for statement before sending a notification, i made the disconnected connection_handle array = 0 instead of -1. See the for statement code that sends notification below: for ( int i = 0; i < CONFIG_BT_NIMBLE_MAX_CONNECTIONS; i++) { if (connection_handle[i] != 0) { struct os_mbuf *txom; txom = ble_hs_mbuf_from_flat(ntf, sizeof(ntf)); rc = ble_gatts_notify_custom(connection_handle[i], ble_spp_svc_gatt_read_val_handle, txom); if ( rc == 0 ) { ESP_LOGI(tag,"Notification sent successfully"); } else { ESP_LOGI(tag,"Error in sending notification rc = %d", rc); } } }
I also had to change the in disconnect event from event->connect.conn_handle to event->disconnect.conn.conn_handle. Here is the code I ended up using: connection_handle[event->disconnect.conn.conn_handle - 1] = 0;
that worked perfectly and still sends notifications to any other devices that are still connected.
Please feel free to close this and thank you again!
Answers checklist.
General issue report
When running the example code for the spp_server under Nimbke BLE, I receive an error when a device is disconnected and a notification is sent.
Once a device disconnects, and I send a notification, I get error #7 for the disconnected device notification. (Other connected devices receive the notification OK)
I see an array is made to keep track of the connected devices
uint16_t connection_handle[CONFIG_BT_NIMBLE_MAX_CONNECTIONS];
and that array is populated when a device connects:
connection_handle[event->connect.conn_handle - 1] = event->connect.conn_handle;
The connection never gets deleted from the connect_handle array on disconnect.
What is the proper way to remove the particular connection_handle when a device disconnects so that error #7 is not thrown when sending notifications.
Thanks!
The text was updated successfully, but these errors were encountered: