BM70 Compact Demo Board User's Guide: Chapter 4. Using RN4870 Firmware on BM-70-CDB
4.1 Introduction
The BM70 module on the BM-70-CDB can be loaded with the RN4870 firmware and operated as an RN4870 module for evaluation and development. Please refer to Appendix A. “Loading RN4870 Firmware”, for the procedure to load the RN4870 firmware onto the BM70 module. Since the BM70 module is programmed with RN4870 firmware, it will be referred to as RN4870 in this section. But when referring to the hardware board, the name BM-70-CDB will be used.
The simplest method to access the BM-70-CDB is to connect it to a PC host that supports USB CDC virtual COM ports. To interact directly with the BM-70-CDB, the following software is needed:
- PC Host supporting USB CDC virtual serial port
- The BM-70-CDB uses the MCP2200 USB to UART bridge. The drivers can be downloaded from the MCP2200 product page.
- Terminal Emulator Application
- Tera Term or CoolTerm is recommended
- Microchip SmartDiscover App for iOS or Android
- Available on App Store (for iOS) or Google Play Store (Android)
- RN4870 Sensor Board Support Package (RN4870-Sensor-Board-Support.zip)
- This is a collection of files and utilities to assist in configuring the Sensor Board. The files can be downloaded from the RN4870 product page.
4.2 Connecting The BM-70-CDB To A Host PC
To connect the BM-70-CDB to a host PC, perform the following steps:
Configure the BM-70-CDB as follows:
- Pins 2 and 3 on J6 are closed to select USB power option
- J8 is closed
- Operating mode switch ( Switch 2 on SW2) is in position 2 to enable Application mode
- Switch 3 on SW2 is in position 3 to enable LD2 (Blue LED)
Connect the BM-70-CDB to the host PC using a micro USB cable. Perform the following steps:
- Verify that the virtual COM port is enumerated on the host PC. If the COM port does not enumerate, the MCP2200 drivers may be missing from the host PC. The drivers can be downloaded from the MCP2200 web page.
- Press Reset button (SW1) and verify that LD2 is flashing slowly
Start the Terminal Emulator software. In this example, Tera Term is used. Configure the enumerated COM port as shown in Figure 4-1.
Enter Command mode by sending the command escape sequence $. Pressing the dollar sign ($) three times puts the RN4870 into Command mode and the CMD> prompt is displayed. Enable the local echo feature by pressing +, which echoes the character entered by the user on the serial emulator window. The ECHO ON response is displayed as shown in Figure 4-2.
To display the basic configuration settings, press the letter D followed by the <Enter> key (\r), as shown in Figure 4-3. Refer to the “RN4870 Bluetooth® Low Energy Module User's Guide” (DS50002466) for a detailed explanation of the commands.
The SmartDiscover App from Microchip can be used to demonstrate RN4870 features. See Figure 4-4 for an example of the SmartDiscover App icon. The iOS version of the SmartDiscover App is referred to in this document.
Once the SmartDiscover App is opened on your smartphone, it discovers the RN4870 peripherals as shown in Figure 4-5.
4.3 Changing Settings Using ASCII Commands
The RN4870 firmware is shipped with a default configuration which includes two services (Transparent UART service and Device Info Service) as noted by the result of the previous command D (displays basic configuration). The list of services is indicated as Services = C0. Refer to the “RN4870 Bluetooth® Low Energy Module User's Guide” (DS50002466) for a bitmap of services. The RN4870 can be discovered using the Bluetooth SmartDiscover App. The SmartDiscover App is available in the iTunes Store and the Google Play Store.
To enable built-in services and connect to the RN4870, perform the following steps:
Connect the BM-70-CDB to the host PC USB port:
- Using Terminal Emulator, open the COM port enumerated for the BM-70-CDB
- Type $ to enter Command mode
- Enter + to turn on ECHO. Refer to Figure 4-2.
To change the default name, send the following commands:
- S-,BLE to create a unique serialized name based on the Bluetooth (BT) address of the device.
- R,1 to reboot the module and enable the configuration commands to take effect. Refer to Figure 4-6.
Verify that the changes made using the S- command are saved by the reboot, with the following steps:
- Type $ to enter Command mode
- Enter + to turn on local echo
- Issue command D to display the settings
- Verify that the name of the device is BLE-b1b0, where b1b0 are the low-order bytes of the BT address; in this example, the Bluetooth is set to BLE-B1E4. Refer to Figure 4-7.
4.4 Connecting To The RN4870 Using SmartDiscover App
To connect the RN4870 using the SmartDiscover App, perform the following steps:
Launch the SmartDiscover App. Refer to Figure 4-8 for how to demonstrate the SmartDiscover App on an iOS device.
Ensure that the connection is established. The GATT service view is illustrated in Figure 4-9. The connection is also verified by the %CONNECT,1,<MAC> status message returned by the RN4870/71 UART. The <MAC> is the address of the remote BT device that initiated the connection. The response in the terminal emulator is shown in Figure 4-10.
4.5 Creating Custom GATT Services
The RN4870 module supports custom (or private) GATT services. Public GATT services are defined by specifications published by the Bluetooth Special Interest Group (SIG). Private GATT services are defined by the user to host information stored in the GATT characteristics. For more information on GATT services, refer to Appendix E. “Bluetooth Low Energy Primer”.
To create a private GATT service, enter the configuration commands listed in Step 3 below. The commands can be entered as shown in this user guide, or copied from configuration files and pasted into the terminal emulator. The configuration text files are included in the RN4870 Sensor Board Support package.
Connect the BM-70-CDB to the host PC USB port
- Using a terminal emulator, open the COM port to the RN4870
- Type $ to enter Command mode
- Enter + to turn on ECHO.
Set Factory Default values
- Enter PZ to clear all services and characteristics
- Enter SF,1
- Verify that the module reboots after the command is entered.
Create the private GATT service with three characteristics by entering the following commands:
PS,4D6963726F636869702D524E34383730
PC,BF3FBD80063F11E59E690002A5D5C501,02,02
PC,BF3FBD80063F11E59E690002A5D5C502,02,02
PC,BF3FBD80063F11E59E690002A5D5C503,18,04
These commands can be entered manually by typing each line followed by the <Enter> key from the file 3.4-GATT-service.txt, or each line copied and pasted one by one into the terminal emulator.
Command PS creates the GATT service, identified by the 16-byte private UUID: 4D6963726F636869702D524E34383730. This command must be called before the command PC.
Command PC creates the private characteristics. Each characteristic is identified by the following UUIDs:
BF3FBD80063F11E59E690002A5D5C501
,
BF3FBD80063F11E59E690002A5D5C502
,
BF3FBD80063F11E59E690002A5D5C503
.
Command PC expects three parameters. The first parameter is the UUID, the second parameter is the characteristic property (refer to Table E-1 in Appendix E. “Bluetooth Low Energy Primer”), and the third parameter is the size of the data of the characteristic.
Verify that the GATT service is correctly configured.
- Enter Command mode ($) after rebooting the module.
- Issue the LS command to list the GATT server services and their characteristics. The response is illustrated in Figure 4-11.
4.6 Accessing GATT Service Using UART Commands And SmartDiscover App
The following examples show how to read and write GATT characteristic values by using UART commands:
To read a value from the GATT Server characteristic C501, use the Server Handle Read (SHR) command with handle (for example, 0072) as first parameter, following by hex-byte values as shown in Figure 4-12.
It is also possible to access the GATT server over a Bluetooth Low Energy connection using the SmartDiscover App. Launch the SmartDiscover App and connect to the RN4870 configured with the private GATT as shown in Section 4.5 “Creating Custom GATT Services”. In this example, the device “BLE-B1E4” is used. Follow the steps in Figure 4-13 to read the value of the GATT characteristic C501. In Step 1, click on the name of your device (BLE-B1E4 >), in Step 2 click on the UUID (BF3FBD80063F11E59E690002A5D5C501 >) and in Step 3 click on Read. The characteristic value is read from the RN4870 into the Smart Discover App.