Topics

Wemos D1 wifi - connection dropping

Jamie Flinn
 

Looking for anyone with experince as such:

  1. Wemos  broadcasts SSID
  2. Can connect via phone wifi but Onstep App is very slow
  3. Any connection drops after a brief connection
  4. Same for sky safari
  5. Not able to get to the built in webserver site

 

This was sudden after a solid week of testing and of course it happened on first run at remote site! Grrrrr

Before I flash/replace this Wemos looking to see if anyone has suffered the same and perhaps knows why it would go belly up like this

 

Thanks

Jamie

 

Jamie Flinn
 

Addendum….setup juts now and EVERYTHING is working but when away from my home it was not – that leave me with “station mode” causing the issue – is it possible that the server causes itself problems when it cannot find the other network to connect to – perhaps some sort of polling loop that cause timeouts?

 

Thanks

 

From: main@onstep.groups.io On Behalf Of Jamie Flinn
Sent: Monday, June 29, 2020 7:30 AM
To: onstep@groups.io
Subject: [onstep] Wemos D1 wifi - connection dropping

 

Looking for anyone with experince as such:

1)      Wemos  broadcasts SSID

2)      Can connect via phone wifi but Onstep App is very slow

3)      Any connection drops after a brief connection

4)      Same for sky safari

5)      Not able to get to the built in webserver site

 

This was sudden after a solid week of testing and of course it happened on first run at remote site! Grrrrr

Before I flash/replace this Wemos looking to see if anyone has suffered the same and perhaps knows why it would go belly up like this

 

Thanks

Jamie

 

Rafael Barberá Córdoba
 

Which port are you using? On some operating systems (like macOS or iOS) you must use a permanent connection (port 9998)

Jamie Flinn
 

9999 – going from android

 

From: main@onstep.groups.io On Behalf Of Rafael Barberá Córdoba
Sent: Monday, June 29, 2020 8:19 AM
To: main@onstep.groups.io
Subject: Re: [onstep] Wemos D1 wifi - connection dropping

 

Which port are you using? On some operating systems (like macOS or iOS) you must use a permanent connection (port 9998)

Drew 🔭📷🚴‍♂️
 

On Mon, Jun 29, 2020 at 08:14 AM, Jamie Flinn wrote:
but when away from my home it was not – that leave me with “station mode” causing the issue – is it possible that the server causes itself problems when it cannot find the other network to connect to
I think we need some more details about your setup. I assume you have something that is operating as a DHCP server such as a WiFi router? It may be that using the access point mode when remote is your solution but we need to understand your configuration.

Jamie Flinn
 

Hi Drew…

I was set to station mode with DHCP enabled

It appears the when no other network is availble (such as at remote site) the server is trying to find the listed SSID for station mode and then flipping back and forth between accesspoint and station (or polling that mimics this)

 

Once my home network was in range the connections are all good and quick

I have disabled station mode and am also in good state

My next test is to disable my home routers so no other network exists (simulate the back woods 😊 )

 

Cheers

J

 

From: main@onstep.groups.io On Behalf Of Drew ?????????
Sent: Monday, June 29, 2020 8:35 AM
To: main@onstep.groups.io
Subject: Re: [onstep] Wemos D1 wifi - connection dropping

 

On Mon, Jun 29, 2020 at 08:14 AM, Jamie Flinn wrote:

but when away from my home it was not – that leave me with “station mode” causing the issue – is it possible that the server causes itself problems when it cannot find the other network to connect to

I think we need some more details about your setup. I assume you have something that is operating as a DHCP server such as a WiFi router? It may be that using the access point mode when remote is your solution but we need to understand your configuration.

Drew 🔭📷🚴‍♂️
 

I am assuming you have OnStep setup as the DHCP server with no additional router. OnStep does not "switch". If it cannot find the station mode connection it goes into Access Point mode and stays there. That you had any connection at all is the mystery

I would suggest you experiment with Access mode. No need to disable the home routers. Just configure your device to see it as the "network" instead of your home network.

Khalid Baheyeldin
 

This may all be due to that incompatibility problem with specific devices.

When it is like this:

Phone -> router -> OnStep
The router and OnStep are compatible and everything works.

When it is like this:

Phone -> OnStep
The phone has some incompatibility with OnStep's WeMos, and the connection is either poor quality or none at all.

