Bluetooth: Mesh: Add Option config unprov beacon interval

Add Option to specifies the second interval when device
send Unprovisioned Beacon.

Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
This commit is contained in:
Lingao Meng 2020-08-10 10:55:21 +08:00 committed by Johan Hedberg
commit f869e51c25
2 changed files with 22 additions and 6 deletions

View file

@ -29,6 +29,15 @@ config BT_MESH_PB_ADV
Enable this option to allow the device to be provisioned over
the advertising bearer.
config BT_MESH_UNPROV_BEACON_INT
int "The interval (in seconds) to send the unprovisioned beacon"
default 5
range 1 10
depends on BT_MESH_PB_ADV
help
This option specifies the interval (in seconds) at which the
device sends unprovisioned beacon.
config BT_MESH_PROVISIONER
bool "Provisioner support"
select BT_MESH_PROV
@ -428,6 +437,7 @@ config BT_MESH_LPN_GROUPS
default 8
help
Maximum number of groups that the LPN can subscribe to.
endif # BT_MESH_LOW_POWER
config BT_MESH_FRIEND

View file

@ -27,7 +27,6 @@
#include "beacon.h"
#include "foundation.h"
#define UNPROVISIONED_INTERVAL K_SECONDS(5)
#define PROVISIONED_INTERVAL K_SECONDS(10)
#define BEACON_TYPE_UNPROVISIONED 0x00
@ -149,6 +148,7 @@ static int secure_beacon_send(void)
return 0;
}
#if defined(CONFIG_BT_MESH_PB_ADV)
static int unprovisioned_beacon_send(void)
{
const struct bt_mesh_prov *prov;
@ -204,6 +204,7 @@ static int unprovisioned_beacon_send(void)
return 0;
}
#endif
static void unprovisioned_beacon_recv(struct net_buf_simple *buf)
{
@ -268,10 +269,12 @@ static void update_beacon_observation(void)
static void beacon_send(struct k_work *work)
{
/* Don't send anything if we have an active provisioning link */
if (IS_ENABLED(CONFIG_BT_MESH_PROV) && bt_prov_active()) {
k_delayed_work_submit(&beacon_timer, UNPROVISIONED_INTERVAL);
#if defined(CONFIG_BT_MESH_PB_ADV)
if (bt_prov_active()) {
k_delayed_work_submit(&beacon_timer, K_SECONDS(CONFIG_BT_MESH_UNPROV_BEACON_INT));
return;
}
#endif
BT_DBG("");
@ -285,10 +288,13 @@ static void beacon_send(struct k_work *work)
k_delayed_work_submit(&beacon_timer,
PROVISIONED_INTERVAL);
}
} else if (IS_ENABLED(CONFIG_BT_MESH_PB_ADV)) {
unprovisioned_beacon_send();
k_delayed_work_submit(&beacon_timer, UNPROVISIONED_INTERVAL);
return;
}
#if defined(CONFIG_BT_MESH_PB_ADV)
unprovisioned_beacon_send();
k_delayed_work_submit(&beacon_timer, K_SECONDS(CONFIG_BT_MESH_UNPROV_BEACON_INT));
#endif
}
static void secure_beacon_recv(struct net_buf_simple *buf)