mesh: add mesh_network_notify_on_freed_pdu

This commit is contained in:
Matthias Ringwald 2020-04-03 18:33:30 +02:00
parent f82a583aa1
commit 3fa4c16cca
2 changed files with 15 additions and 0 deletions

View File

@ -139,6 +139,9 @@ static mesh_network_pdu_t * adv_bearer_network_pdu;
static uint32_t mesh_network_cache[MESH_NETWORK_CACHE_SIZE];
static int mesh_network_cache_index;
// register for freed network pdu
void (*mesh_network_free_pdu_callback)(void);
// prototypes
static void mesh_network_run(void);
@ -1266,8 +1269,19 @@ mesh_network_pdu_t * mesh_network_pdu_get(void){
void mesh_network_pdu_free(mesh_network_pdu_t * network_pdu){
btstack_memory_mesh_network_pdu_free(network_pdu);
if (mesh_network_free_pdu_callback!=NULL){
void (*callback)(void) = mesh_network_free_pdu_callback;
mesh_network_free_pdu_callback= NULL;
(*callback)();
}
}
void mesh_network_notify_on_freed_pdu(void (*callback)(void)){
btstack_assert(mesh_network_free_pdu_callback == NULL);
mesh_network_free_pdu_callback = callback;
}
// Mesh Subnet Management
void mesh_subnet_add(mesh_subnet_t * subnet){

View File

@ -442,6 +442,7 @@ mesh_network_key_t * mesh_subnet_get_outgoing_network_key(mesh_subnet_t * subnet
// buffer pool
mesh_network_pdu_t * mesh_network_pdu_get(void);
void mesh_network_pdu_free(mesh_network_pdu_t * network_pdu);
void mesh_network_notify_on_freed_pdu(void (*callback)(void));
// Mesh Network PDU Getter
uint16_t mesh_network_control(mesh_network_pdu_t * network_pdu);