sm, att_server: don't forward events from lower layers.

This commit is contained in:
Matthias Ringwald 2016-02-04 16:47:17 +01:00
parent 406722e45a
commit 65b44ffd3b
4 changed files with 14 additions and 11 deletions

View File

@ -82,6 +82,7 @@ static const uint8_t adv_data[] = {
};
static uint8_t adv_data_len = sizeof(adv_data);
static btstack_packet_callback_registration_t hci_event_callback_registration;
static btstack_packet_callback_registration_t sm_event_callback_registration;
static void app_packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
switch (packet_type) {
@ -147,6 +148,10 @@ int btstack_main(int argc, const char * argv[]){
sm_set_io_capabilities(IO_CAPABILITY_DISPLAY_ONLY);
sm_set_authentication_requirements( SM_AUTHREQ_BONDING );
// register for SM events
sm_event_callback_registration.callback = &hci_event_handler;
hci_add_event_handler(&sm_event_callback_registration);
// setup ATT server
att_server_init(profile_data, NULL, NULL);
att_server_register_packet_handler(app_packet_handler);

View File

@ -191,9 +191,6 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
break;
}
}
// if (client_packet_handler){
// (*client_packet_handler)(packet_type, channel, packet, size);
// }
}
static void extract_service(le_service_t * service, uint8_t * packet){

View File

@ -199,7 +199,6 @@ static void att_event_packet_handler (uint8_t packet_type, uint16_t channel, uin
att_ir_le_device_db_index = -1;
att_run();
break;
case SM_EVENT_AUTHORIZATION_RESULT: {
if (packet[4] != att_client_addr_type) break;
bt_flip_addr(event_address, &packet[5]);
@ -208,13 +207,12 @@ static void att_event_packet_handler (uint8_t packet_type, uint16_t channel, uin
att_run();
break;
}
default:
break;
}
}
if (att_client_packet_handler){
att_client_packet_handler(packet_type, channel, packet, size);
break;
default:
break;
}
}

View File

@ -2012,10 +2012,13 @@ static void sm_event_packet_handler (uint8_t packet_type, uint8_t *packet, uint1
sm_handle_random_result(&packet[6]);
break;
}
break;
default:
break;
}
// forward packet to higher layer
sm_dispatch_event(packet_type, 0, packet, size);
break;
default:
break;
}
sm_run();