On 8/10/2020 10:53:03 PM, Matthias Ringwald <matthias...@gmail.com> wrote:
Hi Martin
The BTstack examples should work if you create a new thread and call bststack_init, btstack_main, and btstack_run_loop_execute on that thread with/without debug output.
In general, BTstack isn't thread-safe, so you cannot call any function from a different thread. However, you can call btstack_run_loop_freertos_execute_code_on_main_thread(..) to request a callback from the BTstack thread, and e.g. use a queue or just some global flags to trigger your application Bluetooth logic.
Best
Matthias
> On 8 Oct 2020, at 10:35, Martin Slater wrote:
>
> I have succeeded in getting it to run correctly within another task but weirdly only if ENABLE_LOG_DEBUG is enabled in btstack_config.h which seems to suggest a synchronisation issue and the resulting printf are adding sync points that make it work. I will restructure the app to support the builtin runloop structuring and see what that does.
>
> Martin
> On Thursday, 8 October 2020 at 18:17:42 UTC+11 Martin Slater wrote:
> Hi there,
> I am integrating BTStack into an existing application running on an ESP32. Thiis app already has a main run loop and I am trying to get btstack to play nice and not block this main thread. If I just do the initialisation and call btstack_run_loop_execute() then it behaves as expected and my test device is discoverable but this obviously blocks the calling thread.
>
> I have tried moving all the initialisation to another task and calling btstack_run_loop_execute() from there but then it does not work correctly. I can see a lot of info around the freertos runloop but cannnot find any example of using it in a multithreaded or non-blocking way. Can someone point me to how to get this working on another task or how to solve this?
>
> thanks
>
> Martin
>
> --
> 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 on the web visit https://groups.google.com/d/msgid/btstack-dev/321d2415-a8f5-47e9-a2f5-5bd2fb69faf6n%40googlegroups.com.
--
You received this message because you are subscribed to a topic in the Google Groups "btstack-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/btstack-dev/UnSkv6Bxxhs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to btstack-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/btstack-dev/5416A88F-4C74-4518-8B91-4B392E4CE382%40gmail.com.