mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-13 04:13:54 +00:00
mesh: use mesh-unsegmented-pdu to send unsegmented control messages
This commit is contained in:
parent
6545a65bed
commit
b837963cae
@ -171,6 +171,8 @@ static mesh_message_pdu_t lower_transport_outgoing_segmented_message_singlet
|
||||
|
||||
static mesh_message_pdu_t * lower_transport_outgoing_message;
|
||||
|
||||
static mesh_unsegmented_pdu_t * lower_transport_outgoing_unsegmented_pdu;
|
||||
|
||||
// segment at network layer
|
||||
static int lower_transport_outgoing_segment_queued;
|
||||
// transmission timeout occured (while outgoing segment queued at network layer)
|
||||
@ -886,6 +888,14 @@ static void mesh_lower_transport_network_pdu_sent(mesh_network_pdu_t *network_pd
|
||||
return;
|
||||
}
|
||||
|
||||
// Unsegmented message
|
||||
if (lower_transport_outgoing_unsegmented_pdu != NULL){
|
||||
mesh_unsegmented_pdu_t * unsegmented_pdu = lower_transport_outgoing_unsegmented_pdu;
|
||||
lower_transport_outgoing_unsegmented_pdu = NULL;
|
||||
higher_layer_handler(MESH_TRANSPORT_PDU_SENT, MESH_TRANSPORT_STATUS_SUCCESS, (mesh_pdu_t *) unsegmented_pdu);
|
||||
return;
|
||||
}
|
||||
|
||||
// other
|
||||
higher_layer_handler(MESH_TRANSPORT_PDU_SENT, MESH_TRANSPORT_STATUS_SUCCESS, (mesh_pdu_t *) network_pdu);
|
||||
}
|
||||
@ -940,6 +950,11 @@ static void mesh_lower_transport_run(void){
|
||||
network_pdu = (mesh_network_pdu_t *) pdu;
|
||||
mesh_network_send_pdu(network_pdu);
|
||||
break;
|
||||
case MESH_PDU_TYPE_UNSEGMENTED:
|
||||
lower_transport_outgoing_unsegmented_pdu = (mesh_unsegmented_pdu_t *) pdu;
|
||||
network_pdu = lower_transport_outgoing_unsegmented_pdu->segment;
|
||||
mesh_network_send_pdu(network_pdu);
|
||||
break;
|
||||
case MESH_PDU_TYPE_MESSAGE:
|
||||
message_pdu = (mesh_message_pdu_t *) pdu;
|
||||
if (message_pdu->segmented){
|
||||
|
@ -91,8 +91,8 @@ static mesh_access_pdu_t incoming_access_pdu_encrypted_singleton;
|
||||
static mesh_access_pdu_t incoming_access_pdu_decrypted_singleton;
|
||||
|
||||
static mesh_message_pdu_t outgoing_segmented_message_singleton;
|
||||
|
||||
static mesh_transport_pdu_t * outgoing_segmented_pdu;
|
||||
static mesh_unsegmented_pdu_t outgoing_unsegmented_pdu;
|
||||
|
||||
static uint8_t application_nonce[13];
|
||||
static btstack_crypto_ccm_t ccm;
|
||||
@ -601,23 +601,41 @@ static void mesh_upper_transport_message_received(mesh_pdu_t * pdu){
|
||||
|
||||
static void mesh_upper_transport_pdu_handler(mesh_transport_callback_type_t callback_type, mesh_transport_status_t status, mesh_pdu_t * pdu){
|
||||
mesh_transport_pdu_t * transport_pdu;
|
||||
mesh_network_pdu_t * network_pdu;
|
||||
switch (callback_type){
|
||||
case MESH_TRANSPORT_PDU_RECEIVED:
|
||||
mesh_upper_transport_message_received(pdu);
|
||||
break;
|
||||
case MESH_TRANSPORT_PDU_SENT:
|
||||
// free chunks
|
||||
while (!btstack_linked_list_empty(&outgoing_segmented_message_singleton.segments)){
|
||||
mesh_network_pdu_t * network_pdu = (mesh_network_pdu_t *) btstack_linked_list_pop(&outgoing_segmented_message_singleton.segments);
|
||||
mesh_network_pdu_free(network_pdu);
|
||||
}
|
||||
// notify upper layer but use transport pdu
|
||||
transport_pdu = outgoing_segmented_pdu;
|
||||
outgoing_segmented_pdu = NULL;
|
||||
if (higher_layer_handler){
|
||||
higher_layer_handler(callback_type, status, (mesh_pdu_t*) transport_pdu);
|
||||
} else {
|
||||
mesh_transport_pdu_free(transport_pdu);
|
||||
switch (pdu->pdu_type){
|
||||
case MESH_PDU_TYPE_MESSAGE:
|
||||
// free chunks
|
||||
while (!btstack_linked_list_empty(&outgoing_segmented_message_singleton.segments)){
|
||||
mesh_network_pdu_t * network_pdu = (mesh_network_pdu_t *) btstack_linked_list_pop(&outgoing_segmented_message_singleton.segments);
|
||||
mesh_network_pdu_free(network_pdu);
|
||||
}
|
||||
// notify upper layer but use transport pdu
|
||||
transport_pdu = (mesh_transport_pdu_t *) outgoing_segmented_pdu;
|
||||
outgoing_segmented_pdu = NULL;
|
||||
if (higher_layer_handler){
|
||||
higher_layer_handler(callback_type, status, (mesh_pdu_t*) transport_pdu);
|
||||
} else {
|
||||
mesh_transport_pdu_free(transport_pdu);
|
||||
}
|
||||
break;
|
||||
case MESH_PDU_TYPE_UNSEGMENTED:
|
||||
// notify upper layer but use network pdu
|
||||
network_pdu = outgoing_unsegmented_pdu.segment;
|
||||
outgoing_unsegmented_pdu.segment = NULL;
|
||||
if (higher_layer_handler){
|
||||
higher_layer_handler(callback_type, status, (mesh_pdu_t*) network_pdu);
|
||||
} else {
|
||||
mesh_transport_pdu_free(transport_pdu);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
btstack_assert(false);
|
||||
break;
|
||||
}
|
||||
mesh_upper_transport_run();
|
||||
break;
|
||||
@ -1040,8 +1058,12 @@ static void mesh_upper_transport_send_unsegmented_control_pdu(mesh_network_pdu_t
|
||||
uint8_t opcode = network_pdu->data[9];
|
||||
printf("[+] Upper transport, send unsegmented Control PDU %p - seq %06x opcode %02x\n", network_pdu, seq, opcode);
|
||||
mesh_print_hex("Access Payload", &network_pdu->data[10], network_pdu->len - 10);
|
||||
// wrap into mesh-unsegmented-pdu
|
||||
outgoing_unsegmented_pdu.pdu_header.pdu_type = MESH_PDU_TYPE_UNSEGMENTED;
|
||||
outgoing_unsegmented_pdu.segment = network_pdu;
|
||||
|
||||
// send
|
||||
mesh_lower_transport_send_pdu((mesh_pdu_t *) network_pdu);
|
||||
mesh_lower_transport_send_pdu((mesh_pdu_t *) &outgoing_unsegmented_pdu);
|
||||
}
|
||||
|
||||
static void mesh_upper_transport_send_segmented_control_pdu(mesh_transport_pdu_t * transport_pdu){
|
||||
|
Loading…
x
Reference in New Issue
Block a user