-->
Page 1 of 1

Manually sending DHCP discover messages

PostPosted: Sun Mar 20, 2016 3:55 am
by Wamor
Hello,

I want to send DHCP discovery messages with the ESP8266 manually.
I have made the following code:

Code: Select all#define UDP_BROADCAST_PORT 3444
char DeviceBuffer[40] = {0};

wifi_set_opmode(STATION_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 is returning error-code -4.

Could somebody help me and explain what could be wrong here.

Best regards,

Wamor

Re: Manually sending DHCP discover messages

PostPosted: Sun Mar 20, 2016 4:10 pm
by Wamor
Ok, found the first bug. I need to fill the DeviceBuffer with DHCP discovery data. Done this now.
Still when I stop automatic dhcp of the module and set source address to: 0.0.0.0 I got error -4 when executing espconn_send(). Should not this be possible because when sending DHCP discovery packages one should set the source address to 0.0.0.0 and the destination address to 255.255.255.255.