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

generic_ponoff_setup_server doesn't handle subscription lists properly

Hi,

I've added an instance of the Generic Power OnOff Setup Server to an element and I can see it and all the models that it extends, i.e. (Power OnOff Server, DTT Server, OnOff Server), using the nRF Mesh app. If I add an address to one of these models subscription lists and restart the device it crashes on startup due to generic_ponoff_setup_server_init() returning 15 (NRF_ERROR_FORBIDDEN).

This is because all these models is part of a single extension tree and thus shares a single subscription list. The current way this is implemented is by a sequence of alloc/dealloc/share calls. In short this generates a sequence of calls

access_model_subscription_list_alloc(dtt)
access_model_subscription_list_dealloc(dtt)

access_model_subscription_list_alloc(onoff)
access_model_subscription_list_dealloc(onoff)

access_model_subscription_list_alloc(ponoff setup)
access_model_subscription_lists_share(ponoff)
access_model_subscription_lists_share(onoff)
access_model_subscription_lists_share(dtt)

In the end all models will share a single subscription list index.

The error (NRF_ERROR_FORBIDDEN) is returned by the first dealloc() call because subscription_list_is_stored() returned true, i.e. the subscription list index is stored in flash and thus can't be de-allocated.

So the current way the models are implemented doesn't work with the way the access layer handles the subscription lists.

I'm using SDK For Mesh v3.1.0 and calling the init function from the models.models_init_cb given to mesh_stack_init().

Related