Skip to content

Draft: Limit wifi cache key length

Teemu Ikonen requested to merge tpikonen/geoclue:wifi-cache into master

Implements cache key length limiting I outlined a while back. To summarize, generate the cache key with this algorithm:

  • Sort scan results by signal strength and take CACHE_KEY_MAX_LEN (== 4) strongest signals
  • Sort these again by BSSID to be slightly more stable
  • Quantize the signal strength by CACHE_DBM_BIN_WIDTH (== 10)

Also, add a debug msg after a scan result with no new APs and remove duplicate code by moving it to gclue-utils.c (renamed from gclue-nmea-utils.c).

My initial testing on a location with lowish wifi density shows cache hit rates of about 50% before and about 90% after this patch. Test time was 10 to 20 hours with scans every 10 s.

The best cache hit rate for a stationary receiver is obviously achieved with a cache key length of zero, so more testing with scan results from varying locations and limiting the MLS query strings to contain N strongest signals is needed to determine the optimal value for CACHE_KEY_MAX_LEN.

Merge request reports