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

sending message from client to specific server

Hi All, 

I am using the light switch example and have modified it a bit to send packets of data. 
I am able to send data from the client to group address, by setting the publication address of the client to 0xCAFE (using the nrf mesh app)and the message is recieved by the servers.
But if i set the publication address of the client to the unicast address of one of my servers (0x0001), I am not receiving any message.

Please advice if this is the correct way to send message to only one server?

Thanks, 

Nishant

Parents
  • How do you provision your devices? Try to use the nRF Mesh app for mobile, and set the clien't publish adress equal to the address of the nRF5x Mesh Light (in the screenshots below, that would be 0001, but it may vary depending on what order you provision the devices).

    So, try to flash both devices with their respective examples. Then provision both. Enter the "nRF5x Mesh Light", and set the subscription address to a group address, e.g. C001. Then go to the "nRF5x Mesh Switch", and set the first generic OnOff Client to publish to this address, C001. Check that this works first. You should be able to press button 0 and 1 (1 and 2) on the DK of the Client to turn on and off the LED on the server. If that works, then try to set the second "Generic OnOff Client" to publish to "nRF5x Mesh Light"s unicast address (0001 in the screenshot). Does that work?

  • I have tried something very similar to this. 

    Using my modified version. I provision the client using nRFMesh, I then provision the server. 
    Using nRFMesh, I set app keys on both client and server, and I set the publication address on the client to 0x0002. I try to send a message accross, it is not recieved.

    I then set the publication address on the client to 0xCAFE, and set teh subscription address on the server to 0xCAFE the server is then able to recieve messages from the client. 

Reply
  • I have tried something very similar to this. 

    Using my modified version. I provision the client using nRFMesh, I then provision the server. 
    Using nRFMesh, I set app keys on both client and server, and I set the publication address on the client to 0x0002. I try to send a message accross, it is not recieved.

    I then set the publication address on the client to 0xCAFE, and set teh subscription address on the server to 0xCAFE the server is then able to recieve messages from the client. 

Children
  • Edvin said:
    Does it work if you use the unmodified light_switch examples (server + client)? I tested it here, and it seems to work, so I just want to check if the issue is related to the publication/subscription setup or the model setup.

     It should work, but it would be nice to know whether the problem is related to your implementation or the way that you set up the configuration. This is why I would like you to test on the unmodified light switch example. You can just unzip an unmodified version of the SDK for mesh to test this.

  • Hi Edvin, I apologies, I am using the simple on off model  and not the generic on off model .
    I have modified the simple on off to my needs as i do not have a demo dev board that is typically used with examples. . I do not have the dev boards , I have my own custom board with only UART lines connected to the host MCU. 

    Client --> server I am able to send a message to all servers using a broadcast address 0xcafe, 
    Server --> client, i am able to use the client address to send a message directly to either one of two clients, and I am able to send a message to 2 clients using the broadcast address 0xcafe

    The only thing i cant do is send a message directly from client to specific server. 

    I am using the folowing function to send from client to server:

    uint32_t nsMeshModel_clientSendPacket_unreliable(nsMeshClient * p_client, const uint8_t *buff, uint16_t bufflen, uint8_t repeats)
    {
    simple_on_off_msg_set_unreliable_t set_unreliable;
    set_unreliable.tid = m_tid++;
    memcpy(set_unreliable.data, buff, bufflen);

    access_message_tx_t message;
    message.opcode.opcode = NS_MESH_MODEL_OPCODE_SERVER_RECIEVE_DATA_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;
    }

    Im not sure why the server is able to receive messages only when the client publication address is set to 0xcafe and teh server subscribes to teh address 0xcafe. 

    I am using the nRFmesh app to configure the publication/subscription setup

  • What address are you trying to send to when you send directly to a server, then, and why do you expect it to pick it up? Is it another address which it has subscribed to, or is it the unicast address of that node?

    Again, if you have changed something in the model I want to ask you to try the unmodified on_off model from the example. It is basically impossible for me to say what's wrong if you may have changed anything in the SDK.

  • Client Unicast address = 0x0001
    Server unicast address = 0x0002
    broadcast address = 0xcafe

    Client to servers setups:
    server subscribes to address = 0xcafe
    client publication address = 0xcafe
    in this setup the server receives messages

    server subscribes to address = 0xcafe
    client publication address = 0x0002 (unicast address of server)
    in this setup, the server does not receive any message. 

    I apologies, I do not have dev boards, therefor I cannot test the light switch example that uses the Generic on off model.

    I have implemented the simple_on_off model.
    I am expecting the server to pick it up, because I know it picks up when  the client publication address is the same as the broadcast address the server subscribes too. 

    Also if i send message from server to client with the following setup, it works:

    server publication address = 0x0001

    Client does not subscribe to any address, but it receives because the server is publishing to the unicast address of the  client.

    The code snippet above is unmodified from the simple_on_off model provided, and that is the function I am using to send data (regardless of whether it is sent to a unicast or broadcast address).  I dont believe I have modified anything in the SDK.

     

  • Can I see some screenshots from your phone when you provision your devices? Are you sure the server has a unicast address of 0x0002?

    Again, I know that you don't run it on DKs, but you have obviously ported this project to support your HW. Can you try to run the light switch server and client on your HW? Please?

    The challenge here is that I don't know whether the issue is related to your provisioning or your project. If we use a project that we know is working, then we can rule out the provisioning. But maybe you can send some screenshots from your provisioning?

Related