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.

Parents
  • Hi,

    If you take a look at the mesh light switch example in the mesh sdk v1.0.1 inside the main.c file, you can see the nrf_mesh_node_config() function call at the bottom of the int main(void) function. Going to the definition of the nrf_mesh_node_config() file, the access layer gets initialized inside the access_init() function. Inside the access_init() function, there is a line: 

    m_evt_handler.evt_cb = mesh_evt_cb;

    Going to the definition of mesh_evt_cb, you can see that whenever the NRF_MESH_EVT_MESSAGE_RECEIVED event occurs, the mesh_msg_handle() function gets called. It seems that this mesh_msg_handle() function, which is defined in access.c, handles the incoming mesh messages on the server side. This is defined similarly on the client side too (can be checked by looking at the client mesh example). The mesh simple model is given in the link you provided, so that should work correctly.

    What exactly is not working in the link you provided. Is it the provisioning or is it something else?

     

     

  • I am still stuck on this, Could you help me with this issue ? 

  • Sorry about that. This case did not show up in my list of unanswered cases unfortunately. The handle_incoming() function takes the message sent across the access layer & then handles the message depending on whether the mesh address is of type unicast or if it's a subscription address. I am also a bit unsure about the handle_incoming() function, but I have asked the mesh team that developed the sdk for help. I will update this comment as soon as I get a response from them.

  • Thank you, i understood how it works and i am now able to send and receive a simple message. I did not do the initializations, now it works and i am able to read the message in my server "main". Now i am trying to reverse the role, i suppose i have to implement a "simple message server" on the device that is actually the "simple message client" in order to be able to handle the incoming message correctly. Thanks for the help, i will come back if i face new issues.

Reply Children
  • Hi Damien,

    I have still the same problem i send hello message from client and unable to read and print hello string on server side. can you please help me for the same. Where should i need to write code for print incoming message and change in server main file. Can please share your server main.c file with me.

    Any help most appreciate for me...!

    Thanks.

  • You have to use the "simple_message_server_init" defined in "simple_message_server.h" and the "access_model_subscription_list_alloc" as for the simple_on_off_server.
    You should use the "LOG_LEVEL_DBG1" in order to see the opcodes received and sent:    "__LOG_INIT(LOG_SRC_APP | LOG_SRC_ACCESS, LOG_LEVEL_DBG1, LOG_CALLBACK_DEFAULT);"
    If you receive the correct opcode on the server but the message is not handled, you should observe step by step the "handle_incoming" function in access.c

    Tomorrow i will see if i can send you my files.

  • 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  ? 

Related