SNIC UART Interface library: Serial to Wi-Fi library for Murata TypeYD Wi-Fi module. For more information about TypeYD: http://www.murata.co.jp/products/microwave/module/lbwb1zzydz/index.html

Dependents:   SNIC-xively-jumpstart-demo SNIC-FluentLogger-example TCPEchoServer murataDemo ... more

Fork of YDwifiInterface by Takao Kishino

Files at this revision

API Documentation at this revision

Comitter:
kishino
Date:
Tue Jul 15 02:08:42 2014 +0000
Parent:
38:f13e4e563d65
Child:
40:b6b10c22a121
Commit message:
The pointing out of in-house reviews was modified.

Changed in this revision

SNIC/MurataObject.cpp Show annotated file Show diff for this revision Revisions of this file
SNIC/MurataObject.h Show annotated file Show diff for this revision Revisions of this file
SNIC/SNIC_Core.cpp Show annotated file Show diff for this revision Revisions of this file
SNIC/SNIC_Core.h Show annotated file Show diff for this revision Revisions of this file
SNIC/SNIC_UartCommandManager.cpp Show annotated file Show diff for this revision Revisions of this file
SNIC/SNIC_UartCommandManager.h Show annotated file Show diff for this revision Revisions of this file
SNIC/SNIC_UartMsgUtil.cpp Show annotated file Show diff for this revision Revisions of this file
SNIC/SNIC_UartMsgUtil.h Show annotated file Show diff for this revision Revisions of this file
SNIC_WifiInterface.cpp Show annotated file Show diff for this revision Revisions of this file
SNIC_WifiInterface.h Show annotated file Show diff for this revision Revisions of this file
Socket/Endpoint.cpp Show annotated file Show diff for this revision Revisions of this file
Socket/Endpoint.h Show annotated file Show diff for this revision Revisions of this file
Socket/Socket.cpp Show annotated file Show diff for this revision Revisions of this file
Socket/Socket.h Show annotated file Show diff for this revision Revisions of this file
Socket/TCPSocketConnection.cpp Show annotated file Show diff for this revision Revisions of this file
Socket/TCPSocketConnection.h Show annotated file Show diff for this revision Revisions of this file
Socket/TCPSocketServer.cpp Show annotated file Show diff for this revision Revisions of this file
Socket/TCPSocketServer.h Show annotated file Show diff for this revision Revisions of this file
Socket/UDPSocket.cpp Show annotated file Show diff for this revision Revisions of this file
Socket/UDPSocket.h Show annotated file Show diff for this revision Revisions of this file
--- a/SNIC/MurataObject.cpp	Wed Jun 25 00:04:11 2014 +0000
+++ b/SNIC/MurataObject.cpp	Tue Jul 15 02:08:42 2014 +0000
@@ -1,15 +1,21 @@
-/******************* Murata Manufacturing Co.,Ltd. 2014 *****************
+/* Copyright (C) 2014 Murata Manufacturing Co.,Ltd., MIT License
+ *  muRata, SWITCH SCIENCE Wi-FI module TypeYD-SNIC UART.
  *
- * Filename:   MurataObject.cpp
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
  *
- * Purpose:    This module has implementation of common function for Murata.
- *              
- * $Author: kishino $
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
  *
- * $Date: 2014/03/28 $
- *
- * $Revision: 0.0.0.1 $
- * ***********************************************************************/
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
 #include "MurataObject.h"
 #include "stdarg.h"
 
--- a/SNIC/MurataObject.h	Wed Jun 25 00:04:11 2014 +0000
+++ b/SNIC/MurataObject.h	Tue Jul 15 02:08:42 2014 +0000
@@ -1,15 +1,21 @@
-/******************* Murata Manufacturing Co.,Ltd. 2014 *****************
+/* Copyright (C) 2014 Murata Manufacturing Co.,Ltd., MIT License
+ *  muRata, SWITCH SCIENCE Wi-FI module TypeYD-SNIC UART.
  *
- * Filename:   MurataObject.h
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
  *
- * Purpose:    This module has define of common function for Murata.
- *              
- * $Author: kishino $
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
  *
- * $Date: 2014/03/28 $
- *
- * $Revision: 0.0.0.1 $
- * ***********************************************************************/
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
 #ifndef _MURATA_OBJECT_H_
 #define _MURATA_OBJECT_H_
 #include "mbed.h"
