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.

Note: There are two handles referenced for characteristic C503.

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:

  1. Use the Server Handle Write (SHW) and Server 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 handle 1002. Then, the previously written value (1133) is overwritten to 1122.
      Figure 7-25. Writing and Reading GATT Value by Handle Reference
  2. 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.
  3. 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”.
      Figure 7-26. Unknown Service
    • Tap to select the “Unknown Characteristics” with UUID bf3fbd80-063f-11e5-9e69-0002a-5d5c501.
      Figure 7-27. Unknown Characteristics
    • Tap Read. The characteristic value is read from the RNBD451 module into the Microchip Bluetooth Data application.
      Figure 7-28. Reading the Characteristic Value from the RNBD451 Module

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.

Perform the following steps to write a value to the GATT characteristic C503:
  1. Tap ˅ to select the service with UUID 4D6963726F636869702D524E34383730. Three characteristics created under the service are visible on the mobile screen.
    Figure 7-29. List of Available Services
  2. Click the characteristics with UUID BF3FBD80063F11E59E690002A5D5C503.
    Figure 7-30. Selected Specific Characteristics for Write Operation
  3. Turn ON the “Enable Notify/Indicate”.
    Figure 7-31. Enable Notify/Indicate for Characteristic
  4. 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.
    Figure 7-32. Write 4 Bytes of Value to the Characteristic
  5. 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 handle 1006.
    Figure 7-33. Output