gap: return command disallowed if disconnect already requested

This commit is contained in:
Matthias Ringwald 2024-06-28 11:05:47 +02:00
parent 66093044db
commit 61972f0a59
2 changed files with 18 additions and 6 deletions

View File

@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- HID Host: return complete HID report
### Changed
- GAP: return command disallowed if disconnect already requested
## Release v1.6.1

View File

@ -9035,13 +9035,23 @@ uint8_t gap_disconnect(hci_con_handle_t handle){
hci_emit_disconnection_complete(handle, 0);
return 0;
}
// ignore if already disconnected
if (conn->state == RECEIVED_DISCONNECTION_COMPLETE){
return 0;
uint8_t status = ERROR_CODE_SUCCESS;
switch (conn->state){
case RECEIVED_DISCONNECTION_COMPLETE:
// ignore if remote just disconnected
break;
case SEND_DISCONNECT:
case SENT_DISCONNECT:
// disconnect already requested or sent
status = ERROR_CODE_COMMAND_DISALLOWED;
break;
default:
// trigger hci_disconnect
conn->state = SEND_DISCONNECT;
hci_run();
break;
}
conn->state = SEND_DISCONNECT;
hci_run();
return 0;
return status;
}
int gap_read_rssi(hci_con_handle_t con_handle){