Created
June 13, 2020 01:53
-
-
Save vintagechips/98dc2f1493bf529316519a7cd84a8623 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <WiFi.h> | |
const char* ssid = "Buffalo-G-0E94"; | |
const char* password = "password"; | |
const int port = 23; | |
WiFiServer server(port); | |
void setup() { | |
Serial.begin(9600); | |
Serial.println(); | |
Serial.print("Connecting to "); | |
Serial.println(ssid); | |
WiFi.begin(ssid, password); | |
while (WiFi.status() != WL_CONNECTED) { | |
delay(100); | |
Serial.print("."); | |
} | |
Serial.println(); | |
Serial.println("WiFi connected."); | |
Serial.print("IP address: "); | |
Serial.println(WiFi.localIP()); | |
Serial.print("Server port: "); | |
Serial.println(port); | |
server.begin(); | |
server.setNoDelay(true); | |
} | |
void loop() { | |
char c; | |
WiFiClient client = server.available(); | |
if (client) { | |
Serial.println("New Client."); | |
while (client.connected()) { | |
if (client.available()) { | |
c = client.read(); | |
//client.write(c); | |
Serial.write(c); | |
} | |
if (Serial.available()) { | |
c = Serial.read(); | |
client.write(c); | |
} | |
} | |
client.stop(); | |
Serial.println("Client Disconnected."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment