GSwifiInterface (interface for GainSpan Wi-Fi GS1011 modules) see https://mbed.org/users/gsfan/notebook/GSwifiInterface/
Dependencies: GSwifiInterface mbed
Fork of Wifly_HelloWorld by
Diff: main.cpp
- Revision:
- 1:49e1e9ed6e39
- Parent:
- 0:90ba0f51aa64
- Child:
- 2:31905fe9369f
--- a/main.cpp Sun Nov 06 11:59:55 2011 +0000 +++ b/main.cpp Mon Jan 30 10:54:25 2012 +0000 @@ -1,13 +1,36 @@ #include "mbed.h" -#include "Wifly.h" +#include "Wifly.h" + +Serial pc(USBTX, USBRX); + +/* wifly object where: +* - p9 and p10 are for the serial communication +* - p17 is for the reset pin +* - "mbed" is the ssid of the network +* - "password" is the password +* - true means that the security of the network is WPA +*/ +Wifly wifly(p9, p10, p21, "mbed", "mbedapm2011", true); + - Wifly wifly(p9, p10, p20, "network", "password", true); - Serial pc(USBTX, USBRX); - - int main() - { - if(wifly.join()) - pc.printf("network joined!\r\n"); - else - pc.printf("join failed!\r\n"); - } \ No newline at end of file +int main() { + char recv[129]; + + // join the network specified in the constructor + while (!wifly.join()) { + printf("cannot to join the network, will retry!\r\n"); + wifly.reset(); + } + + printf("network joined!\r\n"); + + //print all received messages + while(1) + { + if(wifly.readable()) { + wifly.read(recv); + printf("read: %s\r\n", recv); + } + wait(0.2); + } +} \ No newline at end of file