cancel
Showing results for 
Search instead for 
Did you mean: 

how to enable LWIP multicast reception on STM32F7 + FreeRTOS?

Kamil Alkhouri
Associate II
Posted on May 20, 2018 at 21:14

I have a client/server LWIP program that works correctly with unicast communication however I want to use multicast features so I used IGMP library did the following:

1- in opt.h:

&sharpdefine LWIP_IGMP 1 //allowed IGMP

2- in ethernetif.c:

netif->flags |= NETIF_FLAG_IGMP; //in low_level_init function

3-in my source file (for both client and server projects):

implemented the following code:

void

recCallBack

(void)

{

      printf('connected');  //BREAK_POINT

}

static void UDP_Multicast_init(void *arg)

{

   struct ip4_addr ipgroup, localIP;

   struct udp_pcb *g_udppcb;

   char msg[] = 'hello';

   struct pbuf* p;

   p = pbuf_alloc(PBUF_TRANSPORT,sizeof(msg),PBUF_RAM);

   memcpy (p->payload, msg, sizeof(msg));

   IP4_ADDR(&ipgroup, 224, 0, 1, 129 ); //Multicast IP address.

   IP4_ADDR(&localIP, 192, 168, 1, 2); //Interface IP address

   &sharpif LWIP_IGMP

      s8_t iret = igmp_joingroup((ip4_addr_t *)(&localIP),(ip4_addr_t *)(&ipgroup));

   &sharpendif

   g_udppcb =( struct udp_pcb*) udp_new();

   udp_bind(g_udppcb, &localIP, 319); //to allow receiving multicast

   udp_recv(g_udppcb, recCallBack,NULL); //

recCallBack is 

the callback function that will be called every time you    receive multicast

   udp_sendto(g_udppcb,p,&ipgroup,319); //send a multicast packet

}

void telnet_shell_init(void)

{

   sys_thread_new('TELNET', UDP_Multicast_init, NULL, DEFAULT_THREAD_STACKSIZE, osPriorityAboveNormal);

}

The result: all the mentioned code steps are executed successfully in both projects (client and server) but I'm not receiving any multicast messages (or maybe not even sending)!

I added a '

BREAK_POINT' in the callback function but I never reached it. Can you help me? either by suggesting a solution or at least a way to track the problem... I'm using STM32F746 Nucleo board with LWIP, FreeRTOS libraries generated by cubeMX.

Thank you.

#freertos #lwip #udp #stm32f7-nucleo #multicast
1 REPLY 1

Sorry, bumping old zombie unanswered questions off my feed

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..