Esempio n. 1
0
LOCAL void ICACHE_FLASH_ATTR finger_save_done(finger_packet *packet) {
	finger_current_mode = FINGER_READ;
	
	if (packet->data[0] != FINGER_OK) {
		finger_default(packet);
		finger_frech_params();
		finger_start_read();
		return;
	}
	
	char response[WEBSERVER_MAX_VALUE];
	char data[WEBSERVER_MAX_VALUE];
	json_status(
		response, MOD_FINGER, 
		"New fingerprint stored",
		json_sprintf(data, "\"ID\" : %d", finger_first_free_id())
	);
	
#if FINGER_DEBUG
	debug("FINGER: Stored: ID = %d\n", finger_first_free_id());
#endif
	
	user_event_raise(FINGER_URL, response);
	finger_frech_params();
	finger_start_read();
}
Esempio n. 2
0
LOCAL void ICACHE_FLASH_ATTR finger_find_done(finger_packet *packet) {
	if (packet->data[0] != FINGER_OK) {
		finger_default(packet);
		finger_start_read();
		return;
	}
	
	uint16 id = packet->data[1]*256 + packet->data[2];
	uint16 score = packet->data[3]*256 + packet->data[4];
	
	char response[WEBSERVER_MAX_VALUE];
	char data[WEBSERVER_MAX_VALUE];
	json_status(
		response, MOD_FINGER, "Match found",
		json_sprintf(
			data,
			"\"Match\" : {\"ID\" : %d, \"Score\" : %d}",
			id,
			score
		)
	);
	
#if FINGER_DEBUG
	debug("FINGER: Match: ID = %d, Score = %d\n", id, score);
#endif
	
	user_event_raise(FINGER_URL, response);
	finger_start_read();
}
Esempio n. 3
0
void ICACHE_FLASH_ATTR user_event_connect() {
#if EVENTS_DEBUG
	debug("EVENTS: Station connected\n");
	debug("Free heap: %d\n\n", system_get_free_heap_size());
#endif
	char status[WEBSERVER_MAX_VALUE];
	user_event_raise(NULL, json_status(status, ESP8266, CONNECTED, NULL));
}
Esempio n. 4
0
void ICACHE_FLASH_ATTR user_event_reconnect() {
#if EVENTS_DEBUG
	debug("EVENTS: Reconnect station\n");
#endif
	char status[WEBSERVER_MAX_VALUE];
	user_event_raise(NULL, json_status(status, ESP8266, RECONNECT, NULL));
	websocket_close_all(RECONNECT, NULL);
	long_poll_close_all();
}
Esempio n. 5
0
char ICACHE_FLASH_ATTR *json_data(char *buffer, const char *device, const char *status, const char *data, const char *extra) {
	uint32 extra_len = extra == NULL ? 0 : os_strlen(extra);
	char data_buff[os_strlen(data) + extra_len + 20];
	return json_status(
		buffer, device, status, 
		json_sprintf(
			data_buff, 
			"\"Data\" : {%s}%s%s", 
			data,
			extra_len == 0 ? "" : ", ",
			extra_len == 0 ? "" : extra
		)
	);
}
Esempio n. 6
0
void ICACHE_FLASH_ATTR user_event_system_timer() {
	char status[WEBSERVER_MAX_RESPONSE_LEN];
	char data[WEBSERVER_MAX_RESPONSE_LEN];
	user_event_raise(
		NULL, 
		json_status(
			status, ESP8266, "SysTimer", 
			json_sprintf(
				data,
				"\"Timer\": %d",
				system_get_time()
			)
		)
	);
}
/* Make response */
LOCAL void ICACHE_FLASH_ATTR mb_pcd8544_set_response(char *response, bool is_fault, uint8 req_type) {
	char data_str[WEBSERVER_MAX_RESPONSE_LEN];
	char full_device_name[USER_CONFIG_USER_SIZE];
	
	mb_make_full_device_name(full_device_name, MB_PCD8544_DEVICE, USER_CONFIG_USER_SIZE);
	
	MB_PCD8544_DEBUG("PCD8544:Resp.prep:%d;isFault:%d:\n", req_type, is_fault)
	
	// Sensor fault
	if (is_fault) {
		json_error(response, full_device_name, DEVICE_STATUS_FAULT, NULL);
	}
	// POST request - status & config only
	else if (req_type == MB_REQTYPE_POST) {
		json_status(response, full_device_name, DEVICE_STATUS_OK, 
			json_sprintf(
				data_str, 
				"\"Config\" : {"
					"\"Reset_pin\": %d,"
					"\"Sce_pin\":%d,"
					"\"Dc_pin\": %d,"
					"\"Sdin_pin\": %d,"
					"\"Sclk_pin\": %d"
				"}",
				mb_p_pcd8544_config->resetPin,
				mb_p_pcd8544_config->scePin,
				mb_p_pcd8544_config->dcPin,
				mb_p_pcd8544_config->sdinPin,
				mb_p_pcd8544_config->sclkPin
			)
		);

	// normal event measurement
	} else {
		json_data(
			response, full_device_name, DEVICE_STATUS_OK, 
				json_sprintf(data_str,
					"\"pcd8544\": {"
					"}"
				),
				NULL
		);
	}
}
Esempio n. 8
0
void ICACHE_FLASH_ATTR mod_led_8x8_rgb_scroll_done() {
	char status[WEBSERVER_MAX_VALUE];
	user_event_raise(MOD_LED_8x8_RGB_URL, json_status(status, MOD_LED8x8RGB, DONE, NULL));
}