sm pairing examples: print re-encryption events

This commit is contained in:
Matthias Ringwald 2020-11-09 11:56:51 +01:00
parent 94cfa0e86e
commit 7e65711b3f
2 changed files with 47 additions and 0 deletions

View File

@ -220,6 +220,7 @@ static void sm_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *pa
if (packet_type != HCI_EVENT_PACKET) return;
bd_addr_t addr;
switch (hci_event_packet_get_type(packet)) {
case SM_EVENT_JUST_WORKS_REQUEST:
printf("Just works requested\n");
@ -255,6 +256,29 @@ static void sm_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *pa
break;
}
break;
case SM_EVENT_REENCRYPTION_STARTED:
sm_event_reencryption_complete_get_address(packet, addr);
printf("Bonding information exists for addr type %u, identity addr %s -> start re-encryption\n",
sm_event_reencryption_started_get_addr_type(packet), bd_addr_to_str(addr));
break;
case SM_EVENT_REENCRYPTION_COMPLETE:
switch (sm_event_reencryption_complete_get_status(packet)){
case ERROR_CODE_SUCCESS:
printf("Re-encryption complete, success\n");
break;
case ERROR_CODE_CONNECTION_TIMEOUT:
printf("Re-encryption failed, timeout\n");
break;
case ERROR_CODE_REMOTE_USER_TERMINATED_CONNECTION:
printf("Re-encryption failed, disconnected\n");
break;
case ERROR_CODE_AUTHENTICATION_FAILURE:
printf("Re-encryption failed, authentication failure\n");
break;
default:
break;
}
break;
default:
break;
}

View File

@ -226,6 +226,29 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
break;
}
break;
case SM_EVENT_REENCRYPTION_STARTED:
sm_event_reencryption_complete_get_address(packet, addr);
printf("Bonding information exists for addr type %u, identity addr %s -> re-encryption started\n",
sm_event_reencryption_started_get_addr_type(packet), bd_addr_to_str(addr));
break;
case SM_EVENT_REENCRYPTION_COMPLETE:
switch (sm_event_reencryption_complete_get_status(packet)){
case ERROR_CODE_SUCCESS:
printf("Re-encryption complete, success\n");
break;
case ERROR_CODE_CONNECTION_TIMEOUT:
printf("Re-encryption failed, timeout\n");
break;
case ERROR_CODE_REMOTE_USER_TERMINATED_CONNECTION:
printf("Re-encryption failed, disconnected\n");
break;
case ERROR_CODE_AUTHENTICATION_FAILURE:
printf("Re-encryption failed, authentication failure\n");
break;
default:
break;
}
break;
default:
break;
}