bricknil.message_dispatch¶
Parse incoming BLE Lego messages from hubs
Each hub has one of these objects to control access to the underlying BLE library notification thread.
Communication back into the hub (running in python async-land) is through a curio.UniversalQueue
object.
Todo
- The message parsers need to handle detaching of peripherals
Classes¶
MessageDispatch (hub) |
Parse messages (bytearray) |
Members¶
-
class
bricknil.message_dispatch.
MessageDispatch
(hub)[source]¶ Bases:
object
Parse messages (bytearray)
Once the
parse()
method is called, the message header will be parsed, and based on the msg_type byte, the processing of the message body will be dispatched to the parse method of the matching Message body parser. Message body parsers are subclasses ofbricknil.messages.Message
, and will call back to the message* methods below. This object will then send a message to the connectedbricknil.hub.Hub
object.Parameters: hub ( bricknil.hub.Hub
) – The hub that will be sending messages-
port_info
¶ A mirror copy of the
bricknil.hub.Hub.port_info
object. This object is sent every time an update on the port meta data is made.Type: dict
-
parse
(msg: bytearray)[source]¶ Parse the header of the message and dispatch message body processing
l is only used to build up a log message to display during operation, telling the user what kind of message was received and how it was parsed. If the message cannot be parsed, then l contains the remaining unparsed raw message that was received from the hardware ble device.
-
message_update_value_to_peripheral
(port, value)[source]¶ Called whenever a peripheral on the hub reports a change in its sensed value
-