XBee-mbed library Forked from http://mbed.org/users/okini3939/notebook/xbee-mbed/

Fork of XBee by Suga koubou

Revision:
3:8573b122fa84
Parent:
2:6efb3541af61
Child:
4:f6d73acc1f75
--- a/XBeeWiFi.h	Fri Jul 29 16:22:15 2011 +0000
+++ b/XBeeWiFi.h	Thu Mar 08 17:41:29 2012 +0000
@@ -5,7 +5,7 @@
  */
 
 /** @file
- * @brief Weather Station
+ * @brief XBee Wi-Fi library for mbed
  */
 
 #ifndef XBeeWiFi_h
@@ -16,8 +16,8 @@
 #include "XBee.h"
 #include <inttypes.h>
 
-#undef USE_WIFICLASS
-#undef USE_WIFIDNS
+#define USE_WIFICLASS
+#define USE_WIFIDNS
 
 // the non-variable length of the frame data (not including frame id or api id or variable data size (e.g. payload, at command set value)
 #define IPv4_TRANSMIT_REQUEST_API_LENGTH 10
@@ -53,8 +53,13 @@
 
 /// modem status
 #define JOINED_AP 0
+#define INITIALIZATION 0x01
+#define SSID_NOT_FOUND 0x22
 #define SSID_NOT_CONFIGURED 0x23
-#define JOINING_AP 0xff
+#define JOIN_FAILED 0x27
+#define WAITING_IPADDRESS 0x41
+#define WAITING_SOCKETS 0x42
+#define SCANNING_SSID 0xff
 
 /// dns
 #define DNS_QUERY_A 1
@@ -66,6 +71,10 @@
 #define DNS_QUERY_ANY 255
 #define DNS_CLASS_IN 1
 
+#define DNS_PORT 53
+#define DNS_SRC_PORT 1234
+#define DNS_TIMEOUT 5 // x 3s
+
 struct DNSHeader {
         uint16_t id; 
         uint16_t flags; 
@@ -95,21 +104,24 @@
  */
 class XBeeWiFi : public XBee {
 public:
-    XBeeWiFi (PinName p_tx, PinName p_rx);
+    XBeeWiFi (PinName p_tx, PinName p_rx, PinName p_cts);
 
     int setup (int security, const char *ssid, const char *pin);
     int setup (const char *ssid);
     int reset ();
     int setAddress ();
     int setAddress (IpAddr &ipaddr, IpAddr &netmask, IpAddr &gateway, IpAddr &nameserver);
+    int getAddress (IpAddr &ipaddr, IpAddr &netmask, IpAddr &gateway, IpAddr &nameserver);
     int setTimeout (int timeout);
     int getStatus ();
+    int getWiResponse (int apiId, int frameid = 0, int timeout = 1500);
 #ifdef USE_WIFIDNS
+    int setNameserver (IpAddr &nameserver);
     int getHostByName (const char* name, IpAddr &addr);
 #endif
 
 protected:
-    int getWiResponse (int apiId, int timeout = 1500);
+    int getWiAddr (IpAddr &ipaddr);
 #ifdef USE_WIFIDNS
     int createDnsRequest (const char* name, char *buf);
     int getDnsResponse (const uint8_t *buf, int len, IpAddr &addr);