mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-24 15:02:43 +00:00
mesh: define mesh_network_key and add provide memory pool for it
This commit is contained in:
parent
27c7f61e55
commit
c0a711d937
@ -50,6 +50,32 @@ typedef struct {
|
|||||||
uint8_t data[29];
|
uint8_t data[29];
|
||||||
} mesh_network_pdu_t;
|
} mesh_network_pdu_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
btstack_linked_item_t item;
|
||||||
|
|
||||||
|
// index into shared global key list
|
||||||
|
uint16_t netkey_index;
|
||||||
|
|
||||||
|
// random net_key
|
||||||
|
uint8_t net_key[16];
|
||||||
|
|
||||||
|
// derivative data
|
||||||
|
|
||||||
|
// k1
|
||||||
|
uint8_t identity_key[16];
|
||||||
|
uint8_t beacon_key[16];
|
||||||
|
|
||||||
|
// k2
|
||||||
|
uint8_t nid;
|
||||||
|
uint8_t encryption_key[16];
|
||||||
|
uint8_t privacy_key[16];
|
||||||
|
|
||||||
|
// k3
|
||||||
|
uint8_t network_id[8];
|
||||||
|
|
||||||
|
} mesh_network_key_t;
|
||||||
|
|
||||||
|
|
||||||
#if defined __cplusplus
|
#if defined __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -934,6 +934,44 @@ void btstack_memory_mesh_network_pdu_free(mesh_network_pdu_t *mesh_network_pdu){
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// MARK: mesh_network_key_t
|
||||||
|
#if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_NETWORK_KEYS)
|
||||||
|
#if defined(MAX_NO_MESH_NETWORK_KEYS)
|
||||||
|
#error "Deprecated MAX_NO_MESH_NETWORK_KEYS defined instead of MAX_NR_MESH_NETWORK_KEYS. Please update your btstack_config.h to use MAX_NR_MESH_NETWORK_KEYS."
|
||||||
|
#else
|
||||||
|
#define MAX_NR_MESH_NETWORK_KEYS 0
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef MAX_NR_MESH_NETWORK_KEYS
|
||||||
|
#if MAX_NR_MESH_NETWORK_KEYS > 0
|
||||||
|
static mesh_network_key_t mesh_network_key_storage[MAX_NR_MESH_NETWORK_KEYS];
|
||||||
|
static btstack_memory_pool_t mesh_network_key_pool;
|
||||||
|
mesh_network_key_t * btstack_memory_mesh_network_key_get(void){
|
||||||
|
return (mesh_network_key_t *) btstack_memory_pool_get(&mesh_network_key_pool);
|
||||||
|
}
|
||||||
|
void btstack_memory_mesh_network_key_free(mesh_network_key_t *mesh_network_key){
|
||||||
|
btstack_memory_pool_free(&mesh_network_key_pool, mesh_network_key);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
mesh_network_key_t * btstack_memory_mesh_network_key_get(void){
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
void btstack_memory_mesh_network_key_free(mesh_network_key_t *mesh_network_key){
|
||||||
|
// silence compiler warning about unused parameter in a portable way
|
||||||
|
(void) mesh_network_key;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
#elif defined(HAVE_MALLOC)
|
||||||
|
mesh_network_key_t * btstack_memory_mesh_network_key_get(void){
|
||||||
|
return (mesh_network_key_t*) malloc(sizeof(mesh_network_key_t));
|
||||||
|
}
|
||||||
|
void btstack_memory_mesh_network_key_free(mesh_network_key_t *mesh_network_key){
|
||||||
|
free(mesh_network_key);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// init
|
// init
|
||||||
void btstack_memory_init(void){
|
void btstack_memory_init(void){
|
||||||
@ -995,5 +1033,8 @@ void btstack_memory_init(void){
|
|||||||
#if MAX_NR_MESH_NETWORK_PDUS > 0
|
#if MAX_NR_MESH_NETWORK_PDUS > 0
|
||||||
btstack_memory_pool_create(&mesh_network_pdu_pool, mesh_network_pdu_storage, MAX_NR_MESH_NETWORK_PDUS, sizeof(mesh_network_pdu_t));
|
btstack_memory_pool_create(&mesh_network_pdu_pool, mesh_network_pdu_storage, MAX_NR_MESH_NETWORK_PDUS, sizeof(mesh_network_pdu_t));
|
||||||
#endif
|
#endif
|
||||||
|
#if MAX_NR_MESH_NETWORK_KEYS > 0
|
||||||
|
btstack_memory_pool_create(&mesh_network_key_pool, mesh_network_key_storage, MAX_NR_MESH_NETWORK_KEYS, sizeof(mesh_network_key_t));
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -144,9 +144,11 @@ whitelist_entry_t * btstack_memory_whitelist_entry_get(void);
|
|||||||
void btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry);
|
void btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry);
|
||||||
sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void);
|
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);
|
void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry);
|
||||||
// mesh_network_pdu
|
// mesh_network_pdu, mesh_network_key
|
||||||
mesh_network_pdu_t * btstack_memory_mesh_network_pdu_get(void);
|
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);
|
void btstack_memory_mesh_network_pdu_free(mesh_network_pdu_t *mesh_network_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
|
#endif
|
||||||
|
|
||||||
#if defined __cplusplus
|
#if defined __cplusplus
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
@ -199,12 +201,9 @@ list_of_structs = [
|
|||||||
]
|
]
|
||||||
list_of_le_structs = [
|
list_of_le_structs = [
|
||||||
["gatt_client", "whitelist_entry", "sm_lookup_entry"],
|
["gatt_client", "whitelist_entry", "sm_lookup_entry"],
|
||||||
['mesh_network_pdu']
|
['mesh_network_pdu', 'mesh_network_key']
|
||||||
]
|
]
|
||||||
|
|
||||||
"""
|
|
||||||
"""
|
|
||||||
|
|
||||||
btstack_root = os.path.abspath(os.path.dirname(sys.argv[0]) + '/..')
|
btstack_root = os.path.abspath(os.path.dirname(sys.argv[0]) + '/..')
|
||||||
file_name = btstack_root + "/src/btstack_memory"
|
file_name = btstack_root + "/src/btstack_memory"
|
||||||
print ('Generating %s.[h|c]' % file_name)
|
print ('Generating %s.[h|c]' % file_name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user