Bluetooth: mesh: Clear link TX when ACK arrived on it

Without this fix there is an issue when doing PB-ADV provisioning
with PTS. We keep retransmitting Public Key which is ACKed by PTS and
this leads to transaction timeout as PTS does not send confirm probably
because it keep receiving PK from us.

This patch also makes sure that transaction id is between 0x80 - 0xFF

Signed-off-by: Łukasz Rymanowski <lukasz.rymanowski@codecoup.pl>
This commit is contained in:
Łukasz Rymanowski 2017-09-05 14:12:00 +02:00 committed by Anas Nashif
commit d3862d7b39

View file

@ -150,6 +150,9 @@ struct prov_link {
/* Start timestamp of the transaction */
s64_t start;
/* Transaction id*/
u8_t id;
/* Pending outgoing buffer(s) */
struct net_buf *buf[3];
@ -358,11 +361,21 @@ static u8_t last_seg(u8_t len)
return 1 + (len / CONT_PAYLOAD_MAX);
}
static inline u8_t next_transaction_id(void)
{
if (link.tx.id != 0 && link.tx.id != 0xFF) {
return ++link.tx.id;
}
link.tx.id = 0x80;
return link.tx.id;
}
static int prov_send_adv(struct net_buf_simple *msg)
{
static u8_t id = 0x80;
struct net_buf *start, *buf;
u8_t seg_len, seg_id;
u8_t xact_id;
BT_DBG("len %u: %s", msg->len, bt_hex(msg->data, msg->len));
@ -373,8 +386,9 @@ static int prov_send_adv(struct net_buf_simple *msg)
return -ENOBUFS;
}
xact_id = next_transaction_id();
net_buf_add_be32(start, link.id);
net_buf_add_u8(start, id);
net_buf_add_u8(start, xact_id);
net_buf_add_u8(start, GPC_START(last_seg(msg->len)));
net_buf_add_be16(start, msg->len);
@ -409,14 +423,12 @@ static int prov_send_adv(struct net_buf_simple *msg)
bt_hex(msg->data, seg_len));
net_buf_add_be32(buf, link.id);
net_buf_add_u8(buf, id);
net_buf_add_u8(buf, xact_id);
net_buf_add_u8(buf, GPC_CONT(seg_id));
net_buf_add_mem(buf, msg->data, seg_len);
net_buf_simple_pull(msg, seg_len);
}
id++;
send_reliable();
return 0;
@ -1264,6 +1276,14 @@ static void gen_prov_cont(struct prov_rx *rx, struct net_buf_simple *buf)
static void gen_prov_ack(struct prov_rx *rx, struct net_buf_simple *buf)
{
BT_DBG("len %u", buf->len);
if (!link.tx.buf[0]) {
return;
}
if (rx->xact_id == link.tx.id) {
prov_clear_tx();
}
}
static void gen_prov_start(struct prov_rx *rx, struct net_buf_simple *buf)