Central and Peripheral Role Switching and Nearby Device Discovery in nRF52832

Hi,

I am currently working on a project using the nRF52832 controller as a gateway device and the nRF52810 controller as a timer indication device.

I have successfully integrated the Timer and SAADC peripherals into the ble_app_uart/pca10040e/s112 example project from the nRF5 SDK, and flashed it onto the nRF52810-based timer indication device. The device connects with the mobile app (APK) and is able to send and receive commands.

As discussed earlier, the project has evolved, and we have added an nRF52832-based gateway device. This change requires the nRF52832 gateway device to act as both a Central and Peripheral.

Requirement :-

Initially, the nRF52832 gateway device connects with the APK and sends the list of nearby available BLE devices to the APK, acting as a Peripheral. When the APK sends a command containing the name or MAC address of the desired device, the gateway device switches from Peripheral to Central role and connects to that corresponding timer indication device. This is the core requirement of my current project.

Is there any example project available that I can start with?

Could you please guide me on the following:

  1. Is there any available example project that can demonstrate how a device can act as both a Central and a Peripheral?
  2. How can the role switching between Central and Peripheral be implemented in the nRF52832?
  3. Is there an option to retrieve a list of nearby advertised BLE devices?

Your response will be greatly appreciated.

*******************************************************************************************************************

Project Details:

  • SDK: nRF5 SDK 17.0.2
  • IDE: SEGGER Embedded Studio 5.42a
  • Controller: nRF52832

Thank you for your support.

Best regards,
SILTVM

W1 TO W9 are the timer devices 

Parents
  • Hi Stilvm, 
    Could you describe a little bit more on your application ? How many time indicators you have ? What's the distribution in distance between them and the gateway ? 
    If all is in the range of one single gateway you may not need multiple gateway. Also you may think of having a mesh network if the device is not running on a battery. 

    Regarding your questions: 

    Is there any available example project that can demonstrate how a device can act as both a Central and a Peripheral? 

    yes, please take a look at the examples in \examples\ble_central_and_peripheral\experimental , maybe the best fit would be the \ble_app_hrs_rscs_relay

    How can the role switching between Central and Peripheral be implemented in the nRF52832?

    You can switch between roles or you can have both roles at the same time with no problem. The stack can handle multiple connections at the same time regardless if it's central role or peripheral role

    Is there an option to retrieve a list of nearby advertised BLE devices?

    You can listen to the BLE_GAP_EVT_ADV_REPORT when scanning and can parse the advertising packets to get the name, address. Please take a look at the \examples\ble_central\experimental\ble_app_hrs_nfc_c , in ble_m.c you can find how the advertising packets are parsed in on_adv_report(): 
     

  •  , I see the example project ble_app_hrs_rscs_relay available in the BLE central and peripheral SDK directory, but when I try to build the code, an error occurs initially. I am attaching a screenshot for better understanding

  • Hi Siltvm, 
    It seems that the path is too long. Please try to copy the SDK to a folder near C:\ . You can rename the SDK folder from nRF5_SDK_17.0.2_dd674de to for example SDK1702. Windows only allow max length of the path to 250 characters. 

    I don't see a problem with your set-up. Note that the gateway doesn't have to connect to all the watches at the same time. It can connect, read data and disconnect to connect to more device. This way even if you have more than 20 watches you still can get data from all of them. Of course if you have less than 20, you can just keep connections and don't have to do connect-disconnect. 

    If you keep the connection, avoid using too short connection interval. Try 100ms and higher. 

  • hi ,   . 

    I changed the path as per your suggestion, so the error is resolved, and I am able to build the code. I just have a question on how to implement multirole meaning central and peripheral at the same time

Reply Children
Related