Skip to content

rework WiFi #1323

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 22 commits into from
Dec 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
5 changes: 5 additions & 0 deletions cores/esp8266/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ extern "C" {
#include "binary.h"
#include "esp8266_peri.h"
#include "twi.h"
#include "core_esp8266_features.h"

#define HIGH 0x1
#define LOW 0x0
Expand Down Expand Up @@ -247,8 +248,12 @@ void optimistic_yield(uint32_t interval_us);
#include "Updater.h"
#include "debug.h"

#ifndef _GLIBCXX_VECTOR
// arduino is not compatible with std::vector
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#endif

#define _min(a,b) ((a)<(b)?(a):(b))
#define _max(a,b) ((a)>(b)?(a):(b))

Expand Down
3 changes: 3 additions & 0 deletions cores/esp8266/IPAddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ class IPAddress: public Printable {
bool operator==(const IPAddress& addr) const {
return _address.dword == addr._address.dword;
}
bool operator==(uint32_t addr) const {
return _address.dword == addr;
}
bool operator==(const uint8_t* addr) const;

// Overloaded index operator to allow getting and setting individual octets of the address
Expand Down
2 changes: 2 additions & 0 deletions cores/esp8266/core_esp8266_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#define CORE_HAS_LIBB64
#define CORE_HAS_BASE64_CLASS

#define WIFI_HAS_EVENT_CALLBACK


#endif

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* This sketch shows the WiFi event usage
*
*/

#include <ESP8266WiFi.h>

const char* ssid = "your-ssid";
const char* password = "your-password";


void WiFiEvent(WiFiEvent_t event) {
Serial.printf("[WiFi-event] event: %d\n", event);

switch(event) {
case WIFI_EVENT_STAMODE_GOT_IP:
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
break;
case WIFI_EVENT_STAMODE_DISCONNECTED:
Serial.println("WiFi lost connection");
break;
}
}

void setup() {
Serial.begin(115200);

// delete old config
WiFi.disconnect(true);

delay(1000);

WiFi.onEvent(WiFiEvent);

WiFi.begin(ssid, password);

Serial.println();
Serial.println();
Serial.println("Wait for WiFi... ");
}


void loop() {
delay(1000);
}

Loading