gap: avoid requesting authentication twice

This commit is contained in:
Matthias Ringwald 2021-06-10 16:05:33 +02:00
parent e9f98c4a52
commit dbd5dcc31a
2 changed files with 7 additions and 2 deletions

View File

@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
### Fixed
- GAP: store link key in hci connection struct to allow authenticate after pairing without bonding
- GAP: avoid requesting authentication twice
- ATT DB: fix spelling `gatt_server_get_handle_range_for_service_with_uuid128`, `gatt_server_get_handle_range_for_service_with_uuid16`
### Changed

View File

@ -2790,6 +2790,9 @@ static void event_handler(uint8_t *packet, uint16_t size){
conn = hci_connection_for_handle(handle);
if (!conn) break;
// clear authentication active flag
conn->bonding_flags &= ~BONDING_SENT_AUTHENTICATE_REQUEST;
// authenticated only if auth status == 0
if (hci_event_authentication_complete_get_status(packet) == 0){
// authenticated
@ -5411,8 +5414,9 @@ void gap_request_security_level(hci_con_handle_t con_handle, gap_security_level_
log_info("gap_request_security_level requested level %u, planned level %u, current level %u",
requested_level, connection->requested_security_level, current_level);
// authentication already active if planned level > 0
if (connection->requested_security_level > LEVEL_0){
// authentication active if authentication request was sent or planned level > 0
bool authentication_active = ((connection->bonding_flags & BONDING_SENT_AUTHENTICATE_REQUEST) != 0) || (connection->requested_security_level > LEVEL_0);
if (authentication_active){
// authentication already active
if (connection->requested_security_level < requested_level){
// increase requested level as new level is higher