Dependencies:   BLE_API WIFI_API_32kRAM mbed nRF51822

Fork of NNN40_CLI by Delta

Revision:
5:ee474e3133eb
Parent:
4:b52035367aee
Child:
9:ff3ccba5dc16
--- a/CLI_Source/wifi_cli.cpp	Sat Nov 07 09:02:38 2015 +0000
+++ b/CLI_Source/wifi_cli.cpp	Wed Dec 09 11:31:59 2015 +0000
@@ -20,7 +20,7 @@
 #define STATIC_IP_MAX_LEN 15
 #define TCP_SEND_MAX_LEN 128
 #define UDP_SEND_MAX_LEN 128
-#define DELTA_WIFI_DEBUG 
+//#define DELTA_WIFI_DEBUG
 #define WIFI_MAX_AP_NUMBER 15
 // WiFI_API_32kRAM ver. 8
 #define MAX_MEM_WRITE_LENGTH 0x3FFFF
@@ -93,26 +93,40 @@
 /////////**** WIFI Device Implement ****//////////
 static void cyn_wifi_device_sleep()
 {
-    cyntecPrintOk();
-    wifiDevice.sleep();
+    if (cyntecGetCommandTokenCnt() != 2) {
+        cyntecPrintError(CYNTEC_CMD_ERR_WRONG_NUMBER_OF_ARGUMENTS);
+        return;
+    }
+    uint8_t err_code = wifiDevice.sleep();
+    if (err_code == 0)
+        cyntecPrintOk();
+    else {
+        console.printf("ERROR;%d\r\n",err_code);
+        return;
+    }
 }
 
 static void cyn_wifi_device_coex()
 {
-	if (cyntecGetCommandTokenCnt() != 2) {
-		cyntecPrintError(CYNTEC_CMD_ERR_WRONG_NUMBER_OF_ARGUMENTS);
-		return;
-	}
-	uint8_t err_code = wifiDevice.enableCoexistance();
-	if (err_code == 0)
-		cyntecPrintOk();
-	else
-		return;
-	
+    if (cyntecGetCommandTokenCnt() != 2) {
+        cyntecPrintError(CYNTEC_CMD_ERR_WRONG_NUMBER_OF_ARGUMENTS);
+        return;
+    }
+    uint8_t err_code = wifiDevice.enableCoexistance();
+    if (err_code == 0)
+        cyntecPrintOk();
+    else {
+        console.printf("ERROR;%d\r\n",err_code);
+        return;
+    }
 }
 
 static void cyn_wifi_device_network()
 {
+    if (wifi_init== true) {
+        cyntecPrintError(CYNTEC_CMD_ERR_WRONG_CMD_ORDER);
+        return;
+    }
     if (cyntecGetCommandTokenCnt() == 5) {
         uint8_t argLen = 0;
         uint8_t *argSSID;
@@ -166,12 +180,12 @@
 
 // gill 20150910
 // Comply to WIFI_API_32kRAM version 8
-static void cyn_wifi_read_wifi_sp_version()
+static void cyn_wifi_read_sp_version()
 {
     wifiSpInfo version = wifiDevice.read_WIFI_SP_version();
     cyntecPrintOk();
-    console.printf("%X,", version.chipID);
-    console.printf("%i,", version.imgStaID);
+    console.printf("%X;", version.chipID);
+    console.printf("%i;", version.imgStaID);
     console.printf("%i\r\n", version.imgApID);
 }
 
@@ -197,109 +211,110 @@
 static void cyn_wifi_device_ap_scan()
 {
     if (wifi_init== false) {
-    	cyntecPrintError(CYNTEC_CMD_ERR_WRONG_CMD_ORDER);
-    	return;
+        cyntecPrintError(CYNTEC_CMD_ERR_WRONG_CMD_ORDER);
+        return;
     }
     memset(saveAP,0,sizeof(saveAP));
     cyntecPrintOk();
     apInd = 1;
-    wifiDevice.apScan(scanCallback);
+    int scanResult = wifiDevice.apScan(scanCallback);
+    if (scanResult<0)
+        cyntecPrintError(CYNTEC_CMD_ERR_CALL_FAIL);
     return;
 }
 
 static void cyn_wifi_set_ap()
 {
     if (cyntecGetCommandTokenCnt() != 6) {
-		cyntecPrintError(CYNTEC_CMD_ERR_WRONG_NUMBER_OF_ARGUMENTS);
-	}
-        uint8_t argLen = 0;
-        uint8_t * argSSID;
-        uint8_t * argPW;
-        uint8_t * argSEC;
-        uint8_t * argCH;
+        cyntecPrintError(CYNTEC_CMD_ERR_WRONG_NUMBER_OF_ARGUMENTS);
+    }
+    uint8_t argLen = 0;
+    uint8_t * argSSID;
+    uint8_t * argPW;
+    uint8_t * argSEC;
+    uint8_t * argCH;
+
+    /* handle SSID */
+    argSSID = cyntecGetCommandArgument(0, &argLen);
+    if ( argLen > AP_SSID_MAX_LEN ) {
+        cyntecPrintError(CYNTEC_CMD_ERR_ARGUMENT_OUT_OF_RANGE);
+        return;
+    }
+    memset( devNetwork[3].ap_ssid , 0, AP_SSID_MAX_LEN+1);
+    memcpy( devNetwork[3].ap_ssid, argSSID, argLen);
 
-        /* handle SSID */
-        argSSID = cyntecGetCommandArgument(0, &argLen);
-        if ( argLen > AP_SSID_MAX_LEN ) {
-            cyntecPrintError(CYNTEC_CMD_ERR_ARGUMENT_OUT_OF_RANGE);
-            return;
-        }
-        memset( devNetwork[3].ap_ssid , 0, AP_SSID_MAX_LEN+1);
-        memcpy( devNetwork[3].ap_ssid, argSSID, argLen);
-		
-        /* handle Password */
-        argPW = cyntecGetCommandArgument(1, &argLen);
-        if ( argLen > AP_PW_MAX_LEN ) {
-            cyntecPrintError(CYNTEC_CMD_ERR_ARGUMENT_OUT_OF_RANGE);
-            return;
-        }
-        memset( devNetwork[3].ap_pw, 0, AP_PW_MAX_LEN+1);
-        memcpy( devNetwork[3].ap_pw, argPW, argLen);
+    /* handle Password */
+    argPW = cyntecGetCommandArgument(1, &argLen);
+    if ( argLen > AP_PW_MAX_LEN ) {
+        cyntecPrintError(CYNTEC_CMD_ERR_ARGUMENT_OUT_OF_RANGE);
+        return;
+    }
+    memset( devNetwork[3].ap_pw, 0, AP_PW_MAX_LEN+1);
+    memcpy( devNetwork[3].ap_pw, argPW, argLen);
+
+    /* handle Security */
+    security_t setSec  = SECURITY_WPA2_AES_PSK;
+    argSEC = cyntecGetCommandArgument(2, &argLen);
+    char numSec[argLen];
+    memcpy( numSec, argSEC, argLen);
+    uint8_t sec = atoi(numSec);
+    //uint8_t numSec = atoi((const char *)arg);
 
-        /* handle Security */
-        security_t setSec  = SECURITY_WPA2_AES_PSK;
-        argSEC = cyntecGetCommandArgument(2, &argLen);
-        char numSec[argLen];
-        memcpy( numSec, argSEC, argLen);
-        uint8_t sec = atoi(numSec);
-        //uint8_t numSec = atoi((const char *)arg);
-        
-        if ( (int)sec > 7 || (int)sec < 0) {
-            cyntecPrintError(CYNTEC_CMD_ERR_ARGUMENT_OUT_OF_RANGE);
-            return;
-        }
-        security_t arrySec[8]={SECURITY_OPEN,
-        SECURITY_WEP_PSK,
-        SECURITY_WEP_SHARED,
-        SECURITY_WPA_TKIP_PSK,
-        SECURITY_WPA_AES_PSK,
-        SECURITY_WPA2_AES_PSK,
-        SECURITY_WPA2_TKIP_PSK,
-        SECURITY_WPA2_MIXED_PSK
-        };
-        for (uint8_t i=0;i<8;i++)
-        {
-        	if(sec==i)
-        		setSec = arrySec[i];
-        }
-        
-        /* handle Channel */
-        argCH = cyntecGetCommandArgument(3, &argLen);
-        uint8_t setChan = atoi((char *)argCH);
-    	
-        if ( (int)setChan > 14 || (int)setChan < 1) {
-           	cyntecPrintError(CYNTEC_CMD_ERR_ARGUMENT_OUT_OF_RANGE);
-            return;
-        }
-		#ifdef DELTA_WIFI_DEBUG
-        console.printf("argSSID:%s\r\n",argSSID);
-        console.printf("argPW:%s\r\n",argPW);
-        console.printf("sec:%i\r\n",sec);
-        console.printf("setChan:%i\r\n",setChan);
-        #endif
+    if ( (int)sec > 7 || (int)sec < 0) {
+        cyntecPrintError(CYNTEC_CMD_ERR_ARGUMENT_OUT_OF_RANGE);
+        return;
+    }
+    security_t arrySec[8]= {SECURITY_OPEN,
+                            SECURITY_WEP_PSK,
+                            SECURITY_WEP_SHARED,
+                            SECURITY_WPA_TKIP_PSK,
+                            SECURITY_WPA_AES_PSK,
+                            SECURITY_WPA2_AES_PSK,
+                            SECURITY_WPA2_TKIP_PSK,
+                            SECURITY_WPA2_MIXED_PSK
+                           };
+    for (uint8_t i=0; i<8; i++) {
+        if(sec==i)
+            setSec = arrySec[i];
+    }
 
-        /* call setup API */
-        wifiDevice.setAccessPoint(devNetwork[3].ap_ssid, devNetwork[3].ap_pw, setSec, setChan);
-        cyntecPrintOk();
+    /* handle Channel */
+    argCH = cyntecGetCommandArgument(3, &argLen);
+    uint8_t setChan = atoi((char *)argCH);
+
+    if ( (int)setChan > 14 || (int)setChan < 1) {
+        cyntecPrintError(CYNTEC_CMD_ERR_ARGUMENT_OUT_OF_RANGE);
+        return;
+    }
+#ifdef DELTA_WIFI_DEBUG
+    console.printf("argSSID:%s\r\n",devNetwork[3].ap_ssid);
+    console.printf("argPW:%s\r\n",devNetwork[3].ap_pw);
+    console.printf("sec:%i\r\n",sec);
+    console.printf("setChan:%i\r\n",setChan);
+#endif
+
+    /* call setup API */
+    wifiDevice.setAccessPoint(devNetwork[3].ap_ssid, devNetwork[3].ap_pw, setSec, setChan);
+    cyntecPrintOk();
 
 }
 
 static void cyn_wifi_mem_erase4k()
 {
-	if (cyntecGetCommandTokenCnt() == 3) {
-		uint8_t argLen = 0;
-    	uint8_t *arg;
-    	uint32_t setAddr;
-    	arg = cyntecGetCommandArgument(0, &argLen);
-    	if (arg[0] != '0' || arg[1] != 'x') {
-   			cyntecPrintError(CYNTEC_CMD_ERR_ARGUMENT_SYNTAX_ERROR);
-        	return;
-    	}
-    	setAddr = cyntecHexToUint32(arg+2,argLen-2);
-    	if (setAddr % 0x1000 != 0 || setAddr > MAX_MEM_ERASE_ADDR) {
-    		cyntecPrintError(CYNTEC_CMD_ERR_ARGUMENT_OUT_OF_RANGE);
-    		return;
-    	}
+    if (cyntecGetCommandTokenCnt() == 3) {
+        uint8_t argLen = 0;
+        uint8_t *arg;
+        uint32_t setAddr;
+        arg = cyntecGetCommandArgument(0, &argLen);
+        if (arg[0] != '0' || arg[1] != 'x') {
+            cyntecPrintError(CYNTEC_CMD_ERR_ARGUMENT_SYNTAX_ERROR);
+            return;
+        }
+        setAddr = cyntecHexToUint32(arg+2,argLen-2);
+        if (setAddr % 0x1000 != 0 || setAddr > MAX_MEM_ERASE_ADDR) {
+            cyntecPrintError(CYNTEC_CMD_ERR_ARGUMENT_OUT_OF_RANGE);
+            return;
+        }
 #ifdef DELTA_WIFI_DEBUG
         console.printf("setAddr:%08X\r\n",setAddr);
 #endif
@@ -307,104 +322,99 @@
         if (err_code == 0)
             cyntecPrintOk();
         else
-            console.printf("ERROR;\r\n");    
-	}
-	else {
-		cyntecPrintError(CYNTEC_CMD_ERR_WRONG_NUMBER_OF_ARGUMENTS);
-	}
+            console.printf("ERROR;\r\n");
+    } else {
+        cyntecPrintError(CYNTEC_CMD_ERR_WRONG_NUMBER_OF_ARGUMENTS);
+    }
 }
 
 static void cyn_wifi_mem_write()
 {
-	uint8_t argLen = 0;
+    uint8_t argLen = 0;
     uint8_t *arg;
     uint32_t setAddr;
     uint8_t setData[MAX_DATA_LENGTH] = {0};
     uint16_t writeLen;
     arg = cyntecGetCommandArgument(0, &argLen);
     if (arg[0] != '0' || arg[1] != 'x') {
-   		cyntecPrintError(CYNTEC_CMD_ERR_ARGUMENT_SYNTAX_ERROR);
+        cyntecPrintError(CYNTEC_CMD_ERR_ARGUMENT_SYNTAX_ERROR);
         return;
     }
     setAddr = cyntecHexToUint32(arg+2,argLen-2);
 #ifdef DELTA_WIFI_DEBUG
     console.printf("%08X\r\n",setAddr);
 #endif
-   	if (setAddr > MAX_MEM_WRITE_LENGTH) {
-   		cyntecPrintError(CYNTEC_CMD_ERR_ARGUMENT_OUT_OF_RANGE);
+    if (setAddr > MAX_MEM_WRITE_LENGTH) {
+        cyntecPrintError(CYNTEC_CMD_ERR_ARGUMENT_OUT_OF_RANGE);
         return;
     }
     arg = cyntecGetCommandArgument(1, &argLen);
     if (arg[0]!='0' || arg[1]!='x' || (argLen-2)%2!=0) {
-   		cyntecPrintError(CYNTEC_CMD_ERR_ARGUMENT_SYNTAX_ERROR);
+        cyntecPrintError(CYNTEC_CMD_ERR_ARGUMENT_SYNTAX_ERROR);
         return;
     }
-    //memset(setData,0,(argLen-2)/2); 
-	for (int i=0 ; i < (argLen-2)/2; i++) {
-    	setData[i]  = cyntecArgToUint8(arg+2*(i+1), 2);
+    //memset(setData,0,(argLen-2)/2);
+    for (int i=0 ; i < (argLen-2)/2; i++) {
+        setData[i]  = cyntecArgToUint8(arg+2*(i+1), 2);
 #ifdef DELTA_WIFI_DEBUG
-    console.printf("%02X",setData[i]);
+        console.printf("%02X",setData[i]);
 #endif
-	}
-	writeLen = (argLen-2)/2;
-	// gill need confirm
-	if (writeLen > MAX_MEM_WRITE_LENGTH) {
-   		cyntecPrintError(CYNTEC_CMD_ERR_ARGUMENT_OUT_OF_RANGE);
+    }
+    writeLen = (argLen-2)/2;
+    // gill need confirm
+    if (writeLen > MAX_MEM_WRITE_LENGTH) {
+        cyntecPrintError(CYNTEC_CMD_ERR_ARGUMENT_OUT_OF_RANGE);
         return;
     }
 #ifdef DELTA_WIFI_DEBUG
     console.printf("\r\nwriteLen:%i\r\n",writeLen);
 #endif
-	int err_code = wifiDevice.storage_write(setAddr,setData,writeLen);
-	if (err_code == 0)
-		cyntecPrintOk();
-	else
-		console.printf("ERROR;\r\n");
+    int err_code = wifiDevice.storage_write(setAddr,setData,writeLen);
+    if (err_code == 0)
+        cyntecPrintOk();
+    else
+        console.printf("ERROR;%d\r\n",err_code);
 }
 
 static void cyn_wifi_mem_read()
 {
-	uint8_t argLen = 0;
+    uint8_t argLen = 0;
     uint8_t *arg;
     uint32_t setAddr;
     uint8_t setData[MAX_DATA_LENGTH] = {0};
     uint16_t readLen;
     arg = cyntecGetCommandArgument(0, &argLen);
     if (arg[0] != '0' || arg[1] != 'x') {
-   		cyntecPrintError(CYNTEC_CMD_ERR_ARGUMENT_SYNTAX_ERROR);
+        cyntecPrintError(CYNTEC_CMD_ERR_ARGUMENT_SYNTAX_ERROR);
         return;
     }
     setAddr = cyntecHexToUint32(arg+2,argLen-2);
 #ifdef DELTA_WIFI_DEBUG
     console.printf("%08X\r\n",setAddr);
 #endif
-   	if (setAddr > MAX_MEM_WRITE_LENGTH) {
-   		cyntecPrintError(CYNTEC_CMD_ERR_ARGUMENT_OUT_OF_RANGE);
+    if (setAddr > MAX_MEM_WRITE_LENGTH) {
+        cyntecPrintError(CYNTEC_CMD_ERR_ARGUMENT_OUT_OF_RANGE);
         return;
     }
     arg = cyntecGetCommandArgument(1, &argLen);
-    
-	readLen = cyntecAtoiUint16(arg,argLen);
-	
+
+    readLen = cyntecAtoiUint16(arg,argLen);
+
 #ifdef DELTA_WIFI_DEBUG
     console.printf("\r\nreadLen:%04X\r\n",readLen);
 #endif
-	
-	int err_code = wifiDevice.storage_read(setAddr,setData,readLen);
-	if (err_code == 0) {
-		cyntecPrintOk();
-		for (int i=0;i<readLen;i++) {
-			console.printf("%02X",setData[i]);
-		}
-		console.printf("\r\n");
-	}
-	else
-		console.printf("ERROR;\r\n");
-	
+
+    int err_code = wifiDevice.storage_read(setAddr,setData,readLen);
+    if (err_code == 0) {
+        cyntecPrintOk();
+        for (int i=0; i<readLen; i++) {
+            console.printf("%02X",setData[i]);
+        }
+        console.printf("\r\n");
+    } else
+        console.printf("ERROR;%d\r\n",err_code);
 }
 
-
-
 /////////**** WIFI Ethernet Implement ****//////////
 static void cyn_wifi_ethernet_init()
 {
@@ -417,8 +427,7 @@
         if ( ethInterface.init() == 0 ) {
             cyntecPrintOk();
             wifi_init = true;
-        }
-        else
+        } else
             cyntecPrintError(CYNTEC_CMD_ERR_CALL_FAIL);
 
     } else if ( cyntecGetCommandTokenCnt() == 3 ) {
@@ -435,8 +444,7 @@
         if ( ethInterface.init((const char *)static_ip, NULL, NULL) == 0) {
             cyntecPrintOk();
             wifi_init = true;
-        }
-        else
+        } else
             cyntecPrintError(CYNTEC_CMD_ERR_CALL_FAIL);
     } else {
         cyntecPrintError(CYNTEC_CMD_ERR_WRONG_NUMBER_OF_ARGUMENTS);
@@ -449,20 +457,20 @@
     int timeout_ms = 35000;
     uint8_t *argTimeout;
     EthernetInterface ethInterface;
-
+	if (cyntecGetCommandTokenCnt() != 2 & cyntecGetCommandTokenCnt() != 3)
+		cyntecPrintError(CYNTEC_CMD_ERR_WRONG_NUMBER_OF_ARGUMENTS);
     if (cyntecGetCommandTokenCnt() == 2) {
 #ifdef DELTA_WIFI_DEBUG
         console.printf("\r\n");
         console.printf("Connecting..., Waiting for 35000 ms...");
         console.printf("\r\n\r\n");
 #endif
-
         if ( ethInterface.connect() == 0 )
             cyntecPrintOk();
         else
             cyntecPrintError(CYNTEC_CMD_ERR_CALL_FAIL);
-
-    }	else if (cyntecGetCommandTokenCnt() == 3) {
+    }
+    if (cyntecGetCommandTokenCnt() == 3) {
         argTimeout = cyntecGetCommandArgument(0, NULL);
         timeout_ms = atoi((const char*)argTimeout);
 
@@ -479,9 +487,6 @@
             cyntecPrintOk();
         else
             cyntecPrintError(CYNTEC_CMD_ERR_CALL_FAIL);
-
-    }	else {
-        cyntecPrintError(CYNTEC_CMD_ERR_WRONG_NUMBER_OF_ARGUMENTS);
     }
     return;
 }
@@ -707,12 +712,11 @@
 
         memset( msg, 0, TCP_SEND_MAX_LEN+1);
         memcpy( msg, arg, argLen);
-		sendData = tcpConnect.send(msg, argLen);
-        if ( sendData >= 0 ){
+        sendData = tcpConnect.send(msg, argLen);
+        if ( sendData >= 0 ) {
             console.printf("\r\nOK;");
             console.printf("%i\r\n\r\n",sendData);
-        }
-        else
+        } else
             cyntecPrintError(CYNTEC_CMD_ERR_CALL_FAIL);
 
     }	else {
@@ -1094,25 +1098,76 @@
 // 2015/1/20: Lester add
 
 CyntecCommandEntry wifiCommandSets[] = {
-	
+#if SIMPLE_CMD_NAME
+    /////////**** WIFI Device ****//////////
+    {"DSLP", cyn_wifi_device_sleep, NULL, "Set WIFI module to sleep mode"},
+    {"DCOE", cyn_wifi_device_coex, NULL, "Set/Get device switch for WIFI module"},
+    {"DNWK", cyn_wifi_device_network, NULL, " <SSID> <PASSWORD> <PRIORITY> Set SSID and PASSWORD for WIFI module"},
+    //gill
+    {"DRSV",cyn_wifi_read_sp_version, NULL, "Set network connection in priority"},
+    {"DASN", cyn_wifi_device_ap_scan, NULL, "Scan for available access point on all channels"},
+    {"DSAP",cyn_wifi_set_ap, NULL, " <SSID> <PASSWORD> <SECURITY> <CHANNEL>Set Access Point in given configuration"},
+    {"DME4",cyn_wifi_mem_erase4k, NULL, " <MEMADDR> Erase a 4KB sector of embedded flash"},
+    {"DMRD",cyn_wifi_mem_read, NULL, " <MEMADDR> <LEN> Read data from embeeded flash"},
+    {"DMWT",cyn_wifi_mem_write, NULL, " <MEMADDR> <DATA> Write data into embeeded flash"},
+
+    /////////**** WIFI Ethernet ****//////////
+    {"EINT", cyn_wifi_ethernet_init, NULL, " <STATIC IP> Initialize the interface to use DHCP"},
+    {"ECON", cyn_wifi_ethernet_connect, NULL, "<TIMEOUT MS> Bring up the WiFi connection"},
+    {"EDCN", cyn_wifi_ethernet_disconnect, NULL, "Bring the interface down"},
+    {"EMAC", cyn_wifi_ethernet_mac, NULL, "Get MAC addr of Ehternet Interface"},
+    {"EGIP", cyn_wifi_ethernet_ip, NULL, "Get IP addr of Ehternet Interface"},
+
+    /////////**** WIFI TCP Socket Server ****//////////
+    {"TSBD", cyn_wifi_tcp_server_bind, NULL, " <PORT> Bind a socket to a port"},
+    {"TSLN", cyn_wifi_tcp_server_listen, NULL, "Start listening for incomming connections"},
+    {"TSAC", cyn_wifi_tcp_server_accept, NULL, "Accept a new connection"},
+    {"TSBL", cyn_wifi_tcp_server_blocking, NULL, " <SETTING> <TIMEOUT MS> Set blocking mode and timeout"},
+    {"TSCL", cyn_wifi_tcp_server_close, NULL, " <SHUTDOWN> Close the socket"},
+
+    /////////**** WIFI TCP Socket Connection ****//////////
+    {"TCCN", cyn_wifi_tcp_connection_connect, NULL, " <IPADDR> <PORT> Connects TCP socket to the server"},
+    {"TCIC", cyn_wifi_tcp_connection_is_connected, NULL, "Check if the socket is connected"},
+    {"TCSE", cyn_wifi_tcp_connection_send, NULL, " <DATA> Send data to the remote host"},
+    {"TCSA", cyn_wifi_tcp_connection_send_all, NULL, " <DATA> Send all the data to the remote host"},
+    {"TCRC", cyn_wifi_tcp_connection_receive, NULL, " <DATALEN> Receive data from the remote host"},
+    {"TCRA", cyn_wifi_tcp_connection_receive_all, NULL, "<DATALEN> Receive all the data from the remote host"},
+    {"TCBL ", cyn_wifi_tcp_connection_blocking, NULL, "<SETTING> <TIMEOUT MS> Set blocking mode and timeout"},
+    {"TCCL", cyn_wifi_tcp_connection_close, NULL, "<SHUTDOWN> Close the connection"},
+
+    /////////**** WIFI UDP Socket ****//////////
+    {"UCIN", cyn_wifi_udp_init, NULL, "Init UDP Client Socket"},
+    {"UCBI", cyn_wifi_udp_bind, NULL, " <PORT> Bind UDP Server Socket to a port"},
+    {"UCSB", cyn_wifi_udp_set_broadcasting, NULL, " <IS_BROADCAST> Set socket in broadcasting"},
+    {"UCSE", cyn_wifi_udp_send_to, NULL, " <DATA> Send a packet to a remote endpoint"},
+    {"UCRC", cyn_wifi_udp_received_from, NULL, " <DATALEN> Receive a packet from a remote endpont"},
+    {"UCBL", cyn_wifi_udp_blocking, NULL, " <DATALEN> Set blocking mode and timeout"},
+    {"UCCL", cyn_wifi_udp_close, NULL, " <SHUTDOWN> Close the socket"},
+
+    /////////**** WIFI UDP Endpoint ****//////////
+    {"UERS", cyn_wifi_udp_endpoint_reset_address, NULL, "Reset the address of this endpoint"},
+    {"UEAD", cyn_wifi_udp_endpoint_address, NULL, " <IPADDR> <PORT> Set/Get the address of this endpoint"},
+    {"UEPT", cyn_wifi_udp_endpoint_port, NULL, "Get the port of this endpoint"},
+
+    {NULL, NULL, NULL, NULL},
+#else
     /////////**** WIFI Device ****//////////
     {"device_sleep", cyn_wifi_device_sleep, NULL, "Set WIFI module to sleep mode"},
     {"device_coex", cyn_wifi_device_coex, NULL, "Set/Get device switch for WIFI module"},
     {"device_network", cyn_wifi_device_network, NULL, " <SSID> <PASSWORD> <PRIORITY> Set SSID and PASSWORD for WIFI module"},
     //gill
-//  void WIFIDevice::setAccessPoint(char* SSID, char* PW, security_t security=SECURITY_WPA2_AES_PSK, uint8_t channel=1);
-    {"device_read_version",cyn_wifi_read_wifi_sp_version, NULL, "Set network connection in priority"},
-    {"device_apscan", cyn_wifi_device_ap_scan, NULL, "Perform WIFI scan"},
+    {"device_read_version",cyn_wifi_read_sp_version, NULL, "Read WIFI Service Pack version"},
+    {"device_apscan", cyn_wifi_device_ap_scan, NULL, "Scan for available access point on all channels."},
     {"device_setap",cyn_wifi_set_ap, NULL, " <SSID> <PASSWORD> <SECURITY> <CHANNEL>Set Access Point in given configuration"},
-	{"device_mem_erase4k",cyn_wifi_mem_erase4k, NULL, " <MEMADDR> Erase a 4KB sector of embedded flash"},
-	{"device_mem_read",cyn_wifi_mem_read, NULL, " <MEMADDR> <LEN> Read data from embeeded flash"},
-	{"device_mem_write",cyn_wifi_mem_write, NULL, " <MEMADDR> <DATA> Write data into embeeded flash"},
-	
+    {"device_mem_erase4k",cyn_wifi_mem_erase4k, NULL, " <MEMADDR> Erase a 4KB sector of embedded flash"},
+    {"device_mem_read",cyn_wifi_mem_read, NULL, " <MEMADDR> <LEN> Read data from embeeded flash"},
+    {"device_mem_write",cyn_wifi_mem_write, NULL, " <MEMADDR> <DATA> Write data into embeeded flash"},
+
     /////////**** WIFI Ethernet ****//////////
     {"ethernet_init", cyn_wifi_ethernet_init, NULL, " <STATIC IP> Initialize the interface to use DHCP"},
     {"ethernet_connect", cyn_wifi_ethernet_connect, NULL, "<TIMEOUT MS> Bring up the WiFi connection"},
     {"ethernet_disconnect", cyn_wifi_ethernet_disconnect, NULL, "Bring the interface down"},
-    {"ethernet_mac", cyn_wifi_ethernet_mac, NULL, "Get MAC addr of Ehternet Interface"},
+    {"ethernet_mac", cyn_wifi_ethernet_mac, NULL, "Get MAC addr of Ethernet Interface"},
     {"ethernet_ip", cyn_wifi_ethernet_ip, NULL, "Get IP addr of Ehternet Interface"},
     /* not implement yet... */
     ////{"ethernet_gateway", cyn_wifi_ethernet_gateway, NULL, "........."},
@@ -1154,7 +1209,7 @@
     {"udp_endpoint_port", cyn_wifi_udp_endpoint_port, NULL, "Get the port of this endpoint"},
 
     {NULL, NULL, NULL, NULL},
-
+#endif
 };