link to page 5 link to page 11 link to page 11 link to page 11 link to page 12 link to page 13 link to page 14 link to page 15 link to page 15 link to page 15 link to page 15 link to page 16 link to page 27 link to page 28 link to page 41 link to page 43 link to page 46 link to page 48 link to page 50 link to page 53 link to page 55 link to page 55 link to page 59 link to page 59 link to page 61 link to page 63 link to page 65 link to page 65 link to page 67 link to page 67 link to page 69 link to page 69 link to page 71 link to page 71 link to page 75 RN4870/71 BLUETOOTHLOW ENERGY MODULEUSER’S GUIDETable of ContentsPreface ... 5Chapter 1. Overview 1.1 Introduction ... 11 1.2 Key Features .. 11 1.3 Command Mode and Data Mode ... 12 1.4 Accessing the RN4870/71 over UART ... 13 1.5 RN4870 PIO Control Lines ... 14 Chapter 2. Command Reference 2.1 Introduction ... 15 2.2 Command Syntax ... 15 2.3 Set and Get Commands ... 15 2.4 Set Commands ... 16 2.5 Get Commands .. 27 2.6 Action Commands .. 28 2.7 I2C Commands ... 41 2.8 SPI Commands .. 43 2.9 List Commands .. 46 2.10 Service Configuration Commands .. 48 2.11 Characteristic Access Commands ... 50 2.12 Script Commands ... 53 Chapter 3. Embedded Scripting Feature 3.1 Introduction ... 55 Chapter 4. Connection Examples 4.1 Connecting to RN4870 using SmartDiscover App ... 59 4.2 UART Transparent Connection Using SmartData ... 61 4.3 Module-to-Module Connection ... 63 Appendix A. Bluetooth Low Energy Fundamentals A.1 Introduction .. 65 Appendix B. Transparent UART Service UUIDs B.1 Introduction .. 67 Appendix C. Low-Power Operation C.1 Introduction .. 69 Appendix D. Status Response Summary Quick Reference D.1 Introduction .. 71 Worldwide Sales and Service .. 75 2016-2018 Microchip Technology Inc. DS50002466C-page 3 Document Outline Trademarks Table of Contents Preface Chapter 1. Overview 1.1 Introduction 1.2 Key Features 1.2.1 ASCII Command Interface 1.2.2 Transparent UART 1.2.3 Custom GATT Services 1.2.4 Embedded Scripting Feature 1.2.5 Remote Command Console 1.3 Command Mode and Data Mode Figure 1-1: Command Mode and Transparent UART (Data) mode 1.4 Accessing the RN4870/71 over UART Table 1-1: Default UART Settings 1.5 RN4870 PIO Control Lines Chapter 2. Command Reference 2.1 Introduction 2.2 Command Syntax 2.3 Set and Get Commands Table 2-1: Set and Get Commands Syntax Format 2.4 Set Commands 2.4.1 S-,<string> 2.4.2 S$,<char> 2.4.3 S%,<pre>,<post> 2.4.4 SA,<0-5 Table 2-2: Set I/O Capability 2.4.5 SB,<H8> Table 2-3: UART Baud Rate Settings 2.4.6 SC,<0-2> Table 2-4: CONNECTABLE AND NON-CONNECTABLE ADVERTIEMENT SETTINGS 2.4.7 SDA,<H16> 2.4.8 SDF,<text> 2.4.9 SDH,<text> 2.4.10 SDM,<text> 2.4.11 SDN,<text> 2.4.12 SDR,<text> 2.4.13 SDS,<text> 2.4.14 SF,1 2.4.15 SF,2 2.4.16 SGA,<0-5>/SGC,<0-5> Table 2-5: Typical Output Power values 2.4.17 SM,<1-3>,<hex16> 2.4.18 SN,<text> 2.4.19 SO,<0,1> 2.4.20 SP,<4/6 digit pin> 2.4.21 SR,<hex16> Table 2-6: Bitmap of Features 2.4.22 SS,<hex8> Table 2-7: Bitmap of Services 2.4.23 ST,<hex16>,<hex16>,<hex16>,<hex16> Table 2-8: Connection Parameters 2.4.24 STA,<hex16>,<hex16>,<hex16> 2.4.25 STB,<hex16> 2.4.26 SW,<hex8>,<hex8> Table 2-9: Pin Index and RN4870/71 Pins Table 2-10: Configurable Functions 2.5 Get Commands 2.5.1 GK 2.5.2 GNR 2.5.3 G<char> 2.6 Action Commands 2.6.1 +[,<text>] 2.6.2 $$$ 2.6.3 --- 2.6.4 !,<0,1> 2.6.5 @,<0-5> Table 2-11: analog Channels and Associated Pins 2.6.6 |I,<hex8> Table 2-12: Digital I/O Bitmap 2.6.7 |O,<hex8>,<hex8> 2.6.8 [,<1-2>,<0-3>,<hex16>,<hex16> Table 2-13: PWM Operation Selection Figure 2-1: Basic concept of PWM Operation 2.6.9 &,<MAC> 2.6.10 &C 2.6.11 &R 2.6.12 A[,<hex16>,<hex16>] 2.6.13 B 2.6.14 C 2.6.15 C,<0,1>,<address> 2.6.16 C<1-8> 2.6.17 D 2.6.18 F[,<hex16>,<hex16>] 2.6.19 I 2.6.20 IA,<hex8>,<Hex>/IB,<hex8>,<Hex>/IS,<hex8>,<Hex> NA,<hex8>,<Hex>/NB,<hex8>,<Hex>/NS,<hex8>,<Hex> Table 2-14: List of AD Types 2.6.21 JA,<0,1>,<MAC> 2.6.22 JB 2.6.23 JC 2.6.24 JD 2.6.25 K,1 2.6.26 M 2.6.27 O,0 2.6.28 R,1 2.6.29 T,<hex16>,<hex16>,<hex16>,<hex16> 2.6.30 U,<1-8,Z> 2.6.31 V 2.6.32 X 2.6.33 Y 2.6.34 Z 2.7 I2C Commands Table 2-15: I2C Peripheral Interface Table 2-16: I2C Commands 2.7.1 ]A Table 2-17: Clock values 2.7.2 ]Z 2.7.3 ]D 2.7.4 ]R 2.7.5 ]W 2.7.6 ]X 2.8 SPI Commands Table 2-18: SPI Peripheral Interface Table 2-19: SPI Contacts 2.8.1 {A Table 2-20: SPI Clock Polarity and Phase Settings Table 2-21: SPI Master Clock Rate Table 2-22: SPI Chip Select Pin 2.8.2 {Z 2.8.3 {X 2.8.4 }A Table 2-23: SPI Clock Polarity and Phase Settings Table 2-24: SPI Master Clock Rate 2.8.5 }Z 2.8.6 }R 2.8.7 }W 2.9 List Commands 2.9.1 LB 2.9.2 LC[,<P,UUID>] Figure 2-2: Listing Client Service and Characteristics 2.9.3 LS[,<P,UUID>] 2.9.4 LW 2.10 Service Configuration Commands 2.10.1 PC,<hex16/hex128>,<hex8>,<hex8> 2.10.2 PS,<hex16/hex128> 2.10.3 PZ 2.10.4 Defining Multiple Services 2.11 Characteristic Access Commands 2.11.1 Definition of Characteristic Access Commands Table 2-25: Format of GATT access commands 2.11.2 CHR 2.11.3 CHW 2.11.4 CI 2.11.5 SHR 2.11.6 SHW 2.12 Script Commands 2.12.1 WC 2.12.2 WP 2.12.3 WR[,<H6>] Table 2-26: Command WR Input Parameters and Associated Events 2.12.4 WW Chapter 3. Embedded Scripting Feature 3.1 Introduction 3.1.1 Script Overview 3.1.2 Event Driven Table 3-1: List of Events and Event Labels 3.1.3 Comments 3.1.4 Variables 3.1.5 Handle Association 3.1.6 Remote Function Call Chapter 4. Connection Examples 4.1 Connecting to RN4870 using SmartDiscover App Figure 4-1: Connect to the RN4870 module Figure 4-2: Service Discovery Figure 4-3: Characteristic Access 4.2 UART Transparent Connection Using SmartData Figure 4-4: Connect to RN4870 Figure 4-5: Data Exchange on SmartData APP Figure 4-6: Data Exchange on Terminal Emulator 4.3 Module-to-Module Connection Figure 4-7: Connecting two RN4870 modules Appendix A. Bluetooth Low Energy Fundamentals A.1 Introduction Table A-1: Characteristic Properties Figure A-1: GATT Service in RN4870 Appendix B. Transparent UART Service UUIDs B.1 Introduction Table B-1: Characteristic Properties Appendix C. Low-Power Operation C.1 Introduction Figure C-1: State Diagram Appendix D. Status Response Summary Quick Reference D.1 Introduction Table D-1: Status Messages Returned by RN4870 /71 Table D-2: Command Summary Quick Reference AMERICAS Corporate Office Atlanta Austin, TX Boston Chicago Dallas Detroit Houston, TX Indianapolis Los Angeles Raleigh, NC New York, NY San Jose, CA Canada - Toronto ASIA/PACIFIC Australia - Sydney China - Beijing China - Chengdu China - Chongqing China - Dongguan China - Guangzhou China - Hangzhou China - Hong Kong SAR China - Nanjing China - Qingdao China - Shanghai China - Shenyang China - Shenzhen China - Suzhou China - Wuhan China - Xian China - Xiamen China - Zhuhai ASIA/PACIFIC India - Bangalore India - New Delhi India - Pune Japan - Osaka Japan - Tokyo Korea - Daegu Korea - Seoul Malaysia - Kuala Lumpur Malaysia - Penang Philippines - Manila Singapore Taiwan - Hsin Chu Taiwan - Kaohsiung Taiwan - Taipei Thailand - Bangkok Vietnam - Ho Chi Minh EUROPE Austria - Wels Denmark - Copenhagen Finland - Espoo France - Paris Germany - Garching Germany - Haan Germany - Heilbronn Germany - Karlsruhe Germany - Munich Germany - Rosenheim Israel - Ra’anana Italy - Milan Italy - Padova Netherlands - Drunen Norway - Trondheim Poland - Warsaw Romania - Bucharest Spain - Madrid Sweden - Gothenberg Sweden - Stockholm UK - Wokingham Worldwide Sales and Service Worldwide Sales and Service