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

Adding Simple OnOff Model to Generic OnOff Server Example

Hello,

I'm using Mesh SDk4.0.0 and SD v7.0.1. I have tested the light switch client and server examples. 

Now I want to add some more models for additional functionality. I want to start with adding simple onOff model present in models\vendor\simple_on_off directory. But I could not find any documentation regarding the actual steps/process to achieve this. Can you guide me how to do that? 

I would also like to add simple message model for sending/receiving strings of data instead of 1/0. This will help me better expand the functionality. However, simple OnOff seems to be an easier point to start.

I have been reading how to create new model, it's a pretty good guide to get started with creating a model. But the guide doesn't describe how to integrate it into an app, or more favorably, how to create a new app from scratch and use this model, hence creating a base for a larger application.

  • There was error in initializing the model here:

    static void models_init_cb(void)
    {
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Initializing and adding models\n");
        //NOTE Only SimpleOnOffServer will be initialized. To use both models, constants in nrf_mesh_config.h should be adjusted to allow more models.
        //app_model_init();
    //    ERROR_CHECK(simple_on_off_server_init(&my_simple_onoff_server_0, APP_ONOFF_ELEMENT_INDEX)); //NOTE Added
    //    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "My Simple OnOff Model Handle: %d\n", my_simple_onoff_server_0.model_handle);
        ERROR_CHECK(simple_message_server_init(&my_simple_message_server_0, APP_ONOFF_ELEMENT_INDEX)); //NOTE Added
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "My Simple Message Model Handle: %d\n", my_simple_message_server_0.model_handle);
    }

    After this, I was able to receive data from provisioner/mobile app.

Related