8000 weak hook preinit() #2111 #2133 #2136 by d-a-v · Pull Request #5395 · esp8266/Arduino · GitHub
[go: up one dir, main page]

Skip to content

weak hook preinit() #2111 #2133 #2136 #5395

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

Merged
merged 25 commits into from
Dec 4, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
671bbac
weak hook early_setup() #2111 #2133 #2136
d-a-v Nov 30, 2018
53a2d97
Merge branch 'master' into earlysetup
d-a-v Nov 30, 2018
bf76433
rename to early_init (more "c" vs early_setup which is more "c++ardui…
d-a-v Nov 30, 2018
d296d7b
example
d-a-v Nov 30, 2018
dbf6045
improve earlyWiFi example, slightly change AddrList interface, move W…
d-a-v Nov 30, 2018
acdbe07
fix CI
d-a-v Nov 30, 2018
23b7ace
fix local CI runner
d-a-v Nov 30, 2018
b75c40d
Merge branch 'master' into earlysetup
devyte Dec 2, 2018
9c043f6
fix local CI runner
d-a-v Dec 3, 2018
3393ecc
Merge branch 'master' into earlysetup
d-a-v Dec 3, 2018
e8e0b5c
rename early_init() to preinit()
d-a-v Dec 3, 2018
e014a19
Merge branch 'earlysetup' of github.com:d-a-v/Arduino into earlysetup
d-a-v Dec 3, 2018
5aa7ee6
Merge branch 'master' into earlysetup
d-a-v Dec 3, 2018
f887ce8
+ static ESP8266WiFiClass::preinit_wifi_off()
d-a-v Dec 3, 2018
6c09fbd
update early disable wifi example
d-a-v Dec 3, 2018
a636a80
example update
d-a-v Dec 3, 2018
5d770aa
IPv6 example update
d-a-v Dec 3, 2018
6d9072d
Merge branch 'master' into earlysetup
d-a-v Dec 3, 2018
c0043c2
Update ESP8266WiFiGeneric.h
devyte Dec 4, 2018
8b687b0
Update ESP8266WiFiGeneric.cpp
devyte Dec 4, 2018
85d244d
Update EarlyDisableWiFi.ino
devyte Dec 4, 2018
bef67d7
Update core_esp8266_main.cpp
devyte Dec 4, 2018
eb9f9c2
Update core_esp8266_main.cpp
devyte Dec 4, 2018
1925b0c
Update EarlyDisableWiFi.ino
devyte Dec 4, 2018
5f26799
Merge branch 'master' into earlysetup
devyte Dec 4, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
improve earlyWiFi example, slightly change AddrList interface, move W…
…iFi sketches into WiFi examples
  • Loading branch information
d-a-v committed Nov 30, 2018
commit dbf60459d8013ea90237cb7cdd11f7f663efef18
18 changes: 11 additions & 7 deletions cores/esp8266/AddrList.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
for (auto a: ifList)
out.printf("IF='%s' index=%d legacy=%d IPv4=%d local=%d hostname='%s' addr= %s\n",
a->iface().c_str(),
a->number(),
a->ifnumber(),
a->addr().isLegacy(),
a->addr().isV4(),
a->addr().isLocal(),
Expand Down Expand Up @@ -65,7 +65,7 @@
for (auto iface: ifList)
if ((configured = ( !iface->addr()->isV4()
&& !iface->addr().isLocal()
&& iface->number() == STATION_IF)))
&& iface->ifnumber() == STATION_IF)))
break;
Serial.print('.');
delay(500);
Expand Down Expand Up @@ -126,19 +126,23 @@ class AddrListClass {
}

// (*iterator) emulation:

const const_iterator& operator* () const { return *this; }
const const_iterator* operator-> () const { return this; }

// iterated address
bool isLegacy() const { return _num == 0; }
bool isLocal() const { return addr().isLocal(); }
IPAddress addr () const { return _ip_from_netif_num(); }

// properties of legacy/IPv4 address (one per interface)
IPAddress netmask () const { return _netif->netmask; }
IPAddress gw () const { return _netif->gw; }
String iface () const { return String(_netif->name[0]) + _netif->name[1]; }
const char* hostname () const { return _netif->hostname?: emptyString.c_str(); }
const char* mac () const { return (const char*)_netif->hwaddr; }
int number () const { return _netif->num; }

// interface properties (common to all addresses in the interface)
String ifname () const { return String(_netif->name[0]) + _netif->name[1]; }
const char* ifhostname () const { return _netif->hostname?: emptyString.c_str(); }
const char* ifmac () const { return (const char*)_netif->hwaddr; }
int ifnumber () const { return _netif->num; }

protected:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@

#include <ESP8266WiFi.h>

#ifndef STASSID
#define STASSID "your-ssid"
#define STAPSK "your-password"
#endif

// early_init() is called before system startup
// from nonos-sdk's user entry point user_init()

Expand Down Expand Up @@ -35,6 +40,38 @@ void early_init() {
void setup () {
Serial.begin(115200);
Serial.setDebugOutput(true);
Serial.println("sleeping 5s");

// during this period, a simple amp meter shows
// an average of 20mA with a Wemos D1 mini
// a DSO is needed to check #2111
delay(5000);

Serial.println("waking WiFi up, sleeping 5s");
WiFi.forceSleepWake();

// amp meter raises to 75mA
delay(5000);

Serial.println("connecting to AP " STASSID);
WiFi.mode(WIFI_STA);
WiFi.begin(STASSID, STAPSK);

for (bool configured = false; !configured;) {
for (auto addr : addrList)
if ((configured = !addr->isLocal() && addr->ifnumber() == STATION_IF)) {
Serial.printf("STA: IF='%s' hostname='%s' addr= %s\n",
addr->ifname().c_str(),
addr->ifhostname(),
addr->addr().toString().c_str());
break;
}
Serial.print('.');
delay(500);
}

// amp meter cycles within 75-80 mA

}

void loop () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ void status(Print& out) {
out.println(F("(with 'telnet <addr> or 'nc -u <addr> 23')"));
for (auto a : addrList) {
out.printf("IF='%s' IPv6=%d local=%d hostname='%s' addr= %s",
a->iface().c_str(),
a->ifname().c_str(),
!a->addr().isV4(),
a->addr().isLocal(),
a->hostname(),
a->ifhostname(),
a->addr().toString().c_str());

if (a->isLegacy()) {
Expand All @@ -96,6 +96,8 @@ void setup() {
Serial.println();
Serial.println(ESP.getFullVersion());

Serial.printf("IPV6 is%s enabled\n", LWIP_IPV6? emptyString.c_str(): " NOT");

WiFi.mode(WIFI_STA);
WiFi.begin(STASSID, STAPSK);

Expand Down
0