AP Mode With WiFi Shield?

Discussion related to "under the hood" OpenMV topics.
zoombach
Posts: 2
Joined: Fri Feb 17, 2017 7:46 am

AP Mode With WiFi Shield?

Postby zoombach » Fri Feb 17, 2017 7:54 am

Looks like the hardware would support AP Mode but is it exposed to use in OpenMV MicroPython? Any plans to do so?

Thanks
User avatar
kwagyeman
Posts: 1033
Joined: Sun May 24, 2015 2:10 pm

Re: AP Mode With WiFi Shield?

Postby kwagyeman » Fri Feb 17, 2017 9:54 am

Um, I remember Ibrahim talking about doing this but I don't think it's been implemented. I'll let Ibrahim respond.
Nyamekye,
User avatar
iabdalkader
Posts: 331
Joined: Sun May 24, 2015 3:53 pm

Re: AP Mode With WiFi Shield?

Postby iabdalkader » Fri Feb 17, 2017 11:39 am

Yes the HW supports AP mode but it's not implemented yet, I'll work on it ASAP.
zoombach
Posts: 2
Joined: Fri Feb 17, 2017 7:46 am

Re: AP Mode With WiFi Shield?

Postby zoombach » Fri Feb 17, 2017 12:07 pm

Thanks, that's great. I'll keep my eyes open for it!
schildroth
Posts: 16
Joined: Tue Feb 28, 2017 10:00 am

Re: AP Mode With WiFi Shield?

Postby schildroth » Mon Mar 06, 2017 7:04 am

How is AP Mode coming along? I'm anxious to try it as well.
User avatar
iabdalkader
Posts: 331
Joined: Sun May 24, 2015 3:53 pm

Re: AP Mode With WiFi Shield?

Postby iabdalkader » Mon Mar 06, 2017 9:36 pm

I'm working on it, I should have a testing image really soon.
schildroth
Posts: 16
Joined: Tue Feb 28, 2017 10:00 am

Re: AP Mode With WiFi Shield?

Postby schildroth » Tue Mar 07, 2017 10:27 am

:D Awesome! Thanks for the update.
User avatar
iabdalkader
Posts: 331
Joined: Sun May 24, 2015 3:53 pm

Re: AP Mode With WiFi Shield?

Postby iabdalkader » Thu Mar 09, 2017 4:15 pm

Hi,

AP mode is now supported!

If you can't wait until the next release, you can use the dev firmware images here:

https://github.com/openmv/openmv/tree/master/firmware

Here's an example script:

https://github.com/openmv/openmv/blob/m ... amer_ap.py

Note WINC1500 AP mode has some limitations:

* Only one client can connect at a time, I guess that's okay for a camera.
* It only supports OPEN or WEP security.
* There's a bug in the FW, when the client disconnects any bound sockets are lost (they just stop working).
As a workaround, I set a timeout for the server socket to force it to raise an exception and then reopen it.
schildroth
Posts: 16
Joined: Tue Feb 28, 2017 10:00 am

Re: AP Mode With WiFi Shield?

Postby schildroth » Thu Mar 09, 2017 4:42 pm

Excellent! I'll try it out. Thanks!
schildroth
Posts: 16
Joined: Tue Feb 28, 2017 10:00 am

Re: AP Mode With WiFi Shield?

Postby schildroth » Wed Mar 22, 2017 8:49 am

I'm not seeing how I update the firmware via the IDE. When I click on the 'Firmware Version' button in the lower right, it says I'm up to date and doesn't give an option to load new firmware. Is there a way around this or do I need to use the STM DfuSe upgrade software?
User avatar
iabdalkader
Posts: 331
Joined: Sun May 24, 2015 3:53 pm

Re: AP Mode With WiFi Shield?

Postby iabdalkader » Wed Mar 22, 2017 9:47 am

schildroth wrote:
Wed Mar 22, 2017 8:49 am
I'm not seeing how I update the firmware via the IDE. When I click on the 'Firmware Version' button in the lower right, it says I'm up to date and doesn't give an option to load new firmware. Is there a way around this or do I need to use the STM DfuSe upgrade software?
Tools->Run Bootloader and then upload the firmware binary ( firmware.bin )
schildroth
Posts: 16
Joined: Tue Feb 28, 2017 10:00 am

Re: AP Mode With WiFi Shield?

Postby schildroth » Wed Mar 22, 2017 12:08 pm

That worked. Awesome! It is working great for a first run. Nice!

Only hiccup is that it freezes every 3 seconds or so. Freezes for about a second and then comes back. Did you see the same thing?
User avatar
iabdalkader
Posts: 331
Joined: Sun May 24, 2015 3:53 pm

Re: AP Mode With WiFi Shield?

Postby iabdalkader » Wed Mar 22, 2017 5:48 pm

schildroth wrote:
Wed Mar 22, 2017 12:08 pm
That worked. Awesome! It is working great for a first run. Nice!

