From f3dc77a953314ae2ecf36606d6b8613d7f61bccc Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Thu, 20 Aug 2015 17:28:31 +0200 Subject: [PATCH] fix security manager test and disable packet dumping --- test/security_manager/mock.c | 2 +- test/security_manager/security_manager.c | 44 ++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/test/security_manager/mock.c b/test/security_manager/mock.c index baa1b4cfc..407b858f2 100644 --- a/test/security_manager/mock.c +++ b/test/security_manager/mock.c @@ -37,7 +37,7 @@ void mock_clear_packet_buffer(void){ } static void dump_packet(int packet_type, uint8_t * buffer, uint16_t size){ -#if 1 +#if 0 static int packet_counter = 1; char var_name[80]; sprintf(var_name, "test_%s_packet_%02u", packet_type == HCI_COMMAND_DATA_PACKET ? "command" : "acl", packet_counter); diff --git a/test/security_manager/security_manager.c b/test/security_manager/security_manager.c index c18ac75e5..a6238b0ff 100644 --- a/test/security_manager/security_manager.c +++ b/test/security_manager/security_manager.c @@ -118,6 +118,49 @@ uint16_t mock_packet_buffer_len(void); void mock_clear_packet_buffer(void); +void app_packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){ + uint16_t aHandle; + sm_event_t * sm_event; + switch (packet_type) { + case HCI_EVENT_PACKET: + switch (packet[0]) { + case SM_PASSKEY_INPUT_NUMBER: + // store peer address for input + sm_event = (sm_event_t *) packet; + printf("\nGAP Bonding %s (%u): Enter 6 digit passkey: '", bd_addr_to_str(sm_event->address), sm_event->addr_type); + fflush(stdout); + break; + + case SM_PASSKEY_DISPLAY_NUMBER: + sm_event = (sm_event_t *) packet; + printf("\nGAP Bonding %s (%u): Display Passkey '%06u\n", bd_addr_to_str(sm_event->address), sm_event->addr_type, sm_event->passkey); + break; + + case SM_PASSKEY_DISPLAY_CANCEL: + sm_event = (sm_event_t *) packet; + printf("\nGAP Bonding %s (%u): Display cancel\n", bd_addr_to_str(sm_event->address), sm_event->addr_type); + break; + + case SM_JUST_WORKS_REQUEST: + // auto-authorize connection if requested + sm_event = (sm_event_t *) packet; + sm_just_works_confirm(sm_event->addr_type, sm_event->address); + printf("Just Works request confirmed\n"); + break; + + case SM_AUTHORIZATION_REQUEST: + // auto-authorize connection if requested + sm_event = (sm_event_t *) packet; + sm_authorization_grant(sm_event->addr_type, sm_event->address); + break; + + default: + break; + } + } +} + + void CHECK_EQUAL_ARRAY(uint8_t * expected, uint8_t * actual, int size){ int i; for (i=0; i