Video Streaming using HTTP

Posted on
  • I am starting a project using a WIFI module and the node style server. Essentially this project is a proof of concept for some other things I want to try out. Here are the details:

    I am building a web interface to drive around an RC car in our office. Essentially you will be driving the car from your browser. The board is connected to a LIPO battery and has the WIFI module installed. I can serve the page in the browser and control the car. The problem I am running into is that unless you can actually see the car you don't know what the controls are doing. For this reason I want to add a camera to the board. I am having some difficulty with this portion, however. I don't know which module to buy or how I should connect it to the board/webpage. I assume that I will have to stream the video somehow but I'm not sure where to start. I have been looking at the OV7670 Camera module for Arduino, but I don't want to buy it unless it will work.

    Do any of you have any insight? I am not expecting you to write the code for me, I just need a place to start! I realize that the Espruino may not be capable of full frame streaming, but I would be willing to purchase something else to make this happen.

    Thanks for you help!

  • I was researching this more and found this board: TL-WR703N. It is essentially a modified wireless router. It comes pre-flashed with OPENWRT and it sets up a LAN address with a full frame video stream.

    I may just set up a USB camera and plug it into this board. So essentially I will be bypassing the Espruino for the video portion and simply using it to power on/off the camera. Since the TL-WR703N has it's own address on the network, I will just set that address to a remote stream on the Espruino HTTP server. I will probably also set up other remote assets like the stylesheet, video player and interface JS to save space on the board. I will update here after I have figured out more details!

  • Hi Rayman,

    Yes, that's probably the best bet. Espruino really isn't cut out for handling the large amounts of data needed for video. After all, a single 320x240x24bpp frame of video uses 5x more memory than Espruino has!

    If you want to control everything from one place, your other option is to plug Espruino into the TL-WR703N via USB, and then you can simply send it commands from whatever is running on the router (http://www.espruino.com/Interfacing).

  • Thanks @Gordon!

    I am having another issue, however, but it is with the CC3000 board. It seems like the board will just timeout on a large portion of the requests I am sending to it. I thought maybe it was just human error, but after some testing it seems like the board is just not getting the request and therefor I receive no response. I checked out some of the other forum posts on here and tried the IDE fix where you remove the \x03 from the line and I am still getting issues. Is this a problem with the memory or possibly the driver? If it is the driver, what can I do to fix it? Is there an updated driver and/or can I modify the driver in any way?

  • You're using Espruino 1v50? And with an HTTP server rather than a client?

    I thought it was a lot more stable now, but do you have a way to get the timeout to happen immediately?

    The issue is that the TI driver sends SPI data, and then basically just loops until it gets the response it wants. There's no recovery mechanism and no CRC, so if the data gets corrupted in either direction or if the module itself stops working then it just hangs.

    I modified their driver to add the timeout code to try and avoid a hang, but it seems that after timing out it still crashes. If you're happy poking around then it'd be great if you could try and fix it - but you really need to get a hardware debugger set up so it's a bit difficult.

    Otherwise, if you have an arduino then you can try updating the firmware on the CC3000 itself and see if that helps: https://github.com/cmagagna/CC3000Patch

  • So I set up the board as a client instead of a server to try and keep it from timing out, but I am still having issues. I have the board checking a URL for a current set of JSON commands from the website, but the problem I am seeing is that after about 50 requests or so, I get no response from the server. Then I get an error and it resets all of my loops.

    As far as I can tell, there is no fix I will be able to implement myself (mainly from lack of knowledge). I can try updating the firmware but I just bought the WIFI this month, so I would imagine it is using the latest firmware release. Should I just wait until there is a patch? Or are there other things I can try? Thanks for your help so far, btw!

  • The best bet would be to wait until version 1v51 comes out (or try the latest from http://www.espruino.com/binaries/git). Hopefully I'll get it out today, but I made some more changes to the TI driver. Hopefully it'll be more stable now, and I added code so that if there's a problem with the interface, it actually power cycles the CC3000 and reinitialises it.

    The CC3000 will almost certainly have outdated firmware no matter when you bought it. I believe Adafruit found a firmware version they were happy with and just decided to stick with it in order to make sure that nobody's code needed changing. I wouldn't update yet though - hopefully these recent changes will really improve matters.

  • The power cycling is definitely making this work much better. I can go for a while without having a timeout. When I do have them, though, they seem to hang up the power cycling. Here is the output I am getting from the IDE:

    ERROR: Timeout in CC3000 driver (4103)
    ERROR: Connect failed
    at line 11 col 4
      });}
        ^
    in function called from system
    Looks like CC3000 has died again. Power cycling...
    Execution Interrupted during event processing - clearing all timers and watches.
    

    This error resulted in the power cycle working correctly at which point the board continued processing the JSON commands. After a while I got this error:

    ERROR: Timeout in CC3000 driver (4112)
    ERROR: Connect failed
    at line 11 col 4
      });}
        ^
    in function called from system
    Looks like CC3000 has died again. Power cycling...
    ERROR: Timeout in CC3000 driver (16384)
    Execution Interrupted during event processing - clearing all timers and watches.
    

    This error caused the board to become unresponsive and require a soft reset. I thought maybe the code it was pointing to was incorrect, but it is just the closing brackets for the http.get callback. Not to mention the code works perfectly prior to the error.

    I should mention, for debugging, that the way I am getting this error is by doing a timeout loop of requests. Basically, board makes HTTP request, on response set timeout to do another HTTP request. This essentially is a setInterval, only I am waiting on the response before I fire off another timeout.

    Also, I have noticed that the error codes that are causing the CC3000 driver to timeout are 4104 and 4112. The error code 4103 seems to always power cycle correctly. At this point I have a decently working prototype, so I don't need a quick response or anything - I just want to help spot any issues and help with debugging! Thanks for your help @Gordon!

  • Thanks! The one that's the big issue here is 16384 (that's the 'startup' code so if that fails the Cc3000 has failed to reboot). I thought I'd changed that though so that if it failed it would keep retrying it - are you using the latest firmware?

    If you're interested, the codes come from: https://github.com/espruino/Espruino/blo­b/master/libs/network/cc3000/hci.h

    4104 is socket select which is something that should always return immediately - so the fact that it's not means we definitely need a restart. However 4112 is gethostname, which you might expect would take a long time sometimes? I wonder whether I should have a longer timeout for that.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Video Streaming using HTTP

Posted by Avatar for Rayman @Rayman

Actions