AnsweredAssumed Answered

No udp multicast receive with Kinetis SDK 2.1.0 and FRDM-K66F

Question asked by Juande Sanchez on Nov 21, 2016
Latest reply on Nov 21, 2016 by Juande Sanchez

Hello,

 

Any example over receive udp multicast with Kinetis SDK 2.1.0 and FRDM-K66F?

 

I can not make it work:

 

 

 

static void udpecho_thread(void *arg)
{
struct netconn *conn;
struct netbuf *buf;
char buffer[4096];
err_t err;
LWIP_UNUSED_ARG(arg);

#if LWIP_IPV6
conn = netconn_new(NETCONN_UDP_IPV6);
netconn_bind(conn, IP6_ADDR_ANY, 7);
#else /* LWIP_IPV6 */
conn = netconn_new(NETCONN_UDP);
netconn_bind(conn, IP_ADDR_ANY, 5000);
#endif /* LWIP_IPV6 */
LWIP_ERROR("udpecho: invalid conn", (conn != NULL), return;);

#if LWIP_IGMP /* Only for testing of multicast join*/
{
#include "lwip\netif.h"

ip4_addr_t multiaddr;
IP4_ADDR(&multiaddr, 224, 5, 6, 7);

err = netconn_join_leave_group(conn, &multiaddr, &netif_default->ip_addr, NETCONN_JOIN);
LWIP_ERROR("udpecho: join group is failed", (err == ERR_OK), return;);
}
#endif

while (1) {
err = netconn_recv(conn, &buf);
if (err == ERR_OK) {
/* no need netconn_connect here, since the netbuf contains the address */
if(netbuf_copy(buf, buffer, sizeof(buffer)) != buf->p->tot_len) {
LWIP_DEBUGF(LWIP_DBG_ON, ("netbuf_copy failed\n"));
} else {
buffer[buf->p->tot_len] = '\0';
err = netconn_send(conn, buf);
if(err != ERR_OK) {
LWIP_DEBUGF(LWIP_DBG_ON, ("netconn_send failed: %d\n", (int)err));
} else {
LWIP_DEBUGF(LWIP_DBG_ON, ("got %s\n", buffer));
}
}
netbuf_delete(buf);
}
}
}

 

Thanks.

Outcomes