mesh: single mesh_upper_transport_setup_access_pdu instead of segmented/unsegmented

This commit is contained in:
Matthias Ringwald 2019-04-22 22:48:59 +02:00
parent d984d09471
commit 109de5eff3
3 changed files with 30 additions and 17 deletions

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);