예제 #1
0
void user_init(void)
{
	system_set_os_print(0);

	uart_init(BIT_RATE_115200, BIT_RATE_115200);
	os_delay_us(1000000);

	CFG_Load();

	// Initialize the GPIO subsystem.
    gpio_init();

    //Set GPIO2 to output mode
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2);
    //Set GPIO2 high
    gpio_output_set(ROOMBA_WAKEUP_PIN, 0, ROOMBA_WAKEUP_PIN, 0);

	MQTT_InitConnection(&mqttClient, sysCfg.mqtt_host, sysCfg.mqtt_port, sysCfg.security);
	//MQTT_InitConnection(&mqttClient, "192.168.11.122", 1880, 0);

	MQTT_InitClient(&mqttClient, sysCfg.device_id, sysCfg.mqtt_user, sysCfg.mqtt_pass, sysCfg.mqtt_keepalive, 1);
	//MQTT_InitClient(&mqttClient, "client_id", "user", "pass", 120, 1);

	MQTT_InitLWT(&mqttClient, "/lwt", "offline", 0, 0);
	MQTT_OnConnected(&mqttClient, mqttConnectedCb);
	MQTT_OnDisconnected(&mqttClient, mqttDisconnectedCb);
	MQTT_OnPublished(&mqttClient, mqttPublishedCb);
	MQTT_OnData(&mqttClient, mqttDataCb);

	WIFI_Connect(sysCfg.sta_ssid, sysCfg.sta_pwd, wifiConnectCb);

	INFO("\r\nSystem started ...\r\n");
}
예제 #2
0
void user_init(void)
{
	uart_init(BIT_RATE_9600, BIT_RATE_9600);
	os_install_putc1((void *)uart_putc1);
	avr_uart_override_rx_intr ();

	os_delay_us(1000000);

	CFG_Load();

	MQTT_InitConnection(&mqttClient, sysCfg.mqtt_host, sysCfg.mqtt_port, sysCfg.security);
	MQTT_InitClient(&mqttClient, sysCfg.device_id, sysCfg.mqtt_user, sysCfg.mqtt_pass, sysCfg.mqtt_keepalive, 1);
	MQTT_InitLWT(&mqttClient, "/lwt", "offline", 0, 0);
	MQTT_OnConnected(&mqttClient, mqttConnectedCb);
	MQTT_OnDisconnected(&mqttClient, mqttDisconnectedCb);
	MQTT_OnPublished(&mqttClient, mqttPublishedCb);
	MQTT_OnData(&mqttClient, mqttDataCb);

	WIFI_Connect(sysCfg.sta_ssid, sysCfg.sta_pwd, wifiConnectCb);

	INFO("\r\nSystem started ...\r\n");

	avr_init_task ();
	avr_reg_msg_callback(avr_msg_cb);
}
예제 #3
0
//------------------------------------------------------------------------------------
// MQTT class implementation
//------------------------------------------------------------------------------------
MQTT::MQTT(const char* client_id, const char* host, uint32_t port) :
	onMqttConnectedCb(0)
	,onMqttDisconnectedCb(0)
	,onMqttPublishedCb(0)
	,onMqttDataCb(0)
	,onMqttDataRawCb(0)
{
	// init connections
	MQTT_InitConnection(&mqttClient, host, port);

	// init client
	MQTT_InitClient(&mqttClient, (uint8_t*)client_id, (uint8_t*)"", (uint8_t*)"", 120, 1);

	// init LWT
	MQTT_InitLWT(&mqttClient, (uint8_t*)"/lwt", (uint8_t*)"offline", 0, 0);

	// set user data
	mqttClient.user_data = (void*)this;

	// setup callbacks
	MQTT_OnConnected(&mqttClient, mqttConnectedCb);
	MQTT_OnDisconnected(&mqttClient, mqttDisconnectedCb);
	MQTT_OnPublished(&mqttClient, mqttPublishedCb);
	MQTT_OnData(&mqttClient, mqttDataCb);
	
	MQTT_OnTimeout(&mqttClient, mqttTimeoutCb);
}
void ICACHE_FLASH_ATTR
mqtt_init() {
	MQTT_InitConnection(&mqttClient, config.mqtt_host, config.mqtt_port, config.security);
	MQTT_InitClient(&mqttClient, config.device_id, config.mqtt_user, config.mqtt_pass, config.mqtt_keepalive, 1);
	MQTT_InitLWT(&mqttClient, "/lwt", "offline", 0, 0);
	MQTT_OnConnected(&mqttClient, mqtt_connected_cb);
	MQTT_OnDisconnected(&mqttClient, mqtt_disconnected_cb);
	MQTT_OnPublished(&mqttClient, mqtt_published_cb);
	MQTT_OnData(&mqttClient, mqtt_data_cb);
}
void ICACHE_FLASH_ATTR mqttstart() {
#ifdef MENJINDEBUG
	os_printf("mqtt client starting....");
#endif
	MQTT_InitConnection(&mqttClient, "192.168.1.1", 1883, 0);
	MQTT_InitClient(&mqttClient, "esp_8266", "", "", 10, 1);
	MQTT_InitLWT(&mqttClient, "/lwt", "offline", 0, 0);
	MQTT_OnConnected(&mqttClient, mqttConnectedCb);
	MQTT_OnDisconnected(&mqttClient, mqttDisconnectedCb);
	MQTT_OnPublished(&mqttClient, mqttPublishedCb);
	MQTT_OnData(&mqttClient, mqttDataCb);
}
예제 #6
0
파일: app.c 프로젝트: murphy666/espweather
void ICACHE_FLASH_ATTR mqtt_app_init(){

	MQTT_InitConnection(&mqtt_client, MQTT_SERVER_IP, 1883, 0);
	MQTT_InitClient(&mqtt_client, SERIAL_NUMBER, NULL, NULL, 120, 1);

	MQTT_OnConnected(&mqtt_client, mqttConnectedCb);
	MQTT_OnDisconnected(&mqtt_client, mqttDisconnectedCb);
	MQTT_OnPublished(&mqtt_client, mqttPublishedCb);
	MQTT_OnData(&mqtt_client, mqttDataCb);
	
	//arm mqtt timer
	os_memset(&mqtt_timer,0,sizeof(os_timer_t));
	os_timer_disarm(&mqtt_timer);
	os_timer_setfn(&mqtt_timer, (os_timer_func_t *)mqtt_app_timer_cb, NULL);
}
예제 #7
0
파일: hap.c 프로젝트: andrei-tatar/HAP.esp
static void ICACHE_FLASH_ATTR udp_received(void *arg, char *data, unsigned short len)
{
    struct espconn *udpconn= (struct espconn*)arg;
    if (len > 5 && strncmp(data, "HAP", 3) == 0)
    {
        const char* hapServer = &data[5];
        if (strcmp(settings.serverName, hapServer) != 0)
            return;

        remot_info *info = NULL;
        espconn_get_connection_info(udpconn, &info, 0);

        uint16_t port = (data[3] << 8) | data[4];
        uint32_t address = *(uint32_t*)info->remote_ip;

        if (port == hapPort && address == hapAddress)
            return;

        hapAddress = address;
        hapPort = port;

        static bool inited = false;

        DEBUG_PRINT("[HAP]Discover from "IPSTR":%d\n", IP2STR(&address), port);

        if (inited)
        {
            MQTT_Disconnect(&mqttClient);
            DEBUG_PRINT("[HAP]Disconnect MQTT\n");
        }

        char aux[20];
        os_sprintf(aux, IPSTR, IP2STR(&address));
        MQTT_InitConnection(&mqttClient, aux, hapPort);

        os_sprintf(aux, "client_%d", system_get_chip_id());
        MQTT_InitClient(&mqttClient, aux, settings.mqttUser, settings.mqttPassword, MQTT_KEEPALIVE, 1);
        MQTT_OnConnected(&mqttClient, mqttConnectedCb);
        MQTT_OnDisconnected(&mqttClient, mqttDisconnectedCb);
        MQTT_OnPublished(&mqttClient, mqttPublishedCb);
        MQTT_OnData(&mqttClient, mqttDataCb);
        MQTT_Connect(&mqttClient);

        inited = true;
    }
}
예제 #8
0
파일: user_main.c 프로젝트: Ribster/NoWire
void user_init(void)
{
	uart_init(BIT_RATE_230400, BIT_RATE_230400);
	system_set_os_print(1); // enable/disable operating system printout

	os_sprintf(topic_temp, MQTT_TOPICTEMP, system_get_chip_id());
	os_sprintf(topic_hum, MQTT_TOPICHUM, system_get_chip_id());

	PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, FUNC_GPIO13);


	   ETS_GPIO_INTR_DISABLE(); // Disable gpio interrupts
	   ETS_GPIO_INTR_ATTACH(interrupt_test, 4);
	   PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO4_U, FUNC_GPIO4);
	   gpio_output_set(0, 0, 0, GPIO_ID_PIN(4)); // Set GPIO12 as input
	   GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, BIT(4));
	   gpio_pin_intr_state_set(GPIO_ID_PIN(4), GPIO_PIN_INTR_ANYEDGE);
	   ETS_GPIO_INTR_ENABLE(); // Enable gpio interrupts

	config_load();

	DHTInit(DHT11);

	MQTT_InitConnection(&mqttClient, config.mqtt_host, config.mqtt_port, config.security);
	MQTT_InitClient(&mqttClient, config.device_id, config.mqtt_user, config.mqtt_pass, config.mqtt_keepalive, 1);
	MQTT_InitLWT(&mqttClient, "lwt/", "offline", 0, 0);
	MQTT_OnConnected(&mqttClient, mqtt_connected_cb);
	MQTT_OnDisconnected(&mqttClient, mqtt_disconnected_cb);
	MQTT_OnPublished(&mqttClient, mqtt_published_cb);
	MQTT_OnData(&mqttClient, mqtt_data_cb);

	WIFI_Connect(config.sta_ssid, config.sta_pwd, wifi_connect_cb);

	os_timer_disarm(&dhtTimer);
	os_timer_setfn(&dhtTimer, (os_timer_func_t *)dhtCb, (void *)0);
	os_timer_arm(&dhtTimer, DELAY, 1);

	os_timer_disarm(&hbTimer);
	os_timer_setfn(&hbTimer, (os_timer_func_t *)application_heartbeat, (void *)0);
	os_timer_arm(&hbTimer, 60000, 1);



	INFO("\r\nSystem started ...\r\n");
}
예제 #9
0
void ICACHE_FLASH_ATTR
mqtt_client_init()
{
  MQTT_Init(&mqttClient, flashConfig.mqtt_host, flashConfig.mqtt_port, 0, flashConfig.mqtt_timeout,
    flashConfig.mqtt_clientid, flashConfig.mqtt_username, flashConfig.mqtt_password,
    flashConfig.mqtt_keepalive);

  MQTT_OnConnected(&mqttClient, mqttConnectedCb);
  MQTT_OnDisconnected(&mqttClient, mqttDisconnectedCb);
  MQTT_OnPublished(&mqttClient, mqttPublishedCb);
  MQTT_OnData(&mqttClient, mqttDataCb);

  // Don't connect now, wait for a wifi status change callback
  //if (flashConfig.mqtt_enable && strlen(flashConfig.mqtt_host) > 0)
  //  MQTT_Connect(&mqttClient);

  wifiAddStateChangeCb(wifiStateChangeCb);
}
예제 #10
0
파일: user_main.c 프로젝트: theater/ESP8266
//Main routine. Initialize stdout, the I/O and the webserver and we're done.
void user_init(void) {
// HTTPD
	stdoutInit();
	ioInit();
	httpdInit(builtInUrls, 80);
//MQTT
	uart_init(115200, 115200);
	CFG_Load();
	sleepms(1000);

	MQTT_InitConnection(&mqttClient, sysCfg.mqtt_host, sysCfg.mqtt_port, SEC_NONSSL);
	//MQTT_InitConnection(&mqttClient, "192.168.11.122", 1880, 0);
	MQTT_InitClient(&mqttClient, sysCfg.device_id, sysCfg.mqtt_user, sysCfg.mqtt_pass, sysCfg.mqtt_keepalive, 1);
	//MQTT_InitClient(&mqttClient, "client_id", "user", "pass", 120, 1);

//	MQTT_InitLWT(&mqttClient, "/lwt", "offline", 0, 0);
	MQTT_OnConnected(&mqttClient, mqttConnectedCb);
	MQTT_OnDisconnected(&mqttClient, mqttDisconnectedCb);
	MQTT_OnPublished(&mqttClient, mqttPublishedCb);
	MQTT_OnData(&mqttClient, mqttDataCb);

	INFO("device_ID:%s\r\n",sysCfg.device_id);
	INFO("MQTTHOST:%s\r\n",sysCfg.mqtt_host);
//DS18B20 timers
	os_timer_disarm(&ds18b20_timer);
	os_timer_setfn(&ds18b20_timer, (os_timer_func_t *)ds18b20_cb, (void *)0);
	os_timer_arm(&ds18b20_timer, DELAY, 1);

//NTP timers
		ntp_get_time();
		os_timer_disarm(&NTP_timer);
		os_timer_setfn(&NTP_timer, (os_timer_func_t *)ntp_get_time, (void *)0);
		os_timer_arm(&NTP_timer, NTPDELAY, 1);

// initialize GPIO2
	PIN_FUNC_SELECT(PIN_GPIO2_MUX, PIN_GPIO2_FUNC);
	GPIO_OUTPUT_SET(PIN_GPIO2, 0);
	INFO("GPIO2 set to OFF\r\n");

	WIFI_Connect(sysCfg.sta_ssid, sysCfg.sta_pwd, wifiConnectCb);

	os_printf("\nReady\n");
}
예제 #11
0
void ICACHE_FLASH_ATTR u_mqtt_init()
{
	CFG_Load();

	/*
	 * Original, old call with SSID and Passwd included.
	 * WIFI_Connect(sysCfg.sta_ssid, sysCfg.sta_pwd, wifiConnectCb);
	 *
	 * NOTE:- Our WiFi-Connect callback calls the MQTT_Connect function,
	 *        which in turn will call the mqttConnectCb() function when
	 *        communications with the MQTT servcer are established.
	 */
	WIFI_Connect(wifiConnectCb);

	MQTT_InitConnection(&mqttClient, sysCfg.mqtt_host, sysCfg.mqtt_port, sysCfg.security);
	MQTT_InitClient(&mqttClient, sysCfg.device_id, sysCfg.mqtt_user, sysCfg.mqtt_pass, sysCfg.mqtt_keepalive, 1);
	MQTT_InitLWT(&mqttClient, "/lwt", "offline", 0, 0);
	MQTT_OnConnected(&mqttClient, mqttConnectedCb);
	MQTT_OnDisconnected(&mqttClient, mqttDisconnectedCb);
	MQTT_OnPublished(&mqttClient, mqttPublishedCb);
	MQTT_OnData(&mqttClient, mqttDataCb);
}
예제 #12
0
void user_init(void)
{
	//uart_init(BIT_RATE_115200, BIT_RATE_115200);
	uart_init(BIT_RATE_9600, BIT_RATE_115200);
	os_delay_us(1000000);

	CFG_Load();

	//MQTT_InitConnection(&mqttClient, sysCfg.mqtt_host, sysCfg.mqtt_port, sysCfg.security);
	MQTT_InitConnection(&mqttClient, "user.jdaiot.com", 1883, 0);

	//MQTT_InitClient(&mqttClient, sysCfg.device_id, sysCfg.mqtt_user, sysCfg.mqtt_pass, sysCfg.mqtt_keepalive, 1);
	MQTT_InitClient(&mqttClient, "g500001", "LASS", "LaSS2015", 120, 1);

	MQTT_InitLWT(&mqttClient, "/lwt", "offline", 0, 0);
	MQTT_OnConnected(&mqttClient, mqttConnectedCb);
	MQTT_OnDisconnected(&mqttClient, mqttDisconnectedCb);
	MQTT_OnPublished(&mqttClient, mqttPublishedCb);
	MQTT_OnData(&mqttClient, mqttDataCb);

	WIFI_Connect(sysCfg.sta_ssid, sysCfg.sta_pwd, wifiConnectCb);
  //// modified for LASS
	system_os_task(recvTask, recvTaskPrio, recvTaskQueue, recvTaskQueueLen);
  tick=0;
  refreshTime=10;
   // turn off timer
   os_timer_disarm(&tmr0);
   //
   // set the timer call back function
   //
   os_timer_setfn(&tmr0, tsr0, &mqttClient);
   //
   // turn timer on to trigger each .5 second
   //
   os_timer_arm(&tmr0, 5000, 1); //every 5 second


	INFO("\r\nSystem started ...\r\n");
}
예제 #13
0
void user_init(void)
{
	uart_init(BIT_RATE_115200, BIT_RATE_115200);
	os_delay_us(1000000);

	CFG_Load();

	MQTT_InitConnection(&mqttClient, sysCfg.mqtt_host, sysCfg.mqtt_port, sysCfg.security);
	//MQTT_InitConnection(&mqttClient, "192.168.11.122", 1880, 0);

	MQTT_InitClient(&mqttClient, sysCfg.device_id, sysCfg.mqtt_user, sysCfg.mqtt_pass, sysCfg.mqtt_keepalive, 1);
	//MQTT_InitClient(&mqttClient, "client_id", "user", "pass", 120, 1);

	MQTT_InitLWT(&mqttClient, "/lwt", "offline", 0, 0);
	MQTT_OnConnected(&mqttClient, mqttConnectedCb);
	MQTT_OnDisconnected(&mqttClient, mqttDisconnectedCb);
	MQTT_OnPublished(&mqttClient, mqttPublishedCb);
	MQTT_OnData(&mqttClient, mqttDataCb);

	WIFI_Connect(sysCfg.sta_ssid, sysCfg.sta_pwd, wifiConnectCb);

	INFO("\r\nSystem started ...\r\n");
}
예제 #14
0
파일: app.c 프로젝트: flo90/esp-ginx
void ICACHE_FLASH_ATTR mqtt_app_init(){
	

	//set relays
	int i;
	for(i=0;i<relay_count();i++){
		relays[i].id=i;		
		os_strcpy(relays[i].topic,"relay/");
		os_strcat(relays[i].topic,SERIAL_NUMBER"/");
		os_strcati(relays[i].topic,i);
	}

	//register listeners 
	relay_register_listener(mqtt_relay_change_cb);

	MQTT_InitConnection(&mqtt_client, MQTT_SERVER_IP, 1883, 0);
	MQTT_InitClient(&mqtt_client, SERIAL_NUMBER, NULL, NULL, 120, 1);

	MQTT_OnConnected(&mqtt_client, mqttConnectedCb);
	MQTT_OnDisconnected(&mqtt_client, mqttDisconnectedCb);
	MQTT_OnPublished(&mqtt_client, mqttPublishedCb);
	MQTT_OnData(&mqtt_client, mqttDataCb);
	
	//arm mqtt timer
	os_memset(&mqtt_timer,0,sizeof(os_timer_t));
	os_timer_disarm(&mqtt_timer);
	os_timer_setfn(&mqtt_timer, (os_timer_func_t *)mqtt_app_timer_cb, NULL);
	os_timer_arm(&mqtt_timer, 2000, 1);

	//arm sensor read timer
	os_memset(&sensor_read_timer,0,sizeof(os_timer_t));
	os_timer_disarm(&sensor_read_timer);
	os_timer_setfn(&sensor_read_timer, (os_timer_func_t *)sensor_read_timer_cb, NULL);
	os_timer_arm(&sensor_read_timer, 5000, 1);

}
예제 #15
0
void user_init(void)
{
	int access_point = 1;

	uart_init(BIT_RATE_115200, BIT_RATE_115200);
	os_delay_us(1000000);

	if(access_point) {

		wifi_set_opmode(STATIONAP_MODE);

	} else {

		gpio_init();
		PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_GPIO1);
		gpio_output_set(0, 0, (1 << pin), 0);

    CFG_Load();

    MQTT_InitConnection(&mqttClient, sysCfg.mqtt_host, sysCfg.mqtt_port, sysCfg.security);
    //MQTT_InitConnection(&mqttClient, "192.168.11.122", 1880, 0);

    MQTT_InitClient(&mqttClient, sysCfg.device_id, sysCfg.mqtt_user, sysCfg.mqtt_pass, sysCfg.mqtt_keepalive, 1);
    //MQTT_InitClient(&mqttClient, "client_id", "user", "pass", 120, 1);

    MQTT_InitLWT(&mqttClient, "/lwt", "offline", 0, 0);
    MQTT_OnConnected(&mqttClient, mqttConnectedCb);
    MQTT_OnDisconnected(&mqttClient, mqttDisconnectedCb);
    MQTT_OnPublished(&mqttClient, mqttPublishedCb);
    MQTT_OnData(&mqttClient, mqttDataCb);

    WIFI_Connect(sysCfg.sta_ssid, sysCfg.sta_pwd, wifiConnectCb);

    INFO("\r\nSystem started ...\r\n");
	}
}
예제 #16
0
//Main routine
void ICACHE_FLASH_ATTR user_init(void) {

	stdoutInit();	
	os_delay_us(100000);
	CFG_Load();
	ioInit();
	
	WIFI_Connect(wifiConnectCb);
	
	httpdInit(builtInUrls, sysCfg.httpd_port);
	
	if(sysCfg.ntp_enable==1) {
		sntp_init(sysCfg.ntp_tz);	//timezone
	}
	
	if(sysCfg.mqtt_enable==1) {
		MQTT_InitConnection(&mqttClient, (uint8_t *)sysCfg.mqtt_host, sysCfg.mqtt_port, sysCfg.mqtt_use_ssl );
		MQTT_InitClient(&mqttClient, (uint8_t *)sysCfg.mqtt_devid, (uint8_t *)sysCfg.mqtt_user, (uint8_t *)sysCfg.mqtt_pass, sysCfg.mqtt_keepalive,1);
		MQTT_OnConnected(&mqttClient, mqttConnectedCb);
		MQTT_OnDisconnected(&mqttClient, mqttDisconnectedCb);
		MQTT_OnPublished(&mqttClient, mqttPublishedCb);		
		MQTT_OnData(&mqttClient, mqttDataCb);
		
	}
	
	if(sysCfg.sensor_dht22_enable) 
		DHTInit(SENSOR_DHT22, 30000);
		
	if(sysCfg.sensor_ds18b20_enable) 
		ds_init(30000);

	broadcastd_init();

	thermostat_init(30000);

/*
	//Netbios to set the name
	struct softap_config wiconfig;
	os_memset(netbios_name, ' ', sizeof(netbios_name)-1);
	if(wifi_softap_get_config(&wiconfig)) {
		int i;
		for(i = 0; i < sizeof(netbios_name)-1; i++) {
			if(wiconfig.ssid[i] < ' ') break;
			netbios_name[i] = wiconfig.ssid[i];
		};
	}
	else os_sprintf(netbios_name, "ESP8266");
	netbios_name[sizeof(netbios_name)-1]='\0';
	netbios_init();
*/
		
	os_printf("\nRelay Board Ready\n");	
	os_printf("Free heap size:%d\n",system_get_free_heap_size());

	
#ifdef CGIPWM_H	
	//Mind the PWM pin!! defined in pwm.h
	duty=0;
	pwm_init( 50, &duty);
	pwm_set_duty(duty, 0);
    pwm_start();
#endif
	
	//OLEDInit();
	
}
예제 #17
0
파일: user_main.c 프로젝트: theater/ESP8266
//Main routine. Initialize stdout, the I/O and the webserver and we're done.
void user_init(void) {
// my stuff
	dBR_BOILER_SET=65; // default setting 65C boiler temperature on reboot
	dBR_TEMP_ROOM_SET=18; // default setting 18C room temperature on reboot
	dBR_HUMIDITY_SET=60; // default setting 65% humidity target on reboot
	dBR_MODE=2; // default BR MODE is AUTO
	dDEVICE_MODE=1; // This mode defines if device uses remote (MQTT) management or uses local logics - 0 for remote, 1 for local mode. DEFAULT is 0 - remote

// HTTPD
	stdoutInit();
	ioInit();
	httpdInit(builtInUrls, 80);
//MQTT
	uart_init(115200, 115200);
	CFG_Load();
	sleepms(1000);

	MQTT_InitConnection(&mqttClient, sysCfg.mqtt_host, sysCfg.mqtt_port, SEC_NONSSL);
	//MQTT_InitConnection(&mqttClient, "192.168.11.122", 1880, 0);
	MQTT_InitClient(&mqttClient, sysCfg.device_id, sysCfg.mqtt_user, sysCfg.mqtt_pass, sysCfg.mqtt_keepalive, 1);
	//MQTT_InitClient(&mqttClient, "client_id", "user", "pass", 120, 1);

//	MQTT_InitLWT(&mqttClient, "/lwt", "offline", 0, 0);
	MQTT_OnConnected(&mqttClient, mqttConnectedCb);
	MQTT_OnDisconnected(&mqttClient, mqttDisconnectedCb);
	MQTT_OnPublished(&mqttClient, mqttPublishedCb);
	MQTT_OnData(&mqttClient, mqttDataCb);

	INFO("device_ID:%s\r\n",sysCfg.device_id);
	INFO("MQTTHOST:%s\r\n",sysCfg.mqtt_host);
//DS18B20 timers
	os_timer_disarm(&ds18b20_timer);
	os_timer_setfn(&ds18b20_timer, (os_timer_func_t *)ds18b20_cb, (void *)0);
	os_timer_arm(&ds18b20_timer, DELAY, 1);
// DHT22 initialize
	DHTInit(DHT22, DELAY);
	os_timer_disarm(&dht22_timer);
	os_timer_setfn(&dht22_timer, (os_timer_func_t *)dht22_cb, (void *)0);
	os_timer_arm(&dht22_timer, DELAY, 1);
// INPUT PIN initialize
	ETS_GPIO_INTR_DISABLE(); // Disable gpio interrupts
	ETS_GPIO_INTR_ATTACH(read_input_pin, 13); // GPIO13 interrupt handler
	PIN_FUNC_SELECT(PIN_GPIO13_MUX, PIN_GPIO13_FUNC);
	gpio_output_set(0, 0, 0, BIT13); // Set GPIO13 as input
	PIN_PULLUP_EN(PIN_GPIO13_MUX); // Enable pullup
	GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, BIT(13)); // Clear GPIO12 status
	gpio_pin_intr_state_set(GPIO_ID_PIN(13), GPIO_PIN_INTR_NEGEDGE); // Interrupt on NEGATIVE GPIO13 edge
	ETS_GPIO_INTR_ENABLE(); // Enable gpio interrupts
//	INFO("Input pin INITIALIZED ! ! !");

// initialize GPIO12
	PIN_FUNC_SELECT(PIN_GPIO12_MUX, PIN_GPIO12_FUNC);
	GPIO_OUTPUT_SET(PIN_GPIO12, 0);
//	INFO("GPIO12 set to OFF\r\n");
// initialize GPIO5
	GPIO_OUTPUT_SET(PIN_GPIO5, 0);
//	INFO("GPIO5 set to OFF\r\n");
// initialize GPIO14
	PIN_FUNC_SELECT(PIN_GPIO14_MUX, PIN_GPIO14_FUNC);
	GPIO_OUTPUT_SET(PIN_GPIO14, 0);
//	INFO("GPIO14 set to OFF\r\n");
	WIFI_Connect(sysCfg.sta_ssid, sysCfg.sta_pwd, wifiConnectCb);

	os_printf("\nReady\n");
}