$hardware = ChiconHardware::withSerial($db, $hdwSerial); $result = array("result" => array("code" => 200, "data" => $hardware->unAssignService($localId))); } else { $result = array("result" => array("code" => 400, "data" => array("error" => "Bad command"))); } echo json_encode($result); break; case "configureService": if (isset($_GET['srvLocalId']) and isset($_GET['hdwSerial']) and $user->isUserHardware($_GET['hdwSerial'])) { require '../class/ChiconHardware.class.php'; require '../class/ChiconService.class.php'; $hdwSerial = $_GET['hdwSerial']; $localId = $_GET['srvLocalId']; $myHdw = ChiconHardware::withSerial($db, $hdwSerial); if ($myHdw->isServiceRegistered($localId)) { $mySrv = ChiconService::withHardware($db, $_GET['srvLocalId'], $hdwSerial); $r = processConfig($mySrv, $myHdw); if (isset($r)) { $mySrv->setConfigArgs($r); } } } break; case "mapLed": if (isset($_GET['srvLocalId']) and isset($_GET['hdwSerial']) and isset($_GET['ledHdwId']) and isset($_GET['ledSrvId']) and $user->isUserHardware($_GET['hdwSerial'])) { require '../class/ChiconHardware.class.php'; $hdwSerial = $_GET['hdwSerial']; $localId = $_GET['srvLocalId']; $ledHdwId = $_GET['ledHdwId']; $ledSrvId = $_GET['ledSrvId']; $myHdw = ChiconHardware::withSerial($db, $hdwSerial);
<?php require '../class/ChiconHardware.class.php'; require '../class/ChiconService.class.php'; require '../class/DB.class.php'; // header('Content-type: application/json'); $db = new DB(); if (isset($_GET['mn'])) { $mn = $_GET['mn']; $myHdw = new ChiconHardware($db, $mn); if ($myHdw->isRegistered()) { $myHdw->getSerialNumber(); if (isset($_GET['srv'])) { if ($myHdw->isServiceRegistered($_GET['srv'])) { $mySrv = ChiconService::withHardware($db, $_GET['srv'], $myHdw->getSerialNumber()); $mySrv->run(); } else { echo "{error:'Unknown service'}"; } } elseif (isset($_GET['cfg'])) { $myHdw->getJsonConfig(); } elseif (isset($_GET['led'])) { $mySrv = ChiconService::withHdwLedId($db, $_GET['led'], $myHdw->getSerialNumber()); if ($mySrv != null) { $mySrv->runSelectedLed(); $mySrv->run(); } else { echo "{error:'Unknown service'}"; } } } else {