Добавлен метод получение показаний датчика
This commit is contained in:
1 parent
670e0826c1
commit
cf0b1c40e6
1 file changed
+16
@@ -16,6 +16,22 @@ class CAPI {
|
|||||||
foreach($result['devices'] as $key => $value) {
|
foreach($result['devices'] as $key => $value) {
|
||||||
$result['devices'][$key]['config'] = CIoT::getBoardConfig($value['id']);
|
$result['devices'][$key]['config'] = CIoT::getBoardConfig($value['id']);
|
||||||
}
|
}
|
||||||
|
$result['status'] = 'ok';
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getSensorValue() {
|
||||||
|
global $USER;
|
||||||
|
$sensor = $_REQUEST['sensor'];
|
||||||
|
$deviceId = $_REQUEST['deviceId'];
|
||||||
|
|
||||||
|
$arUserDevices = getUserDevices($USER['id']);
|
||||||
|
if (!in_array($deviceId, $arUserDevices)) {
|
||||||
|
return ['status' => 'fail', 'message' => 'Выбранное устройство не принадлежит текущему пользователю'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$sensorValue = CIoT::getSensorData($deviceId, $sensor);
|
||||||
|
return ['status' => 'ok', 'deviceId' => $deviceId, 'sensor' => $sensor, 'value' => $sensorValue];
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user