From fde19096d3c7ed18d94a1a64a489ad52f372456b Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Tue, 20 Aug 2019 18:07:43 +0200 Subject: [PATCH] mesh: improve _reset functions for unit tests in mesh_network and btstack_crypto --- src/btstack_crypto.c | 4 ++++ src/btstack_crypto.h | 1 + src/mesh/mesh_network.c | 11 +++++++++++ 3 files changed, 16 insertions(+) diff --git a/src/btstack_crypto.c b/src/btstack_crypto.c index 390c5df05..7d2da4160 100644 --- a/src/btstack_crypto.c +++ b/src/btstack_crypto.c @@ -1220,3 +1220,7 @@ void btstack_crypto_ecc_p256_set_key(const uint8_t * public_key, const uint8_t * int btstack_crypto_idle(void){ return btstack_linked_list_empty(&btstack_crypto_operations); } +void btstack_crypto_reset(void){ + btstack_crypto_operations = NULL; + btstack_crypto_wait_for_hci_result = 0; +} diff --git a/src/btstack_crypto.h b/src/btstack_crypto.h index 89ba57d49..6d32bc142 100644 --- a/src/btstack_crypto.h +++ b/src/btstack_crypto.h @@ -275,6 +275,7 @@ void btstack_crypto_ecc_p256_set_key(const uint8_t * public_key, const uint8_t * // Unit testing int btstack_crypto_idle(void); +void btstack_crypto_reset(void); #if defined __cplusplus } diff --git a/src/mesh/mesh_network.c b/src/mesh/mesh_network.c index bc264109f..326f488df 100644 --- a/src/mesh/mesh_network.c +++ b/src/mesh/mesh_network.c @@ -1090,12 +1090,23 @@ void mesh_network_dump(void){ mesh_network_dump_network_pdus("network_pdus_outgoing_adv", &network_pdus_outgoing_adv); printf("network_pdu_in_validation: \n"); mesh_network_dump_network_pdu(network_pdu_in_validation); + printf("gatt_bearer_network_pdu: \n"); + mesh_network_dump_network_pdu(gatt_bearer_network_pdu); + printf("adv_bearer_network_pdu: \n"); + mesh_network_dump_network_pdu(adv_bearer_network_pdu); } void mesh_network_reset(void){ mesh_network_reset_network_pdus(&network_pdus_received); mesh_network_reset_network_pdus(&network_pdus_queued); mesh_network_reset_network_pdus(&network_pdus_outgoing_gatt); mesh_network_reset_network_pdus(&network_pdus_outgoing_adv); + if (adv_bearer_network_pdu){ + mesh_network_pdu_free(adv_bearer_network_pdu); + } + if (gatt_bearer_network_pdu){ + mesh_network_pdu_free(gatt_bearer_network_pdu); + } + mesh_crypto_active = 0; } // buffer pool