def decode_packet(packet: str) -> dict:
node_id, _, protocol, attrs = packet.split(DELIM, <NUM_LIT:3>)<EOL>data = cast(Dict[str, Any], {<EOL>'<STR_LIT>': PacketHeader(node_id).name,<EOL>})<EOL>data['<STR_LIT>'] = UNKNOWN<EOL>if '<STR_LIT:=>' in protocol:<EOL><INDENT>attrs = protocol + DELIM + attrs<EOL><DEDENT>elif '<STR_LIT>' in protocol:<EOL><INDENT>data.update(parse_banner(protocol))<EOL><DEDENT>elif protocol == '<STR_LIT>':<EOL><INDENT>data['<STR_LIT>'] = protocol.lower()<EOL><DEDENT>elif protocol == '<STR_LIT>':<EOL><INDENT>data['<STR_LIT>'] = protocol.lower()<EOL>data['<STR_LIT>'] = packet[<NUM_LIT:3>:<NUM_LIT:5>]<EOL><DEDENT>elif protocol == '<STR_LIT>':<EOL><INDENT>data['<STR_LIT>'] = '<STR_LIT>'<EOL>data['<STR_LIT>'] = False<EOL><DEDENT>elif protocol == '<STR_LIT:OK>':<EOL><INDENT>data['<STR_LIT>'] = True<EOL><DEDENT>else:<EOL><INDENT>data['<STR_LIT>'] = protocol.lower()<EOL><DEDENT>for attr in filter(None, attrs.strip(DELIM).split(DELIM)):<EOL><INDENT>key, value = attr.lower().split('<STR_LIT:=>')<EOL>if key in VALUE_TRANSLATION:<EOL><INDENT>value = VALUE_TRANSLATION.get(key)(value)<EOL><DEDENT>name = PACKET_FIELDS.get(key, key)<EOL>data[name] = value<EOL>unit = UNITS.get(key, None)<EOL>if unit:<EOL><INDENT>data[name + '<STR_LIT>'] = unit<EOL><DEDENT><DEDENT>if data.get('<STR_LIT>', '<STR_LIT>') == '<STR_LIT>' and len(data['<STR_LIT:id>']) != <NUM_LIT:6>:<EOL><INDENT>data['<STR_LIT:id>'] = '<STR_LIT>' + data['<STR_LIT:id>']<EOL><DEDENT>return data<EOL>
Break packet down into primitives, and do basic interpretation.

    >>> decode_packet('20;06;Kaku;ID=41;SWITCH=1;CMD=ON;') == {
    ...     'node': 'gateway',
    ...     'protocol': 'kaku',
    ...     'id': '000041',
    ...     'switch': '1',
    ...     'command': 'on',
    ... }
    True