2016 Microchip Technology Inc. DS50002466A-page 49
RN4870/71 BLUETOOTH
®
LOW ENERGY MODULE
USER’S GUIDE
Chapter 3. Embedded Scripting Feature
3.1 INTRODUCTION
In a typical use case, a host MCU uses ASCII commands over UART to control and
exchange data with the RN4870/71 BLE module. For simple applications, such as a
sensor or beacon broadcaster, a host MCU may not be necessary.
By using the RN4870 Embedded Scripting feature, operations and functions can be
executed by script engine. A script consists of ASCII commands that do not need to be
compiled or processed. The script remains in the RN4870/71 NVM and does not alter
the core firmware in any way.
The scripting capability on the RN4870/71 is useful in the following situations:
• Application is sensitive to the added cost of the host MCU
• User application uses proprietary service and characteristics
• User application mainly uses analog or digital ports that are available on the
RN4870/71
• User application is simple such as sensor or beacon
• RN4870/71 shares raw binary data with remote peer device such as a smart-
phone, where the peer device can interpolate
• The total script does not exceed 1000 bytes, each script line does not exceed 100
bytes and maximum number of script lines is 50.
• Scripting capability can be used to lower load of the host MCU. It can be used to
initialize setting and perform operations once certain event is triggered.
3.1.1
Script Overview
The main functionalities of scripting are achieved by executing ASCII commands that
are the same as those via UART interface. This section presents an overview of the
scripting capability. For detailed descriptions on scripting-related commands, refer to
Section2.10“Script Commands”.
3.1.2
Event Driven
The RN4870/71 scripting is event driven. There are 12 currently defined events.
Tabl e 3-1 lists supported events and their labels. All event scripts start with event label
followed by one or more logic operations or ASCII commands. Once an event is trig-
gered, and an event label is defined, control is passed over to the script engine. The
script engine starts executing the commands that are listed below the event label until
the end of the script or until encountering another event label.
TABLE 3-1: LIST OF EVENTS AND EVENT LABELS
Event Event Label
Power On @PW_ON
Timer 1 Expired @TMR1
Timer 2 Expired @TMR2
Timer 3 Expired @TMR3
Connected @CONN