Skip to content

Commit

Permalink
fix: More robust check for carrier phase and AGC support
Browse files Browse the repository at this point in the history
* Loop through all measurements and check if at least one supports carrier phase and AGC, instead of just checking first measurement
* For carrier phase, device must have ADR_STATE_VALID and a non-zero accumulatedDeltaRangeMeters for it to be "SUPPORTED"

Closes #478
  • Loading branch information
barbeau committed Jan 28, 2021
1 parent 40fe080 commit 70d8ec5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1159,18 +1159,18 @@ public void onGnssMeasurementsReceived(GnssMeasurementsEvent event) {

int agcSupport = PreferenceUtils.CAPABILITY_UNKNOWN;
int carrierPhaseSupport = PreferenceUtils.CAPABILITY_UNKNOWN;
// Loop through all measurements - if at least one supports, then mark as supported
for (GnssMeasurement measurement : event.getMeasurements()) {
if (SatelliteUtils.isAutomaticGainControlSupported(measurement)) {
agcSupport = PreferenceUtils.CAPABILITY_SUPPORTED;
} else {
} else if (agcSupport == PreferenceUtils.CAPABILITY_UNKNOWN) {
agcSupport = PreferenceUtils.CAPABILITY_NOT_SUPPORTED;
}
if (SatelliteUtils.isCarrierPhaseUncertaintySupported(measurement)) {
if (SatelliteUtils.isCarrierPhaseSupported(measurement)) {
carrierPhaseSupport = PreferenceUtils.CAPABILITY_SUPPORTED;
} else {
} else if (carrierPhaseSupport == PreferenceUtils.CAPABILITY_UNKNOWN) {
carrierPhaseSupport = PreferenceUtils.CAPABILITY_NOT_SUPPORTED;
}
break;
}
PreferenceUtils.saveInt(Application.get().getString(R.string.capability_key_measurement_automatic_gain_control), agcSupport);
PreferenceUtils.saveInt(Application.get().getString(R.string.capability_key_measurement_delta_range), carrierPhaseSupport);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,15 +276,17 @@ public static boolean isAutomaticGainControlSupported(GnssMeasurement gnssMeasur
}

/**
* Returns true if carrier phase uncertainty is supported for this GNSS measurement, false if it is not
* Returns true if carrier phase is supported for this GNSS measurement, false if it is not
* @param gnssMeasurement
* @return true if carrier phase uncertainty is supported for this GNSS measurement, false if it is not
* @return true if carrier phase is supported for this GNSS measurement, false if it is not
*/
public static boolean isCarrierPhaseUncertaintySupported(GnssMeasurement gnssMeasurement) {
public static boolean isCarrierPhaseSupported(GnssMeasurement gnssMeasurement) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
return gnssMeasurement.getAccumulatedDeltaRangeState() != GnssMeasurement.ADR_STATE_UNKNOWN;
return gnssMeasurement.getAccumulatedDeltaRangeState() == GnssMeasurement.ADR_STATE_VALID
&& gnssMeasurement.getAccumulatedDeltaRangeMeters() != 0.0d;
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
return gnssMeasurement.hasCarrierFrequencyHz();
return gnssMeasurement.hasCarrierPhase()
&& gnssMeasurement.getCarrierPhase() != 0.0d;
} else {
return false;
}
Expand Down

1 comment on commit 70d8ec5

@webvan1999
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at my logs and don't see "ADR_STATE_VALID" or even "VALID", are you seeing that elsewhere ?

Please sign in to comment.