SensorModelDataCollector/src/com/clarkson/sensormodeldatacollector/WiFiScanActivity.java
/** 
	 * Called from within the registered system broadcast receiver 
	 * to handle a completed wifi scan's results
	 * 
	 * This method iterates through the wifi AP scan results and creates WiFiScanResult objects.
	 * These objects are added to a HashSet, duplicates are removed, and added to the array list
	 * that is connected to the Activity list view through our custom adapter.
	 */
Called from within the registered system broadcast receiver
to handle a completed wifi scan's results

This method iterates through the wifi AP scan results and creates WiFiScanResult objects.
These objects are added to a HashSet, duplicates are removed, and added to the array list
that is connected to the Activity list view through our custom adapter.
Called from within the registered system broadcast receiver to handle a completed wifi scan ' s results This method iterates through the wifi AP scan results and creates WiFiScanResult objects . These objects are added to a HashSet duplicates are removed and added to the array list that is connected to the Activity list view through our custom adapter .
public void handleScanResults()
	{    	
		Log.d(getLocalClassName(), "Step 4");
		mNumberOfScansCounter++;
		Toast.makeText(this, "Scanning...Scan #"+mNumberOfScansCounter, Toast.LENGTH_SHORT).show();
		Log.d(getLocalClassName(), "STEP 5A: scan #" + mNumberOfScansCounter);
		try 
		{
			mWifiManagerScanResultsCount = mWifiManagerScanResultsCount - 1;
			while (mWifiManagerScanResultsCount >= 0) 
			{   
				WiFiScanResult scan_result_item = new WiFiScanResult();
				scan_result_item.setSSID(mWifiManagerScanResults.get(mWifiManagerScanResultsCount).SSID);
				scan_result_item.setRSS(mWifiManagerScanResults.get(mWifiManagerScanResultsCount).level, SystemClock.uptimeMillis()-mMillisecondsSinceBoot, getCurrentTimeString());
				scan_result_item.setMac_address(mWifiManagerScanResults.get(mWifiManagerScanResultsCount).BSSID);
				scan_result_item.setFrequency(mWifiManagerScanResults.get(mWifiManagerScanResultsCount).frequency);
                if(this.mSSIDFilterEnabled == true) {
                    Log.d(getLocalClassName(), "SSID: " + scan_result_item.getSSID());
                    Log.d(getLocalClassName(), "SSID Filter: " + this.mSSIDFilter + "*");
                    if (scan_result_item.getSSID().matches(this.mSSIDFilter + "(.*)")) {
                        mScanResultsHashMap.addItem(scan_result_item);
                    }
                }
                else
                {
                    mScanResultsHashMap.addItem(scan_result_item);
                }
				mScanResultsArrayList.clear();                                
				mScanResultsArrayList.addAll(mScanResultsHashMap.values());
				Collections.sort(mScanResultsArrayList);
				mWifiManagerScanResultsCount--;
				mWifiScanResultAdapter.notifyDataSetChanged();
				Log.d(getLocalClassName(), "Step 6.2: (Size= " + mScanResultsArrayList.size());
			}
		}
		catch (Exception e)
		{ 
			Log.d(getLocalClassName(), "Step 6.2A: Errors");
		}
	}
public void handleScanResults ( ) { Log . d ( getLocalClassName ( ) , "Step 4" ) ; mNumberOfScansCounter ++ ; Toast . makeText ( this , "Scanning...Scan #" + mNumberOfScansCounter , Toast . LENGTH_SHORT ) . show ( ) ; Log . d ( getLocalClassName ( ) , "STEP 5A: scan #" + mNumberOfScansCounter ) ; try { mWifiManagerScanResultsCount = mWifiManagerScanResultsCount - 1 ; while ( mWifiManagerScanResultsCount >= 0 ) { WiFiScanResult scan_result_item = new WiFiScanResult ( ) ; scan_result_item . setSSID ( mWifiManagerScanResults . get ( mWifiManagerScanResultsCount ) . SSID ) ; scan_result_item . setRSS ( mWifiManagerScanResults . get ( mWifiManagerScanResultsCount ) . level , SystemClock . uptimeMillis ( ) - mMillisecondsSinceBoot , getCurrentTimeString ( ) ) ; scan_result_item . setMac_address ( mWifiManagerScanResults . get ( mWifiManagerScanResultsCount ) . BSSID ) ; scan_result_item . setFrequency ( mWifiManagerScanResults . get ( mWifiManagerScanResultsCount ) . frequency ) ; if ( this . mSSIDFilterEnabled == true ) { Log . d ( getLocalClassName ( ) , "SSID: " + scan_result_item . getSSID ( ) ) ; Log . d ( getLocalClassName ( ) , "SSID Filter: " + this . mSSIDFilter + "*" ) ; if ( scan_result_item . getSSID ( ) . matches ( this . mSSIDFilter + "(.*)" ) ) { mScanResultsHashMap . addItem ( scan_result_item ) ; } } else { mScanResultsHashMap . addItem ( scan_result_item ) ; } mScanResultsArrayList . clear ( ) ; mScanResultsArrayList . addAll ( mScanResultsHashMap . values ( ) ) ; Collections . sort ( mScanResultsArrayList ) ; mWifiManagerScanResultsCount -- ; mWifiScanResultAdapter . notifyDataSetChanged ( ) ; Log . d ( getLocalClassName ( ) , "Step 6.2: (Size= " + mScanResultsArrayList . size ( ) ) ; } } catch ( Exception e ) { Log . d ( getLocalClassName ( ) , "Step 6.2A: Errors" ) ; } }
Called from within the registered system broadcast receiver
 to handle a completed wifi scan's results
Called from within the registered system broadcast receiver to handle a completed wifi scan ' s results
//Increase the scan counter
 //Alert user what the current scan number is so he/she knows wifi scans are continuing to complete successfully
 //Log our current scan count
 //Scan results are 0 indexed, so subtract one for our while
 //Loop through the scan results and add them to our array list
 //Need to utilize hash functionality and update RSS/keep history
 //HashMap<String, String> item = new HashMap<String, String>();              	
 //item.put(ITEM_KEY, results.get(size).SSID + "  " + results.get(size).capabilities);
 //Set the SSID (Name) for the scan result
 //Set the RSS (signal strength level) and timestamp normalized to program start time
 //Set the BSSID (Mac Address)
 //Set the frequency
 //Log the scan result fields
 //Log.d(getLocalClassName(), "STEP 5B: " + scan_result_item.printMe());
 //Add the scan result item to the results Array List only if matches SSID filter
 //if
 //if
 //else
 //mScanResultsArrayList.add(scan_result_item);
 //Use a hash set to remove duplicates
 //HashSet<WiFiScanResult> duplicate_filter = new HashSet<WiFiScanResult>();
 //duplicate_filter.addAll(mScanResultsArrayList);
 //while 
 //try
 //catch
