mesh: extract mesh_proxy_set_advertising_with_node_id from config server

This commit is contained in:
Matthias Ringwald 2019-06-14 14:22:30 +02:00
parent af6e0db766
commit ad9347bb4d
3 changed files with 31 additions and 23 deletions

View File

@ -2054,28 +2054,8 @@ static void config_node_identity_set_handler(mesh_model_t *mesh_model, mesh_pdu_
mesh_access_parser_init(&parser, (mesh_pdu_t*) 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);
uint8_t status = MESH_FOUNDATION_STATUS_FEATURE_NOT_SUPPORTED;
mesh_network_key_t * network_key = mesh_network_key_list_get(netkey_index);
if (network_key == NULL){
status = MESH_FOUNDATION_STATUS_INVALID_NETKEY_INDEX;
} else {
#ifdef ENABLE_MESH_PROXY_SERVER
switch (node_identity_state){
case MESH_NODE_IDENTITY_STATE_ADVERTISING_STOPPED:
mesh_proxy_stop_advertising_with_node_id(netkey_index);
status = MESH_FOUNDATION_STATUS_SUCCESS;
break;
case MESH_NODE_IDENTITY_STATE_ADVERTISING_RUNNING:
mesh_proxy_start_advertising_with_node_id(netkey_index);
status = MESH_FOUNDATION_STATUS_SUCCESS;
break;
default:
break;
}
#endif
}
uint8_t status = mesh_proxy_set_advertising_with_node_id(netkey_index, node_identity_state);
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);

View File

@ -145,7 +145,6 @@ void mesh_proxy_stop_advertising_with_node_id(uint16_t netkey_index){
}
uint8_t mesh_proxy_get_advertising_with_node_id_status(uint16_t netkey_index, mesh_node_identity_state_t * out_state ){
mesh_network_key_t * network_key = mesh_network_key_list_get(netkey_index);
if (network_key == NULL){
*out_state = MESH_NODE_IDENTITY_STATE_ADVERTISING_NOT_SUPPORTED;
@ -165,6 +164,28 @@ uint8_t mesh_proxy_get_advertising_with_node_id_status(uint16_t netkey_index, me
return MESH_FOUNDATION_STATUS_SUCCESS;
}
uint8_t mesh_proxy_set_advertising_with_node_id(uint16_t netkey_index, mesh_node_identity_state_t state){
mesh_network_key_t * network_key = mesh_network_key_list_get(netkey_index);
if (network_key == NULL){
return MESH_FOUNDATION_STATUS_INVALID_NETKEY_INDEX;
}
#ifdef ENABLE_MESH_PROXY_SERVER
switch (state){
case MESH_NODE_IDENTITY_STATE_ADVERTISING_STOPPED:
mesh_proxy_stop_advertising_with_node_id(netkey_index);
return MESH_FOUNDATION_STATUS_SUCCESS;
case MESH_NODE_IDENTITY_STATE_ADVERTISING_RUNNING:
mesh_proxy_start_advertising_with_node_id(netkey_index);
return MESH_FOUNDATION_STATUS_SUCCESS;
default:
break;
}
#endif
return MESH_FOUNDATION_STATUS_FEATURE_NOT_SUPPORTED;
}
void mesh_proxy_start_advertising_with_network_id(void){
mesh_network_key_iterator_t it;

View File

@ -69,6 +69,13 @@ void mesh_proxy_start_advertising_with_node_id(uint16_t netkey_index);
*/
void mesh_proxy_stop_advertising_with_node_id(uint16_t netkey_index);
/**
* @brief Set Advertising with Node ID on given subnet
* @param netkey_index of subnet
* @returns MESH_FOUNDATION_STATUS_SUCCESS, MESH_FOUNDATION_STATUS_FEATURE_NOT_SUPPORTED, or MESH_FOUNDATION_STATUS_INVALID_NETKEY_INDEX
*/
uint8_t mesh_proxy_set_advertising_with_node_id(uint16_t netkey_index, mesh_node_identity_state_t state);
/**
* @brief Check if Advertising with Node ID is active
* @param netey_index of subnet