Checklist
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:
|
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:
|
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 :
Remove the else block.
Checklist
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
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 ofble_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
Change it to:
And at :
esp-nimble/nimble/host/src/ble_gap.c
Line 3420 in 039d2d6
Remove the else block.