Android/Eventghost Communication Suite

Das hab ich auch :

Hab mal einige Screener angehängt. Eventuell hat ja noch jemand ne Idee… Firewall auch schon komplett ausgeschaltet…das hat alles keine Wirkung. Wie muß den der DEBUG des Serversockets aussehen ---- ??

instancess.png

EDIT: verdammt… es gibt einen „debug mode“ im terremote event log… da steht alles drin… mist…:-D:-D

OH MANN!
Ich flippe vollkommen aus!
ich glaube ich habe das Symcon Forum mittlerweile durchgelesen…
Ich bekomme es einfach nicht hin.
Ich habe eigentlich alles korrekt konfiguriert aber, das eventlog von terremote bleibt einfach leer.
Auch das Debuglog von der Regvar sagt nichts…
ich habe echt keine Ahnung wie ich anfangen soll zu suchen.

Client Socket ist geöffnet, in der Regvar habe ich auch „Quelle und Zielt“ richtig eingestellt.
Senddata script ist angepasst…
Aktuell ist folgender Stand:
Buffertosend füllt sich mit jedem Versuch, errorcount bleibt aber leer…
Ich würde mich über Debugging-Hilfe freuen…

Meine Scripte:

sendData

<?
// This Script send events to any Eventghost compatible Client via RegisterVariable -> IPS_Client_Socket
// Outgoing Events are read from "BufferToSend" Variable. This works like a send Buffer
// You should use my "SendToDroid() function to write Commands to the Buffer.

// Register variable MUST be named: "regVarDataBuffer"

// If you want to communicate with Eventghost PC please read comment near line 80

// During communication idle and Client Socket is dissabled (Gray Icon), this improved stability and prevent from mess up logging
// If Client is not reachable (Cleint Software Down) ClintSocket become Red Icon, this is cleard after first succesfull Event transfer.
// It works fine for me, but maybe your enviroment need any aditional error handling, check area around line 62

// The Script had been tested with: Eventghost for PC , Eventghost for Anroid, terRemote for Android
// rev 1.0 created by Bernhard Baptist  04.10.2012

// Change Configuration parameters if needed
$maxRetry = 5;  // retries until buffer is cleared
$socketReadyDelay = 10; //delay between retries if socket not ready
$msgDelay = 10;  // delay in sec until timeout and command re-send command

//-------------------------------------------------------------------------------------------
// Nothing to configure below this line

$Id_ClientSocket = IPS_GetParent($_IPS['SELF']);
$IDRegVar = @IPS_GetObjectIDByName("RegVarDataBuffer", $Id_ClientSocket);
$IDBuffer = CreateVariableByName($Id_ClientSocket, 'BufferToSend', 3);
$IDerrorCount = CreateVariableByName($Id_ClientSocket, 'errorCount', 1);

