How can I use sockets with LWIP and FreeRTOS?
I am trying to use Sockets under FreeRTOS. Currently can send data over UDP using netconn, but sockets only send information when two netconn messages are sent previous to the socket one. If some of the netconn_sendto(...) functions is commented, sendto stops working.
void UDP_Send_Thread(void)
{
// Creamos estructuras de datos necesarias para los envíos
struct netconn *conn;
struct netbuf *outbuf;
u8_t dataraw[] = "Hola UDP RTOS\n";
// Generamos IP para envío de datos
ip_addr_t ipto;
IP4_ADDR(&ipto,172,16,0,2);
// Creamos conexión UDP con netconn
conn = netconn_new(NETCONN_UDP);
int s = socket(AF_INET, SOCK_DGRAM, 0);
struct sockaddr_in addr, cliaddr;
memset(&addr, 0, sizeof(addr));
memset(&cliaddr, 0, sizeof(cliaddr));
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = IP_ADDR_ANY;
addr.sin_port = htons(60000);
cliaddr.sin_family = AF_INET;
cliaddr.sin_addr.s_addr = inet_addr("172.16.0.2");
cliaddr.sin_port = htons(49002);
int b = bind(s, (const struct sockaddr *) &addr, sizeof(addr));
// Creamos buffer para envío de datos de tipo netbuf
outbuf = netbuf_new();
// referenciamos cadena de texto al buffer
netbuf_ref(outbuf, dataraw, sizeof(dataraw));
for(;;)
{
// Enviamos datos
netconn_sendto(conn, outbuf, &ipto, 49000);
netconn_sendto(conn, outbuf, &ipto, 49001);
osDelay(500);
// Indicamos con un LED que el envío se ha hecho (parpadeo)
sendto(s, dataraw, strlen(dataraw), MSG_DONTWAIT, (const struct sockaddr *) &cliaddr, sizeof(cliaddr));
HAL_GPIO_TogglePin(LD3_GPIO_Port, LD3_Pin);
osDelay(500);
}
}Can somebody help me regarding with this issue? I am trying to learn how to use all Raw, Sockets and Netconn LWIP.
Thanks in advance.
