Customized SNICInterface

Fork of NySNICInterface by Ryo Iizuka

Revision:
29:6a0ba999597d
Parent:
28:b796031f6519
Child:
31:15c22824cc46
--- a/SNIC/SNIC_Core.h	Tue Apr 01 07:19:19 2014 +0000
+++ b/SNIC/SNIC_Core.h	Mon May 26 05:17:28 2014 +0000
@@ -21,14 +21,14 @@
 
 #include "SNIC_UartCommandManager.h"
 
-namespace murata_wifi
-{
-#define UART_REQUEST_PAYLOAD_MAX 256
+#define UART_REQUEST_PAYLOAD_MAX 1024
 
 #define MEMPOOL_BLOCK_SIZE  2048
 #define MEMPOOL_PAYLOAD_NUM 1
 #define MAX_SOCKET_ID   5
 
+#define MEMPOOL_UART_RECV_NUM 2
+
 /** Wi-Fi security
  */
 typedef enum SECURITY {
@@ -59,6 +59,14 @@
     e_AP_STARTED
 }E_WIFI_STATUS;
 
+/** Memorypool
+ */
+typedef struct
+{
+    unsigned int  size;
+    unsigned char buf[MEMPOOL_BLOCK_SIZE];
+}tagMEMPOOL_BLOCK_T;
+
 /** Internal class used by any other classes. This class is singleton.
  */
 class C_SNIC_Core: public C_MurataObject
@@ -69,13 +77,6 @@
 friend class Socket;
 
 private:
-    /** Memorypool for SNIC UART Response
-     */
-    typedef struct
-    {
-        unsigned char buf[MEMPOOL_BLOCK_SIZE];
-    }tagMEMPOOL_BLOCK_T;
-
     /** Wi-Fi Network type
      */
     typedef enum NETWORK_TYPE {
@@ -88,7 +89,7 @@
     /** Connection information
     */
     typedef struct {
-        CircBuffer<unsigned char>    *recvbuf_p;
+        CircBuffer<char>    *recvbuf_p;
         bool                is_connected;
         bool                is_received;
     }tagCONNECT_INFO_T;
@@ -177,14 +178,6 @@
         unsigned char seq;
     }tagWIFI_GET_STA_RSSI_REQ_T;
     
-    /** WIFI_GET_STATUS_REQ Command */
-    typedef struct 
-    {
-        unsigned char cmd_sid;
-        unsigned char seq;
-        unsigned char interface;
-    }tagWIFI_GET_STATUS_REQ_T;
-    
     /** WIFI_SCAN_REQ Command */
     typedef struct 
     {
@@ -197,18 +190,39 @@
         unsigned char ssid[SSID_MAX_LENGTH+1];
     }tagWIFI_SCAN_REQ_T;
 
-
+    /** WIFI_GET_STATUS_REQ Command */
+    typedef struct 
+    {
+        unsigned char cmd_sid;
+        unsigned char seq;
+        unsigned char interface;
+    }tagWIFI_GET_STATUS_REQ_T;
+    
     /** Get buffer for command from memory pool.
         @return Pointer of buffer
      */
-    C_SNIC_Core::tagMEMPOOL_BLOCK_T *allocCmdBuf();
+    tagMEMPOOL_BLOCK_T *allocCmdBuf();
     
     /** Release buffer to memory pool.
         @param buf_p Pointer of buffer
      */
     void freeCmdBuf( tagMEMPOOL_BLOCK_T *buf_p );
 
-    /** Initialize UART
+    /** Get buffer for command from memory pool.
+        @return Pointer of buffer
+     */
+    tagMEMPOOL_BLOCK_T *allocUartRcvBuf();
+    
+    /** Release buffer to memory pool.
+        @param buf_p Pointer of buffer
+     */
+    void freeUartRecvBuf( tagMEMPOOL_BLOCK_T *buf_p );
+
+    /** Module Reset
+    */
+    int resetModule( PinName reset );
+
+/** Initialize UART
     */
     int initUart( PinName tx, PinName rx, int baud );
 
@@ -245,6 +259,8 @@
     */
     C_SNIC_UartCommandManager *getUartCommand();
 
+    unsigned char *getCommandBuf();
+
     /** Get an instance of the C_SNIC_Core class.
         @return Instance of the C_SNIC_Core class
         @note   Please do not create an instance in the default constructor this class.
@@ -255,14 +271,15 @@
 private:
     static C_SNIC_Core        *mInstance_p;
     Thread                    *mUartRecvThread_p;
+    Thread                    *mUartRecvDispatchThread_p;
     RawSerial                 *mUart_p;
     Mutex                      mUartMutex;
+    
 //    DigitalInOut             mModuleReset;
     C_SNIC_UartCommandManager *mUartCommand_p;
-
-    /** MemoryPool for payload of UART response */
-    MemoryPool<tagMEMPOOL_BLOCK_T, MEMPOOL_PAYLOAD_NUM>     mMemPoolPayload;
-  
+    
+    CircBuffer<char>          *mUartRecvBuf_p;  // UART RecvBuffer
+    
     /** Socket buffer */
     tagCONNECT_INFO_T   mConnectInfo[MAX_SOCKET_ID+1];
   
@@ -271,10 +288,11 @@
     C_SNIC_Core();
 
     virtual ~C_SNIC_Core();
+    
+    static void uartRecvCallback( void );
     /** Receiving thread of UART
     */
-    static void uartRecvThread( void const *args_p );
+    static void uartRecvDispatchThread( void const *args_p );
 };
-}
 
 #endif
\ No newline at end of file