If you have any other devices with WiFi (another family member's phone, laptop, iPad, tablet), try connecting directly to OnStep, and running the WiFi web site, and see if it works. If it does, then it is that random WiFi incompatibility issue for sure.

Jamie Flinn
 

Update

Ran a VERY scientific test 😉 :

  1. Set Onstep via server to be ONLY access point mode – confired station mode off
  2. Loaded my puppy in the car and headed to Tim Hortons (yum – ordered a Latte)
  3. Fired up the OnStep and the  OnStep wifi acess point is the only connection
  4. Run the app = instant and very quick response
  5. Surf some menus – all good

 

So the STATION mode from description is supposed to try to connect and then switch to ACCESS POINT mode but form what I saw last night there are some synchronous blocking calls happening, and withoiut looking at code I supect a polling routing as I WAS able to connect for short and delayed periods, exactly as you if some polling or another thread was thrashing the system….maye be something to checkout but for now the problem is solved by keeping access point mode as the main operating mode…and having a Latte with a Puppy (that has to help somehow)

 

Cheers

Jamie

 

From: main@onstep.groups.io On Behalf Of Drew ?????????
Sent: Monday, June 29, 2020 9:05 AM
To: main@onstep.groups.io
Subject: Re: [onstep] Wemos D1 wifi - connection dropping

 

I am assuming you have OnStep setup as the DHCP server with no additional router. OnStep does not "switch". If it cannot find the station mode connection it goes into Access Point mode and stays there. That you had any connection at all is the mystery

I would suggest you experiment with Access mode. No need to disable the home routers. Just configure your device to see it as the "network" instead of your home network.

Howard Dutton
 

On Mon, Jun 29, 2020 at 11:06 AM, Jamie Flinn wrote:
and withoiut looking at code I supect a polling routing as I WAS able to connect for short and delayed periods, exactly as you if some polling or another thread was thrashing the system….maye be something to checkout but for now the problem is solved
This kind of thing, I read, does go on down in the Espressif network libraries.  Quite some time ago I encountered it and for this reason made the statement that you should only enable one interface at a time... other users, however reported having no ill effects from enabling both at once.  So here we are.  I guess one could add the following in an attempt to shutdown the station mode side (which never connected but is still alive when falling back to AP mode)...

TryAgain:
  if (accessPointEnabled && !stationEnabled) {
    WiFi.disconnect();

    WiFi.softAP(wifi_ap_ssid, wifi_ap_pwd, wifi_ap_ch);

Jamie Flinn
 

Yup…and both were enabled – not a big deal now I know what was causing as it is easy enough to do prior to leaving the site for STATION mode – process vs code 😊

Nothing like getting on site however with something that was super solid and you then start “oh you have got to be kidding me” in the dark

 

I fiddle with the code if I get some time and see if I can get something working that doesn’t block…ahhh the beauty of ardiuno

 

Cheers

 

From: main@onstep.groups.io On Behalf Of Howard Dutton
Sent: Monday, June 29, 2020 2:54 PM
To: main@onstep.groups.io
Subject: Re: [onstep] Wemos D1 wifi - connection dropping

 

On Mon, Jun 29, 2020 at 11:06 AM, Jamie Flinn wrote:

and withoiut looking at code I supect a polling routing as I WAS able to connect for short and delayed periods, exactly as you if some polling or another thread was thrashing the system….maye be something to checkout but for now the problem is solved

This kind of thing, I read, does go on down in the Espressif network libraries.  Quite some time ago I encountered it and for this reason made the statement that you should only enable one interface at a time... other users, however reported having no ill effects from enabling both at once.  So here we are.  I guess one could add the following in an attempt to shutdown the station mode side (which never connected but is still alive when falling back to AP mode)...

TryAgain:
  if (accessPointEnabled && !stationEnabled) {
    WiFi.disconnect();

    WiFi.softAP(wifi_ap_ssid, wifi_ap_pwd, wifi_ap_ch);

Khalid Baheyeldin
 

On Mon, Jun 29, 2020 at 03:00 PM, Jamie Flinn wrote:

Yup…and both were enabled

I could never get OnStep to work in both AP and Station mode simultaneously.
On the other hand, Dave Schwartz is able to get both modes working alongside each other without any problem. And it is very consistent in his case.

So I turn off AP mode and enable Station mode only, and it connects to my home network.
The OnStep WiFi server should switch to AP mode when it could not connect to the home network.

I should take the controller in the car and drive away from home and see if that is the case, just to verify ...

Jamie Flinn
 

Lol…see my prevoius note – my Latte was very yummy doing that test 😊

 

From: main@onstep.groups.io On Behalf Of Khalid Baheyeldin
Sent: Monday, June 29, 2020 3:06 PM
To: main@onstep.groups.io
Subject: Re: [onstep] Wemos D1 wifi - connection dropping

 

On Mon, Jun 29, 2020 at 03:00 PM, Jamie Flinn wrote:

Yup…and both were enabled

I could never get OnStep to work in both AP and Station mode simultaneously.
On the other hand, Dave Schwartz is able to get both modes working alongside each other without any problem. And it is very consistent in his case.

So I turn off AP mode and enable Station mode only, and it connects to my home network.
The OnStep WiFi server should switch to AP mode when it could not connect to the home network.

I should take the controller in the car and drive away from home and see if that is the case, just to verify ...

Howard Dutton
 

On Mon, Jun 29, 2020 at 12:05 PM, Khalid Baheyeldin wrote:
I could never get OnStep to work in both AP and Station mode simultaneously.
I wouldn't say it never worked.  I could always bring up the web-site just the thing time sliced (switching between AP and Station) at rather coarse intervals so performance on the command channel was really insufficient for OnStep.

Drew 🔭📷🚴‍♂️
 

Still I thought that if the network for Station Mode was not found it would disable it.

if (!accessPointEnabled && stationEnabled) {
for (int i=0; i<5; i++)
if (WiFi.status() != WL_CONNECTED) delay(1000); else break;
if (WiFi.status() != WL_CONNECTED) {
stationEnabled=false;
accessPointEnabled=true;
goto TryAgain;
// wait for connection in station mode, if it fails fall back to access-point mode


Isn't that what this code does?

Howard, how do you preserve the code formatting? Copy and paste doesn't seem to get it.

Jamie Flinn
 

Guess the $10000 question is what is in TryAgain – if it drops back into this code it will induce a rolling 1 seconds relay endless 😊

 

From: main@onstep.groups.io On Behalf Of Drew ?????????
Sent: Monday, June 29, 2020 4:11 PM
To: main@onstep.groups.io
Subject: Re: [onstep] Wemos D1 wifi - connection dropping

 

Still I thought that if the network for Station Mode was not found it would disable it.

if (!accessPointEnabled && stationEnabled) {

 

for (int i=0; i<5; i++)

 

if (WiFi.status() != WL_CONNECTED) delay(1000); else break;

 

if (WiFi.status() != WL_CONNECTED) {

 

stationEnabled=false;

 

accessPointEnabled=true;

goto TryAgain;

// wait for connection in station mode, if it fails fall back to access-point mode


Isn't that what this code does?

Howard, how do you preserve the code formatting? Copy and paste doesn't seem to get it.

Khalid Baheyeldin
 

On Mon, Jun 29, 2020 at 04:23 PM, Jamie Flinn wrote:
Guess the $10000 question is what is in TryAgain – if it drops back into this code it will induce a rolling 1 seconds relay endless
Here is the entire code segment involved (from 3.16).

https://github.com/hjd1964/OnStep/blob/release-3.16/addons/WiFi-Bluetooth/WiFi-Bluetooth.ino#L329

Howard Dutton
 

On Mon, Jun 29, 2020 at 01:23 PM, Jamie Flinn wrote:
Guess the $10000 question is what is in TryAgain – if it drops back into this code it will induce a rolling 1 seconds relay endless 😊
Not possible.

Dave Schwartz
 

Yes, I have both enabled and I have not had a problem with active connections over both at the same time. I have done tests with the Android app on one network and Stellarium Mobile Plus on a tablet, both of which have a sub-second polling loop. However, I've never tried to move the whole kit and kaboodle out of the range of the home network to see what would happen then.

However, following the discussion about the station mode fallback to access point, I would be in favour of the method of operation be: try to connect to the network for station mode, if not successful, disable (until next startup) and bring up the access point. I must admit, I thought it already worked that way.

On 2020-06-29 3:05 p.m., Khalid Baheyeldin wrote:
On Mon, Jun 29, 2020 at 03:00 PM, Jamie Flinn wrote:

Yup…and both were enabled

I could never get OnStep to work in both AP and Station mode simultaneously.
On the other hand, Dave Schwartz is able to get both modes working alongside each other without any problem. And it is very consistent in his case.

So I turn off AP mode and enable Station mode only, and it connects to my home network.
The OnStep WiFi server should switch to AP mode when it could not connect to the home network.

I should take the controller in the car and drive away from home and see if that is the case, just to verify ...

Howard Dutton
 

On Mon, Jun 29, 2020 at 01:10 PM, Drew 🔭📷🚴‍♂️ wrote:
Isn't that what this code does?
Not really.  It sees a failed connection then re-configures the modes.  It really made no attempt to turn off the Station mode hence my suggestion to add that line of code below.

Howard, how do you preserve the code formatting? Copy and paste doesn't seem to get it.
Copy, Groups.io editor set font to fixed with/small size, and paste.