Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: SNICInterface mbed-rtos mbed
Fork of SNIC-xively-jumpstart-demo by
Diff: main.cpp
- Revision:
- 30:de5a32932408
- Parent:
- 29:9f08c7152c7a
- Child:
- 31:c42d189364b4
diff -r 9f08c7152c7a -r de5a32932408 main.cpp
--- a/main.cpp Wed Apr 01 23:05:11 2015 +0000
+++ b/main.cpp Thu Apr 02 06:03:05 2015 +0000
@@ -35,6 +35,20 @@
C_SNIC_WifiInterface wifi( D1, D0, NC, NC, D3 );
+
+void scanCallbackFn(tagSCAN_RESULT_T *scan_result)
+{
+ printf("\r\n");
+ printf("channel = %d \r\n" ,scan_result->channel);
+ printf("rssi = %d \r\n" ,scan_result->rssi);
+ printf("security = %d \r\n" ,scan_result->security);
+ printf("bssid = %x%x%x%x%x%x\r\n",scan_result->bssid[0],scan_result->bssid[1],scan_result->bssid[2],scan_result->bssid[3],scan_result->bssid[4],scan_result->bssid[5]);
+ printf("network_type = %d \r\n" ,scan_result->network_type);
+ printf("max_rate = %d \r\n" ,scan_result->max_rate);
+ printf("ssid = %s \r\n" ,scan_result->ssid);
+}
+
+
int main()
{
// for built in debug printouts
@@ -82,16 +96,49 @@
} else {
printf("SetIPConfig successful \r\n");
}
-
+
// Get RSSI
signed char temp = 0;
check = wifi.getRssi(&temp);
- if(check != 0){
+ if(check != 0) {
printf("getRssi failed. \r\n");
- }else{
+ } else {
printf("getRssi success: %d \r\n",temp);
}
-
+
+ // check IP Address
+ char * ip ;
+ ip = wifi.getIPAddress();
+ if(ip == 0) {
+ printf("getIP failed. \r\n");
+ } else {
+ printf("getIP success: %s \r\n",ip);
+ }
+
+ // get wifi status
+ tagWIFI_STATUS_T status;
+ check = wifi.getWifiStatus(&status);
+ if(check != 0) {
+ printf("getWifiStatus failed \r\n");
+ } else {
+ // Status 0=WifiOff, 1=No Network, 2=Connected to AP, 3=Started AP mode
+ printf("getWifiStatus success: status =%d, MAC = %x%x%x%x%x%x, SSID = %s \r\n",
+ status.status,
+ status.mac_address[0], status.mac_address[1],
+ status.mac_address[2], status.mac_address[3],
+ status.mac_address[4], status.mac_address[5],
+ status.ssid );
+ }
+
+ // scan for wifi
+ check = wifi.scan(NULL,NULL,scanCallbackFn);
+ if(check != 0) {
+ printf("scan failed! \r\n");
+ } else {
+ printf("Scan Success! \r\n");
+
+ }
+
// if(check != 0){
// printf(" \r\n");
// }else{
