XBeeWiFi (S6) with SPI connection.

Dependencies:   XBeeWiFi_common XBee_with_SPI mbed

Fork of XBee_wifi_sample by Suga koubou

Revision:
3:67a2c13289ad
Parent:
1:27bf8d24244b
--- a/main.cpp	Wed Dec 18 02:25:14 2013 +0000
+++ b/main.cpp	Sat Jan 04 16:58:46 2014 +0000
@@ -21,8 +21,11 @@
 DigitalOut myled(LED1);
 Serial pc(USBTX, USBRX);
 
-XBeeWiFi xbee(p13, p14, p12, P0_22); // TX, RX, CTS, RTS
-//XBeeWiFi xbee(p13, p14, p12, p11); // TX, RX, CTS, RTS
+#if defined(TARGET_LPC1768) || defined(TARGET_LPC11U24)
+XBeeWiFi xbee(p11, p12, p13, p14, p15, p16);    // mosi, miso, sclk, ssel, attn, reset
+#elif defined(TARGET_LPC1114)
+XBeeWiFi xbee(dp2, dp1, dp6, dp9, dp10, dp11);  // mosi, miso, sclk, ssel, attn, reset
+#endif
 
 int init_wifi (int timeout) {
     int i, r;
@@ -154,13 +157,13 @@
 }
 
 int main() {
-    int i;
+//    int i;
     IpAddr ipaddr, netmask, gateway, nameserver;
     Host host;
 
-    xbee.begin(115200);
+//    xbee.begin(115200);
 //    xbee.baud(921000);
-    pc.baud(115200);
+    pc.baud(9600);
     pc.printf("XBee WiFi test\r\n");
 
     if (init_wifi(20)) {
@@ -170,7 +173,7 @@
 
     xbee.getAddress(ipaddr, netmask, gateway, nameserver);
     pc.printf("IP address %d.%d.%d.%d\r\n", ipaddr[0], ipaddr[1], ipaddr[2], ipaddr[3]);
-    if (ipaddr == 0) {
+    if (ipaddr.isNull()) {
         pc.printf("not configure\r\n");
         return -1;
     }
@@ -194,23 +197,11 @@
 */
     // HTTP request
     wait(1);
-    host.setIp(IpAddr(217,140,96,42));
-    host.setName("mbed.org");
-    httpRequest(METHOD_GET, &host, "/", "", "");
+    host.setIp(IpAddr(54,243,166,106));
+    host.setName("httpbin.org");
+    httpRequest(METHOD_GET, &host, "/get", "", "");
 
-    // Serial through
-    {
-        Serial xbeeserial(p13, p14);
-        DigitalOut rts(p22);
-        
-        xbeeserial.baud(115200);
-        rts = 0;
-        pc.printf("Serial through\r\n");
-        for (;;) {
-            if (pc.readable()) xbeeserial.putc(pc.getc());
-            if (xbeeserial.readable()) pc.putc(xbeeserial.getc());
-//            if (xbeeserial.readable()) pc.printf("%02x ", xbeeserial.getc());
-        }
-    }
+    pc.printf("done.\r\n");
+    while(1);
 
 }