Wifi.softAP DHCP issue - ERROR: send_offer (error -13) · Issue #7871 · esp8266/Arduino (original) (raw)

Basic Infos

Platform

Settings in IDE

Problem Description

When I run WIFI in soft AP mode I can't connect to my board using DHCP. I've tried from different devices both Windows PC and Android phones failed during obtaining IP address. When I assign static IP everything works fine. I've checked network communication using Wireshark and DHCP offer message wasn't send from ESP. When I enabled debug I see following errors:
ERROR: send_offer (error -13)
ERROR: dhcps send ack (error -13)

I've tried different devices and play with a lot of different settings like: WiFi.setSleepMode. IP configuration, dhcps_offer_option, WiFi.mode but without success. I've also check a lot of similar issues (one with mDNS, too short password etc) but none of them fix mine. I will be really glad if somebody give me some advice.

MCVE Sketch

#include <Arduino.h> #include <ESP8266WiFi.h> #include <ESPAsyncTCP.h> #include <ESPAsyncWebServer.h> #include <AsyncJson.h> #include <ArduinoJson.h> #include <DHT.h> #include <LittleFS.h>

extern "C" { #include "user_interface.h" }

void setup() { Serial.begin(115200); Serial.setDebugOutput(true);

 WiFi.setSleepMode(WIFI_NONE_SLEEP);
 WiFi.disconnect(true);
 WiFi.mode(WIFI_AP);

 uint8 mode = 1;
 wifi_softap_set_dhcps_offer_option(OFFER_ROUTER, &mode);

 WiFi.softAP(systemConfig.wifiName, systemConfig.wifiPassword, 9);
 delay(500); //wait for SYSTEM_EVENT_AP_START 
 WiFi.softAPConfig(IPAddress{10, 0, 0, 1}, IPAddress{10, 0, 0, 1}, IPAddress{255, 255, 255, 0});

 Serial.println("Connected:");
 Serial.println(WiFi.softAPIP());
 
 Serial.println("DHCP status:");
 Serial.println(wifi_softap_dhcps_status());

//starting web server etc

}

void loop() { //basic reading sensor operation nothing heavy }

Debug Messages

SDK:2.2.2-dev(38a443e)/Core:2.7.2=20702000/lwIP:STABLE-2_1_2_RELEASE/glue:1.2-30-g92add50/BearSSL:5c771be
sleep disable
[AP] softap config unchanged
[APConfig] local_ip: 10.0.0.1 gateway: 10.0.0.1 subnet: 255.255.255.0
[APConfig] DHCP IP start: 10.0.0.100
[APConfig] DHCP IP end: 10.0.0.200
Connected:
10.0.0.1
DHCP status:
1
wifi evt: 7
aid 1
station: 28:b2:bd:cf:c0:f1 join, AID = 1
wifi evt: 5
ERROR: send_offer (error -13)
wifi evt: 7
....
wifi evt: 7
wifi evt: 9
wifi evt: 7
ERROR: dhcps send ack (error -13)
wifi evt: 9
wifi evt: 7
wifi evt: 7
...