Skip to content

Docs (Command)

Matej Troják edited this page Nov 25, 2019 · 8 revisions

FUNCTIONALITY: Forward commands to device/node. It is possible to send multiple commands, but only to one device/one node at a time. Commands are to be sent as dictionaries in a list.

ENDPOINT: /command

TYPE: POST

URL ARGUMENTS:

  1. ?node_id=x -> send command which affects whole node, currently used only to change time period of measurements
  2. ?node_id=x&device_type=xyz -> send command to specific device on specific node

DATA: [{'time': "%Y-%m-%d %H:%M:%S", 'cmd_id': int, 'args': str(list)}]

POSSIBLE RESPONSES:

  • 200, 1 -> success, the command has been added to corresponding queue and is waiting to be executed
  • 400, 0 -> invalid node_id or device_type requested
  • 401, 'Invalid Credentials' -> invalid credentials in the auth argument in post request
  • 500, error message -> error occurred on PBRcontrol, report immediately

Example

import requests
requests.post('https://localhost:5000/command?node_id=1&device_type=PBR', 
              str([{'time': '2019-10-25 13:03:32', 'cmd_id': 8, 'args': str([1, True]), 'source': 'external'}]), 
              verify=False, auth=('user', 'passwd'))

where there has to be running node with ID = 1 with a device identified as PBR. The available commands with their command ID cmd_id and arguments args are given in Commands. There can only be one device of a type running on one node.

Clone this wiki locally