UDP on openthread is not received

This example automatically create the thread network. Once the button is pressed every 3 second udp is sent. 

Issue is I am not receiving the packet on 2nd device. I am not seeing print from port_data_callback().

What am I missing? Thanks.

Using nrf52840 dongle, nrf connect 1.9.1

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
* Copyright (c) 2020 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/
#include <zephyr.h>
#include <dk_buttons_and_leds.h>
#include <logging/log.h>
#include <net/openthread.h>
#include <openthread/thread.h>
#include <openthread/udp.h>
#include <sys/printk.h>
#include <usb/usb_device.h>
#include <drivers/uart.h>
LOG_MODULE_REGISTER(coap_server, CONFIG_COAP_SERVER_LOG_LEVEL);
BUILD_ASSERT(DT_NODE_HAS_COMPAT(DT_CHOSEN(zephyr_shell_uart), zephyr_cdc_acm_uart),
"Console device is not ACM CDC UART device");
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Hello,

    On the receiver, does any of the function calls in init_udp() return any errors?

    And on the receiver, does any of the function calls in send_udp() return any errors?

    Best regards,

    Edvin

  • I run same code on both devices posted above.

    No, init_udp() and send_udp() is not printing any error.

  • I got an update. I think UDP packet is received by the net_openthead but it's not propogated to the callback passed in by otUdpOpen() function. ( I have not verified by nrf sniffer yet)

    There are two devices in this screenshot. both devices are flashed with the code posted above. 

    left device addr- fe80:0:0:0:dc50:c721:81ac:8d9a:49153 send to ff02::1:1994 ----> received at right device

    right device addr: fe80:0:0:0:24af:a408:99fc:72e5:49153 send to ff02::1:1994 -----> received at left device

    Do I need to set any type of filter so, it can be seen in callback?

    After adding CONFIG_OPENTHREAD_LOG_LEVEL_INFO=y, I saw the prints starting [INFO]-MAC-----:

    prj.config

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    #
    # Copyright (c) 2020 Nordic Semiconductor
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #
    # nRF board library
    CONFIG_DK_LIBRARY=y
    #CONFIG_OPENTHREAD_NORDIC_LIBRARY_MASTER=y
    # Enable CoAP utils and CoAP protocol
    #CONFIG_COAP_UTILS=y
    # Enable OpenThread CoAP support API
    #CONFIG_OPENTHREAD_COAP=y
    # Configure sample logging setting
    CONFIG_LOG=y
    CONFIG_OPENTHREAD_LOG_LEVEL_INFO=y
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • I just want to confirm:

    swap007 said:
    , init_udp() and send_udp() is not printing any error

    Does that mean that you see "otUdpOpen SUCCESS" in the log, or that you don't see anything?

    I am not sure about this one. We don't have any examples using this UDP other than deep inside "Matter", so it is not that easy to see how it is supposed to be used. 

    Assuming that this is Openthreads take on the UDP IP protocol, I would assume that it requires a bit more setup, such as an UDP port, which I assume will be part of the socket setup. 

    Perhaps you can try to both send and receive, but replace the other device (receiver and sender, respectively) with the CLI example.

    Looking at the testing description it looks like you need to bind to a port, and there is a function called otUdpBind(), so I believe you need to call this from the receiver. From the description it looks like the 3rd parameter in otUdpBind() is an otSockAddr, which contains a port number. 

    Best regards,

    Edvin

  • Actually, there was no error output of init function or send function. I wish otUdpOpen() function return error if thread network is not up.

    FInally, I found the issue by try and error with help of CLI example.

    One key piece was missed is : I should not be doing udp init before the thread network is up. Once I call the init function once both devices are part of openthread network, everything is fine.

    Thank you for the help.

1 2