from enum import IntEnum import struct from pyblake2 import blake2s import time import toml HASH_LENGTH = 8 with open("Config.toml", "r") as config_file: config = toml.loads(config_file.read()) print(config) devices = {} class MessageType(IntEnum): DeviceStatus = 1 SensorStatus = 2 def decode_packet(data): packet_type = data[0] # match packet_type: # case MessageType.DeviceStatus: if packet_type == MessageType.DeviceStatus: return {"Battery voltage": struct.unpack('> i) & 1: channels.append(i) sensor_data = [] for i in range(len(channels)): offset = i * 6 sensor_data.append({ "channel": channels[i], "type": data[3 + offset], "pin": data[4 + offset], "value": struct.unpack('