This section provides a description
of how to use the demo application to connect two configured boards and communicate
over Bluetooth. The Bluetooth Heart Rate Service (HRS) is a simple Client-Server
connection process. We will setup one of the boards as a Server and the other board
as a Client. We will then initiate a connection from the Client to the Server. Once
connected, we can transmit data between the two devices over Bluetooth.
Server
setup on the demo application
- We will setup the first board as a Server. Note the Bluetooth address of the
Server; we will later use this to initiate a connection from the Client.
- Two commands are all that is needed to setup the Server. The first is
RegisterHRS, so issue the RegisterHRS 1 command.
- Now use the AdvertiseLE command
by issuing the AdvertiseLE 1 command.
Initiating connection from the ClientNote: Steps 1 and 2 are optional if you
already know the Bluetooth address of the device that you want to connect
to.
- The Client LE device can try to find which LE devices are in the vicinity
issuing the command: StartScanning.
- Once you have found the device,
you can stop scanning by issuing the command: StopScanning
- Retrieve the Bluetooth address of the first board that was configured as a
Server.
- Issue a ConnectLE <BD_ADDR of Server> command in the Client terminal.
- When a Client successfully
connects to a Server, both the Client and Server will output
LE_Connection_Complete and information about the current connection.
Sending Heart Rate Information between Client and Server
- Now we have a connection established and both devices are ready to send data to
each other.
- Before heart rate information can be sent we must first initialize commands in
the Client terminal.
- The two commands are DiscoverHRS and ConfigureRemoteHRS, so issue the command
DiscoverHRS 1. A list of supported services should be displayed.
- Now issue the ConfigureRemoteHRS
1 command. If the configuration succeeds information about the CCCD
configuration will be displayed in the Client and Server terminals.
- To send information about the heart rate, use the NotifyHeartRate command in the
Server terminal. The parameters for the NotifyHeartRate command are [HR (BPM)]
[HR Format (0 = Byte, 1 = Word)] [Sensor Contact Status (0 = Not Supported, 1 =
Supported/Not Detected, 2 = Supported/Detected] [Energy Expended (0 = Don't
send, 1 = Send)] [RR Intervals (0 = None, X = Number of Intervals)]. Use the
parameters 80 1 2 1 0 after the command.
- Information about the heart rate
should now be sent to the Client and be displayed in the Client terminal.
Setting a local appearance on the Server and checking that appearance from the
Client
- In the Server terminal set the type of device with the command
SetLocalAppearance and the parameter [index]. There are over 20 types of devices
in the index, to look at them type first enter only SetLocalAppearance.
- Now use the DiscoverGAPS command in the Client terminal.
- Lastly enter GetRemoteAppearance in the Client terminal to see what type of
device the Server had been set to.
Setting the location of the heart rate sensor on the Server and reading it from
the Client
- In the Server terminal set the location of the heart rate sensor with the
command SetBodySensorLocation [type]. Type = 0 – Other, 1 – Chest, 2 – Wrist, 3
– Finger, 4 – Hand, 5 - Ear Lobe, 6 – Foot.
- To see the location of the heart rate sensor type GetBodySensorLocation in the
Client terminal.