def unmarshall(bytes, extra=None): buf = ByteBuf(bytes) msg = MessageAudioData() msg.type = buf.read_uint8() # 文件类型 msg.total_size = buf.read_uint32() #文件总长 msg.check = buf.read_uint8() check_data = '' if msg.check == 0: # crc16 check_data = buf.read_uint16() if msg.check == 1: # md5 check_data = buf.read_bytes(16) msg.offset = buf.read_uint32() size = buf.read_uint16() msg.content = buf.read_bytes(size) if msg.type in (0,2): # 录音文件s # msg.flag = buf.read_bytes(6) y = 2000 + buf.read_uint8() m = buf.read_uint8() d = buf.read_uint8() h = buf.read_uint8() M = buf.read_uint8() s = buf.read_uint8() msg.ymdhms = '{}{:02d}{:02d} {:02d}:{:02d}:{:02d}'.format(y, m, d, h, M, s) elif msg.type == 1: #对应 SOS、声控 报警包序列号相同 msg.flag = buf.read_uint16() elif msg.type == 3: msg.flag = buf.read_uint32() msg.sequence = buf.read_uint16() return msg
def unmarshall(bytes, extra=None): buf = ByteBuf(bytes) msg = MessageOnlineCommand() msg.extra = extra msg.flag = buf.read_uint32() msg.encode = buf.read_uint8() msg.content = buf.bytes[buf.index:] return msg
def unmarshall(bytes, extra=None): buf = ByteBuf(bytes) msg = MessageGpsLocation() msg.extra = extra msg.location.parse(buf) msg.acc = buf.read_uint8() msg.rpt_mode = buf.read_uint8() msg.up_mode = buf.read_uint8() msg.miles = buf.read_uint32() return msg
def unmarshall(bytes,extra=None): buf = ByteBuf(bytes) msg = MessageOnlineCommand() msg.extra = extra size = buf.read_uint8() body_size = size - 4 msg.sequence = buf.read_uint32() msg.content = buf.read_bytes(body_size) msg.lang = buf.read_uint16() return msg
def unmarshall(bytes, extra=None): buf = ByteBuf(bytes) msg = MessageAlarmData() msg.extra = extra msg.location.parse(buf) msg.simple_info.parse(buf.read_uint8()) msg.voltage = buf.read_uint8() msg.gsm = buf.read_uint8() msg.alarm = buf.read_uint8() msg.lang = buf.read_uint8() msg.miles = buf.read_uint32() return msg