Browse Source

initial commit

master
Jared Dunbar 4 years ago
commit
a307126c3c
Signed by: jared GPG Key ID: CF202CC859BAC692
  1. 8
      .gitignore
  2. 5
      src/org/ja13/Band.java
  3. 12
      src/org/ja13/Main.java
  4. 207
      src/org/ja13/util/RF.java

8
.gitignore

@ -0,0 +1,8 @@
# idea
.idea/
*.iml
# other
/out
/build
/run

5
src/org/ja13/Band.java

@ -0,0 +1,5 @@
package org.ja13;
public enum Band {
f24GHz, f5GHz
}

12
src/org/ja13/Main.java

@ -0,0 +1,12 @@
package org.ja13;
import org.ja13.util.RF;
public class Main {
public static void main(String[] args) {
System.out.println("Hello!");
double thing = RF.calculateDistance(-30, -59, 2437, 0, 0, 2.2, 2.2, 0);
System.out.println(thing);
}
}

207
src/org/ja13/util/RF.java

@ -0,0 +1,207 @@
package org.ja13.util;
import org.ja13.Band;
public class RF {
public static double channelToCenterMHZ(Band band, int channel) {
if (band == Band.f24GHz) {
switch (channel) {
case 1:
return 2412;
case 2:
return 2417;
case 3:
return 2422;
case 4:
return 2427;
case 5:
return 2432;
case 6:
return 2437;
case 7:
return 2442;
case 8:
return 2447;
case 9:
return 2452;
case 10:
return 2457;
case 11:
return 2462;
case 12:
return 2467;
case 13:
return 2472;
case 14:
return 2484;
default:
return 0;
}
}else if (band == Band.f5GHz) {
switch (channel) {
case 7:
return 5035;
case 8:
return 5040;
case 9:
return 5045;
case 11:
return 5055;
case 12:
return 5060;
case 16:
return 5080;
case 32:
return 5160;
case 34:
return 5170;
case 36:
return 5180;
case 38:
return 5190;
case 40:
return 5200;
case 42:
return 5210;
case 44:
return 5220;
case 46:
return 5230;
case 48:
return 5240;
case 50:
return 5250;
case 52:
return 5260;
case 54:
return 5270;
case 56:
return 5280;
case 58:
return 5290;
case 60:
return 5300;
case 62:
return 5310;
case 64:
return 5320;
case 68:
return 5340;
case 96:
return 5480;
case 100:
return 5500;
case 102:
return 5510;
case 104:
return 5520;
case 106:
return 5530;
case 108:
return 5540;
case 110:
return 5550;
case 112:
return 5560;
case 114:
return 5570;
case 116:
return 5580;
case 118:
return 5590;
case 120:
return 5600;
case 122:
return 5610;
case 124:
return 5620;
case 126:
return 5630;
case 128:
return 5640;
case 132:
return 5660;
case 134:
return 5670;
case 136:
return 5680;
case 138:
return 5690;
case 140:
return 5700;
case 142:
return 5710;
case 144:
return 5720;
case 149:
return 5745;
case 153:
return 5765;
case 155:
return 5775;
case 157:
return 5785;
case 159:
return 5795;
case 161:
return 5805;
case 165:
return 5825;
case 169:
return 5845;
case 173:
return 5865;
case 183:
return 4915;
case 184:
return 4920;
case 185:
return 4925;
case 187:
return 4935;
case 188:
return 4940;
case 189:
return 4945;
case 192:
return 4960;
case 196:
return 4980;
default:
return 0;
}
} else {
return 0.0f;
}
}
/*
https://stackoverflow.com/questions/11217674/how-to-calculate-distance-from-wifi-router-using-signal-strength
K = 32.44
FSPL = Ptx - CLtx + AGtx + AGrx - CLrx - Prx - FM
d = 10 ^ (( FSPL - K - 20 log10( f )) / 20 )
K - constant (32.44, when f in MHz and d in km, change to -27.55 when f in MHz and d in m)
FSPL - Free Space Path Loss
Ptx - transmitter power, dBm ( up to 20 dBm (100mW) )
CLtx, CLrx - cable loss at transmitter and receiver, dB ( 0, if no cables )
AGtx, AGrx - antenna gain at transmitter and receiver, dBi
Prx - receiver sensitivity, dBm ( down to -100 dBm (0.1pW) )
FM - fade margin, dB ( more than 14 dB (normal) or more than 22 dB (good))
f - signal frequency, MHz
d - distance, m or km (depends on value of K)
*/
public static double calculateDistance(double transmitPower, double recievePower, double frequency) {
return calculateDistance(transmitPower, recievePower, frequency, 0, 0 ,0 ,0 ,0);
}
public static double calculateDistance(double transmitPower, double recievePower, double frequency, double cltx, double clrx, double agtx, double agrx, double fm) {
double K = -27.55;
return Math.pow(10, ((transmitPower - cltx + agtx + agrx - clrx - recievePower - fm - K - (20 * Math.log10(frequency)))/20));
}
}
Loading…
Cancel
Save