This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to get nRF52 to act as a central and a peripheral with FreeRTOS?

Hi Nordic DevZone,

I am currently trying to implement a system whereby a nordic nRF52 board scans and broadcasts in alternation, using freeRTOS tasks.

I have yet to find any example code that could lead me in the right direction. I was trying to start from scratch but I am having difficulties finding a way to efficiently architect the 

code in an efficient and intuitive way. Is there potentially there is a good SDK example I can base my code on?

Any input is highly appreciated.

Thanks

Parents
  • All I could find, was this example:

    https://devzone.nordicsemi.com/f/nordic-q-a/41508/sdk15-2-freertos-ble-central-and-peripheral

    If this is not sufficient, or if you would like to get a more detailed answer, please tell me and I will ask for a comment from the freeRTOS expert on the support team.

    Best regards,

    Simon

  • Hi Simon,

    I already saw this post and it wasn't as detailed as I was hoping for.

    Currently, I have two code bases where one acts as a peripheral and one acts as a central. I would like to create tasks to have the board act as both, and I would like to use a counting semaphore do to some inter-task communication, which directly controls components on the board such as an LED. 

    In short, the final goal is to have some scanner that listens to a signal (a BLE advertisment from an external source), as well as be advertising itself and allowing a characteristic in a custom service to be written to.

    I am looking for FreeRTOS compatible code that could achieve the above specifications.

    Thank you,

    Daniel

  • I haven't tried this myself, but thinking out loud.

    It does not look like this is a difficult functionality to achieve. The initialization of both roles(peripheral and central) can be done in main function without any threads stated.

    • You can have two threads, one purely handling peripheral BLE events and the other purely handling central events.
    • The events that are received n the BLE event handler and can be forwarded to corresponding threads using message queues

    Apart from that, there should not be any architectural challenges you should see related to FreeRTOS.

Reply
  • I haven't tried this myself, but thinking out loud.

    It does not look like this is a difficult functionality to achieve. The initialization of both roles(peripheral and central) can be done in main function without any threads stated.

    • You can have two threads, one purely handling peripheral BLE events and the other purely handling central events.
    • The events that are received n the BLE event handler and can be forwarded to corresponding threads using message queues

    Apart from that, there should not be any architectural challenges you should see related to FreeRTOS.

Children
No Data
Related