This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Mesh : erase server information and sto

Hi,

I'm using nRF52840 with mesh 2.0.0 and started from the light switch example to build my own application. I have now 2 type of boards master (client+provisionner) and slaves (server).

In case of a change of the master (client +provisioner) the slave boards have to delete their mesh information stored in flash and start again.

Currently, I do that by erasing the flash memory of the ship and reflash the code again which is a manual task! or by using the code provided in the switch light example and calling :

void mesh_stack_config_clear(void)
{
    access_clear();
    dsm_clear();
    net_state_reset();
}

which will generate  CONFIG_SERVER_EVT_NODE_RESET event to reset the chip something that I can't have in my application.

I tried to call nrf_mesh_prov_listen_stop() but it always indicate invalid state.

uint32_t nrf_mesh_prov_listen_stop(nrf_mesh_prov_ctx_t * p_ctx)
{
    if (p_ctx == NULL)
    {
        return NRF_ERROR_NULL;
    }
    else if (p_ctx->state != NRF_MESH_PROV_STATE_WAIT_LINK)
    {
        return NRF_ERROR_INVALID_STATE;
    }

    prov_bearer_t * p_bearer;
    LIST_FOREACH(p_item, p_ctx->p_bearers)
    {
        p_bearer = PARENT_BY_FIELD_GET(prov_bearer_t, node, p_item);
        /* Try stopping listening on all available bearers. */
        (void) p_bearer->p_interface->listen_stop(p_bearer);
    }
    p_ctx->state = NRF_MESH_PROV_STATE_IDLE;

    return NRF_SUCCESS;
}


The only place where the state variable is set to NRF_MESH_PROV_STATE_WAIT_LINK is in the provisioner so I think stopping the prov listening mode with this function is not possible.

How can I achieve this with in a propre way ?

Thank you

/Chaabane

Parents Reply
  • Yes, I received some feedback. Could you please explain where in the code the mesh_stack_config_clear() generates a  CONFIG_SERVER_EVT_NODE_RESET event to reset the chip? This is what happens when you call a node reset from the config client:

    It should be possible for you to use this functionality, like shown below:

                /* Clear all the states to reset the node. */
                if (mesh_stack_is_device_provisioned())
                {
                    (void) proxy_stop();
                    mesh_stack_config_clear();
                    node_reset();
                }

Children
  • I received another reply. The behavior you are requesting is unfortunately not currently supported by the mesh sdk. The requirement to reset the chip is done by design. When the device is reset, the stack initialization code goes through a sequence of operations that initializes various internal modules & variables in the proper state, including initializing the flash area with the required metadata & loading the available information.

Related