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

Receiving simple message mesh

Hi, 

I followed this thread (Link) to implement a simple message model on the light switch example from nRF SDK for Mesh v1.0.1. I created a "send_simple_message" function with all the given code that i call in a function called when a button is pushed on the client.

It seems the message is sent since i receive a "0" status after "access_model_publish". From the server, the led still change its state when i push the button; but i don't know how to read the message (and how to receive it).

Do i have to use the "simple_message_init" function and the others functions defined in the model, how to and when ?
Has somebody implemented the simple message model and could help me?

Thanks.

  • Thanks Damien for your valuable reply,

    I have already use "simple_message_server_init" in configuration setup function and as per told i use LOG_LEVEL_DBG1 for print incoming message. But unable to print please can you provide me your files as mentioned you at last line please.

    Thanks..

  • Have you done the "simple_message_client_init" too ?

    This line in access.c (mesh_msg_handle function) prints in the terminal all the message you receive on the server:
        "__LOG(LOG_SRC_ACCESS, LOG_LEVEL_DBG1, "RX: [aop: 0x%04x]\n", opcode.opcode);"
    So if you see the correct opcode, it means you receive it. You can print it there like this:

     if (opcode.opcode == 0x00D1)
    {
        __LOG(LOG_SRC_ACCESS, LOG_LEVEL_DBG1, "My message received ! \n");      
        __LOG(LOG_SRC_ACCESS, LOG_LEVEL_DBG1, "Message: %c%c%c%c%c \n", message.p_data[0], message.p_data[1], message.p_data[2], message.p_data[3], message.p_data[4]);  
    }

    Then the message is forwarded to the handle_incoming function. There you need to have initialized the server and the client to be able to reach this line:

    "p_model->p_opcode_handlers[opcode_index].handler(i, p_message, p_model->p_args);"

    It call the right handler corresponding to the message if you have done the model configuration using:

     /* Bind the keys to the message client. */
    ERROR_CHECK(access_model_application_bind(m_message_client.model_handle, m_appkey_handle));
    ERROR_CHECK(access_model_publish_application_set(m_message_client.model_handle, m_appkey_handle));
    

    and you have to modify the provisioner.c file to add your new model.
    Could you tell me where your message is stuck  ? 

  • Hi Damien,

    My message see in access.c mesh_msg_handle function but i have see only first char which is 'H'other is not able to see. After that i am trying to print same incoming message on server in main.c file. Can you tell for achieve this how i can init handle_incoming  function in main.c and print incoming message. 

    As per you told me you can check opcode but in server main.c file not able to access opcode variable from access.c file. Could you please tell me how i can verify and print complete incoming message  in main.c file on server side.

    Thanks a lots for helping me...

  • can you please provide code for same?? after make some changes as suggested in above links i am getting error

  • hi,

    how would you define address_set function? like this?

    void address_set(uint16_t addr)
    {
    ERROR_CHECK(dsm_address_publish_add(addr, &m_central_handle));
    ERROR_CHECK(access_model_publish_address_set(m_server.model_handle, m_central_handle));
    }

    if yes then how do u define m_server?? how do you create an instance?

Related