private function WaitForResponse($APIData_Command) { $ReplyAPIDataID = $this->GetIDForIdent('ReplyAPIData'); for ($i = 0; $i < 300; $i++) { if (GetValueString($ReplyAPIDataID) === '') { IPS_Sleep(5); } else { if ($this->lock('ReplyAPIData')) { $ret = GetValueString($ReplyAPIDataID); SetValueString($ReplyAPIDataID, ''); $this->unlock('ReplyAPIData'); $JSON = json_decode($ret); $APIData = new ISCP_API_Data(); $APIData->GetDataFromJSONObject($JSON); if ($APIData_Command == $APIData->APICommand) { return $APIData; } else { $i = $i - 100; if ($i < 0) { $i = 0; } } } } } if ($this->lock('ReplyAPIData')) { SetValueString($ReplyAPIDataID, ''); $this->unlock('ReplyAPIData'); } return false; }
public function ForwardData($JSONString) { $Data = json_decode($JSONString); if ($Data->DataID != "{8F47273A-0B69-489E-AF36-F391AE5FBEC0}") { return false; } $APIData = new ISCP_API_Data(); $APIData->GetDataFromJSONObject($Data); try { $this->ForwardDataFromDevice($APIData); } catch (Exception $ex) { trigger_error($ex->getMessage(), $ex->getCode()); return false; } return true; }