Show minor edits - Show changes to markup
Create a server that listens for incoming connections on the specified port.
Server(port);
port: the port to listen on (int)
None
#include <WiFi.h>
#include <IPAddress.h>
byte mac[6] = { 0 };
IPAddress ip;
IPAddress gateway;
IPAddress subnet;
byte dataBuf[80] = { 0 };
char ssid[32] = { 0 };
int status = WL_IDLE_STATUS;
Server server(23);
void setup()
{
Serial.begin(9600);
Serial.println("Setup WiFi...");
strcpy(ssid, "Vodafone-10289870");
Serial.println(ssid);
int status = WiFi.begin(ssid);
Serial.println("Wifi Connected!");
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;
Client client = server.available(&status);
if (client) {
byte idx = 0;
while (client.available())
{
dataBuf[idx++] = client.read();
}
if (idx>0)
{
dataBuf[idx]=0;
server.write((char*)&dataBuf[0]);
}
return;
}
}
}
Server is the base class for all WiFi server based calls. It is not called directly, but invoked whenever you use a function that relies on it.
WiFi : Server class
Create a server that listens for incoming connections on the specified port.
Server(port);
port: the port to listen on (int)
None
#include <WiFi.h>
#include <IPAddress.h>
byte mac[6] = { 0 };
IPAddress ip;
IPAddress gateway;
IPAddress subnet;
byte dataBuf[80] = { 0 };
char ssid[32] = { 0 };
int status = WL_IDLE_STATUS;
Server server(23);
void setup()
{
Serial.begin(9600);
Serial.println("Setup WiFi...");
strcpy(ssid, "Vodafone-10289870");
Serial.println(ssid);
int status = WiFi.begin(ssid);
Serial.println("Wifi Connected!");
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;
Client client = server.available(&status);
if (client) {
byte idx = 0;
while (client.available())
{
dataBuf[idx++] = client.read();
}
if (idx>0)
{
dataBuf[idx]=0;
server.write((char*)&dataBuf[0]);
}
return;
}
}
}