-->
Page 1 of 1

Wierd one

PostPosted: Sun Jun 26, 2016 5:35 am
by Apothus
My project utilises and ESP-12 board.
The device functions as a webserver that based on a request or timed events(RTC on SPI) controls an RGB light strip.

Because it is just setup for personal use I have hard coded the SSID & password information into the device and set it as a WiFi client.

The device ran fine for a few days then stopped responding to http requests. When I restarted my router and went to refresh my laptops WiFi I noticed the ESP8266 was running as a hotspot. I could connect to it and it would protests my HTTP requests as normal.

I have never setup this device to function as a hotspot, nowhere in my code is this configured. All the other device information and settings that were stored in RAM (not flash, set over http requests) were still remembered. It was not like it had browned out and reset or over written some part of its configuration. Does anyone have any idea why it would have dropped into hotspot mode!?

Code: Select allvoid setup(void) {
  pinMode(buttonPin, INPUT);
  Serial.begin(115200);

  Wire.begin(ds1307SDA, ds1307SCL);
  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
  }

  strip.begin();
  strip.show();

  WiFi.begin(ssid, password);
  WiFi.config(ip, gateway, subnet);

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  if (MDNS.begin("esp8266")) {
    Serial.println("MDNS responder started");
  }

  server.on("/", handleRoot);
  server.on("/json", handleJSON);
  server.on("/AlarmOn", setAlarm);
  server.on("/AlarmOff", clearAlarm);
  server.on("/setAlarm", updateAlarm);
  server.on("/lampOn", lampOn);
  server.on("/lampOff", lampOff);
  server.on("/partyOn", partyOn);

  server.onNotFound(handleNotFound);

  server.begin();
  Serial.println("HTTP server started");

  updateTimeTime = millis() + updateTimeDelay;
  updateStripTime = millis() + updateStripTime;
}

Re: Wierd one

PostPosted: Sun Jun 26, 2016 6:49 am
by lethe
ESPs usually ship with station+AP mode enabled. Unless you have set it station only at least once, that default will persist.

If you expect your ESP to be in any particular mode, you should explicitly set that mode in your code.

Re: Wierd one

PostPosted: Sun Jun 26, 2016 7:15 am
by Apothus
Fantastic.
That makes a lot of sense. I notice my code doesn't explicitly state the mode.