Beispiel #1
0
 def parse_queueHandle(stream: BitStreamReader):  # pylint: disable=invalid-name
     """Parse queueHandle from raw bitstream"""
     # According to the docs queueHandle should be an uint8_t value
     # just like the other similar messages. But for unknown reason zipgateway
     # sends this like an ipv6 address (at least version 7.11.01)
     print("Node failing", stream.remaining(advance=False))
     if stream.bytesLeft() == 16:
         stream.advance(8 * 15)
     return stream.byte()
Beispiel #2
0
 def deserialize(cls, stream: BitStreamReader):
     """Deserialize types from stream"""
     supported = cls()
     value = int.from_bytes(stream.remaining(),
                            byteorder="big",
                            signed=False)
     i = 1
     while value > 0:
         if value & 1 == 1:
             supported.add(SensorType(i))
         value >>= 1
         i += 1
     return supported
Beispiel #3
0
 def deserialize(cls, stream: BitStreamReader):
     """Deserialize nodes from association report."""
     data = stream.remaining()
     nodes = []
     while data:
         node = data[0]
         data = data[1:]
         if node == MULTI_CHANNEL_ASSOCIATION_SET_MARKER_V2:
             break
         nodes.append((node, None))
     while data:
         node = data[0]
         endpoint = data[1]
         nodes.append((node, endpoint))
         data = data[2:]
     return nodes
Beispiel #4
0
def test_BitStreamReader_remaining(streamReader: BitStreamReader):
    assert streamReader.remaining(advance=False) == b"\x02\x01\xcb@"
    assert streamReader.value(1) == b"\x02"
    assert streamReader.remaining() == b"\x01\xcb@"
Beispiel #5
0
def test_BitStreamReader_eof(streamReader: BitStreamReader):
    streamReader.remaining()
    assert streamReader.bytesLeft() == 0
    with pytest.raises(EOFError):
        streamReader.byte()
 def parse_commandClass(self, stream: BitStreamReader):  # pylint: disable=invalid-name
     """Parse the length prefixed command"""
     length = self.nodeInfoLength - 7
     if length > stream.bytesLeft():
         return list(stream.remaining())
     return list(stream.value(length))