HTTPS(SSL) client and NTP client for GSwifi see: http://mbed.org/users/gsfan/notebook/gainspan_wifi/

Dependencies:   GSwifi mbed

Files at this revision

API Documentation at this revision

Comitter:
gsfan
Date:
Tue Feb 26 06:23:33 2013 +0000
Parent:
1:b06de786490e
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 b06de786490e -r 608c25ba84ca GSwifi.lib
--- a/GSwifi.lib	Wed Aug 22 00:52:43 2012 +0000
+++ b/GSwifi.lib	Tue Feb 26 06:23:33 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/gsfan/code/GSwifi/#3b819ba34c6c
+http://mbed.org/users/gsfan/code/GSwifi/#0abdc584823d
diff -r b06de786490e -r 608c25ba84ca main.cpp
--- a/main.cpp	Wed Aug 22 00:52:43 2012 +0000
+++ b/main.cpp	Tue Feb 26 06:23:33 2013 +0000
@@ -1,18 +1,34 @@
+/*
+ * HTTPS(SSL) client and NTP client
+ *
+ * Please update the firmware.
+ */
+
 #include "mbed.h"
 #include "GSwifi.h"
 
-#define SECURE GSSEC_WPA_PSK
-#define SSID "SSID"
-#define PASS "passkey"
+#define HTTP_HOST "secure.sakura.ad.jp"
+#define HTTP_PORT 443
+#define HTTP_URI "/"
+#define NTP_HOST "ntp.jst.mfeed.ad.jp"
 
-#define HTTP_HOST "secure.domain.name"
-#define HTTP_URI "/index.html"
+#define SECURE GSwifi::GSSEC_WPA_PSK
+#define SSID "SSID"
+#define PASS "PASSPHRASE"
 
-GSwifi gs(p13, p14); // TX, RX (no flow control)
-// GSwifi gs(p13, p14, p12, P0_22); // TX, RX, CTS, RTS
+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);
 
+extern "C"
+void HardFault_Handler() {
+    printf("Hard Fault!\r\n");
+    gs.disconnect();
+    exit(-1);
+}
+
 void onGsReceive (int cid, int len) {
     int i;
     char buf[GS_DATA_SIZE + 1];
@@ -33,22 +49,23 @@
     led1 = 1;
     pc.baud(115200);
     
-    pc.printf("connect\r\n");
+    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("ntpdate\r\n");
-    host.setName("ntp.jst.mfeed.ad.jp");
+    host.setName(NTP_HOST);
     gs.ntpdate(host);
     time = gs.getTime() + (9 * 60 * 60);
     t = localtime(&time);
     pc.printf("%04d-%02d-%02d, %02d:%02d:%02d\r\n", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
 
-    pc.printf("httpGet\r\n");
+    pc.printf("httpsGet\r\n");
     host.setName(HTTP_HOST);
+    host.setPort(HTTP_PORT);
     r = gs.httpGet(host, HTTP_URI, 1, &onGsReceive);
     if (r >= 0) {
         for (;;) {