
NXP Semiconductors
UM11038
OM27642 Smart Lock KIT
UM11038
All information provided in this document is subject to legal disclaimers.
© NXP B.V. 2018. All rights reserved.
User manual
COMPANY PUBLIC
Rev. 1.1 — 11 October 2018
407611
23 of 38
11.5 Smart Lock\Smart Lock .c
The file contains the main state machine for UART-to- Bluetooth Low Energy
communication. As described there are two main states:
1) power-on-handshake
2) data exchange
11.6 Power-On-Handshake
The sequence begins after Bluetooth Low Energy receives new connection in the
app_qpps_cfg_indntf_ind_handler
function which calls
Smart Lock _
power_on_pn
to set
up the UART callback to wait for
'P'
command. When something is received on the UART
the
Smart Lock _recived_pn_power_on
is called to check if the command is correct and
in this case the current time is send back (
Smart Lock _send_rtc_time
) and the Smart
Lock enters state 2) – waiting for command - by setting up the correct callback to receive
data on UART
–
Smart Lock _uart_wait_for_cmd
.
If
'P'
command is not received and a time-out happens the QN enters the
sleep/advertise
cycle again.
11.7 Data exchange
11.7.1.1 Send data
Data exchange state is entered by calling
Smart Lock _uart_wait_for_cmd
to set up the
correct callbacks on UART to wait for command from PN. When the command header
(first 3 bytes) is received by the QN the function
Smart Lock _uart_recive_cmd_header
is
called and the command is checked if it is valid.
Valid commands are:
•
'
C
' – send data to the Bluetooth Low Energy client
•
'
T
' – set time of RTC
If a valid command is received the QN proceeds to read the
<len>
bytes of data from the
UART
by registering a UART receive
callback
Smart Lock _uart_recive_cmd
.
When the whole command is received the
Smart Lock _uart_recive_cmd
function sends
the data to the Bluetooth Low Energy client and sets up a time-out on Bluetooth Low
Energy if the client does not respond in case of a
'C
' command.
The
'T'
command sets the RTC to the time sent by PN – no Bluetooth Low Energy
communication is performed at this time.
11.7.1.2 Receive data
Data is received from the Bluetooth Low Energy client in the
app_qpps_data_ind_handler
function. Which uses
Smart Lock _uart_transmit_add_data
to store the fragmented
pieces of data to the UART RX buffer and
Smart Lock _uart_transmit_reply
to send the
data to PN after the entire package was received.