Esempio n. 1
0
void ICACHE_FLASH_ATTR mod_finger_init() {
	finger_set_timeout_callback(finger_timeout);
	webserver_register_handler_callback(FINGER_URL, finger_handler);
	device_register(UART, 0, FINGER_URL, finger_init, NULL);
	
	setTimeout(finger_start_read, NULL, 2000);
}
Esempio n. 2
0
void ICACHE_FLASH_ATTR mod_rgb_init() {
	uint8 i;
	for (i=0; i<MOD_RGB_URLs_COUNT; i++) {
		webserver_register_handler_callback(MOD_RGB_URLs[i], mod_rgb_handler);
	}
	device_register(I2C, MOD_RGB_ID, MOD_RGB_URL, NULL, NULL);
}
Esempio n. 3
0
void ICACHE_FLASH_ATTR user_events_init() {
	wifi_set_event_handler_cb(user_event_wifi);
	webserver_register_handler_callback(EVENTS_URL, events_handler);
#if EVENTS_SYS_TIMER
	setInterval(user_event_system_timer, NULL, 1000);
#endif
}
Esempio n. 4
0
void ICACHE_FLASH_ATTR mod_emtr_init() {
	emtr_set_timeout_callback(emtr_timeout);
	webserver_register_handler_callback(EMTR_URL, emtr_handler);
	device_register(UART, 0, EMTR_URL, emtr_init, emtr_down);
	
	setTimeout(emtr_calibration_read, NULL, 1500);
	setTimeout(emtr_events_read, NULL, 2000);
	setTimeout(emtr_start_read, NULL, 2500);
}
Esempio n. 5
0
void ICACHE_FLASH_ATTR mod_led_8x8_rgb_init() {
	spi_led_8x8_rgb_init();
	
	preferences_get(MOD_LED8x8RGB, mod_led_8x8_rgb_parse);
	led_8x8_rgb_set_dimensions(mod_led_8x8_cols, mod_led_8x8_rows);
	
	webserver_register_handler_callback(MOD_LED_8x8_RGB_URL, mod_led_8x8_rgb_handler);
	device_register(SPI, 0, MOD_LED8x8RGB, MOD_LED_8x8_RGB_URL, NULL, NULL);
}
Esempio n. 6
0
/******************************************************************************
 * FunctionName : user_init
 * Description  : entry of user application, init user function here
 * Parameters   : none
 * Returns	    : none
 *******************************************************************************/
void ICACHE_FLASH_ATTR user_init(void) {
	system_init_done_cb(user_init_done);
	
	// UART Devices
	mod_rfid_init();
	mod_finger_init();
	mod_emtr_init();
	devices_init();
	
	debug("\n\nSDK version: %s\n", system_get_sdk_version());
	debug("Firmware: %s\n", config_firmware_bin());
	memory_info();
	
	user_config_init();
	user_config_load();
#if SSL_ENABLE
	user_config_load_private_key();
	user_config_load_certificate();
#endif
	
	user_events_init();
	
	// Scan
	webserver_register_handler_callback(DEVICES_URL,   devices_handler);
	webserver_register_handler_callback(WIFI_SCAN_URL, wifi_scan_handler);
	
	// Native Devices
	user_button_init();
	user_relay_init();
	user_adc_init();
	
	// I2C Devices
	i2c_master_gpio_init();
	mod_rgb_init();
	mod_tc_mk2_init();
	mod_io2_init();
	mod_irda_init();
	
	// SPI Devices
	mod_led_8x8_rgb_init();
	
	webserver_init();
}
Esempio n. 7
0
void ICACHE_FLASH_ATTR mod_irda_init() {
	uint8 addr = 0;
	i2c_status status;
	irda_init(&addr, &status);
	
	uint8 i;
	for (i=0; i<MOD_IRDA_URLs_COUNT; i++) {
		webserver_register_handler_callback(MOD_IRDA_URLs[i], mod_irda_handler);
	}
	
	device_register(I2C, MOD_IRDA_ID, MOD_IRDA_URL);
}
Esempio n. 8
0
void ICACHE_FLASH_ATTR mod_tc_mk2_init() {
	uint8 addr = 0;
	i2c_status status;
	tc_init(&addr, &status);
	
	uint8 i;
	for (i=0; i<MOD_TC_MK2_URLs_COUNT; i++) {
		webserver_register_handler_callback(MOD_TC_MK2_URLs[i], mod_tc_mk2_handler);
	}
	
	device_register(I2C, MOD_TC_MK2_ID, MOD_TC_MK2_URL, NULL);
	
	if (status == I2C_OK) {
		mod_tc_mk2_timer_init();
	}
}
Esempio n. 9
0
void ICACHE_FLASH_ATTR user_switch1_init() {
	uint8 i;
	
	for (i=0; i<SWITCH_COUNT; i++) {
		switch1_hardware[i].id = i;
		PIN_FUNC_SELECT(switch1_hardware[i].gpio.gpio_name, switch1_hardware[i].gpio.gpio_func);
		
		if (switch1_hardware[i].type == SWITCH1_SWITCH) {
			gpio_output_set(0, 0, 0, GPIO_ID_PIN(switch1_hardware[i].gpio.gpio_id));
			setInterval(switch1_toggle, &switch1_hardware[i], 10);
		}
	}
	
	webserver_register_handler_callback(SWITCH1_URL, switch1_handler);
	device_register(NATIVE, 0, SWITCH1_URL, switch1_init, switch1_down);
}
/* Main Initialization file
 * true: init HW & timer, else web service only (listener)
 */
