Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

after webconfig state=-2 on reset #55

Open
mckennatim opened this issue Mar 16, 2016 · 0 comments
Open

after webconfig state=-2 on reset #55

mckennatim opened this issue Mar 16, 2016 · 0 comments

Comments

@mckennatim
Copy link

After webconfig, when moving from AP mode to wifi client mode, the reset button works for wifi connect but not for pubsubclient connect. In order to get pubsubclient to connect I need to power down the Wemos mini. After wifi is setup, reset works fine for pubsubclient connect. Is there some command that I am missing?

WiFiClient espClient;
PubSubClient client(espClient);

void setup(){
  Serial.begin(115200);
  EEPROM.begin(512);
  Serial.println();
  Serial.println("--------------------------");
  Serial.println("ESP8266 multifile");
  Serial.println("--------------------------");
  getOnline();
  strcpy(cmd, devid);
  strcat(cmd,"/cmd");
  client.setServer(ip, 1883);
  client.setCallback(handleMqttIn);  
}

void loop(){
  server.handleClient();
  if(NEW_MAIL){processIncoming();}
  if(!client.connected() && !NEEDS_RESET){
     reconn();
  }else{
    client.loop();
  }
}

void reconn() {
  Serial.print("Attempting MQTT connection...");
  if (client.connect(devid)) {
    Serial.println("connected");
    client.subscribe(cmd);
    return;
  } else {

(arduino 1.6.7)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant