我正在尝试使用以下代码发送 UDP 广播:
代码:
全选void write_UDP(uint8_t *buffer, int length)
{
sta
tic struct espconn *myEspconn;
unsigned long remote_ip;
ip_addr_t ipaddr;
ets_uart_printf("Sending UDP data!\r\n");
myEspconn = (struct espconn *)os_malloc(sizeof(struct espconn));
myEspconn->type = ESPCONN_UDP;
myEspconn->state = ESPCONN_NONE;
myEspconn->proto.udp = (esp_udp *)os_malloc(sizeof(esp_udp));
myEspconn->proto.udp->local_port = UDP_BROADCAST_PORT;
myEspconn->proto.udp->remote_port = UDP_BROADCAST_PORT;
remote_ip = IPADDR_NONE;
IP4_ADDR(&ipaddr, 255, 255, 255, 255);
os_memcpy(myEspconn->proto.udp->remote_ip, &ipaddr.addr, 4);
ets_uart_printf("ip addres: %x\r\n", ipaddr.addr);
ets_uart_printf("ip addres: " IPSTR "\r\n", IP2STR(&ipaddr.addr));
if (!espconn_send(myEspconn, buffer, length))
ets_uart_printf("espconn_send error!\r\n");
else
ets_uart_printf("espconn_send succeeded!\r\n");
}
谁能帮我找出这里出了什么问题?