gap: emit GAP_EVENT_PAIRING_STARTED and GAP_EVENT_PAIRING_COMPLETE

This commit is contained in:
Matthias Ringwald 2021-06-18 18:15:30 +02:00
parent 1714cbbd1f
commit 77208d9020
2 changed files with 19 additions and 0 deletions

View File

@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## Unreleased
### Added
- GAP: emit GAP_EVENT_PAIRING_STARTED and GAP_EVENT_PAIRING_COMPLETE
### Fixed
- GAP: store link key in hci connection struct to allow authenticate after pairing without bonding
@ -23,6 +24,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- GAP: return status for `gap_set_security_mode`
- HCI: update advertising data without stopping advertising first
## Release v1.4
### Added

View File

@ -406,12 +406,29 @@ static void hci_pairing_started(hci_connection_t * hci_connection, bool ssp){
bool initiator = (hci_connection->bonding_flags & BONDING_SENT_AUTHENTICATE_REQUEST) != 0;
log_info("pairing started, ssp %u, initiator %u", (int) ssp, (int) initiator);
uint8_t event[12];
event[0] = GAP_EVENT_PAIRING_STARTED;
event[1] = 10;
reverse_bd_addr(hci_connection->address, &event[2]);
little_endian_store_16(event, 8, (uint16_t) hci_connection->con_handle);
event[10] = (uint8_t) ssp;
event[11] = (uint8_t) initiator;
hci_emit_event(event, sizeof(event), 1);
}
static void hci_pairing_complete(hci_connection_t * hci_connection, uint8_t status){
if (!hci_pairing_active(hci_connection)) return;
hci_connection->authentication_flags &= ~PAIRING_ACTIVE_MASK;
log_info("pairing complete, status %02x", status);
uint8_t event[12];
event[0] = GAP_EVENT_PAIRING_COMPLETE;
event[1] = 9;
reverse_bd_addr(hci_connection->address, &event[2]);
little_endian_store_16(event, 8, (uint16_t) hci_connection->con_handle);
event[10] = status;
hci_emit_event(event, sizeof(event), 1);
}
int hci_authentication_active_for_handle(hci_con_handle_t handle){