protocol: start a new attempt at handling the protocol
This is only the framework for a new protocol handler that should simplify adding, extending and debugging the actual protocol messages. The summary is: - each protocol interaction is a subclass of Msg() that handles the data sent and received from the device. - the list of messages for each device is stored in a dictionary the caller initializes by providing the protocol version - those messages are addressable via the Interactions enum through the Protocol class - the messages can be run via execute(), taking and setting the obvious properties on the object - actual communication is done via a single callback that takes/returns a NordicData object for the request/reply. So after the basic setup, the caller can do this: p = Protocol(ProtocolVersion.INTUOS_PRO) name = p.execute(Interactions.GET_NAME).name p.execute(Interactions.SET_TIME, time.time()) This completely separates the protocol from the implementation where we want the result of that exchange, ideally paving the way for better testing and easier debugging of what's happening on the wire. Well, ether. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
910bea8898
commit
a817d10cc7