diff --git a/libraries/WiFi/examples/HTTPSRequest/HTTPSRequest.ino b/libraries/WiFi/examples/HTTPSRequest/HTTPSRequest.ino deleted file mode 100644 index 56294d08..00000000 --- a/libraries/WiFi/examples/HTTPSRequest/HTTPSRequest.ino +++ /dev/null @@ -1,90 +0,0 @@ -/* - * HTTP over TLS (HTTPS) example sketch - * - * This example demonstrates how to use - * WiFiClientSecure class to access HTTPS API. - * We fetch and display the status of - * esp8266/Arduino project continuous integration - * build. - * - * Created by Ivan Grokhotkov, 2015. - * This example is in public domain. - */ - -#include -#include - -const char* ssid = "........"; -const char* password = "........"; - -const char* host = "api.github.com"; -const int httpsPort = 443; - -// Use web browser to view and copy -// SHA1 fingerprint of the certificate -const char* fingerprint = "CF 05 98 89 CA FF 8E D8 5E 5C E0 C2 E4 F7 E6 C3 C7 50 DD 5C"; - -void setup() -{ - Serial.begin(115200); - Serial.println(); - Serial.print("connecting to "); - Serial.println(ssid); - WiFi.begin(ssid, password); - while (WiFi.status() != WL_CONNECTED) { - delay(500); - Serial.print("."); - } - Serial.println(""); - Serial.println("WiFi connected"); - Serial.println("IP address: "); - Serial.println(WiFi.localIP()); - - // Use WiFiClientSecure class to create TLS connection - WiFiClientSecure client; - Serial.print("connecting to "); - Serial.println(host); - if (!client.connect(host, httpsPort)) { - Serial.println("connection failed"); - return; - } - - if (client.verify(fingerprint, host)) { - Serial.println("certificate matches"); - } else { - Serial.println("certificate doesn't match"); - } - - String url = "/repos/esp8266/Arduino/commits/master/status"; - Serial.print("requesting URL: "); - Serial.println(url); - - client.print(String("GET ") + url + " HTTP/1.1\r\n" + - "Host: " + host + "\r\n" + - "User-Agent: BuildFailureDetectorESP8266\r\n" + - "Connection: close\r\n\r\n"); - - Serial.println("request sent"); - while (client.connected()) { - String line = client.readStringUntil('\n'); - if (line == "\r") { - Serial.println("headers received"); - break; - } - } - String line = client.readStringUntil('\n'); - if (line.startsWith("{\"state\":\"success\"")) { - Serial.println("esp8266/Arduino CI successfull!"); - } else { - Serial.println("esp8266/Arduino CI has failed"); - } - Serial.println("reply was:"); - Serial.println("=========="); - Serial.println(line); - Serial.println("=========="); - Serial.println("closing connection"); -} - -void loop() -{ -} diff --git a/libraries/WiFi/examples/NTPClient/NTPClient.ino b/libraries/WiFi/examples/NTPClient/NTPClient.ino deleted file mode 100644 index 004d4566..00000000 --- a/libraries/WiFi/examples/NTPClient/NTPClient.ino +++ /dev/null @@ -1,152 +0,0 @@ -/* - - Udp NTP Client - - Get the time from a Network Time Protocol (NTP) time server - Demonstrates use of UDP sendPacket and ReceivePacket - For more on NTP time servers and the messages needed to communicate with them, - see http://en.wikipedia.org/wiki/Network_Time_Protocol - - created 4 Sep 2010 - by Michael Margolis - modified 9 Apr 2012 - by Tom Igoe - updated for the ESP8266 12 Apr 2015 - by Ivan Grokhotkov - - This code is in the public domain. - - */ - -#include -#include - -char ssid[] = "*************"; // your network SSID (name) -char pass[] = "********"; // your network password - - -unsigned int localPort = 2390; // local port to listen for UDP packets - -/* Don't hardwire the IP address or we won't get the benefits of the pool. - * Lookup the IP address for the host name instead */ -//IPAddress timeServer(129, 6, 15, 28); // time.nist.gov NTP server -IPAddress timeServerIP; // time.nist.gov NTP server address -const char* ntpServerName = "time.nist.gov"; - -const int NTP_PACKET_SIZE = 48; // NTP time stamp is in the first 48 bytes of the message - -byte packetBuffer[ NTP_PACKET_SIZE]; //buffer to hold incoming and outgoing packets - -// A UDP instance to let us send and receive packets over UDP -WiFiUDP udp; - -void setup() -{ - Serial.begin(115200); - Serial.println(); - Serial.println(); - - // We start by connecting to a WiFi network - Serial.print("Connecting to "); - Serial.println(ssid); - WiFi.begin(ssid, pass); - - while (WiFi.status() != WL_CONNECTED) { - delay(500); - Serial.print("."); - } - Serial.println(""); - - Serial.println("WiFi connected"); - Serial.println("IP address: "); - Serial.println(WiFi.localIP()); - - Serial.println("Starting UDP"); - udp.begin(localPort); - Serial.print("Local port: "); - Serial.println(udp.localPort()); -} - -void loop() -{ - //get a random server from the pool - WiFi.hostByName(ntpServerName, timeServerIP); - - sendNTPpacket(timeServerIP); // send an NTP packet to a time server - // wait to see if a reply is available - delay(1000); - - int cb = udp.parsePacket(); - if (!cb) { - Serial.println("no packet yet"); - } else { - Serial.print("packet received, length="); - Serial.println(cb); - // We've received a packet, read the data from it - udp.read(packetBuffer, NTP_PACKET_SIZE); // read the packet into the buffer - - //the timestamp starts at byte 40 of the received packet and is four bytes, - // or two words, long. First, esxtract the two words: - - unsigned long highWord = word(packetBuffer[40], packetBuffer[41]); - unsigned long lowWord = word(packetBuffer[42], packetBuffer[43]); - // combine the four bytes (two words) into a long integer - // this is NTP time (seconds since Jan 1 1900): - unsigned long secsSince1900 = highWord << 16 | lowWord; - Serial.print("Seconds since Jan 1 1900 = " ); - Serial.println(secsSince1900); - - // now convert NTP time into everyday time: - Serial.print("Unix time = "); - // Unix time starts on Jan 1 1970. In seconds, that's 2208988800: - const unsigned long seventyYears = 2208988800UL; - // subtract seventy years: - unsigned long epoch = secsSince1900 - seventyYears; - // print Unix time: - Serial.println(epoch); - - - // print the hour, minute and second: - Serial.print("The UTC time is "); // UTC is the time at Greenwich Meridian (GMT) - Serial.print((epoch % 86400L) / 3600); // print the hour (86400 equals secs per day) - Serial.print(':'); - if ( ((epoch % 3600) / 60) < 10 ) { - // In the first 10 minutes of each hour, we'll want a leading '0' - Serial.print('0'); - } - Serial.print((epoch % 3600) / 60); // print the minute (3600 equals secs per minute) - Serial.print(':'); - if ( (epoch % 60) < 10 ) { - // In the first 10 seconds of each minute, we'll want a leading '0' - Serial.print('0'); - } - Serial.println(epoch % 60); // print the second - } - // wait ten seconds before asking for the time again - delay(10000); -} - -// send an NTP request to the time server at the given address -unsigned long sendNTPpacket(IPAddress& address) -{ - Serial.println("sending NTP packet..."); - // set all bytes in the buffer to 0 - memset(packetBuffer, 0, NTP_PACKET_SIZE); - // Initialize values needed to form NTP request - // (see URL above for details on the packets) - packetBuffer[0] = 0b11100011; // LI, Version, Mode - packetBuffer[1] = 0; // Stratum, or type of clock - packetBuffer[2] = 6; // Polling Interval - packetBuffer[3] = 0xEC; // Peer Clock Precision - // 8 bytes of zero for Root Delay & Root Dispersion - packetBuffer[12] = 49; - packetBuffer[13] = 0x4E; - packetBuffer[14] = 49; - packetBuffer[15] = 52; - - // all NTP fields have been given values, now - // you can send a packet requesting a timestamp: - udp.beginPacket(address, 123); //NTP requests are to port 123 - udp.write(packetBuffer, NTP_PACKET_SIZE); - udp.endPacket(); -} diff --git a/libraries/WiFi/examples/WiFiAccessPoint/WiFiAccessPoint.ino b/libraries/WiFi/examples/WiFiAccessPoint/WiFiAccessPoint.ino deleted file mode 100644 index 9fa6c91f..00000000 --- a/libraries/WiFi/examples/WiFiAccessPoint/WiFiAccessPoint.ino +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2015, Majenko Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * * Neither the name of Majenko Technologies nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* Create a WiFi access point and provide a web server on it. */ - -#include -#include -#include - -/* Set these to your desired credentials. */ -const char *ssid = "ESPap"; -const char *password = "thereisnospoon"; - -ESP8266WebServer server(80); - -/* Just a little test message. Go to http://192.168.4.1 in a web browser - * connected to this access point to see it. - */ -void handleRoot() -{ - server.send(200, "text/html", "

