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

Unprovisioning a device with power on off

Hi,

I tried to implement a unprovision method for provisioned devices such as light bulbs. By simply on off it several times. And saving state into flash. 

Currently I'm able to save boot count into flash and able to reload if from flash. But when I tried to unprovision a device I got following error,

<t:       9519>, app_error_weak.c,  108, Mesh assert at 0x0002A86E (:0)

following lines used to unprovision a device as used in Light Switch example..

if(m_nw_state.boot_count > 4)
    {
        m_nw_state.boot_count = 0;
        
        if (mesh_stack_is_device_provisioned())
            {
#if MESH_FEATURE_GATT_PROXY_ENABLED
                (void) proxy_stop();
#endif
                mesh_stack_config_clear();
                mesh_stack_device_reset();
                __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "BOOT RESET Happen\n");
            }
            else
            {
                __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "The device is unprovisioned. Resetting has no effect.\n");
            }

    }
    else
    {
        m_nw_state.boot_count = m_nw_state.boot_count + 1;
    }

    ERROR_CHECK(store_app_data());

And I got log result as below

<t:          0>, main.c,  486, ----- BLE Mesh Light Switch Server Demo -----
<t:       8495>, main.c,  466, ----- inside mesh -----
<t:       9009>, main.c,  460, Initializing and adding models
<t:       9012>, main.c,  355, App OnOff Model Handle: 2
<t:       9049>, main.c,  160, -----inside flash manager -----
<t:       9052>, main.c,  170, -----flash usage -----
<t:       9057>, main.c,  235, -----add flash manager -----
<t:       9061>, main.c,  238, -----load flash manager -----
<t:       9064>, main.c,  253, Restored: App data
<t:       9066>, main.c,  254, Last Red : 0 
<t:       9068>, main.c,  255, Last Green : 0 
<t:       9070>, main.c,  256, Last Blue : 0 
<t:       9073>, main.c,  257, Boot Count : 1 
<t:       9076>, main.c,  533, Device UUID : 005955AA00000000E5F8D4197B5E9BA2
<t:       9625>, main.c,  128, Flash write complete
<t:          0>, main.c,  486, ----- BLE Mesh Light Switch Server Demo -----
<t:       8495>, main.c,  466, ----- inside mesh -----
<t:       9015>, main.c,  460, Initializing and adding models
<t:       9018>, main.c,  355, App OnOff Model Handle: 2
<t:       9056>, main.c,  160, -----inside flash manager -----
<t:       9059>, main.c,  170, -----flash usage -----
<t:       9065>, main.c,  235, -----add flash manager -----
<t:       9068>, main.c,  238, -----load flash manager -----
<t:       9071>, main.c,  253, Restored: App data
<t:       9073>, main.c,  254, Last Red : 0 
<t:       9075>, main.c,  255, Last Green : 0 
<t:       9077>, main.c,  256, Last Blue : 0 
<t:       9079>, main.c,  257, Boot Count : 2 
<t:       9083>, main.c,  533, Device UUID : 005955AA00000000E5F8D4197B5E9BA2
<t:       9637>, main.c,  128, Flash write complete
<t:          0>, main.c,  486, ----- BLE Mesh Light Switch Server Demo -----
<t:       8495>, main.c,  466, ----- inside mesh -----
<t:       9027>, main.c,  460, Initializing and adding models
<t:       9030>, main.c,  355, App OnOff Model Handle: 2
<t:       9068>, main.c,  160, -----inside flash manager -----
<t:       9071>, main.c,  170, -----flash usage -----
<t:       9077>, main.c,  235, -----add flash manager -----
<t:       9081>, main.c,  238, -----load flash manager -----
<t:       9083>, main.c,  253, Restored: App data
<t:       9085>, main.c,  254, Last Red : 0 
<t:       9088>, main.c,  255, Last Green : 0 
<t:       9090>, main.c,  256, Last Blue : 0 
<t:       9092>, main.c,  257, Boot Count : 3 
<t:       9095>, main.c,  533, Device UUID : 005955AA00000000E5F8D4197B5E9BA2
<t:       9634>, main.c,  128, Flash write complete
<t:          0>, main.c,  486, ----- BLE Mesh Light Switch Server Demo -----
<t:       8495>, main.c,  466, ----- inside mesh -----
<t:       9037>, main.c,  460, Initializing and adding models
<t:       9040>, main.c,  355, App OnOff Model Handle: 2
<t:       9078>, main.c,  160, -----inside flash manager -----
<t:       9081>, main.c,  170, -----flash usage -----
<t:       9086>, main.c,  235, -----add flash manager -----
<t:       9090>, main.c,  238, -----load flash manager -----
<t:       9093>, main.c,  253, Restored: App data
<t:       9095>, main.c,  254, Last Red : 0 
<t:       9097>, main.c,  255, Last Green : 0 
<t:       9099>, main.c,  256, Last Blue : 0 
<t:       9101>, main.c,  257, Boot Count : 4 
<t:       9105>, main.c,  533, Device UUID : 005955AA00000000E5F8D4197B5E9BA2
<t:       9614>, main.c,  128, Flash write complete
<t:          0>, main.c,  486, ----- BLE Mesh Light Switch Server Demo -----
<t:       8495>, main.c,  466, ----- inside mesh -----
<t:       9020>, main.c,  460, Initializing and adding models
<t:       9023>, main.c,  355, App OnOff Model Handle: 2
<t:       9061>, main.c,  160, -----inside flash manager -----
<t:       9064>, main.c,  170, -----flash usage -----
<t:       9070>, main.c,  235, -----add flash manager -----
<t:       9074>, main.c,  238, -----load flash manager -----
<t:       9076>, main.c,  253, Restored: App data
<t:       9078>, main.c,  254, Last Red : 0 
<t:       9080>, main.c,  255, Last Green : 0 
<t:       9083>, main.c,  256, Last Blue : 0 
<t:       9085>, main.c,  257, Boot Count : 5 
<t:       9088>, main.c,  533, Device UUID : 005955AA00000000E5F8D4197B5E9BA2
<t:       9519>, app_error_weak.c,  108, Mesh assert at 0x0002A86E (:0)

Is the unprovision method that I used have issues?

Thank you

Related