summaryrefslogtreecommitdiff
path: root/mesh/model.c
diff options
context:
space:
mode:
authorInga Stotland <inga.stotland@intel.com>2020-08-19 22:41:32 -0700
committerBrian Gix <brian.gix@intel.com>2020-08-22 07:20:26 -0700
commit4de3420d3352e0773dd6e4a8ef665247a0da8bc2 (patch)
treecafe18ecb8022c3838b5f82447160fedaccfae75 /mesh/model.c
parent291dbf2c94ed956c2269097d1ed859488b08c2bd (diff)
downloadbluez-4de3420d3352e0773dd6e4a8ef665247a0da8bc2.tar.gz
mesh: Use correct retransmit parameters for publications
This adds previously missing retransmit count and interval values specific to model publications. The values are configured by Config CLient and may be different to each model.
Diffstat (limited to 'mesh/model.c')
-rw-r--r--mesh/model.c59
1 files changed, 33 insertions, 26 deletions
diff --git a/mesh/model.c b/mesh/model.c
index 9529dfb2e..c1497de6a 100644
--- a/mesh/model.c
+++ b/mesh/model.c
@@ -508,10 +508,11 @@ static int virt_packet_decrypt(struct mesh_net *net, const uint8_t *data,
return -1;
}
-static bool msg_send(struct mesh_node *node, bool credential, uint16_t src,
- uint32_t dst, uint16_t app_idx, uint16_t net_idx,
- uint8_t *label, uint8_t ttl, bool segmented,
- const void *msg, uint16_t msg_len)
+static bool msg_send(struct mesh_node *node, bool cred, uint16_t src,
+ uint16_t dst, uint16_t app_idx, uint16_t net_idx,
+ uint8_t *label, uint8_t ttl, uint8_t cnt,
+ uint16_t interval, bool segmented, const void *msg,
+ uint16_t msg_len)
{
uint8_t dev_key[16];
uint32_t iv_index, seq_num;
@@ -562,9 +563,9 @@ static bool msg_send(struct mesh_node *node, bool credential, uint16_t src,
goto done;
}
- ret = mesh_net_app_send(net, credential, src, dst, key_aid, net_idx,
- ttl, seq_num, iv_index, segmented,
- szmic, out, out_len);
+ ret = mesh_net_app_send(net, cred, src, dst, key_aid, net_idx, ttl,
+ cnt, interval, seq_num, iv_index,
+ segmented, szmic, out, out_len);
done:
l_free(out);
return ret;
@@ -705,7 +706,7 @@ static struct mesh_virtual *add_virtual(const uint8_t *v)
static int set_pub(struct mesh_model *mod, uint16_t pub_addr,
uint16_t idx, bool cred_flag, uint8_t ttl,
- uint8_t period, uint8_t retransmit)
+ uint8_t period, uint8_t cnt, uint16_t interval)
{
if (!mod->pub)
mod->pub = l_new(struct mesh_model_pub, 1);
@@ -715,14 +716,15 @@ static int set_pub(struct mesh_model *mod, uint16_t pub_addr,
mod->pub->idx = idx;
mod->pub->ttl = ttl;
mod->pub->period = period;
- mod->pub->retransmit = retransmit;
+ mod->pub->rtx.cnt = cnt;
+ mod->pub->rtx.interval = interval;
return MESH_STATUS_SUCCESS;
}
static int set_virt_pub(struct mesh_model *mod, const uint8_t *label,
uint16_t idx, bool cred_flag, uint8_t ttl,
- uint8_t period, uint8_t retransmit)
+ uint8_t period, uint8_t cnt, uint16_t interval)
{
struct mesh_virtual *virt = NULL;
@@ -734,8 +736,8 @@ static int set_virt_pub(struct mesh_model *mod, const uint8_t *label,
mod->pub = l_new(struct mesh_model_pub, 1);
mod->pub->virt = virt;
- return set_pub(mod, virt->addr, idx, cred_flag, ttl, period,
- retransmit);
+ return set_pub(mod, virt->addr, idx, cred_flag, ttl, period, cnt,
+ interval);
}
static int add_virt_sub(struct mesh_net *net, struct mesh_model *mod,
@@ -1038,9 +1040,10 @@ int mesh_model_publish(struct mesh_node *node, uint32_t id, uint16_t src,
net_idx = appkey_net_idx(net, mod->pub->idx);
- result = msg_send(node, mod->pub->credential != 0, src,
- mod->pub->addr, mod->pub->idx, net_idx,
- label, mod->pub->ttl, false, msg, msg_len);
+ result = msg_send(node, mod->pub->credential != 0, src, mod->pub->addr,
+ mod->pub->idx, net_idx, label, mod->pub->ttl,
+ mod->pub->rtx.cnt, mod->pub->rtx.interval,
+ false, msg, msg_len);
return result ? MESH_ERROR_NONE : MESH_ERROR_FAILED;
}
@@ -1050,6 +1053,10 @@ bool mesh_model_send(struct mesh_node *node, uint16_t src, uint16_t dst,
uint8_t ttl, bool segmented,
const void *msg, uint16_t msg_len)
{
+ struct mesh_net *net = node_get_net(node);
+ uint8_t cnt;
+ uint16_t interval;
+
/* If SRC is 0, use the Primary Element */
if (src == 0)
src = node_get_primary(node);
@@ -1059,14 +1066,16 @@ bool mesh_model_send(struct mesh_node *node, uint16_t src, uint16_t dst,
if (IS_UNASSIGNED(dst))
return false;
- return msg_send(node, false, src, dst, app_idx, net_idx,
- NULL, ttl, segmented, msg, msg_len);
+ mesh_net_transmit_params_get(net, &cnt, &interval);
+
+ return msg_send(node, false, src, dst, app_idx, net_idx, NULL, ttl, cnt,
+ interval, segmented, msg, msg_len);
}
int mesh_model_pub_set(struct mesh_node *node, uint16_t addr, uint32_t id,
const uint8_t *pub_addr, uint16_t idx, bool cred_flag,
- uint8_t ttl, uint8_t period, uint8_t retransmit,
- bool is_virt, uint16_t *pub_dst)
+ uint8_t ttl, uint8_t period, uint8_t cnt,
+ uint16_t interval, bool is_virt, uint16_t *pub_dst)
{
struct mesh_model *mod;
int status, ele_idx = node_get_element_idx(node, addr);
@@ -1104,10 +1113,10 @@ int mesh_model_pub_set(struct mesh_node *node, uint16_t addr, uint32_t id,
if (!is_virt) {
status = set_pub(mod, l_get_le16(pub_addr), idx, cred_flag,
- ttl, period, retransmit);
+ ttl, period, cnt, interval);
} else
status = set_virt_pub(mod, pub_addr, idx, cred_flag, ttl,
- period, retransmit);
+ period, cnt, interval);
*pub_dst = mod->pub->addr;
@@ -1683,15 +1692,13 @@ static struct mesh_model *model_setup(struct mesh_net *net, uint8_t ele_idx,
/* Add publication if enabled and present */
if (mod->pub_enabled && pub) {
- uint8_t retransmit = pub->count +
- ((pub->interval / 50 - 1) << 3);
if (pub->virt)
set_virt_pub(mod, pub->virt_addr, pub->idx,
- pub->credential, pub->ttl,
- pub->period, retransmit);
+ pub->credential, pub->ttl, pub->period,
+ pub->cnt, pub->interval);
else if (!IS_UNASSIGNED(pub->addr))
set_pub(mod, pub->addr, pub->idx, pub->credential,
- pub->ttl, pub->period, retransmit);
+ pub->ttl, pub->period, pub->cnt, pub->interval);
}
mod->sub_enabled = db_mod->sub_enabled;