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

Factory Reset function and erasing EnOcean switch data

I am trying to erase the EnOcean switch data without erasing the board. node_reset() function isn't erasing the EnOcean switch data after commissioning. 

I would like to know how to erase the switch data without erasing. 

Also, is there any function defined to perform a factory reset without erasing the board? 

I am investigating about a way to do a factory reset with buttons on the board.

Thank you.

  • By commisioning data do you mean the provisioning data?

    By commissioning data, I mean the data of the EnOcean switch which is restored even after resetting the node using the Button 4 on the board or resetting through the nRF Mesh app.

    My end goal would be to have a node free from provisioning data and EnOcean switch security materials when i do a node reset.

  • Hi

    I presented this issue to my colleagues, and while providing a patch for this, we found a bug that took some time to fix. There are two parts to patch/bug fix so follow these steps:

    1. In the enocean example's main.c file, call `app_flash_clear(&m_app_secmat_flash[0], sizeof(m_app_secmat_flash));` while handling the `
      EVT_NODE_RESET` in the config server's event handler, as shown below:
       
      --- a/examples/enocean_switch/src/main.c
      +++ b/examples/enocean_switch/src/main.c
      @@ -338,6 +338,8 @@ static void config_server_evt_cb(const config_server_evt_t * p_evt)
       {
           if (p_evt->type == CONFIG_SERVER_EVT_NODE_RESET)
           {
      +        /* Trigger clearing of application data and schedule node reset. */
      +        app_flash_clear(&m_app_secmat_flash[0], sizeof(m_app_secmat_flash));
               node_reset();
           }
       }
    2. Bug fix in `mesh_stack.c`, which will ensure that the application data is erased correctly.
      --- a/mesh/stack/src/mesh_stack.c
      +++ b/mesh/stack/src/mesh_stack.c
      @@ -203,7 +203,7 @@ bool mesh_stack_is_device_provisioned(void)
       #if PERSISTENT_STORAGE
       static void mesh_evt_handler(const nrf_mesh_evt_t * p_evt)
       {
      -    if (p_evt->type == NRF_MESH_EVT_FLASH_STABLE)
      +    if (flash_manager_is_stable() && p_evt->type == NRF_MESH_EVT_FLASH_STABLE)
           {
               device_reset();
           }
       }     
      -- 
      2.17.1.windows.2 

    Editing these two files accordingly should make the EnOcean switch node reset work properly.

    Best regards,

    Simon

Related