From cf0b1c40e6233d0dab77833a16422726910eb48d Mon Sep 17 00:00:00 2001 From: rsgrinko Date: Thu, 13 Jan 2022 11:59:41 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=20=D0=BF=D0=BE=D0=BB?= =?UTF-8?q?=D1=83=D1=87=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BF=D0=BE=D0=BA=D0=B0?= =?UTF-8?q?=D0=B7=D0=B0=D0=BD=D0=B8=D0=B9=20=D0=B4=D0=B0=D1=82=D1=87=D0=B8?= =?UTF-8?q?=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/lib/CAPI.class.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/inc/lib/CAPI.class.php b/inc/lib/CAPI.class.php index 9099af4..37def3b 100644 --- a/inc/lib/CAPI.class.php +++ b/inc/lib/CAPI.class.php @@ -16,6 +16,22 @@ class CAPI { foreach($result['devices'] as $key => $value) { $result['devices'][$key]['config'] = CIoT::getBoardConfig($value['id']); } + $result['status'] = 'ok'; 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]; + + } } \ No newline at end of file