5 years, 2 months ago.

Can I have the nrf52-dk acting as BLE Server and client simultaneously?

Hi,

I would to know if the nrf52-dk could run as BLE Server and Client GATT in the same code.

For example, It starts acting as Server with a advertaising, waiting for a characterictic to be written and when this occurs to switch to Client role, scanning to look for other Server GATT node.?

Regards, Adrian.

Hi Adrian,

I am not sure I understand this question clearly, let me try to clarify more.

Are you meaning after the device connected to a master as a Server, the device will do scan for another GATT Server?

Desmond, team mbed

posted by Desmond Chen 11 Feb 2019

Hi Desmond,

Let me clarify it a little bit. I want the same board to be both the GATT Server (defining our own custom services, characteristics, etc) in order to allow other devices to connect to this board and write data to the server characteristics, and as a GATT Client. And by client I mean this board should also be able to scan and connect to a 3rd board featuring a GATT Server and then connect to it and write some info. This behavior should change periodically following a time-window for each role.

Do you think this is possible? If so, could you give me some guidance to achieve it?

Thank you,

Adrian

posted by Adrian Humanes 12 Feb 2019

1 Answer

5 years, 2 months ago.

Hi Adrian,

Using the same board as a GATT Server and GATT Client simultaneously is possible, but I am sorry we don't have an example to show this capability.

Basically, you need to declare two BLE service objects and setup the event functions, callback functions, and scan for the first connection. After the first connection established, which means in the connection complete event, do advertising for the second connection, both connections can be maintained well.

And for usage of GATT Server and client, you can refer to our documentation here.

https://os.mbed.com/docs/mbed-os/v5.11/apis/gattclient.html

https://os.mbed.com/docs/mbed-os/v5.11/apis/gattserver.html

Or, you can look into our example LED Blinker/LED

https://github.com/ARMmbed/mbed-os-example-ble/tree/master/BLE_LEDBlinker

https://github.com/ARMmbed/mbed-os-example-ble/tree/master/BLE_LED

They are basic GATT examples and they can be extended easily.

Please feel free to ask me any questions!

Desmond, team Mbed