Hi Nikolas
BTstack is single-thread by design, so its API should only be called from the main / Bluetooth thread.
In that case, nothing will happen if you poll att_server_can_send_packet_now() - in fact, I would expect it to block/hang forever.
To send a notification, please request a callack with att_server_request_to_send_notification and send it from the callback.
To send an indication, please request a callback with att_server_request_to_send_indication and send it from the callback.
If you follow this scheme, all notifications and indications should be delivered correctly.
Cheers
Matthias
> On 21 Mar 2025, at 10:45, 'Nikolas von Lonski' via btstack-dev <
btsta...@googlegroups.com> wrote:
>
> Hi,
> We recently update from Pico-SDK 1.7 to 2.1.1
>
> As it turns out there must have been some change somewhere in the mix which broke the way our BLE implementation worked.
>
> The way we schedule our notifications/indications is as follows:
> while ( !l_notification_scheduler.force_quit ) {
> // Wait for a pending notification
> if (!DECREMENT_NOTIFICATION_COUNT(NOTIFICATION_POLL_RATE_MS)) {
> // We don't have any pending notifications
> continue;
> }
>
> // Wait for a notification slot
> DECREMENT_SLOT_COUNT();
>
> while ( !l_notification_scheduler.force_quit &&
> !att_server_can_send_packet_now(l_context_ptr->connection.handle) ) {
> vTaskDelay(pdMS_TO_TICKS(5));
> }
>
> if ( l_notification_scheduler.force_quit ) {
> INCREMENT_SLOT_COUNT();
> continue; // while loop check will exit
> }
>
> // Request a notification slot
> att_server_request_can_send_now_event(l_context_ptr->connection.handle);
> }
>
> We have various notifications competing for radio time and of course writes can also take place.
>
> In the previous version we never had an issue with indications simply getting lost. In the current version this appears to be the case.
>
> Now there are multiple updates that are interrwined. Upgrade to RTOS v11 main from the smp branch.
> Update to the next major Pico-SDK (with minors).
> Update of the BTStack. All of them needing to be updated at the same time.
>
>
> My intutition tells me it's some kind of scheduling issue with the BTStack.
>
> What do you think?
>
> --
> You received this message because you are subscribed to the Google Groups "btstack-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
btstack-dev...@googlegroups.com.
> To view this discussion visit
https://groups.google.com/d/msgid/btstack-dev/e5410c46-d78a-414b-8713-ab5a15fc965an%40googlegroups.com.