The most common application for the host Microcontoller (MCU) to control the RN4870 is via ASCII commands. For development and prototyping purposes, using a terminal emulator to send commands and data over 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 basic Command Mode operation 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
The diagram shows the minimal signal connections between the Host MCU and the RN4870 module. The UART RX and TX lines are used for communication between the Host MCU 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.
This lab is performed on a Windows 7 computer, using CoolTerm terminal emulator software.
Enter Command Mode
To enter Command Mode, send the $ command. The module will respond with CMD>.
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.
Default ServicesCommand 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.
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.
Issuing command SS removes all custom defined public or private services. Use this command to enable default service before defining any custom services.
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.
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.
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 and address type (Public or Random) if connected, or no if there is no active connection.
- Authentication Method: device I/O capability set by command SA.
- Device Features: device features set by command SR.
- Server Services: bitmap of predefined services that are supported as server role, set by command SS.
- The fixed pin code, if fixed pin code is used
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: