User Manual
Starting/Stopping the HTTP Server
You can start the HTTP server using the .begin function (and stop it via .stop ), with the following function signatures:
port: The port number to expose the HTTP server on (generally 80 or 8080, but this can be any port you wish
and you can even have multiple instances of the HTTP server running on different ports if you wish).
max_clients: The maximum number of client connections to accept before refusing requests. This should
generally be kept as low as possible since there is limited SRAM available on the system. 3 is a good number if
there will be multiple file requests at once, for example.
stacksize: This should generally be left at the default value, but if you require a larger stack for the HTTP server
you can adjust the value here within the limit of available system resources.
Complete Example
The following code shows an example using the AdafruitHTTPServer class, but numerous examples are included as
part of the library in the HTTPServer folder, and the latter may be more up to date.
To use this example, update the WLAN_SSID and WLAD_PASS fields, flash the sketch to the User Code section of
your WICED Feather, and then open the Serial Monitor and wait for the connection to finish. Once connected, the
HTTP server will start and you can navigate to the IP address of your board to browse the pages added below.
// Configure HTTP Server Pages
Serial.println("Adding Pages to HTTP Server");
httpserver.addPages(pages, pagecount);
Serial.print("Starting HTTP Server ... ");
httpserver.begin(PORT, MAX_CLIENTS);
Serial.println(" running");
Make sure you call the .addPages function BEFORE calling the .begin function which starts the HTTP server!
bool begin(uint16_t port,
uint8_t max_clients,
uint32_t stacksize = HTTPSERVER_STACKSIZE_DEFAULT);
void stop(void);
/* This example uses the AdafruitHTTPServer class to create a simple webserver */
#include <adafruit_feather.h>
#include <adafruit_http_server.h>
#define WLAN_SSID "yourSSID"
#define WLAN_PASS "yourPassword"
#define PORT 80 // The TCP port to use
#define MAX_CLIENTS 3
int ledPin = PA15;
int visit_count = 0;
© Adafruit Industries https://learn.adafruit.com/introducing-the-adafruit-wiced-feather-wifi Page 104 of 202










