Bluetooth: Mesh: Modularizing the proxy
The Bluetooth proxy feature includes proxy client and proxy server. In addition to the proxy pdu message used above, pb-gatt also uses the same proxy pdu message. Currently zephyr bluetooth mesh couples them in one file. A file at the separation is called gatt_services.c, which is used to contain Mesh Provisioning Service and Mesh Proxy Service. Another file in the separation is called proxy_msg.c, which is used to process Proxy pdu messages. Also according to Trond's suggestion: Rename `CONFIG_BT_MESH_PROXY` to `CONFIG_BT_MESH_GATT`. Create an additional promptless entry `CONFIG_BT_MESH_GATT_SERVER` that selects `CONFIG_BT_MESH_GATT` and is selected by `CONFIG_BT_MESH_GATT_PROXY` or `CONFIG_BT_MESH_PB_GATT`. Create additional `CONFIG_BT_MESH_PROXY` used to represent proxy feature (also include proxy client). see #36343 Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
This commit is contained in:
parent
4268592dc2
commit
3a559e972a
11 changed files with 1339 additions and 1242 deletions
|
@ -132,7 +132,7 @@
|
|||
Z_ITERABLE_SECTION_ROM(bt_mesh_lpn_cb, 4)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_MESH_PROXY)
|
||||
#if defined(CONFIG_BT_MESH_GATT_PROXY)
|
||||
Z_ITERABLE_SECTION_ROM(bt_mesh_proxy_cb, 4)
|
||||
#endif
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ config BT_BUF_ACL_RX_SIZE
|
|||
default 200 if BT_BREDR
|
||||
# Mesh Proxy Recommended: 64 Pkey + 2 Bytes Mesh header.
|
||||
# Overhead: ATT Write command Header (3) in an L2CAP PDU (4).
|
||||
default 73 if BT_MESH_PROXY
|
||||
default 73 if BT_MESH_GATT
|
||||
default 70 if BT_EATT
|
||||
default 69 if BT_SMP
|
||||
default 27
|
||||
|
|
|
@ -29,7 +29,7 @@ config BT_L2CAP_TX_FRAG_COUNT
|
|||
config BT_L2CAP_TX_MTU
|
||||
int "Maximum supported L2CAP MTU for L2CAP TX buffers"
|
||||
default 253 if BT_BREDR
|
||||
default 69 if BT_MESH_PROXY
|
||||
default 69 if BT_MESH_GATT
|
||||
default 65 if BT_SMP
|
||||
default 23
|
||||
range 65 2000 if BT_SMP
|
||||
|
|
|
@ -41,7 +41,9 @@ zephyr_library_sources_ifdef(CONFIG_BT_MESH_PB_ADV pb_adv.c)
|
|||
|
||||
zephyr_library_sources_ifdef(CONFIG_BT_MESH_PB_GATT pb_gatt.c)
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_BT_MESH_PROXY proxy.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_BT_MESH_GATT_SERVER gatt_services.c)
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_BT_MESH_GATT proxy.c)
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_BT_MESH_CFG_CLI cfg_cli.c)
|
||||
|
||||
|
|
|
@ -103,11 +103,18 @@ if BT_CONN
|
|||
# Virtual option enabled whenever any Proxy protocol is needed
|
||||
config BT_MESH_PROXY
|
||||
bool
|
||||
|
||||
config BT_MESH_GATT
|
||||
bool
|
||||
|
||||
config BT_MESH_GATT_SERVER
|
||||
bool
|
||||
select BT_MESH_GATT
|
||||
select BT_GATT_DYNAMIC_DB
|
||||
|
||||
config BT_MESH_PB_GATT
|
||||
bool "Provisioning support using GATT (PB-GATT)"
|
||||
select BT_MESH_PROXY
|
||||
select BT_MESH_GATT_SERVER
|
||||
select BT_MESH_PROV
|
||||
help
|
||||
Enable this option to allow the device to be provisioned over
|
||||
|
@ -115,6 +122,7 @@ config BT_MESH_PB_GATT
|
|||
|
||||
config BT_MESH_GATT_PROXY
|
||||
bool "GATT Proxy Service support"
|
||||
select BT_MESH_GATT_SERVER
|
||||
select BT_MESH_PROXY
|
||||
help
|
||||
This option enables support for the Mesh GATT Proxy Service,
|
||||
|
@ -141,16 +149,6 @@ config BT_MESH_NODE_ID_TIMEOUT
|
|||
be the appropriate value as well, so just leaving this as the
|
||||
default is the safest option.
|
||||
|
||||
config BT_MESH_PROXY_FILTER_SIZE
|
||||
int "Maximum number of filter entries per Proxy Client"
|
||||
default 3 if BT_MESH_GATT_PROXY
|
||||
default 1
|
||||
range 1 32767
|
||||
depends on BT_MESH_PROXY
|
||||
help
|
||||
This option specifies how many Proxy Filter entries the local
|
||||
node supports.
|
||||
|
||||
config BT_MESH_PROXY_USE_DEVICE_NAME
|
||||
bool "Include Bluetooth device name in scan response"
|
||||
depends on BT_MESH_GATT_PROXY
|
||||
|
@ -158,6 +156,16 @@ config BT_MESH_PROXY_USE_DEVICE_NAME
|
|||
This option includes GAP device name in scan response when
|
||||
the GATT Proxy feature is enabled.
|
||||
|
||||
config BT_MESH_PROXY_FILTER_SIZE
|
||||
int "Maximum number of filter entries per Proxy Client"
|
||||
default 3 if BT_MESH_GATT_PROXY
|
||||
default 1
|
||||
range 1 32767
|
||||
depends on BT_MESH_GATT_SERVER
|
||||
help
|
||||
This option specifies how many Proxy Filter entries the local
|
||||
node supports.
|
||||
|
||||
endif # BT_CONN
|
||||
|
||||
config BT_MESH_SELF_TEST
|
||||
|
@ -834,7 +842,7 @@ config BT_MESH_DEBUG_FRIEND
|
|||
|
||||
config BT_MESH_DEBUG_PROXY
|
||||
bool "Proxy debug"
|
||||
depends on BT_MESH_PROXY
|
||||
depends on BT_MESH_GATT
|
||||
help
|
||||
Use this option to enable Proxy protocol debug logs.
|
||||
|
||||
|
|
|
@ -174,7 +174,7 @@ static void send_pending_adv(struct k_work *work)
|
|||
}
|
||||
|
||||
/* No more pending buffers */
|
||||
if (IS_ENABLED(CONFIG_BT_MESH_PROXY)) {
|
||||
if (IS_ENABLED(CONFIG_BT_MESH_GATT_SERVER)) {
|
||||
BT_DBG("Proxy Advertising");
|
||||
err = bt_mesh_proxy_adv_start();
|
||||
if (!err) {
|
||||
|
|
|
@ -108,7 +108,7 @@ static void adv_thread(void *p1, void *p2, void *p3)
|
|||
while (1) {
|
||||
struct net_buf *buf;
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_MESH_PROXY)) {
|
||||
if (IS_ENABLED(CONFIG_BT_MESH_GATT_SERVER)) {
|
||||
buf = net_buf_get(&bt_mesh_adv_queue, K_NO_WAIT);
|
||||
while (!buf) {
|
||||
|
||||
|
|
1226
subsys/bluetooth/mesh/gatt_services.c
Normal file
1226
subsys/bluetooth/mesh/gatt_services.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -321,7 +321,7 @@ int bt_mesh_init(const struct bt_mesh_prov *prov,
|
|||
return err;
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_MESH_PROXY)) {
|
||||
if (IS_ENABLED(CONFIG_BT_MESH_GATT)) {
|
||||
bt_mesh_proxy_init();
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -14,11 +14,47 @@
|
|||
int bt_mesh_pb_gatt_send(struct bt_conn *conn, struct net_buf_simple *buf,
|
||||
bt_gatt_complete_func_t end, void *user_data);
|
||||
|
||||
#define PDU_TYPE(data) (data[0] & BIT_MASK(6))
|
||||
#define CFG_FILTER_SET 0x00
|
||||
#define CFG_FILTER_ADD 0x01
|
||||
#define CFG_FILTER_REMOVE 0x02
|
||||
#define CFG_FILTER_STATUS 0x03
|
||||
|
||||
#define PDU_HDR(sar, type) (sar << 6 | (type & BIT_MASK(6)))
|
||||
|
||||
typedef int (*proxy_send_cb_t)(struct bt_conn *conn,
|
||||
const void *data, uint16_t len,
|
||||
bt_gatt_complete_func_t end, void *user_data);
|
||||
|
||||
typedef void (*proxy_recv_cb_t)(struct bt_conn *conn,
|
||||
struct bt_mesh_net_rx *rx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
struct bt_mesh_proxy_role {
|
||||
struct bt_conn *conn;
|
||||
uint8_t msg_type;
|
||||
|
||||
struct {
|
||||
proxy_send_cb_t send;
|
||||
proxy_recv_cb_t recv;
|
||||
} cb;
|
||||
|
||||
struct k_work_delayable sar_timer;
|
||||
struct net_buf_simple buf;
|
||||
};
|
||||
|
||||
#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
|
||||
|
||||
ssize_t bt_mesh_proxy_msg_recv(struct bt_mesh_proxy_role *role,
|
||||
const void *buf, uint16_t len);
|
||||
int bt_mesh_proxy_msg_send(struct bt_mesh_proxy_role *role, uint8_t type,
|
||||
struct net_buf_simple *msg,
|
||||
bt_gatt_complete_func_t end, void *user_data);
|
||||
void bt_mesh_proxy_msg_init(struct bt_mesh_proxy_role *role);
|
||||
|
||||
int bt_mesh_proxy_prov_enable(void);
|
||||
int bt_mesh_proxy_prov_disable(bool disconnect);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue