#define WIFI_NAME "WiFi Name"
#define WIFI_PASSWORD "WiFi Password"
#define DEVICE_ID 1 
#define DEVICE_NAME "Device Name"
#define TOKEN "Add Token"


#include <RemoteMe.h>

#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>


ESP8266WiFiMulti WiFiMulti;
RemoteMe& remoteMe = RemoteMe::getInstance(TOKEN, DEVICE_ID);

//*************** CODE FOR CONFORTABLE VARIABLE SET *********************


//*************** IMPLEMENT FUNCTIONS BELOW *********************


void onSubscribersChange(int32_t i) 
{
    Serial.println("       ");
    Serial.println("*****YouTube Information*****");
    Serial.println("       ");
    Serial.printf("Subscribers: %d\n",i);
}

void onViewsChange(int32_t i) 
{
    Serial.printf("Total Views: %d\n",i);
}

void onWeatherChange(int16_t i1, int16_t i2,String s1,String s2) 
{
    Serial.println("       ");
    Serial.println("*****Weather Information*****");
    Serial.println("       ");
    Serial.printf("Temperature : %d",i1);
    Serial.printf("°C\n");
    Serial.printf("Pressure : %d\n", i2);
    Serial.printf("Date & Time :%s\n", s1.c_str());
    Serial.printf("Weather : %s\n", s2.c_str());
}

void setup() 
{
    Serial.begin(9600);
    WiFiMulti.addAP(WIFI_NAME, WIFI_PASSWORD);
    while (WiFiMulti.run() != WL_CONNECTED) 
    {
        delay(100);
    }

    remoteMe.getVariables()->observeInteger("Subscribers" ,onSubscribersChange);
    remoteMe.getVariables()->observeInteger("Views" ,onViewsChange);
    remoteMe.getVariables()->observeSmallInteger2Text2("Weather" ,onWeatherChange);
    remoteMe.setupTwoWayCommunication();
    remoteMe.sendRegisterDeviceMessage(DEVICE_NAME);
}


void loop() 
{
    remoteMe.loop();
}
