docs: def write_tlv(data):
      """Convert a dict to TLV8 bytes."""
      tlv = b''
      for key, value in data.items():
          tag = bytes([int(key)])
          length = len(value)
          pos = 0
  
          # A tag with length > 255 is added multiple times and concatenated into
          # one buffer when reading the TLV again.
          while pos < len(value):
              size = min(length, 255)
              tlv += tag
              tlv += bytes([size])
              tlv += value[pos:pos+size]
              pos += size
              length -= size
      return tlv