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

the APP_ERROR in the simple message

I created a simple message mode based on the simple_on_off modle,when I debuged the codes in simple message client,I got an error(app_error),I never changed the codes for this.And there is no trouble when I debugged the simple_on_off modle.Could you tell me some efficacious methods for this problem?

<t: 0>, main.c, 487, ----- BLE Mesh Light Switch Client Demo -----
<t: 0>, nrf_mesh_sdk.c, 187, Initializing softdevice
<t: 0>, nrf_mesh_sdk.c, 122, Initializing SoftDevice...
<t: 2>, nrf_mesh_sdk.c, 131, Ram base: 0x200019C0
<t: 14>, nrf_mesh_sdk.c, 197, Initializing mesh stack
<t: 333>, nrf_mesh_sdk.c, 205, Enabling mesh stack
<t: 337>, main.c, 191, Setting up access layer and models
<t: 356>, nrf_mesh_sdk.c, 72, APP_ERROR: F:\nrf5_SDK_for_Mesh_v1.0.1_src\examples\light_switch\client\src\main.c:212 code 14

Thanks in advance.

Parents Reply Children
  • Maybe I know the reason of the error.the codes:

    ERROR_CHECK(simple_message_client_init(&m_clients[i], i));

    and the function is defined as :

    uint32_t simple_message_client_init(simple_message_client_t * p_client, uint16_t element_index)
    {
    if (p_client == NULL ||
    p_client->status_cb == NULL|| p_client->set_cb == NULL)
    {
    return NRF_ERROR_NULL;
    }

    access_model_add_params_t init_params;
    init_params.model_id.model_id = simple_message_CLIENT_MODEL_ID;
    init_params.model_id.company_id = ACCESS_COMPANY_ID_NORDIC;
    init_params.element_index = element_index;
    init_params.p_opcode_handlers = &m_opcode_handlers[0];
    init_params.opcode_count = sizeof(m_opcode_handlers) / sizeof(m_opcode_handlers[0]);
    init_params.p_args = p_client;
    init_params.publish_timeout_cb = NULL;
    return access_model_add(&init_params, &p_client->model_handle);
    }


    /** Forward declaration. */
    typedef struct __simple_message_client simple_message_client_t;

    but I don't understand the mean of the parameters in this function.Did the pointer means the number of the servers?when I debugged I just used one board as the client and there is no server, the error is theNRF_ERROR_NULL,but I don't know which parameter is NULL. 

    Could you help me?

    Thanks.

  • Most likely one of this was failed: 

    if (p_client == NULL ||
    p_client->status_cb == NULL|| p_client->set_cb == NULL)

     

    Have you check if all of the above are not NULL when you call the function ? 

  • Sorry to reply too late.I have checked it and it shows  the error happens because of set_cb == NULL.And the simple_message_set_cb_t is defined as: 


    typedef bool (*simple_message_set_cb_t)(const simple_message_client_t * p_self,nrf_mesh_address_t src,nrf_mesh_address_t dst, uint8_t *data, uint8_t length);

    /** Simple Message Client state structure. */
    struct __simple_message_client
    {

    /** Status callback called after status received from server. */
    simple_message_set_cb_t set_cb;

    };

    so I think it's a value of bool.In the function,I valued it as true:

    for (uint32_t i = 0; i < CLIENT_COUNT; ++i)
    {
    m_clients[i].set_cb = true;
    m_clients[i].status_cb = client_status_cb;
    ERROR_CHECK(simple_message_client_init(&m_clients[i], i));
    }

    the error is eliminated.I don't know whether it is correct and  I still don't understand the principle of it works.

  • It seems that you created your own "simple_message" model ? 

    Why do you want to add set_cb into the structure ? what's the difference between set_cb and status_cb ? 

    Do you know the use of those variant ? 

    The status_cb is used to assign it to the address of the function you want to call when you receive a status reply from the server. There is no point assigning set_cb = true. 

    You need to assign it value to the address of the function your want to call. If you don't have any use for it, remove it both in the declaration of the struct and in simple_message_client_init()

     

     

  • I created the model by following 

    https://devzone.nordicsemi.com/f/nordic-q-a/29836/send-and-receive-a-string-via-access-layer

    and the file is provided by an application engineer at Nordic as it said.I changed the simple_on_off_client.c to simple_message_client.c.so i can't find the value of set_cb and i'm confused about it.

Related