mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-16 08:42:28 +00:00
mesh: reconstruct SeqAuth from network seq and seq_zero
This commit is contained in:
parent
257edf9b97
commit
f3f54aca9a
@ -51,6 +51,8 @@ typedef struct {
|
|||||||
mesh_transport_pdu_t * transport_pdu;
|
mesh_transport_pdu_t * transport_pdu;
|
||||||
// seq_zero
|
// seq_zero
|
||||||
uint16_t seq_zero;
|
uint16_t seq_zero;
|
||||||
|
// seq_auth
|
||||||
|
uint32_t seq_auth;
|
||||||
// block ack
|
// block ack
|
||||||
uint32_t block_ack;
|
uint32_t block_ack;
|
||||||
} mesh_peer_t;
|
} mesh_peer_t;
|
||||||
|
@ -662,7 +662,7 @@ static void mesh_transport_stop_incomplete_timer(mesh_transport_pdu_t * transpor
|
|||||||
|
|
||||||
// stops timers and updates reassembly engine
|
// stops timers and updates reassembly engine
|
||||||
static void mesh_transport_segmented_message_complete(mesh_transport_pdu_t * transport_pdu){
|
static void mesh_transport_segmented_message_complete(mesh_transport_pdu_t * transport_pdu){
|
||||||
/// set flag
|
// set flag
|
||||||
transport_pdu->message_complete = 1;
|
transport_pdu->message_complete = 1;
|
||||||
// stop timers
|
// stop timers
|
||||||
mesh_transport_stop_acknowledgment_timer(transport_pdu);
|
mesh_transport_stop_acknowledgment_timer(transport_pdu);
|
||||||
@ -752,15 +752,22 @@ static mesh_transport_pdu_t * mesh_transport_pdu_for_segmented_message(mesh_netw
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// reconstruct lowest 24 bit of SeqAuth
|
||||||
|
uint32_t seq = mesh_network_seq(network_pdu);
|
||||||
|
uint32_t seq_auth = (seq & 0xffe000) | seq_zero;
|
||||||
|
if (seq_auth > seq){
|
||||||
|
seq_auth -= 0x2000;
|
||||||
|
}
|
||||||
|
|
||||||
// no transport pdu active, check if seq zero is new
|
// no transport pdu active, check if seq zero is new
|
||||||
if (seq_zero > peer->seq_zero){
|
if (seq_auth > peer->seq_auth){
|
||||||
mesh_transport_pdu_t * pdu = btstack_memory_mesh_transport_pdu_get();
|
mesh_transport_pdu_t * pdu = btstack_memory_mesh_transport_pdu_get();
|
||||||
if (!pdu) return NULL;
|
if (!pdu) return NULL;
|
||||||
|
|
||||||
// cache network pdu header
|
// cache network pdu header
|
||||||
memcpy(pdu->network_header, network_pdu->data, 9);
|
memcpy(pdu->network_header, network_pdu->data, 9);
|
||||||
// store lower 24 bit of SeqAuth for App / Device Nonce (by storing 16-bit seq_zero in seq)
|
// store lower 24 bit of SeqAuth for App / Device Nonce
|
||||||
big_endian_store_16(pdu->network_header, 3, seq_zero);
|
big_endian_store_24(pdu->network_header, 2, seq_auth);
|
||||||
|
|
||||||
// store meta data in new pdu
|
// store meta data in new pdu
|
||||||
pdu->netkey_index = network_pdu->netkey_index;
|
pdu->netkey_index = network_pdu->netkey_index;
|
||||||
@ -772,6 +779,7 @@ static mesh_transport_pdu_t * mesh_transport_pdu_for_segmented_message(mesh_netw
|
|||||||
// update peer info
|
// update peer info
|
||||||
peer->transport_pdu = pdu;
|
peer->transport_pdu = pdu;
|
||||||
peer->seq_zero = seq_zero;
|
peer->seq_zero = seq_zero;
|
||||||
|
peer->seq_auth = seq_auth;
|
||||||
peer->block_ack = 0;
|
peer->block_ack = 0;
|
||||||
|
|
||||||
printf("mesh_transport_pdu_for_segmented_message: setup transport pdu %p for src %x, seq %06x, seq_zero %x\n", pdu, src, mesh_transport_seq(pdu), seq_zero);
|
printf("mesh_transport_pdu_for_segmented_message: setup transport pdu %p for src %x, seq %06x, seq_zero %x\n", pdu, src, mesh_transport_seq(pdu), seq_zero);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user