def parse_packet(data, format=None):
unpacked = struct.unpack(BASE_FORMAT, data[:_FORMAT_SIZE])<EOL>psize, protocol, mac, gateway, time, ptype = unpacked<EOL>header = Header(psize, protocol, mac, gateway, time, ptype)<EOL>return header, data[_FORMAT_SIZE:]<EOL>
Parses a Lifx data packet (as a bytestring), returning into a Header object
for the fields that are common to all data packets, and a bytestring of
payload data for the type-specific fields (suitable for passing to
`parse_payload`).