Generally I would suggest making a struct for each of the payload the same way you have done for the frame. Then you can extract the data by loading it into the struct.
Another thing I notice you are doing is binding on port 56700. You can actually bind on any port you like, and as long as you set the source
field and send using the bound socket then the bulb will return the packets to that port. I suggest you bind on an ephemeral port (check your OS instructions on how to do this).
I’ll list the decodes from my python library for all the packets you posted for you to check against:
1.
24 00 00 34 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 00 00 00
lifx_packet(frame_header=frame_header(size=36, origin=0, tagged=1, addressable=1, protocol=1024, source=0), frame_address=frame_address(target=0, reserved1=0, reserved2=0, ack_required=0, res_required=0, sequence=0), protocol_header=protocol_header(reserved1=0, pkt_type=2, reserved2=0), payload=payload_getservice())
2.
29 00 00 54 00 00 00 00 d0 73 d5 11 97 bd 00 00 4c 49 46 58 56 32 00 00 90 80 27 7a 22 dd 2a 14 03 00 00 00 01 7c dd 00 00
lifx_packet(frame_header=frame_header(size=41, origin=1, tagged=0, addressable=1, protocol=1024, source=0), frame_address=frame_address(target=208456536912848, reserved1=55346429577548, reserved2=0, ack_required=0, res_required=0, sequence=0), protocol_header=protocol_header(reserved1=1453216969928442000, pkt_type=3, reserved2=0), payload=payload_stateservice(service=1, port=56700))
3.
32 00 00 54 42 52 4b 52 d0 73 d5 11 97 bd 00 00 4c 49 46 58 56 32 00 00 90 ae ef 88 22 dd 2a 14 0d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3e 11
lifx_packet(frame_header=frame_header(size=50, origin=1, tagged=0, addressable=1, protocol=1024, source=1380667970), frame_address=frame_address(target=208456536912848, reserved1=55346429577548, reserved2=0, ack_required=0, res_required=0, sequence=0), protocol_header=protocol_header(reserved1=1453216970176442000, pkt_type=13, reserved2=0), payload=payload_statehostinfo(signal=0, tx=0, rx=0, reserved=4414))