Command interface API
This commit is contained in:
parent
0d0ba4ae50
commit
62449d2528
20
api.php
20
api.php
@ -92,6 +92,7 @@ try {
|
|||||||
$token = $obj['token'];
|
$token = $obj['token'];
|
||||||
$values = null;
|
$values = null;
|
||||||
$settings = null;
|
$settings = null;
|
||||||
|
$command = "null";
|
||||||
|
|
||||||
if (isset($obj['values'])) {
|
if (isset($obj['values'])) {
|
||||||
$values = $obj['values'];
|
$values = $obj['values'];
|
||||||
@ -169,6 +170,21 @@ if ($settings != null || $settings != ""){
|
|||||||
DeviceManager::editByToken($token, $data);
|
DeviceManager::editByToken($token, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Issuing command
|
||||||
|
if ($command == "null"){
|
||||||
|
$deviceCommand = DeviceManager::getDeviceByToken($token)["command"];
|
||||||
|
if ($deviceCommand != '' || $deviceCommand != null)
|
||||||
|
{
|
||||||
|
$command = $deviceCommand;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'command'=>'null'
|
||||||
|
];
|
||||||
|
DeviceManager::editByToken($token, $data);
|
||||||
|
$logManager->write("[API] Device_ID " . $deviceId . " executing command " . $command, LogRecordType::INFO);
|
||||||
|
}
|
||||||
|
|
||||||
// Subdevices first data!
|
// Subdevices first data!
|
||||||
if ($values != null || $values != "") {
|
if ($values != null || $values != "") {
|
||||||
|
|
||||||
@ -226,7 +242,7 @@ if ($values != null || $values != "") {
|
|||||||
'gateway' => $device['gateway'],
|
'gateway' => $device['gateway'],
|
||||||
],
|
],
|
||||||
'state' => 'succes',
|
'state' => 'succes',
|
||||||
'command' => "null",
|
'command' => $command,
|
||||||
];
|
];
|
||||||
|
|
||||||
$subDevicesTypeList = SubDeviceManager::getSubDeviceSTypeForMater($deviceId);
|
$subDevicesTypeList = SubDeviceManager::getSubDeviceSTypeForMater($deviceId);
|
||||||
@ -263,7 +279,7 @@ if ($values != null || $values != "") {
|
|||||||
],
|
],
|
||||||
'state' => 'succes',
|
'state' => 'succes',
|
||||||
'value' => $subDeviceLastReordValue,
|
'value' => $subDeviceLastReordValue,
|
||||||
'command' => "null",
|
'command' => $command,
|
||||||
));
|
));
|
||||||
header($_SERVER["SERVER_PROTOCOL"]." 200 OK");
|
header($_SERVER["SERVER_PROTOCOL"]." 200 OK");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user