Limited AP for GSwifi see: http://mbed.org/users/gsfan/notebook/gainspan_wifi/

Dependencies:   GSwifi mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "GSwifi.h"
00003 
00004 #define PORT 10464
00005 
00006 #define SECURE GSwifi::GSSEC_WEP
00007 #define SSID "SSID"
00008 #define PASS "1234567890" // 10 or 26 hexadecimal digits
00009 
00010 GSwifi gs(p13, p14, p20); // TX, RX, Reset (no flow control)
00011 //GSwifi gs(p13, p14, p12, P0_22, p20, NC, 115200); // TX, RX, CTS, RTS, Reset, Alarm
00012 
00013 Serial pc(USBTX, USBRX);
00014 DigitalOut led1(LED1), led2(LED2);
00015 
00016 void onGsReceive (int cid, int len) {
00017     int i, j;
00018     char buf[100];
00019     Host host;
00020 
00021     led2 = 1;
00022 
00023     i = gs.recv(cid, buf, sizeof(buf), host);
00024     for (j = 0; j < i; j ++) {
00025         pc.printf(" %02x", buf[j]);
00026     }   
00027     pc.printf("\r\n");
00028 }
00029 
00030 int main () {
00031 
00032     led1 = 1;
00033     pc.baud(115200);
00034 
00035     pc.printf("limitedap\r\n");
00036     if (gs.limitedap(SECURE, SSID, PASS, IpAddr(192,168,15,5), IpAddr(255,255,255,0))) {
00037         return -1;
00038     }
00039 
00040     pc.printf("listen\r\n");
00041     gs.listen(PORT, GSwifi::GSPROT_UDP, &onGsReceive);
00042 
00043     for (;;) {
00044         gs.poll();
00045 
00046         wait_ms(50);
00047         led1 = !led1;
00048         led2 = 0;
00049     }
00050 }