mirror of
https://github.com/arduino/Arduino.git
synced 2024-12-01 12:24:14 +01:00
Deleted old examples
This commit is contained in:
parent
2b6169e2a2
commit
1e2a51a302
@ -1,137 +0,0 @@
|
||||
/*
|
||||
Pachube sensor client with Strings
|
||||
|
||||
This sketch connects an analog sensor to Pachube (http://www.pachube.com)
|
||||
using a Wiznet Ethernet shield. You can use the Arduino Ethernet shield, or
|
||||
the Adafruit Ethernet shield, either one will work, as long as it's got
|
||||
a Wiznet Ethernet module on board.
|
||||
|
||||
This example uses the String library, which is part of the Arduino core from
|
||||
version 0019.
|
||||
|
||||
Circuit:
|
||||
* Analog sensor attached to analog in 0
|
||||
* Ethernet shield attached to pins 10, 11, 12, 13
|
||||
|
||||
created 15 March 2010
|
||||
updated 4 Sep 2010
|
||||
by Tom Igoe
|
||||
|
||||
This code is in the public domain.
|
||||
|
||||
*/
|
||||
|
||||
#include <WiFi.h>
|
||||
|
||||
char ssid[] = "yourNetwork";
|
||||
char pass[] = "secretPassword";
|
||||
int status = WL_IDLE_STATUS;
|
||||
|
||||
// The address of the server you want to connect to (pachube.com):
|
||||
IPAddress server(173,203,98,29);
|
||||
|
||||
// initialize the library instance:
|
||||
WiFiClient client;
|
||||
|
||||
long lastConnectionTime = 0; // last time you connected to the server, in milliseconds
|
||||
boolean lastConnected = false; // state of the connection last time through the main loop
|
||||
const int postingInterval = 10000; //delay between updates to Pachube.com
|
||||
|
||||
int startWiFiWpa()
|
||||
{
|
||||
Serial.println("\nSetup WiFi Wpa...");
|
||||
strcpy(ssid, "tigoenet");
|
||||
Serial.print("SSID: ");
|
||||
Serial.println(ssid);
|
||||
const char *pass = "m30w-m30w";
|
||||
status = WiFi.begin(ssid, pass);
|
||||
if ( status != WL_CONNECTED)
|
||||
{
|
||||
Serial.println("Connection Failed");
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void setup() {
|
||||
// start the WiFi connection and the server:
|
||||
Serial.begin(9600);
|
||||
Serial.println("*** Start WebClient WiFi example ***");
|
||||
|
||||
int _status = startWiFiWpa();
|
||||
if ( _status == WL_CONNECTED)
|
||||
{
|
||||
Serial.println("\nWiFi Connected.");
|
||||
}
|
||||
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// read the analog sensor:
|
||||
int sensorReading = analogRead(A0);
|
||||
// convert the data to a String to send it:
|
||||
String dataString = String(sensorReading);
|
||||
|
||||
// you can append multiple readings to this String if your
|
||||
// pachube feed is set up to handle multiple values:
|
||||
int otherSensorReading = analogRead(A1);
|
||||
dataString += ",";
|
||||
dataString += String(otherSensorReading);
|
||||
|
||||
// if there's incoming data from the net connection.
|
||||
// send it out the serial port. This is for debugging
|
||||
// purposes only:
|
||||
if (client.available()) {
|
||||
char c = client.read();
|
||||
Serial.print(c);
|
||||
}
|
||||
|
||||
// if there's no net connection, but there was one last time
|
||||
// through the loop, then stop the client:
|
||||
if (!client.connected() && lastConnected) {
|
||||
Serial.println();
|
||||
Serial.println("disconnecting.");
|
||||
client.stop();
|
||||
}
|
||||
|
||||
// if you're not connected, and ten seconds have passed since
|
||||
// your last connection, then connect again and send data:
|
||||
if(!client.connected() && (millis() - lastConnectionTime > postingInterval)) {
|
||||
sendData(dataString);
|
||||
}
|
||||
// store the state of the connection for next time through
|
||||
// the loop:
|
||||
lastConnected = client.connected();
|
||||
}
|
||||
|
||||
// this method makes a HTTP connection to the server:
|
||||
void sendData(String thisData) {
|
||||
// if there's a successful connection:
|
||||
if (client.connect(server, 80)) {
|
||||
Serial.println("connecting...");
|
||||
// send the HTTP PUT request.
|
||||
// fill in your feed address here:
|
||||
client.print("PUT /api/24196.csv HTTP/1.1\n");
|
||||
client.print("Host: www.pachube.com\n");
|
||||
// fill in your Pachube API key here:
|
||||
client.print("X-PachubeApiKey: gw0L2A-J5ACRGQccX59tCYt0IEzyecr-SoiuC47U1-8\n");
|
||||
client.print("Content-Length: ");
|
||||
client.println(thisData.length(), DEC);
|
||||
|
||||
// last pieces of the HTTP PUT request:
|
||||
client.print("Content-Type: text/csv\n");
|
||||
client.println("Connection: close\n");
|
||||
|
||||
// here's the actual content of the PUT request:
|
||||
client.println(thisData);
|
||||
|
||||
// note the time that the connection was made:
|
||||
lastConnectionTime = millis();
|
||||
}
|
||||
else {
|
||||
// if you couldn't make a connection:
|
||||
Serial.println("connection failed");
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
|
||||
Open connection using the WiFi shield. Attempts to connect
|
||||
and prints out the signal strength.
|
||||
|
||||
Circuit:
|
||||
* WiFi shield attached
|
||||
created 5 June 2011
|
||||
by Tom Igoe
|
||||
*/
|
||||
#include <SPI.h>
|
||||
#include <WiFi.h>
|
||||
|
||||
char ssid[] = "yourNetwork"; // the name of your network
|
||||
int status = WL_IDLE_STATUS; // the Wifi radio's status
|
||||
|
||||
|
||||
byte mac[6]; // the MAC address of your Wifi shield
|
||||
IPAddress ip; // the IP address of your shield
|
||||
|
||||
void setup() {
|
||||
// initialize serial:
|
||||
Serial.begin(9600);
|
||||
|
||||
// attempt to connect using WEP encryption:
|
||||
Serial.println("Attempting to connect to open network...");
|
||||
status = WiFi.begin(ssid);
|
||||
|
||||
Serial.print("SSID: ");
|
||||
Serial.println(ssid);
|
||||
|
||||
// if you're not connected, stop here:
|
||||
if ( status != WL_CONNECTED) {
|
||||
Serial.println("Couldn't get a wifi connection");
|
||||
while(true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// if you're connected, print out the signal strength:
|
||||
if ( status != WL_CONNECTED) {
|
||||
// print the received signal strength:
|
||||
long rssi = WiFi.RSSI();
|
||||
Serial.print("RSSI:");
|
||||
Serial.println(rssi);
|
||||
delay(250);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,155 +0,0 @@
|
||||
/*
|
||||
|
||||
Open connection using the WiFi shield. Attempts to connect
|
||||
and prints out info about the network
|
||||
|
||||
Circuit:
|
||||
* WiFi shield attached
|
||||
|
||||
created 13 July 2010
|
||||
by dlf (Metodo2 srl)
|
||||
modified 5 June 2011
|
||||
by Tom Igoe
|
||||
*/
|
||||
|
||||
|
||||
#include <SPI.h>
|
||||
#include <WiFi.h>
|
||||
|
||||
char ssid[] = "yourNetwork"; // the name of your network
|
||||
int status = WL_IDLE_STATUS; // the Wifi radio's status
|
||||
|
||||
|
||||
byte mac[6]; // the MAC address of your Wifi shield
|
||||
IPAddress ip; // the IP address of your shield
|
||||
IPAddress gateway; // the router's address
|
||||
IPAddress subnet; // the subnet mask
|
||||
|
||||
void setup() {
|
||||
// initialize serial:
|
||||
Serial.begin(9600);
|
||||
|
||||
// scan for existing networks:
|
||||
Serial.println("Scanning available networks...");
|
||||
scanNetworks();
|
||||
|
||||
// attempt to connect using WEP encryption:
|
||||
Serial.println("Attempting to connect to open network...");
|
||||
status = WiFi.begin(ssid);
|
||||
|
||||
Serial.print("SSID: ");
|
||||
Serial.println(ssid);
|
||||
|
||||
// if you're not connected, stop here:
|
||||
if ( status != WL_CONNECTED) {
|
||||
Serial.println("Couldn't get a wifi connection");
|
||||
while(true);
|
||||
}
|
||||
// if you are connected, print out info about the connection:
|
||||
else {
|
||||
printIpData();
|
||||
printCurrentNet();
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void printIpData() {
|
||||
// print your WiFi shield's IP address:
|
||||
ip = WiFi.localIP();
|
||||
Serial.print("IP: ");
|
||||
Serial.print(ip[0]);
|
||||
Serial.print(".");
|
||||
Serial.print(ip[1]);
|
||||
Serial.print(".");
|
||||
Serial.print(ip[2]);
|
||||
Serial.print(".");
|
||||
Serial.println(ip[3]);
|
||||
|
||||
// print your subnet mask:
|
||||
subnet = WiFi.subnetMask();
|
||||
Serial.print("NETMASK: ");
|
||||
Serial.print(subnet[0]);
|
||||
Serial.print(".");
|
||||
Serial.print(subnet[1]);
|
||||
Serial.print(".");
|
||||
Serial.print(subnet[2]);
|
||||
Serial.print(".");
|
||||
Serial.println(subnet[3]);
|
||||
|
||||
// print your gateway address:
|
||||
gateway = WiFi.gatewayIP();
|
||||
Serial.print("GATEWAY: ");
|
||||
Serial.print(gateway[0]);
|
||||
Serial.print(".");
|
||||
Serial.print(gateway[1]);
|
||||
Serial.print(".");
|
||||
Serial.print(gateway[2]);
|
||||
Serial.print(".");
|
||||
Serial.println(gateway[3]);
|
||||
|
||||
// print your MAC address:
|
||||
WiFi.macAddress(mac);
|
||||
Serial.print("MAC: ");
|
||||
Serial.print(mac[5],HEX);
|
||||
Serial.print(":");
|
||||
Serial.print(mac[4],HEX);
|
||||
Serial.print(":");
|
||||
Serial.print(mac[3],HEX);
|
||||
Serial.print(":");
|
||||
Serial.print(mac[2],HEX);
|
||||
Serial.print(":");
|
||||
Serial.print(mac[1],HEX);
|
||||
Serial.print(":");
|
||||
Serial.println(mac[0],HEX);
|
||||
}
|
||||
|
||||
void printCurrentNet() {
|
||||
// print the SSID of the network you're attached to:
|
||||
Serial.print("SSID: ");
|
||||
Serial.println(WiFi.SSID());
|
||||
|
||||
// print the MAC address of the router you're attached to:
|
||||
byte bssid[6];
|
||||
WiFi.BSSID(bssid);
|
||||
Serial.print("BSSID: ");
|
||||
Serial.print(bssid[5],HEX);
|
||||
Serial.print(":");
|
||||
Serial.print(bssid[4],HEX);
|
||||
Serial.print(":");
|
||||
Serial.print(bssid[3],HEX);
|
||||
Serial.print(":");
|
||||
Serial.print(bssid[2],HEX);
|
||||
Serial.print(":");
|
||||
Serial.print(bssid[1],HEX);
|
||||
Serial.print(":");
|
||||
Serial.println(bssid[0],HEX);
|
||||
|
||||
// print the received signal strength:
|
||||
long rssi = WiFi.RSSI();
|
||||
Serial.print("RSSI:");
|
||||
Serial.println(rssi);
|
||||
|
||||
// print the encryption type:
|
||||
byte encryption = WiFi.encryptionType();
|
||||
Serial.print("Encryption Type:");
|
||||
Serial.println(encryption,HEX);
|
||||
}
|
||||
|
||||
void scanNetworks() {
|
||||
// scan for nearby networks:
|
||||
Serial.println("** Scan Networks **");
|
||||
byte numSsid = WiFi.scanNetworks();
|
||||
|
||||
// print the list of networks seen:
|
||||
Serial.print("SSID List:");
|
||||
Serial.println(numSsid);
|
||||
// print the network number and name for each network found:
|
||||
for (int thisNet = 0; thisNet<numSsid; thisNet++) {
|
||||
Serial.print(thisNet);
|
||||
Serial.print(") Network: ");
|
||||
Serial.println(WiFi.SSID(thisNet));
|
||||
}
|
||||
}
|
@ -1,164 +0,0 @@
|
||||
/*
|
||||
|
||||
WEP connection using the WiFi shield. Attempts to connect
|
||||
and prints out info about the network
|
||||
|
||||
Circuit:
|
||||
* WiFi shield attached
|
||||
|
||||
created 13 July 2010
|
||||
by dlf (Metodo2 srl)
|
||||
modified 5 June 2011
|
||||
by Tom Igoe
|
||||
*/
|
||||
|
||||
|
||||
#include <SPI.h>
|
||||
#include <WiFi.h>
|
||||
|
||||
char ssid[] = "yourNetwork"; // the name of your network
|
||||
char keyIndex = 0; // WEP networks can have multiple keys.
|
||||
char key[] = "BAE4B2EDB9171646AA0DC8ED19"; // the key you're using to connect
|
||||
int status = WL_IDLE_STATUS; // the Wifi radio's status
|
||||
|
||||
|
||||
byte mac[6]; // the MAC address of your Wifi shield
|
||||
IPAddress ip; // the IP address of your shield
|
||||
IPAddress gateway; // the router's address
|
||||
IPAddress subnet; // the subnet mask
|
||||
|
||||
void setup() {
|
||||
// initialize serial:
|
||||
Serial.begin(9600);
|
||||
|
||||
// attempt to connect using WEP encryption:
|
||||
Serial.println("Attempting to connect to WEP-128 network...");
|
||||
status = WiFi.begin(ssid, keyIndex, key);
|
||||
|
||||
|
||||
Serial.print("SSID: ");
|
||||
Serial.println(ssid);
|
||||
|
||||
// scan for existing networks:
|
||||
Serial.println("Scanning available networks...");
|
||||
scanNetworks();
|
||||
|
||||
// if you're not connected, stop here:
|
||||
if ( status != WL_CONNECTED) {
|
||||
Serial.println("Couldn't get a wifi connection");
|
||||
while(true);
|
||||
}
|
||||
// if you are connected, print out info about the connection:
|
||||
else {
|
||||
printIpData();
|
||||
printCurrentNet();
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void printIpData() {
|
||||
// print your WiFi shield's IP address:
|
||||
ip = WiFi.localIP();
|
||||
Serial.print("IP: ");
|
||||
Serial.print(ip[3]);
|
||||
Serial.print(".");
|
||||
Serial.print(ip[2]);
|
||||
Serial.print(".");
|
||||
Serial.print(ip[1]);
|
||||
Serial.print(".");
|
||||
Serial.println(ip[0]);
|
||||
|
||||
// print your subnet mask:
|
||||
subnet = WiFi.subnetMask();
|
||||
Serial.print("NETMASK: ");
|
||||
Serial.print(subnet[3]);
|
||||
Serial.print(".");
|
||||
Serial.print(subnet[2]);
|
||||
Serial.print(".");
|
||||
Serial.print(subnet[1]);
|
||||
Serial.print(".");
|
||||
Serial.println(subnet[0]);
|
||||
|
||||
// print your gateway address:
|
||||
gateway = WiFi.gatewayIP();
|
||||
Serial.print("GATEWAY: ");
|
||||
Serial.print(gateway[3]);
|
||||
Serial.print(".");
|
||||
Serial.print(gateway[2]);
|
||||
Serial.print(".");
|
||||
Serial.print(gateway[1]);
|
||||
Serial.print(".");
|
||||
Serial.println(gateway[0]);
|
||||
|
||||
// print your MAC address:
|
||||
WiFi.macAddress(mac);
|
||||
Serial.print("MAC: ");
|
||||
Serial.print(mac[5],HEX);
|
||||
Serial.print(":");
|
||||
Serial.print(mac[4],HEX);
|
||||
Serial.print(":");
|
||||
Serial.print(mac[3],HEX);
|
||||
Serial.print(":");
|
||||
Serial.print(mac[2],HEX);
|
||||
Serial.print(":");
|
||||
Serial.print(mac[1],HEX);
|
||||
Serial.print(":");
|
||||
Serial.println(mac[0],HEX);
|
||||
}
|
||||
|
||||
void printCurrentNet() {
|
||||
// print the SSID of the network you're attached to:
|
||||
Serial.print("SSID: ");
|
||||
Serial.println(WiFi.SSID());
|
||||
|
||||
// print the MAC address of the router you're attached to:
|
||||
byte bssid[6];
|
||||
WiFi.BSSID(bssid);
|
||||
Serial.print("BSSID: ");
|
||||
Serial.print(bssid[5],HEX);
|
||||
Serial.print(":");
|
||||
Serial.print(bssid[4],HEX);
|
||||
Serial.print(":");
|
||||
Serial.print(bssid[3],HEX);
|
||||
Serial.print(":");
|
||||
Serial.print(bssid[2],HEX);
|
||||
Serial.print(":");
|
||||
Serial.print(bssid[1],HEX);
|
||||
Serial.print(":");
|
||||
Serial.println(bssid[0],HEX);
|
||||
|
||||
// print the received signal strength:
|
||||
long rssi = WiFi.RSSI();
|
||||
Serial.print("RSSI:");
|
||||
Serial.println(rssi);
|
||||
|
||||
// print the encryption type:
|
||||
byte encryption = WiFi.encryptionType();
|
||||
Serial.print("Encryption Type:");
|
||||
Serial.println(encryption,HEX);
|
||||
}
|
||||
|
||||
void scanNetworks() {
|
||||
// scan for nearby networks:
|
||||
Serial.println("** Scan Networks **");
|
||||
byte numSsid = WiFi.scanNetworks();
|
||||
|
||||
// print the list of networks seen:
|
||||
Serial.print("SSID List:");
|
||||
Serial.println(numSsid);
|
||||
// print the network number and name for each network found:
|
||||
for (int thisNet = 0; thisNet<numSsid; thisNet++) {
|
||||
Serial.print(thisNet);
|
||||
Serial.print(") Network: ");
|
||||
Serial.println(WiFi.SSID(thisNet));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,79 +0,0 @@
|
||||
/*
|
||||
Wifi Chat Server
|
||||
|
||||
A simple server that distributes any incoming messages to all
|
||||
connected clients. To use telnet to your device's IP address and type.
|
||||
You can see the client's input in the serial monitor as well.
|
||||
|
||||
This example obtains an IP address from the Wifi router and
|
||||
reports it.
|
||||
|
||||
Circuit:
|
||||
* WiFi shield attached
|
||||
|
||||
created 21 May 2011
|
||||
by Tom Igoe
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include <SPI.h>
|
||||
#include <WiFi.h>
|
||||
|
||||
char ssid[] = "yourNetwork"; // the name of your network
|
||||
char pass[] = "secretPassword"; // the WPA2 password for your network
|
||||
int status = WL_IDLE_STATUS; // the Wifi radio's status
|
||||
|
||||
// telnet defaults to port 23
|
||||
WiFiServer server(23);
|
||||
|
||||
boolean gotAMessage = false; // whether or not you got a message from the client yet
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
Serial.println("Attempting to connect to WPA network...");
|
||||
Serial.print("SSID: ");
|
||||
Serial.println(ssid);
|
||||
|
||||
status = WiFi.begin(ssid, pass);
|
||||
if ( status != WL_CONNECTED) {
|
||||
Serial.println("Couldn't get a wifi connection");
|
||||
while(true);
|
||||
}
|
||||
else {
|
||||
server.begin();
|
||||
Serial.print("Connected to wifi. My address:");
|
||||
IPAddress myAddress = WiFi.localIP();
|
||||
Serial.print(myAddress[0]);
|
||||
Serial.print(".");
|
||||
Serial.print(myAddress[1]);
|
||||
Serial.print(".");
|
||||
Serial.print(myAddress[2]);
|
||||
Serial.print(".");
|
||||
Serial.println(myAddress[3]);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// wait for a new client:
|
||||
WiFiClient client = server.available();
|
||||
|
||||
// when the client sends the first byte, say hello:
|
||||
if (client) {
|
||||
if (!gotAMessage) {
|
||||
Serial.println("I have a new client");
|
||||
client.println("Hello, client!");
|
||||
gotAMessage = true;
|
||||
}
|
||||
// read the bytes incoming from the client:
|
||||
char thisChar = client.read();
|
||||
// echo the bytes back to the client:
|
||||
client.write(thisChar);
|
||||
// echo the bytes to the server as well:
|
||||
Serial.print(thisChar);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,140 +0,0 @@
|
||||
/*
|
||||
Pachube sensor client with Strings
|
||||
|
||||
This sketch connects an analog sensor to Pachube (http://www.pachube.com)
|
||||
using an Arduino WiFi shield.
|
||||
|
||||
This example uses the String library, which is part of the Arduino core from
|
||||
version 0019.
|
||||
|
||||
Circuit:
|
||||
* Analog sensors attached to analog in 0 and 1
|
||||
* WoFo shield attached to pins 10, 11, 12, 13
|
||||
|
||||
created 15 March 2010
|
||||
updated 5 June 2011
|
||||
by Tom Igoe
|
||||
|
||||
This code is in the public domain.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include <SPI.h>
|
||||
#include <WiFi.h>
|
||||
|
||||
char ssid[] = "yourNetwork";
|
||||
char pass[] = "secretPassword";
|
||||
int status = WL_IDLE_STATUS;
|
||||
|
||||
// The address of the server you want to connect to (pachube.com):
|
||||
IPAddress server(173,203,98,29);
|
||||
|
||||
// initialize the library instance:
|
||||
WiFiClient client;
|
||||
|
||||
long lastConnectionTime = 0; // last time you connected to the server, in milliseconds
|
||||
boolean lastConnected = false; // state of the connection last time through the main loop
|
||||
const int postingInterval = 30000; //delay between updates to Pachube.com
|
||||
|
||||
int startWiFiWpa()
|
||||
{
|
||||
Serial.println("\nSetup WiFi Wpa...");
|
||||
//strcpy(ssid, "AndroidAP9647");
|
||||
strcpy(ssid, "tigoenet");
|
||||
Serial.print("SSID: ");
|
||||
Serial.println(ssid);
|
||||
const char *pass = "m30w-m30w";
|
||||
status = WiFi.begin(ssid, pass);
|
||||
if ( status != WL_CONNECTED)
|
||||
{
|
||||
Serial.println("Connection Failed");
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void setup() {
|
||||
// start the WiFi connection and the server:
|
||||
Serial.begin(9600);
|
||||
Serial.println("*** Start WebClient WiFi example ***");
|
||||
|
||||
int _status = startWiFiWpa();
|
||||
if ( _status == WL_CONNECTED)
|
||||
{
|
||||
Serial.println("\nWiFi Connected.");
|
||||
}
|
||||
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
// read the analog sensor:
|
||||
int sensorReading = analogRead(A0);
|
||||
// convert the data to a String to send it:
|
||||
String dataString = String(sensorReading);
|
||||
|
||||
// you can append multiple readings to this String if your
|
||||
// pachube feed is set up to handle multiple values:
|
||||
int otherSensorReading = analogRead(A1);
|
||||
dataString += ",";
|
||||
dataString += String(otherSensorReading);
|
||||
|
||||
// if there's incoming data from the net connection.
|
||||
// send it out the serial port. This is for debugging
|
||||
// purposes only:
|
||||
if (client.available()) {
|
||||
char c = client.read();
|
||||
Serial.print(c);
|
||||
}
|
||||
|
||||
// if there's no net connection, but there was one last time
|
||||
// through the loop, then stop the client:
|
||||
if (!client.connected() && lastConnected) {
|
||||
Serial.println();
|
||||
Serial.println("disconnecting.");
|
||||
client.stop();
|
||||
}
|
||||
|
||||
// if you're not connected, and ten seconds have passed since
|
||||
// your last connection, then connect again and send data:
|
||||
if(!client.connected() && (millis() - lastConnectionTime > postingInterval)) {
|
||||
sendData(dataString);
|
||||
}
|
||||
// store the state of the connection for next time through
|
||||
// the loop:
|
||||
lastConnected = client.connected();
|
||||
}
|
||||
|
||||
// this method makes a HTTP connection to the server:
|
||||
void sendData(String thisData) {
|
||||
// if there's a successful connection:
|
||||
if (client.connect(server, 80)) {
|
||||
Serial.println("connecting...");
|
||||
// send the HTTP PUT request.
|
||||
// fill in your feed address here:
|
||||
client.print("PUT /api/YOUR_FEED_HERE.csv HTTP/1.1\n");
|
||||
client.print("Host: www.pachube.com\n");
|
||||
// fill in your Pachube API key here:
|
||||
client.print("X-PachubeApiKey: YOUR_KEY_HERE\n");
|
||||
client.print("Content-Length: ");
|
||||
client.println(thisData.length(), DEC);
|
||||
|
||||
// last pieces of the HTTP PUT request:
|
||||
client.print("Content-Type: text/csv\n");
|
||||
client.println("Connection: close\n");
|
||||
|
||||
// here's the actual content of the PUT request:
|
||||
client.println(thisData);
|
||||
|
||||
// note the time that the connection was made:
|
||||
lastConnectionTime = millis();
|
||||
}
|
||||
else {
|
||||
// if you couldn't make a connection:
|
||||
Serial.println("connection failed");
|
||||
}
|
||||
}
|
||||
|
@ -1,170 +0,0 @@
|
||||
/*
|
||||
|
||||
WPA2 conection using the WiFi shield. Attempts to connect
|
||||
and prints out info about the network
|
||||
|
||||
Circuit:
|
||||
* WiFi shield attached
|
||||
|
||||
created 13 July 2010
|
||||
by dlf (Metodo2 srl)
|
||||
modified 5 June 2011
|
||||
by Tom Igoe
|
||||
*/
|
||||
|
||||
|
||||
#include <SPI.h>
|
||||
#include <WiFi.h>
|
||||
|
||||
char ssid[] = "yourNetwork";
|
||||
char pass[] = "secretpassword";
|
||||
int status = WL_IDLE_STATUS; // the Wifi radio's status
|
||||
|
||||
byte mac[6]; // the MAC address of your Wifi shield
|
||||
IPAddress ip; // the IP address of your shield
|
||||
IPAddress gateway; // the router's address
|
||||
IPAddress subnet; // the subnet mask
|
||||
|
||||
void setup() {
|
||||
// initialize serial:
|
||||
Serial.begin(9600);
|
||||
// scan for existing networks:
|
||||
Serial.println("Scanning available networks...");
|
||||
//WiFi.begin();
|
||||
scanNetworks();
|
||||
|
||||
// attempt to connect using WEP encryption:
|
||||
// Serial.println("Attempting to connect to WEP-128 network...");
|
||||
// status = WiFi.begin(ssid, keyIndex, key);
|
||||
|
||||
// attempt to connect using WPA2 encryption:
|
||||
Serial.println("Attempting to connect to WPA network...");
|
||||
status = WiFi.begin(ssid, pass);
|
||||
|
||||
|
||||
Serial.print("SSID: ");
|
||||
Serial.println(ssid);
|
||||
|
||||
// scan for existing networks:
|
||||
Serial.println("Scanning available networks...");
|
||||
scanNetworks();
|
||||
|
||||
// if you're not connected, stop here:
|
||||
if ( status != WL_CONNECTED) {
|
||||
Serial.println("Couldn't get a wifi connection");
|
||||
while(true);
|
||||
}
|
||||
// if you are connected, print out info about the connection:
|
||||
else {
|
||||
printIpData();
|
||||
printCurrentNet();
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void printIpData() {
|
||||
// print your WiFi shield's IP address:
|
||||
ip = WiFi.localIP();
|
||||
Serial.print("IP: ");
|
||||
Serial.print(ip[0]);
|
||||
Serial.print(".");
|
||||
Serial.print(ip[1]);
|
||||
Serial.print(".");
|
||||
Serial.print(ip[2]);
|
||||
Serial.print(".");
|
||||
Serial.println(ip[3]);
|
||||
|
||||
// print your subnet mask:
|
||||
subnet = WiFi.subnetMask();
|
||||
Serial.print("NETMASK: ");
|
||||
Serial.print(subnet[0]);
|
||||
Serial.print(".");
|
||||
Serial.print(subnet[1]);
|
||||
Serial.print(".");
|
||||
Serial.print(subnet[2]);
|
||||
Serial.print(".");
|
||||
Serial.println(subnet[3]);
|
||||
|
||||
// print your gateway address:
|
||||
gateway = WiFi.gatewayIP();
|
||||
Serial.print("GATEWAY: ");
|
||||
Serial.print(gateway[0]);
|
||||
Serial.print(".");
|
||||
Serial.print(gateway[1]);
|
||||
Serial.print(".");
|
||||
Serial.print(gateway[2]);
|
||||
Serial.print(".");
|
||||
Serial.println(gateway[3]);
|
||||
|
||||
// print your MAC address:
|
||||
WiFi.macAddress(mac);
|
||||
Serial.print("MAC: ");
|
||||
Serial.print(mac[5],HEX);
|
||||
Serial.print(":");
|
||||
Serial.print(mac[4],HEX);
|
||||
Serial.print(":");
|
||||
Serial.print(mac[3],HEX);
|
||||
Serial.print(":");
|
||||
Serial.print(mac[2],HEX);
|
||||
Serial.print(":");
|
||||
Serial.print(mac[1],HEX);
|
||||
Serial.print(":");
|
||||
Serial.println(mac[0],HEX);
|
||||
}
|
||||
|
||||
void printCurrentNet() {
|
||||
// print the SSID of the network you're attached to:
|
||||
Serial.print("SSID: ");
|
||||
Serial.println(WiFi.SSID());
|
||||
|
||||
// print the MAC address of the router you're attached to:
|
||||
byte bssid[6];
|
||||
WiFi.BSSID(bssid);
|
||||
Serial.print("BSSID: ");
|
||||
Serial.print(bssid[5],HEX);
|
||||
Serial.print(":");
|
||||
Serial.print(bssid[4],HEX);
|
||||
Serial.print(":");
|
||||
Serial.print(bssid[3],HEX);
|
||||
Serial.print(":");
|
||||
Serial.print(bssid[2],HEX);
|
||||
Serial.print(":");
|
||||
Serial.print(bssid[1],HEX);
|
||||
Serial.print(":");
|
||||
Serial.println(bssid[0],HEX);
|
||||
|
||||
// print the received signal strength:
|
||||
long rssi = WiFi.RSSI();
|
||||
Serial.print("RSSI:");
|
||||
Serial.println(rssi);
|
||||
|
||||
// print the encryption type:
|
||||
byte encryption = WiFi.encryptionType();
|
||||
Serial.print("Encryption Type:");
|
||||
Serial.println(encryption,HEX);
|
||||
}
|
||||
|
||||
void scanNetworks() {
|
||||
// scan for nearby networks:
|
||||
Serial.println("** Scan Networks **");
|
||||
byte numSsid = WiFi.scanNetworks();
|
||||
|
||||
// print the list of networks seen:
|
||||
Serial.print("SSID List:");
|
||||
Serial.println(numSsid);
|
||||
// print the network number and name for each network found:
|
||||
for (int thisNet = 0; thisNet<numSsid; thisNet++) {
|
||||
Serial.print(thisNet);
|
||||
Serial.print(") Network: ");
|
||||
Serial.println(WiFi.SSID(thisNet));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,121 +0,0 @@
|
||||
/*
|
||||
Twitter Client with Strings
|
||||
|
||||
This sketch connects to Twitter using using an Arduino WiFi shield.
|
||||
It parses the XML returned, and looks for <text>this is a tweet</text>
|
||||
|
||||
This example uses the String library, which is part of the Arduino core from
|
||||
version 0019.
|
||||
|
||||
Circuit:
|
||||
* WiFi shield attached to pins 10, 11, 12, 13
|
||||
|
||||
created 21 May 2011
|
||||
by Tom Igoe
|
||||
|
||||
This code is in the public domain.
|
||||
|
||||
*/
|
||||
#include <SPI.h>
|
||||
#include <WiFi.h>
|
||||
|
||||
char ssid[] = "yourNetwork";
|
||||
char pass[] = "secretpassword";
|
||||
int status = WL_IDLE_STATUS;
|
||||
|
||||
// initialize the library instance:
|
||||
WiFiClient client;
|
||||
|
||||
const int requestInterval = 30*1000; // delay between requests; 30 seconds
|
||||
|
||||
IPAddress server(199,59,149,200); // api.twitter.com
|
||||
|
||||
boolean requested; // whether you've made a request since connecting
|
||||
long lastAttemptTime = 0; // last time you connected to the server, in milliseconds
|
||||
|
||||
String currentLine = ""; // string to hold the text from server
|
||||
String tweet = ""; // string to hold the tweet
|
||||
boolean readingTweet = false; // if you're currently reading the tweet
|
||||
|
||||
void setup() {
|
||||
// reserve space for the strings:
|
||||
currentLine.reserve(256);
|
||||
tweet.reserve(150);
|
||||
// initialize serial:
|
||||
Serial.begin(9600);
|
||||
Serial.println("Attempting to connect to WPA network...");
|
||||
Serial.print("SSID: ");
|
||||
Serial.println(ssid);
|
||||
|
||||
status = WiFi.begin(ssid, pass);
|
||||
if ( status != WL_CONNECTED) {
|
||||
Serial.println("Couldn't get a wifi connection");
|
||||
while(true);
|
||||
}
|
||||
else {
|
||||
Serial.println("Connected to wifi");
|
||||
connectToServer();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (client.connected()) {
|
||||
if (client.available()) {
|
||||
// read incoming bytes:
|
||||
char inChar = client.read();
|
||||
|
||||
// add incoming byte to end of line:
|
||||
currentLine += inChar;
|
||||
|
||||
// if you get a newline, clear the line:
|
||||
if (inChar == '\n') {
|
||||
currentLine = "";
|
||||
}
|
||||
// if the current line ends with <text>, it will
|
||||
// be followed by the tweet:
|
||||
if ( currentLine.endsWith("<text>")) {
|
||||
// tweet is beginning. Clear the tweet string:
|
||||
readingTweet = true;
|
||||
tweet = "";
|
||||
}
|
||||
// if you're currently reading the bytes of a tweet,
|
||||
// add them to the tweet String:
|
||||
if (readingTweet) {
|
||||
if (inChar != '<') {
|
||||
tweet += inChar;
|
||||
}
|
||||
else {
|
||||
// if you got a "<" character,
|
||||
// you've reached the end of the tweet:
|
||||
readingTweet = false;
|
||||
Serial.println(tweet);
|
||||
// close the connection to the server:
|
||||
client.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (millis() - lastAttemptTime > requestInterval) {
|
||||
// if you're not connected, and two minutes have passed since
|
||||
// your last connection, then attempt to connect again:
|
||||
connectToServer();
|
||||
}
|
||||
}
|
||||
|
||||
void connectToServer() {
|
||||
// attempt to connect, and wait a millisecond:
|
||||
Serial.println("connecting to server...");
|
||||
if (client.connect(server, 80)) {
|
||||
Serial.println("making HTTP request...");
|
||||
// make HTTP GET request to twitter:
|
||||
client.println("GET /1/statuses/user_timeline.xml?screen_name=arduinoteam HTTP/1.1");
|
||||
client.println("HOST: api.twitter.com");
|
||||
client.println();
|
||||
}
|
||||
// note the time of this connect attempt:
|
||||
lastAttemptTime = millis();
|
||||
}
|
||||
|
@ -1,76 +0,0 @@
|
||||
|
||||
/*
|
||||
Web client
|
||||
|
||||
This sketch connects to a website (http://www.google.com)
|
||||
using a WiFi shield.
|
||||
|
||||
Circuit:
|
||||
* WiFi shield attached
|
||||
|
||||
created 13 July 2010
|
||||
by dlf (Metodo2 srl)
|
||||
modified 21 May 2011
|
||||
by Tom Igoe
|
||||
*/
|
||||
|
||||
|
||||
#include <SPI.h>
|
||||
#include <WiFi.h>
|
||||
|
||||
char ssid[] = "yourNetwork";
|
||||
char pass[] = "secretPassword";
|
||||
int status = WL_IDLE_STATUS;
|
||||
IPAddress server(74,125,115,105); // Google
|
||||
|
||||
// Initialize the Ethernet client library
|
||||
// with the IP address and port of the server
|
||||
// that you want to connect to (port 80 is default for HTTP):
|
||||
WiFiClient client;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
Serial.println("Attempting to connect to WPA network...");
|
||||
Serial.print("SSID: ");
|
||||
Serial.println(ssid);
|
||||
|
||||
status = WiFi.begin(ssid, pass);
|
||||
if ( status != WL_CONNECTED) {
|
||||
Serial.println("Couldn't get a wifi connection");
|
||||
// don't do anything else:
|
||||
while(true);
|
||||
}
|
||||
else {
|
||||
Serial.println("Connected to wifi");
|
||||
Serial.println("\nStarting connection...");
|
||||
// if you get a connection, report back via serial:
|
||||
if (client.connect(server, 80)) {
|
||||
Serial.println("connected");
|
||||
// Make a HTTP request:
|
||||
client.println("GET /search?q=arduino HTTP/1.0");
|
||||
client.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// if there are incoming bytes available
|
||||
// from the server, read them and print them:
|
||||
if (client.available()) {
|
||||
char c = client.read();
|
||||
Serial.print(c);
|
||||
}
|
||||
|
||||
// if the server's disconnected, stop the client:
|
||||
if (!client.connected()) {
|
||||
Serial.println();
|
||||
Serial.println("disconnecting.");
|
||||
client.stop();
|
||||
|
||||
// do nothing forevermore:
|
||||
for(;;)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,100 +0,0 @@
|
||||
/*
|
||||
Web Server
|
||||
|
||||
A simple web server that shows the value of the analog input pins.
|
||||
using a WiFi shield.
|
||||
|
||||
Circuit:
|
||||
* WiFi shield attached
|
||||
* Analog inputs attached to pins A0 through A5 (optional)
|
||||
|
||||
created 13 July 2010
|
||||
by dlf (Metodo2 srl)
|
||||
modified 5 June 2011
|
||||
by Tom Igoe
|
||||
*/
|
||||
|
||||
|
||||
#include <SPI.h>
|
||||
#include <WiFi.h>
|
||||
|
||||
char ssid[] = "yourNetwork";
|
||||
char pass[] = "secretpassword";
|
||||
int status = WL_IDLE_STATUS;
|
||||
|
||||
WiFiServer server(80);
|
||||
|
||||
void setup() {
|
||||
// initialize serial:
|
||||
Serial.begin(9600);
|
||||
Serial.println("Attempting to connect to WPA network...");
|
||||
Serial.print("SSID: ");
|
||||
Serial.println(ssid);
|
||||
|
||||
status = WiFi.begin(ssid, pass);
|
||||
if ( status != WL_CONNECTED) {
|
||||
Serial.println("Couldn't get a wifi connection");
|
||||
while(true);
|
||||
}
|
||||
else {
|
||||
server.begin();
|
||||
Serial.print("Connected to wifi. My address:");
|
||||
IPAddress myAddress = WiFi.localIP();
|
||||
Serial.print(myAddress[0]);
|
||||
Serial.print(".");
|
||||
Serial.print(myAddress[1]);
|
||||
Serial.print(".");
|
||||
Serial.print(myAddress[2]);
|
||||
Serial.print(".");
|
||||
Serial.println(myAddress[3]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
// listen for incoming clients
|
||||
WiFiClient client = server.available();
|
||||
if (client) {
|
||||
// an http request ends with a blank line
|
||||
boolean currentLineIsBlank = true;
|
||||
while (client.connected()) {
|
||||
if (client.available()) {
|
||||
char c = client.read();
|
||||
// if you've gotten to the end of the line (received a newline
|
||||
// character) and the line is blank, the http request has ended,
|
||||
// so you can send a reply
|
||||
if (c == '\n' && currentLineIsBlank) {
|
||||
// send a standard http response header
|
||||
client.println("HTTP/1.1 200 OK");
|
||||
client.println("Content-Type: text/html");
|
||||
client.println();
|
||||
client.println("<html>");
|
||||
// output the value of each analog input pin
|
||||
for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
|
||||
client.print("analog input ");
|
||||
client.print(analogChannel);
|
||||
client.print(" is ");
|
||||
client.print(analogRead(analogChannel));
|
||||
client.println("<br />");
|
||||
}
|
||||
client.println("</html>");
|
||||
break;
|
||||
}
|
||||
if (c == '\n') {
|
||||
// you're starting a new line
|
||||
currentLineIsBlank = true;
|
||||
}
|
||||
else if (c != '\r') {
|
||||
// you've gotten a character on the current line
|
||||
currentLineIsBlank = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
// give the web browser time to receive the data
|
||||
delay(1);
|
||||
// close the connection:
|
||||
client.stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,158 +0,0 @@
|
||||
/*
|
||||
WiFi Server example
|
||||
|
||||
A simple connection with WiFi AP with Wireless Security
|
||||
information try to access with WPA or WEP security keys
|
||||
A simple server is setup to exchange data.
|
||||
|
||||
created 13 July 2010
|
||||
by dlf (Metodo2 srl)
|
||||
*/
|
||||
#include <WiFi.h>
|
||||
|
||||
byte mac[6] = { 0 };
|
||||
IPAddress ip;
|
||||
IPAddress gateway;
|
||||
IPAddress subnet;
|
||||
byte dataBuf[80] = { 0 };
|
||||
char ssid[32] = { 0 };
|
||||
int status = WL_IDLE_STATUS;
|
||||
|
||||
WiFiServer server(23);
|
||||
|
||||
void printIpData()
|
||||
{
|
||||
ip = WiFi.localIP();
|
||||
|
||||
Serial.print("IP: ");
|
||||
Serial.print(ip[3],10);Serial.print(".");
|
||||
Serial.print(ip[2],10);Serial.print(".");
|
||||
Serial.print(ip[1],10);Serial.print(".");
|
||||
Serial.println(ip[0],10);
|
||||
|
||||
subnet = WiFi.subnetMask();
|
||||
Serial.print("NETMASK: ");
|
||||
Serial.print(subnet[3],10);Serial.print(".");
|
||||
Serial.print(subnet[2],10);Serial.print(".");
|
||||
Serial.print(subnet[1],10);Serial.print(".");
|
||||
Serial.println(subnet[0],10);
|
||||
|
||||
gateway = WiFi.gatewayIP();
|
||||
Serial.print("GATEWAY: ");
|
||||
Serial.print(gateway[3],10);Serial.print(".");
|
||||
Serial.print(gateway[2],10);Serial.print(".");
|
||||
Serial.print(gateway[1],10);Serial.print(".");
|
||||
Serial.println(gateway[0],10);
|
||||
|
||||
WiFi.macAddress(mac);
|
||||
Serial.print("MAC: ");
|
||||
Serial.print(mac[5],16);Serial.print(":");
|
||||
Serial.print(mac[4],16);Serial.print(":");
|
||||
Serial.print(mac[3],16);Serial.print(":");
|
||||
Serial.print(mac[2],16);Serial.print(":");
|
||||
Serial.print(mac[1],16);Serial.print(":");
|
||||
Serial.println(mac[0],16);
|
||||
}
|
||||
|
||||
void printCurrNet()
|
||||
{
|
||||
//WiFi.getCurrSSID(&ssid[0]);
|
||||
//Serial.print("SSID:");
|
||||
//Serial.println(ssid);
|
||||
byte bssid[6];
|
||||
WiFi.BSSID(bssid);
|
||||
//delay(200);
|
||||
Serial.print("BSSID:");
|
||||
Serial.print(bssid[5],16);Serial.print(":");
|
||||
Serial.print(bssid[4],16);Serial.print(":");
|
||||
Serial.print(bssid[3],16);Serial.print(":");
|
||||
Serial.print(bssid[2],16);Serial.print(":");
|
||||
Serial.print(bssid[1],16);Serial.print(":");
|
||||
Serial.println(bssid[0],16);
|
||||
|
||||
int32_t rssi = WiFi.RSSI();
|
||||
Serial.print("RSSI:");
|
||||
Serial.println(rssi,10);
|
||||
|
||||
uint8_t enct = WiFi.encryptionType();
|
||||
Serial.print("Encryption Type:");
|
||||
Serial.println(enct,16);
|
||||
|
||||
char ssid[20][32] = { {0} };
|
||||
byte numSsid = WiFi.scanNetworks();
|
||||
Serial.print("SSID List:");
|
||||
Serial.println(numSsid, 10);
|
||||
for (int i = 0; i<numSsid; ++i)
|
||||
{
|
||||
Serial.println(WiFi.SSID(i));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
Serial.println("Setup WiFi...");
|
||||
strcpy(ssid, "Vodafone-10289870");
|
||||
Serial.println(ssid);
|
||||
int status = WiFi.begin(ssid);
|
||||
if ( status != WL_CONNECTED)
|
||||
{
|
||||
// Using WPA
|
||||
Serial.println("Trying with Passphrase...");
|
||||
const char *pass = "12345678";
|
||||
status = WiFi.begin(ssid, pass);
|
||||
if ( status != WL_CONNECTED)
|
||||
{
|
||||
// using WEP
|
||||
Serial.println("Trying with Key...");
|
||||
uint8_t key_idx = 0;
|
||||
const char *key = "12345678";
|
||||
status = WiFi.begin(ssid,key_idx, key);
|
||||
if ( status != WL_CONNECTED)
|
||||
{
|
||||
Serial.println("Wifi Connection failed!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
Serial.println("Wifi Connected!");
|
||||
|
||||
printIpData();
|
||||
|
||||
printCurrNet();
|
||||
|
||||
Serial.println("Starting server...");
|
||||
server.begin();
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
static uint8_t count = 0;
|
||||
Serial.println("Retry connect...");
|
||||
status = WiFi.begin(ssid);
|
||||
if (status == WL_CONNECTED)
|
||||
{
|
||||
byte status = 0;
|
||||
WiFiClient client = server.available(&status);
|
||||
if (client) {
|
||||
//Serial.print("Status: ");
|
||||
//Serial.println(status, 16);
|
||||
byte idx = 0;
|
||||
while (client.available())
|
||||
{
|
||||
dataBuf[idx++] = client.read();
|
||||
}
|
||||
|
||||
if (idx>0)
|
||||
{
|
||||
dataBuf[idx]=0;
|
||||
//Serial.println((char*)&dataBuf[0]);
|
||||
server.write((char*)&dataBuf[0]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,171 +0,0 @@
|
||||
/*
|
||||
WiFi Server example
|
||||
|
||||
A simple connection with WiFi AP with Wireless Security
|
||||
information try to access with WPA or WEP security keys
|
||||
A simple server is setup to exchange data.
|
||||
|
||||
created 13 July 2010
|
||||
by dlf (Metodo2 srl)
|
||||
*/
|
||||
#include <WiFi.h>
|
||||
|
||||
byte mac[6] = { 0 };
|
||||
IPAddress ip;
|
||||
IPAddress gateway;
|
||||
IPAddress subnet;
|
||||
byte dataBuf[80] = { 0 };
|
||||
char ssid[32] = { 0 };
|
||||
int status = WL_IDLE_STATUS;
|
||||
#define MAX_NUM_SSID 10
|
||||
char ssidList[MAX_NUM_SSID][32] = { {0} };
|
||||
|
||||
WiFiServer server(23);
|
||||
|
||||
void printIpData()
|
||||
{
|
||||
ip = WiFi.localIP();
|
||||
|
||||
Serial.print("IP: ");
|
||||
Serial.print(ip[3],10);Serial.print(".");
|
||||
Serial.print(ip[2],10);Serial.print(".");
|
||||
Serial.print(ip[1],10);Serial.print(".");
|
||||
Serial.println(ip[0],10);
|
||||
|
||||
subnet = WiFi.subnetMask();
|
||||
Serial.print("NETMASK: ");
|
||||
Serial.print(subnet[3],10);Serial.print(".");
|
||||
Serial.print(subnet[2],10);Serial.print(".");
|
||||
Serial.print(subnet[1],10);Serial.print(".");
|
||||
Serial.println(subnet[0],10);
|
||||
|
||||
gateway = WiFi.gatewayIP();
|
||||
Serial.print("GATEWAY: ");
|
||||
Serial.print(gateway[3],10);Serial.print(".");
|
||||
Serial.print(gateway[2],10);Serial.print(".");
|
||||
Serial.print(gateway[1],10);Serial.print(".");
|
||||
Serial.println(gateway[0],10);
|
||||
|
||||
WiFi.macAddress(mac);
|
||||
Serial.print("MAC: ");
|
||||
Serial.print(mac[5],16);Serial.print(":");
|
||||
Serial.print(mac[4],16);Serial.print(":");
|
||||
Serial.print(mac[3],16);Serial.print(":");
|
||||
Serial.print(mac[2],16);Serial.print(":");
|
||||
Serial.print(mac[1],16);Serial.print(":");
|
||||
Serial.println(mac[0],16);
|
||||
}
|
||||
|
||||
void printCurrNet()
|
||||
{
|
||||
char* ssid = WiFi.SSID();
|
||||
Serial.print("SSID: ");
|
||||
Serial.println(ssid);
|
||||
|
||||
byte bssid[6];
|
||||
WiFi.BSSID(bssid);
|
||||
Serial.print("BSSID: ");
|
||||
Serial.print(bssid[5],16);Serial.print(":");
|
||||
Serial.print(bssid[4],16);Serial.print(":");
|
||||
Serial.print(bssid[3],16);Serial.print(":");
|
||||
Serial.print(bssid[2],16);Serial.print(":");
|
||||
Serial.print(bssid[1],16);Serial.print(":");
|
||||
Serial.println(bssid[0],16);
|
||||
|
||||
int32_t rssi = WiFi.RSSI();
|
||||
Serial.print("RSSI:");
|
||||
Serial.println(rssi,10);
|
||||
|
||||
uint8_t enct = WiFi.encryptionType();
|
||||
Serial.print("Encryption Type:");
|
||||
Serial.println(enct,16);
|
||||
}
|
||||
|
||||
void scanNetworks()
|
||||
{
|
||||
Serial.println("** Scan Networks **");
|
||||
byte numSsid = WiFi.scanNetworks();
|
||||
if (numSsid > MAX_NUM_SSID) numSsid = MAX_NUM_SSID;
|
||||
Serial.print("SSID List:");
|
||||
Serial.println(numSsid, 10);
|
||||
for (int i = 0; i<numSsid; ++i)
|
||||
{
|
||||
Serial.print(i,10);
|
||||
Serial.print(") Network: ");
|
||||
Serial.println(WiFi.SSID(i));
|
||||
}
|
||||
}
|
||||
|
||||
int startWiFiWep()
|
||||
{
|
||||
Serial.println("Setup WiFi Wep...");
|
||||
strcpy(ssid, "Cariddiwep");
|
||||
Serial.print("SSID: ");
|
||||
Serial.println(ssid);
|
||||
uint8_t key_idx = 0;
|
||||
const char *key = "1234567890";
|
||||
Serial.println("Connecting...");
|
||||
status = WiFi.begin(ssid,key_idx, key);
|
||||
if ( status != WL_CONNECTED)
|
||||
{
|
||||
Serial.println("Connection Failed");
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
Serial.println("*** Start WiFi example ***");
|
||||
|
||||
delay(3000);
|
||||
|
||||
startWiFiWep();
|
||||
|
||||
if ( status == WL_CONNECTED)
|
||||
{
|
||||
Serial.println("Wifi Connected!");
|
||||
|
||||
printIpData();
|
||||
|
||||
printCurrNet();
|
||||
|
||||
scanNetworks();
|
||||
|
||||
Serial.println("Starting server...");
|
||||
server.begin();
|
||||
delay(1000);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
if (status == WL_CONNECTED)
|
||||
{
|
||||
byte _status = 0;
|
||||
WiFiClient client = server.available(&_status);
|
||||
if (client) {
|
||||
Serial.print("Status: ");
|
||||
Serial.println(status, 16);
|
||||
/*
|
||||
byte idx = 0;
|
||||
while (client.available())
|
||||
{
|
||||
dataBuf[idx++] = client.read();
|
||||
}
|
||||
|
||||
if (idx>0)
|
||||
{
|
||||
dataBuf[idx]=0;
|
||||
Serial.println((char*)&dataBuf[0]);
|
||||
server.write((char*)&dataBuf[0]);
|
||||
}
|
||||
return;
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,201 +0,0 @@
|
||||
/*
|
||||
WiFi Server example
|
||||
|
||||
A simple connection with WiFi AP with Wireless Security
|
||||
information try to access with WPA or WEP security keys
|
||||
A simple server is setup to exchange data.
|
||||
|
||||
created 13 July 2010
|
||||
by dlf (Metodo2 srl)
|
||||
*/
|
||||
#include <WiFi.h>
|
||||
|
||||
#define _PRINT_
|
||||
|
||||
byte mac[6] = { 0 };
|
||||
IPAddress ip;
|
||||
IPAddress gateway;
|
||||
IPAddress subnet;
|
||||
byte dataBuf[80] = { 0 };
|
||||
char ssid[32] = { 0 };
|
||||
int status = WL_IDLE_STATUS;
|
||||
#define MAX_NUM_SSID 10
|
||||
char ssidList[MAX_NUM_SSID][32] = { {0} };
|
||||
|
||||
|
||||
WiFiServer server(23);
|
||||
boolean gotAMessage = false; // whether or not you got a message from the client yet
|
||||
|
||||
void printIpData()
|
||||
{
|
||||
ip = WiFi.localIP();
|
||||
|
||||
Serial.print("\nIP: ");
|
||||
Serial.print(ip[3],10);Serial.print(".");
|
||||
Serial.print(ip[2],10);Serial.print(".");
|
||||
Serial.print(ip[1],10);Serial.print(".");
|
||||
Serial.println(ip[0],10);
|
||||
|
||||
subnet = WiFi.subnetMask();
|
||||
Serial.print("NETMASK: ");
|
||||
Serial.print(subnet[3],10);Serial.print(".");
|
||||
Serial.print(subnet[2],10);Serial.print(".");
|
||||
Serial.print(subnet[1],10);Serial.print(".");
|
||||
Serial.println(subnet[0],10);
|
||||
|
||||
gateway = WiFi.gatewayIP();
|
||||
Serial.print("GATEWAY: ");
|
||||
Serial.print(gateway[3],10);Serial.print(".");
|
||||
Serial.print(gateway[2],10);Serial.print(".");
|
||||
Serial.print(gateway[1],10);Serial.print(".");
|
||||
Serial.println(gateway[0],10);
|
||||
|
||||
WiFi.macAddress(mac);
|
||||
Serial.print("MAC: ");
|
||||
Serial.print(mac[5],16);Serial.print(":");
|
||||
Serial.print(mac[4],16);Serial.print(":");
|
||||
Serial.print(mac[3],16);Serial.print(":");
|
||||
Serial.print(mac[2],16);Serial.print(":");
|
||||
Serial.print(mac[1],16);Serial.print(":");
|
||||
Serial.println(mac[0],16);
|
||||
}
|
||||
|
||||
void printCurrNet()
|
||||
{
|
||||
char* ssid = WiFi.SSID();
|
||||
Serial.print("SSID: ");
|
||||
Serial.println(ssid);
|
||||
|
||||
byte bssid[6];
|
||||
WiFi.BSSID(bssid);
|
||||
Serial.print("BSSID: ");
|
||||
Serial.print(bssid[5],16);Serial.print(":");
|
||||
Serial.print(bssid[4],16);Serial.print(":");
|
||||
Serial.print(bssid[3],16);Serial.print(":");
|
||||
Serial.print(bssid[2],16);Serial.print(":");
|
||||
Serial.print(bssid[1],16);Serial.print(":");
|
||||
Serial.println(bssid[0],16);
|
||||
|
||||
int32_t rssi = WiFi.RSSI();
|
||||
Serial.print("RSSI:");
|
||||
Serial.println(rssi,10);
|
||||
|
||||
uint8_t enct = WiFi.encryptionType();
|
||||
Serial.print("Encryption Type:");
|
||||
Serial.println(enct,16);
|
||||
}
|
||||
|
||||
void scanNetworks()
|
||||
{
|
||||
Serial.println("\n** Scan Networks **");
|
||||
byte numSsid = WiFi.scanNetworks();
|
||||
if (numSsid > MAX_NUM_SSID) numSsid = MAX_NUM_SSID;
|
||||
Serial.print("SSID List:");
|
||||
Serial.println(numSsid, 10);
|
||||
for (int i = 0; i<numSsid; ++i)
|
||||
{
|
||||
Serial.print(i,10);
|
||||
Serial.print(") Network: ");
|
||||
Serial.println(WiFi.SSID(i));
|
||||
}
|
||||
}
|
||||
|
||||
int startWiFiWpa()
|
||||
{
|
||||
Serial.println("\nSetup WiFi Wpa...");
|
||||
//strcpy(ssid, "AndroidAP9647");
|
||||
//strcpy(ssid, "AndroidAP3551");
|
||||
strcpy(ssid, "Cariddi");
|
||||
Serial.print("SSID: ");
|
||||
Serial.println(ssid);
|
||||
const char *pass = "1234567890";
|
||||
status = WiFi.begin(ssid, pass);
|
||||
//status = WiFi.begin(ssid);
|
||||
if ( status != WL_CONNECTED)
|
||||
{
|
||||
Serial.println("Connection Failed");
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
Serial.println("*** Start WiFi example ***");
|
||||
|
||||
WiFi.begin();
|
||||
|
||||
// Wait for initialize WiFi
|
||||
delay(3000);
|
||||
|
||||
scanNetworks();
|
||||
|
||||
int _status = startWiFiWpa();
|
||||
|
||||
if ( _status == WL_CONNECTED)
|
||||
{
|
||||
Serial.println("\nWifi Connected!");
|
||||
|
||||
printIpData();
|
||||
|
||||
printCurrNet();
|
||||
|
||||
Serial.println("\nStarting server...");
|
||||
server.begin();
|
||||
delay(1000);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void execCmd(char* buf)
|
||||
{
|
||||
#ifdef _PRINT_
|
||||
Serial.print("\nExecuting command: ");
|
||||
Serial.println(buf);
|
||||
#endif
|
||||
server.write(buf);
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (status == WL_CONNECTED)
|
||||
{
|
||||
byte _status = 0;
|
||||
WiFiClient client = server.available(&_status);
|
||||
if (client) {
|
||||
if (!gotAMessage) {
|
||||
Serial.println("\nWe have a new client\n");
|
||||
client.println("Hello, client!");
|
||||
gotAMessage = true;
|
||||
}
|
||||
|
||||
static byte idx = 0;
|
||||
int c = 0;
|
||||
|
||||
do
|
||||
{
|
||||
c = client.read();
|
||||
if (c!=-1)
|
||||
{
|
||||
dataBuf[idx] = c;
|
||||
#ifdef _PRINT_
|
||||
if (idx == 0) Serial.print("Client chatting...: ");
|
||||
Serial.print(dataBuf[idx]);
|
||||
#endif
|
||||
if ((dataBuf[idx] == 0xa)/*||(dataBuf[idx] == 0xd)*/)
|
||||
{
|
||||
dataBuf[idx+1]=0;
|
||||
//Serial.println((char*)dataBuf);
|
||||
execCmd((char*)dataBuf);
|
||||
idx=0;
|
||||
}else{
|
||||
++idx;
|
||||
}
|
||||
}
|
||||
}while (c!=-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,142 +0,0 @@
|
||||
/*
|
||||
WiFi Server example
|
||||
|
||||
A simple connection with WiFi AP with Wireless Security
|
||||
information try to access with WPA or WEP security keys
|
||||
A simple server is setup to exchange data.
|
||||
|
||||
created 13 July 2010
|
||||
by dlf (Metodo2 srl)
|
||||
*/
|
||||
#include <WiFi.h>
|
||||
|
||||
byte mac[6] = { 0 };
|
||||
IPAddress ip;
|
||||
IPAddress gateway;
|
||||
IPAddress subnet;
|
||||
byte dataBuf[80] = { 0 };
|
||||
char ssid[32] = { 0 };
|
||||
int status = WL_IDLE_STATUS;
|
||||
#define MAX_NUM_SSID 10
|
||||
char ssidList[MAX_NUM_SSID][32] = { {0} };
|
||||
|
||||
|
||||
WiFiServer server(23);
|
||||
|
||||
void printIpData()
|
||||
{
|
||||
ip = WiFi.localIP();
|
||||
|
||||
Serial.print("IP: ");
|
||||
Serial.print(ip[3],10);Serial.print(".");
|
||||
Serial.print(ip[2],10);Serial.print(".");
|
||||
Serial.print(ip[1],10);Serial.print(".");
|
||||
Serial.println(ip[0],10);
|
||||
|
||||
subnet = WiFi.subnetMask();
|
||||
Serial.print("NETMASK: ");
|
||||
Serial.print(subnet[3],10);Serial.print(".");
|
||||
Serial.print(subnet[2],10);Serial.print(".");
|
||||
Serial.print(subnet[1],10);Serial.print(".");
|
||||
Serial.println(subnet[0],10);
|
||||
|
||||
gateway = WiFi.gatewayIP();
|
||||
Serial.print("GATEWAY: ");
|
||||
Serial.print(gateway[3],10);Serial.print(".");
|
||||
Serial.print(gateway[2],10);Serial.print(".");
|
||||
Serial.print(gateway[1],10);Serial.print(".");
|
||||
Serial.println(gateway[0],10);
|
||||
|
||||
WiFi.macAddress(mac);
|
||||
Serial.print("MAC: ");
|
||||
Serial.print(mac[5],16);Serial.print(":");
|
||||
Serial.print(mac[4],16);Serial.print(":");
|
||||
Serial.print(mac[3],16);Serial.print(":");
|
||||
Serial.print(mac[2],16);Serial.print(":");
|
||||
Serial.print(mac[1],16);Serial.print(":");
|
||||
Serial.println(mac[0],16);
|
||||
}
|
||||
|
||||
void printCurrNet()
|
||||
{
|
||||
char* ssid = WiFi.SSID();
|
||||
Serial.print("SSID: ");
|
||||
Serial.println(ssid);
|
||||
|
||||
byte bssid[6];
|
||||
WiFi.BSSID(bssid);
|
||||
Serial.print("BSSID: ");
|
||||
Serial.print(bssid[5],16);Serial.print(":");
|
||||
Serial.print(bssid[4],16);Serial.print(":");
|
||||
Serial.print(bssid[3],16);Serial.print(":");
|
||||
Serial.print(bssid[2],16);Serial.print(":");
|
||||
Serial.print(bssid[1],16);Serial.print(":");
|
||||
Serial.println(bssid[0],16);
|
||||
|
||||
int32_t rssi = WiFi.RSSI();
|
||||
Serial.print("RSSI:");
|
||||
Serial.println(rssi,10);
|
||||
|
||||
uint8_t enct = WiFi.encryptionType();
|
||||
Serial.print("Encryption Type:");
|
||||
Serial.println(enct,16);
|
||||
}
|
||||
|
||||
void scanNetworks()
|
||||
{
|
||||
Serial.println("** Scan Networks **");
|
||||
byte numSsid = WiFi.scanNetworks();
|
||||
if (numSsid > MAX_NUM_SSID) numSsid = MAX_NUM_SSID;
|
||||
Serial.print("SSID List:");
|
||||
Serial.println(numSsid, 10);
|
||||
for (int i = 0; i<numSsid; ++i)
|
||||
{
|
||||
Serial.print(i,10);
|
||||
Serial.print(") Network: ");
|
||||
Serial.println(WiFi.SSID(i));
|
||||
}
|
||||
}
|
||||
|
||||
int startWiFiWep()
|
||||
{
|
||||
Serial.println("Setup WiFi Wep...");
|
||||
strcpy(ssid, "Cariddiwep");
|
||||
Serial.print("SSID: ");
|
||||
Serial.println(ssid);
|
||||
uint8_t key_idx = 0;
|
||||
const char *key = "1234567890";
|
||||
Serial.println("Connecting...");
|
||||
status = WiFi.begin(ssid,key_idx, key);
|
||||
if ( status != WL_CONNECTED)
|
||||
{
|
||||
Serial.println("Connection Failed");
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
Serial.println("*** Start WiFi example ***");
|
||||
delay(3000);
|
||||
|
||||
WiFi.begin();
|
||||
scanNetworks();
|
||||
|
||||
startWiFiWep();
|
||||
|
||||
if ( status == WL_CONNECTED)
|
||||
{
|
||||
Serial.println("Wifi Connected!");
|
||||
|
||||
printIpData();
|
||||
|
||||
printCurrNet();
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1,206 +0,0 @@
|
||||
/*
|
||||
WiFi Server example
|
||||
|
||||
A simple connection with WiFi AP with Wireless Security
|
||||
information try to access with WPA or WEP security keys
|
||||
A simple server is setup to exchange data.
|
||||
|
||||
created 13 July 2010
|
||||
by dlf (Metodo2 srl)
|
||||
*/
|
||||
#include <WiFi.h>
|
||||
|
||||
byte mac[6] = { 0 };
|
||||
IPAddress ip;
|
||||
IPAddress gateway;
|
||||
IPAddress subnet;
|
||||
byte dataBuf[80] = { 0 };
|
||||
char ssid[32] = { 0 };
|
||||
int status = WL_IDLE_STATUS;
|
||||
#define MAX_NUM_SSID 10
|
||||
char ssidList[MAX_NUM_SSID][32] = { {0} };
|
||||
|
||||
|
||||
WiFiServer server(23);
|
||||
|
||||
void printIpData()
|
||||
{
|
||||
ip = WiFi.localIP();
|
||||
|
||||
Serial.print("IP: ");
|
||||
Serial.print(ip[3],10);Serial.print(".");
|
||||
Serial.print(ip[2],10);Serial.print(".");
|
||||
Serial.print(ip[1],10);Serial.print(".");
|
||||
Serial.println(ip[0],10);
|
||||
|
||||
subnet = WiFi.subnetMask();
|
||||
Serial.print("NETMASK: ");
|
||||
Serial.print(subnet[3],10);Serial.print(".");
|
||||
Serial.print(subnet[2],10);Serial.print(".");
|
||||
Serial.print(subnet[1],10);Serial.print(".");
|
||||
Serial.println(subnet[0],10);
|
||||
|
||||
gateway = WiFi.gatewayIP();
|
||||
Serial.print("GATEWAY: ");
|
||||
Serial.print(gateway[3],10);Serial.print(".");
|
||||
Serial.print(gateway[2],10);Serial.print(".");
|
||||
Serial.print(gateway[1],10);Serial.print(".");
|
||||
Serial.println(gateway[0],10);
|
||||
|
||||
WiFi.macAddress(mac);
|
||||
Serial.print("MAC: ");
|
||||
Serial.print(mac[5],16);Serial.print(":");
|
||||
Serial.print(mac[4],16);Serial.print(":");
|
||||
Serial.print(mac[3],16);Serial.print(":");
|
||||
Serial.print(mac[2],16);Serial.print(":");
|
||||
Serial.print(mac[1],16);Serial.print(":");
|
||||
Serial.println(mac[0],16);
|
||||
}
|
||||
|
||||
void printCurrNet()
|
||||
{
|
||||
char* ssid = WiFi.SSID();
|
||||
Serial.print("SSID: ");
|
||||
Serial.println(ssid);
|
||||
|
||||
byte bssid[6];
|
||||
WiFi.BSSID(bssid);
|
||||
Serial.print("BSSID: ");
|
||||
Serial.print(bssid[5],16);Serial.print(":");
|
||||
Serial.print(bssid[4],16);Serial.print(":");
|
||||
Serial.print(bssid[3],16);Serial.print(":");
|
||||
Serial.print(bssid[2],16);Serial.print(":");
|
||||
Serial.print(bssid[1],16);Serial.print(":");
|
||||
Serial.println(bssid[0],16);
|
||||
|
||||
int32_t rssi = WiFi.RSSI();
|
||||
Serial.print("RSSI:");
|
||||
Serial.println(rssi,10);
|
||||
|
||||
uint8_t enct = WiFi.encryptionType();
|
||||
Serial.print("Encryption Type:");
|
||||
Serial.println(enct,16);
|
||||
}
|
||||
|
||||
void scanNetworks()
|
||||
{
|
||||
byte numSsid = WiFi.scanNetworks();
|
||||
if (numSsid > MAX_NUM_SSID) numSsid = MAX_NUM_SSID;
|
||||
Serial.print("SSID List:");
|
||||
Serial.println(numSsid, 10);
|
||||
for (int i = 0; i<numSsid; ++i)
|
||||
{
|
||||
Serial.println(WiFi.SSID(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int startWiFi()
|
||||
{
|
||||
Serial.println("Setup WiFi...");
|
||||
strcpy(ssid, "Cariddiwep");
|
||||
Serial.print("SSID: ");
|
||||
Serial.println(ssid);
|
||||
int status = WiFi.begin(ssid);
|
||||
if ( status != WL_CONNECTED)
|
||||
{
|
||||
Serial.println("Connection Failed");
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
Serial.println("*** Start WiFi example ***");
|
||||
WiFi.begin();
|
||||
//scanNetworks();
|
||||
delay(3000);
|
||||
|
||||
//int _status = startWiFi();
|
||||
/*
|
||||
if ( _status == WL_CONNECTED)
|
||||
{
|
||||
Serial.println("Wifi Connected!");
|
||||
|
||||
printIpData();
|
||||
|
||||
printCurrNet();
|
||||
|
||||
scanNetworks();
|
||||
|
||||
Serial.println("Starting server...");
|
||||
server.begin();
|
||||
delay(1000);
|
||||
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
static boolean free = false;
|
||||
|
||||
// if (free) Serial.println(WiFi.test(),10);
|
||||
if (free) WiFi.test();
|
||||
|
||||
byte c = Serial.read();
|
||||
if (c!=255)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
{
|
||||
int i = 0;
|
||||
for (;i<(c-0x30);++i)
|
||||
{
|
||||
int num = WiFi.test();
|
||||
//Serial.println(num,10);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'c':
|
||||
free = true;
|
||||
break;
|
||||
case 's':
|
||||
free = false;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
/*
|
||||
Client client = server.available();
|
||||
static uint8_t count = 0;
|
||||
Serial.println("Retry connect...");
|
||||
status = WiFi.begin(ssid);
|
||||
if (status == WL_CONNECTED)
|
||||
{
|
||||
byte status = 0;
|
||||
Client client = server.available(&status);
|
||||
if (client) {
|
||||
//Serial.print("Status: ");
|
||||
//Serial.println(status, 16);
|
||||
byte idx = 0;
|
||||
while (client.available())
|
||||
{
|
||||
dataBuf[idx++] = client.read();
|
||||
}
|
||||
|
||||
if (idx>0)
|
||||
{
|
||||
dataBuf[idx]=0;
|
||||
//Serial.println((char*)&dataBuf[0]);
|
||||
server.write((char*)&dataBuf[0]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user