demo of the murata wifi chip. This demo tries to connect to an open wifi access point and prints out all the relevant information about the connection. It then scans all wifi access points nearby and reports their information.

Dependencies:   SNICInterface mbed-rtos mbed

Fork of SNIC-xively-jumpstart-demo by muRata

Revision:
29:9f08c7152c7a
Parent:
28:174412ff9671
Child:
30:de5a32932408
--- a/main.cpp	Wed Apr 01 22:37:22 2015 +0000
+++ b/main.cpp	Wed Apr 01 23:05:11 2015 +0000
@@ -22,49 +22,81 @@
 Serial pc(USBTX, USBRX);
 
 
-#define WIFI_SSID                  "AP_SSID"
-#define WIFI_SECURITY_TYPE         e_SEC_WPA2_AES
+#define WIFI_SSID                  "demossid"
+#define WIFI_SECURITY_TYPE         e_SEC_OPEN
 #define WIFI_SECUTIRY_KEY          "WPA2_PASSPHRASE"
 #define WIFI_SECUTIRY_KEY_LEN      15
 
+//#define WIFI_SSID                  "AP_SSID"
+//#define WIFI_SECURITY_TYPE         e_SEC_WPA2_AES
+//#define WIFI_SECUTIRY_KEY          "WPA2_PASSPHRASE"
+//#define WIFI_SECUTIRY_KEY_LEN      15
+
+
 C_SNIC_WifiInterface     wifi( D1, D0, NC, NC, D3 );
 
 int main()
 {
     // for built in debug printouts
-//    pc.baud( 115200 ); 
+//    pc.baud( 115200 );
+
+    int check = 0;
 
     // Initialize Wi-Fi interface
-    if( wifi.init() != 0 ) {
+    check = wifi.init();
+    if( check != 0 ) {
         printf( "Wifi could not be initialized, halting.\r\n" );
         return -1;
-    }else {
+    } else {
         printf("wifi initialized successfully!\r\n");
     }
     wait(0.5);
-    
+
     // good form to make sure you are disconnected from all AP's
-    if( wifi.disconnect() != 0 ) {
+    check = wifi.disconnect();
+    if( check != 0 ) {
         printf( "disconnect failed\r\n" );
         return -1;
-    }else{
+    } else {
         printf("disconnection successful!\r\n");
-        }
+    }
     wait(0.3);
-    
+
     // Connect AP
-    wifi.connect( WIFI_SSID
-                       , strlen(WIFI_SSID)
-                       , WIFI_SECURITY_TYPE
-                       , WIFI_SECUTIRY_KEY
-                       , WIFI_SECUTIRY_KEY_LEN );
-    printf("connect();\r\n");
+    check = wifi.connect( WIFI_SSID
+                          , strlen(WIFI_SSID)
+                          , WIFI_SECURITY_TYPE
+                          , WIFI_SECUTIRY_KEY
+                          , WIFI_SECUTIRY_KEY_LEN );
+    if( check != 0) {
+        printf("Connect Failed\r\n");
+    } else {
+        printf("connected successfully!\r\n");
+    }
     wait(0.5);
 
-    printf("IP Config();\r\n");
-    wifi.setIPConfig( true );
-
-    printf( "done...\n" );
+    // Get DHCP IP
+    check = wifi.setIPConfig( true ); // get IP as DHCP IP
+    if(check != 0) {
+        printf("SetIPConfig failed \r\n");
+    } else {
+        printf("SetIPConfig successful \r\n");
+    }
+    
+    // Get RSSI
+    signed char temp = 0;
+    check = wifi.getRssi(&temp);
+    if(check != 0){
+        printf("getRssi failed. \r\n");
+    }else{
+        printf("getRssi success: %d \r\n",temp);
+    }
+        
+//    if(check != 0){
+//        printf(" \r\n");
+//    }else{
+//        printf(" \r\n");
+//    }
 
     wait( 1.0 );
 }