mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-25 09:35:42 +00:00
mesh: add mesh_network_callback_type_t to callbacks from mesh_network
This commit is contained in:
parent
4c8f56d7c4
commit
12560ee3f2
@ -64,7 +64,7 @@ typedef struct {
|
||||
static uint32_t global_iv_index;
|
||||
static uint16_t mesh_network_primary_address;
|
||||
static uint16_t mesh_network_num_elements;
|
||||
static void (*mesh_network_higher_layer_handler)(mesh_network_pdu_t * network_pdu);
|
||||
static void (*mesh_network_higher_layer_handler)(mesh_network_callback_type_t callback_type, mesh_network_pdu_t * network_pdu);
|
||||
|
||||
// shared send/receive crypto
|
||||
static int mesh_crypto_active;
|
||||
@ -359,7 +359,7 @@ static void process_network_pdu_validate_d(void * arg){
|
||||
mesh_network_cache_add(hash);
|
||||
|
||||
// forward to lower transport layer. message is freed by call to mesh_network_message_processed_by_upper_layer
|
||||
(*mesh_network_higher_layer_handler)(network_pdu);
|
||||
(*mesh_network_higher_layer_handler)(MESH_NETWORK_PDU_RECEIVED, network_pdu);
|
||||
|
||||
} else {
|
||||
|
||||
@ -540,7 +540,7 @@ void mesh_network_init(void){
|
||||
adv_bearer_register_for_mesh_message(&mesh_message_handler);
|
||||
}
|
||||
|
||||
void mesh_network_set_higher_layer_handler(void (*packet_handler)(mesh_network_pdu_t * network_pdu)){
|
||||
void mesh_network_set_higher_layer_handler(void (*packet_handler)(mesh_network_callback_type_t callback_type, mesh_network_pdu_t * network_pdu)){
|
||||
mesh_network_higher_layer_handler = packet_handler;
|
||||
}
|
||||
|
||||
|
@ -50,6 +50,11 @@ extern "C" {
|
||||
#define MESH_NETWORK_PAYLOAD_MAX 29
|
||||
#define MESH_ACCESS_PAYLOAD_MAX 384
|
||||
|
||||
typedef enum {
|
||||
MESH_NETWORK_PDU_RECEIVED,
|
||||
MESH_NETWORK_PDU_SENT,
|
||||
} mesh_network_callback_type_t;
|
||||
|
||||
typedef struct {
|
||||
// allow for linked lists
|
||||
btstack_linked_item_t item;
|
||||
@ -124,7 +129,7 @@ void mesh_network_init(void);
|
||||
* @brief Set higher layer Network PDU handler
|
||||
* @param packet_handler
|
||||
*/
|
||||
void mesh_network_set_higher_layer_handler(void (*packet_handler)(mesh_network_pdu_t * network_pdu));
|
||||
void mesh_network_set_higher_layer_handler(void (*packet_handler)(mesh_network_callback_type_t callback_type, mesh_network_pdu_t * network_pdu));
|
||||
|
||||
/**
|
||||
* @brief Mark packet as processed
|
||||
|
@ -888,10 +888,18 @@ static void mesh_lower_transport_run(void){
|
||||
}
|
||||
}
|
||||
|
||||
static void mesh_transport_received_mesage(mesh_network_pdu_t * network_pdu){
|
||||
// add to list and go
|
||||
btstack_linked_list_add_tail(&lower_transport_incoming, (btstack_linked_item_t *) network_pdu);
|
||||
mesh_lower_transport_run();
|
||||
static void mesh_transport_received_mesage(mesh_network_callback_type_t callback_type, mesh_network_pdu_t * network_pdu){
|
||||
switch (callback_type){
|
||||
case MESH_NETWORK_PDU_RECEIVED:
|
||||
// add to list and go
|
||||
btstack_linked_list_add_tail(&lower_transport_incoming, (btstack_linked_item_t *) network_pdu);
|
||||
mesh_lower_transport_run();
|
||||
break;
|
||||
case MESH_NETWORK_PDU_SENT:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// UPPER TRANSPORT
|
||||
|
Loading…
x
Reference in New Issue
Block a user