2017-06-16 12:30:54 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2017 Intel Corporation
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <zephyr.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#include <net/buf.h>
|
|
|
|
#include <bluetooth/bluetooth.h>
|
|
|
|
#include <bluetooth/conn.h>
|
2018-08-16 13:51:24 +03:00
|
|
|
#include <bluetooth/uuid.h>
|
2017-06-16 12:30:54 +03:00
|
|
|
#include <bluetooth/mesh.h>
|
|
|
|
|
2017-08-09 09:21:11 +03:00
|
|
|
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG)
|
2018-07-17 10:35:52 +03:00
|
|
|
#define LOG_MODULE_NAME bt_mesh_main
|
2017-06-16 12:30:54 +03:00
|
|
|
#include "common/log.h"
|
|
|
|
|
|
|
|
#include "test.h"
|
|
|
|
#include "adv.h"
|
2021-08-09 12:18:08 +02:00
|
|
|
#include "host/ecc.h"
|
2017-06-16 12:30:54 +03:00
|
|
|
#include "prov.h"
|
2020-09-17 13:47:37 +08:00
|
|
|
#include "provisioner.h"
|
2017-06-16 12:30:54 +03:00
|
|
|
#include "net.h"
|
2020-10-22 22:16:33 +08:00
|
|
|
#include "subnet.h"
|
2020-08-25 11:03:42 +02:00
|
|
|
#include "app_keys.h"
|
2020-09-09 16:59:43 +08:00
|
|
|
#include "rpl.h"
|
2020-08-18 13:36:38 +02:00
|
|
|
#include "cfg.h"
|
2017-06-16 12:30:54 +03:00
|
|
|
#include "beacon.h"
|
|
|
|
#include "lpn.h"
|
|
|
|
#include "friend.h"
|
|
|
|
#include "transport.h"
|
2020-08-12 17:07:38 +02:00
|
|
|
#include "heartbeat.h"
|
2017-06-16 12:30:54 +03:00
|
|
|
#include "access.h"
|
|
|
|
#include "foundation.h"
|
|
|
|
#include "proxy.h"
|
2021-08-19 09:25:25 +08:00
|
|
|
#include "pb_gatt_srv.h"
|
2018-05-07 12:23:37 +03:00
|
|
|
#include "settings.h"
|
2017-06-16 12:30:54 +03:00
|
|
|
#include "mesh.h"
|
2022-02-07 17:13:02 +08:00
|
|
|
#include "gatt_cli.h"
|
2017-06-16 12:30:54 +03:00
|
|
|
|
2020-05-27 11:26:57 -05:00
|
|
|
int bt_mesh_provision(const uint8_t net_key[16], uint16_t net_idx,
|
|
|
|
uint8_t flags, uint32_t iv_index, uint16_t addr,
|
|
|
|
const uint8_t dev_key[16])
|
2017-06-16 12:30:54 +03:00
|
|
|
{
|
|
|
|
int err;
|
2022-02-18 16:42:58 +08:00
|
|
|
struct bt_mesh_cdb_subnet *subnet = NULL;
|
2017-06-16 12:30:54 +03:00
|
|
|
|
|
|
|
BT_INFO("Primary Element: 0x%04x", addr);
|
2017-11-05 21:45:24 +02:00
|
|
|
BT_DBG("net_idx 0x%04x flags 0x%02x iv_index 0x%04x",
|
|
|
|
net_idx, flags, iv_index);
|
2017-06-16 12:30:54 +03:00
|
|
|
|
2019-01-25 18:24:44 +02:00
|
|
|
if (atomic_test_and_set_bit(bt_mesh.flags, BT_MESH_VALID)) {
|
|
|
|
return -EALREADY;
|
|
|
|
}
|
|
|
|
|
2021-04-20 15:23:55 +02:00
|
|
|
if (IS_ENABLED(CONFIG_BT_MESH_CDB) &&
|
|
|
|
atomic_test_bit(bt_mesh_cdb.flags, BT_MESH_CDB_VALID)) {
|
2019-11-04 16:14:07 +01:00
|
|
|
const struct bt_mesh_comp *comp;
|
|
|
|
const struct bt_mesh_prov *prov;
|
|
|
|
struct bt_mesh_cdb_node *node;
|
|
|
|
|
|
|
|
comp = bt_mesh_comp_get();
|
|
|
|
if (comp == NULL) {
|
|
|
|
BT_ERR("Failed to get node composition");
|
|
|
|
atomic_clear_bit(bt_mesh.flags, BT_MESH_VALID);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2022-02-18 16:42:58 +08:00
|
|
|
subnet = bt_mesh_cdb_subnet_get(net_idx);
|
|
|
|
if (!subnet) {
|
2019-11-04 16:14:07 +01:00
|
|
|
BT_ERR("No subnet with idx %d", net_idx);
|
|
|
|
atomic_clear_bit(bt_mesh.flags, BT_MESH_VALID);
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
prov = bt_mesh_prov_get();
|
|
|
|
node = bt_mesh_cdb_node_alloc(prov->uuid, addr,
|
|
|
|
comp->elem_count, net_idx);
|
|
|
|
if (node == NULL) {
|
|
|
|
BT_ERR("Failed to allocate database node");
|
|
|
|
atomic_clear_bit(bt_mesh.flags, BT_MESH_VALID);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2022-02-18 16:42:58 +08:00
|
|
|
if (BT_MESH_KEY_REFRESH(flags)) {
|
|
|
|
memcpy(subnet->keys[1].net_key, net_key, 16);
|
|
|
|
subnet->kr_phase = BT_MESH_KR_PHASE_2;
|
|
|
|
} else {
|
|
|
|
memcpy(subnet->keys[0].net_key, net_key, 16);
|
|
|
|
subnet->kr_phase = BT_MESH_KR_NORMAL;
|
|
|
|
}
|
|
|
|
bt_mesh_cdb_subnet_store(subnet);
|
|
|
|
|
2019-11-04 16:14:07 +01:00
|
|
|
addr = node->addr;
|
2022-02-18 16:42:58 +08:00
|
|
|
bt_mesh_cdb_iv_update(iv_index, BT_MESH_IV_UPDATE(flags));
|
|
|
|
|
2019-11-04 16:14:07 +01:00
|
|
|
memcpy(node->dev_key, dev_key, 16);
|
|
|
|
|
|
|
|
if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
|
2021-01-06 09:56:56 +01:00
|
|
|
bt_mesh_cdb_node_store(node);
|
2019-11-04 16:14:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-16 12:30:54 +03:00
|
|
|
err = bt_mesh_net_create(net_idx, flags, net_key, iv_index);
|
|
|
|
if (err) {
|
2019-01-25 18:24:44 +02:00
|
|
|
atomic_clear_bit(bt_mesh.flags, BT_MESH_VALID);
|
2017-06-16 12:30:54 +03:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2018-11-29 11:23:03 -08:00
|
|
|
bt_mesh.seq = 0U;
|
2017-06-16 12:30:54 +03:00
|
|
|
|
|
|
|
bt_mesh_comp_provision(addr);
|
|
|
|
|
|
|
|
memcpy(bt_mesh.dev_key, dev_key, 16);
|
|
|
|
|
2020-04-18 00:15:19 -07:00
|
|
|
if (IS_ENABLED(CONFIG_BT_MESH_LOW_POWER) &&
|
|
|
|
IS_ENABLED(CONFIG_BT_MESH_LPN_SUB_ALL_NODES_ADDR)) {
|
|
|
|
bt_mesh_lpn_group_add(BT_MESH_ADDR_ALL_NODES);
|
|
|
|
}
|
|
|
|
|
2021-02-08 09:21:28 +01:00
|
|
|
if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
|
|
|
|
bt_mesh_net_pending_net_store();
|
|
|
|
}
|
|
|
|
|
2019-12-20 12:18:14 +01:00
|
|
|
bt_mesh_start();
|
2017-11-14 18:45:32 +02:00
|
|
|
|
2017-06-16 12:30:54 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-05-27 11:26:57 -05:00
|
|
|
int bt_mesh_provision_adv(const uint8_t uuid[16], uint16_t net_idx, uint16_t addr,
|
|
|
|
uint8_t attention_duration)
|
2019-07-16 16:05:00 +02:00
|
|
|
{
|
|
|
|
if (!atomic_test_bit(bt_mesh.flags, BT_MESH_VALID)) {
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bt_mesh_subnet_get(net_idx) == NULL) {
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IS_ENABLED(CONFIG_BT_MESH_PROVISIONER) &&
|
|
|
|
IS_ENABLED(CONFIG_BT_MESH_PB_ADV)) {
|
|
|
|
return bt_mesh_pb_adv_open(uuid, net_idx, addr,
|
|
|
|
attention_duration);
|
|
|
|
}
|
|
|
|
|
|
|
|
return -ENOTSUP;
|
|
|
|
}
|
|
|
|
|
2022-02-07 17:25:09 +08:00
|
|
|
int bt_mesh_provision_gatt(const uint8_t uuid[16], uint16_t net_idx, uint16_t addr,
|
|
|
|
uint8_t attention_duration)
|
|
|
|
{
|
|
|
|
if (!atomic_test_bit(bt_mesh.flags, BT_MESH_VALID)) {
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bt_mesh_subnet_get(net_idx) == NULL) {
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IS_ENABLED(CONFIG_BT_MESH_PB_GATT_CLIENT)) {
|
|
|
|
return bt_mesh_pb_gatt_open(uuid, net_idx, addr,
|
|
|
|
attention_duration);
|
|
|
|
}
|
|
|
|
|
|
|
|
return -ENOTSUP;
|
|
|
|
}
|
|
|
|
|
2017-06-16 12:30:54 +03:00
|
|
|
void bt_mesh_reset(void)
|
|
|
|
{
|
2019-01-25 15:57:45 +02:00
|
|
|
if (!atomic_test_bit(bt_mesh.flags, BT_MESH_VALID)) {
|
2017-11-13 20:52:26 +02:00
|
|
|
return;
|
2017-06-16 12:30:54 +03:00
|
|
|
}
|
|
|
|
|
2018-11-29 11:23:03 -08:00
|
|
|
bt_mesh.iv_index = 0U;
|
2021-08-17 16:52:42 +02:00
|
|
|
bt_mesh.ivu_duration = 0;
|
2018-11-29 11:23:03 -08:00
|
|
|
bt_mesh.seq = 0U;
|
2019-01-25 15:57:45 +02:00
|
|
|
|
|
|
|
memset(bt_mesh.flags, 0, sizeof(bt_mesh.flags));
|
2017-06-16 12:30:54 +03:00
|
|
|
|
2021-03-29 08:20:27 -05:00
|
|
|
/* If this fails, the work handler will return early on the next
|
|
|
|
* execution, as the device is not provisioned. If the device is
|
|
|
|
* reprovisioned, the timer is always restarted.
|
|
|
|
*/
|
|
|
|
(void)k_work_cancel_delayable(&bt_mesh.ivu_timer);
|
2017-06-16 12:30:54 +03:00
|
|
|
|
2021-06-23 16:27:35 +02:00
|
|
|
bt_mesh_model_reset();
|
|
|
|
bt_mesh_cfg_default_set();
|
2020-08-18 10:53:15 +02:00
|
|
|
bt_mesh_trans_reset();
|
2020-08-25 11:03:42 +02:00
|
|
|
bt_mesh_app_keys_reset();
|
|
|
|
bt_mesh_net_keys_reset();
|
2017-11-20 14:51:32 +02:00
|
|
|
|
2020-07-10 11:10:55 +02:00
|
|
|
bt_mesh_net_loopback_clear(BT_MESH_KEY_ANY);
|
|
|
|
|
2017-08-09 09:21:11 +03:00
|
|
|
if (IS_ENABLED(CONFIG_BT_MESH_LOW_POWER)) {
|
2020-04-18 00:15:19 -07:00
|
|
|
if (IS_ENABLED(CONFIG_BT_MESH_LPN_SUB_ALL_NODES_ADDR)) {
|
2020-05-27 11:26:57 -05:00
|
|
|
uint16_t group = BT_MESH_ADDR_ALL_NODES;
|
2020-04-18 00:15:19 -07:00
|
|
|
|
|
|
|
bt_mesh_lpn_group_del(&group, 1);
|
|
|
|
}
|
|
|
|
|
2017-11-17 13:06:09 +02:00
|
|
|
bt_mesh_lpn_disable(true);
|
2017-06-16 12:30:54 +03:00
|
|
|
}
|
|
|
|
|
2017-11-27 21:02:38 +02:00
|
|
|
if (IS_ENABLED(CONFIG_BT_MESH_FRIEND)) {
|
2020-08-25 11:03:42 +02:00
|
|
|
bt_mesh_friends_clear();
|
2017-11-27 21:02:38 +02:00
|
|
|
}
|
|
|
|
|
2017-08-09 09:21:11 +03:00
|
|
|
if (IS_ENABLED(CONFIG_BT_MESH_GATT_PROXY)) {
|
2021-07-11 18:34:27 -07:00
|
|
|
(void)bt_mesh_proxy_gatt_disable();
|
2017-06-16 12:30:54 +03:00
|
|
|
}
|
|
|
|
|
2022-02-07 17:13:02 +08:00
|
|
|
if (IS_ENABLED(CONFIG_BT_MESH_GATT_CLIENT)) {
|
|
|
|
bt_mesh_gatt_client_deinit();
|
|
|
|
}
|
|
|
|
|
2018-05-08 09:21:57 +03:00
|
|
|
if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
|
2021-01-06 09:56:56 +01:00
|
|
|
bt_mesh_net_clear();
|
2018-05-08 09:21:57 +03:00
|
|
|
}
|
|
|
|
|
2018-09-11 19:09:03 -07:00
|
|
|
(void)memset(bt_mesh.dev_key, 0, sizeof(bt_mesh.dev_key));
|
2017-06-16 12:30:54 +03:00
|
|
|
|
2017-11-13 20:52:26 +02:00
|
|
|
bt_mesh_scan_disable();
|
|
|
|
bt_mesh_beacon_disable();
|
|
|
|
|
2018-06-26 11:29:24 +03:00
|
|
|
bt_mesh_comp_unprovision();
|
|
|
|
|
2017-11-13 20:52:26 +02:00
|
|
|
if (IS_ENABLED(CONFIG_BT_MESH_PROV)) {
|
|
|
|
bt_mesh_prov_reset();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool bt_mesh_is_provisioned(void)
|
|
|
|
{
|
2019-01-25 15:57:45 +02:00
|
|
|
return atomic_test_bit(bt_mesh.flags, BT_MESH_VALID);
|
2017-11-13 20:52:26 +02:00
|
|
|
}
|
|
|
|
|
2019-01-25 19:25:17 +02:00
|
|
|
static void model_suspend(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
|
|
|
|
bool vnd, bool primary, void *user_data)
|
|
|
|
{
|
|
|
|
if (mod->pub && mod->pub->update) {
|
2019-03-26 19:57:45 -06:00
|
|
|
mod->pub->count = 0U;
|
2021-04-15 12:28:20 +02:00
|
|
|
/* If this fails, the work handler will check the suspend call
|
|
|
|
* and exit without transmitting.
|
|
|
|
*/
|
|
|
|
(void)k_work_cancel_delayable(&mod->pub->timer);
|
2019-01-25 19:25:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int bt_mesh_suspend(void)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (!atomic_test_bit(bt_mesh.flags, BT_MESH_VALID)) {
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (atomic_test_and_set_bit(bt_mesh.flags, BT_MESH_SUSPENDED)) {
|
|
|
|
return -EALREADY;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = bt_mesh_scan_disable();
|
|
|
|
if (err) {
|
|
|
|
atomic_clear_bit(bt_mesh.flags, BT_MESH_SUSPENDED);
|
|
|
|
BT_WARN("Disabling scanning failed (err %d)", err);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2022-02-07 17:13:02 +08:00
|
|
|
if (IS_ENABLED(CONFIG_BT_MESH_GATT_CLIENT)) {
|
|
|
|
bt_mesh_proxy_disconnect(BT_MESH_KEY_ANY);
|
|
|
|
}
|
|
|
|
|
2020-08-12 17:07:38 +02:00
|
|
|
bt_mesh_hb_suspend();
|
2019-01-25 19:25:17 +02:00
|
|
|
|
2020-08-18 13:36:38 +02:00
|
|
|
if (bt_mesh_beacon_enabled()) {
|
2019-01-25 19:25:17 +02:00
|
|
|
bt_mesh_beacon_disable();
|
|
|
|
}
|
|
|
|
|
|
|
|
bt_mesh_model_foreach(model_suspend, NULL);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void model_resume(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
|
|
|
|
bool vnd, bool primary, void *user_data)
|
|
|
|
{
|
|
|
|
if (mod->pub && mod->pub->update) {
|
2020-05-27 11:26:57 -05:00
|
|
|
int32_t period_ms = bt_mesh_model_pub_period_get(mod);
|
2019-01-25 19:25:17 +02:00
|
|
|
|
|
|
|
if (period_ms) {
|
2021-04-15 12:28:20 +02:00
|
|
|
k_work_reschedule(&mod->pub->timer,
|
|
|
|
K_MSEC(period_ms));
|
2019-01-25 19:25:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int bt_mesh_resume(void)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (!atomic_test_bit(bt_mesh.flags, BT_MESH_VALID)) {
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!atomic_test_and_clear_bit(bt_mesh.flags, BT_MESH_SUSPENDED)) {
|
|
|
|
return -EALREADY;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = bt_mesh_scan_enable();
|
|
|
|
if (err) {
|
|
|
|
BT_WARN("Re-enabling scanning failed (err %d)", err);
|
|
|
|
atomic_set_bit(bt_mesh.flags, BT_MESH_SUSPENDED);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2020-08-12 17:07:38 +02:00
|
|
|
bt_mesh_hb_resume();
|
|
|
|
|
2020-08-18 13:36:38 +02:00
|
|
|
if (bt_mesh_beacon_enabled()) {
|
2019-01-25 19:25:17 +02:00
|
|
|
bt_mesh_beacon_enable();
|
|
|
|
}
|
|
|
|
|
|
|
|
bt_mesh_model_foreach(model_resume, NULL);
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2017-06-16 12:30:54 +03:00
|
|
|
int bt_mesh_init(const struct bt_mesh_prov *prov,
|
|
|
|
const struct bt_mesh_comp *comp)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
|
|
|
err = bt_mesh_test();
|
|
|
|
if (err) {
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = bt_mesh_comp_register(comp);
|
|
|
|
if (err) {
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2017-08-09 09:21:11 +03:00
|
|
|
if (IS_ENABLED(CONFIG_BT_MESH_PROV)) {
|
2017-11-02 13:50:29 +01:00
|
|
|
err = bt_mesh_prov_init(prov);
|
|
|
|
if (err) {
|
|
|
|
return err;
|
|
|
|
}
|
2017-06-16 12:30:54 +03:00
|
|
|
}
|
|
|
|
|
2021-06-23 16:27:35 +02:00
|
|
|
bt_mesh_cfg_default_set();
|
2017-06-16 12:30:54 +03:00
|
|
|
bt_mesh_net_init();
|
|
|
|
bt_mesh_trans_init();
|
2020-08-12 17:07:38 +02:00
|
|
|
bt_mesh_hb_init();
|
2017-06-16 12:30:54 +03:00
|
|
|
bt_mesh_beacon_init();
|
|
|
|
bt_mesh_adv_init();
|
|
|
|
|
2018-05-07 22:22:30 +03:00
|
|
|
if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
|
|
|
|
bt_mesh_settings_init();
|
|
|
|
}
|
|
|
|
|
2017-06-16 12:30:54 +03:00
|
|
|
return 0;
|
|
|
|
}
|
2019-12-20 12:18:14 +01:00
|
|
|
|
|
|
|
static void model_start(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
|
|
|
|
bool vnd, bool primary, void *user_data)
|
|
|
|
{
|
|
|
|
if (mod->cb && mod->cb->start) {
|
|
|
|
mod->cb->start(mod);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int bt_mesh_start(void)
|
|
|
|
{
|
2020-11-13 16:21:32 +01:00
|
|
|
int err;
|
|
|
|
|
|
|
|
err = bt_mesh_adv_enable();
|
|
|
|
if (err) {
|
|
|
|
BT_ERR("Failed enabling advertiser");
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2020-08-18 13:36:38 +02:00
|
|
|
if (bt_mesh_beacon_enabled()) {
|
2020-10-22 22:16:33 +08:00
|
|
|
bt_mesh_beacon_enable();
|
|
|
|
} else {
|
|
|
|
bt_mesh_beacon_disable();
|
|
|
|
}
|
|
|
|
|
2021-08-18 16:56:31 +08:00
|
|
|
if (!IS_ENABLED(CONFIG_BT_MESH_PROV) || !bt_mesh_prov_active() ||
|
|
|
|
bt_mesh_prov_link.bearer->type == BT_MESH_PROV_ADV) {
|
2021-07-11 18:34:27 -07:00
|
|
|
if (IS_ENABLED(CONFIG_BT_MESH_PB_GATT)) {
|
2022-02-08 16:44:31 +08:00
|
|
|
(void)bt_mesh_pb_gatt_srv_disable();
|
2021-07-11 18:34:27 -07:00
|
|
|
}
|
|
|
|
|
2021-08-18 16:56:31 +08:00
|
|
|
if (IS_ENABLED(CONFIG_BT_MESH_GATT_PROXY)) {
|
2021-07-11 18:34:27 -07:00
|
|
|
(void)bt_mesh_proxy_gatt_enable();
|
2021-11-18 09:23:08 +08:00
|
|
|
bt_mesh_adv_gatt_update();
|
2021-07-11 18:34:27 -07:00
|
|
|
}
|
2020-10-22 22:16:33 +08:00
|
|
|
}
|
|
|
|
|
2022-02-07 17:13:02 +08:00
|
|
|
if (IS_ENABLED(CONFIG_BT_MESH_GATT_CLIENT)) {
|
|
|
|
bt_mesh_gatt_client_init();
|
|
|
|
}
|
|
|
|
|
2020-10-22 22:16:33 +08:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2020-08-12 17:07:38 +02:00
|
|
|
bt_mesh_hb_start();
|
|
|
|
|
2019-12-20 12:18:14 +01:00
|
|
|
bt_mesh_model_foreach(model_start, NULL);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|