User's Manual

Once timer 1 is expired, event @TMR1 is generated. AIO0, which is the light sensor,
is read and the value is assigned to $VAR1. If the reading is within the predefined
range (less than 0x0300), then the value is written to handle 0x000B; otherwise,
handle 0x000B is not updated.
If user would like to debug the script, command “WR,<0-6>” could be used.
4.4.3 Running Script
Now, let’s run this script by enabling script after power on with following command:
SR,4100 // Run script after power on
R,1 // Reboot
After rebooting, the script should be running. User could open LightBlue app and
connect to RN4020 module. Click the characteristic
0x12345678901234567890123456789011 and start notify.
For every five seconds, AIO0 (the light sensor) will be read. If the light sensor is
exposed to light, the reading is around 0x0500, outside the range of $VAR1.
Therefore, handle 0x000B is never updated and notification is never sent. However,
if user block the light sensor, the reading should be within the range of $VAR1,
therefore, the value of the characteristic in LightBlue will be updated every 5
seconds.
On the other hand, for characteristic 0x12345678901234567890123456789022,
user could read its value from LightBlue app. Since the corresponding handle
0x000E has been associated with AIO1, so reading on handle 0x000E will return the
reading of AIO1 (the temperature sensor) without involvement of a host MCU.
In this demo, the script runs the RN4020 module and performed tasks
independently. It shows that for a simple application like this, RN4020 module could
run stand-alone and a host MCU could be saved.