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

sending ASCII bytes through Mesh between a nrf52840 development kit and two dongle

Hello everyone,

I am new and tried some example on the nrf52840 devkit and dongle, including light switch example. 

I am now going to send some ASCII bytes through the mesh between three boards and receive a verification message in the client side.

Actually I thought this is done by adding  sent and receive functions in the switch light example (server and client) inside the main.c. But after searching the devzone I was completely confused.

I read these discussions but I could not modify the code correctly.

https://devzone.nordicsemi.com/f/nordic-q-a/29836/send-and-receive-a-string-via-access-layer

https://devzone.nordicsemi.com/f/nordic-q-a/31256/receiving-simple-message-mesh/123576

https://devzone.nordicsemi.com/f/nordic-q-a/39629/how-to-send-data-to-all-node-over-mesh

https://devzone.nordicsemi.com/f/nordic-q-a/47611/sending-data-over-the-mesh-network

https://devzone.nordicsemi.com/f/nordic-q-a/46092/send-string-in-a-mesh-with-nrf52dk/

I have error on 

simple_message_OPCODE_SEND
and
the address_set function
and also in the server side:
status= access_model_publish(m_server.model_handle, &msg);

I think there are some different in the new version of the nRF52 SDK for mesh V.5 I used.

Could you please help me on this topic.

Thank you,

Sama

  • Hi,

    You don't need to make a new ticket for this, we can continue this here. I'm not sure what the issue is though

    Sama said:

    I added the send_my_message function in the button handler but it got stuck.

     What do you mean by stuck? Do you get any errors? Any log you can share?

    Sama said:
    Due to existing the generic_onoff model in this example, may it cause a conflict with the simple_onoff model?

    I don't think this will casue any problems. You can add multiple models in the same example.

    Sama said:
    In the access_model_publish_address_set function we assign an address for our model, right? how can I found if another model signed to this address or not? and is there any limitation to add models? 

    Yes, that function is for adding a publish address to a model. You can have multiple models sending to the same address. 

  • Hi,

    Thank you for your reply.

    Here it is two pictures of my debug:

    In this case, I add my function in the case of 1.3 buttons, 

    and in this case, I add my function in the case of 2.4 buttons, 

    and this is the log:

    <t: 0>, main.c, 439, ----- BLE Mesh Light Switch Client Demo -----
    <t: 12144>, main.c, 398, Initializing and adding models
    <t: 17040>, mesh_app_utils.c, 66, Device UUID (raw): 137FF47B11294702B381A62F60654E45
    <t: 17043>, mesh_app_utils.c, 67, Device UUID : 137FF47B-1129-4702-B381-A62F60654E45
    <t: 17056>, main.c, 486,
    ------------------------------------------------------------------------------------
    Button/RTT 1) Send a message to the odd group (address: 0xC003) to turn on LED 1.
    Button/RTT 2) Send a message to the odd group (address: 0xC003) to turn off LED 1.
    Button/RTT 3) Send a message to the even group (address: 0xC002) to turn on LED 1.
    Button/RTT 4) Send a message to the even group (address: 0xC002) to turn off LED 1.
    ------------------------------------------------------------------------------------
    <t: 97625>, main.c, 304, Button 1 pressed
    <t: 97627>, main.c, 329, Sending msg: ONOFF SET 1
    <t: 97630>, main.c, 374, Publication not configured for client 1
    <t: 350157>, main.c, 304, Button 1 pressed
    <t: 350159>, main.c, 329, Sending msg: ONOFF SET 1
    <t: 350162>, main.c, 374, Publication not configured for client 1
    <t: 398193>, main.c, 304, Button 2 pressed
    <t: 398195>, main.c, 145, ----- send_message -----
    Sending to group address 0xCAFE
    <t: 398206>, main.c, 157, Status : 7
    <t: 398208>, app_error_weak.c, 115, Mesh error 7 at 0x000279EF (D:\Behine Niroo\Nordic\NRF Mesh\nrf5_SDK_for_Mesh_v5.0.0_src\examples\light_switch - Copy\client\src\main.c:167)

    I wonder that the address_set function in server and client are different or not. Because in this case, it seems that they are alike.

    Furthermore, I am confused about the "m_clients" variable. This variable is defined in the Nordic's codes as:

    static generic_onoff_client_t m_clients[CLIENT_MODEL_INSTANCE_COUNT];

    Should I use this in my functions, e.g

    ERROR_CHECK(access_model_publish_address_set(m_clients[0].model_handle, m_central_handle));
    status= access_model_publish(m_clients[0].model_handle, &msg);

    or should I define another variable "m_client" as

    static simple_on_off_client_t m_client[CLIENT_MODEL_INSTANCE_COUNT];

    and use this in my functions?

    Please let me know as soon as possible.

    I look forward to hearing from you.

    Br,

    Sama

  • Hi,

    Update:

    When I provision and configure the devices, there are not simple messages or simple OnOff models.

    any idea?

    I look forward to hearing from you.

    Br,

    Sama

  • Sama said:

    or should I define another variable "m_client" as

    static simple_on_off_client_t m_client[CLIENT_MODEL_INSTANCE_COUNT];

    and use this in my functions?

    Yes, you should define another variable for m_client and use this in your functions. As this is for simpleOnOff while the other one is for GenericOnOff.

    The error that you get, Mesh error 7, corresponds to Invalid Parameter. In main on line 167, can you see which function is returning this error? Have you put in the correct parameter?

  • Hi,

    Thank you for your reply.

    I tested that again, and it seems that the error is related to the invalid status in ERROR_CHECK(status);

    Here is the log and line that returned the error.


    <t: 0>, main.c, 431, ----- BLE Mesh Light Switch Client Demo -----
    <t: 12585>, main.c, 390, Initializing and adding models
    <t: 17486>, mesh_app_utils.c, 66, Device UUID (raw): 137FF47B11294702B381A62F60654E45
    <t: 17489>, mesh_app_utils.c, 67, Device UUID : 137FF47B-1129-4702-B381-A62F60654E45
    <t: 17506>, main.c, 478,
    ------------------------------------------------------------------------------------
    Button/RTT 1) Send a message to the odd group (address: 0xC003) to turn on LED 1.
    Button/RTT 2) Send a message to the odd group (address: 0xC003) to turn off LED 1.
    Button/RTT 3) Send a message to the even group (address: 0xC002) to turn on LED 1.
    Button/RTT 4) Send a message to the even group (address: 0xC002) to turn off LED 1.
    ------------------------------------------------------------------------------------
    <t: 150901>, main.c, 297, Button 1 pressed
    <t: 150903>, main.c, 139, ----- send_message -----
    Sending to group address 0xCAFE
    <t: 150914>, main.c, 151, Status : 7
    <t: 150916>, app_error_weak.c, 115, Mesh error 7 at 0x000279E5 (D:\Behine Niroo\Nordic\NRF Mesh\nrf5_SDK_for_Mesh_v5.0.0_src\examples\light_switch - Copy (3)\client\src\main.c:161)

    Because the status returned by the "access_model_publish" function, I printed out the parameters before that. As you can see 

    <t: 0>, main.c, 435, ----- BLE Mesh Light Switch Client Demo -----
    <t: 12535>, main.c, 394, Initializing and adding models
    <t: 17432>, mesh_app_utils.c, 66, Device UUID (raw): 137FF47B11294702B381A62F60654E45
    <t: 17435>, mesh_app_utils.c, 67, Device UUID : 137FF47B-1129-4702-B381-A62F60654E45
    <t: 17449>, main.c, 482,
    ------------------------------------------------------------------------------------
    Button/RTT 1) Send a message to the odd group (address: 0xC003) to turn on LED 1.
    Button/RTT 2) Send a message to the odd group (address: 0xC003) to turn off LED 1.
    Button/RTT 3) Send a message to the even group (address: 0xC002) to turn on LED 1.
    Button/RTT 4) Send a message to the even group (address: 0xC002) to turn off LED 1.
    ------------------------------------------------------------------------------------
    <t: 111205>, main.c, 301, Button 1 pressed
    <t: 111208>, main.c, 139, ----- send_message -----
    Sending to group address 0xCAFE
    <t: 111219>, main.c, 150, msg.opcode.opcode : 0x00C1
    <t: 111221>, main.c, 151, msg.p_buffer : Hello
    <t: 111223>, main.c, 152, msg.length : 5
    <t: 111225>, main.c, 154, Status : 7
    <t: 111227>, app_error_weak.c, 115, Mesh error 7 at 0x00027A1D (D:\Behine Niroo\Nordic\NRF Mesh\nrf5_SDK_for_Mesh_v5.0.0_src\examples\light_switch - Copy (3)\client\src\main.c:165)

    I also followed the  "access_model_publish" function until "packet_alloc_and_tx" function and tried to print out its parameters:

    <t: 0>, main.c, 467, ----- BLE Mesh Light Switch Client Demo -----
    <t: 12356>, main.c, 426, Initializing and adding models
    <t: 12406>, main.c, 230, Node Address: 0x0002
    <t: 12409>, mesh_app_utils.c, 66, Device UUID (raw): 137FF47B11294702B381A62F60654E45
    <t: 12412>, mesh_app_utils.c, 67, Device UUID : 137FF47B-1129-4702-B381-A62F60654E45
    <t: 12436>, main.c, 514,
    ------------------------------------------------------------------------------------
    Button/RTT 1) Send a message to the odd group (address: 0xC003) to turn on LED 1.
    Button/RTT 2) Send a message to the odd group (address: 0xC003) to turn off LED 1.
    Button/RTT 3) Send a message to the even group (address: 0xC002) to turn on LED 1.
    Button/RTT 4) Send a message to the even group (address: 0xC002) to turn off LED 1.
    ------------------------------------------------------------------------------------
    <t: 178686>, main.c, 333, Button 1 pressed
    <t: 178688>, main.c, 139, ----- send_message -----
    Sending to group address 0xCAFE
    <t: 178699>, main.c, 150, msg.opcode.opcode : 0x00C1
    <t: 178702>, main.c, 151, msg.p_buffer : Hello
    <t: 178704>, main.c, 152, msg.length : 5
    <t: 178706>, access.c, 439, handle : 0
    <t: 178708>, access.c, 440, pp_access_payload : 537128688
    <t: 178711>, access.c, 441, p_access_payload_len : 537128694
    <t: 178714>, access.c, 442, TX: Msg Hello
    <t: 178716>, main.c, 154, Status : 7
    <t: 178718>, app_error_weak.c, 115, Mesh error 7 at 0x00027A25 (D:\Behine Niroo\Nordic\NRF Mesh\nrf5_SDK_for_Mesh_v5.0.0_src\examples\light_switch - Copy (3)\client\src\main.c:165)

    I am not sure about the correctness of my method to print out and I could not print the "p_rx_message" variable.

    Any idea?

    Are you sure there is no need to change other codes, as I see in this case that the Generic OnOff and a few lines have been modified?

    Could you please run this example on your side? Because I have been struggling a long time to run that.

    It seems that after 3 years, it is needed an update, isn't it?

    Br,

    Sama

Related