RN4870 Command Mode

 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 host PC.

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

You will learn:

  • how to setup 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.

 Materials

Hardware Tools

Software Tools

 Connection Diagram

MinimumConnection.png

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

 Procedure

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

1

Connect RN4870 PICtail to PC

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

JumperSettings.jpg

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

2

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.

DeviceManager.png

3

Start a CoolTerm Connection

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

CoolTerm.png

4

Enter Command Mode

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

CMD.png

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.

EchoOn.png

5

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.
Service Bitmap
Device Information 0x80
Transparent UART 0x40
Beacon 0x20
Airpatch 0x10

I have decided I would like to use the Device Information and Transparent UART services, so I issued 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.

SS.png

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

6

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.

DeviceName.png

7

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.

Reboot.png

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.

AfterReboot.png

8

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 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 server role
    • Set by command SS
  • Fixed pin code (if used)
D.png

9

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.

FirmwareVersion.png

10

Factory Defaults

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

FactoryDefault.png

 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:

© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
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.