mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-30 16:20:24 +00:00
mesh: single mesh_upper_transport_register_control_message_handler instead of segmented/unsegmented
This commit is contained in:
parent
c9e8931a1a
commit
9cee7f1f66
@ -190,16 +190,25 @@ static void test_upper_transport_access_message_handler(mesh_pdu_t * pdu){
|
||||
}
|
||||
}
|
||||
|
||||
static void test_upper_transport_unsegmented_callback_handler(mesh_network_pdu_t * network_pdu){
|
||||
recv_upper_transport_pdu_len = mesh_network_pdu_len(network_pdu);
|
||||
memcpy(recv_upper_transport_pdu_data, mesh_network_pdu_data(network_pdu), recv_upper_transport_pdu_len);
|
||||
mesh_upper_transport_unsegmented_message_processed_by_higher_layer(network_pdu);
|
||||
}
|
||||
|
||||
static void test_upper_transport_segmented_callback_handler(mesh_transport_pdu_t * transport_pdu){
|
||||
recv_upper_transport_pdu_len = transport_pdu->len;
|
||||
memcpy(recv_upper_transport_pdu_data, transport_pdu->data, recv_upper_transport_pdu_len);
|
||||
mesh_upper_transport_segmented_message_processed_by_higher_layer(transport_pdu);
|
||||
static void test_upper_transport_control_message_handler(mesh_pdu_t * pdu){
|
||||
mesh_transport_pdu_t * transport_pdu;
|
||||
mesh_network_pdu_t * network_pdu;
|
||||
switch(pdu->pdu_type){
|
||||
case MESH_PDU_TYPE_TRANSPORT:
|
||||
transport_pdu = (mesh_transport_pdu_t *) pdu;
|
||||
recv_upper_transport_pdu_len = transport_pdu->len;
|
||||
memcpy(recv_upper_transport_pdu_data, transport_pdu->data, recv_upper_transport_pdu_len);
|
||||
mesh_upper_transport_segmented_message_processed_by_higher_layer(transport_pdu);
|
||||
break;
|
||||
case MESH_PDU_TYPE_NETWORK:
|
||||
network_pdu = (mesh_network_pdu_t *) pdu;
|
||||
recv_upper_transport_pdu_len = mesh_network_pdu_len(network_pdu);
|
||||
memcpy(recv_upper_transport_pdu_data, mesh_network_pdu_data(network_pdu), recv_upper_transport_pdu_len);
|
||||
mesh_upper_transport_unsegmented_message_processed_by_higher_layer(network_pdu);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
TEST_GROUP(MessageTest){
|
||||
@ -214,7 +223,7 @@ TEST_GROUP(MessageTest){
|
||||
mesh_network_set_proxy_message_handler(&test_proxy_server_callback_handler);
|
||||
// register to receive upper transport messages
|
||||
mesh_upper_transport_register_access_message_handler(&test_upper_transport_access_message_handler);
|
||||
mesh_upper_transport_register_unsegmented_control_message_handler(&test_upper_transport_unsegmented_callback_handler);
|
||||
mesh_upper_transport_register_control_message_handler(&test_upper_transport_control_message_handler);
|
||||
mesh_seq_auth_reset();
|
||||
received_network_pdu = NULL;
|
||||
recv_upper_transport_pdu_len =0;
|
||||
|
@ -141,7 +141,7 @@ static mesh_transport_key_and_virtual_address_iterator_t mesh_transport_key_it;
|
||||
|
||||
// upper transport callbacks - in access layer
|
||||
static void (*mesh_access_message_handler)(mesh_pdu_t * pdu);
|
||||
static void (*mesh_control_unsegmented_handler)(mesh_network_pdu_t * network_pdu);
|
||||
static void (*mesh_control_message_handler)(mesh_pdu_t * pdu);
|
||||
|
||||
// unsegmented (network) and segmented (transport) control and access messages
|
||||
static btstack_linked_list_t upper_transport_incoming;
|
||||
@ -150,8 +150,8 @@ static btstack_linked_list_t upper_transport_incoming;
|
||||
void mesh_upper_unsegmented_control_message_received(mesh_network_pdu_t * network_pdu){
|
||||
uint8_t * lower_transport_pdu = mesh_network_pdu_data(network_pdu);
|
||||
uint8_t opcode = lower_transport_pdu[0];
|
||||
if (mesh_control_unsegmented_handler){
|
||||
mesh_control_unsegmented_handler(network_pdu);
|
||||
if (mesh_control_message_handler){
|
||||
mesh_control_message_handler((mesh_pdu_t*) network_pdu);
|
||||
} else {
|
||||
printf("[!] Unhandled Control message with opcode %02x\n", opcode);
|
||||
// done
|
||||
@ -780,8 +780,9 @@ void mesh_upper_transport_set_primary_element_address(uint16_t unicast_address){
|
||||
void mesh_upper_transport_register_access_message_handler(void (*callback)(mesh_pdu_t *pdu)){
|
||||
mesh_access_message_handler = callback;
|
||||
}
|
||||
void mesh_upper_transport_register_unsegmented_control_message_handler(void (*callback)(mesh_network_pdu_t *network_pdu)){
|
||||
mesh_control_unsegmented_handler = callback;
|
||||
|
||||
void mesh_upper_transport_register_control_message_handler(void (*callback)(mesh_pdu_t *pdu)){
|
||||
mesh_control_message_handler = callback;
|
||||
}
|
||||
|
||||
void mesh_upper_transport_set_higher_layer_handler(void (*pdu_handler)( mesh_transport_callback_type_t callback_type, mesh_transport_status_t status, mesh_pdu_t * pdu)){
|
||||
|
@ -59,7 +59,7 @@ void mesh_application_key_set(uint16_t appkey_index, uint8_t aid, const uint8_t
|
||||
|
||||
// Control PDUs
|
||||
|
||||
void mesh_upper_transport_register_unsegmented_control_message_handler(void (*callback)(mesh_network_pdu_t *network_pdu));
|
||||
void mesh_upper_transport_register_control_message_handler(void (*callback)(mesh_pdu_t * pdu));
|
||||
|
||||
uint8_t mesh_upper_transport_setup_segmented_control_pdu(mesh_transport_pdu_t * transport_pdu, uint16_t netkey_index,
|
||||
uint8_t ttl, uint16_t src, uint16_t dest, uint8_t opcode, const uint8_t * control_pdu_data, uint16_t control_pdu_len);
|
||||
|
Loading…
x
Reference in New Issue
Block a user