Your comments

i understand your side for a http server. you don't have to comment.


but to use the normal tcpserver, why is the .send method not working?

Checked it again with wireshark. The iRidium Server does not send out any data when you call the .Send Method, until you kill the device. Thats a bug i think. iRidium Team?

Tried it, doesn't make any changes. Looks like the data is buffered and not sent out directly. When you delete the part:

IR.SetTimeout(200,function()
   {
   HTTPServer.Disconnect();
   });
  
   IR.SetTimeout(400,function()
   {
   HTTPServer.Connect();
   });

You get no answer in the browser until you restart the iridiumserver or upload a new project. On a normal Webserver, the Server closes the connection to the client when the data was sent out. So, how to close a Client connection?

yes, but the iRidium team should please jump in and tell me how to finish the client connection (flushing out the buffered data) without disconnecting and reconnecting the driver itself. it works, but thats a little buggy to me.

hi,


you see the switch-part? in that part you can do anything you want like:


   switch (httpRequest) {
   
      case 'favicon.ico':
         HTTPServer.Send(['HTTP/1.1 302 Found\n']);
         HTTPServer.Send(['Location: http://www.iridiummobile.net/favicon.ico\n\n']);
      break;
      case 'command1':
         IR.GetDevice("HDL-BUS Pro Network (UDP)").Set("Curtain1:Curtain Up/Stop/Down",1);
         IR.GetDevice("KNX Router (KNXnet/IP)").Set(1,"red"); 
         IR.GetDevice("BAOS").Set("BAOS Command",100);
         IR.GetDevice("Global Cache").Set("POWER ON","");
         IR.GetDevice("Sonos").Set("Play","");
         HTTPServer.Send(['HTTP/1.0 200 OK\n']);
         HTTPServer.Send(['Content-Type: text/plain\n\n']);
         HTTPServer.Send(['Your command was: ' + httpRequest]);
      break;
      default:
         HTTPServer.Send(['HTTP/1.0 200 OK\n']);
         HTTPServer.Send(['Content-Type: text/plain\n\n']);
         HTTPServer.Send(['OK you requested: ' + httpRequest]);
      break;
      } 

using it with a device that can make a http request, like a browser:

http://<IP_OF_IRIDIUMSERVER/command


like


http://192.168.1.100/command1


then you get back a short message "Your command was: command1" and all the action within the 'command1' switch part will be executed. But thats a really simple example, you can do whatever you want within your JS. you can send back html code too by changing the content-type to text/html.


Ciao

 Martin


here's a snippet i just wrote in a few minutes (not good coding), it is working you see the requested file/command in the log and you get a message back to the browser. the only thing i couldn't figured out was how to force the HTTPServer to send out the data to the client without disconnecting and reconnecting them. whats the way to disconnect a client that is connected to a CUSTOM_TCP_SERVER? 


var HTTPServer = IR.CreateDevice(IR.DEVICE_CUSTOM_SERVER_TCP, "HTTPServer",
   {Port: 80, MaxClients: 3});
var httpRequestMessage = "";
IR.AddListener(IR.EVENT_ONLINE,HTTPServer,function()
{
IR.Log("*** HTTP Server online");
});
IR.AddListener(IR.EVENT_OFFLINE,HTTPServer,function()
{
IR.Log("*** HTTP Server offline");
});
IR.AddListener(IR.EVENT_RECEIVE_TEXT, HTTPServer, function(text)
{
  
  httpRequestMessage = httpRequestMessage + text;
  
  var httpRequestEND = httpRequestMessage.indexOf('\r\n\r\n');
  
  var GETstartpos = httpRequestMessage.indexOf('GET ');
  
  if ((httpRequestEND != -1) && (GETstartpos != -1)) {
    
   httpRequestMessage = httpRequestMessage.slice(GETstartpos + 5);
   
   var GETendpos = httpRequestMessage.indexOf(' ');
   
   var httpRequest = decodeURIComponent(httpRequestMessage.slice(0,GETendpos));
   
   IR.Log("*** HTTP Request: " + httpRequest);
   
   httpRequestMessage = "";
   
   switch (httpRequest) {
   
      case 'favicon.ico' :
         HTTPServer.Send(['HTTP/1.1 302 Found\n']);
         HTTPServer.Send(['Location: http://www.iridiummobile.net/favicon.ico\n\n']);
      break;
      default:
         HTTPServer.Send(['HTTP/1.0 200 OK\n']);
         HTTPServer.Send(['Content-Type: text/plain\n\n']);
         HTTPServer.Send(['OK you requested: ' + httpRequest]);
      break;
      } 
   
   IR.SetTimeout(200,function()
   {
   HTTPServer.Disconnect();
   });
   
   IR.SetTimeout(400,function()
   {
   HTTPServer.Connect();
   });
   
   }
 
 });



So maybe the iRidium Team can help out with the Sending flush to the client!?


Ciao

 Martin

so thats no option, would take months that the drivers are updated. any other z-wave solutions by the way of fibaro or so?