From 4fe3e03152c24ce0691e9e6541d9b46b73b4d0da Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 22 Nov 2017 11:35:32 +0200 Subject: [PATCH] Bluetooth: samples/mesh_demo: Fix address handling Clean up and fix the address handling. Signed-off-by: Johan Hedberg --- samples/bluetooth/mesh_demo/src/board.h | 6 +++++- samples/bluetooth/mesh_demo/src/main.c | 12 +++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/samples/bluetooth/mesh_demo/src/board.h b/samples/bluetooth/mesh_demo/src/board.h index e8e973e761..4cedbb3e39 100644 --- a/samples/bluetooth/mesh_demo/src/board.h +++ b/samples/bluetooth/mesh_demo/src/board.h @@ -6,6 +6,10 @@ * SPDX-License-Identifier: Apache-2.0 */ +#if !defined(NODE_ADDR) +#define NODE_ADDR 0x0b0c +#endif + void board_button_1_pressed(void); u16_t board_set_target(void); void board_play(const char *str); @@ -20,7 +24,7 @@ void board_attention(bool attention); #else static inline void board_init(u16_t *addr, u32_t *seq) { - *addr = 0x0b0c; + *addr = NODE_ADDR; *seq = 0; } diff --git a/samples/bluetooth/mesh_demo/src/main.c b/samples/bluetooth/mesh_demo/src/main.c index 58b8ce0182..e846ff7898 100644 --- a/samples/bluetooth/mesh_demo/src/main.c +++ b/samples/bluetooth/mesh_demo/src/main.c @@ -17,7 +17,7 @@ #define MOD_INTEL 0x0000 #define GROUP_ADDR 0xc000 -#define PROV_ADDR 0x000f +#define PUBLISHER_ADDR 0x000f #define OP_VENDOR_BUTTON BT_MESH_MODEL_OP_3(0x00, CID_INTEL) @@ -37,15 +37,9 @@ static const u16_t net_idx; static const u16_t app_idx; static const u32_t iv_index; static u8_t flags; -#if defined(NODE_ADDR) static u16_t addr = NODE_ADDR; -#else -static u16_t addr = 0x0b0c; -#endif static u32_t seq; -#define PROVISIONER_ADDR 0x0001 - static void heartbeat(u8_t hops, u16_t feat) { board_heartbeat(hops, feat); @@ -157,7 +151,7 @@ static void configure(void) bt_mesh_cfg_mod_sub_add_vnd(net_idx, addr, addr, GROUP_ADDR, MOD_INTEL, CID_INTEL, NULL); -#if defined(NODE_ADDR) && NODE_ADDR == PROV_ADDR +#if NODE_ADDR == PUBLISHER_ADDR { struct bt_mesh_cfg_hb_pub pub = { .dst = GROUP_ADDR, @@ -174,7 +168,7 @@ static void configure(void) #else { struct bt_mesh_cfg_hb_sub sub = { - .src = PROV_ADDR, + .src = PUBLISHER_ADDR, .dst = GROUP_ADDR, .period = 0x10, };