Skip to content

Commit c057a69

Browse files
LingaoMcfriedt
authored andcommitted
Bluetooth: Mesh: Rename bt_mesh_pb_gatt<*> function
Rename bt_mesh_pb_gatt_<*> function, and split from proxy.h Signed-off-by: Lingao Meng <[email protected]>
1 parent b288990 commit c057a69

File tree

10 files changed

+47
-17
lines changed

10 files changed

+47
-17
lines changed

subsys/bluetooth/mesh/adv_ext.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "adv.h"
2222
#include "net.h"
2323
#include "proxy.h"
24+
#include "pb_gatt_srv.h"
2425

2526
/* Convert from ms to 0.625ms units */
2627
#define ADV_INT_FAST_MS 20
@@ -182,7 +183,7 @@ static void send_pending_adv(struct k_work *work)
182183
BT_DBG("Proxy Advertising");
183184
}
184185
} else if (IS_ENABLED(CONFIG_BT_MESH_PB_GATT)) {
185-
err = bt_mesh_prov_adv_start();
186+
err = bt_mesh_pb_gatt_adv_start();
186187
BT_DBG("PB-GATT Advertising");
187188
}
188189

subsys/bluetooth/mesh/adv_legacy.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "host/ecc.h"
2929
#include "prov.h"
3030
#include "proxy.h"
31+
#include "pb_gatt_srv.h"
3132

3233
/* Pre-5.0 controllers enforce a minimum interval of 100ms
3334
* whereas 5.0+ controllers can go down to 20ms.
@@ -143,7 +144,7 @@ static void adv_thread(void *p1, void *p2, void *p3)
143144
BT_DBG("Proxy Advertising");
144145
}
145146
} else if (IS_ENABLED(CONFIG_BT_MESH_PB_GATT)) {
146-
(void)bt_mesh_prov_adv_start();
147+
(void)bt_mesh_pb_gatt_adv_start();
147148
BT_DBG("PB-GATT Advertising");
148149
}
149150

subsys/bluetooth/mesh/main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "access.h"
3737
#include "foundation.h"
3838
#include "proxy.h"
39+
#include "pb_gatt_srv.h"
3940
#include "settings.h"
4041
#include "mesh.h"
4142

@@ -357,7 +358,7 @@ int bt_mesh_start(void)
357358
if (!IS_ENABLED(CONFIG_BT_MESH_PROV) || !bt_mesh_prov_active() ||
358359
bt_mesh_prov_link.bearer->type == BT_MESH_PROV_ADV) {
359360
if (IS_ENABLED(CONFIG_BT_MESH_PB_GATT)) {
360-
(void)bt_mesh_proxy_prov_disable();
361+
(void)bt_mesh_pb_gatt_disable();
361362
}
362363

363364
if (IS_ENABLED(CONFIG_BT_MESH_GATT_PROXY)) {

subsys/bluetooth/mesh/pb_gatt.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "adv.h"
1212
#include "host/ecc.h"
1313
#include "prov.h"
14+
#include "pb_gatt_srv.h"
1415

1516
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_PROV)
1617
#define LOG_MODULE_NAME bt_mesh_pb_gatt
@@ -42,7 +43,7 @@ static void reset_state(void)
4243
/* If this fails, the protocol timeout handler will exit early. */
4344
(void)k_work_cancel_delayable(&link.prot_timer);
4445

45-
link.rx_buf = bt_mesh_proxy_get_buf();
46+
link.rx_buf = bt_mesh_pb_gatt_get_buf();
4647
}
4748

4849
static void link_closed(enum prov_bearer_link_status status)
@@ -119,7 +120,7 @@ int bt_mesh_pb_gatt_close(struct bt_conn *conn)
119120

120121
static int link_accept(const struct prov_bearer_cb *cb, void *cb_data)
121122
{
122-
(void)bt_mesh_proxy_prov_enable();
123+
(void)bt_mesh_pb_gatt_enable();
123124
bt_mesh_adv_update();
124125

125126
link.cb = cb;

subsys/bluetooth/mesh/pb_gatt_srv.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "access.h"
3131
#include "proxy.h"
3232
#include "proxy_msg.h"
33+
#include "pb_gatt_srv.h"
3334

3435
#define CLIENT_BUF_SIZE 66
3536

@@ -113,7 +114,7 @@ static void gatt_disconnected(struct bt_conn *conn, uint8_t reason)
113114
bt_mesh_pb_gatt_close(conn);
114115

115116
if (bt_mesh_is_provisioned()) {
116-
(void)bt_mesh_proxy_prov_disable();
117+
(void)bt_mesh_pb_gatt_disable();
117118

118119
if (IS_ENABLED(CONFIG_BT_MESH_GATT_PROXY)) {
119120
(void)bt_mesh_proxy_gatt_enable();
@@ -126,7 +127,7 @@ static void gatt_disconnected(struct bt_conn *conn, uint8_t reason)
126127
bt_mesh_adv_update();
127128
}
128129

129-
struct net_buf_simple *bt_mesh_proxy_get_buf(void)
130+
struct net_buf_simple *bt_mesh_pb_gatt_get_buf(void)
130131
{
131132
struct net_buf_simple *buf = &cli.buf;
132133

@@ -181,7 +182,7 @@ static struct bt_gatt_attr prov_attrs[] = {
181182

182183
static struct bt_gatt_service prov_svc = BT_GATT_SERVICE(prov_attrs);
183184

184-
int bt_mesh_proxy_prov_enable(void)
185+
int bt_mesh_pb_gatt_enable(void)
185186
{
186187
BT_DBG("");
187188

@@ -200,7 +201,7 @@ int bt_mesh_proxy_prov_enable(void)
200201
return 0;
201202
}
202203

203-
int bt_mesh_proxy_prov_disable(void)
204+
int bt_mesh_pb_gatt_disable(void)
204205
{
205206
BT_DBG("");
206207

@@ -281,7 +282,7 @@ static int gatt_send(struct bt_conn *conn,
281282
return bt_gatt_notify_cb(conn, &params);
282283
}
283284

284-
int bt_mesh_prov_adv_start(void)
285+
int bt_mesh_pb_gatt_adv_start(void)
285286
{
286287
BT_DBG("");
287288

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright (c) 2017 Intel Corporation
3+
* Copyright (c) 2021 Lingao Meng
4+
*
5+
* SPDX-License-Identifier: Apache-2.0
6+
*/
7+
8+
#ifndef ZEPHYR_SUBSYS_BLUETOOTH_MESH_PB_GATT_SRV_H_
9+
#define ZEPHYR_SUBSYS_BLUETOOTH_MESH_PB_GATT_SRV_H_
10+
11+
#include <bluetooth/gatt.h>
12+
13+
int bt_mesh_pb_gatt_send(struct bt_conn *conn, struct net_buf_simple *buf,
14+
bt_gatt_complete_func_t end, void *user_data);
15+
16+
int bt_mesh_pb_gatt_enable(void);
17+
int bt_mesh_pb_gatt_disable(void);
18+
19+
struct net_buf_simple *bt_mesh_pb_gatt_get_buf(void);
20+
21+
int bt_mesh_pb_gatt_adv_start(void);
22+
23+
#endif /* ZEPHYR_SUBSYS_BLUETOOTH_MESH_PB_GATT_SRV_H_ */

subsys/bluetooth/mesh/prov_device.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "access.h"
3838
#include "foundation.h"
3939
#include "proxy.h"
40+
#include "pb_gatt_srv.h"
4041
#include "prov.h"
4142
#include "settings.h"
4243

@@ -649,7 +650,7 @@ int bt_mesh_prov_disable(bt_mesh_prov_bearer_t bearers)
649650

650651
if (IS_ENABLED(CONFIG_BT_MESH_PB_GATT) &&
651652
(bearers & BT_MESH_PROV_GATT)) {
652-
(void)bt_mesh_proxy_prov_disable();
653+
(void)bt_mesh_pb_gatt_disable();
653654
}
654655

655656
return 0;

subsys/bluetooth/mesh/proxy.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ void bt_mesh_proxy_gatt_disconnect(void);
4040

4141
void bt_mesh_proxy_beacon_send(struct bt_mesh_subnet *sub);
4242

43-
struct net_buf_simple *bt_mesh_proxy_get_buf(void);
44-
4543
int bt_mesh_proxy_adv_start(void);
46-
int bt_mesh_prov_adv_start(void);
4744

4845
void bt_mesh_proxy_identity_start(struct bt_mesh_subnet *sub);
4946
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);
5249
void bt_mesh_proxy_addr_add(struct net_buf_simple *buf, uint16_t addr);
5350

5451
int bt_mesh_proxy_init(void);
55-
56-
#endif /* ZEPHYR_SUBSYS_BLUETOOTH_MESH_PROXY_H_ */

subsys/bluetooth/mesh/proxy_msg.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
#define CFG_FILTER_REMOVE 0x02
1919
#define CFG_FILTER_STATUS 0x03
2020

21+
#define BT_MESH_PROXY_NET_PDU 0x00
22+
#define BT_MESH_PROXY_BEACON 0x01
23+
#define BT_MESH_PROXY_CONFIG 0x02
24+
#define BT_MESH_PROXY_PROV 0x03
25+
2126
#define PDU_HDR(sar, type) (sar << 6 | (type & BIT_MASK(6)))
2227

2328
typedef int (*proxy_send_cb_t)(struct bt_conn *conn,

subsys/bluetooth/mesh/settings.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "heartbeat.h"
2727
#include "access.h"
2828
#include "proxy.h"
29+
#include "pb_gatt_srv.h"
2930
#include "settings.h"
3031
#include "cfg.h"
3132

@@ -61,7 +62,7 @@ static int mesh_commit(void)
6162
}
6263

6364
if (IS_ENABLED(CONFIG_BT_MESH_PB_GATT)) {
64-
(void)bt_mesh_proxy_prov_disable();
65+
(void)bt_mesh_pb_gatt_disable();
6566
}
6667

6768
bt_mesh_net_settings_commit();

0 commit comments

Comments
 (0)