Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "board.h"
- #include "net/af.h"
- #include "net/protnum.h"
- #include "net/ipv6/addr.h"
- #include "net/sock/udp.h"
- #include "shell.h"
- #define BUFFER_SIZE (128U)
- #define UDP_PORT (32323U)
- uint8_t data[BUFFER_SIZE];
- extern void handle_udp_command(uint8_t * data);
- extern void send_ack(sock_udp_t * sock, sock_udp_ep_t * remote);
- int main(void)
- {
- puts("RIOT OS");
- sock_udp_ep_t local = SOCK_IPV6_EP_ANY;
- sock_udp_t sock;
- local.port = UDP_PORT;
- if (sock_udp_create(&sock, &local, NULL, 0) < 0)
- {
- return -1;
- }
- while (1)
- {
- sock_udp_ep_t remote;
- ssize_t res;
- remote.port = UDP_PORT;
- if ((res = sock_udp_recv(&sock, data, sizeof(data), SOCK_NO_TIMEOUT, &remote)) >= 0)
- {
- if (res > 0)
- {
- send_ack(&sock, &remote);
- handle_udp_command(data);
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement