示例#1
0
 private function SendDataToSplitter(TXB_API_Data $APIData)
 {
     //        IPS_LogMessage('SendDataToSplitter:'.$this->InstanceID,  print_r($APIData,1));
     $Data = $APIData->ToJSONString('{0C541DDF-CE0F-4113-A76F-B4836015212B}');
     IPS_SendDataToChildren($this->InstanceID, $Data);
 }
示例#2
0
 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;
 }