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.

 Materials

Hardware Tools

  • BM70 PICtail
  • 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

Software Tools

Be sure to install the MCP2200 USB drivers before starting. Also, download/extract the UI Configuration Tool as well as the Manual Pattern Test Tool to your PC using the links above.

Exercise Files

File Download
Installation
Instructions
Windows Linux Mac OSX
Lab 2 Configuration

 Connection Diagram

ConnectionDiagram.png

 Procedure

GATT Server Configuration

1

Place the Module in Test Mode

After connecting the PICtail 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:

BM70Update.png

With Jumper JP8 shorted, LED0 will be lit (BLUE) indicating the module is in Test Mode, as shown above.

2

Load UI Configuration

Launch the UI Configuration Tool (found in the Software Tools section above) and load in the Lab2 solution configuration file (lab2p-config-solution.txt) which you obtained from the Exercise Files section of this page.

NewUILoad.png

3

Edit UI Configuration

Select Edit and ensure the BLEDK3 radio button is checked with BM70 device under Main Feature. Then press OK.

BLEDK3withBM70.png

4

Change the Device Name

Under the Device Information section set the Name Fragment to lab3p-XXXX where XXXX are the last 4 digits of the BM70 MAC address. This identifier will become the GAP Service Device Name characteristic.

NameFragmentLab3.png

This Lab exercise was developed for a classroom environment having many radios. Appending the last 4 digits of the MAC address to the Device Name aids in identifying a specific board during advertising.

The device name should be unique. Also, since the advertising packet is pretty small (31 byte max. payload), suggest you limit the name ID to fewer than 8 characters (i.e. for the 10-character device name shown, if you try to add a 16-byte private service to the ADV payload, you will get an error message).

5

Add the Heart Rate Service to the GATT Table

Scroll down to the Add-on Service box under the GATT Service Table tab, then, from the Service List box, select/drag/drop Heart Rate Service into the blank Add-On Service Table canvas as shown:

AddOnService.png

6

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.

UpdateCharacteristic.png

On the Characteristic Edit Page dialog, ensure Attribute Updated and Read are checked.

CharEditPage.png

7

Write Settings

Press Finish.

Write.png

Then, to program these settings into the BM70 module click on Write. Select the COM port you are using and press Write again.

WriteSettings2.png

On the window that pops up, click Yes and lastly, OK as shown above.

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

8

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.

Switch.png

9

Connect to Module

Open the Manual Pattern Test Tool and connect to the COM port associated with the board.

ManualConnection.png

Verify your connection by sending a 0x01:Read Local Information packet using the Common tab.

ReadLocalInfo.png

10

Start Advertising

Start Advertising for connection by sending a 0x1C: Set Adv Enable packet using the GAP tab with settings as shown below:

EnterStandby.png

11

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.

ScanAndroid.png

12

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.

HRSAndroid.png

13

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.

EnableNotificationsAndroid.png

"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).

14

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.

LocalGATTTable.png

15

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 (Handle 0x8002) as shown below.

GATTTable.png

Notice that the GATT Connection Handle Value (0x00) and Characteristic Handle (0x8002) are populated in the GATT R/W dialog.

16

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.

CharValueAndroid.png

17

Send Different Characteristic Values

The same sequence may be completed in the GATT Server tab by selecting Opcode 0x38, Connection Handle 0x00, Char Value Handle 0x8002, and Characteristic Value 0x00A0 and then pressing Send.

UpdateChar.png

Try sending different Characteristic Values and note the immediate update on the app.

18

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.

UpdateCharValueAndroid.png

 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
© 2016 Microchip Technology, Inc.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.