GSwifiInterface (interface for GainSpan Wi-Fi GS1011 modules) see https://mbed.org/users/gsfan/notebook/GSwifiInterface/
Dependencies: GSwifiInterface mbed
Fork of Wifly_HelloWorld by
main.cpp@1:49e1e9ed6e39, 2012-01-30 (annotated)
- Committer:
- samux
- Date:
- Mon Jan 30 10:54:25 2012 +0000
- Revision:
- 1:49e1e9ed6e39
- Parent:
- 0:90ba0f51aa64
- Child:
- 2:31905fe9369f
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
samux | 0:90ba0f51aa64 | 1 | #include "mbed.h" |
samux | 1:49e1e9ed6e39 | 2 | #include "Wifly.h" |
samux | 1:49e1e9ed6e39 | 3 | |
samux | 1:49e1e9ed6e39 | 4 | Serial pc(USBTX, USBRX); |
samux | 1:49e1e9ed6e39 | 5 | |
samux | 1:49e1e9ed6e39 | 6 | /* wifly object where: |
samux | 1:49e1e9ed6e39 | 7 | * - p9 and p10 are for the serial communication |
samux | 1:49e1e9ed6e39 | 8 | * - p17 is for the reset pin |
samux | 1:49e1e9ed6e39 | 9 | * - "mbed" is the ssid of the network |
samux | 1:49e1e9ed6e39 | 10 | * - "password" is the password |
samux | 1:49e1e9ed6e39 | 11 | * - true means that the security of the network is WPA |
samux | 1:49e1e9ed6e39 | 12 | */ |
samux | 1:49e1e9ed6e39 | 13 | Wifly wifly(p9, p10, p21, "mbed", "mbedapm2011", true); |
samux | 1:49e1e9ed6e39 | 14 | |
samux | 0:90ba0f51aa64 | 15 | |
samux | 1:49e1e9ed6e39 | 16 | int main() { |
samux | 1:49e1e9ed6e39 | 17 | char recv[129]; |
samux | 1:49e1e9ed6e39 | 18 | |
samux | 1:49e1e9ed6e39 | 19 | // join the network specified in the constructor |
samux | 1:49e1e9ed6e39 | 20 | while (!wifly.join()) { |
samux | 1:49e1e9ed6e39 | 21 | printf("cannot to join the network, will retry!\r\n"); |
samux | 1:49e1e9ed6e39 | 22 | wifly.reset(); |
samux | 1:49e1e9ed6e39 | 23 | } |
samux | 1:49e1e9ed6e39 | 24 | |
samux | 1:49e1e9ed6e39 | 25 | printf("network joined!\r\n"); |
samux | 1:49e1e9ed6e39 | 26 | |
samux | 1:49e1e9ed6e39 | 27 | //print all received messages |
samux | 1:49e1e9ed6e39 | 28 | while(1) |
samux | 1:49e1e9ed6e39 | 29 | { |
samux | 1:49e1e9ed6e39 | 30 | if(wifly.readable()) { |
samux | 1:49e1e9ed6e39 | 31 | wifly.read(recv); |
samux | 1:49e1e9ed6e39 | 32 | printf("read: %s\r\n", recv); |
samux | 1:49e1e9ed6e39 | 33 | } |
samux | 1:49e1e9ed6e39 | 34 | wait(0.2); |
samux | 1:49e1e9ed6e39 | 35 | } |
samux | 1:49e1e9ed6e39 | 36 | } |