Lines Matching full:beacon
23 #include "beacon.h"
48 * Identifier for the current Private beacon random-value.
50 * Whenever it's time for a subnet to create a beacon, it'll compare
51 * the subnet's beacon idx to determine whether the random value has
52 * changed since the last beacon was sent. If this is the case, we'll
53 * regenerate the beacon based on the new random value.
95 struct bt_mesh_beacon *beacon; in beacon_cache_match() local
98 beacon = subnet_beacon_get_by_type(sub, params->private); in beacon_cache_match()
100 return !memcmp(beacon->cache, params->auth, sizeof(beacon->cache)); in beacon_cache_match()
103 static void cache_add(const uint8_t auth[8], struct bt_mesh_beacon *beacon) in cache_add() argument
105 memcpy(beacon->cache, auth, sizeof(beacon->cache)); in cache_add()
119 LOG_ERR("Failed to send beacon: err %d", err); in beacon_start()
128 struct bt_mesh_beacon *beacon = user_data; in beacon_complete() local
131 beacon->sent = k_uptime_get_32(); in beacon_complete()
172 /* The Private beacon random value should change every N seconds to maintain privacy. in private_random_update()
173 * N = (10 * interval) seconds, or on every beacon creation, if the interval is 0. in private_random_update()
188 /* Update the index to indicate to all subnets that the private beacon must be regenerated. in private_random_update()
189 * Each subnet maintains the random index their private beacon data was generated with. in private_random_update()
207 LOG_ERR("Can't encrypt private beacon"); in private_beacon_update()
220 /* Refresh beacon data */ in private_beacon_create()
255 /* If the interval has passed or is within 5 seconds from now send a beacon */
256 #define BEACON_THRESHOLD(beacon) \ argument
257 ((10 * ((beacon)->last + 1)) * MSEC_PER_SEC - (5 * MSEC_PER_SEC))
265 static int net_beacon_send(struct bt_mesh_subnet *sub, struct bt_mesh_beacon *beacon, in net_beacon_send() argument
281 time_diff = now - beacon->sent; in net_beacon_send()
282 time_since_last_recv = now - beacon->recv; in net_beacon_send()
284 (time_diff < BEACON_THRESHOLD(beacon) || in net_beacon_send()
292 LOG_ERR("Unable to allocate beacon adv"); in net_beacon_send()
298 bt_mesh_adv_send(adv, &send_cb, beacon); in net_beacon_send()
311 struct bt_mesh_beacon *beacon; in net_beacon_for_subnet_send() member
316 .beacon = &sub->secure_beacon, in net_beacon_for_subnet_send()
322 .beacon = &sub->priv_beacon, in net_beacon_for_subnet_send()
334 err = net_beacon_send(sub, beacons[i].beacon, beacons[i].create_fn); in net_beacon_for_subnet_send()
356 LOG_ERR("Unable to allocate beacon adv"); in unprovisioned_beacon_send()
416 LOG_ERR("Invalid unprovisioned beacon length (%u)", buf->len); in unprovisioned_beacon_recv()
450 /* Observation period is 20 seconds, whereas the beacon timer in update_beacon_observation()
531 if (bt_mesh_beacon_auth(&keys->beacon, params->flags, keys->net_id, params->iv_index, in auth_match()
613 static void net_beacon_register(struct bt_mesh_beacon *beacon, bool priv) in net_beacon_register() argument
616 bt_mesh_beacon_enabled()) && beacon->cur < 0xff) { in net_beacon_register()
617 beacon->cur++; in net_beacon_register()
618 beacon->recv = k_uptime_get_32(); in net_beacon_register()
631 LOG_WRN("Ignoring secure beacon on non-primary subnet"); in net_beacon_recv()
654 struct bt_mesh_beacon *beacon; in net_beacon_resolve() local
658 beacon = subnet_beacon_get_by_type(sub, params->private); in net_beacon_resolve()
660 /* We've seen this beacon before - just update the stats */ in net_beacon_resolve()
661 net_beacon_register(beacon, params->private); in net_beacon_resolve()
667 LOG_DBG("No subnet that matched beacon"); in net_beacon_resolve()
676 beacon = subnet_beacon_get_by_type(sub, params->private); in net_beacon_resolve()
678 cache_add(params->auth, beacon); in net_beacon_resolve()
681 net_beacon_register(beacon, params->private); in net_beacon_resolve()
689 LOG_ERR("Too short secure beacon (len %u)", buf->len); in secure_beacon_recv()
707 LOG_ERR("Too short private beacon (len %u)", buf->len); in private_beacon_recv()
726 LOG_ERR("Too short beacon"); in bt_mesh_beacon_recv()
744 LOG_WRN("Unknown beacon type 0x%02x", type); in bt_mesh_beacon_recv()
761 /* Invalidate private beacon to force regeneration: */ in bt_mesh_beacon_update()
766 bt_mesh_beacon_auth(&keys->beacon, flags, keys->net_id, bt_mesh.iv_index, in bt_mesh_beacon_update()
777 BT_MESH_SUBNET_CB_DEFINE(beacon) = {
794 /* Fire the beacon handler straight away if it's not already pending - in bt_mesh_beacon_ivu_initiator()