Bluetooth: Mesh: Rename bt_mesh_pb_gatt<*> function
Rename bt_mesh_pb_gatt_<*> function, and split from proxy.h Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
This commit is contained in:
parent
b2889903a3
commit
c057a69a2c
10 changed files with 47 additions and 17 deletions
|
@ -21,6 +21,7 @@
|
||||||
#include "adv.h"
|
#include "adv.h"
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
|
#include "pb_gatt_srv.h"
|
||||||
|
|
||||||
/* Convert from ms to 0.625ms units */
|
/* Convert from ms to 0.625ms units */
|
||||||
#define ADV_INT_FAST_MS 20
|
#define ADV_INT_FAST_MS 20
|
||||||
|
@ -182,7 +183,7 @@ static void send_pending_adv(struct k_work *work)
|
||||||
BT_DBG("Proxy Advertising");
|
BT_DBG("Proxy Advertising");
|
||||||
}
|
}
|
||||||
} else if (IS_ENABLED(CONFIG_BT_MESH_PB_GATT)) {
|
} 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");
|
BT_DBG("PB-GATT Advertising");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "host/ecc.h"
|
#include "host/ecc.h"
|
||||||
#include "prov.h"
|
#include "prov.h"
|
||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
|
#include "pb_gatt_srv.h"
|
||||||
|
|
||||||
/* Pre-5.0 controllers enforce a minimum interval of 100ms
|
/* Pre-5.0 controllers enforce a minimum interval of 100ms
|
||||||
* whereas 5.0+ controllers can go down to 20ms.
|
* 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");
|
BT_DBG("Proxy Advertising");
|
||||||
}
|
}
|
||||||
} else if (IS_ENABLED(CONFIG_BT_MESH_PB_GATT)) {
|
} 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");
|
BT_DBG("PB-GATT Advertising");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include "access.h"
|
#include "access.h"
|
||||||
#include "foundation.h"
|
#include "foundation.h"
|
||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
|
#include "pb_gatt_srv.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "mesh.h"
|
#include "mesh.h"
|
||||||
|
|
||||||
|
@ -357,7 +358,7 @@ int bt_mesh_start(void)
|
||||||
if (!IS_ENABLED(CONFIG_BT_MESH_PROV) || !bt_mesh_prov_active() ||
|
if (!IS_ENABLED(CONFIG_BT_MESH_PROV) || !bt_mesh_prov_active() ||
|
||||||
bt_mesh_prov_link.bearer->type == BT_MESH_PROV_ADV) {
|
bt_mesh_prov_link.bearer->type == BT_MESH_PROV_ADV) {
|
||||||
if (IS_ENABLED(CONFIG_BT_MESH_PB_GATT)) {
|
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)) {
|
if (IS_ENABLED(CONFIG_BT_MESH_GATT_PROXY)) {
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "adv.h"
|
#include "adv.h"
|
||||||
#include "host/ecc.h"
|
#include "host/ecc.h"
|
||||||
#include "prov.h"
|
#include "prov.h"
|
||||||
|
#include "pb_gatt_srv.h"
|
||||||
|
|
||||||
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_PROV)
|
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_PROV)
|
||||||
#define LOG_MODULE_NAME bt_mesh_pb_gatt
|
#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. */
|
/* If this fails, the protocol timeout handler will exit early. */
|
||||||
(void)k_work_cancel_delayable(&link.prot_timer);
|
(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)
|
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)
|
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();
|
bt_mesh_adv_update();
|
||||||
|
|
||||||
link.cb = cb;
|
link.cb = cb;
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "access.h"
|
#include "access.h"
|
||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
#include "proxy_msg.h"
|
#include "proxy_msg.h"
|
||||||
|
#include "pb_gatt_srv.h"
|
||||||
|
|
||||||
#define CLIENT_BUF_SIZE 66
|
#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);
|
bt_mesh_pb_gatt_close(conn);
|
||||||
|
|
||||||
if (bt_mesh_is_provisioned()) {
|
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)) {
|
if (IS_ENABLED(CONFIG_BT_MESH_GATT_PROXY)) {
|
||||||
(void)bt_mesh_proxy_gatt_enable();
|
(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();
|
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;
|
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);
|
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("");
|
BT_DBG("");
|
||||||
|
|
||||||
|
@ -200,7 +201,7 @@ int bt_mesh_proxy_prov_enable(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bt_mesh_proxy_prov_disable(void)
|
int bt_mesh_pb_gatt_disable(void)
|
||||||
{
|
{
|
||||||
BT_DBG("");
|
BT_DBG("");
|
||||||
|
|
||||||
|
@ -281,7 +282,7 @@ static int gatt_send(struct bt_conn *conn,
|
||||||
return bt_gatt_notify_cb(conn, ¶ms);
|
return bt_gatt_notify_cb(conn, ¶ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
int bt_mesh_prov_adv_start(void)
|
int bt_mesh_pb_gatt_adv_start(void)
|
||||||
{
|
{
|
||||||
BT_DBG("");
|
BT_DBG("");
|
||||||
|
|
||||||
|
|
23
subsys/bluetooth/mesh/pb_gatt_srv.h
Normal file
23
subsys/bluetooth/mesh/pb_gatt_srv.h
Normal file
|
@ -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 <bluetooth/gatt.h>
|
||||||
|
|
||||||
|
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_ */
|
|
@ -37,6 +37,7 @@
|
||||||
#include "access.h"
|
#include "access.h"
|
||||||
#include "foundation.h"
|
#include "foundation.h"
|
||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
|
#include "pb_gatt_srv.h"
|
||||||
#include "prov.h"
|
#include "prov.h"
|
||||||
#include "settings.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) &&
|
if (IS_ENABLED(CONFIG_BT_MESH_PB_GATT) &&
|
||||||
(bearers & BT_MESH_PROV_GATT)) {
|
(bearers & BT_MESH_PROV_GATT)) {
|
||||||
(void)bt_mesh_proxy_prov_disable();
|
(void)bt_mesh_pb_gatt_disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -40,10 +40,7 @@ void bt_mesh_proxy_gatt_disconnect(void);
|
||||||
|
|
||||||
void bt_mesh_proxy_beacon_send(struct bt_mesh_subnet *sub);
|
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_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_start(struct bt_mesh_subnet *sub);
|
||||||
void bt_mesh_proxy_identity_stop(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);
|
void bt_mesh_proxy_addr_add(struct net_buf_simple *buf, uint16_t addr);
|
||||||
|
|
||||||
int bt_mesh_proxy_init(void);
|
int bt_mesh_proxy_init(void);
|
||||||
|
|
||||||
#endif /* ZEPHYR_SUBSYS_BLUETOOTH_MESH_PROXY_H_ */
|
|
||||||
|
|
|
@ -18,6 +18,11 @@
|
||||||
#define CFG_FILTER_REMOVE 0x02
|
#define CFG_FILTER_REMOVE 0x02
|
||||||
#define CFG_FILTER_STATUS 0x03
|
#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)))
|
#define PDU_HDR(sar, type) (sar << 6 | (type & BIT_MASK(6)))
|
||||||
|
|
||||||
typedef int (*proxy_send_cb_t)(struct bt_conn *conn,
|
typedef int (*proxy_send_cb_t)(struct bt_conn *conn,
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "heartbeat.h"
|
#include "heartbeat.h"
|
||||||
#include "access.h"
|
#include "access.h"
|
||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
|
#include "pb_gatt_srv.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "cfg.h"
|
#include "cfg.h"
|
||||||
|
|
||||||
|
@ -61,7 +62,7 @@ static int mesh_commit(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_BT_MESH_PB_GATT)) {
|
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();
|
bt_mesh_net_settings_commit();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue