public function ForwardData($JSONString) { // Prüfen und aufteilen nach ForwardDataFromSplitter und ForwardDataFromDevcie $Data = json_decode($JSONString); // IPS_LogMessage('ForwardDataFrom???:'.$this->InstanceID, print_r($Data,1)); switch ($Data->DataID) { case "{5971FB22-3F96-45AE-916F-AE3AC8CA8782}": //API $APIData = new TXB_API_Data(); $APIData->GetDataFromJSONObject($Data); $this->ForwardDataFromSplitter($APIData); break; case "{C2813FBB-CBA1-4A92-8896-C8BC32A82BA4}": //CMD $ATData = new TXB_Command_Data(); $ATData->GetDataFromJSONObject($Data); $this->ForwardDataFromDevice($ATData); break; } }
public function ReceiveData($JSONString) { $Data = json_decode($JSONString); // Nur API Daten annehmen. // IPS_LogMessage('ReceiveDataFromGateway:'.$this->InstanceID, print_r($Data,1)); if ($Data->DataID != '{0C541DDF-CE0F-4113-A76F-B4836015212B}') { return false; } $APIData = new TXB_API_Data(); $APIData->GetDataFromJSONObject($Data); // Auf NodeNamen prüfen if ($APIData->NodeName != $this->ReadPropertyString('NodeName')) { return false; } switch ($APIData->APICommand) { case TXB_API_Command::XB_API_Transmit_Status: $TransmitStatusID = $this->GetIDForIdent("TransmitStatus"); if (!$this->lock('Transmit_Status')) { throw new Exception('Receive Transmit Status is locked'); } $this->SendDebug('TX_Status_Received(8B)', $APIData->Data, 1); SetValueInteger($TransmitStatusID, ord($APIData->Data[1])); $this->unlock('Transmit_Status'); break; case TXB_API_Command::XB_API_Receive_Paket: $Receive_Status = $APIData->Data[0]; if ((ord($Receive_Status) & TXB_Receive_Status::XB_Receive_Packet_Acknowledged) == TXB_Receive_Status::XB_Receive_Packet_Acknowledged) { $this->SendDebug('Receive_Paket(OK)', substr($APIData->Data, 1), 1); $this->SendDataToChild(substr($APIData->Data, 1)); } else { $this->SendDebug('ReceivePaket(Error:' . bin2hex($Receive_Status) . ')', substr($APIData->Data, 1), 1); } break; case TXB_API_Command::XB_API_Remote_AT_Command_Responde: $ATData = new TXB_Command_Data(); $ATData->ATCommand = substr($APIData->Data, 0, 2); $ATData->Status = $APIData->Data[2]; $ATData->Data = substr($APIData->Data, 3); $this->SendDebug('Remote_AT_Command_Responde(' . $ATData->ATCommand . ')', $ATData->Data, 1); $this->SendDataToDevice($ATData); break; case TXB_API_Command::XB_API_IO_Data_Sample_Rx: $IOSample = new TXB_API_IO_Sample(); $IOSample->Status = $APIData->Data[0]; $IOSample->Sample = substr($APIData->Data, 1); $this->SendDebug('IO_Data_Sample_Rx(' . $APIData->APICommand . ')', $APIData->Data, 1); $this->SendDataToDevice($IOSample); break; default: /* SendData('unhandle('+inttohex(ord(APIData.APICommand),2)+')',APIdata.Data); */ break; } return true; }