@classmethod
def decode(cls, data):
    """
        see https://lego.github.io/lego-ble-wireless-protocol-docs/#common-message-header
        """
    msg = cls()
    msg.payload = data
    msglen = msg._byte()
    assert msglen < 127, 'TODO: handle longer messages with 2-byte len'
    hub_id = msg._byte()
    assert hub_id == 0
    msg_type = msg._byte()
    assert cls.TYPE == msg_type, 'Message type does not match: %x!=%x' % (cls
        .TYPE, msg_type)
    assert isinstance(msg.payload, (bytes, bytearray))
    return msg
