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.
IntensityScanner.cpp
00001 #include "IntensityScanner.h" 00002 00003 IntensityScanner::IntensityScanner (PinName cc3000_irq, 00004 PinName cc3000_en, 00005 PinName cc3000_cs, 00006 SPI cc3000_spi, const char* SSID, const char* key, mbed_cc3000::Security sec, bool smart_config, uint32_t timeout) : wifi(cc3000_irq, cc3000_en, 00007 cc3000_cs, cc3000_spi, SSID, key, sec, smart_config), timeout(timeout) { 00008 wifi.init(); 00009 /* 00010 const unsigned long intervalTime[16] = { 2000, 2000, 2000, 2000, 2000, 00011 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000 }; 00012 */ 00013 00014 /*wifi._wlan.ioctl_set_scan_params(timeout, 20, 30, 5, 00015 0x7ff, -80, 0, 205, (uint32_t*) intervalTime); 00016 */ 00017 const unsigned long intervalTime[16] = { 200, 200, 200, 200, 200, 00018 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200 }; 00019 wifi._wlan.ioctl_set_scan_params(timeout, 20, 30, 5, 00020 0x400, -80, 0, 205, (uint32_t*) intervalTime); 00021 00022 }; 00023 00024 00025 int IntensityScanner::rssi_for_ssid (const char* ssid, uint8_t* rssi) { 00026 00027 uint8_t scan_buffer[50]; 00028 uint8_t rssi_field, ssid_length_field, ssid_length; 00029 char* measured_ssid_name; 00030 00031 int found_match = 0; 00032 while (!found_match 00033 && wifi._wlan.ioctl_get_scan_results(1000, scan_buffer) == 0) { 00034 00035 rssi_field = scan_buffer[8]; 00036 ssid_length_field = scan_buffer[9]; 00037 ssid_length = ssid_length_field & (0x3F); 00038 00039 measured_ssid_name = (char*) malloc(sizeof(char) * (ssid_length+1)); 00040 memcpy(measured_ssid_name, scan_buffer + 12, ssid_length); 00041 measured_ssid_name[ssid_length] = '\0'; 00042 00043 if (strcmp(ssid, measured_ssid_name) == 0) { 00044 00045 *rssi = (rssi_field & 0x7f); 00046 found_match = 1; 00047 } 00048 00049 free(measured_ssid_name); 00050 } 00051 00052 return found_match ? 0 : 1; 00053 }
Generated on Wed Jul 13 2022 12:36:27 by
1.7.2