BLE chat
master and slave demo application
UM2264
30/55
DocID030868 Rev 1
8
BLE chat master and slave demo application
The BlueNRG-1 chat master and slave demo is supported on the SPBTLE-1S or BlueNRG-
1 development platform (STEVAL-IDB007V1 or STEVAL-IDB007V1M). It demonstrates
simple point-to-point wireless communication using a single application which configures
the chat client and server roles at runtime.
The new chat demo application configures a BlueNRG-1 BLE device as central or
peripheral using the API:
aci_gap_init(GAP_CENTRAL_ROLE|GAP_PERIPHERAL_ROLE, 0, 0x07, &service_handle,
&dev_name_char_handle, &appearance_char_handle);
It then initiates a discovery procedure for another BlueNRG-1 BLE device configured with
the same chat master and slave application image.
If such a device is found within a random interval, it starts a connection procedure and
waits until a connection is established. If the discovery procedure time expires without
finding another chat master and slave device, the device enters discovery mode and waits
for another chat master and slave device to discover and connect to it.
When connection is established, the client and server roles are defined and the chat
communication channel can be used.
This demo application exposes a single chat service with the following (20 byte max.)
characteristic values:
The TX characteristic, with which the client can enable notifications; when the server
has data to be sent, it sends notifications with the value of the TX characteristic.
The RX characteristic, is a writable characteristic; when the client has data to be sent
to the server, it writes a value in this characteristic.
The application requires two devices to be programmed with the same application, with the
server and client roles defined at runtime. Connect the two devices to a PC via USB and
open a serial terminal on both with the same configuration as
The application listens for keys typed in one device terminal and sends them to the remote
device when the return key is pressed; the remote device then outputs the received RF
messages to the serial port. Therefore, anything typed in one terminal becomes visible in
the other.
8.1
BlueNRG-1 chat master and slave roles
This section describes how two BLE chat master and slave devices interact with each other
in order to set up a point-to-point wireless chat.
The BlueNRG-1 BLE stack must first be set up on both devices by sending a series of API
commands to the processor. The chat master and slave client and server roles are defined
at runtime.
8.1.1
Initialization
The BlueNRG-1 BLE stack must be correctly initialized before establishing a connection
with another BLE device. This is done with two commands:
aci_gatt_init();
aci_gap_init(GAP_CENTRAL_ROLE|GAP_PERIPHERAL_ROLE, TRUE,0x07, &service_handle,
&dev_name_char_handle, &appearance_char_handle);