GAP Peripheral Demo (Making Connections)

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

Objective

This lab exercise will have you configure, then explore, Generic Access Profile (GAP) discovery and connection procedures on a BM70 configured as a GAP Peripheral, using a BM-70-PICtail™ board.

You will:

  • Configure key static module configuration settings using the User Interface (UI) Configuration Tool (Device Name, Pinout, Operation mode, Default ADV & SCAN_RSP packet payload data & interval, LED0 etc.)
  • Dynamically trigger GAP Discovery modes/procedures via BM70 OP codes using the Manual Pattern Test Tool
  • Interact with the board using a Smartphone app

Back to Top

Reference Materials

  • 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

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 using micro USB from BM70 PICTail to PC

Back to Top

Manual Pattern Flow Chart

For this example, the BM70 is configured to operate in Manual Pattern mode (i.e. a Generic Bluetooth® Low Energy BLE Link Controller). The following flow chart depicts the operation:

Manual Pattern Flow Chart

Back to Top

Procedure

Peripheral Configuration

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:

Swithc SW7 to the ON position, then 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 above.


Launch the UI Configuration Tool

Open the BLEDK3 UI Configuration Tool and load the default BM70 configuration file: IS1870SF_102_BLEDK3_UI v100.132(BM70) default.txt

UI Tool Load Text File Dialog

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

Main Feature window

Back to Top


System Setup Tab

Change Device Name

Under Device Information, set the Name Fragment to lab2p-XXXX where XXXX is the last four digits of the BM70 MAC address. This identifier will become the GAP Service Device Name characteristic, as well as the Local Name identifier during advertising.

Device Information box

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 helps 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), we suggest you 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).

Back to Top


Disable UART_RX_IND

Under UART Setting, select the pull-down to Disable UART RX_IND.

pull-down menu to Disable UART RX_IND

When enabled, this feature places the module into a lower power operating mode, shutting off its UART RX operation. The host MCU needs to drive this pin low for at least 2 ms before sending the next packet to the module, as shown:

Next packet sent to the module

Back to Top


Configure Manual Pattern (BLE GATT) Operation Mode

Under Operation Mode Setting, select Manual Pattern as shown.

Manual Pattern Operation Mode

Click OK to the pop-up dialog box that follows.

Select OK in the Flowcontrol popup

Click Next to proceed to the next tab.

Back to Top


System Setup2 Tab

GPIO Configuration

Under GPIO Configuration, ensure the GPIO pin radio button settings are left at default settings, as shown:

GPIO pin radio button settings are left at default settings

Click Next to proceed to the next tab.

Back to Top


LE Mode Setup Tab

ADV Packet Interval

Under LE Advertising Setting, set the ADV packet interval, referred to as LE Fast Advertising Interval, to 100 ms by writing "0x00A0" in the field as shown in the accompanying image.

Set the ADV packet interval

LE Fast Advertising Timeout & LE Reduced Power Interval/Timeout parameters are only used for Auto-Pattern mode operation

Leave the remaining parameters as-is.

Back to Top


ADV Packet Payload

Under Advertising Data Setting, ensure the Complete Device Name and Flag are included in the payload. (The GAP Device Name characteristic will automatically be included in the ADV packet as the Local Name).

Advertising Data Setting: Complete Device Name and Flag are included

This tab sets the default (static) ADV_IND type advertising packet payload, which is issued when the BM70 is operating in GAP General Discoverable mode. ADV types and parameters may be changed dynamically via op-code 0x13 (Set_Advertising_Parameter).

Back to Top


SCAN_RSP Packet Payload

Under Scan Response Data Setting, ensure the box next to Tx Power is checked. This will enable the payload.

Scan Response Data Setting:Tx Power is checked

A SCAN_RSP packet is returned to a Scanner who has issued a SCAN_REQ packet. These packets provide additional information to a Scanner/Central device.

The remainder of the settings are left at their defaults.

Back to Top


Write Settings

Press Finish.

Press Finish

To program these settings into the BM70 module, click on Write and then select the COM Port you are using, and then press Write again.

Select the COM Port you are using, and then press Write

The Write EFLASH window should appear. Click Yes then click OK.

GAP Discovery and Connection

Discovery means:

  • Put the Peripheral in General Discoverable mode (start Advertising)
  • Trigger the Central to initiate the General Discovery Procedure (Scanning)

Connection means:

  • Central runs a general Connection Establishment Procedure (scan/select a peripheral based on certain criteria, then initiate a direct connection establishment procedure)

Back to Top


APP Mode

Move dip-switch SW7 to the OFF position (1) and reset the module by pressing SW5 (button immediately above dip-switch).

