Telink TLSR8232 BLE SDK Developer Handbook
AN-19112700-E1
51
Ver.1.0.0
The figure above shows a Link Layer state machine combination for a basic BLE Slave
application. In SDK, 5316 hci/5316 remote/5316 module/5316 sample/5316 dual mode
are all based on this combination.
The module initialization code of Link Layer state machine is:
u8 tbl_mac [6] = {……};
blc_ll_initBasicMCU(tbl_mac);
blc_ll_initAdvertising_module(tbl_mac);
blc_ll_initSlaveRole_module();
State switch in this combination is shown as below:
1) After power on, 5316 MCU enters Idle state. In Idle state, Adv is enabled, and Link
Layer switches to Advertising state; when Adv is disabled, it will return to Idle state.
The API
“bls_ll_setAdvEnable” serves to enable/disable Adv.
After power on, Link Layer is in Idle state by default. Generally Adv needs to be
enabled
in “user_init” so as to enter Advertising state.
2) When Link Layer is in Idle state, Physical Layer won
’t take any RF operation
including packet transmission and reception.
3) When Link Layer is in Advertising state, advertising packets are transmitted in adv
channels. Master will send connection request if it receives adv packet. After Link
Layer receives this connection request, it will respond, establish connection and
enter ConnSlaveRole.
4) When Link Layer is in ConnSlaveRole, it will return to Idle State or Advertising state
in any of the following cases:
a) Master sends
“terminate” command to Slave and requests disconnection. Slave
will exit ConnSlaveRole after it receives this command.
b)
By sending “terminate” command to Master, Slave actively terminates the
connection and exits ConnSlaveRole.
c) If Slave fails to receive any packet due to Slave RF Rx abnormity or Master Tx
abnormity until BLE connection supervision timeout is triggered, Slave will exit
ConnSlaveRole.
When Link Layer exits ConnSlaveRole state, it will switch to Adv/Idle state according
to whether Adv is enabled or disabled which depends on the value configured during
last calling
of “bls_ll_setAdvEnable” in APP layer. If Adv is enabled, Link Layer
returns to Advertising state; if Adv is disabled, Link Layer returns to Idle state.
3.2.4 Link Layer Timing Sequence
In this section, Link Layer timing sequence in various states will be illustrated combining
with irq_handler and mainloop of 5316 BLE SDK.
_attribute_ram_code_
void
irq_handler
(
void
)
{
……