mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-28 18:32:41 +00:00
mesh: extend mesh_upper_transport_pdu_free to handle mesh_upper_transport_pdus
This commit is contained in:
parent
ad3a646c65
commit
9efa7aca08
@ -617,15 +617,6 @@ static int mesh_access_setup_opcode(uint8_t * buffer, uint32_t opcode){
|
||||
|
||||
// mesh_message_t builder
|
||||
|
||||
void mesh_access_message_free(mesh_upper_transport_pdu_t * upper) {
|
||||
btstack_assert(upper != NULL);
|
||||
while (upper->segments) {
|
||||
mesh_network_pdu_t *segment = (mesh_network_pdu_t *) btstack_linked_list_pop(&upper->segments);
|
||||
mesh_network_pdu_free(segment);
|
||||
}
|
||||
btstack_memory_mesh_upper_transport_pdu_free(upper);
|
||||
}
|
||||
|
||||
// returns true if successful
|
||||
bool mesh_access_message_add_data(mesh_upper_transport_pdu_t * pdu, const uint8_t * data, uint16_t data_len){
|
||||
uint16_t bytes_current_segment = 0;
|
||||
@ -759,7 +750,7 @@ mesh_upper_transport_pdu_t * mesh_access_setup_message(const mesh_access_message
|
||||
|
||||
if (ok == false){
|
||||
// memory alloc failed
|
||||
mesh_access_message_free(upper_pdu);
|
||||
mesh_upper_transport_pdu_free((mesh_pdu_t *) upper_pdu);
|
||||
upper_pdu = NULL;
|
||||
}
|
||||
|
||||
|
@ -247,8 +247,6 @@ uint32_t mesh_access_parser_get_sig_model_identifier(mesh_access_parser_state_t
|
||||
uint32_t mesh_access_parser_get_vendor_model_identifier(mesh_access_parser_state_t * parser);
|
||||
uint32_t mesh_access_parser_get_model_identifier(mesh_access_parser_state_t * parser);
|
||||
|
||||
// message builder
|
||||
void mesh_access_message_free(mesh_upper_transport_pdu_t * upper);
|
||||
mesh_upper_transport_pdu_t * mesh_access_message_init(uint32_t opcode);
|
||||
bool mesh_access_message_add_data(mesh_upper_transport_pdu_t * pdu, const uint8_t * data, uint16_t data_len);
|
||||
bool mesh_access_message_add_uint8(mesh_upper_transport_pdu_t * pdu, uint8_t value);
|
||||
|
@ -965,9 +965,12 @@ static void mesh_upper_transport_pdu_handler(mesh_transport_callback_type_t call
|
||||
}
|
||||
|
||||
void mesh_upper_transport_pdu_free(mesh_pdu_t * pdu){
|
||||
btstack_assert(pdu != NULL);
|
||||
mesh_network_pdu_t * network_pdu;
|
||||
mesh_segmented_pdu_t * message_pdu;
|
||||
mesh_upper_transport_pdu_t * upper_pdu;
|
||||
switch (pdu->pdu_type) {
|
||||
case MESH_PDU_TYPE_UPPER_UNSEGMENTED_CONTROL:
|
||||
case MESH_PDU_TYPE_NETWORK:
|
||||
network_pdu = (mesh_network_pdu_t *) pdu;
|
||||
mesh_network_pdu_free(network_pdu);
|
||||
@ -975,6 +978,16 @@ void mesh_upper_transport_pdu_free(mesh_pdu_t * pdu){
|
||||
case MESH_PDU_TYPE_SEGMENTED:
|
||||
message_pdu = (mesh_segmented_pdu_t *) pdu;
|
||||
mesh_message_pdu_free(message_pdu);
|
||||
case MESH_PDU_TYPE_UPPER_UNSEGMENTED_ACCESS:
|
||||
case MESH_PDU_TYPE_UPPER_SEGMENTED_ACCESS:
|
||||
case MESH_PDU_TYPE_UPPER_SEGMENTED_CONTROL:
|
||||
upper_pdu = (mesh_upper_transport_pdu_t *) pdu;
|
||||
while (upper_pdu->segments) {
|
||||
mesh_network_pdu_t *segment = (mesh_network_pdu_t *) btstack_linked_list_pop(&upper_pdu->segments);
|
||||
mesh_network_pdu_free(segment);
|
||||
}
|
||||
btstack_memory_mesh_upper_transport_pdu_free(upper_pdu);
|
||||
break;
|
||||
default:
|
||||
btstack_assert(false);
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user