mesh: check netkey index if mesh proxy server not suppoted

This commit is contained in:
Matthias Ringwald 2019-07-19 21:14:58 +02:00
parent c949b9e794
commit 0694a632a5

View File

@ -2101,6 +2101,12 @@ static void config_node_identity_get_handler(mesh_model_t *mesh_model, mesh_pdu_
uint8_t status = MESH_FOUNDATION_STATUS_SUCCESS;
#ifdef ENABLE_MESH_PROXY_SERVER
status = mesh_proxy_get_advertising_with_node_id_status(netkey_index, &node_identity_state);
#else
mesh_subnet_t * network_key = mesh_subnet_get_by_netkey_index(netkey_index);
if (network_key == NULL){
status = MESH_FOUNDATION_STATUS_INVALID_NETKEY_INDEX;
node_identity_state = MESH_NODE_IDENTITY_STATE_ADVERTISING_STOPPED;
}
#endif
config_node_identity_status(mesh_model, mesh_pdu_netkey_index(pdu), mesh_pdu_src(pdu), status, netkey_index, node_identity_state);
@ -2113,11 +2119,22 @@ static void config_node_identity_set_handler(mesh_model_t *mesh_model, mesh_pdu_
uint16_t netkey_index = mesh_access_parser_get_u16(&parser);
mesh_node_identity_state_t node_identity_state = (mesh_node_identity_state_t) mesh_access_parser_get_u8(&parser);
// ignore invalid state
if (node_identity_state >= MESH_NODE_IDENTITY_STATE_ADVERTISING_NOT_SUPPORTED) {
mesh_access_message_processed(pdu);
return;
}
uint8_t status = MESH_FOUNDATION_STATUS_SUCCESS;
#ifdef ENABLE_MESH_PROXY_SERVER
status = mesh_proxy_set_advertising_with_node_id(netkey_index, node_identity_state);
#else
mesh_subnet_t * network_key = mesh_subnet_get_by_netkey_index(netkey_index);
if (network_key == NULL){
status = MESH_FOUNDATION_STATUS_INVALID_NETKEY_INDEX;
}
#endif
config_node_identity_status(mesh_model, mesh_pdu_netkey_index(pdu), mesh_pdu_src(pdu), status, netkey_index, node_identity_state);
mesh_access_message_processed(pdu);