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

Mesh SDK light switch example combining client and server

Hi All:

We are using nRF52840 SDK with BLE Mesh sdk5.0 to develop bluetooth mesh and we can use light_sw_client to control the LED1 state on the light_sw_sever via BLE Mesh APP and   nRF52840_DK.

Now we hope to integrated the ight_sw_client and  light_sw_sever to implement bi-direction data transfer between two nRF52840_DK.

The integrated light_sw client and server can be compliled successfully,but executing the mesh_stack_init function has a error message( Mesh error 5 at 0x00027B49) from the function of "ERROR_CHECK(generic_onoff_client_init(&m_clients[i], i + 1))".

How to debug the issue? Thanks a lot.

/***************************************************************************

static void mesh_init(void)
{
/* Initialize the application storage for models */
model_config_file_init();

mesh_stack_init_params_t init_params =Post
{
.core.irq_priority = NRF_MESH_IRQ_PRIORITY_LOWEST,
.core.lfclksrc = DEV_BOARD_LF_CLK_CFG,
.core.p_uuid = NULL,
.models.models_init_cb = models_init_cb,
.models.config_server_cb = config_server_evt_cb
};

uint32_t status = mesh_stack_init(&init_params, &m_device_provisioned);

*************************************************************************************/

static void models_init_cb(void)
{
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Initializing and adding models\n");
app_model_init();

// ..... adding client models ....
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Initializing and adding client models\n");

for (uint32_t i = 0; i < CLIENT_MODEL_INSTANCE_COUNT; ++i)
{
m_clients[i].settings.p_callbacks = &client_cbs;
m_clients[i].settings.timeout = 0;
m_clients[i].settings.force_segmented = APP_FORCE_SEGMENTATION;
m_clients[i].settings.transmic_size = APP_MIC_SIZE;

ERROR_CHECK(generic_onoff_client_init(&m_clients[i], i + 1));
}

Best Regards,

Sheng-Hua

Parents
  • Hi,

    Getting Mesh error 5 (NRF_ERROR_NOT_FOUND) from generic_onoff_client_init() function means invalid access element index. Can you check that the element index is correct?

  • Hi,

    Just to clarify, you want two client models on the same node?

    I suspect that not enough elements have been added to the node so when you try to initiate the model in the inputted element index it will return invalid element index. Can you check that you also have added the correct amount of elements to the node?

    Note that if you want multiple instances of the same model, these instances cannot be in the same element and a separate element is needed for each new instance of the same model.

  • DeaMttrinh:

    It is right.
    we hope add two client models into sever model to implement a control model on the same node.
    After adding enough elements to the node in the "nrf_mesh_conf_app.h", we can the "run mesh_init()" function successfully.
    The "nrf_mesh_conf_app.h" was modified as the following.
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //#define ACCESS_MODEL_COUNT (/* Element 0:                                       */ \
    //                            1 + /* Config Server                                */ \
    //                            1 + /* Health Server                                */ \
    //                            1 + /* Generic OnOff Server                         */ \
    //                            1 + /* Default Transition Time Server               */ \
    //                            1 + /* Scene Server                                 */ \
    //                            1   /* Scene Setup Server (extends Scene Server)    */)

    #if 1
    //2021.0916  .....add Generic OnOff client model ......
    #define ACCESS_MODEL_COUNT (/* Element 0:                                       */ \
                                1 + /* Config Server                                */ \
                                1 + /* Health Server                                */ \
                                1 + /* Generic OnOff Server                         */ \
                                1 + /* Default Transition Time Server               */ \
                                1 + /* Scene Server                                 */ \
                                1 +  /* Scene Setup Server (extends Scene Server)   */ \
                                2   /* Generic OnOff client (2 groups) */)

    #endif
    /**
     * The number of elements in the application.
     *
     * @warning If the application is to support _multiple instances_ of the _same_ model, these instances
     * cannot be in the same element and a separate element is needed for each new instance of the same model.
     */
    //2021.0916 ......update element count .....
    //#define ACCESS_ELEMENT_COUNT (1)
    #define ACCESS_ELEMENT_COUNT (3)

    //#define ACCESS_ELEMENT_COUNT (1 + CLIENT_MODEL_INSTANCE_COUNT) /* One element per Generic OnOff client instance */
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    Then we ran the "BLE Mesh APP" to add a node in the cell phone and found the elements of "Generic_on_off_client" had been add into the node as below.
    Best Regards,
    Sheng-Hua
Reply
  • DeaMttrinh:

    It is right.
    we hope add two client models into sever model to implement a control model on the same node.
    After adding enough elements to the node in the "nrf_mesh_conf_app.h", we can the "run mesh_init()" function successfully.
    The "nrf_mesh_conf_app.h" was modified as the following.
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //#define ACCESS_MODEL_COUNT (/* Element 0:                                       */ \
    //                            1 + /* Config Server                                */ \
    //                            1 + /* Health Server                                */ \
    //                            1 + /* Generic OnOff Server                         */ \
    //                            1 + /* Default Transition Time Server               */ \
    //                            1 + /* Scene Server                                 */ \
    //                            1   /* Scene Setup Server (extends Scene Server)    */)

    #if 1
    //2021.0916  .....add Generic OnOff client model ......
    #define ACCESS_MODEL_COUNT (/* Element 0:                                       */ \
                                1 + /* Config Server                                */ \
                                1 + /* Health Server                                */ \
                                1 + /* Generic OnOff Server                         */ \
                                1 + /* Default Transition Time Server               */ \
                                1 + /* Scene Server                                 */ \
                                1 +  /* Scene Setup Server (extends Scene Server)   */ \
                                2   /* Generic OnOff client (2 groups) */)

    #endif
    /**
     * The number of elements in the application.
     *
     * @warning If the application is to support _multiple instances_ of the _same_ model, these instances
     * cannot be in the same element and a separate element is needed for each new instance of the same model.
     */
    //2021.0916 ......update element count .....
    //#define ACCESS_ELEMENT_COUNT (1)
    #define ACCESS_ELEMENT_COUNT (3)

    //#define ACCESS_ELEMENT_COUNT (1 + CLIENT_MODEL_INSTANCE_COUNT) /* One element per Generic OnOff client instance */
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    Then we ran the "BLE Mesh APP" to add a node in the cell phone and found the elements of "Generic_on_off_client" had been add into the node as below.
    Best Regards,
    Sheng-Hua
Children
No Data
Related