Bluetooth: Mesh: Fix calling send start for multi-segmented messages
Using the start callback, especially with multi-segment messages, may not be super useful for applications, but we should support if if they do provide it. One application could e.g. be to calculate the duration it takes for a multi-segment message to be completely received by the remote end. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
e7bb76e2b6
commit
ec9aaaed23
1 changed files with 17 additions and 1 deletions
|
@ -198,6 +198,15 @@ static inline void seg_tx_complete(struct seg_tx *tx, int err)
|
|||
seg_tx_reset(tx);
|
||||
}
|
||||
|
||||
static void seg_send_start(u16_t duration, int err, void *user_data)
|
||||
{
|
||||
struct seg_tx *tx = user_data;
|
||||
|
||||
if (tx->cb && tx->cb->start) {
|
||||
tx->cb->start(duration, err, tx->cb_data);
|
||||
}
|
||||
}
|
||||
|
||||
static void seg_sent(int err, void *user_data)
|
||||
{
|
||||
struct seg_tx *tx = user_data;
|
||||
|
@ -205,6 +214,11 @@ static void seg_sent(int err, void *user_data)
|
|||
k_delayed_work_submit(&tx->retransmit, SEG_RETRANSMIT_TIMEOUT);
|
||||
}
|
||||
|
||||
static const struct bt_mesh_send_cb first_sent_cb = {
|
||||
.start = seg_send_start,
|
||||
.end = seg_sent,
|
||||
};
|
||||
|
||||
static const struct bt_mesh_send_cb seg_sent_cb = {
|
||||
.end = seg_sent,
|
||||
};
|
||||
|
@ -358,7 +372,9 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, struct net_buf_simple *sdu,
|
|||
|
||||
BT_DBG("Sending %u/%u", seg_o, tx->seg_n);
|
||||
|
||||
err = bt_mesh_net_send(net_tx, seg, &seg_sent_cb, tx);
|
||||
err = bt_mesh_net_send(net_tx, seg,
|
||||
seg_o ? &seg_sent_cb : &first_sent_cb,
|
||||
tx);
|
||||
if (err) {
|
||||
BT_ERR("Sending segment failed");
|
||||
seg_tx_reset(tx);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue