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

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

  • Hi, can you please explain to me how you did yo send packets of data from client to server?

    I would like to do the same. 

    Thank you

Related