 #include <Ticker.h>
 #include "/usr/local/src/rpi2_setting.h"
 
+extern "C" {
+#include "user_interface.h"
+}
+
 #define BUTTON_PIN 0
 #define RELAY_PIN 12
 #define LED_PIN 13
 
-#define BETWEEN_RELAY_ACTIVE 5000
+#define BETWEEN_RELAY_ACTIVE 1000
 
 IPAddress mqtt_server = MQTT_SERVER;
 
-char* subscribe_topic = "light/bedroomlight";
+const char* subscribe_topic = "light/bedroomlight";
+const char* reporting_topic = "light/bedroomlight/report";
+
 long lastReconnectAttempt = 0;
 volatile bool bUpdated = false;
 volatile bool bRelayState = false;

  digitalWrite(LED_PIN, !state);     // set pin to the opposite state
}

void ICACHE_RAM_ATTR parseMqttMsg(String receivedpayload, String receivedtopic)
{
  char json[] = "{\"cmd\":\"off\"}";

    Serial.print("[WIFI] Connecting to ");
    Serial.println(WIFI_SSID);

    //wifi_set_phy_mode(PHY_MODE_11N);
    WiFi.mode(WIFI_STA);
    WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
    WiFi.hostname("esp-bedroomlight");
