OpenThread CLI - UDP Example

The OpenThread UDP APIs may be invoked via the OpenThread CLI.

Quick Start

Form Network

Form a network with at least two devices.

Node 1

On node 1, open and bind the example UDP socket.

> udp open
> udp bind :: 1234

The :: specifies the IPv6 Unspecified Address.

Node 2

On node 2, open the example UDP socket and send a simple message.

> udp open
> udp send fdde:ad00:beef:0:bb1:ebd6:ad10:f33 1234 hello

Result

On node 1, you should see a print out similar to below:

5 bytes from fdde:ad00:beef:0:dac3:6792:e2e:90d8 49153 hello

Command List

Command Details

help

List the UDP CLI commands.

> udp help
help
bind
close
connect
open
send
Done

bind [netif] <ip> <port>

Assigns a name (i.e. IPv6 address and port) to the example socket.

  • netif: the network interface to bind to.
    • not specified: Thread network interface.
    • -u: unspecified network interface.
    • -b: Backbone network interface.
  • ip: the IPv6 address or the unspecified IPv6 address (::).
  • port: the UDP port
> udp bind :: 1234
Done
> udp bind -u :: 1234
Done
> udp bind -b :: 1234
Done

close

Closes the example socket.

> udp close
Done

connect <ip> <port>

Specifies the peer with which the socket is to be associated.

  • ip: the peer's IPv6 address.
  • port: the peer's UDP port.
> udp connect fdde:ad00:beef:0:bb1:ebd6:ad10:f33 1234
Done

linksecurity

Indicates whether the link security is enabled or disabled.

> udp linksecurity
Enabled
Done

linksecurity enable

Enable link security.

> udp linksecurity enable
Done

linksecurity disable

Disable link security.

> udp linksecurity disable
Done

open

Opens the example socket.

> udp open
Done

send <ip> <port> <message>

Send a UDP message.

  • ip: the IPv6 destination address.
  • port: the UDP destination port.
  • message: the message to send.
> udp send fdde:ad00:beef:0:bb1:ebd6:ad10:f33 1234 hello
Done

send <ip> <port> <type> <value>

Send a few bytes over UDP.

  • ip: the IPv6 destination address.
  • port: the UDP destination port.
  • type: the type of the message:
    • -t: text payload in the value, same as without specifying the type.
    • -s: autogenerated payload with specified length indicated in the value.
    • -x: binary data in hexadecimal representation in the value.
> udp send fdde:ad00:beef:0:bb1:ebd6:ad10:f33 1234 -t hello
Done

> udp send fdde:ad00:beef:0:bb1:ebd6:ad10:f33 1234 -x 68656c6c6f
Done

> udp send fdde:ad00:beef:0:bb1:ebd6:ad10:f33 1234 -s 800
Done

send <message>

Send a UDP message on a connected socket.

  • message: the message to send.
> udp send hello
Done

send <type> <value>

Send a few bytes over UDP.

  • type: the type of the message:
    • -t: text payload in the value, same as without specifying the type.
    • -s: autogenerated payload with specified length indicated in the value.
    • -x: binary data in hexadecimal representation in the value.
> udp send -t hello
Done

> udp send -x 68656c6c6f
Done

> udp send -s 800
Done