1 /*
2 * Copyright (C) 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #define LOG_TAG "GnssMeasurementCorrections"
18
19 #include "GnssMeasurementCorrections.h"
20 #include <log/log.h>
21
22 namespace android {
23 namespace hardware {
24 namespace gnss {
25 namespace measurement_corrections {
26 namespace V1_1 {
27 namespace implementation {
28
29 // Methods from V1_0::IMeasurementCorrections follow.
setCorrections(const V1_0::MeasurementCorrections & corrections)30 Return<bool> GnssMeasurementCorrections::setCorrections(
31 const V1_0::MeasurementCorrections& corrections) {
32 ALOGD("setCorrections");
33 ALOGD("corrections = lat: %f, lng: %f, alt: %f, hUnc: %f, vUnc: %f, toa: %llu, "
34 "satCorrections.size: %d",
35 corrections.latitudeDegrees, corrections.longitudeDegrees, corrections.altitudeMeters,
36 corrections.horizontalPositionUncertaintyMeters,
37 corrections.verticalPositionUncertaintyMeters,
38 static_cast<unsigned long long>(corrections.toaGpsNanosecondsOfWeek),
39 static_cast<int>(corrections.satCorrections.size()));
40 for (auto singleSatCorrection : corrections.satCorrections) {
41 ALOGD("singleSatCorrection = flags: %d, constellation: %d, svid: %d, cfHz: %f, probLos: %f,"
42 " epl: %f, eplUnc: %f",
43 static_cast<int>(singleSatCorrection.singleSatCorrectionFlags),
44 static_cast<int>(singleSatCorrection.constellation),
45 static_cast<int>(singleSatCorrection.svid), singleSatCorrection.carrierFrequencyHz,
46 singleSatCorrection.probSatIsLos, singleSatCorrection.excessPathLengthMeters,
47 singleSatCorrection.excessPathLengthUncertaintyMeters);
48 ALOGD("reflecting plane = lat: %f, lng: %f, alt: %f, azm: %f",
49 singleSatCorrection.reflectingPlane.latitudeDegrees,
50 singleSatCorrection.reflectingPlane.longitudeDegrees,
51 singleSatCorrection.reflectingPlane.altitudeMeters,
52 singleSatCorrection.reflectingPlane.azimuthDegrees);
53 }
54
55 return true;
56 }
57
setCallback(const sp<V1_0::IMeasurementCorrectionsCallback> & callback)58 Return<bool> GnssMeasurementCorrections::setCallback(
59 const sp<V1_0::IMeasurementCorrectionsCallback>& callback) {
60 using Capabilities = V1_0::IMeasurementCorrectionsCallback::Capabilities;
61 auto ret =
62 callback->setCapabilitiesCb(Capabilities::LOS_SATS | Capabilities::EXCESS_PATH_LENGTH |
63 Capabilities::REFLECTING_PLANE);
64 if (!ret.isOk()) {
65 ALOGE("%s: Unable to invoke callback", __func__);
66 return false;
67 }
68 return true;
69 }
70
71 // Methods from V1_1::IMeasurementCorrections follow.
setCorrections_1_1(const V1_1::MeasurementCorrections & corrections)72 Return<bool> GnssMeasurementCorrections::setCorrections_1_1(
73 const V1_1::MeasurementCorrections& corrections) {
74 ALOGD("setCorrections_1_1");
75 ALOGD("corrections = lat: %f, lng: %f, alt: %f, hUnc: %f, vUnc: %f, toa: %llu,"
76 "satCorrections.size: %d, hasEnvironmentBearing: %d, environmentBearingDeg: %f,"
77 "environmentBearingUncDeg: %f",
78 corrections.v1_0.latitudeDegrees, corrections.v1_0.longitudeDegrees,
79 corrections.v1_0.altitudeMeters, corrections.v1_0.horizontalPositionUncertaintyMeters,
80 corrections.v1_0.verticalPositionUncertaintyMeters,
81 static_cast<unsigned long long>(corrections.v1_0.toaGpsNanosecondsOfWeek),
82 static_cast<int>(corrections.v1_0.satCorrections.size()),
83 corrections.hasEnvironmentBearing, corrections.environmentBearingDegrees,
84 corrections.environmentBearingUncertaintyDegrees);
85 for (auto singleSatCorrection : corrections.satCorrections) {
86 ALOGD("singleSatCorrection = flags: %d, constellation: %d, svid: %d, cfHz: %f, probLos: %f,"
87 " epl: %f, eplUnc: %f",
88 static_cast<int>(singleSatCorrection.v1_0.singleSatCorrectionFlags),
89 static_cast<int>(singleSatCorrection.constellation),
90 static_cast<int>(singleSatCorrection.v1_0.svid),
91 singleSatCorrection.v1_0.carrierFrequencyHz, singleSatCorrection.v1_0.probSatIsLos,
92 singleSatCorrection.v1_0.excessPathLengthMeters,
93 singleSatCorrection.v1_0.excessPathLengthUncertaintyMeters);
94 ALOGD("reflecting plane = lat: %f, lng: %f, alt: %f, azm: %f",
95 singleSatCorrection.v1_0.reflectingPlane.latitudeDegrees,
96 singleSatCorrection.v1_0.reflectingPlane.longitudeDegrees,
97 singleSatCorrection.v1_0.reflectingPlane.altitudeMeters,
98 singleSatCorrection.v1_0.reflectingPlane.azimuthDegrees);
99 }
100
101 return true;
102 }
103
104 } // namespace implementation
105 } // namespace V1_1
106 } // namespace measurement_corrections
107 } // namespace gnss
108 } // namespace hardware
109 } // namespace android
110