Different Value Types of Characteristics Example
This code example has a related User's Guide, here: Different Value Types of Characteristics.
This is the example code for the Different Value Types of Characteristics, which demonstrates below features:
- Write and read a characteristic with value type "Hex".
- Write and read a characteristic with value type "User".
- If notification to the characteristic are enabled, it sends a notification for every 3 seconds and increments the first byte.
- By searching the key word "TAG", you will easily find the place for handling the operations above.
Create a “SoC-Empty” example as the starting point
Copy attached app.c and app.h to the project overwriting the existing ones.
Open the .isc file in the project, import the GATT database, as shown in the following steps. In this example, one service and two characteristics are added into the GATT database.
- Click the "Custom BLE GATT".
- Click the "import GATT from .bgproj file" on the right side.
- Choose the gatt.xml file in the attachment and generate. Note: DO NOT FORGET THIS STEP.
Figure 1. Import GATT Database
Build and program to your board.
The example code shows where to handle the read and write requests to the characteristic with both user or hex type, as well as sending a notification every 3 seconds and incrementing the first byte. Follow the below steps to test the example:
- Use the EFR Connect app to connect.
- Try to read and write the 2 characteristics.
- Try enabling the notification to the 2 characteristics.