diff --git a/library.properties b/library.properties index 020a707..d08cea6 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=M5ModuleLLM -version=1.0.0 +version=1.4.0 author=M5Stack maintainer=M5Stack sentence=M5ModuleLLM is a library for M5ModuleLLM diff --git a/src/api/api_llm.cpp b/src/api/api_llm.cpp index 617c8bd..44ca3aa 100644 --- a/src/api/api_llm.cpp +++ b/src/api/api_llm.cpp @@ -47,7 +47,7 @@ String ApiLlm::setup(ApiLlmSetupConfig_t config, String request_id) // Copy work id llm_work_id = msg.work_id; }, - 20000); + 30000); return llm_work_id; } diff --git a/src/utils/comm.cpp b/src/utils/comm.cpp index 7df0c4a..33b6bc5 100644 --- a/src/utils/comm.cpp +++ b/src/utils/comm.cpp @@ -7,6 +7,8 @@ #include using namespace m5_module_llm; +const size_t JSON_BUFFER_SIZE = 2048; +char jsonBuffer[JSON_BUFFER_SIZE]; bool ModuleComm::init(Stream* serialPort) { @@ -34,6 +36,7 @@ void ModuleComm::sendRaw(const uint8_t* data, size_t& raw_len) ModuleComm::Respond_t ModuleComm::getResponse(uint32_t timeout) { Respond_t ret; + String buffer; uint32_t time_out_count = millis(); bool get_msg = false; @@ -43,7 +46,13 @@ ModuleComm::Respond_t ModuleComm::getResponse(uint32_t timeout) if (_serial->available()) { get_msg = true; while (_serial->available()) { - ret.msg += (char)_serial->read(); + char c = (char)_serial->read(); + buffer += c; + + if (c == '\n') { + ret.msg = buffer; + return ret;; + } } get_msg_count = millis(); time_out_count = millis(); @@ -62,7 +71,7 @@ ModuleComm::Respond_t ModuleComm::getResponse(uint32_t timeout) break; } - delay(5); + // delay(5); } return ret;