Skip to content

Commit

Permalink
Improve the AGC key used for GLONASS
Browse files Browse the repository at this point in the history
  • Loading branch information
christianrowlands committed Nov 17, 2023
1 parent c7ca418 commit 913c900
Showing 1 changed file with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import android.location.GnssStatus;

import com.craxiom.networksurvey.util.CarrierFreqUtils;
import com.craxiom.networksurvey.util.MathUtils;

import java.util.Objects;

/**
Expand All @@ -10,18 +13,18 @@
public class ConstellationFreqKey
{
private final int constellationType;
private final long carrierFrequencyTrimmed;
private final String carrierFrequencyNormalized;
private final int hash;

public ConstellationFreqKey(int constellationType, long carrierFrequency)
public ConstellationFreqKey(int constellationType, long carrierFrequencyHz)
{
this.constellationType = constellationType;
if (constellationType == GnssStatus.CONSTELLATION_GLONASS)
{
// GLONASS frequencies have a pretty wide range, so we trim them down to 10 MHz bins
// Even this is not enough, but I am nervous going any farther. For example, here
// are the results of GNSS measurement scan, and the AGC class on a Pixel 8 Pro. Notice
// that the carier freq ranges from 1598062464 to 1605374976 and they all have the same AGC.
// GLONASS frequencies have a pretty wide range, so we use the band label instead.
// For example, here are the results of GNSS measurement scan, and the AGC class on a
// Pixel 8 Pro. Notice that the carrier freq ranges from 1598062464 to 1605374976 and
// they all have the same AGC.
//
// GnssMeasurement: Constellation=GLONASS, CarrierFreq=1598062464, AGC=47.18083190917969
// GnssMeasurement: Constellation=GLONASS, CarrierFreq=1600312448, AGC=47.18083190917969
Expand All @@ -34,12 +37,12 @@ public ConstellationFreqKey(int constellationType, long carrierFrequency)
// GnssMeasurement: Constellation=GLONASS, CarrierFreq=1605374976, AGC=47.18083190917969
//
// GnssAutomaticGainControl: Constellation=GLONASS, CarrierFreq=1602000000, AGC=46.839942932128906
carrierFrequencyTrimmed = carrierFrequency / 10_000_000;
carrierFrequencyNormalized = CarrierFreqUtils.getCarrierFrequencyLabel(GnssType.GLONASS, -1, MathUtils.toMhz(carrierFrequencyHz));
} else
{
carrierFrequencyTrimmed = carrierFrequency / 1_000;
carrierFrequencyNormalized = String.valueOf(carrierFrequencyHz / 1_000);
}
hash = Objects.hash(constellationType, carrierFrequencyTrimmed);
hash = Objects.hash(constellationType, carrierFrequencyNormalized);
}

@Override
Expand All @@ -48,7 +51,7 @@ public boolean equals(Object o)
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ConstellationFreqKey that = (ConstellationFreqKey) o;
return carrierFrequencyTrimmed == that.carrierFrequencyTrimmed && constellationType == that.constellationType;
return carrierFrequencyNormalized == that.carrierFrequencyNormalized && constellationType == that.constellationType;
}

@Override
Expand Down

0 comments on commit 913c900

Please sign in to comment.