Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By matkar
#23491 I have the following problem:
When I connect multiple stations (I use two tablets and a PC) to the SoftAP they get their IP addresses consecutively.
ESP has 192.168.4.1 and stations get .2, .3, .4 in accordance to the order they have been connected to ESP. All good by now.
Then I disable the connections on all three stations. If I reenable them in the correct order (.2, .3, .4) all stations connect OK, but;
(fail scenario)
If I reenable the .4 station first it wont connect. If I then enable the station .3 sometimes it connects, sometimes it doesn't.
If I then enable the first station (.2) it will surely connect and soon after that the .4 station will connect as well. Actually it is enough the .2 station sends a request to connect (acquiring network address) to allow the .3 and .4 to connect even before .2 does.

During the ESP session the assigned IPs remain tied to a specific device. Once the device has been assigned an IP address it will keep getting the same IP until the next reboot of ESP module. Disabling station wifi won't affect it's IP assigned by ESP. ESP probably ties the IP to station's MAC.

It doesn't matter which station is firstly associated to which IP number, the described problem is there in all cases.

As I see it SoftAP expects to connect the devices in the order they were connected to in the first run. Since it can't reassign the previously used IP to newly connected station, it doesn't connect with them at all.

Now this is a problem for the obvious reason. If the station that firstly connected to the ESP leaves the connection, none of the devices connected after won't be able to connect to ESP again if they loose connection in the meantime.

Any thoughts?

Mat

Here is a simple sketch I'm using for testing:
Code: Select all#include <ESP8266WiFi.h>
#include <WiFiUDP.h>
#include <ESP8266WebServer.h>

//////////////////////
// WiFi Definitions //
//////////////////////
const char WiFiAPPSK[] = "1234567890";

//***************************************************************
//                              SETUP
//***************************************************************
void setup() {
  Serial.begin(115200);

  delay(2000);
 
  // We start by setting up WiFi access point
  Serial.println();
  Serial.print("Setting up AP...");
 
  WiFi.mode(WIFI_AP);
 
  delay(2000);

  // Do a little work to get a unique-ish name. Append the
  // last two bytes of the MAC (HEX'd) to "Thing-":
  uint8_t mac[WL_MAC_ADDR_LENGTH];
  WiFi.softAPmacAddress(mac);
  String temp1 = String(mac[WL_MAC_ADDR_LENGTH - 2], HEX);
  if(temp1.length() == 1)
  {
    temp1 = '0' + temp1;
  }
  String temp2 = String(mac[WL_MAC_ADDR_LENGTH - 1], HEX);
  if(temp2.length() == 1)
  {
    temp2 = '0' + temp2;
  }
  String macID = temp1 + temp2;
  macID.toUpperCase();
  String AP_NameString = "ESP_DHCP_TEST." + macID;
  Serial.println(AP_NameString);
  char AP_NameChar[AP_NameString.length() + 1];
  memset(AP_NameChar, AP_NameString.length() + 1, 0);
  for (int i=0; i<AP_NameString.length() + 1; i++)
  {
    AP_NameChar[i] = AP_NameString.charAt(i);
  }
  WiFi.softAP(AP_NameChar, WiFiAPPSK);

  delay(2000);

  Serial.println("");
  Serial.println("WiFi connected"); 
  Serial.print("AP IP address: ");
  Serial.println(WiFi.softAPIP()); 
}

//***************************************************************
//                              LOOP
//***************************************************************
void loop()
{
 
}
User avatar
By matkar
#23552 I did some additional tests...
If I set all three (.2, .3, .4) clients to static connection I have no trouble disconnecting and connecting in any order.
Then I set the .4 client to DHCP and it connects normally. Even if I disable the .2 client (which is set to static routing) I can reconnect the .4 normally with DHCP. Then I set the .2 client to DHCP and it didn't connect. Then I set the .3 client to DHCP and it connected and at the same time the .2 connected as well.

It seems there is some complex logic on how the clients connect over DHCP, I can't figure it out.

I do believe this is a DHCP issue. I don't now who to inform about this. Is this a fault in espressif SDK? Shall I bring this up on their BBS?