mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-31 00:32:52 +00:00
att_dispatch: use bool
This commit is contained in:
parent
edc4e664d5
commit
429d695f3d
@ -53,14 +53,14 @@
|
||||
|
||||
struct {
|
||||
btstack_packet_handler_t packet_handler;
|
||||
uint8_t waiting_for_can_send;
|
||||
bool waiting_for_can_send;
|
||||
} subscriptions[ATT_MAX];
|
||||
|
||||
// index of subscription that will get can send now first if waiting for it
|
||||
static uint8_t att_round_robin;
|
||||
|
||||
// track can send now requests
|
||||
static uint8_t can_send_now_pending;
|
||||
static bool can_send_now_pending;
|
||||
|
||||
static void att_packet_handler(uint8_t packet_type, uint16_t handle, uint8_t *packet, uint16_t size){
|
||||
uint8_t index;
|
||||
@ -86,8 +86,8 @@ static void att_packet_handler(uint8_t packet_type, uint16_t handle, uint8_t *pa
|
||||
can_send_now_pending = 0;
|
||||
for (i = 0; i < ATT_MAX; i++){
|
||||
index = (att_round_robin + i) & 1u;
|
||||
if (subscriptions[index].packet_handler && subscriptions[index].waiting_for_can_send){
|
||||
subscriptions[index].waiting_for_can_send = 0;
|
||||
if ( (subscriptions[index].packet_handler != NULL) && subscriptions[index].waiting_for_can_send){
|
||||
subscriptions[index].waiting_for_can_send = false;
|
||||
subscriptions[index].packet_handler(packet_type, handle, packet, size);
|
||||
// fairness: prioritize next service
|
||||
att_round_robin = (index + 1u) % ATT_MAX;
|
||||
@ -98,8 +98,8 @@ static void att_packet_handler(uint8_t packet_type, uint16_t handle, uint8_t *pa
|
||||
// check if more can send now events are needed
|
||||
if (!can_send_now_pending){
|
||||
for (i = 0; i < ATT_MAX; i++){
|
||||
if (subscriptions[i].packet_handler && subscriptions[i].waiting_for_can_send){
|
||||
can_send_now_pending = 1;
|
||||
if ((subscriptions[i].packet_handler != NULL) && subscriptions[i].waiting_for_can_send){
|
||||
can_send_now_pending = true;
|
||||
// note: con_handle is not used, so we can pass in anything
|
||||
l2cap_request_can_send_fix_channel_now_event(0, L2CAP_CID_ATTRIBUTE_PROTOCOL);
|
||||
break;
|
||||
@ -153,9 +153,9 @@ int att_dispatch_server_can_send_now(hci_con_handle_t con_handle){
|
||||
* @param con_handle
|
||||
*/
|
||||
void att_dispatch_client_request_can_send_now_event(hci_con_handle_t con_handle){
|
||||
subscriptions[ATT_CLIENT].waiting_for_can_send = 1;
|
||||
subscriptions[(uint8_t)ATT_CLIENT].waiting_for_can_send = true;
|
||||
if (!can_send_now_pending){
|
||||
can_send_now_pending = 1;
|
||||
can_send_now_pending = true;
|
||||
l2cap_request_can_send_fix_channel_now_event(con_handle, L2CAP_CID_ATTRIBUTE_PROTOCOL);
|
||||
}
|
||||
}
|
||||
@ -167,9 +167,9 @@ void att_dispatch_client_request_can_send_now_event(hci_con_handle_t con_handle)
|
||||
* @param con_handle
|
||||
*/
|
||||
void att_dispatch_server_request_can_send_now_event(hci_con_handle_t con_handle){
|
||||
subscriptions[ATT_SERVER].waiting_for_can_send = 1;
|
||||
subscriptions[(uint8_t)ATT_SERVER].waiting_for_can_send = true;
|
||||
if (!can_send_now_pending){
|
||||
can_send_now_pending = 1;
|
||||
can_send_now_pending = true;
|
||||
l2cap_request_can_send_fix_channel_now_event(con_handle, L2CAP_CID_ATTRIBUTE_PROTOCOL);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user