def encodeLength(value):
encoded = bytearray()<EOL>while True:<EOL><INDENT>digit = value % <NUM_LIT><EOL>value //= <NUM_LIT><EOL>if value > <NUM_LIT:0>:<EOL><INDENT>digit |= <NUM_LIT><EOL><DEDENT>encoded.append(digit)<EOL>if value <= <NUM_LIT:0>:<EOL><INDENT>break<EOL><DEDENT><DEDENT>return encoded<EOL>
Encodes value into a multibyte sequence defined by MQTT protocol.
Used to encode packet length fields.