mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-03 20:54:18 +00:00
mesh: introduce mesh_message_t
This commit is contained in:
parent
1c79b5e3cc
commit
f7434c1fd6
@ -35,11 +35,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#define BTSTACK_FILE__ "btstack_memory.c"
|
||||
|
||||
|
||||
/*
|
||||
* btstack_memory.h
|
||||
* btstack_memory.c
|
||||
*
|
||||
* @brief BTstack memory management via configurable memory pools
|
||||
*
|
||||
@ -992,6 +992,52 @@ void btstack_memory_mesh_transport_pdu_free(mesh_transport_pdu_t *mesh_transport
|
||||
#endif
|
||||
|
||||
|
||||
// MARK: mesh_message_pdu_t
|
||||
#if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_MESSAGE_PDUS)
|
||||
#if defined(MAX_NO_MESH_MESSAGE_PDUS)
|
||||
#error "Deprecated MAX_NO_MESH_MESSAGE_PDUS defined instead of MAX_NR_MESH_MESSAGE_PDUS. Please update your btstack_config.h to use MAX_NR_MESH_MESSAGE_PDUS."
|
||||
#else
|
||||
#define MAX_NR_MESH_MESSAGE_PDUS 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MAX_NR_MESH_MESSAGE_PDUS
|
||||
#if MAX_NR_MESH_MESSAGE_PDUS > 0
|
||||
static mesh_message_pdu_t mesh_message_pdu_storage[MAX_NR_MESH_MESSAGE_PDUS];
|
||||
static btstack_memory_pool_t mesh_message_pdu_pool;
|
||||
mesh_message_pdu_t * btstack_memory_mesh_message_pdu_get(void){
|
||||
void * buffer = btstack_memory_pool_get(&mesh_message_pdu_pool);
|
||||
if (buffer){
|
||||
memset(buffer, 0, sizeof(mesh_message_pdu_t));
|
||||
}
|
||||
return (mesh_message_pdu_t *) buffer;
|
||||
}
|
||||
void btstack_memory_mesh_message_pdu_free(mesh_message_pdu_t *mesh_message_pdu){
|
||||
btstack_memory_pool_free(&mesh_message_pdu_pool, mesh_message_pdu);
|
||||
}
|
||||
#else
|
||||
mesh_message_pdu_t * btstack_memory_mesh_message_pdu_get(void){
|
||||
return NULL;
|
||||
}
|
||||
void btstack_memory_mesh_message_pdu_free(mesh_message_pdu_t *mesh_message_pdu){
|
||||
// silence compiler warning about unused parameter in a portable way
|
||||
(void) mesh_message_pdu;
|
||||
};
|
||||
#endif
|
||||
#elif defined(HAVE_MALLOC)
|
||||
mesh_message_pdu_t * btstack_memory_mesh_message_pdu_get(void){
|
||||
void * buffer = malloc(sizeof(mesh_message_pdu_t));
|
||||
if (buffer){
|
||||
memset(buffer, 0, sizeof(mesh_message_pdu_t));
|
||||
}
|
||||
return (mesh_message_pdu_t *) buffer;
|
||||
}
|
||||
void btstack_memory_mesh_message_pdu_free(mesh_message_pdu_t *mesh_message_pdu){
|
||||
free(mesh_message_pdu);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// MARK: mesh_network_key_t
|
||||
#if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_NETWORK_KEYS)
|
||||
#if defined(MAX_NO_MESH_NETWORK_KEYS)
|
||||
@ -1244,6 +1290,9 @@ void btstack_memory_init(void){
|
||||
#if MAX_NR_MESH_TRANSPORT_PDUS > 0
|
||||
btstack_memory_pool_create(&mesh_transport_pdu_pool, mesh_transport_pdu_storage, MAX_NR_MESH_TRANSPORT_PDUS, sizeof(mesh_transport_pdu_t));
|
||||
#endif
|
||||
#if MAX_NR_MESH_MESSAGE_PDUS > 0
|
||||
btstack_memory_pool_create(&mesh_message_pdu_pool, mesh_message_pdu_storage, MAX_NR_MESH_MESSAGE_PDUS, sizeof(mesh_message_pdu_t));
|
||||
#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
|
||||
|
@ -153,11 +153,13 @@ 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_transport_pdu, mesh_network_key, mesh_transport_key, mesh_virtual_address, mesh_subnet
|
||||
// mesh_network_pdu, mesh_transport_pdu, mesh_message_pdu, mesh_network_key, mesh_transport_key, mesh_virtual_address, mesh_subnet
|
||||
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_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_message_pdu_t * btstack_memory_mesh_message_pdu_get(void);
|
||||
void btstack_memory_mesh_message_pdu_free(mesh_message_pdu_t *mesh_message_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);
|
||||
mesh_transport_key_t * btstack_memory_mesh_transport_key_get(void);
|
||||
|
@ -68,6 +68,7 @@ typedef enum {
|
||||
typedef enum {
|
||||
MESH_PDU_TYPE_NETWORK = 0,
|
||||
MESH_PDU_TYPE_TRANSPORT,
|
||||
MESH_PDU_TYPE_MESSAGE,
|
||||
} mesh_pdu_type_t;
|
||||
|
||||
typedef struct mesh_pdu {
|
||||
@ -142,6 +143,40 @@ typedef struct {
|
||||
uint8_t data[MESH_ACCESS_PAYLOAD_MAX];
|
||||
} mesh_transport_pdu_t;
|
||||
|
||||
typedef struct {
|
||||
mesh_pdu_t pdu_header;
|
||||
|
||||
// rx/tx: acknowledgement timer / segment transmission timer
|
||||
btstack_timer_source_t acknowledgement_timer;
|
||||
// rx: incomplete timer / tx: resend timer
|
||||
btstack_timer_source_t incomplete_timer;
|
||||
// block access
|
||||
uint32_t block_ack;
|
||||
// meta data network layer
|
||||
uint16_t netkey_index;
|
||||
// meta data transport layer
|
||||
uint16_t appkey_index;
|
||||
// transmic size
|
||||
uint8_t transmic_len;
|
||||
// akf - aid for access, opcode for control
|
||||
uint8_t akf_aid_control;
|
||||
// network pdu header
|
||||
uint8_t network_header[9];
|
||||
// MESH_TRANSPORT_FLAG
|
||||
uint16_t flags;
|
||||
// acknowledgement timer active
|
||||
uint8_t acknowledgement_timer_active;
|
||||
// incomplete timer active
|
||||
uint8_t incomplete_timer_active;
|
||||
// message complete
|
||||
uint8_t message_complete;
|
||||
// seq_zero for segmented messages
|
||||
uint16_t seq_zero;
|
||||
// pdu segments
|
||||
uint16_t len;
|
||||
btstack_linked_list_t segments;
|
||||
} mesh_message_pdu_t;
|
||||
|
||||
typedef enum {
|
||||
MESH_KEY_REFRESH_NOT_ACTIVE = 0,
|
||||
MESH_KEY_REFRESH_FIRST_PHASE,
|
||||
|
@ -213,7 +213,7 @@ list_of_le_structs = [
|
||||
["gatt_client", "whitelist_entry", "sm_lookup_entry"],
|
||||
]
|
||||
list_of_mesh_structs = [
|
||||
['mesh_network_pdu', 'mesh_transport_pdu', 'mesh_network_key', 'mesh_transport_key', 'mesh_virtual_address', 'mesh_subnet']
|
||||
['mesh_network_pdu', 'mesh_transport_pdu', 'mesh_message_pdu', 'mesh_network_key', 'mesh_transport_key', 'mesh_virtual_address', 'mesh_subnet']
|
||||
]
|
||||
|
||||
btstack_root = os.path.abspath(os.path.dirname(sys.argv[0]) + '/..')
|
||||
|
Loading…
x
Reference in New Issue
Block a user