Dip-switch SW7 to the OFF position and press SW5 to reset the module

Back to Top


Launch the Manual Pattern Test Tool

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

Manual Pattern Test Tool window.  Connect to the COM Port associated with the board.

Back to Top


Command and Response

Under the Common tab, select Read Local Information from the drop-down menu next to Opcode. This will verify the connection.

Common tab, select Read Local Information from the drop-down menu next to Opcode

If the COM port connection was successful, you should see results similar to the following Log View and Local Information:

Log View and Local Information


Log View does not display packet delimiter (0xAA) or checksum values on out-going or in-coming packets

Analysis of the “Read Local Information” (0x01) Command Packet:

Command Packet format

Analysis of the “Read Local Information” (0x01) Event Packet:

Response Packet format

Back to Top


Mode of Operation

Verify the BM70 state/mode of operation by sending a Read BLEDK3 Status packet using the Common tab.

Read BLEDK3 Status packet using the Common tab

The module should be on Idle mode.

Idle Mode in BT Status

Back to Top


Advertising Overview (BM70)

Set Advertising Data

On BM70, the ADV interval, as well as ADV_IND and SCAN_RSP payload data, can be set statically (using the UI Configuration Tool) and dynamically (via command op-codes/packets).

Since we’ve set an appropriate ADV_IND Interval, as well as ADV_IND and SCAN_RSP payload data using the UI Configuration Tool (steps 7 through 9 above), we will not need to update them dynamically via the Manual Pattern evaluation tool shown in the accompanying image.

If you need to update ADV and SCAN_RSP payload data dynamically, select the ADV / SR Data tab and set advertising and scan response data payload. Then, pressing Update will issue GAP Command Opcode 0x11 (Write_Adv_Data) to update the payload data sent during Advertising (Standby) mode:

ADV / SR Data tab

If you need to update ADV Interval dynamically, GAP Opcode 0x13 (Set_Adv_Parameter) may be used to dynamically alter the ADV interval:

Update ADV Interval dynamically, GAP Opcode 0x13 (Set_Adv_Parameter) in GAP Tab

On a BM70 Reset, the ADV interval, as well as ADV_IND and SCAN_RSP payload data, will revert back to those settings made in the UI Configuration Tool, and saved to non-volatile configuration memory. Any dynamic changes (made via command op-codes/packets) will be lost.

Back to Top


Put the BM70 Peripheral in General Discoverable Mode

Begin Advertising

All GAP operations are controlled via the GAP tab

Select the GAP tab. Next to Opcode, select 0x1C: (Set Adv Enable) from the drop-down menu. Then, next to Standby Mode, select 0x01: (Enter Standby Mode). Finally, press Send as shown:

Configure GAP settings

You should see the following indicators of success:
BT Status will show 0x03: (Standby Mode)

BT Status will show 0x03: (Standby Mode)

Blue LED (P2_0/LED) will blink once every three seconds (default setting - configurable via UI Config Tool):

Blue LED (P2_0/LED) will blink once every three seconds

You should also see the peripheral’s Local Name displayed in the Smart Discover app, along with RSSI & ADV Interval (Android):

Peripheral’s Local Name displayed in the Smart Discover app

Back to Top


Connect to the BM70 Peripheral using SmartDiscover App

In the SmartDiscover app, select the device you wish to connect to by tapping on it.

SmartDiscover app: Select the device you wish to connect

You should see the following indicators of success:

BT Status will show 0x0C: (BLE Connected Mode) and LE Connection Information (provided by the Central) is also provided.

BT Status will show 0x0C: (BLE Connected Mode)

Blue LED (P2_0/LED) will blink twice every 1.5 seconds (default setting -configurable via UI Config Tool):

Blue LED (P2_0/LED) will blink twice every 1.5 seconds

In SmartDiscover, the default services will have been enumerated, and the ADV and SCAN_RSP data displayed for the device:

ADV and SCAN_RSP data displayed

Back to Top


Disconnect from the BM70 Peripheral using SmartDiscover app

In the SmartDiscover app, disconnect from the device by tapping DISCONNECT.

You should see the following indicators of success:

BT Status will show 0x09 (Idle Mode):

BT Status will show 0x09 (Idle Mode):

Blue LED (P2_0/LED) will stop blinking:

Blue LED (P2_0/LED) will stop blinking

Back to Top

Conclusions

A GAP Peripheral device needs to setup

  • ADV payload data
  • SCAN_RSP payload data
  • Advertising interval
  • BM70 parameters may be modified statically or dynamically:
    • Statically: Using the UI Configuration Tool, or via Direct-write to configuration non-volatile memory.
    • Dynamically: Via op-codes/packets send to the module

Back to Top