--- a/SNIC/SNIC_Core.cpp	Wed Jun 25 00:04:11 2014 +0000
+++ b/SNIC/SNIC_Core.cpp	Tue Jul 15 02:08:42 2014 +0000
@@ -1,15 +1,21 @@
-/******************* Murata Manufacturing Co.,Ltd. 2014 *****************
+/* Copyright (C) 2014 Murata Manufacturing Co.,Ltd., MIT License
+ *  muRata, SWITCH SCIENCE Wi-FI module TypeYD-SNIC UART.
  *
- * Filename:   SNIC_Core.cpp
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
  *
- * Purpose:    This module has implementation of internal common function for API.
- *              
- * $Author: kishino $
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
  *
- * $Date: 2014/03/26 $
- *
- * $Revision: 0.0.0.1 $
- * ***********************************************************************/
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
 #include "mbed.h"
 #include "SNIC_Core.h"
 #include "SNIC_UartMsgUtil.h"
@@ -20,6 +26,9 @@
 
 #define UART_RECVBUF_SIZE       2048
 #define UART_THREAD_STACK_SIZE  512
+#define UART_FIXED_HEADER_SIZE    3
+#define UART_FIXED_SIZE_IN_FRAME  6
+#define UART_RECV_QUEUE_TIMEOUT   500
 
 typedef struct
 {
@@ -198,13 +207,11 @@
     {
         int  recvdata = 0;
 
-        // set signal
-        if( instance_p->mUart_p->readable() )
+        // Check received data from UART.
+        while( instance_p->mUart_p->readable() )
         {
             // Receive data from UART.
-            instance_p->mUartMutex.lock();
             recvdata = instance_p->mUart_p->getc();
-            instance_p->mUartMutex.unlock();
 
             // Check UART receiving buffer
             if( gUART_RCVBUF_p != NULL )
@@ -212,12 +219,15 @@
                 gUART_RCVBUF_p->buf[ gUART_RCVBUF_p->size ] = (unsigned char)recvdata;
                 gUART_RCVBUF_p->size++;
                 
-                if( gUART_RCVBUF_p->size == 3 )
+                if( gUART_RCVBUF_p->size == UART_FIXED_HEADER_SIZE )
                 {
                     // get demand size
                     unsigned short  payload_len = ( ( (gUART_RCVBUF_p->buf[1] & ~0x80) & 0xff) | ( ( (gUART_RCVBUF_p->buf[2] & ~0xC0) << 7) & 0xff80) );
-                    gUART_RCVBUF_p->demand_size = payload_len + 6;
-                        
+                    gUART_RCVBUF_p->demand_size = payload_len + UART_FIXED_SIZE_IN_FRAME;
+                    if( gUART_RCVBUF_p->demand_size > MEMPOOL_BLOCK_SIZE )
+                    {
+                        gUART_RCVBUF_p->demand_size = MEMPOOL_BLOCK_SIZE;
+                    }
                 }
 
                 if( gUART_RCVBUF_p->demand_size > 0 )
@@ -268,7 +278,7 @@
         Thread::signal_wait( UART_DISPATCH_SIGNAL );
 
         // Get scanresults from queue
-        evt = mUartRecvQueue.get(500);
+        evt = mUartRecvQueue.get(UART_RECV_QUEUE_TIMEOUT);
         if (evt.status == osEventMessage)
         {
             do
@@ -328,11 +338,15 @@
                     // Set signal for command response wait.
                     uartCmdMgr_p->signal();
                 }
+                else
+                {
+                    printf(" The received data is not expected.\r\n");
+                }
+                
                 // 
                 instance_p->freeUartRecvBuf( uartRecvBuf_p );
                 
                 evt = mUartRecvQueue.get(500);
-                Thread::yield();
             } while( evt.status == osEventMessage );
         }
     }
