Telink TLSR8232 BLE SDK Developer Handbook
AN-19112700-E1
146
Ver.1.0.0
The maximal adr_index and inverted value of
“5316_remote.bin” are “0x05a9” and
shows the final OTA end packet.
9) Check if link-layer
TX FIFO on Master side is empty: If it’s empty, it indicates all data
and commands in above steps are sent successfully, i.e. OTA process on Master
succeeds.
Please refer to Appendix for CRC_16 calculation function.
6.2.4 RF Receive Processing on Slave Side
As introduced above, Slave can directly invoke the otaWrite and otaRead in OTA
Attribute. After Slave receives write command from Master, it will be parsed and
processed automatically in BLE stack by invoking the otaWrite function.
In the otaWrite function, the 20-
byte packet data will be parsed: first judge whether it’s
OTA CMD or OTA data, then process correspondingly (respond to OTA cmd; check CRC
to OTA data and burn data into specific addresses of Flash).
The OTA related operations on Slave side are shown as below:
1) OTA_FIRMWARE_VERSION command is received (first two bytes are 0xff00):
Master requests to obtain Slave firmware version number.
In 5316 BLE SDK, after Slave receives this command, it will only check whether
related callback function is registered and determine whether to trigger the callback
function correspondingly.
The interface in ble_ll_ota.h to register this callback function is:
typedef void
(*
ota_versionCb_t
)(
void
);
void
bls_ota_registerVersionReqCb
(
ota_versionCb_t
cb);
2) OTA start command is received (first two bytes are 0xff01): Slave enters OTA mode.
If the “bls_ota_registerStartCmdCb” function is used to register the callback function
of OTA start, then the callback function is executed to modify some parameter states
after entering OTA mode (e.g. disable PM to stabilize OTA data transfer).
Slave starts and maintains a slave_adr_index to record the adr_index of the latest
correct OTA data. The initial value of slave_adr_index is -1, and it
’s used to judge
whether there’s packet loss in the whole OTA process; if so, OTA fails, Slave MCU
exits OTA and reboots, since Master can’t receive any ack packet from Slave, it will
discover OTA failure by software after timeout.
The following interface is used to register the callback function of OTA start:
typedefvoid
(*
ota_startCb_t
)(
void
);
void
bls_ota_registerStartCmdCb
(
ota_startCb_t
cb);
User needs to register this callback function to carry out operations when OTA starts,
for example, configure LED blinking to indicate OTA process. After Slave receives
“OTA start”, it enters OTA and starts a timer (The timeout duration is set as 15s by
default in current SDK). If OTA process is not finished within the duration, it’s
regarded as OTA failure due to timeout. Users can evaluate firmware size (larger
size takes more time) and BLE data bandwidth on Master (narrow bandwidth will