diff --git a/subsys/bluetooth/mesh/adv_ext.c b/subsys/bluetooth/mesh/adv_ext.c index 3466e734fce..eb7d40a4d75 100644 --- a/subsys/bluetooth/mesh/adv_ext.c +++ b/subsys/bluetooth/mesh/adv_ext.c @@ -21,6 +21,7 @@ #include "adv.h" #include "net.h" #include "proxy.h" +#include "pb_gatt_srv.h" /* Convert from ms to 0.625ms units */ #define ADV_INT_FAST_MS 20 @@ -182,7 +183,7 @@ static void send_pending_adv(struct k_work *work) BT_DBG("Proxy Advertising"); } } else if (IS_ENABLED(CONFIG_BT_MESH_PB_GATT)) { - err = bt_mesh_prov_adv_start(); + err = bt_mesh_pb_gatt_adv_start(); BT_DBG("PB-GATT Advertising"); } diff --git a/subsys/bluetooth/mesh/adv_legacy.c b/subsys/bluetooth/mesh/adv_legacy.c index a2568c0fbaf..6933a4912fd 100644 --- a/subsys/bluetooth/mesh/adv_legacy.c +++ b/subsys/bluetooth/mesh/adv_legacy.c @@ -28,6 +28,7 @@ #include "host/ecc.h" #include "prov.h" #include "proxy.h" +#include "pb_gatt_srv.h" /* Pre-5.0 controllers enforce a minimum interval of 100ms * whereas 5.0+ controllers can go down to 20ms. @@ -143,7 +144,7 @@ static void adv_thread(void *p1, void *p2, void *p3) BT_DBG("Proxy Advertising"); } } else if (IS_ENABLED(CONFIG_BT_MESH_PB_GATT)) { - (void)bt_mesh_prov_adv_start(); + (void)bt_mesh_pb_gatt_adv_start(); BT_DBG("PB-GATT Advertising"); } diff --git a/subsys/bluetooth/mesh/main.c b/subsys/bluetooth/mesh/main.c index d8e154fd0d0..d91ae262f30 100644 --- a/subsys/bluetooth/mesh/main.c +++ b/subsys/bluetooth/mesh/main.c @@ -36,6 +36,7 @@ #include "access.h" #include "foundation.h" #include "proxy.h" +#include "pb_gatt_srv.h" #include "settings.h" #include "mesh.h" @@ -357,7 +358,7 @@ int bt_mesh_start(void) if (!IS_ENABLED(CONFIG_BT_MESH_PROV) || !bt_mesh_prov_active() || bt_mesh_prov_link.bearer->type == BT_MESH_PROV_ADV) { if (IS_ENABLED(CONFIG_BT_MESH_PB_GATT)) { - (void)bt_mesh_proxy_prov_disable(); + (void)bt_mesh_pb_gatt_disable(); } if (IS_ENABLED(CONFIG_BT_MESH_GATT_PROXY)) { diff --git a/subsys/bluetooth/mesh/pb_gatt.c b/subsys/bluetooth/mesh/pb_gatt.c index 992eebe8785..e81eece3566 100644 --- a/subsys/bluetooth/mesh/pb_gatt.c +++ b/subsys/bluetooth/mesh/pb_gatt.c @@ -11,6 +11,7 @@ #include "adv.h" #include "host/ecc.h" #include "prov.h" +#include "pb_gatt_srv.h" #define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_PROV) #define LOG_MODULE_NAME bt_mesh_pb_gatt @@ -42,7 +43,7 @@ static void reset_state(void) /* If this fails, the protocol timeout handler will exit early. */ (void)k_work_cancel_delayable(&link.prot_timer); - link.rx_buf = bt_mesh_proxy_get_buf(); + link.rx_buf = bt_mesh_pb_gatt_get_buf(); } static void link_closed(enum prov_bearer_link_status status) @@ -119,7 +120,7 @@ int bt_mesh_pb_gatt_close(struct bt_conn *conn) static int link_accept(const struct prov_bearer_cb *cb, void *cb_data) { - (void)bt_mesh_proxy_prov_enable(); + (void)bt_mesh_pb_gatt_enable(); bt_mesh_adv_update(); link.cb = cb; diff --git a/subsys/bluetooth/mesh/pb_gatt_srv.c b/subsys/bluetooth/mesh/pb_gatt_srv.c index b09fdcb4401..168d9984cdd 100644 --- a/subsys/bluetooth/mesh/pb_gatt_srv.c +++ b/subsys/bluetooth/mesh/pb_gatt_srv.c @@ -30,6 +30,7 @@ #include "access.h" #include "proxy.h" #include "proxy_msg.h" +#include "pb_gatt_srv.h" #define CLIENT_BUF_SIZE 66 @@ -113,7 +114,7 @@ static void gatt_disconnected(struct bt_conn *conn, uint8_t reason) bt_mesh_pb_gatt_close(conn); if (bt_mesh_is_provisioned()) { - (void)bt_mesh_proxy_prov_disable(); + (void)bt_mesh_pb_gatt_disable(); if (IS_ENABLED(CONFIG_BT_MESH_GATT_PROXY)) { (void)bt_mesh_proxy_gatt_enable(); @@ -126,7 +127,7 @@ static void gatt_disconnected(struct bt_conn *conn, uint8_t reason) bt_mesh_adv_update(); } -struct net_buf_simple *bt_mesh_proxy_get_buf(void) +struct net_buf_simple *bt_mesh_pb_gatt_get_buf(void) { struct net_buf_simple *buf = &cli.buf; @@ -181,7 +182,7 @@ static struct bt_gatt_attr prov_attrs[] = { static struct bt_gatt_service prov_svc = BT_GATT_SERVICE(prov_attrs); -int bt_mesh_proxy_prov_enable(void) +int bt_mesh_pb_gatt_enable(void) { BT_DBG(""); @@ -200,7 +201,7 @@ int bt_mesh_proxy_prov_enable(void) return 0; } -int bt_mesh_proxy_prov_disable(void) +int bt_mesh_pb_gatt_disable(void) { BT_DBG(""); @@ -281,7 +282,7 @@ static int gatt_send(struct bt_conn *conn, return bt_gatt_notify_cb(conn, ¶ms); } -int bt_mesh_prov_adv_start(void) +int bt_mesh_pb_gatt_adv_start(void) { BT_DBG(""); diff --git a/subsys/bluetooth/mesh/pb_gatt_srv.h b/subsys/bluetooth/mesh/pb_gatt_srv.h new file mode 100644 index 00000000000..d1501682f02 --- /dev/null +++ b/subsys/bluetooth/mesh/pb_gatt_srv.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2017 Intel Corporation + * Copyright (c) 2021 Lingao Meng + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_SUBSYS_BLUETOOTH_MESH_PB_GATT_SRV_H_ +#define ZEPHYR_SUBSYS_BLUETOOTH_MESH_PB_GATT_SRV_H_ + +#include + +int bt_mesh_pb_gatt_send(struct bt_conn *conn, struct net_buf_simple *buf, + bt_gatt_complete_func_t end, void *user_data); + +int bt_mesh_pb_gatt_enable(void); +int bt_mesh_pb_gatt_disable(void); + +struct net_buf_simple *bt_mesh_pb_gatt_get_buf(void); + +int bt_mesh_pb_gatt_adv_start(void); + +#endif /* ZEPHYR_SUBSYS_BLUETOOTH_MESH_PB_GATT_SRV_H_ */ diff --git a/subsys/bluetooth/mesh/prov_device.c b/subsys/bluetooth/mesh/prov_device.c index ef6eca7e0ad..dede7a7e067 100644 --- a/subsys/bluetooth/mesh/prov_device.c +++ b/subsys/bluetooth/mesh/prov_device.c @@ -37,6 +37,7 @@ #include "access.h" #include "foundation.h" #include "proxy.h" +#include "pb_gatt_srv.h" #include "prov.h" #include "settings.h" @@ -649,7 +650,7 @@ int bt_mesh_prov_disable(bt_mesh_prov_bearer_t bearers) if (IS_ENABLED(CONFIG_BT_MESH_PB_GATT) && (bearers & BT_MESH_PROV_GATT)) { - (void)bt_mesh_proxy_prov_disable(); + (void)bt_mesh_pb_gatt_disable(); } return 0; diff --git a/subsys/bluetooth/mesh/proxy.h b/subsys/bluetooth/mesh/proxy.h index b535fa2e866..2757827b2d8 100644 --- a/subsys/bluetooth/mesh/proxy.h +++ b/subsys/bluetooth/mesh/proxy.h @@ -40,10 +40,7 @@ void bt_mesh_proxy_gatt_disconnect(void); void bt_mesh_proxy_beacon_send(struct bt_mesh_subnet *sub); -struct net_buf_simple *bt_mesh_proxy_get_buf(void); - int bt_mesh_proxy_adv_start(void); -int bt_mesh_prov_adv_start(void); void bt_mesh_proxy_identity_start(struct bt_mesh_subnet *sub); void bt_mesh_proxy_identity_stop(struct bt_mesh_subnet *sub); @@ -52,5 +49,3 @@ bool bt_mesh_proxy_relay(struct net_buf *buf, uint16_t dst); void bt_mesh_proxy_addr_add(struct net_buf_simple *buf, uint16_t addr); int bt_mesh_proxy_init(void); - -#endif /* ZEPHYR_SUBSYS_BLUETOOTH_MESH_PROXY_H_ */ diff --git a/subsys/bluetooth/mesh/proxy_msg.h b/subsys/bluetooth/mesh/proxy_msg.h index a3a4e05f6b8..fb679ec9a0f 100644 --- a/subsys/bluetooth/mesh/proxy_msg.h +++ b/subsys/bluetooth/mesh/proxy_msg.h @@ -18,6 +18,11 @@ #define CFG_FILTER_REMOVE 0x02 #define CFG_FILTER_STATUS 0x03 +#define BT_MESH_PROXY_NET_PDU 0x00 +#define BT_MESH_PROXY_BEACON 0x01 +#define BT_MESH_PROXY_CONFIG 0x02 +#define BT_MESH_PROXY_PROV 0x03 + #define PDU_HDR(sar, type) (sar << 6 | (type & BIT_MASK(6))) typedef int (*proxy_send_cb_t)(struct bt_conn *conn, diff --git a/subsys/bluetooth/mesh/settings.c b/subsys/bluetooth/mesh/settings.c index e29a1449c64..33f1e0703cb 100644 --- a/subsys/bluetooth/mesh/settings.c +++ b/subsys/bluetooth/mesh/settings.c @@ -26,6 +26,7 @@ #include "heartbeat.h" #include "access.h" #include "proxy.h" +#include "pb_gatt_srv.h" #include "settings.h" #include "cfg.h" @@ -61,7 +62,7 @@ static int mesh_commit(void) } if (IS_ENABLED(CONFIG_BT_MESH_PB_GATT)) { - (void)bt_mesh_proxy_prov_disable(); + (void)bt_mesh_pb_gatt_disable(); } bt_mesh_net_settings_commit();