def packet(self): pkt = DownStream.packet() buf = ByteBuf() size = 4 + len(self.content) buf.write_uint8(size) buf.write_uint32(self.sequence) buf.write_bytes(self.content) buf.write_uint16(self.lang) pkt.set_payload(buf.bytes)
def marshall(self): buf = ByteBuf() self.size = 39 + len(self.address) buf.write_uint8(self.size) buf.write_uint32(self.sequence) buf.write_bytes(self.alarmsms) buf.write_bytes('&&') buf.write_bytes(self.address) buf.write_bytes('&&') buf.write_bytes(self.tel) buf.write_bytes('##') return buf.bytes
def packet(self): from packet import NetWorkPacket pkt = NetWorkPacket() buf = ByteBuf() size = 4 + len(self.content) buf.write_uint8(size) buf.write_uint32(self.sequence) buf.write_bytes(self.content) buf.write_uint16(self.lang) pkt.set_payload(buf.bytes) pkt.type = self.Type.value return pkt
def to_bytes(self): buf = ByteBuf() self.size = 5 + len(self.payload) buf.write_bytes(self.start_flag) if self.fieldsize_width == 1: buf.write_uint8(self.size) if self.fieldsize_width == 2: buf.write_uint16(self.size) buf.write_uint8(self.type) buf.write_bytes(self.payload) buf.write_uint16(self.sequence) crc = self.calc_crc(buf.bytes[2:]) buf.write_uint16(crc) buf.write_bytes(self.stop_flag) return buf.bytes