Central which can connect and communicate with all kinds peripheral

Hi

      I want to use nrf52840 to develop a central like figure below,the central can connect and communicate with all kinds of peripheral. Is there a reference example?

Parents
  • Hello,

    You can scan to see what devices that are advertising nearby, and based on the advertisements, decide who you want to connect to. But how do you want to make this decision during runtime?

    Best regards,

    Edvin

  • Hi

           

            Sorry,Because  various peripherals have different servers inside.The central which I want to realize can connect and communicate with various peripherals,The central can discover any server in any peripheral,It is similar to how nrf connect app conncts and communicates with a peripheral .what I need is the implementation of code ,Is there a reference example?

    decisio
  • I think I understand, but the issue is that in your case, you would just connect to the first device you would receive an advertisement from then, right?

    Do you intend to run this from a computer, like nRF Connect for Desktop does in your screenshot, or is this a standalone device?

    helen said:
    various peripherals have different servers inside.The central which I want to realize can connect and communicate with various peripherals

    If you look at one of our central examples, like the central_uart sample found in NCS\nrf\samples\bluetooth\central_uart, you can see how it calls 

    bt_gatt_dm_start() in gatt_discover() in main.c.
    If you look at the declaration from gatt_dm.h, you can see that the 2nd input parameter can either be the UUID of the target service, or NULL if any service should be discovered. Perhaps that is what you are looking for?
    helen said:

    Is there a reference example?

    Sorry, we do not have any reference examples that connects to any peripheral like you describe above. I am sorry.

    Best regards,

    Edvin

Reply
  • I think I understand, but the issue is that in your case, you would just connect to the first device you would receive an advertisement from then, right?

    Do you intend to run this from a computer, like nRF Connect for Desktop does in your screenshot, or is this a standalone device?

    helen said:
    various peripherals have different servers inside.The central which I want to realize can connect and communicate with various peripherals

    If you look at one of our central examples, like the central_uart sample found in NCS\nrf\samples\bluetooth\central_uart, you can see how it calls 

    bt_gatt_dm_start() in gatt_discover() in main.c.
    If you look at the declaration from gatt_dm.h, you can see that the 2nd input parameter can either be the UUID of the target service, or NULL if any service should be discovered. Perhaps that is what you are looking for?
    helen said:

    Is there a reference example?

    Sorry, we do not have any reference examples that connects to any peripheral like you describe above. I am sorry.

    Best regards,

    Edvin

Children
  • The central can receive advertisements like nrf connect desktop and connect to a peripheral which the user need like nrf connect desktop.The central connect to peripheral by one to one like nrf connect desktop.

    The central is a standalone device that receive command through uart to control the central to scan,connect,disconnect,read,write a peripheral like nrf connect desktop.

    Yes,I also use commands which from uart to get the central connect or disconnect to the peripheral I want and to get the central to read,write and enable the characteristics in the server of the peripheral like nrf connect desktop.

    Could you list apis about these operation?Or Could you share the source code which is downloaded  to nrf52840 by the Bluetooth Low Energy app in the nRF Connect Desktop?

  • nRF Connect for Desktop uses (a slightly modified version) of the example found in nRF5_SDK\examples\connectivity\ble_connectivity). 

    This is basically a serialized softdevice application, meaning that all the softdevice calls that would normally be triggered from the application on the nRF52 and handled by the softdevice is instead triggered by UART from a connected device (computer), and handled by the softdevice. The replies are then reported back over UART. 

    nRF Connect for Desktop is built on top of something called pc-ble-driver, which is a c++ based SDK running on a computer, triggering the softdevice via serial. 

    Unfortunately, nRF Connect for Desktop -> Bluetooth Low Energy is not open source, so I don't have anything I can share with you. 

    You need to decide whether you want to start with pc-ble-driver, or if you would like to write your own UART protocol. If you want to write your own uart protocol, you need to find a way to extract arguments from the UART messages (used to decide what peripheral to connect to, enable/disable notifications, etc.). Unfortunately, we don't have any guides on how to do this. 

    Best regards,

    Edvin

Related