I'm building an app that sends data over udp.
As a beginning, I did something like this:
Code: Select all
static void udpServerTask(void *pvParameters) {
tcpip_adapter_ip_info_t ip_info;
tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &ip_info);
struct udp_pcb *upcb;
err_t err;
upcb = udp_new_ip_type(IPADDR_TYPE_V4);
ip4_addr_t serverIp;
if (upcb != NULL) {
serverIp = ip_info.gw;
err = udp_connect(upcb, &serverIp, UDP_SERVER_PORT);
struct pbuf *p;
char data[128] = "$GPGGA,121222.33,4500.0000,N,00000.0000,W,1,05,3.2,280.2,M,-34.0,M,,*59"; // ok
char *d;
d = data;
while (1) {
p = pbuf_alloc(PBUF_TRANSPORT, strlen((char*) d), PBUF_POOL);
if (p != NULL) {
err = pbuf_take(p, (char*) d, strlen((char*) d));
err = udp_send(upcb, p);
pbuf_free(p);
}
vTaskDelay(500 / portTICK_PERIOD_MS);
}
}
while (1)
taskYIELD();
}
Code: Select all
char data[128] = "$GPGGA,121222.33,4500.0000,N,00000.0000,W,1,05,3.2,280.2,M,-34.0,M,,*59";
Code: Select all
char data[255] = "$GPGGA,121222.33,4500.0000,N,00000.0000,W,1,05,3.2,280.2,M,-34.0,M,,*59";
I also noticed a supect warning that I was unable to remove:
Code: Select all
warning: passing argument 2 of 'udp_connect' from incompatible pointer type [-Wincompatible-pointer-types]
err = udp_connect(upcb, &serverIp, UDP_SERVER_PORT);
Code: Select all
xTaskCreate(udpServerTask, "xcTrackServer", 4096 * 4, NULL, 5, NULL);