bricknil.messages¶
Message parsers for each message type
Classes¶
AttachedIOMessage |
Peripheral attach and detach message |
HubPropertiesMessage |
Used to get data on the hub as well as button press information on the hub |
Message |
Base class for each message parser. |
PortComboValueMessage |
Multiple (combination) value updates from different modes of a sensor |
PortInformationMessage |
Information on what modes are supported on a port and whether a port is input/output. |
PortModeInformationMessage |
Information on a specific mode |
PortOutputFeedbackMessage |
Ack messages/error messages sent in response to a command being issued to the hub |
PortValueMessage |
Single value update from a sensor |
Members¶
-
class
bricknil.messages.
Message
[source]¶ Bases:
object
Base class for each message parser.
This class instance keeps track of each subclass and stores an object of each subclass in the attribue parsers. None of these subclass instances should ever store any instance data since these are shared across multiple hubs.
-
parsers
= {1: <bricknil.messages.HubPropertiesMessage object>, 4: <bricknil.messages.AttachedIOMessage object>, 67: <bricknil.messages.PortInformationMessage object>, 68: <bricknil.messages.PortModeInformationMessage object>, 69: <bricknil.messages.PortValueMessage object>, 70: <bricknil.messages.PortComboValueMessage object>, 130: <bricknil.messages.PortOutputFeedbackMessage object>}
-
parse
(msg_bytes, l, dispatcher)[source]¶ Implement this handle parsing of each message body type.
Parameters: - msg_bytes (bytearray) – Message body
- l (list) – text description of what’s being parsed for logging (just append details as you go along)
- dispatcher (
bricknil.message_dispatch.MessageDispatch
) – The dispatch object that is sending messages. Call back into its methods to send messages back to the hub.
-
-
class
bricknil.messages.
PortValueMessage
[source]¶ Bases:
bricknil.messages.Message
Single value update from a sensor
-
msg_type
= 69¶
-
parse
(msg_bytes, l, dispatcher)[source]¶ Implement this handle parsing of each message body type.
Parameters: - msg_bytes (bytearray) – Message body
- l (list) – text description of what’s being parsed for logging (just append details as you go along)
- dispatcher (
bricknil.message_dispatch.MessageDispatch
) – The dispatch object that is sending messages. Call back into its methods to send messages back to the hub.
-
-
class
bricknil.messages.
PortComboValueMessage
[source]¶ Bases:
bricknil.messages.Message
Multiple (combination) value updates from different modes of a sensor
-
msg_type
= 70¶
-
parse
(msg_bytes, l, dispatcher)[source]¶ Implement this handle parsing of each message body type.
Parameters: - msg_bytes (bytearray) – Message body
- l (list) – text description of what’s being parsed for logging (just append details as you go along)
- dispatcher (
bricknil.message_dispatch.MessageDispatch
) – The dispatch object that is sending messages. Call back into its methods to send messages back to the hub.
-
-
class
bricknil.messages.
HubPropertiesMessage
[source]¶ Bases:
bricknil.messages.Message
Used to get data on the hub as well as button press information on the hub
-
msg_type
= 1¶
-
prop_names
= {1: 'Advertising Name', 2: 'Button', 3: 'FW Version', 4: 'HW Version', 5: 'RSSI', 6: 'Battery Voltage', 7: 'Battery Type', 8: 'Manufacturer Name', 9: 'Radio FW Version', 10: 'LEGO Wireles Protocol Version', 11: 'System Type ID', 12: 'HW Network ID', 13: 'Primary MAC address', 14: 'Seconary MAC address', 15: 'HW Network Family'}¶
-
operation_names
= {1: 'Set (downstream)', 2: 'Enable Updates (Downstream)', 3: 'Disable Updates (Downstream)', 4: 'Reset (Downstream)', 5: 'Request Update (Downstream)', 6: 'Update (Upstream)'}¶
-
parse
(msg_bytes, l, dispatcher)[source]¶ Implement this handle parsing of each message body type.
Parameters: - msg_bytes (bytearray) – Message body
- l (list) – text description of what’s being parsed for logging (just append details as you go along)
- dispatcher (
bricknil.message_dispatch.MessageDispatch
) – The dispatch object that is sending messages. Call back into its methods to send messages back to the hub.
-
-
class
bricknil.messages.
PortInformationMessage
[source]¶ Bases:
bricknil.messages.Message
Information on what modes are supported on a port and whether a port is input/output.
-
msg_type
= 67¶
-
parse
(msg_bytes, l, dispatcher)[source]¶ Implement this handle parsing of each message body type.
Parameters: - msg_bytes (bytearray) – Message body
- l (list) – text description of what’s being parsed for logging (just append details as you go along)
- dispatcher (
bricknil.message_dispatch.MessageDispatch
) – The dispatch object that is sending messages. Call back into its methods to send messages back to the hub.
-
-
class
bricknil.messages.
PortOutputFeedbackMessage
[source]¶ Bases:
bricknil.messages.Message
Ack messages/error messages sent in response to a command being issued to the hub
-
msg_type
= 130¶
-
parse
(msg_bytes, l, dispatcher)[source]¶ Implement this handle parsing of each message body type.
Parameters: - msg_bytes (bytearray) – Message body
- l (list) – text description of what’s being parsed for logging (just append details as you go along)
- dispatcher (
bricknil.message_dispatch.MessageDispatch
) – The dispatch object that is sending messages. Call back into its methods to send messages back to the hub.
-
-
class
bricknil.messages.
PortModeInformationMessage
[source]¶ Bases:
bricknil.messages.Message
Information on a specific mode
This tells us a mode’s name, what numeric format it uses, and it’s range.
-
msg_type
= 68¶
-
parse
(msg_bytes, l, dispatcher)[source]¶ Implement this handle parsing of each message body type.
Parameters: - msg_bytes (bytearray) – Message body
- l (list) – text description of what’s being parsed for logging (just append details as you go along)
- dispatcher (
bricknil.message_dispatch.MessageDispatch
) – The dispatch object that is sending messages. Call back into its methods to send messages back to the hub.
-
-
class
bricknil.messages.
AttachedIOMessage
[source]¶ Bases:
bricknil.messages.Message
Peripheral attach and detach message
-
msg_type
= 4¶
-
parse
(msg_bytes, l, dispatcher)[source]¶ Implement this handle parsing of each message body type.
Parameters: - msg_bytes (bytearray) – Message body
- l (list) – text description of what’s being parsed for logging (just append details as you go along)
- dispatcher (
bricknil.message_dispatch.MessageDispatch
) – The dispatch object that is sending messages. Call back into its methods to send messages back to the hub.
-