method.exec

The method.exec command is used to execute a method call for a Thing.

TR50 Request
{
  "cmd": {
    "command": "method.exec",
    "params": {
      "thingKey": "mything",
      "method": "methodName",
      "ackTimeout": 30,
      "params": {
        "paramKey": "paramValue" 
      }
    }
  }
}
  • If ackTimeout is not set in the method.exec then the Default method timeout is used as the ackTimeout. The Default method timeout (defaultAckTimeout)is set while creating the Thing Definition. For more information, see thing_def.create.

Request Parameters

Name Type Required Description
thingKey String Yes Identifies the thing to which the method call is to be associated. This parameter may also contain a mailbox alias.
method String Yes The method you wish to execute on the thing.
ackTimeout Integer Acknowledge timeout duration in seconds (maximum of 300).
ttl Integer The time to live of the message. Defaults to the ackTimeout.
params Object Notification variables or method parameters to be executed with the method.

If the command is sent successfully a success message is returned. Otherwise, an error and error message will be returned.

TR50 Response
{
  "cmd": {
    "success": true
  }
}

Response Parameters

Name Type Description
params Object The completion variables returned by the method's execution if any.
C API
// basic API
int tr50_method_exec(void *tr50, const char *method, JSON* params);
 
// extended API
int tr50_method_exec_ex_sync(void *tr50, const char *method, JSON* req_params, void* optional_params, void** optional_reply);
JAVA API
// Synchronous
int exec(String thingKey, String method, Boolean singleton, Integer ackTimeout, LinkedHashMap<String, Object> params, Object response);
 
// Asynchronous
int exec(String thingKey, String method, Boolean singleton, Integer ackTimeout, LinkedHashMap<String, Object> 
params, DwOpenReceiveActionListener recv, Object response);

Response Objects:  StringReplyDwOpenResponse, DwOpenMethodExec

PHP API
bool TR50httpWorker::methodExec($thingKey, $method[, $ackTimeout[, $parameters]]);