Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to the last version of nonos-sdk V2, WiFi addons #5210

Merged
merged 17 commits into from
Oct 9, 2018

Conversation

d-a-v
Copy link
Collaborator

@d-a-v d-a-v commented Oct 6, 2018

edited

New feature / API update: WiFi.setSleepMode(WIFI_LIGHT/MODEM_SLEEP, listen-interval)
Default value in FW is 3 - documentation
see also: https://routerguide.net/dtim-interval-period-best-setting/

note: I'm not a radio expert

With new api: WiFi.getListenInterval() / WiFi.isSleepLevelMax()
(the setters are here but should not be used, prefer WiFi.setSleepMode())

This is interesting for at least #2330 #1381 #4485

This WiFi issue with light or modem sleep modes does not happen for everybody,
so testing testers (with current-meter or not) are needed.

How to try the git way:

git fetch origin pull/5210/head:wifi
git checkout wifi

Revert to master:

git checkout master

In case of updates in the PR, do this before restarting the above.

git checkout master
git branch -D wifi

libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp Outdated Show resolved Hide resolved
doc/esp8266wifi/generic-class.rst Outdated Show resolved Hide resolved
libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp Outdated Show resolved Hide resolved
libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp Outdated Show resolved Hide resolved
@@ -86,6 +86,7 @@ static bool sta_config_equal(const station_config& lhs, const station_config& rh
// -----------------------------------------------------------------------------------------------------------------------

bool ESP8266WiFiSTAClass::_useStaticIp = false;
bool ESP8266WiFiSTAClass::_useInsecureWEP = false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this here on purpose, or did it slip in? I'm ok with what I see of the code, but given the nature of this functionality I suggest splitting it into its own PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All points above are addressed your way.
About WEP, it is a requirement to set this value in sdk structures for initialization.

@ascillato
Copy link
Contributor

Hi,

I have tested the actual Stage Core with this PR in order to check the Modem Sleep Feature and works very good. No crashes if using lwIP 1.4.

@ascillato
Copy link
Contributor

Hi,

After performing several tests of the actual stage core with @d-a-v's PR, it results that it is working really good for Sonoff-Tasmota.

All functions are working very good and also the sleep feature finally works in a core different than 2.3.0 !

I have tested with lwIP 1.4, lwIP 2 (low memory) and also lwIP (high bandwidth) and works very stable in all those, with and without sleep enabled.

So, I hope this Pull Request got merged ASAP into the core, and also that a new core got released ASAP.

Thanks a lot for all the hard work you all have done here, and thanks @d-a-v for this solution!

@Jason2866
Copy link
Contributor

Jason2866 commented Oct 9, 2018

Hello @d-a-v
would be perfect if your PR is merged very very soon and a new core version is released!
I use Tasmota (https://github.com/arendst/Sonoff-Tasmota) which uses Modem Sleep. With your modification Sleep works again without issues. Sleep was unusable since the last working Version 2.3.0.
Thanks for your work and all the others here!

@andrethomas
Copy link

This is really good news - will be very good if these fixes can be included to finally solve the sleep problem on 2.4.2!

@arendst
Copy link

arendst commented Oct 9, 2018

It would be great if this PR could be implemented really soon as currently most Tasmota users are forced to use core 2.3.0 for light sleep functionality while so many new features have been released in later core versions.

@d-a-v d-a-v changed the title Update to the last version of non-sdk V2, WiFi addons Update to the last version of nonos-sdk V2, WiFi addons Oct 9, 2018
@mike2nl
Copy link

mike2nl commented Oct 9, 2018

I would like to have it too, because by 193 sonoff devices you have a lot of power use and that is pricy.
When i could cut it by a half that would be a great step in the right direction.

So please don't waste time and money. Add it where we need it.

@d-a-v
Copy link
Collaborator Author

d-a-v commented Oct 9, 2018

documentation overview

@devyte devyte merged commit 8ef21ca into esp8266:master Oct 9, 2018
@devyte devyte mentioned this pull request Oct 9, 2018
@d-a-v d-a-v added this to the 2.5.0 milestone Oct 9, 2018
@d-a-v d-a-v deleted the fw2 branch October 9, 2018 15:11
@clumsy-stefan
Copy link

Just a question: this actually updated to Nonos SDK V3.0.0 not V2 ? At least the libraries in the tools/sdk/lib directory show V3...

@d-a-v
Copy link
Collaborator Author

d-a-v commented Oct 26, 2018 via email

@AugustoCiuffoletti
Copy link

It seems that the problem has been solved, so it's probably my mistake, but I still have problems with LIGHT_SLEEP, and I can't find any document around. I use the Arduino IDE 1.8.7, and installed the ESP8266 package v2.5.0 (stable) using the File->Preferences way. Doing of my best with many suggestions that I found googling around I produced the following testing sketch:

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include "secret.h"  //defines MYSSID and MYPASSWD

int joinAP(){
  Serial.print("Connecting");
  WiFi.begin(MYSSID, MYPASSWD);
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    Serial.print(".");
  }
  Serial.println();
  Serial.print("Connected as ");
  Serial.println(WiFi.localIP());
}

void setup()
{
  Serial.begin(115200);
  WiFi.mode(WIFI_STA);
  pinMode(LED_BUILTIN, OUTPUT); 
  digitalWrite(LED_BUILTIN,LOW);
  WiFi.setSleepMode(WIFI_LIGHT_SLEEP,10);
}

void loop()
{
  WiFiClient client;
  HTTPClient http;

  joinAP();
  digitalWrite(LED_BUILTIN,!digitalRead(LED_BUILTIN));
  if (http.begin(client, "http://www.example.com")) {
    Serial.print(" - return code: "); Serial.println(http.GET());
  }

unsigned long t0=millis();
WiFi.forceSleepBegin(5000000UL); 
Serial.println(millis()-t0);
}

However there is no 5 seconds delay: the output is as follows:

Connecting.............................
Connected as 192.168.43.113
 - return code: 200
91
.....

The 91 is the difference in ms. In fact, there is no visible delay.

Thank you.

@AugustoCiuffoletti
Copy link

I did an experiment today replacing the WiFi.forceSleepBegin(5000000) with a plain

delay(5000);

The result is that the delay time is measured correctly, and power consumption drops around 15mA, with short (20ms) spikes around 60mA every one second. Outside the delay time power consumption is around 60mA with spikes around 200mA.
So power consumption is reduced to 25%, but I'd expect better than that. My guess is that the result is consistent with a MODEM_SLEEP, and not with LIGHT_SLEEP as I asked with the setSleepMode.
I used an oscilloscope with a 1Ohm shunt to measure currents.

@netprince17
Copy link

I haven't had any luck making lightsleep work yet either.

We need a good example that works with a specific version of the esp8266 code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants