Firefox on Linux sends signal strength to Google geolocation API as a percentage, not RSSI dBm
Categories
(Core :: DOM: Geolocation, defect, P3)
Tracking
()
People
(Reporter: zibri, Assigned: samo.golez, Mentored)
References
Details
(Keywords: good-first-bug)
Attachments
(2 files, 1 obsolete file)
Updated•7 years ago
|
Comment 5•7 years ago
|
||
Comment 6•6 years ago
|
||
I don't have a Linux build environment, but the fix for this bug should be pretty easy. We can convert the signal strength percentage to a fake RSSI value:
https://en.wikipedia.org/wiki/Received_signal_strength_indication
RSSI is the relative received signal strength in a wireless environment, in arbitrary units. RSSI is an indication of the power level being received by the receive radio after the antenna and possible cable loss. Therefore, the higher the RSSI number, the stronger the signal. Thus, when an RSSI value is represented in a negative form (e.g. −100), the closer the value is to 0, the stronger the received signal has been.
In my home, I see strong Wi-Fi signals are about -40 dBm and weak signals are about -80 dBm. So we can just slide the 0-100% value down -100 points to simulate an RSSI value. A 100% signal would be converted to 0 dBm and a 0% signal to -100 dBm in this function:
uint8_t strength;
dbus_message_iter_get_basic(&variant, &strength);
MOZ_ASSERT(strength >= 0 && strength <= 100, "strength should be a percentage");
int fakeRSSI = strength - 100; // [-100, 0] pseudo-dBm
ap->setSignal(fakeRSSI);
(In reply to Chris Peterson [:cpeterson] from comment #6)
I don't have a Linux build environment, but the fix for this bug should be pretty easy. We can convert the signal strength percentage to a fake RSSI value:
https://en.wikipedia.org/wiki/Received_signal_strength_indication
RSSI is the relative received signal strength in a wireless environment, in arbitrary units. RSSI is an indication of the power level being received by the receive radio after the antenna and possible cable loss. Therefore, the higher the RSSI number, the stronger the signal. Thus, when an RSSI value is represented in a negative form (e.g. −100), the closer the value is to 0, the stronger the received signal has been.
In my home, I see strong Wi-Fi signals are about -40 dBm and weak signals are about -80 dBm. So we can just slide the 0-100% value down -100 points to simulate an RSSI value. A 100% signal would be converted to 0 dBm and a 0% signal to -100 dBm in this function:
uint8_t strength; dbus_message_iter_get_basic(&variant, &strength); MOZ_ASSERT(strength >= 0 && strength <= 100, "strength should be a percentage"); int fakeRSSI = strength - 100; // [-100, 0] pseudo-dBm ap->setSignal(fakeRSSI);
Did you read my original post? https://bugzilla.mozilla.org/show_bug.cgi?id=1458624#c0
I wrote it there one year ago!
signalStrenght=(signal_quality / 2 -100)
bzero(&iwrequest, sizeof(struct iwreq)); iwrequest.u.data.pointer = buff; iwrequest.u.data.flags = 0; iwrequest.u.data.length = buffsize; strcpy(iwrequest.ifr_name, wifi_devicename); if (ioctl(iwsd, SIOCGIWRANGE, &iwrequest) < 0) { die(wifi_device_name); } struct iw_range *range = (struct iw_range *)buff; maxqual = range->max_qual.qual;
Comment 8•6 years ago
|
||
Sorry! I read your original comment last year and didn't read it all this time as I was reviewing some old geolocation bugs. The Google Chrome formula you describe is better (and avoids the edge case of sending signalStrength == 0 that might cause unexpected results from the geolocation service).
Assignee | ||
Comment 10•6 years ago
|
||
I think this will be good first bug for me. Can someone assign this to me?
Comment 11•6 years ago
|
||
(In reply to sagudev from comment #10)
I think this will be good first bug for me. Can someone assign this to me?
Hi Samo! Thanks for your help!
Have built and run Firefox on your machine yet? That's the first step. Here are instructions for getting the code and building on Linux:
I can assign the bug to you after you have a patch ready for code review. That's the usual process for first bugs.
Assignee | ||
Comment 12•6 years ago
|
||
I just compiled Firefox and try https://www.w3schools.com/html/tryit.asp?filename=tryhtml5_geolocation
I capture traffic and Firefox only connect to location.services.mozilla.com so is this bug still existing.
Assignee | ||
Comment 13•6 years ago
|
||
I think the problem is that I did not use Google API key.
Assignee | ||
Comment 14•6 years ago
|
||
I have all implemented except max quality. I did some test and it seems it is not needed.
Probably https://developer.gnome.org/NetworkManager/stable/gdbus-org.freedesktop.NetworkManager.AccessPoint.html#gdbus-property-org-freedesktop-NetworkManager-AccessPoint.Strength always use 100 as max quality.
When I ran command: iwconfig wlan0 | grep -i --color quality
and compere dB with first formula (signal_quality / 2 -100) and with second formula ((signal_quality * 100 / max_quality / 2) - 100) it seems that first formula without max quality is more accurate than second formula. Even in chromium they did not calculate with max quality (https://cs.chromium.org/chromium/src/services/device/geolocation/wifi_data_provider_linux.cc?q=/org/freedesktop/NetworkManager&sq=package:chromium&dr=C&l=292).
Assignee | ||
Comment 15•6 years ago
|
||
Comment 16•6 years ago
|
||
(In reply to sagudev from comment #12)
I just compiled Firefox and try https://www.w3schools.com/html/tryit.asp?filename=tryhtml5_geolocation
I capture traffic and Firefox only connect to location.services.mozilla.com so is this bug still existing.
This is expected. At this time, Firefox uses location.services.mozilla.com (Mozilla Location Service aka MLS) instead of Google's location service (aka GLS). You shouldn't need an API key to test with MLS.
(In reply to sagudev from comment #14)
I have all implemented except max quality. I did some test and it seems it is not needed.
Probably https://developer.gnome.org/NetworkManager/stable/gdbus-org.freedesktop.NetworkManager.AccessPoint.html#gdbus-property-org-freedesktop-NetworkManager-AccessPoint.Strength always use 100 as max quality.
When I ran command:
iwconfig wlan0 | grep -i --color quality
and compere dB with first formula (signal_quality / 2 -100) and with second formula ((signal_quality * 100 / max_quality / 2) - 100) it seems that first formula without max quality is more accurate than second formula. Even in chromium they did not calculate with max quality (https://cs.chromium.org/chromium/src/services/device/geolocation/wifi_data_provider_linux.cc?q=/org/freedesktop/NetworkManager&sq=package:chromium&dr=C&l=292).
Interesting. What is the reported max_quality
value? If it is 100, then the first and second formulas should produce the same result. If max_quality
is not 100, then what are the results of the two different formulas?
Comment 17•6 years ago
•
|
||
Assignee | ||
Comment 18•6 years ago
|
||
(In reply to Chris Peterson [:cpeterson] from comment #16)
Interesting. What is the reported
max_quality
value? If it is 100, then the first and second formulas should produce the same result. Ifmax_quality
is not 100, then what are the results of the two different formulas?
I did not checked for reported max_quality in code. I used linux command ´iwconfig Interface-Name-Here´ and result was Link Quality=x/70, so maximum quality is 70.
Assignee | ||
Comment 19•6 years ago
|
||
Also, do you mind resubmitting your patch using Phabricator (Mozilla's code
review server) instead of a .diff patch file? Here are instructions for
creating a Phabricator account and uploading your patch:https://moz-conduit.readthedocs.io/en/latest/phabricator-user.html
OK, I will try.
Assignee | ||
Comment 20•6 years ago
|
||
Comment 21•6 years ago
|
||
(In reply to sagudev from comment #19)
Also, do you mind resubmitting your patch using Phabricator (Mozilla's code
review server) instead of a .diff patch file? Here are instructions for
creating a Phabricator account and uploading your patch:https://moz-conduit.readthedocs.io/en/latest/phabricator-user.html
OK, I will try.
Thanks. Your patch looks good. One small issue: your patch doesn't include your name and email address. You might need to set the username
variable in your ~/.hgrc config file like this:
https://www.mercurial-scm.org/wiki/QuickStart#Setting_a_username
I can fix your patch's username when I check it in. Do you want to be credited with your Bugzilla account's name and email address sagudev <samo.golez@outlook.com>
?
I will run your patch through our Linux tests before checking it in:
https://treeherder.mozilla.org/#/jobs?repo=try&revision=1717bd16412ac9ba5fb911004092299e41045ce4
Assignee | ||
Comment 22•6 years ago
|
||
Thanks. Your patch looks good. One small issue: your patch doesn't include your name and email address. You might need to set the
username
variable in your ~/.hgrc config file like this:https://www.mercurial-scm.org/wiki/QuickStart#Setting_a_username
I can fix your patch's username when I check it in. Do you want to be credited with your Bugzilla account's name and email address
sagudev <samo.golez@outlook.com>
?
Yes, please.
Assignee | ||
Comment 23•6 years ago
|
||
Updated•6 years ago
|
Updated•6 years ago
|
Comment 24•6 years ago
|
||
Comment 25•6 years ago
|
||
I will close this and push data to original one. Sorry for trouble. I'm still learning phabricator.
No problem at all. That's why we have bug mentors to help contributors learn these tools in their first bugs. :)
I see you mentioned arc diff
in a Phabricator comment. I recommend using the moz-phab
script in the future. moz-phab
is a wrapper around arc
that makes uploading new and revised patches easier.
https://moz-conduit.readthedocs.io/en/latest/phabricator-user.html#using-moz-phab
Comment 26•6 years ago
|
||
bugherder |
Assignee | ||
Comment 27•6 years ago
|
||
@cpeterson Thanks for helping me on first bug.
Comment 28•6 years ago
|
||
You're welcome! Thanks for fixing this bug. If you're looking for another bug, check out Mozilla's "Codetribute" website to search for interesting bugs with mentors:
Updated•6 years ago
|
Description
•