void ICACHE_FLASH_ATTR mb_pcd8544_init() {
	bool isStartReading = false;
	mb_p_pcd8544_config = (mb_pcd8544_config_t *)p_user_app_config_data->pcd8544;		// set proper structure in app settings
	
	webserver_register_handler_callback(MB_PCD8544_URL, mb_pcd8544_handler);
	device_register(NATIVE, 0, MB_PCD8544_DEVICE, MB_PCD8544_URL, NULL, NULL);
	
	if (!user_app_config_is_config_valid())
	{
		mb_p_pcd8544_config->resetPin = MB_PCD8544_RESET_PIN_DEFAULT;
		mb_p_pcd8544_config->scePin = MB_PCD8544_SCE_PIN_DEFAULT;
		mb_p_pcd8544_config->dcPin = MB_PCD8544_DC_PIN_DEFAULT;
		mb_p_pcd8544_config->sdinPin = MB_PCD8544_SDIN_PIN_DEFAULT;
		mb_p_pcd8544_config->sclkPin = MB_PCD8544_SCLK_PIN_DEFAULT;
	}

	mb_pcd8544_hw_init();
}
Esempio n. 11
0
void ICACHE_FLASH_ATTR user_switch2_init() {
	uint8 i;
	
	for (i=0; i<SWITCH_COUNT; i++) {
		switch2_hardware[i].id = i;
		PIN_FUNC_SELECT(switch2_hardware[i].gpio.gpio_name, switch2_hardware[i].gpio.gpio_func);
		switch2_hardware[i].state = GPIO_INPUT_GET(GPIO_ID_PIN(switch2_hardware[i].gpio.gpio_id));
		
		if (switch2_hardware[i].type == SWITCH2_SWITCH) {
			gpio_output_set(0, 0, 0, GPIO_ID_PIN(switch2_hardware[i].gpio.gpio_id));
			setInterval(switch2_toggle, &switch2_hardware[i], 10);
		}
	}
	
	preferences_get(SWITCH2_STR, switch2_parse);
	
	webserver_register_handler_callback(SWITCH2_URL, switch2_handler);
	device_register(NATIVE, 0, SWITCH2_STR, SWITCH2_URL, switch2_init, switch2_down);
}
Esempio n. 12
0
void ICACHE_FLASH_ATTR user_dimmer_init() {
	uint8 addr = 0;
	i2c_status status;
	#ifdef DIMMER_REV_A   // DIMMER - Revision A
	stdout_disable();
	#endif
	dimmer_init(&addr, &status);
	
	uint8 i;
	for (i=0; i<DIMMER_URLs_COUNT; i++) {
		webserver_register_handler_callback(DIMMER_URLs[i], dimmer_handler);
	}
	
	device_register(I2C, DIMMER_ID, DIMMER_URL, NULL, NULL);
	
	if (status == I2C_OK) {
		dimmer_timer_init();
	}
}
Esempio n. 13
0
void ICACHE_FLASH_ATTR user_button_init() {
	struct single_key_param *key = NULL;
	key = key_init_single(
		GPIO_ID_PIN(0), 
		PERIPHS_IO_MUX_GPIO0_U,
		FUNC_GPIO0,
		button_press,
		button_short_release,
		button_long_press,
		button_long_release
	);
	
	if (key == NULL) {
		debug("BUTTON: Initialization Fail\n");
		return;
	}
	
	webserver_register_handler_callback(BUTTON_URL, button_handler);
	device_register(NATIVE, 0, BUTTON_URL, NULL, NULL);
}
Esempio n. 14
0
void ICACHE_FLASH_ATTR user_events_init() {
	wifi_set_event_handler_cb(user_event_wifi);
	webserver_register_handler_callback(EVENTS_URL, events_handler);
}
Esempio n. 15
0
void ICACHE_FLASH_ATTR user_adc_init() {
	webserver_register_handler_callback(ADC_URL, adc_handler);
	device_register(NATIVE, 0, ESP8266, ADC_URL, NULL, NULL);
	user_adc_timer_init();
}
Esempio n. 16
0
/******************************************************************************
 * FunctionName : user_init
 * Description  : entry of user application, init user function here
 * Parameters   : none
 * Returns	    : none
 *******************************************************************************/
