cliff

Fork of WizFi250Interface by WIZnet

Files at this revision

API Documentation at this revision

Comitter:
cliff1
Date:
Mon Aug 21 23:02:00 2017 +0000
Parent:
1:046a828fe0d2
Commit message:
cliff_testV

Changed in this revision

WizFi250/WizFi250_msg.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 046a828fe0d2 -r 13aeb8e94fed WizFi250/WizFi250_msg.cpp
--- a/WizFi250/WizFi250_msg.cpp	Fri Aug 18 05:52:17 2017 +0000
+++ b/WizFi250/WizFi250_msg.cpp	Mon Aug 21 23:02:00 2017 +0000
@@ -397,35 +397,58 @@
 }
 
 void WizFi250::resWSTATUS (const char *buf)
+//{
+//    int idx=0,sep_cnt=0;
+//    int ip_idx=0,gw_idx=0;
+//
+//    if(_state.n == 0)
+//    {
+//        _state.n++;
+//    }
+//    else if(_state.n == 1)
+//    {
+//        for(idx=0;buf[idx]!='\r';idx++)
+//        {
+//            if(buf[idx] =='/')
+//            {
+//                sep_cnt++;
+//                continue;
+//            }
+//
+//            if( sep_cnt == 2)    // IP Address
+//            {
+//                _state.ip[ip_idx++] = buf[idx];
+//            }
+//            else if(sep_cnt == 3)
+//            {
+//                _state.gateway[gw_idx++] = buf[idx];
+//            }
+//        }
+//        _state.ip[ip_idx] = '\0';
+//        _state.gateway[gw_idx] = '\0';
+//        _state.res = RES_NULL;
+//    }
+//}
 {
-    int idx=0,sep_cnt=0;
-    int ip_idx=0,gw_idx=0;
-
+    char* idx_ptr;
+ 
     if(_state.n == 0)
     {
         _state.n++;
     }
     else if(_state.n == 1)
     {
-        for(idx=0;buf[idx]!='\r';idx++)
-        {
-            if(buf[idx] =='/')
-            {
-                sep_cnt++;
-                continue;
-            }
-
-            if( sep_cnt == 2)    // IP Address
-            {
-                _state.ip[ip_idx++] = buf[idx];
-            }
-            else if(sep_cnt == 3)
-            {
-                _state.gateway[gw_idx++] = buf[idx];
-            }
-        }
-        _state.ip[ip_idx] = '\0';
-        _state.gateway[gw_idx] = '\0';
+        idx_ptr = strtok((char*)buf, "/");  // Interface STA or AP
+        idx_ptr = strtok( NULL, "/");       // SSID
+        idx_ptr = strtok( NULL, "/");       // IP Addr
+        memset(_state.ip, 0, sizeof(_state.ip));
+        memcpy(_state.ip, idx_ptr, strlen(idx_ptr)+1);
+        
+        idx_ptr = strtok( NULL, "/");       // Gateway Addr
+        memset(_state.gateway, 0, sizeof(_state.gateway));
+        memcpy(_state.gateway, idx_ptr, strlen(idx_ptr)+1);
+ 
         _state.res = RES_NULL;
     }
+ 
 }