Test Command Response with RainMaker CLI
about
This test, carried out via RainMaker CLI to test the command response feature provided by ESP RainMaker is used to monitor and verify the execution of commands sent to devices. The goal is to track whether a command has been processed successfully or is still pending, ensuring that devices respond as expected. By checking the status, timestamps, and response data, we can confirm if commands are executed correctly, troubleshoot delays or failures, and ensure reliable communication between the cloud and connected devices. This is essential for validating system performance, debugging issues, and maintaining seamless IoT operations.
Test Guide
The best way to test command response framework is via RainMaker CLI
Creating a Request
esp-rainmaker-cli create_cmd_request -h
usage: usage: esp-rainmaker-cli create_cmd_request [-h] (Beta)
Create command response requests for the node(s) associated with the current (logged-in) user. The format of this command might change in future.
positional arguments:
nodes Node Ids of the node(s) format: <nodeid1>,<nodeid2>,...,<nodeid25>
cmd ID of the command response request
data JSON data containing parameters to be sent to the node(s). Note: Enter JSON data in single quotes
optional arguments:
-h, --help show this help message and exit
--timeout TIMEOUT Time in seconds till which the command response request will be valid
For example:
$ esp-rainmaker-cli create_cmd_request --timeout 60 6055F97E2008 4096 '{"brightness":50}'
Request Id: BK00t2QNe7oT12dBdh9f8X
Status: success
Monitoring Response
$ esp-rainmaker-cli get_cmd_requests -h
usage: usage: esp-rainmaker-cli get_cmd_requests [-h] (Beta)
Get command response requests created by current (logged-in) user. The format of this command might change in future.
positional arguments:
request_id ID of the command response request
optional arguments:
-h, --help show this help message and exit
--node_id NODE_ID Node Id of the node
--start_id START_ID Start Id used for pagination. This should be the Next Id received in the previous batch
--num_records NUM_RECORDS Number of requests to get
For Example
Command in Progress:
$ esp-rainmaker-cli get_cmd_requests BK00t2QNe7oT12dBdh9f8X
Requests: [{'node_id': '6055F97E2008', 'request_id': 'BK00t2QNe7oT12dBdh9f8X', 'request_timestamp': 1685382006, 'status': 'in_progress', 'expiration_timestamp': 1685382066}]
Total: 1
Command completed:
$ esp-rainmaker-cli get_cmd_requests BK00t2QNe7oT12dBdh9f8X
Requests: [{'node_id': '6055F97E2008', 'request_id': 'BK00t2QNe7oT12dBdh9f8X', 'request_timestamp': 1685382006, 'response_timestamp': 1685382039, 'response_data': {'status': 'success'}, 'status': 'success', 'device_status': 0, 'expiration_timestamp': 1685382066}]
More Info
- REST API usage information can be found in the Swagger documentation.