From 10f2ed14eb5afe52ffc0522d7be1f8539bf09651 Mon Sep 17 00:00:00 2001 From: lly Date: Wed, 25 Mar 2020 00:15:27 +0800 Subject: [PATCH] ble_mesh: Support reliable sending when publishing [Zephyr] Until now the choice of reliable sending (segmented messages with acks) was implicitly dependent on the size of the payload. Add a new member to the bt_mesh_model_pub to force using segment acks even when the payload would fit a single unsegmented message. --- components/bt/esp_ble_mesh/api/esp_ble_mesh_defs.h | 3 ++- components/bt/esp_ble_mesh/mesh_core/access.c | 4 +++- components/bt/esp_ble_mesh/mesh_core/include/mesh_access.h | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/components/bt/esp_ble_mesh/api/esp_ble_mesh_defs.h b/components/bt/esp_ble_mesh/api/esp_ble_mesh_defs.h index 61b6c10d6..bb7847cd0 100644 --- a/components/bt/esp_ble_mesh/api/esp_ble_mesh_defs.h +++ b/components/bt/esp_ble_mesh/api/esp_ble_mesh_defs.h @@ -369,7 +369,8 @@ typedef struct { uint16_t publish_addr; /*!< Publish Address. */ uint16_t app_idx:12, /*!< Publish AppKey Index. */ - cred:1; /*!< Friendship Credentials Flag. */ + cred:1, /*!< Friendship Credentials Flag. */ + send_rel:1; /*!< Force reliable sending (segment acks) */ uint8_t ttl; /*!< Publish Time to Live. */ uint8_t retransmit; /*!< Retransmit Count & Interval Steps. */ diff --git a/components/bt/esp_ble_mesh/mesh_core/access.c b/components/bt/esp_ble_mesh/mesh_core/access.c index 529cca1b3..acc48ed53 100644 --- a/components/bt/esp_ble_mesh/mesh_core/access.c +++ b/components/bt/esp_ble_mesh/mesh_core/access.c @@ -1024,7 +1024,9 @@ int bt_mesh_model_publish(struct bt_mesh_model *model) struct bt_mesh_model_pub *pub = model->pub; struct bt_mesh_app_key *key = NULL; struct net_buf_simple *sdu = NULL; - struct bt_mesh_msg_ctx ctx = {0}; + struct bt_mesh_msg_ctx ctx = { + .send_rel = pub->send_rel, + }; struct bt_mesh_net_tx tx = { .sub = NULL, .ctx = &ctx, diff --git a/components/bt/esp_ble_mesh/mesh_core/include/mesh_access.h b/components/bt/esp_ble_mesh/mesh_core/include/mesh_access.h index 261056f60..bfe35fa67 100644 --- a/components/bt/esp_ble_mesh/mesh_core/include/mesh_access.h +++ b/components/bt/esp_ble_mesh/mesh_core/include/mesh_access.h @@ -339,7 +339,8 @@ struct bt_mesh_model_pub { u16_t addr; /**< Publish Address. */ u16_t key:12, /**< Publish AppKey Index. */ - cred:1; /**< Friendship Credentials Flag. */ + cred:1, /**< Friendship Credentials Flag. */ + send_rel:1; /**< Force reliable sending (segment acks) */ u8_t ttl; /**< Publish Time to Live. */ u8_t retransmit; /**< Retransmit Count & Interval Steps. */