BM70 GATT Server Demo (Public Service)

Last modified by Microchip on 2023/11/09 09:03

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

This lab uses a BM70 PICtail with version 1.06 of the firmware. If you don't have v1.06, go to the Firmware Upgrade page to update your BM70 module.

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.

Back to Top


Connection Diagram

Connection Diagram showing MIcro USB from BM70 PICTail to PC

Back to Top

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:

Module in Test Mode by setting SW7 in the ON position.  Press SW5 (reset) to reset the module.

​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.

Load in the Lab2 solution configuration file

Edit UI Configuration

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

BLEDK3 radio button is checked

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.

Device Information section showing Name Fragment set

This lab exercise was developed for a classroom environment having many radios. Appending the last four 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), you should limit the name ID to fewer than eight 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).

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:

Add-On Service Table canvas

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.

Body Sensor Location declaration attribute. Select Edit

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

Characteristic Edit Page dialog: Ensure Attribute Updated and Read are checked.

Write Settings

Press Finish.

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.

Select the COM port you are using press Write

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.

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.

COM port associated with the board

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

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:

Send a 0x1C: Set Adv Enable packet using the GAP tab

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.

Smart Discover app scanning for devices

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.

Services displayed on the screen

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.

Toggle the Enable Notify switch to the ON position.

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

Local GATT Table tab and Get Local GATT Table button

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:

Parsed GATT Table display

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 Characteristic Value packet in the Log View

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.

GATT Server tab

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.

GATT Server tab

Back to Top

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