Transfer exisiting application nrf52840 SD 6.1.1 from Peripheral to Central and Peripheral Mode.

We do have standalone applications developed in nrf52840, SD 6.1.1 Peripheral and Central individually, and working perfect.  

Now we want to merge both applications based on our requirements. Let say based on one event My primary peripheral application should work as central and peripheral mode both simultaneously.

Background of both applications

  • Peripheral : --- This application is collecting data from on board sensor periodically and saving it to the memory, and sending those data chunks whenever central (let say Mobile app and other central device) is requesting.
  • Central :--- which scans nearby peripheral device and connects based on filters and connects to more than one peripheral sensor through BLE. After connecting it reading data from more than one peripheral. periodically.

Question I have is,

  • I want to switch the role between peripheral to central based on event frequently, how can I do that?
  • Which examples from SDK 15.3.0_59ac345 is more relevant to my application “ multirole_lesc” or “hrs_rscs_relay” from ble_central_and_peripheralàexperimental ?
  • How ble_conn_state_role(conn_handle) is switching the role in these examples? . It is not clear by tracing it down.
  • What will be the major key function need to address when we are switching between the roles.?
  • How we can assign the priority of our central and peripheral roles? I mean to say my priority here is let say peripheral role should be more important than central and when both called simultaneously than I want to perform my peripheral activity first.
Parents
  • Hello,

    As you mention, you can look at the examples in ble_central_and_peripheral for examples on how to set up a device that supports both the peripheral and central role. I think the hrs_rscs_relay is a place to start perhaps. I see that you are very concerned with the roles, peripheral and central, but in reality, there isn't really a switch saying whether you are currently a central or a peripheral. If you are advertising, then you are doing that as a peripheral, and if you are scanning, you are doing that as a central. You can start and stop the scanning from any events in your application. 

    When you are in a connection, the difference between central and peripheral will be smaller. The difference is what device that typically "owns" the services and characteristics, and hence, if you want to send a message to the other device, you need to know whether to send a notification or a write request (or something else). 

    How ble_conn_state_role(conn_handle) is switching the role in these examples? . It is not clear by tracing it down.

    This function will tell you whether you are a peripheral or central in that specific connection (the connection that this conn_handle belongs to).

    • What will be the major key function need to address when we are switching between the roles.?

    You don't really need to switch roles actively. You can start and stop advertising/scanning.

    How we can assign the priority of our central and peripheral roles? I mean to say my priority here is let say peripheral role should be more important than central and when both called simultaneously than I want to perform my peripheral activity first.

    What activities do you mean? You can handle both connections at the same time. Since the connections are time slotted, they will (most of the times) not collide. If they do collide, however, the Softdevice will handle scheduling dynamically, to maintain both connections. But I suspect this is not the type of priorities that you are talking about. Can you please elaborate?

    Best regards,

    Edvin

  •  


    Thank you for detail answer. That covers lot my confusion here. 

    Regarding priority if our softdevice is handling not to collide with communication between central and peripheral than I don't need to worry about it. 

    I see in the hrs_rscs_relay example most of the time it is remain in the BLE_GAP_ROLE_INVALID mode when not commnicating with other devices. that clears my doubt. 

    Let me try some troubleshoots over here and get back to you.

  • The reason I am asking this because in my application when it is performing central task (reading value from peripherals periodically let say every 15 seconds), it is not doing other task of (Peripheral) inbetween.

  • What exactly are these tasks? Are the peripheral tasks that are not being done in a connection, or is it advertising is it disconnecting from an existing connection? If it is in a connection, what is it supposed to to? Perhaps you have some snippets you can show?

  • Do you want me to share snippets of debug terminal?

  • That probably won't tell me much if I don't know what your application looks like. What sort of tasks do you claim that it doesn't perform when it is in "central mode"? 

    I guess that these tasks are triggered somewhere in your main.c file. Are they still being triggered when you are in "central mode"? If not, how are they usually triggered? Timer? Button handler? Other events? And why are they being blocked some times? Perhaps you are spending too much time in another interrupt with a higher (or equal) priority? Remember that interrupts can't be triggered if your application is "stuck"/waiting in another interrupt with equal or higher priority.

    Best regards,

    Edvin

  • , Yes this task are triggered when we are in "Central Mode" through the button handler kind of thing.  It might be possible that I am spending too much time in other interrupt. 

    Here it seems like my application is stuck in central task and I am triggring the interrupt event for peripheral. Not sure.

    Let me check and get back to you.!


Reply Children
No Data
Related