void loop() { wdt_reset(); if (Serial.available()) { parseHttp(); } processSensors(); checkLedTimeouts(); }
int HttpParserImpl::parse(const char* data, uint32_t len) { if(HTTP_READ_DONE == read_state_ || HTTP_READ_ERROR == read_state_) { KUMA_WARNTRACE("HttpParser::parse, invalid state="<<read_state_); return 0; } if(HTTP_READ_BODY == read_state_ && !is_chunked_ && !has_content_length_) {// return directly, read untill EOF total_bytes_read_ += len; if(cb_data_) cb_data_(data, len); return len; } const char* pos = data; const char* end = data + len; ParseState parse_state = parseHttp(pos, end); int parsed_len = (int)(pos - data); if(PARSE_STATE_DESTROY == parse_state) { return parsed_len; } if(PARSE_STATE_ERROR == parse_state && cb_event_) { cb_event_(HTTP_ERROR); } return parsed_len; }