esp8266 / esp8266/Arduino

softAPConfig creates IP conflict to devices connected to soft AP

Open
#8,257 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
16.7k
Forks
13.1k
PR merge metrics
No merged PRs in 30d

Description

### Basic Infos

- [x ] This issue complies with the [issue POLICY doc](https://github.com/esp8266/Arduino/blob/master/POLICY.md).
- [x ] I have read the documentation at [readthedocs](https://arduino-esp8266.readthedocs.io/en/latest) and the issue is not addressed there.
- [ ] I have tested that the issue is present in current master branch (aka latest git).
- [x] I have searched the issue tracker for a similar issue.
- [ ] If there is a stack dump, I have decoded it.
- [x] I have filled out all fields below.

#### Platform

- Hardware: [NodeMCU-ESP8266]
- Core Version: [3.0.1]
- Development Env: [Arduino IDE]
- Operating System: [Ubuntu]

### Settings in IDE

- Module: [Generic ESP8266 Module]
- Flash Size: [4MB]
- lwip Variant: [v2 Lower Memory]
- Reset Method: [nodemcu]
- Flash Frequency: [40Mhz]
- CPU Frequency: [80Mhz]
- Upload Using: [SERIAL]
- Upload Speed: [115200]

### Problem Description

The code bellow uses WiFi.softAPConfig to create a soft AP with ip 192.168.10.1.
The problem is that the ESP gives the same IP to multiple devices connected to its soft AP creating IP conflict.
For instance my PC and my phone both get the 192.168.10.100 IP.
This looks like a bug in softAPConfig since I remove it and there is no more conflicts.
- Tested on 3.0.1

### [MCVE](https://stackoverflow.com/help/mcve) Sketch

```cpp

#include
#include "ESP8266WiFi.h"

#define NET_SSID "..."
#define NET_PASS "..."

#define AP_SSID "test_net"

IPAddress ap_ip(192,168,10,1);
IPAddress ap_gateway(192,168,10,1);
IPAddress ap_subnet(255,255,255,0);
char ap_channel=11;

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

delay(1000);
Serial.println("");

WiFi.mode(WIFI_AP_STA);

WiFi.softAPConfig(ap_ip, ap_gateway, ap_subnet);
WiFi.softAP(AP_SSID,"", ap_channel,false,4);
delay(500);

WiFi.begin(NET_SSID, NET_PASS);

Serial.print("Connecting");
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.println(".");
}
Serial.println();
}


void loop() {}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.