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
- MCP2200 Windows® Drivers & Installer
- Terminal Emulator
- Windows/MAC/Linux: CoolTerm
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".
Procedure
This lab is performed on a Windows 7 computer, using CoolTerm terminal emulator software.
4
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.
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.
Issuing command SS removes all custom defined public or private services. Use this command to enable default service before defining any custom services.
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.
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.
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)
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:
Table of Contents
|