diff --git a/test/mesh/mesh.c b/test/mesh/mesh.c index 0354df7d9..96a967994 100644 --- a/test/mesh/mesh.c +++ b/test/mesh/mesh.c @@ -409,10 +409,10 @@ static void send_pts_unsegmented_access_messsage(void){ uint16_t appkey_index = 0; // MESH_DEVICE_KEY_INDEX; // send as unsegmented access pdu - mesh_network_pdu_t * network_pdu = mesh_network_pdu_get(); - int status = mesh_upper_transport_setup_unsegmented_access_pdu(network_pdu, netkey_index, appkey_index, ttl, src, dest, access_pdu_data, access_pdu_len); + mesh_pdu_t * pdu = (mesh_pdu_t*) mesh_network_pdu_get(); + int status = mesh_upper_transport_setup_access_pdu(pdu, netkey_index, appkey_index, ttl, src, dest, 0, access_pdu_data, access_pdu_len); if (status) return; - mesh_upper_transport_send_access_pdu((mesh_pdu_t*) network_pdu); + mesh_upper_transport_send_access_pdu(pdu); } static void send_pts_segmented_access_messsage_unicast(void){ @@ -430,10 +430,10 @@ static void send_pts_segmented_access_messsage_unicast(void){ uint16_t appkey_index = 0; // MESH_DEVICE_KEY_INDEX; // send as segmented access pdu - mesh_transport_pdu_t * transport_pdu = mesh_transport_pdu_get(); - int status = mesh_upper_transport_setup_segmented_access_pdu(transport_pdu, netkey_index, appkey_index, ttl, src, dest, 0, access_pdu_data, access_pdu_len); + mesh_pdu_t * pdu = (mesh_pdu_t *) mesh_transport_pdu_get(); + int status = mesh_upper_transport_setup_access_pdu(pdu, netkey_index, appkey_index, ttl, src, dest, 0, access_pdu_data, access_pdu_len); if (status) return; - mesh_upper_transport_send_access_pdu((mesh_pdu_t*) transport_pdu); + mesh_upper_transport_send_access_pdu(pdu); } static void send_pts_segmented_access_messsage_group(void){ @@ -451,10 +451,10 @@ static void send_pts_segmented_access_messsage_group(void){ uint16_t appkey_index = 0; // send as segmented access pdu - mesh_transport_pdu_t * transport_pdu = mesh_transport_pdu_get(); - int status = mesh_upper_transport_setup_segmented_access_pdu(transport_pdu, netkey_index, appkey_index, ttl, src, dest, 0, access_pdu_data, access_pdu_len); + mesh_pdu_t * pdu = (mesh_pdu_t *) mesh_transport_pdu_get(); + int status = mesh_upper_transport_setup_access_pdu(pdu, netkey_index, appkey_index, ttl, src, dest, 0, access_pdu_data, access_pdu_len); if (status) return; - mesh_upper_transport_send_access_pdu((mesh_pdu_t*) transport_pdu); + mesh_upper_transport_send_access_pdu(pdu); } static void send_pts_segmented_access_messsage_virtual(void){ @@ -473,7 +473,7 @@ static void send_pts_segmented_access_messsage_virtual(void){ // send as segmented access pdu mesh_transport_pdu_t * transport_pdu = mesh_transport_pdu_get(); - int status = mesh_upper_transport_setup_segmented_access_pdu(transport_pdu, netkey_index, appkey_index, ttl, src, dest, 0, access_pdu_data, access_pdu_len); + int status = mesh_upper_transport_setup_access_pdu((mesh_pdu_t*) transport_pdu, netkey_index, appkey_index, ttl, src, dest, 0, access_pdu_data, access_pdu_len); if (status) return; mesh_upper_transport_send_access_pdu((mesh_pdu_t*) transport_pdu); } diff --git a/test/mesh/mesh_transport.c b/test/mesh/mesh_transport.c index daf21dd1c..89172691c 100644 --- a/test/mesh/mesh_transport.c +++ b/test/mesh/mesh_transport.c @@ -631,7 +631,7 @@ uint8_t mesh_upper_transport_setup_unsegmented_access_pdu_header(mesh_network_pd return 0; } -uint8_t mesh_upper_transport_setup_unsegmented_access_pdu(mesh_network_pdu_t * network_pdu, uint16_t netkey_index, uint16_t appkey_index, uint8_t ttl, uint16_t src, uint16_t dest, +static uint8_t mesh_upper_transport_setup_unsegmented_access_pdu(mesh_network_pdu_t * network_pdu, uint16_t netkey_index, uint16_t appkey_index, uint8_t ttl, uint16_t src, uint16_t dest, const uint8_t * access_pdu_data, uint8_t access_pdu_len){ int status = mesh_upper_transport_setup_unsegmented_access_pdu_header(network_pdu, netkey_index, appkey_index, ttl, src, dest); @@ -683,7 +683,7 @@ uint8_t mesh_upper_transport_setup_segmented_access_pdu_header(mesh_transport_pd } -uint8_t mesh_upper_transport_setup_segmented_access_pdu(mesh_transport_pdu_t * transport_pdu, uint16_t netkey_index, uint16_t appkey_index, uint8_t ttl, uint16_t src, uint16_t dest, +static uint8_t mesh_upper_transport_setup_segmented_access_pdu(mesh_transport_pdu_t * transport_pdu, uint16_t netkey_index, uint16_t appkey_index, uint8_t ttl, uint16_t src, uint16_t dest, uint8_t szmic, const uint8_t * access_pdu_data, uint8_t access_pdu_len){ int status = mesh_upper_transport_setup_segmented_access_pdu_header(transport_pdu, netkey_index, appkey_index, ttl, src, dest, szmic); if (status) return status; @@ -694,6 +694,21 @@ uint8_t mesh_upper_transport_setup_segmented_access_pdu(mesh_transport_pdu_t * t return 0; } +uint8_t mesh_upper_transport_setup_access_pdu(mesh_pdu_t * pdu, uint16_t netkey_index, uint16_t appkey_index, + uint8_t ttl, uint16_t src, uint16_t dest, uint8_t szmic, + const uint8_t * access_pdu_data, uint8_t access_pdu_len){ + switch (pdu->pdu_type){ + case MESH_PDU_TYPE_NETWORK: + mesh_upper_transport_setup_unsegmented_access_pdu((mesh_network_pdu_t *) pdu, netkey_index, appkey_index, ttl, src, dest, access_pdu_data, access_pdu_len); + break; + case MESH_PDU_TYPE_TRANSPORT: + mesh_upper_transport_setup_segmented_access_pdu((mesh_transport_pdu_t *) pdu, netkey_index, appkey_index, ttl, src, dest, szmic, access_pdu_data, access_pdu_len); + break; + default: + break; + } +} + void mesh_upper_transport_send_control_pdu(mesh_pdu_t * pdu){ mesh_lower_transport_send_pdu((mesh_pdu_t*) pdu); } diff --git a/test/mesh/mesh_transport.h b/test/mesh/mesh_transport.h index 8913ee588..239f8d50d 100644 --- a/test/mesh/mesh_transport.h +++ b/test/mesh/mesh_transport.h @@ -76,14 +76,12 @@ void mesh_upper_transport_register_access_message_handler(void (*callback)(mesh_ uint8_t mesh_upper_transport_setup_unsegmented_access_pdu_header(mesh_network_pdu_t * network_pdu, uint16_t netkey_index, uint16_t appkey_index, uint8_t ttl, uint16_t src, uint16_t dest); -uint8_t mesh_upper_transport_setup_unsegmented_access_pdu(mesh_network_pdu_t * network_pdu, uint16_t netkey_index, uint16_t appkey_index, - uint8_t ttl, uint16_t src, uint16_t dest, const uint8_t * access_pdu_data, uint8_t access_pdu_len); - uint8_t mesh_upper_transport_setup_segmented_access_pdu_header(mesh_transport_pdu_t * transport_pdu, uint16_t netkey_index, uint16_t appkey_index, uint8_t ttl, uint16_t src, uint16_t dest, uint8_t szmic); -uint8_t mesh_upper_transport_setup_segmented_access_pdu(mesh_transport_pdu_t * transport_pdu, uint16_t netkey_index, uint16_t appkey_index, - uint8_t ttl, uint16_t src, uint16_t dest, uint8_t szmic, const uint8_t * access_pdu_data, uint8_t access_pdu_len); +uint8_t mesh_upper_transport_setup_access_pdu(mesh_pdu_t * pdu, uint16_t netkey_index, uint16_t appkey_index, + uint8_t ttl, uint16_t src, uint16_t dest, uint8_t szmic, + const uint8_t * access_pdu_data, uint8_t access_pdu_len); void mesh_upper_transport_send_access_pdu(mesh_pdu_t * pdu);