您好,
我想用 ESP8266 手动发送 DHCP 发现消息。
我做了以下代码:
代码:
全选#define UDP_BROADCAST_PORT 3444
char DeviceBuffer[40] = {0};
wifi_set_opmode(STA
tiON_MODE);
wifi_station_dhcpc_stop();
myEspconn.type = ESPCONN_UDP;
myEspconn.state = ESPCONN_NONE;
myEspconn.proto.udp->remote_port = UDP_BROADCAST_PORT; // ESP8266 udp remote port
myEspconn.proto.udp->local_port = UDP_BROADCAST_PORT; // ESP8266 udp local port
remote_ip = IPADDR_NONE;
os_memcpy(myEspconn.proto.udp->remote_ip, &remote_ip, 4);
wifi_get_macaddr(STATION_IF, hwaddr);
os_sprintf(DeviceBuffer, "%s" MACSTR "!", ESP8266_MSG, MAC2STR(hwaddr));
espconn_send(&myEspconn, DeviceBuffer, os_strlen(DeviceBuffer));
Espconn_send 返回错误代码 -4。
有人可以帮我解释一下这里可能出了什么问题。