--- a/SNIC/SNIC_Core.h	Wed Jun 25 00:04:11 2014 +0000
+++ b/SNIC/SNIC_Core.h	Tue Jul 15 02:08:42 2014 +0000
@@ -1,15 +1,21 @@
-/******************* Murata Manufacturing Co.,Ltd. 2014 *****************
+/* Copyright (C) 2014 Murata Manufacturing Co.,Ltd., MIT License
+ *  muRata, SWITCH SCIENCE Wi-FI module TypeYD-SNIC UART.
  *
- * Filename:   SNIC_Core.h
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
  *
- * Purpose:    This module has define of internal common function for API.
- *              
- * $Author: kishino $
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
  *
- * $Date: 2014/03/26 $
- *
- * $Revision: 0.0.0.1 $
- * ***********************************************************************/
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
 #ifndef _SNIC_CORE_H_
 #define _SNIC_CORE_H_
 
@@ -98,6 +104,7 @@
         bool                is_received;
         int                 parent_socket;
         bool                is_accept;
+        Mutex               mutex;
     }tagCONNECT_INFO_T;
 
     /** UDP Recv information
@@ -108,6 +115,7 @@
         short               from_port;
         int                 parent_socket;
         bool                is_received;
+        Mutex               mutex;
     }tagUDP_RECVINFO_T;
 
     /** GEN_FW_VER_GET_REQ Command */
--- a/SNIC/SNIC_UartCommandManager.cpp	Wed Jun 25 00:04:11 2014 +0000
+++ b/SNIC/SNIC_UartCommandManager.cpp	Tue Jul 15 02:08:42 2014 +0000
@@ -1,16 +1,21 @@
-/******************* Murata Manufacturing Co.,Ltd. 2014 *****************
+/* Copyright (C) 2014 Murata Manufacturing Co.,Ltd., MIT License
+ *  muRata, SWITCH SCIENCE Wi-FI module TypeYD-SNIC UART.
  *
- * Filename:   SNIC_UartCommandManager.cpp
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
  *
- * Purpose:    This module has implementation of function for management of 
-               SNIC UART Command.
- *              
- * $Author: kishino $
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
  *
- * $Date: 2014/03/26 $
- *
- * $Revision: 0.0.0.1 $
- * ***********************************************************************/
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
 #include "SNIC_UartCommandManager.h"
 #include "SNIC_Core.h"
 
@@ -181,7 +186,9 @@
         // Add to receive buffer
         con_info_p->recvbuf_p->queue( payload_p[5+i] );
     }
+    con_info_p->mutex.lock();
     con_info_p->is_received = true;
+    con_info_p->mutex.unlock();
 }
 
 void C_SNIC_UartCommandManager::connectedTCPClient( unsigned char *payload_p, int payload_len )
@@ -238,8 +245,9 @@
 //        printf( "create recv buffer[socket:%d]\r\n", payload_p[2]);
         con_info_p->recvbuf_p = new CircBuffer<char>(SNIC_UART_RECVBUF_SIZE);
     }
-
+    con_info_p->mutex.lock();
     con_info_p->is_received = true;
+    con_info_p->mutex.unlock();
     
     // Set remote IP address and remote port
     con_info_p->from_ip   = ((payload_p[3] << 24) | (payload_p[4] << 16) | (payload_p[5] << 8) | payload_p[6]);
--- a/SNIC/SNIC_UartCommandManager.h	Wed Jun 25 00:04:11 2014 +0000
+++ b/SNIC/SNIC_UartCommandManager.h	Tue Jul 15 02:08:42 2014 +0000
@@ -1,16 +1,21 @@
-/******************* Murata Manufacturing Co.,Ltd. 2014 *****************
+/* Copyright (C) 2014 Murata Manufacturing Co.,Ltd., MIT License
+ *  muRata, SWITCH SCIENCE Wi-FI module TypeYD-SNIC UART.
  *
- * Filename:   SNIC_UartCommandManager.h
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
  *
- * Purpose:    This module has define of function for management of 
-               SNIC UART Command.
- *              
- * $Author: kishino $
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
  *
- * $Date: 2014/03/26 $
- *
- * $Revision: 0.0.0.1 $
- * ***********************************************************************/
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
 #ifndef _SNIC_UART_COMMAND_MANAGER_H_
 #define _SNIC_UART_COMMAND_MANAGER_H_
 #include "MurataObject.h"
--- a/SNIC/SNIC_UartMsgUtil.cpp	Wed Jun 25 00:04:11 2014 +0000
+++ b/SNIC/SNIC_UartMsgUtil.cpp	Tue Jul 15 02:08:42 2014 +0000
@@ -1,16 +1,21 @@
-/******************* Murata Manufacturing Co.,Ltd. 2014 *****************
+/* Copyright (C) 2014 Murata Manufacturing Co.,Ltd., MIT License
+ *  muRata, SWITCH SCIENCE Wi-FI module TypeYD-SNIC UART.
  *
- * Filename:   SNIC_UartMsgUtil.cpp
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
  *
- * Purpose:    This module has implementation of function for utilities 
- *             of SNIC UART Command.
- *              
- * $Author: kishino $
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
  *
- * $Date: 2014/03/26 $
- *
- * $Revision: 0.0.0.1 $
- * ***********************************************************************/
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
 #include "SNIC_UartMsgUtil.h"
 
 C_SNIC_UartMsgUtil::C_SNIC_UartMsgUtil()
--- a/SNIC/SNIC_UartMsgUtil.h	Wed Jun 25 00:04:11 2014 +0000
+++ b/SNIC/SNIC_UartMsgUtil.h	Tue Jul 15 02:08:42 2014 +0000
@@ -1,16 +1,21 @@
-/******************* Murata Manufacturing Co.,Ltd. 2014 *****************
+/* Copyright (C) 2014 Murata Manufacturing Co.,Ltd., MIT License
+ *  muRata, SWITCH SCIENCE Wi-FI module TypeYD-SNIC UART.
  *
- * Filename:   SNIC_UartMsgUtil.h
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
  *
- * Purpose:    This module has define of function for utilities 
- *             of SNIC UART Command.
- *              
- * $Author: kishino $
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
  *
- * $Date: 2014/03/26 $
- *
- * $Revision: 0.0.0.1 $
- * ***********************************************************************/
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
 #ifndef _SNIC_WIFI_UART_MSG_UTIL_H_
 #define _SNIC_WIFI_UART_MSG_UTILH_
 #include "MurataObject.h"
--- a/SNIC_WifiInterface.cpp	Wed Jun 25 00:04:11 2014 +0000
+++ b/SNIC_WifiInterface.cpp	Tue Jul 15 02:08:42 2014 +0000
@@ -1,15 +1,21 @@
-/******************* Murata Manufacturing Co.,Ltd. 2014 *****************
+/* Copyright (C) 2014 Murata Manufacturing Co.,Ltd., MIT License
+ *  muRata, SWITCH SCIENCE Wi-FI module TypeYD-SNIC UART.
  *
- * Filename:   SNIC_WifiInterface.cpp
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
  *
- * Purpose:    This module has implementation of API for SNIC UART of Wi-Fi. 
- *              
- * $Author: kishino $
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
  *
- * $Date: 2014/03/26 $
- *
- * $Revision: 0.0.0.1 $
- * ***********************************************************************/
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
 #include "SNIC_WifiInterface.h"
 #include "SNIC_UartMsgUtil.h"
 
@@ -80,7 +86,8 @@
     if( uartCmdMgr_p->getCommandStatus() != 0 )
     {
         printf("snic_init status:%02x\r\n", uartCmdMgr_p->getCommandStatus());
-        ret = -1;
+        snic_core_p->freeCmdBuf( payload_buf_p );
+        return -1;
     }
     snic_core_p->freeCmdBuf( payload_buf_p );
     
@@ -215,7 +222,8 @@
         (uartCmdMgr_p->getCommandStatus() != UART_CMD_RES_WIFI_ERR_ALREADY_JOINED) )
     {
         printf("join status:%02x\r\n", uartCmdMgr_p->getCommandStatus());
-        ret = -1;
+        snic_core_p->freeCmdBuf( payload_buf_p );
+        return -1;
     }
     snic_core_p->freeCmdBuf( payload_buf_p );
 
