RN4870/71 Bluetooth
®
Low Energy Module User’s Guide
DS50002466A-page 52 2016 Microchip Technology Inc.
The characteristic, most likely a private characteristic, of the handle must have the
property of Write or Write_CMD. If the function expects a return value, the characteris-
tic must have the property of Read or Notify. The data size of the characteristics must
be the higher size of either the input parameters or the return value. For simplicity, the
user can assign the maximum data size to be 20 when defining such a private charac-
teristic.
One or more ASCII commands can be executed within the function until reaching the
next function definition or the next event. The function body format is the same as an
event, with the exception of the differences described in Section 3.1.6.2 “Parameters
of Function”.
3.1.6.2 PARAMETERS OF FUNCTION
New variables $PM1, $PM2, $PM3, $PM4 and $PM5 have been defined to pass input
parameters to the function. A remote peer device can write an ASCII value of the han-
dle that associates with the function in the following format:
<Parameter1>,<Parameter2>…
The parameters are in ASCII format in 1, 2 or 4 characters to specify up to a 16-bit hex
value. If the function does not expect any parameters, the user is free to write any
dummy value to the handle to start the function. Up to five input parameters in total
length, including separating commas, up to 20 characters are supported.
For example, the following ASCII value written to handle 0x0018 passes input param-
eters to function ?FUNC2:
1234,0,56
When function ?FUNC2 is called after the written operation to handle 0x0018, variables
are assigned as follows:
All parameters can be used in ASCII commands as input parameters. If a function
returns a value, the command SHW can be used to set the return value to the same han-
dle. Notice that the input parameter is in ASCII format, while the return value can be in
binary format.
Example 3-1 shows how to use functions to read an EEPROM through I
2
C.
EXAMPLE 3-1: FUNCTION EXAMPLE
If private characteristic is configured to be able to notify and the peer device has started
notification, the return value is automatically sent to the peer device. Otherwise, the
peer device needs to read the same handle to get the return value.
$PM1:0x1234
$PM2:0
$PM3:0x56
From the remote peer device, the following ASCII value is written to handle 0x0018:
0050,0010,06
or, in hex format:
303035302C303031302C3036