Only hiccup is that it freezes every 3 seconds or so. Freezes for about a second and then comes back. Did you see the same thing?
I don't remember seeing this issue, but I used the Android app for testing. Try increasing the server and/or client timeout in line 76
https://github.com/openmv/openmv/blob/m ... _ap.py#L76

And line 35
https://github.com/openmv/openmv/blob/m ... _ap.py#L35
schildroth
Posts: 16
Joined: Tue Feb 28, 2017 10:00 am

Re: AP Mode With WiFi Shield?

Postby schildroth » Wed Mar 22, 2017 7:54 pm

Thanks for the quick reply. Increasing the timeouts helped, but doesn't completely eliminate it. I'll play around with it a bit.
User avatar
iabdalkader
Posts: 331
Joined: Sun May 24, 2015 3:53 pm

Re: AP Mode With WiFi Shield?

Postby iabdalkader » Thu Mar 23, 2017 10:17 pm

schildroth wrote:
Wed Mar 22, 2017 7:54 pm
Thanks for the quick reply. Increasing the timeouts helped, but doesn't completely eliminate it. I'll play around with it a bit.
I'll also do some testing and get back to you.
User avatar
iabdalkader
Posts: 331
Joined: Sun May 24, 2015 3:53 pm

Re: AP Mode With WiFi Shield?

Postby iabdalkader » Sat Mar 25, 2017 4:27 pm

I did some testing and I'm not seeing the freeze, I'm testing with my Android phone.
zlite
Posts: 70
Joined: Sun Feb 05, 2017 9:26 pm

Re: AP Mode With WiFi Shield?

Postby zlite » Sun Apr 09, 2017 7:00 pm

When connecting to the cam in WiFI AP mode via the Open Terminal, should we be using UDP or TCP mode? And what port number?

I tried both modes with port 8080 that's used in the MPEG streaming demo, but that didn't work.

Apologies if this is in the documentation somewhere. I looked by couldn't find it
User avatar
kwagyeman
Posts: 1033
Joined: Sun May 24, 2015 2:10 pm

Re: AP Mode With WiFi Shield?

Postby kwagyeman » Sun Apr 09, 2017 7:23 pm

I'll have to debug OpenMV IDE with open terminal for this. Might be some stuff broken that I have to get working. Apologies.
Nyamekye,
zlite
Posts: 70
Joined: Sun Feb 05, 2017 9:26 pm

Re: AP Mode With WiFi Shield?

Postby zlite » Mon Apr 10, 2017 8:51 pm

I assume the process is as follows:

1) OpenMV is running Mpeg AP streaming example
2) Connect to OpenMV AP via WiFi
3) Test the Mpeg stream in a browser at the given IP: 192.168.1.1:8080
4) Create a new Open Terminal using TCP at the same IP: 192.168.1.1:8080
5) Everything magically works

I'm fine up until step 5 ;-)
User avatar
iabdalkader
Posts: 331
Joined: Sun May 24, 2015 3:53 pm

Re: AP Mode With WiFi Shield?

Postby iabdalkader » Mon Apr 10, 2017 9:40 pm

Note the shield doesn't support multiple connections, only one at a time. Never really tested the terminal so not sure if it works.
zlite
Posts: 70
Joined: Sun Feb 05, 2017 9:26 pm

Re: AP Mode With WiFi Shield?

Postby zlite » Mon Apr 10, 2017 10:39 pm

Even if you skip Step 3 (testing on a browser, and thus opening a second connection) it still fails. This is the error:

Waiting for connections..
Connected to 192.168.1.100:14960
socket error: 134642565
Waiting for connections..
socket error: -116
....
[repeat]
zlite
Posts: 70
Joined: Sun Feb 05, 2017 9:26 pm

Re: AP Mode With WiFi Shield?

Postby zlite » Tue Apr 11, 2017 9:00 pm

Just a ping to nag @kwagyeman to please take a look at this. I'm stalled until this gets fixed (or someone tells me how to do it properly -- right now it's undocumented, so I'm just guessing)
User avatar
kwagyeman
Posts: 1033
Joined: Sun May 24, 2015 2:10 pm

Re: AP Mode With WiFi Shield?

Postby kwagyeman » Tue Apr 11, 2017 9:53 pm

Let me test with a UDP connection really quick.
Nyamekye,
User avatar
kwagyeman
Posts: 1033
Joined: Sun May 24, 2015 2:10 pm

Re: AP Mode With WiFi Shield?

Postby kwagyeman » Tue Apr 11, 2017 10:35 pm

UDP stuff is broken.

Here's some code that works to stream images for TCP. Just connect to the IP address printed out and UDP port 8080 with Open Terminal in the IDE. Frame rate seems to be low, will have to look into that.

Will try AP mode next.
mjpeg_streamer_1.py
(1.55 KiB) Downloaded 20 times
Nyamekye,
User avatar
kwagyeman
Posts: 1033
Joined: Sun May 24, 2015 2:10 pm

Re: AP Mode With WiFi Shield?

