code: public JSONObject sendToObject(String method, Object params) throws CommandExecutionException {
          Response resp = send(method, params);
          if (resp == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE);
          if (resp.getParams() == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE);
          if (resp.getParams().getClass() != JSONObject.class) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE);
          return (JSONObject)resp.getParams();
      }
docs: Send a command to a device. If no IP has been specified, this will try do discover a device on the network.
  @param method The method to execute on the device.
  @param params The command to execute on the device. Must be a JSONArray or JSONObject.
  @return The response from the device as a JSONObject.
  @throws CommandExecutionException When there has been a error during the communication or the response was invalid.