code: def _write_handle(self, conn, handle, ack, value, timeout=1.0):
          
  
          conn_handle = conn
          char_handle = handle
  
          def write_handle_acked(event):
              if event.command_class == 4 and event.command == 1:
                  conn, _, char = unpack("<BHH", event.payload)
  
                  return conn_handle == conn and char_handle == char
  
          data_len = len(value)
          if data_len > 20:
              return False, {'reason': 'Data too long to write'}
  
          payload = struct.pack("<BHB%ds" % data_len, conn_handle, char_handle, data_len, value)
  
          try:
              if ack:
                  response = self._send_command(4, 5, payload)
              else:
                  response = self._send_command(4, 6, payload)
          except InternalTimeoutError:
              return False, {'reason': 'Timeout waiting for response to command in _write_handle'}
  
          _, result = unpack("<BH", response.payload)
          if result != 0:
              return False, {'reason': 'Error writing to handle', 'error_code': result}
  
          if ack:
              events = self._wait_process_events(timeout, lambda x: False, write_handle_acked)
              if len(events) == 0:
                  return False, {'reason': 'Timeout waiting for acknowledge on write'}
  
              _, result, _ = unpack("<BHH", events[0].payload)
              if result != 0:
                  return False, {'reason': 'Error received during write to handle', 'error_code': result}
  
          return True, None
docs: Write to a BLE device characteristic by its handle
  
          Args:
              conn (int): The connection handle for the device we should read from
              handle (int): The characteristics handle we should read
              ack (bool): Should this be an acknowledges write or unacknowledged
              timeout (float): How long to wait before failing
              value (bytearray): The value that we should write