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

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

 
 
URL для  command server
https://<address>:8080/device_command
Переменные
$agent_id-  уникальный ID прибора в системе ПИЛОТ
$command_id - уникальный ID  типа команды 
$json_params - параметры команды заколированные в  JSON , например  {"duration":5, "feature":"my_feature"}
 
Сервисы
Получение списка команд
GET
https://<address>:8080/device_command/special_commands?agent_id=$agent_id
Отправка команды
 POST
 https://<address>:8080/device_command
параметры  POST: 
special_command_id=$command_id&agent_id=$agent_id&parameters=$json_params
Удаление команды
DELETE
 https://<address>:8080/device_command/$command_id
Получение истории команд
GET
 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&parameters={"duration":5}
Oтвет
HTTP/1.1 200 OK
или 
HTTP/1.1 400 Bad Request{"message": "Incorrect command or agent id"}
Список команд
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
}