Skip to content

Commit a984979

Browse files
committed
Merge branch 'master' of github.com:arduino/wifishield
2 parents d647a4b + 71ee203 commit a984979

File tree

2 files changed

+22
-19
lines changed

2 files changed

+22
-19
lines changed

WiFi/examples/ScanNetworks/ScanNetworks.ino

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
1111
created 13 July 2010
1212
by dlf (Metodo2 srl)
13-
modified 9 Mar 2012
13+
modified 12 Mar 2012
1414
by Tom Igoe
1515
*/
1616

@@ -26,7 +26,6 @@ void setup() {
2626
Serial.println("Initializing Wifi...");
2727
printMacAddress();
2828

29-
3029
// scan for existing networks:
3130
Serial.println("Scanning available networks...");
3231
listNetworks();
@@ -72,13 +71,12 @@ void listNetworks() {
7271
for (int thisNet = 0; thisNet<numSsid; thisNet++) {
7372
Serial.print(thisNet);
7473
Serial.print(") ");
75-
Serial.println(WiFi.SSID(thisNet));
76-
Serial.print("Signal Strength: ");
74+
Serial.print(WiFi.SSID(thisNet));
75+
Serial.print("\tSignal: ");
7776
Serial.print(WiFi.RSSI(thisNet));
78-
Serial.println("dBm");
79-
Serial.print("Encryption Type: ");
77+
Serial.print(" dBm");
78+
Serial.print("\tEncryption: ");
8079
Serial.println(WiFi.encryptionType(thisNet));
81-
Serial.println();
8280
}
8381
}
8482

WiFi/examples/WifiChatServer/WifiChatServer.ino

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,24 @@
1414
1515
created 18 Dec 2009
1616
by David A. Mellis
17-
modified 4 Mar 2012
17+
modified 12 Mar 2012
1818
by Tom Igoe
1919
2020
*/
2121

22-
2322
#include <SPI.h>
2423
#include <WiFi.h>
2524

2625
char ssid[] = "YourNetwork"; // your network SSID (name)
2726
char pass[] = "password"; // your network password (use for WPA, or use as key for WEP)
27+
2828
int keyIndex = 0; // your network key Index number (needed only for WEP)
2929

3030
int status = WL_IDLE_STATUS;
3131

3232
WiFiServer server(23);
3333

34-
boolean gotAMessage = false; // whether or not you got a message from the client yet
34+
boolean alreadyConnected = false; // whether or not the client was connected previously
3535

3636
void setup() {
3737
// initialize serial:
@@ -55,20 +55,25 @@ void loop() {
5555
// wait for a new client:
5656
WiFiClient client = server.available();
5757

58+
5859
// when the client sends the first byte, say hello:
5960
if (client) {
60-
if (!gotAMessage) {
61+
if (!alreadyConnected) {
62+
// clead out the input buffer:
63+
client.flush();
6164
Serial.println("We have a new client");
6265
client.println("Hello, client!");
63-
gotAMessage = true;
64-
}
66+
alreadyConnected = true;
67+
}
6568

66-
// read the bytes incoming from the client:
67-
char thisChar = client.read();
68-
// echo the bytes back to the client:
69-
server.write(thisChar);
70-
// echo the bytes to the server as well:
71-
Serial.print(thisChar);
69+
if (client.available() > 0) {
70+
// read the bytes incoming from the client:
71+
char thisChar = client.read();
72+
// echo the bytes back to the client:
73+
server.write(thisChar);
74+
// echo the bytes to the server as well:
75+
Serial.write(thisChar);
76+
}
7277
}
7378
}
7479

0 commit comments

Comments
 (0)