Direct method
Direct Method in Trimble IoT refers to a request-response interaction with a device similar to an HTTP call in that they succeed or fail immediately after a response timeout. Direct methods are used for communications that require immediate confirmation of results from devices. The device may return some message body due to the method, but it isn’t required for the method. Applications can configure methods associated with names.
| Operation | Topic | Payload |
|---|---|---|
| Subscription | $iothub/methods/POST/{methodName} or$iothub/methods/POST/# | N/A |
| Notification for Direct Method Request from Application | $iothub/methods/POST/{methodName}/?$rid={requestId} | Valid JSON |
| Device Response | $iothub/methods/res/{status}/?$rid={request id} | Empty or Valid JSON |
-
methodName - Name of the Direct Method
-
requestId - This parameter can be used to synchronize between the requests. The requestId from the notification has to be set in the response.
-
status - Status of the direct method. Status should be the HTTP Status Code Integers like
- 200 - Success
- 400 - Indicates that either device ID is invalid, or that the device was not online upon invocation of a direct method
- 504 - Iindicates gateway timeout caused by device not responding to a direct method call within responseTimeoutInSeconds.
-
Devices should respond back using the response topic within the response time out.