Results 1 to 5 of 5

Thread: girder based ftp server for use with ip camera motion detector

  1. #1
    Join Date
    Jan 2004
    Location
    The Netherlands
    Posts
    2,140

    Default girder based ftp server for use with ip camera motion detector

    I have a levelone FCS-1030 IP network camera

    http://www.levelone.eu/products3.php?idu=7004&id=2077

    This camera has built in motion detector functionality.
    It can FTP an image, when there is motion.

    I don't need the image, I only need a girder event, to be used in combination with this electrical front door lock :

    http://www.promixis.com/forums/showthread.php?t=17314

    (i.e. I walk up to my front door, motion is detected by the camera, then the front door will open automatically (BUT ONLY if my bluetooth phone is in-range AND the house is currently unoccupied)

    the following is code for a simple 'fake' ftp server, that the camera can connect to without error and then executes a girder event...

    (note that the image is NOT received/stored by the ftp server nor am I planning to add that feature)


    of course, I know that you can do the same, with a normal X10 IR motion detector or a photocell
    but those will have to be physically mounted outside. the camera I can put inside, in the window (and this is more fun anyway...)....

    Code:
     
    --  pasv socket, does nothing
    local passive_port = 18694;
    if ( pasv_socket ) then
     pasv_socket:Close()
    end
    pasv_socket = gip.Listen(18694)
    if ( not pasv_socket ) then
      print("pasv Could not start listening")
      return
    end
    function ftp_clientcb(p1,p2)
     if ( p2 == gip.CONNECTIONCLOSED ) then
      --print("Client Connection Closed")
      return
     end 
     
     if ( p2 == gip.CONNECTIONESTABLISHED ) then
     --[[
      if ( p1 == 0 ) then
       print("New Client Connection") 
      else
       print("New Client Connection Failed: ", p1)
      end
     --]]
      return
     end 
     
     --print(">>>"..p1)
     
     if (string.find(p1,"USER ftpuser",1,1) ~= nil) then
       ftp_client_socket:Write ("331 User name OK\r\n");
     elseif (string.find(p1,"PASS ftpuser",1,1) ~= nil) then
       ftp_client_socket:Write ("230 User logged in\r\n");
     elseif (string.find(p1,"TYPE I",1,1) ~= nil) then
       ftp_client_socket:Write ("200 Type set to I\r\n");
     elseif (string.find(p1,"CWD",1,1) ~= nil) then
       ftp_client_socket:Write ("250 OK\r\n");
     elseif (string.find(p1,"PASV",1,1) ~= nil) then
       local ipaddress = comserv.GetAddrInfo(comserv.GetHostName())[1];
       ipaddress = string.gsub(ipaddress,"%.",",");
       ftp_client_socket:Write ("227 Entering passive mode ("..ipaddress..","..tostring(math.bshiftr(passive_port,8))..","..tostring(math.band(passive_port,255))..")\r\n");
     elseif (string.find(p1,"ALLO",1,1) ~= nil) then
       ftp_client_socket:Write ("200 OK\r\n");
     elseif (string.find(p1,"STOR",1,1) ~= nil) then 
       local filename =string.sub (p1,6,-1);
       print (filename);
       -- do something !!!!
       gir.TriggerEvent ("FTP_UPDATE",232,filename);
     
       ftp_client_socket:Write ("150 Opening BINARY mode data connection\r\n");
       ftp_client_socket:Write ("226 Transfer Complete\r\n");
     elseif (string.find(p1,"QUIT",1,1) ~= nil) then 
       ftp_client_socket:Write ("221 goodbye\r\n");
     end
    end
    function ftp_cbserver(p1,p2)
     
     if ( p2 == gip.CONNECTIONCLOSED ) then
      --print("Connection Closed")
      return
     end
     
     if ( p2 == gip.NEWCONNECTION ) then
     
      --print("New Incoming Connection")
      ftp_client_socket =p1
      p1:Callback(2,'\r\n', 1000, ftp_clientcb)
      p1:Write ("220 ready.\r\n");
     
      return
     end
     
     --print(p1)
     
     
    end
    if ( ftp_socket ) then
     ftp_socket:Close()
    end
    ftp_socket = gip.Listen(21)
    if ( not ftp_socket ) then
      print("Could not start listening")
      return
    end
    ftp_socket:Callback(2, '\r\n', 1000, ftp_cbserver)
    Last edited by mhwlng; December 15th, 2007 at 11:34 AM.

  2. #2
    Join Date
    May 2004
    Posts
    2,588

    Default

    Another cool idea, Marcell.
    I'm just wondering though, would it not be easy for someone to detect your phone and rename theirs to the same as yours, then enter your house after you leave?
    The next step is to incorporate some face recognition software into the system -- perhaps Veriface software?
    Beware of the robot.

  3. #3
    Join Date
    Jan 2004
    Location
    The Netherlands
    Posts
    2,140

    Default

    each phone has a unique mac address (which could be spoofed in theory, of course, perhaps if the hacker has some advanced bluetooth hardware development kit)

    Marcel
    Last edited by mhwlng; December 16th, 2007 at 02:59 AM.

  4. #4
    Join Date
    Jul 2007
    Location
    Netherlands
    Posts
    370

    Default

    Great idea! Just curious; how did you do the bluetooth part?

  5. #5
    Join Date
    Jan 2004
    Location
    The Netherlands
    Posts
    2,140

    Default

    Quote Originally Posted by Tieske8 View Post
    Great idea! Just curious; how did you do the bluetooth part?
    see here

    http://www.promixis.com/forums/showthread.php?t=14891

    Marcel

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •