#pragma once

#include <Arduino.h>

namespace field_qa {

enum class FixType : uint8_t {
  NoFix = 0,
  Fix2D,
  Fix3D,
  Dgps,
  RtkFloat,
  RtkFixed
};

struct SatelliteInfo {
  bool valid = false;
  bool usedInSolution = false;
  char talker[3] = {'?', '?', '\0'};
  uint8_t prn = 0;
  uint8_t elevation = 0;
  uint16_t azimuth = 0;
  uint8_t snr = 0;
};

struct GnssSample {
  bool sawSentence = false;
  bool validTime = false;
  bool validFix = false;
  bool validLocation = false;
  bool validAltitude = false;
  bool validCourse = false;
  bool validSpeed = false;
  bool validHdop = false;
  bool validVdop = false;
  bool validPdop = false;
  bool ppsSeen = false;

  FixType fixType = FixType::NoFix;
  int fixDimension = 0;
  int satsInView = -1;
  int satsUsed = -1;
  float hdop = -1.0f;
  float vdop = -1.0f;
  float pdop = -1.0f;
  double latitude = 0.0;
  double longitude = 0.0;
  double altitudeM = 0.0;
  float speedMps = -1.0f;
  float courseDeg = -1.0f;

  uint16_t year = 0;
  uint8_t month = 0;
  uint8_t day = 0;
  uint8_t hour = 0;
  uint8_t minute = 0;
  uint8_t second = 0;

  uint8_t gpsCount = 0;
  uint8_t galileoCount = 0;
  uint8_t glonassCount = 0;
  uint8_t beidouCount = 0;
  uint8_t navicCount = 0;
  uint8_t qzssCount = 0;
  uint8_t sbasCount = 0;

  float meanSnr = -1.0f;
  uint8_t maxSnr = 0;
  uint32_t ageOfFixMs = 0;
  uint32_t ttffMs = 0;
  uint32_t longestNoFixMs = 0;
  uint32_t sampleMillis = 0;
};

const char* fixTypeToString(FixType type);
const char* qualityClassForSample(const GnssSample& sample);

}  // namespace field_qa
