diff --git a/mesht_device.py b/mesht_device.py index 56aabdc..2ac1b66 100644 --- a/mesht_device.py +++ b/mesht_device.py @@ -265,11 +265,7 @@ class MeshtDevice: async def recv(self): data = await self.transport.recv() - try: - fr = pb.decode(data, FROMRADIO_SCHEMA) - except UnicodeDecodeError: - logger.error("Cannot decode msg with string") - fr = {} + fr = pb.decode(data, FROMRADIO_SCHEMA) logger.debug(f"FromRadio: {fr}") self._maybe_store_channel(fr) self._maybe_store_lora_config(fr) diff --git a/pb.py b/pb.py index 2dc4b63..501a350 100644 --- a/pb.py +++ b/pb.py @@ -447,7 +447,10 @@ def decode(buf, schema=None, _depth=0, _max_depth=_MAX_NESTING_DEPTH): elif spec and spec.get("kind") == "packed": v = _decode_packed(chunk, t) elif t == "string": - v = chunk.decode("utf-8") + try: + v = chunk.decode("utf-8") + except UnicodeDecodeError: + v = None elif t == "bytes" or spec is None: v = chunk else: