Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Getting status messages from Mesh to Phone

Hi I'd like to know how to get status messages into Mesh Proxy Data out. I have a Light Switch Server, and a Light Switch Client. They publish/subscribe to each other, and I've set up a timer to call app_onoff_status_publish every 1 second. I get the Present OnOff value and the source address in each status publish message and it is printed in the logs for the Client every second.

I'd like to know how I can put the present OnOff value and source address into Mesh Proxy Data Out (0x2ADE) on the Client.

I have a Proxy Client that connects to the Light Switch Client, acting as a Proxy Server. I am able to enable notifications on 0x2ADE, Proxy Data Out, but nothing is being written to 0x2ADE. I would like for the present on off value and src address in a status message to be written to 0x2ADE every time the Light Switch Client receives a status publish message.

Parents
  • This should already be partially done in the mesh sdk FW. If you have an Android phone, you can update to the latest nRF Mesh app & you should be able to ask for the current LED status in the app. If you then run a debugging session, you should be able to see which function sends the status message from the mesh SDK to the smartphone app.

    If you have the iOS nRF Mesh app, this has not been implemented yet. However, you are still able to set the status of the LED. Take a look at the following lines in the proxy.c function in the latest mesh sdk for hints on where this functionality is implemented:

    <t:    1932865>, proxy.c,  619, TX complete
    <t:    7992254>, proxy.c,  611, RX
    <t:    7992260>, proxy.c,  553, RX GATT PDU type 0x0, len 24
    <t:    7992269>, access.c,  268, p_evt->dst.value: 0x0003
    <t:    7992272>, generic_onoff_server.c,  136, Server: transition_time_ms = 0
    <t:    7992275>, generic_onoff_server.c,  137, Server: delay_ms = 0
    <t:    7992278>, app_onoff.c,  204, msg: SET: 0
    <t:    7992280>, main.c,   96, Setting GPIO value: 0
    <t:    7994215>, proxy.c,  619, TX complete
    <t:    8177064>, proxy.c,  611, RX
    <t:    8177070>, proxy.c,  553, RX GATT PDU type 0x0, len 24
    <t:    8177079>, access.c,  268, p_evt->dst.value: 0x0003
    <t:    8177082>, generic_onoff_server.c,  136, Server: transition_time_ms = 0
    <t:    8177085>, generic_onoff_server.c,  137, Server: delay_ms = 0
    <t:    8177088>, app_onoff.c,  204, msg: SET: 1
    <t:    8177090>, main.c,   96, Setting GPIO value: 1
    <t:    8179025>, proxy.c,  619, TX complete

Reply
  • This should already be partially done in the mesh sdk FW. If you have an Android phone, you can update to the latest nRF Mesh app & you should be able to ask for the current LED status in the app. If you then run a debugging session, you should be able to see which function sends the status message from the mesh SDK to the smartphone app.

    If you have the iOS nRF Mesh app, this has not been implemented yet. However, you are still able to set the status of the LED. Take a look at the following lines in the proxy.c function in the latest mesh sdk for hints on where this functionality is implemented:

    <t:    1932865>, proxy.c,  619, TX complete
    <t:    7992254>, proxy.c,  611, RX
    <t:    7992260>, proxy.c,  553, RX GATT PDU type 0x0, len 24
    <t:    7992269>, access.c,  268, p_evt->dst.value: 0x0003
    <t:    7992272>, generic_onoff_server.c,  136, Server: transition_time_ms = 0
    <t:    7992275>, generic_onoff_server.c,  137, Server: delay_ms = 0
    <t:    7992278>, app_onoff.c,  204, msg: SET: 0
    <t:    7992280>, main.c,   96, Setting GPIO value: 0
    <t:    7994215>, proxy.c,  619, TX complete
    <t:    8177064>, proxy.c,  611, RX
    <t:    8177070>, proxy.c,  553, RX GATT PDU type 0x0, len 24
    <t:    8177079>, access.c,  268, p_evt->dst.value: 0x0003
    <t:    8177082>, generic_onoff_server.c,  136, Server: transition_time_ms = 0
    <t:    8177085>, generic_onoff_server.c,  137, Server: delay_ms = 0
    <t:    8177088>, app_onoff.c,  204, msg: SET: 1
    <t:    8177090>, main.c,   96, Setting GPIO value: 1
    <t:    8179025>, proxy.c,  619, TX complete

Children
  • Yes I've sent status publish messages using generic_onoff_status__publish() on a timer once every second from the light_switch_server to the light_switch_client, the issue was not with sending the status messages. The issue was with receiving the status message on the client and doing something other than printing the data out.

    In the app_onoff_status_publish_cb, the callback handler for when status messages are received (i.e. what the client does with status messages), you guys simply __LOG() the present on off value. I wanted to take that value, and programmatically write it to Mesh Proxy Data Out.

  • Sorry if I did not explain myself clearly enough. I agree with you that if you send a get message or an acknowledged set message from the client to the server, then the server will send a status message back the client.

    However, if you send a get message from the nRF Mesh phone app, then, the client or server responds with a status message to the phone app. You can see that:

    #define PROXY_UUID_CHAR_TX 0x2ade
    #define PROXY_UUID_CHAR_RX 0x2add

    has been added to proxy.c (I am looking at mesh sdk v3.1.0, but it should be similar in previous mesh sdks).

    I am not exactly sure which function sends the status message from the proxy to the PROXY_UUID_CHAR_TX, but my bet is on the gatt_evt_handler. The case MESH_GATT_EVT_TYPE_TX_COMPLETE should also be relevant I believe.

  • That's okay Bjorn I was able to figure it out. I remembered using sd_ble_gatts_value_set() to programmatically write to a characteristic a few months ago. I was able to slightly modify an existing function, renaming it mesh_gatt_value_update(), which used sd_ble_gatts_value_set().

    By adding mesh_gatt_value_update to mesh_gatt.h and mesh_gatt.c, the function would have access to m_gatt, which has the 0x2ADE characteristic. 

    Then I was able to call mesh_gatt_value_update in main.c by including mesh_gatt.h at the top of main.c. I call mesh_gatt_value_update inside of app_onoff_status_publish_cb, which takes the incoming status message and prints it (Nordic's code) but then also sends the src address and payload to mesh_gatt_value_update, which passes it to sd_ble_gatts_value_set.

    It is working now, and anytime the servers publish status messages, they end up in 0x2ADE on the proxy node, where I can read them through notifications in my cross platform mobile application.

  • With your code are you able to send a msg to a phone after relaying it?

    I mean, mesh_node --> mesh_proxy_node ---> phone

    Could you post the code you made with the changes you made to get it working?

    Thanks!

Related