 /*
- * $Id: sonoff.ino,v 1.1 2016/04/04 14:45:06 anoncvs Exp $
+ * $Id: sonoff.ino,v 1.2 2016/04/30 14:52:52 anoncvs Exp $
  *
  * Sonoff Arduino implementation by Theo Arends
  */

      sprintf_P(svalue, PSTR("%s, %s, %s, %d, %d"),
        VERSION, sysCfg.mqtt_topic, sysCfg.mqtt_subtopic, sysCfg.power, sysCfg.timezone);
      if ((data_len > 0) && (payload == 1)) {
        sprintf_P(svalue, PSTR("%s, "MQTT_CLIENT_ID", %s, %s, %s, %s, %d, %d"),
          sysCfg.mqtt_grptopic, ESP.getChipId(), sysCfg.otaUrl, sysCfg.sta_ssid, sysCfg.sta_pwd, sysCfg.mqtt_host, heartbeat, sysCfg.saveFlag);
      }
      if ((data_len > 0) && (payload == 2)) {
        sprintf_P(svalue, PSTR("Version %s, Boot %d, SDK %s"), VERSION, ESP.getBootVersion(), ESP.getSdkVersion());
      }
    }
    else if (!grpflg && !strcmp(type,"UPGRADE")) {

  Serial.printf("Project %s (Topic %s, Fallback "MQTT_CLIENT_ID", GroupTopic %s) Version %s (Boot %d, SDK %s)\n",
    PROJECT, sysCfg.mqtt_topic, ESP.getChipId(), sysCfg.mqtt_grptopic, VERSION, ESP.getBootVersion(), ESP.getSdkVersion());

  Serial.printf("\n\tMQTT-MAX-PACKET: %d\n\t MQTT-KEEPALIVE: %d\n\n", MQTT_MAX_PACKET_SIZE, MQTT_KEEPALIVE); 

  WIFI_Connect();

  mqttClient.setServer(sysCfg.mqtt_host, MQTT_PORT);
