I try to make an application that will calculate the signal strenth of my wifi, or 3g and let the user know about his distance from that access point. For instance, I have here a sample of my code that will calculate the distance, in kilometers, between device and a wifi access point:
public double calculateDistance(double signalLevelInDb, double freqInMHz)
{
double exp = (27.55 - (20 * Math.log10(freqInMHz)) + Math.abs(signalLevelInDb)) / 20.0;
return Math.pow(10.0, exp);
}
but, when i call the function in android studio, I don't know how to calculate the signalLevelInDb
(=dbm) and freqInMhz
(=mHz) so I can send them to the function to display my distance. How can I make android studio give me these 2 values? Can I use the same function for the 3g and how?