BM70 GATT Server Demo (Public Service)
Objective
This lab exercise will have you configure/deploy the GATT Heart Rate Service on a BM70 and update the characteristics dynamically using the appropriate op-codes. Results will be monitored via a smartphone application.
You will:
- Configure/Deploy the Heart Rate Service on a BM70 using the User Interface (UI) Configuration Tool.
- Deploy appropriate BM70 op-codes to dynamically update server characteristics using the Manual Pattern Tool.
- Monitor updated characteristic values using a smartphone application.
Reference Materials
- BM70 PICtail™ Board
- Android™ Smartphone (lab tested with BLU Advance 5.0).
- OS version 4.4 or higher
- BT 4.0 or higher hardware
- Apple® Smartphone
- OS version 5 or later
- BT 4.0 or higher hardware
- Lab 2 Configuration
- User Interface (UI) Configuration Tool
- Manual Pattern Tool
- Smart Discover app (iOS)
- Smart Discover App (Android)
Connection Diagram
Procedure
GATT Server Configuration
Place the Module in Test Mode
After connecting the PICtail board to your PC, place the module in Test Mode by setting SW7 in the ON position, then press SW5 (reset) to reset the module. Also, ensure the jumpers are all set as shown:
With Jumper JP8 shorted, LED0 will be lit (BLUE) indicating the module is in Test Mode, as shown
Load UI Configuration
Launch the UI Configuration Tool and load in the Lab2 solution configuration file (lab2p-config-solution.txt) which you obtained from the "Reference Materials" section of this page.
Edit UI Configuration
Select Edit and ensure the BLEDK3 radio button is checked with the BM70 device under Main Feature. Then press OK.
Change the Device Name
Under the Device Information section set the Name Fragment to lab3p-XXXX where XXXX are the last four digits of the BM70 MAC address. This identifier will become the GAP Service Device Name characteristic.
Add the Heart Rate Service to the GATT Table
Scroll down to the Add-On Service Table under the GATT Service Table tab, then, from the Service List pane, select/drag/drop Heart Rate Service into the blank Add-On Service Table canvas as shown:
Update Characteristic
Fully expand the Heart Rate Service attribute table by clicking on all the + signs. Right-click on Body Sensor Location declaration attribute, and select Edit.
On the Characteristic Edit Page dialog, ensure Attribute Updated and Read are checked.
Write Settings
Press Finish.
Then, to program these settings into the BM70 module click on Write. Select the COM port you are using and press Write again.
On the window that pops up, click Yes and lastly, OK as shown.
GATT Server Interaction
In the first interaction, you will:
- Establish a BLE connection between the smartphone app and the BM70
- As a BLE Client (smartphone), enable notifications on the Heart Rate Measurement characteristic
- As a BLE Server (BM70), update the characteristic using op-code 0x38 Send_Characteristic_Value
- As BLE Client, instantly see these updates appear in the app
Switch to Application Mode
Put the module in Application mode. Move dip-switch SW7 to the OFF position and reset the module by pressing SW5.
Connect to Module
Open the Manual Pattern Test Tool and connect to the COM port associated with the board.
Verify your connection by sending a 0x01:Read Local Information packet using the Common tab.
Start Advertising
Start Advertising for connection by sending a 0x1C: Set Adv Enable packet using the GAP tab with settings as shown:
Smart Discover App
Launch the Smart Discover app on the smartphone. It should start scanning for devices. Tap on your device to connect to it.
Search for Heart Rate Service
Once connected, the app will interrogate all the services and display them on the screen. Scroll down and select Heart Rate Service.
Enable Notifications
Select (tap) the Heart Rate Measurement characteristic, then enable notifications on that characteristic by toggling the Enable Notify switch to the ON position. By doing this, the app (GAP Central, GATT Client) will be able to receive updates to this characteristic as soon as the GATT Server updates it.
"Enabling Notifications" = Writing 0x0001 to the Heart Rate Measurement Client Characteristic Configuration Descriptor (CCCD) Attribute Value (Handle 0x8003 from Step 6 above). This procedure is performed by the GATT client (SmartDiscover app in this case).
Retrieve Local GATT Table
In the Manual Test Tool, go to the Local GATT Table tab and select the Get Local GATT Table button to read the GATT Table into the main view.
Expand GATT Table
You should see the fully parsed GATT Table display. Scroll down to the Heart Rate Service and click on Heart Rate Measurement value attribute, Value: 0x0000[8002], (Handle 0x8002) as shown:
Notice that the GATT Connection Handle Value (0x00) and Characteristic Handle (0x8002) are populated in the GATT R/W dialog.
Send Characteristic Value
Enter 0x00A0 as the Characteristic Value and press Send. You will see the 0x38: Send Characteristic Value packet in the Log View, and you should see the value show up immediately in the app.
Send Different Characteristic Values
The same sequence may be completed in the GATT Server tab by selecting:
- Opcode: 0x38: Send Characteristic Value,
- Connection Handle: 0x00,
- Char Value Handle: 0x8002,
- Characteristic Value: 0x00A0, and
- then press Send.
Try sending different Characteristic Values and note the immediate update on the app.
Bonus
Using either the Local GATT Table tab or the GATT Server tab, execute Opcode 0x39: Update Characteristic Value on the Body Sensor Location Characteristic (Handle: 0x8005).
This time you will need to manually poll (Read) the characteristic value in the app by tapping the Read button.
Conclusions
- Several Public GATT Services are available to be loaded into the GATT Table of the BM70
- Profiles are loaded via the UI Configuration Tool
- 2 op-codes are available to update characteristics on the server
- 0x38: Send Characteristic Value which is used for notify-enabled characteristics
- 0x39: Update Characteristic Value which is used for read-only characteristics