From 61c3b3059348845a255ef2b88a61800a3f7d2283 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Kopy=C5=9Bci=C5=84ski?= Date: Wed, 18 Nov 2020 08:52:42 +0100 Subject: [PATCH] mesh: Remove `bt_mesh_net_start` Move `bt_mesh_net_start` functionality to `bt_mesh_start` this is port of 627ee1125b808dc6bda427efca25f8fc73ff4fff --- nimble/host/mesh/src/mesh.c | 30 +++++++++++++++++++++++++++++- nimble/host/mesh/src/net.c | 32 -------------------------------- nimble/host/mesh/src/net.h | 2 -- 3 files changed, 29 insertions(+), 35 deletions(-) diff --git a/nimble/host/mesh/src/mesh.c b/nimble/host/mesh/src/mesh.c index f289ce8ae..2f9d3e37f 100644 --- a/nimble/host/mesh/src/mesh.c +++ b/nimble/host/mesh/src/mesh.c @@ -20,6 +20,7 @@ #include "prov.h" #include "provisioner.h" #include "net.h" +#include "subnet.h" #include "app_keys.h" #include "rpl.h" #include "beacon.h" @@ -374,7 +375,34 @@ static void model_start(struct bt_mesh_model *mod, struct bt_mesh_elem *elem, int bt_mesh_start(void) { - bt_mesh_net_start(); + if (bt_mesh_beacon_get() == BT_MESH_BEACON_ENABLED) { + bt_mesh_beacon_enable(); + } else { + bt_mesh_beacon_disable(); + } + + if (IS_ENABLED(CONFIG_BT_MESH_GATT_PROXY) && + bt_mesh_gatt_proxy_get() != BT_MESH_GATT_PROXY_NOT_SUPPORTED) { + bt_mesh_proxy_gatt_enable(); + bt_mesh_adv_update(); + } + + if (IS_ENABLED(CONFIG_BT_MESH_LOW_POWER)) { + bt_mesh_lpn_init(); + } else { + bt_mesh_scan_enable(); + } + + if (IS_ENABLED(CONFIG_BT_MESH_FRIEND)) { + bt_mesh_friend_init(); + } + + if (IS_ENABLED(CONFIG_BT_MESH_PROV)) { + struct bt_mesh_subnet *sub = bt_mesh_subnet_next(NULL); + uint16_t addr = bt_mesh_primary_addr(); + + bt_mesh_prov_complete(sub->net_idx, addr); + } bt_mesh_model_foreach(model_start, NULL); return 0; diff --git a/nimble/host/mesh/src/net.c b/nimble/host/mesh/src/net.c index 9aaf16e83..09dc5a74b 100644 --- a/nimble/host/mesh/src/net.c +++ b/nimble/host/mesh/src/net.c @@ -839,38 +839,6 @@ static void ivu_refresh(struct ble_npl_event *work) } } -void bt_mesh_net_start(void) -{ - if (bt_mesh_beacon_get() == BT_MESH_BEACON_ENABLED) { - bt_mesh_beacon_enable(); - } else { - bt_mesh_beacon_disable(); - } - - if (IS_ENABLED(CONFIG_BT_MESH_GATT_PROXY) && - bt_mesh_gatt_proxy_get() != BT_MESH_GATT_PROXY_NOT_SUPPORTED) { - bt_mesh_proxy_gatt_enable(); - bt_mesh_adv_update(); - } - - if (IS_ENABLED(CONFIG_BT_MESH_LOW_POWER)) { - bt_mesh_lpn_init(); - } else { - bt_mesh_scan_enable(); - } - - if (IS_ENABLED(CONFIG_BT_MESH_FRIEND)) { - bt_mesh_friend_init(); - } - - if (IS_ENABLED(CONFIG_BT_MESH_PROV)) { - struct bt_mesh_subnet *sub = bt_mesh_subnet_next(NULL); - uint16_t addr = bt_mesh_primary_addr(); - - bt_mesh_prov_complete(sub->net_idx, addr); - } -} - void bt_mesh_net_init(void) { k_delayed_work_init(&bt_mesh.ivu_timer, ivu_refresh); diff --git a/nimble/host/mesh/src/net.h b/nimble/host/mesh/src/net.h index b3f245769..b1f066832 100644 --- a/nimble/host/mesh/src/net.h +++ b/nimble/host/mesh/src/net.h @@ -283,8 +283,6 @@ void bt_mesh_net_loopback_clear(uint16_t net_idx); uint32_t bt_mesh_next_seq(void); -void bt_mesh_net_start(void); - void bt_mesh_net_init(void); void bt_mesh_net_header_parse(struct os_mbuf *buf, struct bt_mesh_net_rx *rx);