Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: WiflyInterface mbed
main.cpp@0:f2524261196f, 2014-04-08 (annotated)
- Committer:
- screamer
- Date:
- Tue Apr 08 18:40:52 2014 +0000
- Revision:
- 0:f2524261196f
- Child:
- 1:ced62d2a69f9
Initial revision
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| screamer | 0:f2524261196f | 1 | #include "mbed.h" |
| screamer | 0:f2524261196f | 2 | #include "WiflyInterface.h" |
| screamer | 0:f2524261196f | 3 | |
| screamer | 0:f2524261196f | 4 | /** |
| screamer | 0:f2524261196f | 5 | * D1 - TX pin (RX on the WiFi side) |
| screamer | 0:f2524261196f | 6 | * D0 - RX pin (TX on the WiFi side) |
| screamer | 0:f2524261196f | 7 | * NC - Reset pin |
| screamer | 0:f2524261196f | 8 | * LED1 - TCP status pin |
| screamer | 0:f2524261196f | 9 | * "ssid" - hostspot name |
| screamer | 0:f2524261196f | 10 | * "password" - hotspot passowrd |
| screamer | 0:f2524261196f | 11 | * security method - NONE, WEP_128, WPA, WPA2 |
| screamer | 0:f2524261196f | 12 | */ |
| screamer | 0:f2524261196f | 13 | WiflyInterface wifi(D1, D0, NC, LED1, "hotspot", "", NONE); |
| screamer | 0:f2524261196f | 14 | Serial pc(USBTX, USBRX); |
| screamer | 0:f2524261196f | 15 | |
| screamer | 0:f2524261196f | 16 | int main() |
| screamer | 0:f2524261196f | 17 | { |
| screamer | 0:f2524261196f | 18 | int s = wifi.init(); // Use DHCP |
| screamer | 0:f2524261196f | 19 | if( s != NULL ) { |
| screamer | 0:f2524261196f | 20 | printf("Could not initialise. Halting!\n"); |
| screamer | 0:f2524261196f | 21 | exit(0); |
| screamer | 0:f2524261196f | 22 | } |
| screamer | 0:f2524261196f | 23 | |
| screamer | 0:f2524261196f | 24 | while (1) { |
| screamer | 0:f2524261196f | 25 | s = wifi.connect(); // Set up the chip and join the network |
| screamer | 0:f2524261196f | 26 | |
| screamer | 0:f2524261196f | 27 | if( s == false ) { |
| screamer | 0:f2524261196f | 28 | printf("Could not connect. Retrying!\n"); |
| screamer | 0:f2524261196f | 29 | wait(3); |
| screamer | 0:f2524261196f | 30 | continue; |
| screamer | 0:f2524261196f | 31 | } else { |
| screamer | 0:f2524261196f | 32 | // Print the IP address every second |
| screamer | 0:f2524261196f | 33 | while(1) { |
| screamer | 0:f2524261196f | 34 | printf("Got IP: %s\n", wifi.getIPAddress()); |
| screamer | 0:f2524261196f | 35 | wait(1); |
| screamer | 0:f2524261196f | 36 | } |
| screamer | 0:f2524261196f | 37 | } |
| screamer | 0:f2524261196f | 38 | } |
| screamer | 0:f2524261196f | 39 | } |
Seeed Wifi Shield