diff --git a/boards/default_src/micropython/origin/build/lib/ags10.py b/boards/default_src/micropython/origin/build/lib/ags10.py index 2ee81bca..249c1451 100644 --- a/boards/default_src/micropython/origin/build/lib/ags10.py +++ b/boards/default_src/micropython/origin/build/lib/ags10.py @@ -17,9 +17,10 @@ class AGS10: def __init__(self, i2c_bus, address=0x1A, delay=1000): self._i2c = i2c_bus self._addr = address - self._voc = None + self._voc = 0 self._delay = delay self._star = 0 + self.ready = 0 def _crc8(self, buf, is_byte=False): '''Perform CRC check on the data''' @@ -76,8 +77,8 @@ class AGS10: if time.ticks_diff(time.ticks_ms(), self._star) >= self._delay: self._star = time.ticks_ms() _buf = self._rreg(_AGS10_ADC) - if (_buf[0] & 0x01) == 0: - self._voc = int.from_bytes(_buf[1:4], 'big') + self._voc = int.from_bytes(_buf[1:4], 'big') + self.ready = not (_buf[0] & 0x01) return self._voc / 1000 def read(self, hcho_mw=30.033 , co2_mv=0.853, co2_base=400): diff --git a/boards/default_src/micropython/origin/build/lib/ntptime.py b/boards/default_src/micropython/origin/build/lib/ntptime.py index 7474eec6..cce0a4b0 100644 --- a/boards/default_src/micropython/origin/build/lib/ntptime.py +++ b/boards/default_src/micropython/origin/build/lib/ntptime.py @@ -6,21 +6,27 @@ import ustruct as struct # NTP_DELTA (date(2000, 1, 1) - date(1900, 1, 1)).days * 24*60*60 NTP_DELTA=3155673600 -def time(host="pool.ntp.org", utc=28800): - NTP_QUERY = bytearray(48) - NTP_QUERY[0] = 0x1B - addr = socket.getaddrinfo(host, 123)[0][-1] - s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - try: - s.settimeout(1) - res = s.sendto(NTP_QUERY, addr) - msg = s.recv(48) - finally: - del addr - s.close() - gc.collect() - val = struct.unpack("!I", msg[40:44])[0] - return utime.gmtime(val - NTP_DELTA + utc) +def time(host="pool.ntp.org", utc=28800, times=5): + for _ in range(times): + try: + NTP_QUERY = bytearray(48) + NTP_QUERY[0] = 0x1B + addr = socket.getaddrinfo(host, 123)[0][-1] + s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + try: + s.settimeout(1) + res = s.sendto(NTP_QUERY, addr) + msg = s.recv(48) + finally: + del addr + s.close() + gc.collect() + val = struct.unpack("!I", msg[40:44])[0] + return utime.gmtime(val - NTP_DELTA + utc) + except Exception as e: + error = e + utime.sleep(0.1) + raise OSError('Error fetching network time', error) # There's currently no timezone support in MicroPython, and the RTC is set in UTC time. def settime(times): diff --git a/boards/default_src/micropython_esp32c2/origin/build/lib/mini_xunfei.py b/boards/default_src/micropython_esp32c2/origin/build/lib/mini_xunfei.py index 3692c1da..1d51a73f 100644 --- a/boards/default_src/micropython_esp32c2/origin/build/lib/mini_xunfei.py +++ b/boards/default_src/micropython_esp32c2/origin/build/lib/mini_xunfei.py @@ -244,6 +244,10 @@ class LLM_WebSocket(Ws_Param): if "reasoning_content" in text and reas: print("reasoning: ", text["reasoning_content"]) #回调 + if "tool_calls" in text: + function = text['tool_calls'][0]['function'] + if str(function['name']) in self._function[0] and function['arguments']: + self._function[0][function['name']](json.loads(function['arguments'])) if "function_call" in text: if str(text['function_call']['name']) in self._function[0] and text['function_call']['arguments']: self._function[0][text['function_call']['name']](json.loads(text['function_call']['arguments']))