- Auto reconnect - Added is_associated method

Fork of WiflyInterface by mbed official

Revision:
10:e19f4c58a137
Parent:
9:c77799a03294
diff -r c77799a03294 -r e19f4c58a137 Wifly/Wifly.cpp
--- a/Wifly/Wifly.cpp	Tue Jan 28 11:00:48 2014 +0200
+++ b/Wifly/Wifly.cpp	Fri Dec 16 02:50:56 2016 +0000
@@ -71,8 +71,8 @@
 
     for (int i= 0; i < MAX_TRY_JOIN; i++) {
 
-        // no auto join
-        if (!sendCommand("set w j 0\r", "AOK"))
+        // force auto join
+        if (!sendCommand("set w j 1\r", "AOK"))
             continue;
 
         //no echo
@@ -121,6 +121,10 @@
         sprintf(cmd, "set w a %d\r", state.sec);
         if (!sendCommand(cmd, "AOK"))
             continue;
+            
+        //tcp
+        sprintf(cmd, "set comm idle 0%d\r", state.sec);
+        if (!sendCommand(cmd, "AOK"))
 
         // if no dhcp, set ip, netmask and gateway
         if (!state.dhcp) {
@@ -390,6 +394,12 @@
     return wifi.putc(c);
 }
 
+bool Wifly::associated()
+{
+    bool flag=sendCommand("show c\r", "8630", NULL, 1000);
+    exit();
+    return flag;
+}
 
 bool Wifly::exit()
 {