Freedman v2

Dependents:   Freedman_v2

Fork of WizFi250Interface by DongEun Koak

Revision:
9:12ecb377f63f
Parent:
7:ba28fe711055
Child:
11:e52b91d1a5d5
--- a/WizFi250/WizFi250_at.cpp	Fri Nov 14 16:53:10 2014 +0900
+++ b/WizFi250/WizFi250_at.cpp	Fri Jun 19 15:34:40 2015 +0900
@@ -128,7 +128,6 @@
 {
     int resp;
     char cmd[CFG_CMD_SIZE];
-    const char xmac[] = "00:08:DC:00:00:00";
 
     if (mac)
     {
@@ -178,12 +177,31 @@
 
 int WizFi250::cmdWJOIN()
 {
+	//if( sendCommand("AT+WJOIN", RES_WJOIN, CFG_JOIN_TIMEOUT) )
+    if( sendCommand("AT+WJOIN", RES_NULL, CFG_JOIN_TIMEOUT) )
+	{
+	    WIZ_ERR("cmdWJOIN");
+	    return -1;
+	}
 
-	if( sendCommand("AT+WJOIN", RES_WJOIN, CFG_JOIN_TIMEOUT) ) return -1;
+	if( cmdWSTATUS() )
+	    return -1;
+
+	WIZ_INFO("WizFi250 is successfully join to AP");
 
-	WIZ_INFO("IP : %s",_state.ip);
-	WIZ_INFO("Gateway : %s",_state.gateway);
-	WIZ_INFO("WizFi250 is successfully join to AP");
+    return 0;
+}
+
+int WizFi250::cmdWSTATUS()
+{
+    if( sendCommand("AT+WSTATUS", RES_WSTATUS, DEFAULT_WAIT_RESP_TIMEOUT) )
+    {
+        WIZ_ERR("cmdWSTATUS");
+        return -1;
+    }
+
+    WIZ_INFO("IP      : %s", _state.ip);
+    WIZ_INFO("Gateway : %s", _state.gateway);
 
     return 0;
 }
@@ -201,13 +219,12 @@
     int resp;
     char cmd[CFG_CMD_SIZE];
 
-    if(localPort == NULL)
+    if(localPort == 0)
         sprintf(cmd,"AT+SCON=%s,%s,%s,%d,%s,%s",openType, socketType, remoteIp, remotePort, "", dataMode);
     else
         sprintf(cmd,"AT+SCON=%s,%s,%s,%d,%d,%s",openType, socketType, remoteIp, remotePort, localPort, dataMode);
 
-    resp = sendCommand(cmd, RES_CONNECT, 5000 );
-    WIZ_DBG("Create CID : %s",_state.dummyBuf);
+    resp = sendCommand(cmd, RES_CONNECT, 15000 );
 
     return resp;
 }
@@ -218,13 +235,12 @@
     Timer t;
     char cmd[CFG_CMD_SIZE];
 
-
     if (lockUart(Timeout))    return -1;
 
     clearFlags();
-    if(remotePort == NULL)
+    if(remoteIp == NULL)
     {
-        sprintf(cmd,"AT+SSEND=%d,%s,,%d",cid, remoteIp, sendSize);
+    	sprintf(cmd,"AT+SSEND=%d,,,%d",cid, sendSize);
     }
     else
     {
@@ -234,6 +250,7 @@
     _con[cid].send_length = sendSize;
 
     resp = sendCommand(cmd, RES_SSEND, 2000, 1);
+
     unlockUart();
     if(resp){
     	WIZ_DBG("Fail cmdSSEND")
@@ -261,7 +278,7 @@
         t.stop();
     }
 
-    //WIZ_INFO("data: '%s' size : %d\r\n",data, sendSize);
+    WIZ_INFO("data: '%s' size : %d\r\n",data, sendSize);
 
     return i;
 }