7.3.2 Accessing the GATT Service Using UART Commands and the Microchip Bluetooth Data Application
The result of the List Service
command (LS
command)
shows a custom GATT service (UUID: 4D6963726F636869702D524E34383730
)
with three characteristics identified by low order bytes C501, C502, C503 from the
128-bit UUID. Each characteristic is assigned a 16-bit handle (1002, 1004,1006,1007 [see
Figure 7-24]). Use handles to efficiently reference and identify characteristics
in the GATT service. A 16-bit handle is easier to manage than a 128-bit UUID.
As indicated by the 08 property value in 1006 for characteristic C503, this characteristic has the write property enabled. In the same way, reference 1007, has the notification property 10 enabled. This means that to write a value on characteristics C503, use reference 1006. To enable client notifications on this characteristic, use reference 1007.
The following examples show how to read and write the GATT characteristics value by using UART commands on the local GATT server device and how to read the value from the remote GATT client (Microchip Bluetooth Data application) through the Bluetooth Low Energy link:
- Use the
Server Handle Write
(SHW
) andServer Handle Read
(SHR
) commands to read and write values to specific characteristics using assigned handle numbers.- Command format:
SHW, <handle>,<hex byte value>
- In the following
reference, example value
1133
is written to handle1002
. Then, the previously written value (1133
) is overwritten to1122
.
- Command format:
- It is also possible to access the GATT server over the Bluetooth Low Energy connection using the Microchip Bluetooth Data application. Launch the Microchip Bluetooth Data application and connect to the RNBD451 board. For more details, refer to 7.1 Connecting to the RNBD451 Module Using the Microchip Bluetooth Data Application.
- The following are the steps to
read the value of GATT characteristic
bf3fbd80-063f-11e5-9e69-0002a-5d5c501
.- Tap ˅ to select
the service with UUID
4D6963726F636869702D524E34383730
listed as “Unknown Service”. - Tap to select the
“Unknown Characteristics” with UUID
bf3fbd80-063f-11e5-9e69-0002a-5d5c501
. - Tap Read. The characteristic value is read from the RNBD451 module into the Microchip Bluetooth Data application.
- Tap ˅ to select
the service with UUID
The following example shows how to write a value to a GATT characteristic from the
Microchip Bluetooth Data application, and how to read and verify the same at the device
side using the UART
command.
- Tap ˅ to select the
service with UUID
4D6963726F636869702D524E34383730
. Three characteristics created under the service are visible on the mobile screen. - Click the characteristics with
UUID
BF3FBD80063F11E59E690002A5D5C503
. - Turn ON the “Enable Notify/Indicate”.
- From the “Write” option, type a 4-byte value, then tap Write. The notification is enabled for this characteristic; therefore, a notification for the value is automatically generated and is available under the read section.
- Read the characteristic value at
the device side using the
SHR
command, and verify whether the value written from the mobile application took effect for the handle1006
.