1 /* 2 * Copyright (C) 2020 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 #pragma once 18 #include <vector> 19 #include "data_sink.h" 20 21 namespace goldfish { 22 using ::android::hardware::hidl_bitfield; 23 24 class GnssHwListener { 25 public: 26 explicit GnssHwListener(const DataSink* sink); 27 void reset(); 28 void consume(char); 29 30 private: 31 bool parse(const char* begin, const char* end, 32 const ahg10::GnssUtcTime& t, 33 const ahg20::ElapsedRealtime& ert); 34 bool parseGPRMC(const char* begin, const char* end, 35 const ahg10::GnssUtcTime& t, 36 const ahg20::ElapsedRealtime& ert); 37 bool parseGPGGA(const char* begin, const char* end, 38 const ahg10::GnssUtcTime& t, 39 const ahg20::ElapsedRealtime& ert); 40 41 const DataSink* m_sink; 42 std::vector<char> m_buffer; 43 44 double m_altitude = 0; 45 46 hidl_bitfield<ahg10::GnssLocationFlags> m_flags; 47 }; 48 49 } // namespace goldfish 50