mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-13 15:41:17 +00:00
mesh: extract mesh_lower_transport_process_segment_acknowledgement_message
This commit is contained in:
parent
8f6e30145b
commit
68d3bb6c90
@ -125,27 +125,19 @@ static mesh_transport_pdu_t * lower_transport_outgoing_pdu;
|
|||||||
static mesh_network_pdu_t * lower_transport_outgoing_segment;
|
static mesh_network_pdu_t * lower_transport_outgoing_segment;
|
||||||
static uint16_t lower_transport_outgoing_seg_o;
|
static uint16_t lower_transport_outgoing_seg_o;
|
||||||
|
|
||||||
static void mesh_lower_transport_process_unsegmented_control_message(mesh_network_pdu_t *network_pdu){
|
static void mesh_lower_transport_process_segment_acknowledgement_message(mesh_network_pdu_t *network_pdu){
|
||||||
|
if (lower_transport_outgoing_pdu == NULL) return;
|
||||||
|
|
||||||
uint8_t * lower_transport_pdu = mesh_network_pdu_data(network_pdu);
|
uint8_t * lower_transport_pdu = mesh_network_pdu_data(network_pdu);
|
||||||
uint8_t opcode = lower_transport_pdu[0];
|
uint16_t seq_zero_pdu = big_endian_read_16(lower_transport_pdu, 1) >> 2;
|
||||||
uint16_t seq_zero_pdu;
|
uint16_t seq_zero_out = mesh_transport_seq(lower_transport_outgoing_pdu) & 0x1fff;
|
||||||
uint16_t seq_zero_out;
|
uint32_t block_ack = big_endian_read_32(lower_transport_pdu, 3);
|
||||||
uint32_t block_ack;
|
|
||||||
|
|
||||||
#ifdef LOG_LOWER_TRANSPORT
|
|
||||||
printf("Unsegmented Control message, outgoing message %p, opcode %x\n", lower_transport_outgoing_pdu, opcode);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
switch (opcode){
|
|
||||||
case 0:
|
|
||||||
if (lower_transport_outgoing_pdu == NULL) break;
|
|
||||||
seq_zero_pdu = big_endian_read_16(lower_transport_pdu, 1) >> 2;
|
|
||||||
seq_zero_out = mesh_transport_seq(lower_transport_outgoing_pdu) & 0x1fff;
|
|
||||||
block_ack = big_endian_read_32(lower_transport_pdu, 3);
|
|
||||||
#ifdef LOG_LOWER_TRANSPORT
|
#ifdef LOG_LOWER_TRANSPORT
|
||||||
printf("[+] Segment Acknowledgment message with seq_zero %06x, block_ack %08x - outgoing seq %06x, block_ack %08x\n",
|
printf("[+] Segment Acknowledgment message with seq_zero %06x, block_ack %08x - outgoing seq %06x, block_ack %08x\n",
|
||||||
seq_zero_pdu, block_ack, seq_zero_out, lower_transport_outgoing_pdu->block_ack);
|
seq_zero_pdu, block_ack, seq_zero_out, lower_transport_outgoing_pdu->block_ack);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (block_ack == 0){
|
if (block_ack == 0){
|
||||||
// If a Segment Acknowledgment message with the BlockAck field set to 0x00000000 is received,
|
// If a Segment Acknowledgment message with the BlockAck field set to 0x00000000 is received,
|
||||||
// then the Upper Transport PDU shall be immediately cancelled and the higher layers shall be notified that
|
// then the Upper Transport PDU shall be immediately cancelled and the higher layers shall be notified that
|
||||||
@ -154,24 +146,40 @@ static void mesh_lower_transport_process_unsegmented_control_message(mesh_networ
|
|||||||
printf("[+] Block Ack == 0 => Abort\n");
|
printf("[+] Block Ack == 0 => Abort\n");
|
||||||
#endif
|
#endif
|
||||||
mesh_lower_transport_abort_transmission();
|
mesh_lower_transport_abort_transmission();
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
if (seq_zero_pdu != seq_zero_out){
|
if (seq_zero_pdu != seq_zero_out){
|
||||||
|
|
||||||
#ifdef LOG_LOWER_TRANSPORT
|
#ifdef LOG_LOWER_TRANSPORT
|
||||||
printf("[!] Seq Zero doesn't match\n");
|
printf("[!] Seq Zero doesn't match\n");
|
||||||
#endif
|
#endif
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
lower_transport_outgoing_pdu->block_ack &= ~block_ack;
|
lower_transport_outgoing_pdu->block_ack &= ~block_ack;
|
||||||
#ifdef LOG_LOWER_TRANSPORT
|
#ifdef LOG_LOWER_TRANSPORT
|
||||||
printf("[+] Updated block_ack %08x\n", lower_transport_outgoing_pdu->block_ack);
|
printf("[+] Updated block_ack %08x\n", lower_transport_outgoing_pdu->block_ack);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (lower_transport_outgoing_pdu->block_ack == 0){
|
if (lower_transport_outgoing_pdu->block_ack == 0){
|
||||||
#ifdef LOG_LOWER_TRANSPORT
|
#ifdef LOG_LOWER_TRANSPORT
|
||||||
printf("[+] Sent complete\n");
|
printf("[+] Sent complete\n");
|
||||||
#endif
|
#endif
|
||||||
mesh_lower_transport_abort_transmission();
|
mesh_lower_transport_abort_transmission();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void mesh_lower_transport_process_unsegmented_control_message(mesh_network_pdu_t *network_pdu){
|
||||||
|
uint8_t * lower_transport_pdu = mesh_network_pdu_data(network_pdu);
|
||||||
|
uint8_t opcode = lower_transport_pdu[0];
|
||||||
|
|
||||||
|
#ifdef LOG_LOWER_TRANSPORT
|
||||||
|
printf("Unsegmented Control message, outgoing message %p, opcode %x\n", lower_transport_outgoing_pdu, opcode);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
switch (opcode){
|
||||||
|
case 0:
|
||||||
|
mesh_lower_transport_process_segment_acknowledgement_message(network_pdu);
|
||||||
mesh_network_message_processed_by_higher_layer(network_pdu);
|
mesh_network_message_processed_by_higher_layer(network_pdu);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user