Datasheet
Central BLEUART
This example show you how to use Feather nRF52 as a Central to talk to other Bluefruit (nRF52 or nRF51) peripherals
exposing the bleuart (AKA 'NUS') service.
Client Services
Since the Central role accesses the GATT server on the peripheral, we first need to declare a client bleuart instance
using the BLEClientUart helper class. We can also conveniently read Device Information if BLEClientDis is also used.
Before we can configure client services, Bluefruit.begin() must be called with at least 1 for the number of concurrent
connections supported in central mode. Since we won't be running the nRF52 as a peripheral in this instance, we will
set the peripheral count to 0:
Afterward this, the client service(s) must be initialized by calling their begin() function, and you can setup any callbacks
that you wish to use from the helper class:
Scanner
Let's start the advertising scanner to find a peripheral.
We'll hook up the scan result callback with setRxCallback().
Whenever advertising data is found by the scanner, it will be passed to this callback handler, and we can examine the
advertising data there, and only connect to peripheral(s) that advertise the bleuart service.
Note: If the peripheral has multiple services and bleuart is not included in the UUID list in the advertising packet, you
could optionally use another check such as matching the MAC address, name checking, using "another service", etc.
Once we find a peripheral that we wish to communicate with, call Bluefruit.Central.connect() to establish connection with
it:
BLEClientDis clientDis;
BLEClientUart clientUart;
// Initialize Bluefruit with maximum connections as Peripheral = 0, Central = 1
Bluefruit.begin(0, 1);
// Configure DIS client
clientDis.begin();
// Init BLE Central Uart Serivce
clientUart.begin();
clientUart.setRxCallback(bleuart_rx_callback);
© Adafruit Industries https://learn.adafruit.com/bluefruit-nrf52-feather-learning-guide Page 70 of 175