|
From: | Maarten Roozendaal |
Subject: | [lwip-users] netconn receive UDP via multicast address |
Date: | Tue, 9 Jan 2018 21:11:41 +0100 |
Goodday, I am working on an implementation of lwip netconn api in combination with FreeRTOS. I use lwip version 2.0.0 on an STM32F7 microcontroller with FreeRTOS V9.0.0 I want to use lwip to receive UDP packets from a mullticast adress. 239.0.0.0 in this case. The system running lwip is assigned a static ip adress, being 192.169.123.109. When sending UDP packets to 192.169.123.109 directly I can process them and echo them back. However, I need to be able to read UDP packets send to the multicast ip adress 239.0.0.0. To accomplish this I use the following task: static void vUDPnetconnTask(void *pvParameters) { static struct netconn *conn; static struct netbuf *buf; ip_addr_t DestIPaddr, OwnAddr; err_t err, recv_err; LWIP_UNUSED_ARG(pvParameters); netif_default->flags = NETIF_FLAG_UP | NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP | NETIF_FLAG_IGMP; IP4_ADDR(&MulticastIPaddr, 239, 0, 0, 0); IP4_ADDR(&OwnAddr, 192, 168, 123, 109); conn = netconn_new(NETCONN_UDP); if (conn!= NULL) { netconn_bind(conn, IP_ADDR_ANY, 60004); // returns ERR_OK err = netconn_join_leave_group(conn, &MulticastIPaddr, &OwnAddr, NETCONN_JOIN); // returns ERR_OK if (err == ERR_OK) { while (1) { recv_err = netconn_recv(conn, &buf); if (recv_err == ERR_OK) { // process the packet } } } else { netconn_delete(conn); } } } So, I bind to IP_ADDR_ANY using port 60004 (this is the port that the multicast address receives UDP packets on) and I use the function netconn_join_leave_group() to subribe to the multicast address. I do not get any error returns but I do not receive any UDP packets send to 293.0.0.0. I have been trying for a long time to get this to work but feel like I am missing something fundamental. Is there a way to accomplish what I need? Help is very much appriciated! Greetings, Maarten |
[Prev in Thread] | Current Thread | [Next in Thread] |