Skip to content

Commit 28664d1

Browse files
committed
Bluetooth: Mesh: Add seperate config for pb-gatt dev name
Add seperate config to control whether device name include in pb-gatt advertising scan response data. Signed-off-by: Lingao Meng <[email protected]>
1 parent 49c0a19 commit 28664d1

File tree

4 files changed

+32
-19
lines changed

4 files changed

+32
-19
lines changed

subsys/bluetooth/mesh/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,14 @@ config BT_MESH_PB_GATT
120120
Enable this option to allow the device to be provisioned over
121121
GATT.
122122

123+
config BT_MESH_PB_GATT_USE_DEVICE_NAME
124+
bool "Include Bluetooth device name in scan response"
125+
depends on BT_MESH_PB_GATT
126+
default y
127+
help
128+
This option includes GAP device name in scan response when
129+
the PB-GATT is enabled.
130+
123131
config BT_MESH_GATT_PROXY
124132
bool "GATT Proxy Service support"
125133
select BT_MESH_GATT_SERVER

subsys/bluetooth/mesh/pb_gatt_srv.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@
3232
#include "proxy_msg.h"
3333
#include "pb_gatt_srv.h"
3434

35+
#if defined(CONFIG_BT_MESH_PB_GATT_USE_DEVICE_NAME)
36+
#define ADV_OPT_USE_NAME BT_LE_ADV_OPT_USE_NAME
37+
#else
38+
#define ADV_OPT_USE_NAME 0
39+
#endif
40+
41+
#define ADV_OPT_PROV \
42+
(BT_LE_ADV_OPT_CONNECTABLE | BT_LE_ADV_OPT_SCANNABLE | \
43+
BT_LE_ADV_OPT_ONE_TIME | ADV_OPT_USE_IDENTITY | \
44+
ADV_OPT_USE_NAME)
45+
3546
static bool prov_fast_adv;
3647

3748
static int gatt_send(struct bt_conn *conn,

subsys/bluetooth/mesh/proxy.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,6 @@
1010
#define ADV_OPT_USE_IDENTITY 0
1111
#endif
1212

13-
#if defined(CONFIG_BT_MESH_PROXY_USE_DEVICE_NAME)
14-
#define ADV_OPT_USE_NAME BT_LE_ADV_OPT_USE_NAME
15-
#else
16-
#define ADV_OPT_USE_NAME 0
17-
#endif
18-
19-
#define ADV_OPT_PROXY \
20-
(BT_LE_ADV_OPT_CONNECTABLE | BT_LE_ADV_OPT_SCANNABLE | \
21-
BT_LE_ADV_OPT_ONE_TIME | ADV_OPT_USE_IDENTITY | \
22-
ADV_OPT_USE_NAME)
23-
24-
#define ADV_OPT_PROV \
25-
(BT_LE_ADV_OPT_CONNECTABLE | BT_LE_ADV_OPT_SCANNABLE | \
26-
BT_LE_ADV_OPT_ONE_TIME | ADV_OPT_USE_IDENTITY | \
27-
BT_LE_ADV_OPT_USE_NAME)
28-
2913
#define ADV_SLOW_INT \
3014
.interval_min = BT_GAP_ADV_SLOW_INT_MIN, \
3115
.interval_max = BT_GAP_ADV_SLOW_INT_MAX

subsys/bluetooth/mesh/proxy_srv.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@
3131
#include "proxy.h"
3232
#include "proxy_msg.h"
3333

34+
#if defined(CONFIG_BT_MESH_PROXY_USE_DEVICE_NAME)
35+
#define ADV_OPT_USE_NAME BT_LE_ADV_OPT_USE_NAME
36+
#else
37+
#define ADV_OPT_USE_NAME 0
38+
#endif
39+
40+
#define ADV_OPT_PROXY \
41+
(BT_LE_ADV_OPT_CONNECTABLE | BT_LE_ADV_OPT_SCANNABLE | \
42+
BT_LE_ADV_OPT_ONE_TIME | ADV_OPT_USE_IDENTITY | \
43+
ADV_OPT_USE_NAME)
44+
3445
static void proxy_send_beacons(struct k_work *work);
3546
static int proxy_send(struct bt_conn *conn,
3647
const void *data, uint16_t len,
@@ -43,7 +54,6 @@ static struct bt_mesh_proxy_client {
4354
NONE,
4455
ACCEPT,
4556
REJECT,
46-
PROV,
4757
} filter_type;
4858
struct k_work send_beacons;
4959
} clients[CONFIG_BT_MAX_CONN] = {
@@ -681,7 +691,7 @@ int bt_mesh_proxy_gatt_enable(void)
681691
service_registered = true;
682692

683693
for (i = 0; i < ARRAY_SIZE(clients); i++) {
684-
if (clients[i].cli.conn) {
694+
if (clients[i].cli) {
685695
clients[i].filter_type = ACCEPT;
686696
}
687697
}
@@ -698,7 +708,7 @@ void bt_mesh_proxy_gatt_disconnect(void)
698708
for (i = 0; i < ARRAY_SIZE(clients); i++) {
699709
struct bt_mesh_proxy_client *client = &clients[i];
700710

701-
if (client->cli.conn && (client->filter_type == ACCEPT ||
711+
if (client->cli && (client->filter_type == ACCEPT ||
702712
client->filter_type == REJECT)) {
703713
client->filter_type = NONE;
704714
bt_conn_disconnect(client->cli->conn,

0 commit comments

Comments
 (0)