2

I'm writing an android application which purpouse is to determine the user position via a wifi fingerprint, and in order to do that i need to get really frequent (as frequent as possible) scansions of present networks but I've found time limitations to do that.

In fact, no matter what, I can get a new scan roughtly every second and I was wondering if there could be a way to speed things up.

Past questions on the topic (as this one Android, wifi active scans) were not really useful.

here's the code:

public class WiFiScanReceiver extends BroadcastReceiver {
    private static final String TAG = "WiFiScanReceiver";
    private Main parent;
    private ScanResult storedBest;
    private String actualFileName;
    private int nOfScans;
    private long initialTime;
    private FileSaver fs;

    public WiFiScanReceiver(Main wifiDemo) {
        super();
        this.parent = wifiDemo;
        storedBest = null;
        actualFileName ="";
        nOfScans = 0;
        fs = new FileSaver(parent);
    }

    @Override
    public void onReceive(Context c, Intent intent) {
        List<ScanResult> results = parent.getWifiManager().getScanResults();
        ScanResult bestSignal = null;
        if(parent.isRecording()&& actualFileName!=""){

        //Getting the fingerprint
        }

        if (parent.isRecording()) nOfScans ++;
        parent.getWifiManager().startScan();
        Log.d(TAG, "onReceive() message: " + message);
    }
    //VARIOUS GETTERs AND SETTERs

}
Community
  • 1
  • 1
lucretiusT
  • 45
  • 1
  • 10
  • how are you getting user position? Can we see code? – Ian Nov 01 '11 at 16:09
  • I'm planning to get the position by comparing the wifi fingerprint (RSSI + BSSID) against a database of known fingerprints. I'm gonna use this method in order the increase the precision of a localization proces based on the devices sensors. I don't have the code for the localization process in my possession right now. – lucretiusT Nov 01 '11 at 16:14

3 Answers3

2

There is a limit on how many scans you can get per unit of time. An access point broadcasts a beacon roughly every 100 ms, so that is the time you need to wait to be sure to detect it. There are 12 frequency channels so you have to spend at least 100ms*12 = 1.2s in order to be sure that you have all the access points. Anything below that will be inaccurate.

chopchop
  • 1,905
  • 2
  • 22
  • 37
1

I also try to determine the user position via a wifi fingerprint.

On my device(Galaxy S2),I can get one scan result per six seconds. I used active scan,but there is no change of the interval between two wifi scans. But on my friend's device(HTC Desire),I can get one scan result every second.(using same code)

I think scan speed depends on device.

If you can get scan result frequently, please tell me.

RyoM
  • 11
  • 1
  • I'm working on a HTC Desire HD and I can get different results every second, but my experience, as yours, points to the fact that there's no way to override the hardcoded device maximun frequency of scans, and that frequenct greatly varies on device basis. – lucretiusT Dec 08 '11 at 13:59
0

This code can find the location via WIFI + GPS (GPS alone is slow):

Finding current location works when using Wifi, but fails when using GPS

But on the other hand, u can consider other option as listed here:

Android : How may ways I can get current location programatically

Community
  • 1
  • 1
Peter Teoh
  • 6,337
  • 4
  • 42
  • 58
  • Thank you, but I can't rely on GPS since the system will mostly be deployed indoor. I can already make an estimation of the position using a known starting position and the sensors output from the that position using kalman filters, but it's not as accurate as i wish. So i need to integrate it with a wifi fingerprint. I've added the code for receiving the wifi data in the first post. – lucretiusT Nov 01 '11 at 16:36