-
Notifications
You must be signed in to change notification settings - Fork 71
Description
Checklist
- Checked the issue tracker for similar issues to ensure this is not a duplicate
- Read the documentation to confirm the issue is not addressed there and your configuration is set correctly
- Tested with the latest version to ensure the issue hasn't been fixed
How often does this bug occurs?
always
Expected behavior
The peripheral should know about a connected central before any other connection oriented event occurs.
Actual behavior (suspected bug)
When acting as a peripheral the central starts requesting reads/writes etc. before the peripheral knows about the connection.
Error logs or terminal output
Steps to reproduce the behavior
The cause is here:
esp-nimble/nimble/host/src/ble_gap.c
Line 3302 in 039d2d6
| ble_gap_rd_rem_ver_tx(evt->connection_handle); |
Instead of calling ble_gap_event_connect_call(evt->connection_handle, evt->status);, as it should in the slave roll since the connection has already been established, it waits for the result of ble_gap_rd_rem_ver_tx(evt->connection_handle); before sending the connection event.
During this time the central could, and in my tests does, start performing GATT operations before the application knows about the connection.
Project release version
latest
System architecture
Intel/AMD 64-bit (modern PC, older Mac)
Operating system
Linux
Operating system version
all
Shell
Bash
Additional context
The fix is simple, at:
esp-nimble/nimble/host/src/ble_gap.c
Line 3302 in 039d2d6
| ble_gap_rd_rem_ver_tx(evt->connection_handle); |
Change it to:
if (evt->role == BLE_HCI_LE_CONN_COMPLETE_ROLE_SLAVE) {
ble_gap_event_connect_call(evt->connection_handle, evt->status);
ble_gap_rd_rem_ver_tx(evt->connection_handle);
} else {
ble_gap_rd_rem_sup_feat_tx(evt->connection_handle);
}
And at :
esp-nimble/nimble/host/src/ble_gap.c
Line 3420 in 039d2d6
| } else { |
Remove the else block.