From df5d954debb499f8fc16dc87ca1930fe55e294f1 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Fri, 9 Nov 2018 20:11:03 +0100 Subject: [PATCH] mesh: use mesh_transport_pdu instead of mesh_access_pdu --- src/ble/mesh/mesh_network.h | 2 +- src/btstack_memory.c | 40 ++++++++++++++++---------------- src/btstack_memory.h | 6 ++--- tool/btstack_memory_generator.py | 2 +- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/ble/mesh/mesh_network.h b/src/ble/mesh/mesh_network.h index 0a27ff9b8..d1a42dfdd 100644 --- a/src/ble/mesh/mesh_network.h +++ b/src/ble/mesh/mesh_network.h @@ -72,7 +72,7 @@ typedef struct { // pdu uint16_t len; uint8_t data[MESH_ACCESS_PAYLOAD_MAX]; -} mesh_access_pdu_t; +} mesh_transport_pdu_t; // typedef struct { diff --git a/src/btstack_memory.c b/src/btstack_memory.c index db9eafbd9..4f717aaa4 100644 --- a/src/btstack_memory.c +++ b/src/btstack_memory.c @@ -938,40 +938,40 @@ void btstack_memory_mesh_network_pdu_free(mesh_network_pdu_t *mesh_network_pdu){ #endif -// MARK: mesh_access_pdu_t -#if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_ACCESS_PDUS) - #if defined(MAX_NO_MESH_ACCESS_PDUS) - #error "Deprecated MAX_NO_MESH_ACCESS_PDUS defined instead of MAX_NR_MESH_ACCESS_PDUS. Please update your btstack_config.h to use MAX_NR_MESH_ACCESS_PDUS." +// MARK: mesh_transport_pdu_t +#if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_TRANSPORT_PDUS) + #if defined(MAX_NO_MESH_TRANSPORT_PDUS) + #error "Deprecated MAX_NO_MESH_TRANSPORT_PDUS defined instead of MAX_NR_MESH_TRANSPORT_PDUS. Please update your btstack_config.h to use MAX_NR_MESH_TRANSPORT_PDUS." #else - #define MAX_NR_MESH_ACCESS_PDUS 0 + #define MAX_NR_MESH_TRANSPORT_PDUS 0 #endif #endif -#ifdef MAX_NR_MESH_ACCESS_PDUS -#if MAX_NR_MESH_ACCESS_PDUS > 0 -static mesh_access_pdu_t mesh_access_pdu_storage[MAX_NR_MESH_ACCESS_PDUS]; -static btstack_memory_pool_t mesh_access_pdu_pool; -mesh_access_pdu_t * btstack_memory_mesh_access_pdu_get(void){ - return (mesh_access_pdu_t *) btstack_memory_pool_get(&mesh_access_pdu_pool); +#ifdef MAX_NR_MESH_TRANSPORT_PDUS +#if MAX_NR_MESH_TRANSPORT_PDUS > 0 +static mesh_transport_pdu_t mesh_transport_pdu_storage[MAX_NR_MESH_TRANSPORT_PDUS]; +static btstack_memory_pool_t mesh_transport_pdu_pool; +mesh_transport_pdu_t * btstack_memory_mesh_transport_pdu_get(void){ + return (mesh_transport_pdu_t *) btstack_memory_pool_get(&mesh_transport_pdu_pool); } -void btstack_memory_mesh_access_pdu_free(mesh_access_pdu_t *mesh_access_pdu){ - btstack_memory_pool_free(&mesh_access_pdu_pool, mesh_access_pdu); +void btstack_memory_mesh_transport_pdu_free(mesh_transport_pdu_t *mesh_transport_pdu){ + btstack_memory_pool_free(&mesh_transport_pdu_pool, mesh_transport_pdu); } #else -mesh_access_pdu_t * btstack_memory_mesh_access_pdu_get(void){ +mesh_transport_pdu_t * btstack_memory_mesh_transport_pdu_get(void){ return NULL; } -void btstack_memory_mesh_access_pdu_free(mesh_access_pdu_t *mesh_access_pdu){ +void btstack_memory_mesh_transport_pdu_free(mesh_transport_pdu_t *mesh_transport_pdu){ // silence compiler warning about unused parameter in a portable way - (void) mesh_access_pdu; + (void) mesh_transport_pdu; }; #endif #elif defined(HAVE_MALLOC) -mesh_access_pdu_t * btstack_memory_mesh_access_pdu_get(void){ - return (mesh_access_pdu_t*) malloc(sizeof(mesh_access_pdu_t)); +mesh_transport_pdu_t * btstack_memory_mesh_transport_pdu_get(void){ + return (mesh_transport_pdu_t*) malloc(sizeof(mesh_transport_pdu_t)); } -void btstack_memory_mesh_access_pdu_free(mesh_access_pdu_t *mesh_access_pdu){ - free(mesh_access_pdu); +void btstack_memory_mesh_transport_pdu_free(mesh_transport_pdu_t *mesh_transport_pdu){ + free(mesh_transport_pdu); } #endif diff --git a/src/btstack_memory.h b/src/btstack_memory.h index e6500ff56..db1f082c3 100644 --- a/src/btstack_memory.h +++ b/src/btstack_memory.h @@ -151,11 +151,11 @@ sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void); void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry); #endif #ifdef ENABLE_MESH -// mesh_network_pdu, mesh_access_pdu, mesh_network_key +// mesh_network_pdu, mesh_transport_pdu, mesh_network_key mesh_network_pdu_t * btstack_memory_mesh_network_pdu_get(void); void btstack_memory_mesh_network_pdu_free(mesh_network_pdu_t *mesh_network_pdu); -mesh_access_pdu_t * btstack_memory_mesh_access_pdu_get(void); -void btstack_memory_mesh_access_pdu_free(mesh_access_pdu_t *mesh_access_pdu); +mesh_transport_pdu_t * btstack_memory_mesh_transport_pdu_get(void); +void btstack_memory_mesh_transport_pdu_free(mesh_transport_pdu_t *mesh_transport_pdu); mesh_network_key_t * btstack_memory_mesh_network_key_get(void); void btstack_memory_mesh_network_key_free(mesh_network_key_t *mesh_network_key); #endif diff --git a/tool/btstack_memory_generator.py b/tool/btstack_memory_generator.py index e7291d2db..b54962849 100755 --- a/tool/btstack_memory_generator.py +++ b/tool/btstack_memory_generator.py @@ -208,7 +208,7 @@ list_of_le_structs = [ ["gatt_client", "whitelist_entry", "sm_lookup_entry"], ] list_of_mesh_structs = [ - ['mesh_network_pdu', 'mesh_access_pdu', 'mesh_network_key'] + ['mesh_network_pdu', 'mesh_transport_pdu', 'mesh_network_key'] ] btstack_root = os.path.abspath(os.path.dirname(sys.argv[0]) + '/..')