void ICACHE_FLASH_ATTR user_init(void) {
	system_init_done_cb(user_init_done);
	
//	wifi_set_phy_mode(PHY_MODE_11N);
//	wifi_set_sleep_type(MODEM_SLEEP_T);
	
#if UART0_SWAP
	stdout_disable();
	system_uart_swap();
#endif
#if UART1_ENABLE
	stdout_init(UART1);
#endif

	// UART Devices
#if DEVICE == PLUG
	user_plug_init();
#endif
#if DEVICE == SWITCH1
	user_switch1_init();
#endif
#if DEVICE == SWITCH2
	user_switch2_init();
#endif
#if MOD_RFID_ENABLE
	mod_rfid_init();
#endif
#if MOD_FINGER_ENABLE
	mod_finger_init();
#endif
#if MOD_EMTR_ENABLE
	mod_emtr_init();
#endif
	devices_init();
	
	debug("\n\nSDK version: %s\n", system_get_sdk_version());
	debug("Firmware: %s\n", config_firmware_bin());
	memory_info();
	
	user_config_init();
	user_config_load();
#if SSL_ENABLE
	user_config_load_private_key();
	user_config_load_certificate();
#endif
	
	user_events_init();
	
	// Scan
	webserver_register_handler_callback(DEVICES_URL,   devices_handler);
	webserver_register_handler_callback(WIFI_SCAN_URL, wifi_scan_handler);
	
	// Native Devices
#if BUTTON_ENABLE
	user_button_init();
#endif
#if RELAY_ENABLE
	user_relay_init();
#endif
#if ADC_ENABLE
	user_adc_init();
#endif
#if BATTERY_ENABLE
	user_battery_init();
#endif
	
#if I2C_ENABLE	
	// I2C Devices
	i2c_master_gpio_init();
#if MOD_RGB_ENABLE
	mod_rgb_init();
#endif
#if MOD_TC_MK2_ENABLE
	mod_tc_mk2_init();
#endif
#if MOD_IO2_ENABLE
	mod_io2_init();
#endif
#if MOD_IRDA_ENABLE
	mod_irda_init();
#endif
#if DEVICE == DIMMER
	user_dimmer_init();
#endif
#endif
	
	// SPI Devices
#if MOD_LED_8x8_RGB_ENABLE
	mod_led_8x8_rgb_init();
#endif
#if DEVICE == BADGE
	badge_init();
#endif
	
	key_init();
	webserver_init();
}
Esempio n. 17
0
/******************************************************************************
 * FunctionName : user_init
 * Description  : entry of user application, init user function here
 * Parameters   : none
 * Returns	    : none
 *******************************************************************************/
void ICACHE_FLASH_ATTR user_init(void) {
    system_init_done_cb(user_init_done);

    // UART Devices
#if MOD_RFID_ENABLE
    mod_rfid_init();
#endif
#if MOD_FINGER_ENABLE
    mod_finger_init();
#endif
#if MOD_EMTR_ENABLE
    mod_emtr_init();
#endif
    devices_init();

    debug("\n\nSDK version: %s\n", system_get_sdk_version());
    debug("Firmware: %s\n", config_firmware_bin());
    memory_info();

    user_config_init();
    user_config_load();
#if SSL_ENABLE
    user_config_load_private_key();
    user_config_load_certificate();
#endif

    user_events_init();

    // Scan
    webserver_register_handler_callback(DEVICES_URL,   devices_handler);
    webserver_register_handler_callback(WIFI_SCAN_URL, wifi_scan_handler);

    // Native Devices
#if BUTTON_ENABLE
    user_button_init();
#endif
#if RELAY_ENABLE
    user_relay_init();
#endif
#if ADC_ENABLE
    user_adc_init();
#endif
#if BATTERY_ENABLE
    user_battery_init();
#endif

    // I2C Devices
    i2c_master_gpio_init();
#if MOD_RGB_ENABLE
    mod_rgb_init();
#endif
#if MOD_TC_MK2_ENABLE
    mod_tc_mk2_init();
#endif
#if MOD_IO2_ENABLE
    mod_io2_init();
#endif
#if MOD_IRDA_ENABLE
    mod_irda_init();
#endif

    // SPI Devices
#if MOD_LED_8x8_RGB_ENABLE
    mod_led_8x8_rgb_init();
#endif

    key_init();
    webserver_init();
}
Esempio n. 18
0
void ICACHE_FLASH_ATTR user_events_init() {
	wifi_set_station_connected_callback(user_event_connect);
	webserver_register_handler_callback(EVENTS_URL, events_handler);
}
Esempio n. 19
0
void ICACHE_FLASH_ATTR user_relay_init() {
	PIN_FUNC_SELECT(relay_hardware.gpio_name, relay_hardware.gpio_func);
	relay_state = GPIO_INPUT_GET(GPIO_ID_PIN(relay_hardware.gpio_id));
	webserver_register_handler_callback(RELAY_URL, relay_handler);
	device_register(NATIVE, 0, ESP8266, RELAY_URL, NULL, NULL);
}