att_dispatch: extract att_dispatch_classic_get_l2cap_cid

This commit is contained in:
Matthias Ringwald 2023-07-02 11:17:06 +02:00
parent eb65899c12
commit 0cd55b6c9f

View File

@ -128,15 +128,24 @@ void att_dispatch_register_server(btstack_packet_handler_t packet_handler){
l2cap_register_fixed_channel(att_packet_handler, L2CAP_CID_ATTRIBUTE_PROTOCOL);
}
static bool att_dispatch_can_send_now(hci_con_handle_t con_handle) {
#ifdef ENABLE_GATT_OVER_CLASSIC
static uint16_t att_dispatch_classic_get_l2cap_cid(hci_con_handle_t con_handle){
// get l2cap_cid from att_server in hci_connection
hci_connection_t * hci_connection = hci_connection_for_handle(con_handle);
if (hci_connection != NULL){
uint16_t l2cap_cid = hci_connection->att_server.l2cap_cid;
if (l2cap_cid != 0){
return l2cap_can_send_packet_now(l2cap_cid);
}
if (hci_connection != NULL) {
return hci_connection->att_server.l2cap_cid;
} else {
return 0;
}
}
#endif
static bool att_dispatch_can_send_now(hci_con_handle_t con_handle) {
#ifdef ENABLE_GATT_OVER_CLASSIC
uint16_t l2cap_cid = att_dispatch_classic_get_l2cap_cid(con_handle);
if (l2cap_cid != 0){
return l2cap_can_send_packet_now(l2cap_cid);
}
#endif
return l2cap_can_send_fixed_channel_packet_now(con_handle, L2CAP_CID_ATTRIBUTE_PROTOCOL);