@@ -341,7 +349,8 @@
     if( uartCmdMgr_p->getCommandStatus() != 0 )
     {
         printf("scan status:%02x\r\n", uartCmdMgr_p->getCommandStatus());
-        ret = -1;
+        snic_core_p->freeCmdBuf( payload_buf_p );
+        return -1;
     }
 
     snic_core_p->freeCmdBuf( payload_buf_p );
@@ -397,7 +406,8 @@
     if( uartCmdMgr_p->getCommandStatus() != 0 )
     {
         printf("wifi_on status:%02x\r\n", uartCmdMgr_p->getCommandStatus());
-        ret = -1;
+        snic_core_p->freeCmdBuf( payload_buf_p );
+        return -1;
     }
     snic_core_p->freeCmdBuf( payload_buf_p );
 
@@ -444,7 +454,8 @@
     if( uartCmdMgr_p->getCommandStatus() != 0 )
     {
         printf("wifi_off status:%02x\r\n", uartCmdMgr_p->getCommandStatus());
-        ret = -1;
+        snic_core_p->freeCmdBuf( payload_buf_p );
+        return -1;
     }
     snic_core_p->freeCmdBuf( payload_buf_p );
 
@@ -638,7 +649,8 @@
     if( uartCmdMgr_p->getCommandStatus() != 0 )
     {
         printf("setIPConfig status:%02x\r\n", uartCmdMgr_p->getCommandStatus());
-        ret = -1;
+        snic_core_p->freeCmdBuf( payload_buf_p );
+        return -1;
     }
 
     snic_core_p->freeCmdBuf( payload_buf_p );
--- a/SNIC_WifiInterface.h	Wed Jun 25 00:04:11 2014 +0000
+++ b/SNIC_WifiInterface.h	Tue Jul 15 02:08:42 2014 +0000
@@ -1,15 +1,21 @@
-/******************* Murata Manufacturing Co.,Ltd. 2014 *****************
+/* Copyright (C) 2014 Murata Manufacturing Co.,Ltd., MIT License
+ *  muRata, SWITCH SCIENCE Wi-FI module TypeYD-SNIC UART.
  *
- * Filename:   SNIC_WifiInterface.h
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
  *
- * Purpose:    This module has define of API for SNIC UART of Wi-Fi.
- *              
- * $Author: kishino $
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
  *
- * $Date: 2014/03/26 $
- *
- * $Revision: 0.0.0.1 $
- * ***********************************************************************/
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
 #ifndef _SNIC_WIFIINTERFACE_H_
 #define _SNIC_WIFIINTERFACE_H_
 
--- a/Socket/Endpoint.cpp	Wed Jun 25 00:04:11 2014 +0000
+++ b/Socket/Endpoint.cpp	Tue Jul 15 02:08:42 2014 +0000
@@ -15,18 +15,9 @@
  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
-/******************* Murata Manufacturing Co.,Ltd. 2014 *****************
- *
- * Filename:   Endpoint.cpp
- *
- * Purpose:    This module has implementation of socket end point.
- *              
- * $Author: kishino $
- *
- * $Date: 2014/03/26 $
- *
- * $Revision: 0.0.0.1 $
- * ***********************************************************************/
+/* Copyright (C) 2014 Murata Manufacturing Co.,Ltd., MIT License
+ *  port to the muRata, SWITCH SCIENCE Wi-FI module TypeYD-SNIC UART.
+ */
 #include "Socket.h"
 #include "Endpoint.h"
 #include <cstring>
--- a/Socket/Endpoint.h	Wed Jun 25 00:04:11 2014 +0000
+++ b/Socket/Endpoint.h	Tue Jul 15 02:08:42 2014 +0000
@@ -15,18 +15,9 @@
  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
