Datasheet
Dual Roles BLEUART
This example demonstrates how you can use a Feather nRF52 to connect to two other Bluefruit or BLE devices using
the bleuart (AKA 'NUS') service concurrently, with the device running at both a peripheral and a central at the same
time.
This dual role example acts as a BLE bridge that sits between a central and a peripheral forwarding bleuart messages
back and forth, as shown in the image below:
Server & Client Service Setup
Since the Bluefruit device will act as both a central and a peripheral, we will need to declare both server and client
instance of the bleuart helper class:
Before we can configure client services, Bluefruit.begin() must be called with at least 1 for the number of concurrent
connection for both peripheral and central mode:
After this, client services must be initialized by calling their begin() function, followed by any callbacks that you wish to
wire up as well:
If you are not familiar with Central Role, it is advised to look at the "Central BLEUART" example first then
continue with this afterwards.
// Peripheral uart service
BLEUart bleuart;
// Central uart client
BLEClientUart clientUart;
// Initialize Bluefruit with max concurrent connections as Peripheral = 1, Central = 1
Bluefruit.begin(1, 1);
// Configure and Start BLE Uart Service
bleuart.begin();
bleuart.setRxCallback(prph_bleuart_rx_callback);
// Init BLE Central Uart Serivce
clientUart.begin();
clientUart.setRxCallback(cent_bleuart_rx_callback);
© Adafruit Industries https://learn.adafruit.com/bluefruit-nrf52-feather-learning-guide Page 76 of 175