#ifndef GPS_COMPONENT
#define GPS_COMPONENT

#include "driver/uart.h"
#include "soc/uart_struct.h"
#include "buscfg.h"

// Structure to hold parsed GPS data in a compact binary format
typedef struct {
    uint32_t time_seconds;      // Seconds since start of day
    int32_t latitude_centi_degrees;   // Latitude * 10,000
    int32_t longitude_centi_degrees;  // Longitude * 10,000
    uint8_t fix_quality;
    uint8_t num_satellites;
    int16_t altitude_centi_meters;    // Altitude * 100
    uint16_t date_yyddmm;       // YYDDMM (from GPRMC)
    uint16_t speed_centi_knots;  // Speed * 100 (from GPRMC)
} gps_binary_struct_t;

typedef struct {
    int32_t latitude_centi_degrees;  // Latitude * 10,000
    int32_t longitude_centi_degrees; // Longitude * 10,000
    int16_t altitude_centi_meters; // Altitude * 100
} predicted_binary_position_struct_t;

extern gps_binary_struct_t gpsDataOut;

extern predicted_binary_position_struct_t predictedPosition;

void gps_task(void *arg);
void parse_gpgga(const char *nmea);
void parse_gprmc(const char *nmea);

void parse_gprmc_to_struct(const char *nmea, gps_binary_struct_t *data);
void parse_gpgga_to_struct(const char *nmea, gps_binary_struct_t *data);



#endif