Switch ($_IPS['SENDER'])
    {
      Case "Execute":
    // reserved for debug
    break;

    Case "RunScript":
    if (IPS_GetInstance($Id_ClientSocket)['InstanceStatus'] != 102) {// Check if Socket is Active
       IPS_SetProperty($Id_ClientSocket, "Open", true);
       IPS_ApplyChanges($Id_ClientSocket);
       if (IPS_GetInstance($Id_ClientSocket)['InstanceStatus'] != 102) {
              IPS_SetScriptTimer($_IPS['SELF'], $socketReadyDelay);  //arm Timer for retry
             echo "Keine Verbindung zu ".IPS_GetName($Id_ClientSocket);
            Return;  // Stop in case Socket Open fail
            }
    }
    RegVar_SendText($IDRegVar, "quintessence
\r");             //  start handshake
                IPS_SetScriptTimer($_IPS['SELF'], $msgDelay);          //arm Timer for retry if Fail

    break;

    Case "TimerEvent":
        IPS_SetScriptTimer($_IPS['SELF'], 0);                          //stop Timer
        $errorCount=GetValue($IDerrorCount);
      $errorCount=$errorCount+1;
      if ($errorCount < $maxRetry) {
         SetValue($IDerrorCount,$errorCount);
             IPS_RunScript($_IPS['SELF']);                                // Run next try
            }
        else {
        SetValue($IDerrorCount,0);
        SetValueString($IDBuffer,"nothing to send");
            // todo: add additional error processing there
            }
      break;

    Case "RegisterVariable":
        $data = $_IPS['VALUE'];
        $data = trim($data);

        Switch ($data) {
        Case "accept":                                                    // ready to send data
              $buffer=GetValueString($IDBuffer);                  //re-read in case modified meanwhile
                  $data_to_send= substr($buffer,0,strpos ($buffer ,"_+_"));
            $posPayload = strpos ($data_to_send ,",");
            if ($posPayload > 0){                           // check if Payload should be added
                     $payload = "payload ".substr($data_to_send,$posPayload+1);
                    RegVar_SendText($IDRegVar,$payload."
");  //here the payload is sent
                      $data_to_send= substr($data_to_send,0,$posPayload);
                RegVar_SendText($IDRegVar,$data_to_send."
\r");  //here the event is sent
                    }
                 else {
                     RegVar_SendText($IDRegVar,$data_to_send."
\r");  //here the event is sent
                    }
             RegVar_SendText($IDRegVar, "close
\r");
// Eventghost PC does not send "close" so we cannot do proper handshake
// Remark next three lines in case your Client is Eventghost PC
// unremark this line: //    sleep(1);

             IPS_SetScriptTimer($_IPS['SELF'], $msgDelay);                      //arm Timer for retry if Fail
         break;
        case "close":                                                             // data successfull send
           IPS_SetScriptTimer($_IPS['SELF'], 0);                                  //Send Ok, stop Timer
         SetValue($IDerrorCount,0);
            IPS_SetProperty($Id_ClientSocket, "Open", false);
          $buffer=GetValueString($IDBuffer);                              //re-read in case modified meanwhile
            if (substr_count ($buffer,"_+_")> 1) {
               $pos_next =strpos ($buffer ,"_+_");
            SetValueString($IDBuffer,substr($buffer,$pos_next+3,strlen($buffer))); //update
    //            sleep(1);  //  todo: find minimum delay
                IPS_RunScript($_IPS['SELF']);                                 // re-run to process next command
                }
            else{
                SetValueString($IDBuffer,"nothing to send");
            }

       break;

          case "declined":                                                         // any problem
          // todo: add logic to recover,
            IPS_SetProperty($Id_ClientSocket, "Open", false);
         IPS_SetScriptTimer($_IPS['SELF'], 1);                                  //arm Timer for retry

       break;

        Default:                                                                   // send Hash ti initiate handshake
            $data .= ":";
             $hash = md5($data);
             $hash .= "
";
         RegVar_SendText($IDRegVar, $hash);
        Break;
        }

}


// common helper Function
function CreateVariableByName($id, $name, $type)
{
   Global ${$_IPS['SELF']};
   $vid = @IPS_GetVariableIDByName($name, $id);
   if($vid===false) {
         $vid = IPS_CreateVariable($type);
      IPS_SetParent($vid, $id);
      IPS_SetName($vid, $name);
      IPS_SetInfo($vid, "This Variable was created by Script #".$_IPS['SELF']);
        }
    return $vid;

}
?>

Mein test-Script:

<?

include_once "SendToDroid_include.ips.php";
// this library provides SendtoDroid() function;

$Id_ClientSocket = 43945  /*[Client Socket Android]*/  ; 
$new = "muh" ; 
SendtoDroid($Id_ClientSocket ,$new);  
?>

Meine Sendtodroid Funktions.Datei

<? // Call this function to add new command to ClientSocket message queue
// Args[$IDBuffer = ID of ClientSocket] [$new... command to be send]
function SendtoDroid($Id_ClientSocket,$new) {


$IDBuffer = @IPS_GetObjectIDByName("BufferToSend", 43945);
$IDSendScript = @IPS_GetObjectIDByName("sendData", 20288);


$maxQueueLenght = 10;  // max Commands in Queue
$old = GetValueString($IDBuffer);
// cleanup queue if too much commands pending
if (substr_count ($old,"_+_") >  $maxQueueLenght) {
   $old ='nothing to send';    //todo: add error processing if required
     }
if ($old == 'nothing to send') {
   SetValue($IDBuffer,$new."_+_");
  IPS_RunScript($IDSendScript);
    }
    else {
    SetValue($IDBuffer,$old.$new."_+_");
    }
}  
?>

EDIT: verdammt… es gibt einen „debug mode“ im terremote event log… da steht alles drin… mist…:-D:-D

2.PNG

Edit

Geht unter 4.2 … musste nur das Pad neu starten

Gruß
Jens