Skip to content

Commit 0eee702

Browse files
m-alperen-senerjhedberg
authored andcommitted
Bluetooth: Mesh: Add back-off to secure beacons
adding back-off mechanism to mesh secure beacon behaviour Signed-off-by: Alperen Sener <[email protected]>
1 parent 452b897 commit 0eee702

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

subsys/bluetooth/mesh/beacon.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,15 @@ static bool secure_beacon_send(struct bt_mesh_subnet *sub, void *cb_data)
101101
uint32_t now = k_uptime_get_32();
102102
struct net_buf *buf;
103103
uint32_t time_diff;
104+
uint32_t time_since_last_recv;
104105

105106
BT_DBG("");
106107

107108
time_diff = now - sub->beacon_sent;
109+
time_since_last_recv = now - sub->beacon_recv;
108110
if (time_diff < (600 * MSEC_PER_SEC) &&
109-
time_diff < BEACON_THRESHOLD(sub)) {
111+
(time_diff < BEACON_THRESHOLD(sub) ||
112+
time_since_last_recv < (10 * MSEC_PER_SEC))) {
110113
return false;
111114
}
112115

@@ -374,6 +377,7 @@ static void secure_beacon_recv(struct net_buf_simple *buf)
374377
if (bt_mesh_beacon_enabled() &&
375378
sub->beacons_cur < 0xff) {
376379
sub->beacons_cur++;
380+
sub->beacon_recv = k_uptime_get_32();
377381
}
378382
}
379383

subsys/bluetooth/mesh/subnet.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ struct bt_mesh_net_cred {
3636
/** Subnet instance. */
3737
struct bt_mesh_subnet {
3838
uint32_t beacon_sent; /* Timestamp of last sent beacon */
39+
uint32_t beacon_recv; /* Timestamp of last received beacon */
3940
uint8_t beacons_last; /* Number of beacons during last
4041
* observation window
4142
*/

0 commit comments

Comments
 (0)