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:
Fri Mar 14 08:48:12 2014 +0000
Parent:
6:70f522934032
Child:
8:50d2509479cd
Commit message:
Scan handler interface modify

Changed in this revision

YDwifi/YDwifi.cpp Show annotated file Show diff for this revision Revisions of this file
YDwifi/YDwifiUartCommand.cpp Show annotated file Show diff for this revision Revisions of this file
YDwifi/YDwifiUartCommand.h Show annotated file Show diff for this revision Revisions of this file
YDwifi/YDwifi_uartmsg.cpp Show annotated file Show diff for this revision Revisions of this file
YDwifi/YDwifi_uartmsg.h Show annotated file Show diff for this revision Revisions of this file
YDwifiInterface.cpp Show annotated file Show diff for this revision Revisions of this file
YDwifiInterface.h Show annotated file Show diff for this revision Revisions of this file
--- a/YDwifi/YDwifi.cpp	Thu Mar 13 10:33:18 2014 +0000
+++ b/YDwifi/YDwifi.cpp	Fri Mar 14 08:48:12 2014 +0000
@@ -84,7 +84,7 @@
             instance_p->mUartMutex.lock();
             recvdata = instance_p->mUart.getc();
             instance_p->mUartMutex.unlock();
-            
+
             // Check UART receiving flg
             if( gUART_RCVBUF.is_receive )
             {
@@ -151,6 +151,7 @@
                     gUART_RCVBUF.is_receive = true;
                 }
             }
+//            Thread::yield();
         }
         Thread::yield();
     }
--- a/YDwifi/YDwifiUartCommand.cpp	Thu Mar 13 10:33:18 2014 +0000
+++ b/YDwifi/YDwifiUartCommand.cpp	Fri Mar 14 08:48:12 2014 +0000
@@ -51,6 +51,7 @@
 int C_YDwifiUartCommand::wait()
 {
     int ret = 0;
+
     // Get thread ID
     mCommandThreadID = osThreadGetId();
     
@@ -60,13 +61,14 @@
     {
         ret = -1;
     }
+
     return ret;
 }
 
 int C_YDwifiUartCommand::signal()
 {
     // set signal
-    return osSignalSet(mCommandThreadID, UART_COMMAND_SIGNAL);;
+    return osSignalSet(mCommandThreadID, UART_COMMAND_SIGNAL);
 }
 
 bool C_YDwifiUartCommand::isWaitingCommand( unsigned int command_id, unsigned char *payload_p )
@@ -89,11 +91,16 @@
     }
     
     tagSCAN_RESULT_T scan_result;
-    int            ap_count  = payload_p[2];
+    int ap_count  = payload_p[2];
+    
+    if( ap_count == 0 )
+    {
+        mScanResultHandler_p( NULL );
+    }
+    
     unsigned char *ap_info_p = &payload_p[3];
     int ap_info_idx = 0;
-    
-    printf("%d\r\n", ap_count);
+
     for( int i = 0; i < ap_count; i++ )
     {
         scan_result.channel = ap_info_p[ap_info_idx];
--- a/YDwifi/YDwifiUartCommand.h	Thu Mar 13 10:33:18 2014 +0000
+++ b/YDwifi/YDwifiUartCommand.h	Fri Mar 14 08:48:12 2014 +0000
@@ -20,6 +20,7 @@
 /** Scan result 
 */
 typedef struct {
+    bool          is_complete;
     /** Channel */
     unsigned char channel;
     /** RSSI */
--- a/YDwifi/YDwifi_uartmsg.cpp	Thu Mar 13 10:33:18 2014 +0000
+++ b/YDwifi/YDwifi_uartmsg.cpp	Fri Mar 14 08:48:12 2014 +0000
@@ -1,5 +1,7 @@
 #include "YDwifi_uartmsg.h"
 
+using namespace murata_wifi;
+
 C_YD_UartMsg::C_YD_UartMsg()
 {
 }
--- a/YDwifi/YDwifi_uartmsg.h	Thu Mar 13 10:33:18 2014 +0000
+++ b/YDwifi/YDwifi_uartmsg.h	Fri Mar 14 08:48:12 2014 +0000
@@ -5,6 +5,9 @@
 #include "rtos.h"
 #include "RawSerial.h"
 
+namespace murata_wifi
+{
+
 #define UART_CMD_SOM        0x02
 #define UART_CMD_EOM        0x04
 #define UART_CMD_ESC        0x10
@@ -119,4 +122,5 @@
 protected:
 
 };
+}
 #endif /* _YD_WIFI_UART_MSG_H_ */
\ No newline at end of file
--- a/YDwifiInterface.cpp	Thu Mar 13 10:33:18 2014 +0000
+++ b/YDwifiInterface.cpp	Fri Mar 14 08:48:12 2014 +0000
@@ -267,13 +267,11 @@
         strcpy( (char *)req.ssid, ssid_p );
         buf_len += strlen(ssid_p);
     }
-    else
-    {
-        buf_len++;
-    }
-    
+    buf_len++;
+
     // Make command payload
     payload_len = C_YD_UartMsg::makePayload( buf_len, (unsigned char *)&req, payload_array );
+
     // Make all command request
     command_len = C_YD_UartMsg::makeRequest( UART_CMD_ID_WIFI, payload_array, payload_len, command_array );
 
@@ -286,7 +284,7 @@
     
     // Send uart command request
     sendUart( command_len, command_array );
-    
+
     // Wait UART response
     ret = mUartCommand.wait();
     printf( "scan wait:%d\r\n", ret );
@@ -302,6 +300,7 @@
         printf("scan status:%02x\r\n", mUartCommand.getCommandStatus());
         ret = -1;
     }
+
     gMEMPOOL_PAYLOAD.free( payload_buf );
 
     return ret;
--- a/YDwifiInterface.h	Thu Mar 13 10:33:18 2014 +0000
+++ b/YDwifiInterface.h	Fri Mar 14 08:48:12 2014 +0000
@@ -74,6 +74,7 @@
         @note   This function is blocked until a returns.
                 When you use it by UI thread, be careful. 
                 Scan results will be notified by asynchronous callback function.
+                If there is no continuity data, result_handler_p will be set NULL..
     */
     int scan( const char *ssid_p, unsigned char *bssid_p
             ,void (*result_handler_p)(tagSCAN_RESULT_T *scan_result) );