Explore Command Mode of a RN4870 Bluetooth Low Energy Module

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

Objective

The most common application for the host Microcontroller Unit (MCU) to control the RN4870 is via ASCII commands. For development and prototyping purposes, using a terminal emulator to send commands and data over the Universal Asynchronous Receiver/Transmitter (UART) is recommended. Any terminal emulator, such as CoolTerm, can be used to control and configure the RN4870 via UART on the host PC.

This hands-on application example outlines the basic Command mode operations for the RN4870.

You will learn:

  • How to set up basic communications between your PC and the RN4870.
  • How to enter Command mode.
  • Commands that review the current configuration settings of the module.
  • Commands that reset the module.

Reference Materials

Connection Diagram

Connection Diagram

The diagram shows the minimal signal connections between the Host (MCU or PC) and the RN4870 module. The UART RX and TX lines are used for communication between the Host and the RN4870. The module‘s operation or mode is determined by the level of a hardware pin - P2_0. This pin is sampled when the RST_N pin goes active. The Test, Configuration, and Programming modes are entered when pin P2_0 is latched by the RN4870 at a logic level "0". The application or run mode where general BLE operation is available is entered when pin P2_0 is latched by the RN4870 at a logic level "1".
 

Back to Top

Procedure

This lab is performed on a Windows 7 computer, using CoolTerm terminal emulator software.

Connect RN4870 PICtail to PC

Make sure the jumpers are configured as in the following picture and that the blue dip switch is set to 1 (APP mode).

Board view of Jumpers

If hardware flow control is enabled, then RTS and CTS jumpers must be installed.


Verify COM Port

Open the Device Manager window by going to Start Menu > Control Panel > Hardware and Sound > Device Manager. Once open, check which COM Port has been assigned to the RN4870 PICtail. In this case, it is COM18. Please note that yours may probably be different.

Device manager showing which COM Port has been assigned to the RN4870 PICtail


Start a CoolTerm Connection

Launch CoolTerm and establish a connection with the following settings. (Your COM port might be different).

CoolTerm window showing 115200 baurdrate and COM port assigned to RN4870 PICTail


Enter Command Mode

To enter Command mode, send the $ command. The module will respond with CMD>.

CoolTerm window in CMD mode

The next command we will issue is the + command. This toggles the local echo on and off. Now that we have entered this command, while in Command mode, it allows all typed characters to be echoed to the output. The module will respond with ECHO ON.

CoolTerm window showing text echo


Default Services

Command SS sets the default services to be supported by the RN4870 when used in the GAP server role. The table listing the 8-bit bitmap is below.

ServiceBitmap
Device Information0x80
Transparent UART0x40
Beacon0x20
Airpatch0x10

We would like to use the Device Information and Transparent UART services, so issue the following command: SS, C0. As you can see, we used 0x80 and 0x40 to come up with the C0 number we used for this command. The module will respond with AOK.

CoolTerm window showing commands

Issuing command SS removes all custom defined public or private services. Use this command to enable default service before defining any custom services.


Set Device Name

Next, we will set our device's name. We do that by issuing the SN command. In my case, I chose DeveloperHelp.

CoolTerm window showing the name being set as DeveloperHelp


Reboot

All configuration changes made by Set commands are stored in the Non-Volatile Memory (NVM) and survive the power cycle. Any configuration changes take effect after a reboot. Command R,1 forces a complete device reboot. The module will respond with Rebooting and once the reboot is finished you will see the %REBOOT% message.

CoolTerm window showing %REBOOT% message after reboot

After the reboot takes place, we need to tell the module to enter Command mode once again by sending the $ command. If you want to keep seeing all the commands you are typing, you can also enable the echo by issuing the + command.

CoolTerm window showing echo turned on and Command mode resumed


Get Device Information

To see if all the changes we've made took effect or to view critical information about the device, we simply issue the D command. The module will respond with:

  • Device MAC Address
  • The random address, if a random address is used
  • Device Name
  • Connected Device
    • MAC address (if connected or no if there is no active connection)
    • MAC address type (public or random)
  • Authentication Method
    • Device I/O capability (set by command SA)
  • Device Features (set by command SR)
  • Server Services
    • Bitmap of predefined services that are supported as a server role
    • Set by command SS
  • Fixed pin code (if used)

CoolTerm window showing results of "D" command which shows critical information about the device


Verify Firmware Version

To verify which firmware is currently programmed into your module, you can issue the V command. The module will respond with the following.

CoolTerm window response to "V" command to Verify Firmware Version


Factory Defaults

Lastly, the SF,1 command resets the configurations into factory default.

CoolTerm window showing SF,1 command which resets device to factory defaults

Back to Top

Conclusions

This lab has briefly introduced you to some of the ASCII commands used to control and configure the RN4870 module. To learn more about the RN4870, the RN4870 PICtail, or to view the entire RN4870 command set, please view the following: