Руководство пользователя
Версия 7.5
×

API сервер команд

 
URL для командного сервера
https://<address>:8080/device_command
 
Входные параметры
$agent_id- ID устройства в системе PILOT
$command_id - уникальный идентификатор команды в системе PILOT
$json_params — параметры команды в формате JSON, например  {"duration":5, "feature":"my_feature"}
 
Услуги
Получить список команд
ПОЛУЧАТЬ
 https://<address>:8080/device_command/special_commands?agent_id=$agent_id
 
Отправить команду
ПОЧТА
 https://<address>:8080/device_command
 POST-параметры:
special_command_id= $command_id &agent_id=$agent_id¶meters=$json_params
 
Удалить команду
УДАЛИТЬ
 https://<address>:8080/device_command/$command_id
 Получить историю команд
 
ПОЛУЧАТЬ
https://<address>:8080/device_command/history?command_type=special&agent_id=$agent_id
 
Примеры
Отправить команду
https://<address>:8080/device_command
POST:  special_command_id=605&agent_id=69085¶meters={"duration":5}
 
Ответ:
HTTP / 1.1 200 ОК
или
HTTP / 1.1 400 Неверный запрос
{"message": "Неправильная команда или идентификатор агента"}
 
Список команд
https://<address>:8080/device_command/special_commands?agent_id=69085
 
Ответ:
[
    {
        "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"
    }
]
 
История
https://<address>:8080/device_command/history?command_type=special&agent_id=69085
 
Ответ:
{
  "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
}