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.
Fork of GSwifi_tcpserver by
Revision 4:e6192ed22442, committed 2013-02-26
- Comitter:
- gsfan
- Date:
- Tue Feb 26 03:36:49 2013 +0000
- Parent:
- 3:7ec5f2741abf
- Commit message:
- fix
Changed in this revision
GSwifi.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 7ec5f2741abf -r e6192ed22442 GSwifi.lib --- a/GSwifi.lib Sat Oct 27 00:43:28 2012 +0000 +++ b/GSwifi.lib Tue Feb 26 03:36:49 2013 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/gsfan/code/GSwifi/#aea56cce3bf5 +http://mbed.org/users/gsfan/code/GSwifi/#f3e9053d9b46
diff -r 7ec5f2741abf -r e6192ed22442 main.cpp --- a/main.cpp Sat Oct 27 00:43:28 2012 +0000 +++ b/main.cpp Tue Feb 26 03:36:49 2013 +0000 @@ -1,59 +1,60 @@ -#include "mbed.h" -#include "GSwifi.h" - -#define HOST "test.example.com" -#define PORT 10080 - -#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 -Serial pc(USBTX, USBRX); -DigitalOut led1(LED1), led2(LED2); - -void onGsReceive (int cid, int len) { - int i; - char buf[100]; - Host host; - - led2 = 1; - - i = gs.recv(cid, buf, sizeof(buf)); - pc.printf("recv %d\r\n", i); -} - -int main () { - IpAddr ipaddr, netmask, gateway, nameserver; - Host host; - int cid; - - 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]); - - pc.printf("connection\r\n"); - host.setName(HOST); - host.setPort(PORT); - cid = gs.open(host, GSPROT_TCP, &onGsReceive); // TCP client -// cid = gs.open(host, GSPROT_TCP, &onGsReceive); // UDP client - if (cid < 0) { - return -1; - } - - for (;;) { - gs.poll(); - - gs.send(cid, "Hello", 5); - wait_ms(500); - led1 = !led1; - led2 = 0; - } -} +#include "mbed.h" +#include "GSwifi.h" + +#define HOST "test.example.com" +#define PORT 10080 + +#define SECURE GSwifi::GSSEC_WPA_PSK +#define SSID "SSID" +#define PASS "PASSPHRASE" + +GSwifi gs(p13, p14, p20); // TX, RX, Reset (no flow control) +//GSwifi gs(p13, p14, p12, P0_22, p20, NC, 115200); // TX, RX, CTS, RTS, Reset, Alarm + +Serial pc(USBTX, USBRX); +DigitalOut led1(LED1), led2(LED2); + +void onGsReceive (int cid, int len) { + int i; + char buf[100]; + Host host; + + led2 = 1; + + i = gs.recv(cid, buf, sizeof(buf)); + pc.printf("recv %d\r\n", i); +} + +int main () { + IpAddr ipaddr, netmask, gateway, nameserver; + Host host; + int cid; + + led1 = 1; + pc.baud(115200); + + pc.printf("connecting...\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]); + + pc.printf("connection\r\n"); + host.setName(HOST); + host.setPort(PORT); + cid = gs.open(host, GSwifi::GSPROT_TCP, &onGsReceive); // TCP client +// cid = gs.open(host, GSwifi::GSPROT_UDP, &onGsReceive); // UDP client + if (cid < 0) { + return -1; + } + + for (;;) { + gs.poll(); + + gs.send(cid, "Hello", 5); + wait_ms(500); + led1 = !led1; + led2 = 0; + } +}