Bluetooth: Mesh: Add callback for unprovisioned device beacon
Adds the unprovisioned_beacon callback to the bt_mesh_prov structure. Signed-off-by: Tobias Svehagen <tobias.svehagen@gmail.com>
This commit is contained in:
parent
4ccf4f4ccb
commit
de92d1a83b
2 changed files with 49 additions and 1 deletions
|
@ -136,6 +136,20 @@ struct bt_mesh_prov {
|
|||
*/
|
||||
void (*input_complete)(void);
|
||||
|
||||
/** @brief Unprovisioned beacon has been received.
|
||||
*
|
||||
* This callback notifies the application that an unprovisioned
|
||||
* beacon has been received.
|
||||
*
|
||||
* @param uuid UUID
|
||||
* @param oob_info OOB Information
|
||||
* @param uri_hash Pointer to URI Hash value. NULL if no hash was
|
||||
* present in the beacon.
|
||||
*/
|
||||
void (*unprovisioned_beacon)(u8_t uuid[16],
|
||||
bt_mesh_prov_oob_info_t oob_info,
|
||||
u32_t *uri_hash);
|
||||
|
||||
/** @brief Provisioning link has been opened.
|
||||
*
|
||||
* This callback notifies the application that a provisioning
|
||||
|
|
|
@ -205,6 +205,40 @@ static int unprovisioned_beacon_send(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void unprovisioned_beacon_recv(struct net_buf_simple *buf)
|
||||
{
|
||||
#if defined(CONFIG_BT_MESH_PB_ADV)
|
||||
const struct bt_mesh_prov *prov;
|
||||
u8_t *uuid;
|
||||
u16_t oob_info;
|
||||
u32_t uri_hash_val;
|
||||
u32_t *uri_hash = NULL;
|
||||
|
||||
if (buf->len != 18 && buf->len != 22) {
|
||||
BT_ERR("Invalid unprovisioned beacon length (%u)", buf->len);
|
||||
return;
|
||||
}
|
||||
|
||||
uuid = net_buf_simple_pull_mem(buf, 16);
|
||||
oob_info = net_buf_simple_pull_be16(buf);
|
||||
|
||||
if (buf->len == 4) {
|
||||
uri_hash_val = net_buf_simple_pull_be32(buf);
|
||||
uri_hash = &uri_hash_val;
|
||||
}
|
||||
|
||||
BT_DBG("uuid %s", bt_hex(uuid, 16));
|
||||
|
||||
prov = bt_mesh_prov_get();
|
||||
|
||||
if (prov->unprovisioned_beacon) {
|
||||
prov->unprovisioned_beacon(uuid,
|
||||
(bt_mesh_prov_oob_info_t)oob_info,
|
||||
uri_hash);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void update_beacon_observation(void)
|
||||
{
|
||||
static bool first_half;
|
||||
|
@ -352,7 +386,7 @@ void bt_mesh_beacon_recv(struct net_buf_simple *buf)
|
|||
type = net_buf_simple_pull_u8(buf);
|
||||
switch (type) {
|
||||
case BEACON_TYPE_UNPROVISIONED:
|
||||
BT_DBG("Ignoring unprovisioned device beacon");
|
||||
unprovisioned_beacon_recv(buf);
|
||||
break;
|
||||
case BEACON_TYPE_SECURE:
|
||||
secure_beacon_recv(buf);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue