From 8aaf05cc9ffd9d225dfe61f5f77a42b51bbb0393 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Rymanowski?= Date: Tue, 22 May 2018 22:09:43 +0200 Subject: [PATCH 1/3] nimble/mesh: Fix set for address type --- nimble/host/mesh/src/glue.c | 1 + 1 file changed, 1 insertion(+) diff --git a/nimble/host/mesh/src/glue.c b/nimble/host/mesh/src/glue.c index 8fc27a678..ca1f88389 100644 --- a/nimble/host/mesh/src/glue.c +++ b/nimble/host/mesh/src/glue.c @@ -510,6 +510,7 @@ ble_adv_copy_to_ext_param(struct ble_gap_ext_adv_params *ext_param, ext_param->itvl_min = param->itvl_min; ext_param->channel_map = param->channel_map; ext_param->high_duty_directed = param->high_duty_cycle; + ext_param->own_addr_type = g_mesh_addr_type; } static int From 12f3d059cd95551c9305e0772179dd2bf61a1f4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Rymanowski?= Date: Tue, 22 May 2018 23:30:30 +0200 Subject: [PATCH 2/3] nimble/mesh: Minor fix name for mesh advertising instance and idx Make sure we use GATT and ADV bearer --- nimble/host/mesh/src/glue.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/nimble/host/mesh/src/glue.c b/nimble/host/mesh/src/glue.c index ca1f88389..fb62ad40e 100644 --- a/nimble/host/mesh/src/glue.c +++ b/nimble/host/mesh/src/glue.c @@ -32,15 +32,16 @@ #if MYNEWT_VAL(BLE_MULTI_ADV_INSTANCES) < 1 #error "Mesh needs at least BLE_MULTI_ADV_INSTANCES set to 1" #endif -#define BT_MESH_ADV_PROXY_INST (MYNEWT_VAL(BLE_MULTI_ADV_INSTANCES) - 1) +#define BT_MESH_ADV_GATT_INST (MYNEWT_VAL(BLE_MULTI_ADV_INSTANCES) - 1) #endif /* BLE_MESH_PROXY */ #endif /* BLE_EXT_ADV */ extern u8_t g_mesh_addr_type; #if MYNEWT_VAL(BLE_EXT_ADV) -#define BLE_ADV_PB_ADV_IDX (0) -#define BLE_ADV_PB_GATT_IDX (1) +/* Store configuration for different bearers */ +#define BT_MESH_ADV_IDX (0) +#define BT_MESH_GATT_IDX (1) static struct ble_gap_adv_params ble_adv_cur_conf[2]; #endif @@ -522,11 +523,11 @@ ble_adv_conf_adv_instance(const struct ble_gap_adv_params *param, int *instance) if (param->conn_mode == BLE_GAP_CONN_MODE_NON) { *instance = BT_MESH_ADV_INST; - cur_conf = &ble_adv_cur_conf[BLE_ADV_PB_ADV_IDX]; + cur_conf = &ble_adv_cur_conf[BT_MESH_ADV_IDX]; } else { #if MYNEWT_VAL(BLE_MESH_PROXY) - *instance = BT_MESH_ADV_PROXY_INST; - cur_conf = &ble_adv_cur_conf[BLE_ADV_PB_GATT_IDX]; + *instance = BT_MESH_ADV_GATT_INST; + cur_conf = &ble_adv_cur_conf[BT_MESH_GATT_IDX]; #else assert(0); #endif From cc9b523e60538354a7461b39216b40d55d97ecfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Rymanowski?= Date: Tue, 22 May 2018 23:33:39 +0200 Subject: [PATCH 3/3] nimble/mesh: Fix stop advertising for ADV and GATT bearer When using ext advetising, we need to make sure to stop correct instance. --- nimble/host/mesh/include/mesh/glue.h | 2 +- nimble/host/mesh/src/adv.c | 2 +- nimble/host/mesh/src/glue.c | 18 +++++++++++++++--- nimble/host/mesh/src/proxy.c | 2 +- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/nimble/host/mesh/include/mesh/glue.h b/nimble/host/mesh/include/mesh/glue.h index 7ace07524..5ccc2d589 100644 --- a/nimble/host/mesh/include/mesh/glue.h +++ b/nimble/host/mesh/include/mesh/glue.h @@ -274,7 +274,7 @@ void bt_mesh_register_gatt(void); int bt_le_adv_start(const struct ble_gap_adv_params *param, const struct bt_data *ad, size_t ad_len, const struct bt_data *sd, size_t sd_len); -int bt_le_adv_stop(void); +int bt_le_adv_stop(bool proxy); struct k_delayed_work { struct ble_npl_callout work; diff --git a/nimble/host/mesh/src/adv.c b/nimble/host/mesh/src/adv.c index 8b8b4260a..d1ad2ab53 100644 --- a/nimble/host/mesh/src/adv.c +++ b/nimble/host/mesh/src/adv.c @@ -131,7 +131,7 @@ static inline void adv_send(struct os_mbuf *buf) k_sleep(K_MSEC(duration)); - err = bt_le_adv_stop(); + err = bt_le_adv_stop(false); adv_send_end(err, cb, cb_data); if (err) { BT_ERR("Stopping advertising failed: err %d", err); diff --git a/nimble/host/mesh/src/glue.c b/nimble/host/mesh/src/glue.c index fb62ad40e..41cdbe129 100644 --- a/nimble/host/mesh/src/glue.c +++ b/nimble/host/mesh/src/glue.c @@ -643,9 +643,21 @@ error: return err; } -int bt_le_adv_stop(void) +int bt_le_adv_stop(bool proxy) { - return ble_gap_ext_adv_stop(BT_MESH_ADV_INST); +#if MYNEWT_VAL(BLE_MESH_PROXY) + int rc; + + if (proxy) { + rc = ble_gap_ext_adv_stop(BT_MESH_ADV_GATT_INST); + } else { + rc = ble_gap_ext_adv_stop(BT_MESH_ADV_INST); + } + + return rc; +#else + return ble_gap_ext_adv_stop(BT_MESH_ADV_INST); +#endif } #else @@ -695,7 +707,7 @@ bt_le_adv_start(const struct ble_gap_adv_params *param, return 0; } -int bt_le_adv_stop(void) +int bt_le_adv_stop(bool proxy) { return ble_gap_adv_stop(); } diff --git a/nimble/host/mesh/src/proxy.c b/nimble/host/mesh/src/proxy.c index 55148cd45..186f2f560 100644 --- a/nimble/host/mesh/src/proxy.c +++ b/nimble/host/mesh/src/proxy.c @@ -1233,7 +1233,7 @@ void bt_mesh_proxy_adv_stop(void) return; } - err = bt_le_adv_stop(); + err = bt_le_adv_stop(true); if (err) { BT_ERR("Failed to stop advertising (err %d)", err); } else {