@staticmethod
def decode(buffer):
    """
          Get the value of a multi-byte integer from a buffer
          Return the value, and the number of bytes used.

          [MQTT-1.5.5-1] the encoded value MUST use the minimum number of bytes necessary to represent the value
        """
    multiplier = 1
    value = 0
    bytes = 0
    while 1:
        bytes += 1
        digit = buffer[0]
        buffer = buffer[1:]
        value += (digit & 127) * multiplier
        if digit & 128 == 0:
            break
        multiplier *= 128
    return value, bytes
