WebServer sketch
From AsyncLabs Documentation
The WebServer sketch included in the WiShield library implements a webserver which can serve up simple webpages. The library includes a port of the uIP TCP/IP stack to the Arduino. The WebServer sketch exposes all the parameters (wireless and stack related) that need to be configured to use the WiShield.
IMPORTANT NOTE:
The WiShield library includes support for both server and client applications. The individual apps are included as sample sketches but to switch between the two will require rebuilding the WiShield library as it requires reconfiguration of some variables. The library is configured as a webserver by default. To switch between modes:
- Uncomment the appropriate mode, APP_WEBSERVER or APP_WEBCLIENT in the apps-conf.h file in the WiShield directory.
- Delete all the object files (files with an extension of '.o') in the WiShield directory.
- Delete the 'applet' directory in the WiShield/examples/WebServer/ or WiShield/examples/WebClient/ directories.
- Restart the Arduino IDE to rebuild the library in the appropriate mode.
Configuration parameters:
- local_ip : This is the static IP address that is assigned to the WiShield. The stack does not include support for DHCP and therefore a static IP address is used in the sketch. Assign a valid IP address to this parameter considering the configuration of your network.
- gateway_ip : This is the IP address of the router or gateway device attached to your network. This IP address will be used by the WiShield if it has to talk to another device which is on a different network or on the Internet.
- subnet_mask : This is the subnet mask of the network.
- SSID : This is the SSID of the wireless network
- security_type : This parameter specifies the type of security used on the wireless network. Assign a value to match the configuration of your network.
- security_passphrase : This parameter is used if WPA/WPA2 security is used on the wireless network. This parameter has to match the passphrase used for your wireless network
- wep_keys : This parameter specifies the WEP keys that are used if WEP security is enabled on the wireless network. The example included is for a WEP 128-bit configuration. The length of the table corresponds to the length required to store 4 WEP keys. If your network uses more than one key or if it uses WEP 64-bit keys then modify the table accordingly. The length of the table should not change.
- wireless_mode : This parameter can be WIRELESS_MODE_INFRA or WIRELESS_MODE_ADHOC. It specifies the mode used by WiShield to setup the network. If WIRELESS_MODE_INFRA is selected, the WiShield connects to an AP and if WIRELESS_MODE_ADHOC is selected, the WiShield connects to an adhoc network if one exists or else will start a new adhoc network with the specified SSID.
- webpage : This variable holds the actual webpage that is served up by the webserver.