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

Proxy Server Publish Issue

Based on Mesh SDK 2.1.1.

I use light switch proxy client & proxy server to test server publish function.

But when I use the phone setting network, I found that the client's publish & subscribe settings, the server's publish function can be used correctly.

If the client only sets subscribe and doesn't set publish,the server's publish function can't be used.

Can I set the client's subscribe and server's publish separately to use the publish function?

client set publish & subscribeclient only set subscribe

left figure : client set publish & subscribe

right figure : client only set subscribe

Server set publish

figure : server set publish

Parents Reply Children
  • I am pretty sure the reason that left figure + figure works is because the client publishes to the unicast address of the simple on off server (0x0004). Then, you are able to send status updates from the server to the client. Could you test & just try to make the client publishes to the simple on off server address? Please test without publishing & subscribing to the group addresses 0xC100 & 0xC200. Does that procedure work?

  • Why U say test & try to make client publish to the server address?

    I have already test client publish to the unicast address of the server node,and client publish to the group address of the server node,too.

    But, I want server publish to the client.

  • QK-Huang said:
    Why U say test & try to make client publish to the server address?

     Because I thought you just wanted to send a status message from the server back to the client.

    The reason the publishing from the server to the group address 0xC100 & subscribing to the group address from the client does not work is two-fold: firstly, when you press button 1 on the server, you are calling this code:

    static void button_event_handler(uint32_t button_number)
    {
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Button %u pressed\n", button_number);
        switch (button_number)
        {
            /* Pressing SW1 on the Development Kit will result in LED state to toggle and trigger
            the STATUS message to inform client about the state change. This is a demonstration of
            state change publication due to local event. */
            case 0:
            {
                uint8_t value = !hal_led_pin_get(LED_PIN_NUMBER);
                __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "User action \n");
                hal_led_pin_set(LED_PIN_NUMBER, value);
                (void)simple_on_off_server_status_publish(&m_server, value);
                break;
            }

    This code is only setting a server status publish, aka a status message. I am not exactly sure on this, but I believe a status message can only be sent to a unicast address. I believe the reason your scenario one worked to send the status message back to the client from the server was because the client was publishing directly to the unicast address of the server.

    In order to publish from the server to a group address & let the client subscribe to this group address, you will need to add the simple on off server model to the client & add the simple on off client model to the server. That way, both boards will act as both clients & servers.

    You can do something similar to what has been done here. I would not recommend you to use that source code directly, as it has not been tested as extensively as the mesh sdk.

    Also, if you notice that you are having issues with provisioning & configuring nodes via nRF Mesh, I would suggest you to migrate from mesh sdk v2.1.1 to mesh sdk v2.2.0. This version has more stable support for nRF Mesh. I would also make sure that you are using the latest version of nRF Mesh. We do have a migration guide here if you decide to download the mesh sdk v2.2.0 here: nrf5_SDK_for_Mesh_v2.2.0_src\doc\migration\

  • Tanks your answer. I have a question.

    In simple_on_off_client.c 

    uint32_t simple_on_off_client_set_unreliable(simple_on_off_client_t * p_client, bool on_off, uint8_t repeats)
    {
        simple_on_off_msg_set_unreliable_t set_unreliable;
        set_unreliable.on_off = on_off ? 1 : 0;
        set_unreliable.tid = m_tid++;
    
        access_message_tx_t message;
        message.opcode.opcode = SIMPLE_ON_OFF_OPCODE_SET_UNRELIABLE;
        message.opcode.company_id = SIMPLE_ON_OFF_COMPANY_ID;
        message.p_buffer = (const uint8_t*) &set_unreliable;
        message.length = sizeof(set_unreliable);
        message.force_segmented = false;
        message.transmic_size = NRF_MESH_TRANSMIC_SIZE_DEFAULT;
    
        uint32_t status = NRF_SUCCESS;
        for (uint8_t i = 0; i < repeats; ++i)
        {
            message.access_token = nrf_mesh_unique_token_get();
            status = access_model_publish(p_client->model_handle, &message);
            if (status != NRF_SUCCESS)
            {
                break;
            }
        }
        return status;
    }

    this function use access_model_publish() to publish data to the server.

    In simple_on_off_server.c

    uint32_t simple_on_off_server_status_publish(simple_on_off_server_t * p_server, bool value)
    {
        simple_on_off_msg_status_t status;
        status.present_on_off = value ? 1 : 0;
        access_message_tx_t msg;
        msg.opcode.opcode = SIMPLE_ON_OFF_OPCODE_STATUS;
        msg.opcode.company_id = SIMPLE_ON_OFF_COMPANY_ID;
        msg.p_buffer = (const uint8_t *) &status;
        msg.length = sizeof(status);
        msg.force_segmented = false;
        msg.transmic_size = NRF_MESH_TRANSMIC_SIZE_DEFAULT;
        msg.access_token = nrf_mesh_unique_token_get();
        return access_model_publish(p_server->model_handle, &msg);
    }
    

    this function also use access_model_publish() to publish data to the client.

    Both function are use access_model_publish(). Why the  former can publish unicast or group address, the latter only publish unicast address?

    What is the difference between the two function?

  • You are correct. From reading the mesh spec, it does seem that you are able to publish a status message to a group address:

    However, the way the generic on off server model on the server is configured, it will send the status message back to the client.

    The main difference between the two functions is that the client generic on off model sends a set message, whereas the server generic on off model sends a status message.

Related