UDP Echo server not working
Working on a basic UDP Echo server with STM32F429ZI. I had CubeMX add lwIP into the project, but its doesn't seem to receive any packets when I send them. DHCP seems to work as I can see an IP getting assigned on the router.
void udp_echoserver_receive_callback(void *arg, struct udp_pcb *upcb, struct pbuf *p, struct ip_addr *addr, u16_t port)
{
/* Connect to the remote client */
udp_connect(upcb, addr, UDP_CLIENT_PORT);
/* Tell the client that we have accepted it */
udp_send(upcb, p);
/* free the UDP connection, so we can accept new clients */
udp_disconnect(upcb);
/* Free the p buffer */
pbuf_free(p);
}
/**
* @brief Initialize the server application.
* @param None
* @retval None
*/
void udp_echoserver_init(void)
{
struct udp_pcb *upcb;
err_t err;
/* Create a new UDP control block */
upcb = udp_new();
if (upcb)
{
/* Bind the upcb to the UDP_PORT port */
/* Using IP_ADDR_ANY allow the upcb to be used by any local interface */
err = udp_bind(upcb, IP_ADDR_ANY, UDP_SERVER_PORT);
if(err == ERR_OK)
{
/* Set a receive callback for the upcb */
udp_recv(upcb, udp_echoserver_receive_callback, NULL);
}
}
}These are my init and callback functions. In main I call ethernetif_input(&gnetif);
I'd like to store the packets to be read in main using the RxCmpltCallback, but I'm not sure what to do. Also despite ICMP being enabled, no pings are recieved when I use a ping program.
