コード例 #1
0
ファイル: user_switch1.c プロジェクト: lvjh/ESP8266
void ICACHE_FLASH_ATTR switch1_handler(
	struct espconn *pConnection, 
	request_method method, 
	char *url, 
	char *data, 
	uint16 data_len, 
	uint32 content_len, 
	char *response,
	uint16 response_len
) {
	struct jsonparse_state parser;
	int type;
	uint16 state = 0;
	
	if (method == POST && data != NULL && data_len != 0) {
		jsonparse_setup(&parser, data, data_len);
		
		while ((type = jsonparse_next(&parser)) != 0) {
			if (type == JSON_TYPE_PAIR_NAME) {
				if (jsonparse_strcmp_value(&parser, "Relay") == 0) {
					jsonparse_next(&parser);
					jsonparse_next(&parser);
					state = jsonparse_get_value_as_int(&parser);
					user_switch1_set(0, state);
				}
			}
		}
	}
	
	user_switch1_state(response);
}
コード例 #2
0
ファイル: user_switch1.c プロジェクト: toome123/ESP8266
void ICACHE_FLASH_ATTR switch1_handler(
    struct espconn *pConnection,
    request_method method,
    char *url,
    char *data,
    uint16 data_len,
    uint32 content_len,
    char *response,
    uint16 response_len
) {
    if (method == POST && data != NULL && data_len != 0) {
        if (switch1_parse(data, data_len)) {
            switch1_preferences_set();
        }
    }

    user_switch1_state(response);
}
コード例 #3
0
ファイル: user_switch1.c プロジェクト: lvjh/ESP8266
LOCAL void ICACHE_FLASH_ATTR user_switch1_event() {
	char response[WEBSERVER_MAX_VALUE];
	user_switch1_state(response);
	user_event_raise(SWITCH1_URL, response);
}