mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-26 12:35:25 +00:00
att_dispatch: don't forward HCI Events to ATT Server. ATT Server registers for HCI Events
This commit is contained in:
parent
361b1363b7
commit
1a389cdc72
@ -50,24 +50,9 @@ static void dummy_packet_handler(uint8_t packet_type, uint16_t handle, uint8_t *
|
|||||||
static btstack_packet_handler_t att_client_handler = &dummy_packet_handler;
|
static btstack_packet_handler_t att_client_handler = &dummy_packet_handler;
|
||||||
static btstack_packet_handler_t att_server_handler = &dummy_packet_handler;
|
static btstack_packet_handler_t att_server_handler = &dummy_packet_handler;
|
||||||
|
|
||||||
static btstack_packet_callback_registration_t hci_event_callback_registration;
|
|
||||||
|
|
||||||
static int registered_for_hci_events = 0;
|
|
||||||
|
|
||||||
static void dummy_packet_handler(uint8_t packet_type, uint16_t handle, uint8_t *packet, uint16_t size){
|
static void dummy_packet_handler(uint8_t packet_type, uint16_t handle, uint8_t *packet, uint16_t size){
|
||||||
}
|
}
|
||||||
|
|
||||||
static void att_hci_event_handler(uint8_t packet_type, uint8_t * packet, uint16_t size){
|
|
||||||
att_server_handler(packet_type, 0, packet, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void att_dispatch_register_for_hci_events(void){
|
|
||||||
if (registered_for_hci_events) return;
|
|
||||||
registered_for_hci_events = 1;
|
|
||||||
hci_event_callback_registration.callback = &att_hci_event_handler;
|
|
||||||
hci_add_event_handler(&hci_event_callback_registration);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void att_packet_handler(uint8_t packet_type, uint16_t handle, uint8_t *packet, uint16_t size){
|
static void att_packet_handler(uint8_t packet_type, uint16_t handle, uint8_t *packet, uint16_t size){
|
||||||
if (packet_type != ATT_DATA_PACKET) return;
|
if (packet_type != ATT_DATA_PACKET) return;
|
||||||
|
|
||||||
@ -87,7 +72,6 @@ static void att_packet_handler(uint8_t packet_type, uint16_t handle, uint8_t *pa
|
|||||||
* @param packet_hander for ATT client packets
|
* @param packet_hander for ATT client packets
|
||||||
*/
|
*/
|
||||||
void att_dispatch_register_client(btstack_packet_handler_t packet_handler){
|
void att_dispatch_register_client(btstack_packet_handler_t packet_handler){
|
||||||
att_dispatch_register_for_hci_events();
|
|
||||||
if (packet_handler == NULL){
|
if (packet_handler == NULL){
|
||||||
packet_handler = dummy_packet_handler;
|
packet_handler = dummy_packet_handler;
|
||||||
}
|
}
|
||||||
@ -100,7 +84,6 @@ void att_dispatch_register_client(btstack_packet_handler_t packet_handler){
|
|||||||
* @param packet_hander for ATT server packets
|
* @param packet_hander for ATT server packets
|
||||||
*/
|
*/
|
||||||
void att_dispatch_register_server(btstack_packet_handler_t packet_handler){
|
void att_dispatch_register_server(btstack_packet_handler_t packet_handler){
|
||||||
att_dispatch_register_for_hci_events();
|
|
||||||
if (packet_handler == NULL){
|
if (packet_handler == NULL){
|
||||||
packet_handler = dummy_packet_handler;
|
packet_handler = dummy_packet_handler;
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ static int att_ir_lookup_active = 0;
|
|||||||
|
|
||||||
static int att_handle_value_indication_handle = 0;
|
static int att_handle_value_indication_handle = 0;
|
||||||
static btstack_timer_source_t att_handle_value_indication_timer;
|
static btstack_timer_source_t att_handle_value_indication_timer;
|
||||||
|
static btstack_packet_callback_registration_t hci_event_callback_registration;
|
||||||
static btstack_packet_handler_t att_client_packet_handler = NULL;
|
static btstack_packet_handler_t att_client_packet_handler = NULL;
|
||||||
|
|
||||||
static void att_handle_value_indication_notify_client(uint8_t status, uint16_t client_handle, uint16_t attribute_handle){
|
static void att_handle_value_indication_notify_client(uint8_t status, uint16_t client_handle, uint16_t attribute_handle){
|
||||||
@ -355,10 +355,20 @@ static void att_packet_handler(uint8_t packet_type, uint16_t handle, uint8_t *pa
|
|||||||
att_run();
|
att_run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void att_event_packet_handler2(uint8_t packet_type, uint8_t * packet, uint16_t size){
|
||||||
|
att_event_packet_handler(packet_type, 0, packet, size);
|
||||||
|
}
|
||||||
|
|
||||||
void att_server_init(uint8_t const * db, att_read_callback_t read_callback, att_write_callback_t write_callback){
|
void att_server_init(uint8_t const * db, att_read_callback_t read_callback, att_write_callback_t write_callback){
|
||||||
|
|
||||||
|
// register for HCI Events
|
||||||
|
hci_event_callback_registration.callback = &att_event_packet_handler2;
|
||||||
|
hci_add_event_handler(&hci_event_callback_registration);
|
||||||
|
|
||||||
|
// SM events
|
||||||
sm_register_packet_handler(att_event_packet_handler);
|
sm_register_packet_handler(att_event_packet_handler);
|
||||||
|
|
||||||
|
// and L2CAP ATT Server PDUs
|
||||||
att_dispatch_register_server(att_packet_handler);
|
att_dispatch_register_server(att_packet_handler);
|
||||||
|
|
||||||
att_server_state = ATT_SERVER_IDLE;
|
att_server_state = ATT_SERVER_IDLE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user