From bfe7f21053059b27f65e36c2d6f4c950b9de22c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Kopy=C5=9Bci=C5=84ski?= Date: Tue, 3 Nov 2020 14:03:30 +0100 Subject: [PATCH] mesh: Add Option config unprov beacon interval 1 Add Option to specifies the second interval when device send Unprovisioned Beacon. 2 Move BT_MESH_LPN_SUB_ALL_NODES_ADDR to LPN subgroup. this is port of 81fc15c4d64aab5f73f8d6ab755fa9688dd67734, c86966719fef7564e7350cae5f0f2ab843f70eaa and 72315cf01e69ec2df802c6417f100a3777cd0345 --- nimble/host/mesh/src/beacon.c | 19 ++++++++++++------- nimble/host/mesh/syscfg.yml | 18 ++++++++++++------ .../linux_blemesh/include/syscfg/syscfg.h | 8 ++++++++ 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/nimble/host/mesh/src/beacon.c b/nimble/host/mesh/src/beacon.c index 7764d86a0..dcc19a80c 100644 --- a/nimble/host/mesh/src/beacon.c +++ b/nimble/host/mesh/src/beacon.c @@ -23,7 +23,6 @@ #include "foundation.h" #include "atomic.h" -#define UNPROVISIONED_INTERVAL (K_SECONDS(5)) #define PROVISIONED_INTERVAL (K_SECONDS(10)) #define BEACON_TYPE_UNPROVISIONED 0x00 @@ -203,7 +202,6 @@ static int unprovisioned_beacon_send(void) static void unprovisioned_beacon_recv(struct os_mbuf *buf) { -#if MYNEWT_VAL(BLE_MESH_PB_ADV) const struct bt_mesh_prov *prov; u8_t *uuid; u16_t oob_info; @@ -232,7 +230,6 @@ static void unprovisioned_beacon_recv(struct os_mbuf *buf) (bt_mesh_prov_oob_info_t)oob_info, uri_hash); } -#endif } static void update_beacon_observation(void) @@ -265,7 +262,8 @@ static void beacon_send(struct ble_npl_event *work) { /* Don't send anything if we have an active provisioning link */ if ((MYNEWT_VAL(BLE_MESH_PROV)) && bt_prov_active()) { - k_delayed_work_submit(&beacon_timer, UNPROVISIONED_INTERVAL); + k_delayed_work_submit(&beacon_timer, + K_SECONDS(MYNEWT_VAL(BLE_MESH_UNPROV_BEACON_INT))); return; } @@ -281,9 +279,14 @@ static void beacon_send(struct ble_npl_event *work) k_delayed_work_submit(&beacon_timer, PROVISIONED_INTERVAL); } - } else if (IS_ENABLED(CONFIG_BT_MESH_PB_ADV)) { + + return; + } + + if (IS_ENABLED(BLE_MESH_PB_ADV)) { unprovisioned_beacon_send(); - k_delayed_work_submit(&beacon_timer, UNPROVISIONED_INTERVAL); + k_delayed_work_submit(&beacon_timer, + K_SECONDS(MYNEWT_VAL(BLE_MESH_UNPROV_BEACON_INT))); } } @@ -381,7 +384,9 @@ void bt_mesh_beacon_recv(struct os_mbuf *buf) type = net_buf_simple_pull_u8(buf); switch (type) { case BEACON_TYPE_UNPROVISIONED: - unprovisioned_beacon_recv(buf); + if (IS_ENABLED(BLE_MESH_PB_ADV)) { + unprovisioned_beacon_recv(buf); + } break; case BEACON_TYPE_SECURE: secure_beacon_recv(buf); diff --git a/nimble/host/mesh/syscfg.yml b/nimble/host/mesh/syscfg.yml index 197661f77..036e66c14 100644 --- a/nimble/host/mesh/syscfg.yml +++ b/nimble/host/mesh/syscfg.yml @@ -29,6 +29,12 @@ syscfg.defs: the advertising bearer. value: 1 + BLE_MESH_UNPROV_BEACON_INT: + description: > + This option specifies the interval (in seconds) at which the + device sends unprovisioned beacon. + value: 5 + BLE_MESH_PROVISIONER: description: > Enable this option to have support for provisioning remote devices. @@ -356,6 +362,12 @@ syscfg.defs: Maximum number of groups that the LPN can subscribe to. value: 10 + BLE_MESH_LPN_SUB_ALL_NODES_ADDR: + description: > + Automatically subscribe all nodes address when friendship + established. + value: 1 + BLE_MESH_FRIEND: description: > Enable this option to be able to act as a Friend Node. @@ -378,12 +390,6 @@ syscfg.defs: Friend node for a Low Power node. value: 3 - BLE_MESH_LPN_SUB_ALL_NODES_ADDR: - description: > - Automatically subscribe all nodes address when friendship - established. - value: 0 - BLE_MESH_FRIEND_LPN_COUNT: description: > Number of Low Power Nodes the Friend can have a Friendship diff --git a/porting/examples/linux_blemesh/include/syscfg/syscfg.h b/porting/examples/linux_blemesh/include/syscfg/syscfg.h index 341a1dcf7..0d66805e2 100644 --- a/porting/examples/linux_blemesh/include/syscfg/syscfg.h +++ b/porting/examples/linux_blemesh/include/syscfg/syscfg.h @@ -912,6 +912,10 @@ #define MYNEWT_VAL_BLE_MESH_LPN_GROUPS (10) #endif +#ifndef MYNEWT_VAL_BLE_MESH_LPN_SUB_ALL_NODES_ADDR +#define MYNEWT_VAL_BLE_MESH_LPN_SUB_ALL_NODES_ADDR (1) +#endif + #ifndef MYNEWT_VAL_BLE_MESH_LPN_INIT_POLL_TIMEOUT #define MYNEWT_VAL_BLE_MESH_LPN_INIT_POLL_TIMEOUT (MYNEWT_VAL_BLE_MESH_LPN_POLL_TIMEOUT) #endif @@ -1151,6 +1155,10 @@ #define MYNEWT_VAL_BLE_MESH_RX_SEG_MSG_COUNT (3) #endif +#ifndef MYNEWT_VAL_BLE_MESH_UNPROV_BEACON_INT +#define MYNEWT_VAL_BLE_MESH_UNPROV_BEACON_INT (5) +#endif + #ifndef MYNEWT_VAL_BLE_MESH_TX_SEG_MSG_COUNT #define MYNEWT_VAL_BLE_MESH_TX_SEG_MSG_COUNT (4) #endif