The default Contiki UDP API is difficult to use.
More...
|
typedef void(* | simple_udp_callback) (struct simple_udp_connection *c, const uip_ipaddr_t *source_addr, uint16_t source_port, const uip_ipaddr_t *dest_addr, uint16_t dest_port, const uint8_t *data, uint16_t datalen) |
| Simple UDP Callback function type.
|
|
|
int | simple_udp_send (struct simple_udp_connection *c, const void *data, uint16_t datalen) |
| Send a UDP packet. More...
|
|
int | simple_udp_sendto (struct simple_udp_connection *c, const void *data, uint16_t datalen, const uip_ipaddr_t *to) |
| Send a UDP packet to a specified IP address. More...
|
|
int | simple_udp_sendto_port (struct simple_udp_connection *c, const void *data, uint16_t datalen, const uip_ipaddr_t *to, uint16_t to_port) |
| Send a UDP packet to a specified IP address and UDP port. More...
|
|
int | simple_udp_register (struct simple_udp_connection *c, uint16_t local_port, uip_ipaddr_t *remote_addr, uint16_t remote_port, simple_udp_callback receive_callback) |
| Register a UDP connection. More...
|
|
The default Contiki UDP API is difficult to use.
The simple-udp module provides a significantly simpler API.
◆ simple_udp_register()
Register a UDP connection.
- Parameters
-
c | A pointer to a struct simple_udp_connection |
local_port | The local UDP port in host byte order |
remote_addr | The remote IP address |
remote_port | The remote UDP port in host byte order |
receive_callback | A pointer to a function to be called for incoming packets |
- Return values
-
0 | If no UDP connection could be allocated |
1 | If the connection was successfully allocated This function registers a UDP connection and attaches a
callback function to it. The callback function will be
called for incoming packets. The local UDP port can be
set to 0 to indicate that an ephemeral UDP port should
be allocated. The remote IP address can be NULL, to
indicate that packets from any IP address should be
accepted.
Note that receive_callback is executed in the context
of the process which has called this function
|
Definition at line 102 of file simple-udp.c.
◆ simple_udp_send()
Send a UDP packet.
- Parameters
-
c | A pointer to a struct simple_udp_connection |
data | A pointer to the data to be sent |
datalen | The length of the data This function sends a UDP packet. The packet will be
sent to the IP address and with the UDP ports that were
specified when the connection was registered with
simple_udp_register().
|
- See also
- simple_udp_sendto()
Definition at line 66 of file simple-udp.c.
◆ simple_udp_sendto()
int simple_udp_sendto |
( |
struct simple_udp_connection * |
c, |
|
|
const void * |
data, |
|
|
uint16_t |
datalen, |
|
|
const uip_ipaddr_t * |
to |
|
) |
| |
Send a UDP packet to a specified IP address.
- Parameters
-
c | A pointer to a struct simple_udp_connection |
data | A pointer to the data to be sent |
datalen | The length of the data |
to | The IP address of the receiver This function sends a UDP packet to a specified IP
address. The packet will be sent with the UDP ports
that were specified when the connection was registered
with simple_udp_register().
|
- See also
- simple_udp_send()
Definition at line 77 of file simple-udp.c.
◆ simple_udp_sendto_port()
int simple_udp_sendto_port |
( |
struct simple_udp_connection * |
c, |
|
|
const void * |
data, |
|
|
uint16_t |
datalen, |
|
|
const uip_ipaddr_t * |
to, |
|
|
uint16_t |
to_port |
|
) |
| |
Send a UDP packet to a specified IP address and UDP port.
- Parameters
-
c | A pointer to a struct simple_udp_connection |
data | A pointer to the data to be sent |
datalen | The length of the data |
to | The IP address of the receiver |
to_port | The UDP port of the receiver, in host byte order This function sends a UDP packet to a specified IP
address and UDP port. The packet will be sent with the
UDP ports that were specified when the connection was
registered with simple_udp_register().
|
- See also
- simple_udp_sendto()
Definition at line 89 of file simple-udp.c.