Postby kwagyeman » Tue Apr 11, 2017 10:49 pm

This script works for AP mode. Connect to 192.168.1.1:8080 with Open Terminal. Frame rate seems to be low.
Attachments
mjpeg_streamer_ap_1.py
(2.01 KiB) Downloaded 20 times
Nyamekye,
User avatar
kwagyeman
Posts: 1033
Joined: Sun May 24, 2015 2:10 pm

Re: AP Mode With WiFi Shield?

Postby kwagyeman » Tue Apr 11, 2017 10:55 pm

Note that you should connect with the IDE after the camera is up and running. The IDE connects like a TCP client.
Nyamekye,
zlite
Posts: 70
Joined: Sun Feb 05, 2017 9:26 pm

Re: AP Mode With WiFi Shield?

Postby zlite » Tue Apr 11, 2017 11:39 pm

I'm sure I'm doing something stupid, but can't figure out what it is.

Here's what I'm doing (not connected to any other network, via Ethernet or Wifi):

1) Load the program you supplied,
2) Send to Cam over USB and run it
3) Connect to MVCAM wifi AP
4) Create a new Open Terminal with TCP connection at 192.168.1.1:8080
5) Wait for it to try to connect. It times out.

Is there some step I'm missing?

As I said before, this works great in a browser. Just not in Open Terminal
User avatar
kwagyeman
Posts: 1033
Joined: Sun May 24, 2015 2:10 pm

Re: AP Mode With WiFi Shield?

Postby kwagyeman » Tue Apr 11, 2017 11:44 pm

That's basically what I've done...

Um, so, try the non AP script. That should work for Open Terminal definitely (the first script I posted). Just connect to the IP_address:8080 that the cam prints out.
Nyamekye,
User avatar
iabdalkader
Posts: 331
Joined: Sun May 24, 2015 3:53 pm

Re: AP Mode With WiFi Shield?

Postby iabdalkader » Wed Apr 12, 2017 12:13 am

If you're sure AP mode works with the browser but not the IDE, then maybe you have a firewall ?
zlite
Posts: 70
Joined: Sun Feb 05, 2017 9:26 pm

Re: AP Mode With WiFi Shield?

Postby zlite » Wed Apr 12, 2017 12:47 am

Thanks for the suggestions. Your non-AP script works fine over WiFi in Station Mode, but nothing works in AP mode for me.
zlite
Posts: 70
Joined: Sun Feb 05, 2017 9:26 pm

Re: AP Mode With WiFi Shield?

Postby zlite » Wed Apr 12, 2017 2:10 am

Update: AP mode works on Linux. My problems have been on Windows. Maybe something to do with the built-in Windows firewall, as @iabdalkader suggests
zlite
Posts: 70
Joined: Sun Feb 05, 2017 9:26 pm

Re: AP Mode With WiFi Shield?

Postby zlite » Wed Apr 12, 2017 2:17 am

Update2: AP mode works on one Windows machine but not the other. Curiouser and curiouser.

Quick aside: can you run code from the Open Terminal window? I see a Run button, but no obvious way to open a Python file or even paste or type code into the terminal
User avatar
kwagyeman
Posts: 1033
Joined: Sun May 24, 2015 2:10 pm

Re: AP Mode With WiFi Shield?

Postby kwagyeman » Wed Apr 12, 2017 10:19 am

The run button executes whatever python script is being displayed in the editor. It does this by sending repl commands over the connection. For a good test try opening a serial port connection to the camera while the IDE is not connected.

Note however... I've noticed a bug where the repl code drops bytes when being sent data in paste mode. I think I have to slow down how fast I send out a script. Only short scripts seem to work.
Nyamekye,
zlite
Posts: 70
Joined: Sun Feb 05, 2017 9:26 pm

Re: AP Mode With WiFi Shield?

Postby zlite » Wed Apr 12, 2017 10:30 am

My question is how you get code to display in an Open Terminal at all. There's no obvious way to load a file in or even type or paste code. What am I missing?

-c
Attachments
Serial_Port_-_cu_Bluetooth-Incoming-Port_-_115_200_BPS.png
Serial_Port_-_cu_Bluetooth-Incoming-Port_-_115_200_BPS.png (45.08 KiB) Viewed 3844 times
User avatar
kwagyeman
Posts: 1033
Joined: Sun May 24, 2015 2:10 pm

Re: AP Mode With WiFi Shield?

Postby kwagyeman » Wed Apr 12, 2017 10:36 am

So, whatever is in the editor will be sent to the device when you click the run button in the terminal. The terminal doesn't locally echo. So, the microcontroller needs to be running a repl terminal over the serial connection.

To demonstrate this just try to connect the OpenMV Cam's virtual serial port that appears normally when plugged into your computer. This should have the repl terminal on it by default. If you press enter in the terminal window area then you should see ">>>". Try typing stuff, etc. Then hit the run button to run whatever script is in the editor window.
Nyamekye,

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 2 guests