Bluetooth: Mesh: Provisioning: Introduce link open/close callbacks
It may be useful for the app to know when the provisioning link is active and when it has been closed. This can be used e.g. to signal the user the state of the device. Some PTS tests also require verifying the link state. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
1311676645
commit
092a28541a
2 changed files with 18 additions and 0 deletions
|
@ -468,6 +468,8 @@ struct bt_mesh_prov {
|
|||
|
||||
int (*input)(bt_mesh_input_action act, u8_t size);
|
||||
|
||||
void (*link_open)(void);
|
||||
void (*link_close)(void);
|
||||
void (*complete)(void);
|
||||
};
|
||||
|
||||
|
|
|
@ -229,6 +229,10 @@ static void reset_link(void)
|
|||
{
|
||||
prov_clear_tx();
|
||||
|
||||
if (prov->link_close) {
|
||||
prov->link_close();
|
||||
}
|
||||
|
||||
/* Clear everything except the retransmit delayed work config */
|
||||
memset(&link, 0, offsetof(struct prov_link, tx.retransmit));
|
||||
|
||||
|
@ -1162,6 +1166,10 @@ static void link_open(struct prov_rx *rx, struct net_buf_simple *buf)
|
|||
return;
|
||||
}
|
||||
|
||||
if (prov->link_open) {
|
||||
prov->link_open();
|
||||
}
|
||||
|
||||
link.id = rx->link_id;
|
||||
atomic_set_bit(link.flags, LINK_ACTIVE);
|
||||
net_buf_simple_init(link.rx.buf, 0);
|
||||
|
@ -1463,6 +1471,10 @@ int bt_mesh_pb_gatt_open(struct bt_conn *conn)
|
|||
link.conn = bt_conn_ref(conn);
|
||||
link.expect = PROV_INVITE;
|
||||
|
||||
if (prov->link_open) {
|
||||
prov->link_open();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1482,6 +1494,10 @@ int bt_mesh_pb_gatt_close(struct bt_conn *conn)
|
|||
bt_mesh_attention(NULL, 0);
|
||||
}
|
||||
|
||||
if (prov->link_close) {
|
||||
prov->link_close();
|
||||
}
|
||||
|
||||
bt_conn_unref(link.conn);
|
||||
|
||||
pub_key = atomic_test_bit(link.flags, LOCAL_PUB_KEY);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue