Bluetooth: Mesh: Allow passing adv transmit info in net_tx

This makes it possible (in a subsequent patch) to fine-tune some
special cases, like the LPN poll messages.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2017-11-09 19:58:25 +02:00 committed by Johan Hedberg
commit 01d3940cdb
5 changed files with 17 additions and 12 deletions

View file

@ -446,6 +446,7 @@ int bt_mesh_model_send(struct bt_mesh_model *model,
.sub = bt_mesh_subnet_get(ctx->net_idx),
.ctx = ctx,
.src = model->elem->addr,
.xmit = bt_mesh_net_transmit_get(),
};
if (ctx->friend_cred && !bt_mesh_lpn_established()) {

View file

@ -76,6 +76,7 @@ static void hb_send(struct bt_mesh_model *model)
.sub = bt_mesh_subnet_get(cfg->hb_pub.net_idx),
.ctx = &ctx,
.src = model->elem->addr,
.xmit = bt_mesh_net_transmit_get(),
};
hb.init_ttl = cfg->hb_pub.ttl;

View file

@ -24,6 +24,7 @@
#include "transport.h"
#include "access.h"
#include "beacon.h"
#include "foundation.h"
#include "lpn.h"
#if defined(CONFIG_BT_MESH_LPN_AUTO)
@ -133,6 +134,7 @@ static int send_friend_clear(void)
.sub = &bt_mesh.sub[0],
.ctx = &ctx,
.src = bt_mesh_primary_addr(),
.xmit = bt_mesh_net_transmit_get(),
};
struct bt_mesh_ctl_friend_clear req = {
.lpn_addr = sys_cpu_to_be16(tx.src),
@ -227,6 +229,7 @@ static int send_friend_req(struct bt_mesh_lpn *lpn)
.sub = &bt_mesh.sub[0],
.ctx = &ctx,
.src = bt_mesh_primary_addr(),
.xmit = bt_mesh_net_transmit_get(),
};
struct bt_mesh_ctl_friend_req req = {
.criteria = LPN_CRITERIA,
@ -327,6 +330,7 @@ static int send_friend_poll(void)
.sub = &bt_mesh.sub[0],
.ctx = &ctx,
.src = bt_mesh_primary_addr(),
.xmit = bt_mesh_net_transmit_get(),
};
struct bt_mesh_lpn *lpn = &bt_mesh.lpn;
u8_t fsn = lpn->fsn;
@ -618,6 +622,7 @@ static bool sub_update(u8_t op)
.sub = &bt_mesh.sub[0],
.ctx = &ctx,
.src = bt_mesh_primary_addr(),
.xmit = bt_mesh_net_transmit_get(),
};
struct bt_mesh_ctl_friend_sub req;
size_t i, g;

View file

@ -246,6 +246,7 @@ struct bt_mesh_net_tx {
struct bt_mesh_subnet *sub;
struct bt_mesh_msg_ctx *ctx;
u16_t src;
u8_t xmit;
};
extern struct bt_mesh_net bt_mesh;

View file

@ -103,14 +103,12 @@ static int send_unseg(struct bt_mesh_net_tx *tx, u8_t aid,
struct net_buf_simple *sdu)
{
struct net_buf *buf;
u8_t xmit;
BT_DBG("src 0x%04x dst 0x%04x app_idx 0x%04x sdu_len %u",
tx->src, tx->ctx->addr, tx->ctx->app_idx, sdu->len);
xmit = bt_mesh_net_transmit_get();
buf = bt_mesh_adv_create(BT_MESH_ADV_DATA, TRANSMIT_COUNT(xmit),
TRANSMIT_INT(xmit), BUF_TIMEOUT);
buf = bt_mesh_adv_create(BT_MESH_ADV_DATA, TRANSMIT_COUNT(tx->xmit),
TRANSMIT_INT(tx->xmit), BUF_TIMEOUT);
if (!buf) {
BT_ERR("Out of network buffers");
return -ENOBUFS;
@ -306,12 +304,12 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, u8_t aid,
for (seg_o = 0; sdu->len; seg_o++) {
struct net_buf *seg;
u16_t len;
u8_t xmit;
int err;
xmit = bt_mesh_net_transmit_get();
seg = bt_mesh_adv_create(BT_MESH_ADV_DATA, TRANSMIT_COUNT(xmit),
TRANSMIT_INT(xmit), BUF_TIMEOUT);
seg = bt_mesh_adv_create(BT_MESH_ADV_DATA,
TRANSMIT_COUNT(net_tx->xmit),
TRANSMIT_INT(net_tx->xmit),
BUF_TIMEOUT);
if (!seg) {
BT_ERR("Out of segment buffers");
seg_tx_reset(tx);
@ -838,15 +836,13 @@ int bt_mesh_ctl_send(struct bt_mesh_net_tx *tx, u8_t ctl_op, void *data,
size_t data_len, u64_t *seq_auth, bt_mesh_adv_func_t cb)
{
struct net_buf *buf;
u8_t xmit;
BT_DBG("src 0x%04x dst 0x%04x ttl 0x%02x ctl 0x%02x", tx->src,
tx->ctx->addr, tx->ctx->send_ttl, ctl_op);
BT_DBG("len %zu: %s", data_len, bt_hex(data, data_len));
xmit = bt_mesh_net_transmit_get();
buf = bt_mesh_adv_create(BT_MESH_ADV_DATA, TRANSMIT_COUNT(xmit),
TRANSMIT_INT(xmit), BUF_TIMEOUT);
buf = bt_mesh_adv_create(BT_MESH_ADV_DATA, TRANSMIT_COUNT(tx->xmit),
TRANSMIT_INT(tx->xmit), BUF_TIMEOUT);
if (!buf) {
BT_ERR("Out of transport buffers");
return -ENOBUFS;
@ -894,6 +890,7 @@ static int send_ack(struct bt_mesh_subnet *sub, u16_t src, u16_t dst,
.sub = sub,
.ctx = &ctx,
.src = obo ? bt_mesh_primary_addr() : src,
.xmit = bt_mesh_net_transmit_get(),
};
u16_t seq_zero = *seq_auth & 0x1fff;
u8_t buf[6];