Skip to content

Commit 5bcfd16

Browse files
KKopyscinskirymanluk
authored andcommitted
mesh: fix cdb.c conflicts when BLE_MESH_CDB is disabled
1 parent 5a5493d commit 5bcfd16

File tree

5 files changed

+17
-10
lines changed

5 files changed

+17
-10
lines changed

nimble/host/mesh/include/mesh/cdb.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
#include "syscfg/syscfg.h"
1010

1111
#if MYNEWT_VAL(BLE_MESH_CDB)
12-
#define NODE_COUNT MYNEWT_VAL(BLE_MESH_CDB_NODE_COUNT)
13-
#define SUBNET_COUNT MYNEWT_VAL(BLE_MESH_CDB_SUBNET_COUNT)
14-
#define APP_KEY_COUNT MYNEWT_VAL(BLE_MESH_CDB_APP_KEY_COUNT)
12+
#define NODE_COUNT CONFIG_BT_MESH_NODE_COUNT
13+
#define SUBNET_COUNT CONFIG_BT_MESH_SUBNET_COUNT
14+
#define APP_KEY_COUNT CONFIG_BT_MESH_APP_KEY_COUNT
1515
#else
1616
#define NODE_COUNT 0
1717
#define SUBNET_COUNT 0

nimble/host/mesh/src/cdb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7+
#if BLE_MESH_CDB
78
#define BT_DBG_ENABLED MYNEWT_VAL(BLE_MESH_DEBUG_CDB)
89
#define LOG_MODULE_NAME bt_mesh_cdb
910
#include "log/log.h"
@@ -16,7 +17,6 @@
1617
#include "mesh/glue.h"
1718

1819

19-
#if MYNEWT_VAL(BLE_MESH_CDB)
2020
struct bt_mesh_cdb bt_mesh_cdb = {
2121
.nodes = {
2222
[0 ... (CONFIG_BT_MESH_NODE_COUNT - 1)] = {

nimble/host/mesh/src/provisioner.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ static void pub_key_ready(const uint8_t *pkey);
3737

3838
static int reset_state(void)
3939
{
40+
#if BLE_MESH_CDB
4041
if (prov_device.node != NULL) {
4142
bt_mesh_cdb_node_del(prov_device.node, false);
4243
}
43-
44+
#endif
4445
return bt_mesh_prov_reset_state(pub_key_ready);
4546
}
4647

@@ -237,7 +238,7 @@ static void prov_capabilities(const uint8_t *data)
237238
prov_fail(PROV_ERR_NVAL_FMT);
238239
return;
239240
}
240-
241+
#if BLE_MESH_CDB
241242
prov_device.node =
242243
bt_mesh_cdb_node_alloc(prov_device.uuid,
243244
prov_device.addr, data[0],
@@ -247,7 +248,7 @@ static void prov_capabilities(const uint8_t *data)
247248
prov_fail(PROV_ERR_RESOURCES);
248249
return;
249250
}
250-
251+
#endif
251252
memcpy(&bt_mesh_prov_link.conf_inputs[1], data, 11);
252253

253254
if (bt_mesh_prov->capabilities) {
@@ -453,7 +454,9 @@ static void prov_input_complete(const uint8_t *data)
453454
static void send_prov_data(void)
454455
{
455456
struct os_mbuf *pdu = PROV_BUF(34);
457+
#if BLE_MESH_CDB
456458
struct bt_mesh_cdb_subnet *sub;
459+
#endif
457460
uint8_t session_key[16];
458461
uint8_t nonce[13];
459462
int err;
@@ -487,20 +490,22 @@ static void send_prov_data(void)
487490
}
488491

489492
BT_DBG("DevKey: %s", bt_hex(prov_device.node->dev_key, 16));
490-
493+
#if BLE_MESH_CDB
491494
sub = bt_mesh_cdb_subnet_get(prov_device.node->net_idx);
492495
if (sub == NULL) {
493496
BT_ERR("No subnet with net_idx %u",
494497
prov_device.node->net_idx);
495498
prov_fail(PROV_ERR_UNEXP_ERR);
496499
return;
497500
}
498-
501+
#endif
499502
bt_mesh_prov_buf_init(pdu, PROV_DATA);
503+
#if BLE_MESH_CDB
500504
net_buf_simple_add_mem(pdu, sub->keys[sub->kr_flag].net_key, 16);
501505
net_buf_simple_add_be16(pdu, prov_device.node->net_idx);
502506
net_buf_simple_add_u8(pdu, bt_mesh_cdb_subnet_flags(sub));
503507
net_buf_simple_add_be32(pdu, bt_mesh_cdb.iv_index);
508+
#endif
504509
net_buf_simple_add_be16(pdu, prov_device.node->addr);
505510
net_buf_simple_add(pdu, 8); /* For MIC */
506511

nimble/host/mesh/src/testing.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ void bt_test_print_credentials(void)
141141

142142
for (i = 0; i < ARRAY_SIZE(bt_mesh_cdb.app_keys); ++i)
143143
{
144+
app_key = &bt_mesh_cdb.app_keys[i];
144145
if (app_key->net_idx == BT_MESH_KEY_UNUSED) {
145146
continue;
146147
}
@@ -160,6 +161,7 @@ void bt_test_print_credentials(void)
160161
for (i = 0; i < ARRAY_SIZE(bt_mesh_cdb.subnets); ++i)
161162
{
162163
sub = bt_mesh_cdb_subnet_get(i);
164+
app_key = &bt_mesh_cdb.app_keys[i];
163165
if (sub[i].net_idx == BT_MESH_KEY_UNUSED) {
164166
continue;
165167
}

porting/examples/linux_blemesh/include/syscfg/syscfg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,7 @@
10251025
#endif
10261026

10271027
#ifndef MYNEWT_VAL_BLE_MESH_CDB
1028-
#define MYNEWT_VAL_BLE_MESH_CDB (1)
1028+
#define MYNEWT_VAL_BLE_MESH_CDB (0)
10291029
#endif
10301030

10311031
#ifndef MYNEWT_VAL_BLE_MESH_CDB_SUBNET_COUNT

0 commit comments

Comments
 (0)