Command Server API

 
URL for command server
https://<address>:8080/device_command
Input parameters
$agent_id-  ID of device in PILOT System
$command_id - uniq ID  of command in PILOT System
$json_params - Command parameters in JSON, for example {"duration":5, "feature":"my_feature"}
 
Services
Get list of commands
GET
 https://<address>:8080/device_command/special_commands?agent_id=$agent_id
Send command
POST
 https://<address>:8080/device_command
POST parameters: 
special_command_id=$command_id&agent_id=$agent_id&parameters=$json_params
Delete command
DELETE
 https://<address>:8080/device_command/$command_id
Get history of commands
GET
 https://<address>:8080/device_command/history?command_type=special&agent_id=$agent_id
 
 
Example:
Send command
https://<address>:8080/device_command
POST: special_command_id=605&agent_id=69085&parameters={"duration":5}
 
Answer:
HTTP/1.1 200 OK
or
HTTP/1.1 400 Bad Request
{"message": "Incorrect command or agent id"}
 
 
List of commands
https://<address>:8080/device_command/special_commands?agent_id=69085
 
Answer:
[
    {
        "agent_id": 69085,
        "command_name": "ring",
        "command_parameters": [
            {
                "param_default_value": 5,
                "param_field_name": "duration",
                "param_max_value": 999,
                "param_min_value": 0,
                "param_name": "duration",
                "param_type": "integer"
            }
        ],
        "description": "ring",
        "id": "605"
    },
    {
        "agent_id": 69085,
        "command_name": "unlock",
        "command_parameters": [
            {
                "param_default_value": 0,
                "param_field_name": "user_id",
                "param_max_value": 999999999,
                "param_min_value": 0,
                "param_name": "user_id",
                "param_type": "integer"
            }
        ],
        "description": "unlock",
        "id": "601"
    },
    {
        "agent_id": 69085,
        "command_name": "get_sim_iccid",
        "command_parameters": [
        ],
        "description": "get_sim_iccid",
        "id": "599"
    },
    {
        "agent_id": 69085,
        "command_name": "lock_status",
        "command_parameters": [
        ],
        "description": "lock_status",
        "id": "598"
    },
    {
        "agent_id": 69085,
        "command_name": "query_firmware_ver",
        "command_parameters": [
        ],
        "description": "query_firmware_ver",
        "id": "597"
    },
    {
        "agent_id": 69085,
        "command_name": "alarm",
        "command_parameters": [
        ],
        "description": "alarm",
        "id": "596"
    },
    {
        "agent_id": 69085,
        "command_name": "position",
        "command_parameters": [
        ],
        "description": "position",
        "id": "595"
    }
]
 
 
 
History
https://<address>:8080/device_command/history?command_type=special&agent_id=69085
 
Answer:
{
  "items": [
    {
      "id": 58075,
      "creation_timestamp": 1569330907,
      "raw_command": {
        "device_id": "863921030920816",
        "creation_timestamp": 1569330907,
        "command": "query_firmware_ver",
        "parameters": [],
        "server": {
          "address": "pilot-gps.com",
          "port": "8080"
        }
      },
      "status": "queued",
      "answer": null,
      "command_name": "query_firmware_ver"
    },
    {
      "id": 58255,
      "creation_timestamp": 1569419121,
      "raw_command": {
        "device_id": "863921030920816",
        "creation_timestamp": 1569419121,
        "command": "position",
        "parameters": [],
        "server": {
          "address": "pilot-gps.com",
          "port": "8080"
        }
      },
      "status": "accepted",
      "answer": null,
      "command_name": "position"
    },
    {
      "id": 58256,
      "creation_timestamp": 1569419144,
      "raw_command": {
        "device_id": "863921030920816",
        "creation_timestamp": 1569419144,
        "command": "get_sim_iccid",
        "parameters": [],
        "server": {
          "address": "pilot-gps.com",
          "port": "8080"
        }
      },
      "status": "new",
      "answer": null,
      "command_name": "get_sim_iccid"
    },
    {
      "id": 58257,
      "creation_timestamp": 1569419661,
      "raw_command": {
        "device_id": "863921030920816",
        "creation_timestamp": 1569419661,
        "command": "position",
        "parameters": [],
        "server": {
          "address": "pilot-gps.com",
          "port": "8080"
        }
      },
      "status": "accepted",
      "answer": null,
      "command_name": "position"
    },
    {
      "id": 58258,
      "creation_timestamp": 1569437512,
      "raw_command": {
        "device_id": "863921030920816",
        "creation_timestamp": 1569437512,
        "command": "query_firmware_ver",
        "parameters": [],
        "server": {
          "address": "pilot-gps.com",
          "port": "8080"
        }
      },
      "status": "new",
      "answer": null,
      "command_name": "query_firmware_ver"
    },
    {
      "id": 58259,
      "creation_timestamp": 1569437904,
      "raw_command": {
        "device_id": "863921030920816",
        "creation_timestamp": 1569437904,
        "command": "get_sim_iccid",
        "parameters": [],
        "server": {
          "address": "pilot-gps.com",
          "port": "8080"
        }
      },
      "status": "new",
      "answer": null,
      "command_name": "get_sim_iccid"
    },
    {
      "id": 58260,
      "creation_timestamp": 1569438396,
      "raw_command": {
        "device_id": "863921030920816",
        "creation_timestamp": 1569438396,
        "command": "ring",
        "parameters": {
          "duration": "5"
        },
        "server": {
          "address": "pilot-gps.com",
          "port": "8080"
        }
      },
      "status": "new",
      "answer": null,
      "command_name": "ring"
    },
    {
      "id": 58272,
      "creation_timestamp": 1569482788,
      "raw_command": {
        "device_id": "863921030920816",
        "creation_timestamp": 1569482788,
        "command": "position",
        "parameters": [],
        "server": {
          "address": "pilot-gps.com",
          "port": "8080"
        }
      },
      "status": "accepted",
      "answer": null,
      "command_name": "position"
    },
    {
      "id": 58273,
      "creation_timestamp": 1569482843,
      "raw_command": {
        "device_id": "863921030920816",
        "creation_timestamp": 1569482843,
        "command": "ring",
        "parameters": {
          "duration": "5"
        },
        "server": {
          "address": "pilot-gps.com",
          "port": "8080"
        }
      },
      "status": "new",
      "answer": null,
      "command_name": "ring"
    },
    {
      "id": 58275,
      "creation_timestamp": 1569487616,
      "raw_command": {
        "device_id": "863921030920816",
        "creation_timestamp": 1569487616,
        "command": "ring",
        "parameters": {
          "duration": "5"
        },
        "server": {
          "address": "pilot-gps.com",
          "port": "8080"
        }
      },
      "status": "new",
      "answer": null,
      "command_name": "ring"
    },
    {
      "id": 58276,
      "creation_timestamp": 1569489219,
      "raw_command": {
        "device_id": "863921030920816",
        "creation_timestamp": 1569489219,
        "command": "unlock",
        "parameters": {
          "user_id": 0
        },
        "server": {
          "address": "pilot-gps.com",
          "port": "8080"
        }
      },
      "status": "new",
      "answer": null,
      "command_name": "unlock"
    },
    {
      "id": 58277,
      "creation_timestamp": 1569489261,
      "raw_command": {
        "device_id": "863921030920816",
        "creation_timestamp": 1569489261,
        "command": "unlock",
        "parameters": {
          "user_id": 0
        },
        "server": {
          "address": "pilot-gps.com",
          "port": "8080"
        }
      },
      "status": "new",
      "answer": null,
      "command_name": "unlock"
    }
  ],
  "total": 12
}