You are connected

"); -} - -void setup() -{ - delay(1000); - Serial.begin(115200); - Serial.println(); - Serial.print("Configuring access point..."); - /* You can remove the password parameter if you want the AP to be open. */ - WiFi.softAP(ssid, password); - - IPAddress myIP = WiFi.softAPIP(); - Serial.print("AP IP address: "); - Serial.println(myIP); - server.on("/", handleRoot); - server.begin(); - Serial.println("HTTP server started"); -} - -void loop() -{ - server.handleClient(); -} diff --git a/libraries/WiFi/examples/WiFiClientEvents/WiFiClientEvents.ino b/libraries/WiFi/examples/WiFiClientEvents/WiFiClientEvents.ino index b6842cd4..6971e269 100644 --- a/libraries/WiFi/examples/WiFiClientEvents/WiFiClientEvents.ino +++ b/libraries/WiFi/examples/WiFiClientEvents/WiFiClientEvents.ino @@ -14,12 +14,12 @@ void WiFiEvent(WiFiEvent_t event) Serial.printf("[WiFi-event] event: %d\n", event); switch(event) { - case WIFI_EVENT_STAMODE_GOT_IP: + case SYSTEM_EVENT_STA_GOT_IP: Serial.println("WiFi connected"); Serial.println("IP address: "); Serial.println(WiFi.localIP()); break; - case WIFI_EVENT_STAMODE_DISCONNECTED: + case SYSTEM_EVENT_STA_DISCONNECTED: Serial.println("WiFi lost connection"); break; } diff --git a/libraries/WiFi/examples/WiFiScan/WiFiScan.ino b/libraries/WiFi/examples/WiFiScan/WiFiScan.ino index 975a1fe6..5d11fbb6 100644 --- a/libraries/WiFi/examples/WiFiScan/WiFiScan.ino +++ b/libraries/WiFi/examples/WiFiScan/WiFiScan.ino @@ -37,7 +37,7 @@ void loop() Serial.print(" ("); Serial.print(WiFi.RSSI(i)); Serial.print(")"); - Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE)?" ":"*"); + Serial.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN)?" ":"*"); delay(10); } } diff --git a/libraries/WiFi/examples/WiFiTelnetToSerial/WiFiTelnetToSerial.ino b/libraries/WiFi/examples/WiFiTelnetToSerial/WiFiTelnetToSerial.ino deleted file mode 100644 index 4099928e..00000000 --- a/libraries/WiFi/examples/WiFiTelnetToSerial/WiFiTelnetToSerial.ino +++ /dev/null @@ -1,103 +0,0 @@ -/* - WiFiTelnetToSerial - Example Transparent UART to Telnet Server for esp8266 - - Copyright (c) 2015 Hristo Gochkov. All rights reserved. - This file is part of the WiFi library for Arduino environment. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ -#include - -//how many clients should be able to telnet to this ESP8266 -#define MAX_SRV_CLIENTS 1 -const char* ssid = "**********"; -const char* password = "**********"; - -WiFiServer server(23); -WiFiClient serverClients[MAX_SRV_CLIENTS]; - -void setup() -{ - Serial1.begin(115200); - WiFi.begin(ssid, password); - Serial1.print("\nConnecting to "); - Serial1.println(ssid); - uint8_t i = 0; - while (WiFi.status() != WL_CONNECTED && i++ < 20) { - delay(500); - } - if(i == 21) { - Serial1.print("Could not connect to"); - Serial1.println(ssid); - while(1) { - delay(500); - } - } - //start UART and the server - Serial.begin(115200); - server.begin(); - server.setNoDelay(true); - - Serial1.print("Ready! Use 'telnet "); - Serial1.print(WiFi.localIP()); - Serial1.println(" 23' to connect"); -} - -void loop() -{ - uint8_t i; - //check if there are any new clients - if (server.hasClient()) { - for(i = 0; i < MAX_SRV_CLIENTS; i++) { - //find free/disconnected spot - if (!serverClients[i] || !serverClients[i].connected()) { - if(serverClients[i]) { - serverClients[i].stop(); - } - serverClients[i] = server.available(); - Serial1.print("New client: "); - Serial1.print(i); - continue; - } - } - //no free/disconnected spot so reject - WiFiClient serverClient = server.available(); - serverClient.stop(); - } - //check clients for data - for(i = 0; i < MAX_SRV_CLIENTS; i++) { - if (serverClients[i] && serverClients[i].connected()) { - if(serverClients[i].available()) { - //get data from the telnet client and push it to the UART - while(serverClients[i].available()) { - Serial.write(serverClients[i].read()); - } - } - } - } - //check UART for data - if(Serial.available()) { - size_t len = Serial.available(); - uint8_t sbuf[len]; - Serial.readBytes(sbuf, len); - //push UART data to all connected telnet clients - for(i = 0; i < MAX_SRV_CLIENTS; i++) { - if (serverClients[i] && serverClients[i].connected()) { - serverClients[i].write(sbuf, len); - delay(1); - } - } - } -} diff --git a/libraries/WiFi/examples/WiFiWebServer/WiFiWebServer.ino b/libraries/WiFi/examples/WiFiWebServer/WiFiWebServer.ino deleted file mode 100644 index 91e85b3d..00000000 --- a/libraries/WiFi/examples/WiFiWebServer/WiFiWebServer.ino +++ /dev/null @@ -1,100 +0,0 @@ -/* - * This sketch demonstrates how to set up a simple HTTP-like server. - * The server will set a GPIO pin depending on the request - * http://server_ip/gpio/0 will set the GPIO2 low, - * http://server_ip/gpio/1 will set the GPIO2 high - * server_ip is the IP address of the ESP8266 module, will be - * printed to Serial when the module is connected. - */ - -#include - -const char* ssid = "your-ssid"; -const char* password = "your-password"; - -// Create an instance of the server -// specify the port to listen on as an argument -WiFiServer server(80); - -void setup() -{ - Serial.begin(115200); - delay(10); - - // prepare GPIO2 - pinMode(2, OUTPUT); - digitalWrite(2, 0); - - // Connect to WiFi network - Serial.println(); - Serial.println(); - Serial.print("Connecting to "); - Serial.println(ssid); - - WiFi.begin(ssid, password); - - while (WiFi.status() != WL_CONNECTED) { - delay(500); - Serial.print("."); - } - Serial.println(""); - Serial.println("WiFi connected"); - - // Start the server - server.begin(); - Serial.println("Server started"); - - // Print the IP address - Serial.println(WiFi.localIP()); -} - -void loop() -{ - // Check if a client has connected - WiFiClient client = server.available(); - if (!client) { - return; - } - - // Wait until the client sends some data - Serial.println("new client"); - while(!client.available()) { - delay(1); - } - - // Read the first line of the request - String req = client.readStringUntil('\r'); - Serial.println(req); - client.flush(); - - // Match the request - int val; - if (req.indexOf("/gpio/0") != -1) { - val = 0; - } else if (req.indexOf("/gpio/1") != -1) { - val = 1; - } else { - Serial.println("invalid request"); - client.stop(); - return; - } - - // Set GPIO2 according to the request - digitalWrite(2, val); - - client.flush(); - - // Prepare the response - String s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n\r\n\r\nGPIO is now "; - s += (val)?"high":"low"; - s += "\n"; - - // Send the response to the client - client.print(s); - delay(1); - Serial.println("Client disonnected"); - - // The client will actually be disconnected - // when the function returns and 'client' object is detroyed -} -