Skip to content

Commit 1dab9fd

Browse files
committed
att_dispatch: fix bug in round robin between
1 parent 0fbf59a commit 1dab9fd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/ble/att_dispatch.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,16 @@ static void att_packet_handler(uint8_t packet_type, uint16_t handle, uint8_t *pa
8181
if (subscriptions[index].packet_handler && subscriptions[index].waiting_for_can_send){
8282
subscriptions[index].waiting_for_can_send = 0;
8383
subscriptions[index].packet_handler(packet_type, handle, packet, size);
84-
// fairness
85-
att_round_robin = 1 - index;
84+
// fairness: prioritize next service
85+
att_round_robin = (index + 1) % ATT_MAX;
8686
// stop if client cannot send anymore
8787
if (!hci_can_send_acl_le_packet_now()) break;
8888
}
8989
}
9090
// check if more can send now events are needed
9191
if (!can_send_now_pending){
9292
for (i = 0; i < ATT_MAX; i++){
93-
if (subscriptions[index].waiting_for_can_send){
93+
if (subscriptions[i].waiting_for_can_send){
9494
can_send_now_pending = 1;
9595
// note: con_handle is not used, so we can pass in anything
9696
l2cap_request_can_send_fix_channel_now_event(0, L2CAP_CID_ATTRIBUTE_PROTOCOL);

0 commit comments

Comments
 (0)