-/******************* Murata Manufacturing Co.,Ltd. 2014 *****************
- *
- * Filename:   Endpoint.h
- *
- * Purpose:    This module has define of socket end point.
- *              
- * $Author: kishino $
- *
- * $Date: 2014/03/26 $
- *
- * $Revision: 0.0.0.1 $
- * ***********************************************************************/
+/* Copyright (C) 2014 Murata Manufacturing Co.,Ltd., MIT License
+ *  port to the muRata, SWITCH SCIENCE Wi-FI module TypeYD-SNIC UART.
+ */
 #ifndef ENDPOINT_H
 #define ENDPOINT_H
 
--- a/Socket/Socket.cpp	Wed Jun 25 00:04:11 2014 +0000
+++ b/Socket/Socket.cpp	Tue Jul 15 02:08:42 2014 +0000
@@ -15,18 +15,9 @@
  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
-/******************* Murata Manufacturing Co.,Ltd. 2014 *****************
- *
- * Filename:   Socket.cpp
- *
- * Purpose:    This module has implementation of socket.
- *              
- * $Author: kishino $
- *
- * $Date: 2014/03/26 $
- *
- * $Revision: 0.0.0.1 $
- * ***********************************************************************/
+/* Copyright (C) 2014 Murata Manufacturing Co.,Ltd., MIT License
+ *  port to the muRata, SWITCH SCIENCE Wi-FI module TypeYD-SNIC UART.
+ */
 #include "Socket.h"
 #include <cstring>
 
--- a/Socket/Socket.h	Wed Jun 25 00:04:11 2014 +0000
+++ b/Socket/Socket.h	Tue Jul 15 02:08:42 2014 +0000
@@ -15,18 +15,9 @@
  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
-/******************* Murata Manufacturing Co.,Ltd. 2014 *****************
- *
- * Filename:   Socket.h
- *
- * Purpose:    This module has define of socket.
- *              
- * $Author: kishino $
- *
- * $Date: 2014/03/26 $
- *
- * $Revision: 0.0.0.1 $
- * ***********************************************************************/
+/* Copyright (C) 2014 Murata Manufacturing Co.,Ltd., MIT License
+ *  port to the muRata, SWITCH SCIENCE Wi-FI module TypeYD-SNIC UART.
+ */
 #ifndef SOCKET_H_
 #define SOCKET_H_
 
--- a/Socket/TCPSocketConnection.cpp	Wed Jun 25 00:04:11 2014 +0000
+++ b/Socket/TCPSocketConnection.cpp	Tue Jul 15 02:08:42 2014 +0000
@@ -15,18 +15,9 @@
  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
-/******************* Murata Manufacturing Co.,Ltd. 2014 *****************
- *
- * Filename:   TCPSocketConnection.cpp
- *
- * Purpose:    This module has implementation of TCP connection.
- *              
- * $Author: kishino $
- *
- * $Date: 2014/03/26 $
- *
- * $Revision: 0.0.0.1 $
- * ***********************************************************************/
+/* Copyright (C) 2014 Murata Manufacturing Co.,Ltd., MIT License
+ *  port to the muRata, SWITCH SCIENCE Wi-FI module TypeYD-SNIC UART.
+ */
 #include "TCPSocketConnection.h"
 #include <cstring>
 
@@ -240,7 +231,9 @@
 
     if( con_info_p->recvbuf_p->isEmpty() )
     {
+        con_info_p->mutex.lock();
         con_info_p->is_received = false;
+        con_info_p->mutex.unlock();
     }
 
     return i;
--- a/Socket/TCPSocketConnection.h	Wed Jun 25 00:04:11 2014 +0000
+++ b/Socket/TCPSocketConnection.h	Tue Jul 15 02:08:42 2014 +0000
@@ -15,19 +15,9 @@
  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
-/******************* Murata Manufacturing Co.,Ltd. 2014 *****************
- *
- * Filename:   TCPSocketConnection.h
- *
- * Purpose:    This module has define of TCP connection.
- *              
- * $Author: kishino $
- *
- * $Date: 2014/03/26 $
- *
- * $Revision: 0.0.0.1 $
- * ***********************************************************************/
-
+/* Copyright (C) 2014 Murata Manufacturing Co.,Ltd., MIT License
+ *  port to the muRata, SWITCH SCIENCE Wi-FI module TypeYD-SNIC UART.
+ */
 #ifndef TCPSOCKET_H
 #define TCPSOCKET_H
 
