Reference.WiFiServerConstructor History

Show minor edits - Show changes to markup

May 18, 2012, at 06:32 PM by Scott Fitzgerald -
Deleted line 8:

Functions

November 22, 2011, at 10:56 PM by Scott Fitzgerald -
Changed lines 3-4 from:

Server()

to:

Server

Changed lines 7-78 from:

Create a server that listens for incoming connections on the specified port.

Syntax

Server(port);

Parameters

port: the port to listen on (int)

Returns

None

Example

#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;
      }
  }
}

to:

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.

Functions

November 22, 2011, at 03:54 AM by Scott Fitzgerald -
Added lines 1-78:

WiFi : Server class

Server()

Description

Create a server that listens for incoming connections on the specified port.

Syntax

Server(port);

Parameters

port: the port to listen on (int)

Returns

None

Example

#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;
      }
  }
}

Share