
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
22 of 38
11.3 Interaction with Bluetooth Low Energy Stack
NXP Bluetooth Low Energy Lib only needs few interfaces to exchange data with the
Bluetooth Low Energy Client. When the Bluetooth Low Energy Client sends a BLE write
command the function
gatt_write_cmd_ind_handler()
in file smx_task.c gets called. This
file is part of the proprietary profile.
In this function the PN_TASK is called in two places:
-
When the Bluetooth Low Energy Client connects and registers to receive
Bluetooth Low Energy notifications the PN_TASK is activated by calling
pn_send_ble_activate_req(smx_env.con_info.conhdl)
-
During normal operation the NXP Bluetooth Low Energy Lib collects data from 1
or more Bluetooth Low Energy frames. After the payload frame has been
received completely, the function
pn_send_ble_rx_ind(smx_env.in_buf,smx_env.nb_received_data_bytes)
gets
called to forward incoming payload from the Bluetooth Low Energy client to the
PN_TASK.
In the opposite direction the PN_TASK calls function
smx_send_apdu_to_phone_req(param->data,param->len)
in file smx.c. If necessary, the
data will be split automatically into several Bluetooth Low Energy frames and sent as
Bluetooth Low Energy notifications to the Bluetooth Low Energy client.
After a Bluetooth Low Energy disconnect sequence is completed (trigger via Bluetooth
Low Energy client or smartlock) the PN_TASK receives a PN_BLE_DISC_IND message
and the handler
pn_ble_disc_ind_handler()
gets called. This handler checks
(
reset_after_ble_disc_cmpl
) whether a system reset is necessary (e.g. new device
name).
Since there are situations where the Bluetooth Low Energy connection is closed (eg
Bluetooth Low Energy Client disconnects) but PN activity is still not finished (eg lock
open/close ongoing), Bluetooth Low Energy advertising may not automatically be started
after a Bluetooth Low Energy disconnect complete event. Therefore the event handler for
GAP_DISCON_CMP_EVT
in file usr_design.c and function
app_task_msg_hdl()
will check
whether advertising is allowed by invoking
pn_adv_allowed()
.
In this situation advertising has to be started manually after PN has finished its operation.
For the manual advertising start PN_TASK will call
app_start_adv()
in file usr_design.c.
11.4 Bluetooth Low Energy Service definition
The file smx.h contains the definition for the UUIDs used in the Smart Lock application:
SMX_SVC_UUID
defines the service UUID. This UUID is also advertised. The smartphone
app is looking for devices advertising this service.
SMX_WR_CHAR_UUID
defines the characteristic to which the Bluetooth Low Energy client will
write to
SMX_RD_CHAR_UUID
defines the characteristic which will transfer data from QN to the
Bluetooth Low Energy client using Bluetooth Low Energy notifications. Therefore, the
Bluetooth Low Energy client has to subscribe at first to receive notifications.