--- a/Socket/TCPSocketServer.cpp	Wed Jun 25 00:04:11 2014 +0000
+++ b/Socket/TCPSocketServer.cpp	Tue Jul 15 02:08:42 2014 +0000
@@ -15,18 +15,9 @@
  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
-/******************* Murata Manufacturing Co.,Ltd. 2014 *****************
- *
- * Filename:   TCPSocketServer.cpp
- *
- * Purpose:    This module has implementation of TCP server.
- *              
- * $Author: kishino $
- *
- * $Date: 2014/03/26 $
- *
- * $Revision: 0.0.0.1 $
- * ***********************************************************************/
+/* Copyright (C) 2014 Murata Manufacturing Co.,Ltd., MIT License
+ *  port to the muRata, SWITCH SCIENCE Wi-FI module TypeYD-SNIC UART.
+ */
 #include "TCPSocketServer.h"
 #include "SNIC_Core.h"
 
--- a/Socket/TCPSocketServer.h	Wed Jun 25 00:04:11 2014 +0000
+++ b/Socket/TCPSocketServer.h	Tue Jul 15 02:08:42 2014 +0000
@@ -15,18 +15,9 @@
  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
-/******************* Murata Manufacturing Co.,Ltd. 2014 *****************
- *
- * Filename:   TCPSocketServer.h
- *
- * Purpose:    This module has define of TCP server.
- *              
- * $Author: kishino $
- *
- * $Date: 2014/03/26 $
- *
- * $Revision: 0.0.0.1 $
- * ***********************************************************************/
+/* Copyright (C) 2014 Murata Manufacturing Co.,Ltd., MIT License
+ *  port to the muRata, SWITCH SCIENCE Wi-FI module TypeYD-SNIC UART.
+ */
 #ifndef TCPSOCKETSERVER_H
 #define TCPSOCKETSERVER_H
 
--- a/Socket/UDPSocket.cpp	Wed Jun 25 00:04:11 2014 +0000
+++ b/Socket/UDPSocket.cpp	Tue Jul 15 02:08:42 2014 +0000
@@ -15,19 +15,9 @@
  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
-/******************* Murata Manufacturing Co.,Ltd. 2014 *****************
- *
- * Filename:   UDPSocket.cpp
- *
- * Purpose:    This module has implementation of UDP socket.
- *              
- * $Author: kishino $
- *
- * $Date: 2014/03/26 $
- *
- * $Revision: 0.0.0.1 $
- * ***********************************************************************/
-
+/* Copyright (C) 2014 Murata Manufacturing Co.,Ltd., MIT License
+ *  port to the muRata, SWITCH SCIENCE Wi-FI module TypeYD-SNIC UART.
+ */
 #include "Socket/UDPSocket.h"
 #include <cstring>
 
@@ -269,7 +259,9 @@
 
     if( con_info_p->recvbuf_p->isEmpty() )
     {
+        con_info_p->mutex.lock();
         con_info_p->is_received = false;
+        con_info_p->mutex.unlock();
     }
 
     return i;
--- a/Socket/UDPSocket.h	Wed Jun 25 00:04:11 2014 +0000
+++ b/Socket/UDPSocket.h	Tue Jul 15 02:08:42 2014 +0000
@@ -15,19 +15,9 @@
  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
-/******************* Murata Manufacturing Co.,Ltd. 2014 *****************
- *
- * Filename:   UDPSocket.h
- *
- * Purpose:    This module has define of UDP socket.
- *              
- * $Author: kishino $
- *
- * $Date: 2014/03/26 $
- *
- * $Revision: 0.0.0.1 $
- * ***********************************************************************/
-
+/* Copyright (C) 2014 Murata Manufacturing Co.,Ltd., MIT License
+ *  port to the muRata, SWITCH SCIENCE Wi-FI module TypeYD-SNIC UART.
+ */
 #ifndef UDPSOCKET_H
 #define UDPSOCKET_H