gs fan
/
GSwifi_httpd
HTTP server for GSwifi see: http://mbed.org/users/gsfan/notebook/gainspan_wifi/
Diff: main.cpp
- Revision:
- 0:540fed81e29b
- Child:
- 1:d0ec28e041d6
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Nov 01 03:06:04 2012 +0000 @@ -0,0 +1,46 @@ +#include "mbed.h" +#include "GSwifi.h" + +#define PORT 80 + +#define SECURE GSSEC_WPA_PSK +#define SSID "SSID" +#define PASS "passkey" + +GSwifi gs(p13, p14); // TX, RX (no flow control) +// GSwifi gs(p13, p14, p12, P0_22); // TX, RX, CTS, RTS + +LocalFileSystem local("local"); + +Serial pc(USBTX, USBRX); +DigitalOut led1(LED1), led2(LED2); + +int main () { + IpAddr ipaddr, netmask, gateway, nameserver; + Host host; + + led1 = 1; + pc.baud(115200); + + pc.printf("connect\r\n"); + if (gs.connect(SECURE, SSID, PASS)) { + return -1; + } + gs.getAddress(ipaddr, netmask, gateway, nameserver); + pc.printf("ip %d.%d.%d.%d\r\n", ipaddr[0], ipaddr[1], ipaddr[2], ipaddr[3]); + + led2 = 1; + pc.printf("httpd\r\n"); + gs.httpd(PORT); + gs.attach_httpd("/test/", "/local/sample/"); + gs.attach_httpd("/example/", "/local/"); + gs.attach_httpd("/", "/local/"); + + for (;;) { + gs.poll(); + + wait_ms(50); + led1 = !led1; + led2 = 0; + } +}