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 ? 

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

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

Children
  • 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...

Related