As the title says... Chat on...

User avatar
By kitsune_x3
#38159 hi,

i'm tryting to add a small camera to my esp controlled robot, but i dont seem to be able to get a video stream trough .
let me clarify , i have an esp sending serial to an arduino used to controll the motors but for the interface i have a small (ugly) web page running on my esp . My thought was to use the esp as a small host/router to connect the camera to and my cellphone/laptop/homenetwork/ wathever to but .... i dont seem to be able to host the video stream on the esp when i connect the camera ( i think it's connecting) to the ESP network . it does work when i connect the esp to my home network ant the camera also to the home network. " dont worry i drew(?) a litle diagram to make it more clear .
So i was hoping someone could point me to the right direction .
i also am sorry if the spelling and grammar are all over the place .

Code: Select all
gpio.mode(3,gpio.OUTPUT)
gpio.mode(4,gpio.OUTPUT)
function split(s, delimiter)
    result = {};
    for match in (s..delimiter):gmatch("(.-)"..delimiter) do
        table.insert(result, match);
    end
    return result;
end
function urldecode(payload)
    result = {};
    list=split(payload,"\r\n")
    list=split(list[1]," ")
    list=split(list[2],"\/")
    table.insert(result, list[1]);
    table.insert(result, list[2]);
    table.insert(result, list[3]);
    return result;
end

function index(conn)

   
    conn:send('HTTP/1.1 200 OK\r\nConnection: keep-alive\r\nCache-Control: private, no-store\r\n\r\n\
     <!DOCTYPE HTML><html><head><style>input[type=submit] {font-size:large;width:8em;height:4em;}</style>\
     <meta content="text/html;charset=utf-8"><title>ROBBIT</title>\
     <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">\
     <body bgcolor="#ffffff"><h2>Robbit</h2><hr>\
     <img style="-webkit-user-select: none" src="http://192.168.4.15/?action=stream">\
     <form action="/robbit/1/1" method="POST">\
     <input type="submit" value="forward"/></form><br><br>\
     <form action="/robbit/2/1" method="POST">\
     <input type="submit" value="right" /></form><br><br>\
     <form action="/robbit/3/1" method="POST">\
     <input type="submit" value="left"/></form><br><br>\
     <form action="/robbit/4/1" method="POST">\
     <input type="submit" value="back"/></form><br><br>\
     <form action="/robbit/5/1" method="POST">\
     <input type="submit" value="stop"/></form><br><br>\
     </form>\
     </body></html>')
end
function notfound(conn)
     conn:send('HTTP/1.1 404 Not Found\r\nConnection: keep-alive\r\nCache-Control: private, no-store\r\n\r\n\
          <!DOCTYPE HTML>\
         <html><head><meta content="text/html;charset=utf-8"><title>ESP8266</title></head>\
          <body bgcolor="#ffe4c4"><h2>Page Not Found</h2>\
          </body></html>')
end



srv:listen(80,function(conn)
    conn:on("receive",function(conn,payload)
      --print("Http Request..\r\n")
     
      list=urldecode(payload)
      if ((list[2]=="") or (list[2]=="index.html")) then
          index(conn)   
      elseif (list[2]=="robbit") then
         
          local status = tonumber(list[3])
          if (status == 1) then
               print("f")
          end 
          if (status == 2) then
               print("r")
          end
          if (status == 3) then
               print("l")
          end
          if (status == 4) then
               print("b")
          end
          if (status == 5) then
               print("s")
          end     
          index(conn)
      else
          notfound(conn)   
      end     
      conn:close()
    end)
end)


Image Image