ble_mesh: Expose SeqZero mask

Makes a define for the seqzero 13-bit mask in transport, and exposes it
in the header for use in the friend module.
This commit is contained in:
lly 2019-10-23 09:54:44 +08:00
parent 463a9d8b7f
commit a870460f72
2 changed files with 6 additions and 5 deletions

View File

@ -371,7 +371,7 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, struct net_buf_simple *sdu,
tx->ttl = net_tx->ctx->send_ttl; tx->ttl = net_tx->ctx->send_ttl;
} }
seq_zero = tx->seq_auth & 0x1fff; seq_zero = tx->seq_auth & TRANS_SEQ_ZERO_MASK;
BT_DBG("SeqZero 0x%04x", seq_zero); BT_DBG("SeqZero 0x%04x", seq_zero);
@ -780,7 +780,7 @@ static struct seg_tx *seg_tx_lookup(u16_t seq_zero, u8_t obo, u16_t addr)
for (i = 0; i < ARRAY_SIZE(seg_tx); i++) { for (i = 0; i < ARRAY_SIZE(seg_tx); i++) {
tx = &seg_tx[i]; tx = &seg_tx[i];
if ((tx->seq_auth & 0x1fff) != seq_zero) { if ((tx->seq_auth & TRANS_SEQ_ZERO_MASK) != seq_zero) {
continue; continue;
} }
@ -818,7 +818,7 @@ static int trans_ack(struct bt_mesh_net_rx *rx, u8_t hdr,
seq_zero = net_buf_simple_pull_be16(buf); seq_zero = net_buf_simple_pull_be16(buf);
obo = seq_zero >> 15; obo = seq_zero >> 15;
seq_zero = (seq_zero >> 2) & 0x1fff; seq_zero = (seq_zero >> 2) & TRANS_SEQ_ZERO_MASK;
if (IS_ENABLED(CONFIG_BLE_MESH_FRIEND) && rx->friend_match) { if (IS_ENABLED(CONFIG_BLE_MESH_FRIEND) && rx->friend_match) {
BT_DBG("Ack for LPN 0x%04x of this Friend", rx->ctx.recv_dst); BT_DBG("Ack for LPN 0x%04x of this Friend", rx->ctx.recv_dst);
@ -1079,7 +1079,7 @@ static int send_ack(struct bt_mesh_subnet *sub, u16_t src, u16_t dst,
.src = obo ? bt_mesh_primary_addr() : src, .src = obo ? bt_mesh_primary_addr() : src,
.xmit = bt_mesh_net_transmit_get(), .xmit = bt_mesh_net_transmit_get(),
}; };
u16_t seq_zero = *seq_auth & 0x1fff; u16_t seq_zero = *seq_auth & TRANS_SEQ_ZERO_MASK;
u8_t buf[6]; u8_t buf[6];
BT_DBG("SeqZero 0x%04x Block 0x%08x OBO %u", seq_zero, block, obo); BT_DBG("SeqZero 0x%04x Block 0x%08x OBO %u", seq_zero, block, obo);
@ -1287,7 +1287,7 @@ static int trans_seg(struct net_buf_simple *buf, struct bt_mesh_net_rx *net_rx,
seq_zero = net_buf_simple_pull_be16(buf); seq_zero = net_buf_simple_pull_be16(buf);
seg_o = (seq_zero & 0x03) << 3; seg_o = (seq_zero & 0x03) << 3;
seq_zero = (seq_zero >> 2) & 0x1fff; seq_zero = (seq_zero >> 2) & TRANS_SEQ_ZERO_MASK;
seg_n = net_buf_simple_pull_u8(buf); seg_n = net_buf_simple_pull_u8(buf);
seg_o |= seg_n >> 5; seg_o |= seg_n >> 5;
seg_n &= 0x1f; seg_n &= 0x1f;

View File

@ -14,6 +14,7 @@
#define BLE_MESH_TX_SDU_MAX (CONFIG_BLE_MESH_TX_SEG_MAX * 12) #define BLE_MESH_TX_SDU_MAX (CONFIG_BLE_MESH_TX_SEG_MAX * 12)
#define TRANS_SEQ_ZERO_MASK ((u16_t)BIT_MASK(13))
#define TRANS_CTL_OP_MASK ((u8_t)BIT_MASK(7)) #define TRANS_CTL_OP_MASK ((u8_t)BIT_MASK(7))
#define TRANS_CTL_OP(data) ((data)[0] & TRANS_CTL_OP_MASK) #define TRANS_CTL_OP(data) ((data)[0] & TRANS_CTL_OP_MASK)
#define TRANS_CTL_HDR(op, seg) ((op & TRANS_CTL_OP_MASK) | (seg << 7)) #define TRANS_CTL_HDR(op, seg) ((op & TRANS_CTL_OP_MASK) | (seg << 7))