GPS - Routing towards DecodeGPSConfig

This commit is contained in:
brentru 2025-06-16 17:03:03 -04:00
parent d17f2b8478
commit b60c23334a
3 changed files with 32 additions and 5 deletions

View file

@ -33,13 +33,37 @@ GPSController::~GPSController() {
}
}
/*!
* @brief Sets a UART hardware interface for the GPS controller.
* @param uart_hardware Pointer to the UARTHardware instance.
* @returns True if the interface was set successfully, False otherwise.
*/
bool GPSController::SetInterface(UARTHardware *uart_hardware) {
if (uart_hardware == nullptr) {
WS_DEBUG_PRINTLN("[gps] ERROR: Provided UART instance is undefined!");
return false;
}
_uart_hardware = uart_hardware;
}
/*!
* @brief Handles GPS configuration messages.
* @param stream A pointer to the pb_istream_t stream.
* @returns True if the GPS configuration was handled successfully, False otherwise.
*/
bool GPSController::Handle_GPSConfig(pb_istream_t *stream) {
// TODO: Implement the logic to handle GPSAdd
WS_DEBUG_PRINTLN("[gps] Decoding GPSConfig message...");
if (!_gps_model->DecodeGPSConfig(stream)) {
WS_DEBUG_PRINTLN("[gps] ERROR: Failed to decode GPSConfig message!");
return false;
}
// NOTE: GPSConfig just stores the commands from IO to send to the GPS device, it does
// not store anything else!
for (pb_size_t i = 0; i < _gps_model->GetGPSConfigMsg()->commands_count; i++) {
WS_DEBUG_PRINT("[gps] Command: ");
WS_DEBUG_PRINTLN(_gps_model->GetGPSConfigMsg()->commands[i]);
}
// TODO: Implement the logic to handle the GPS configuration
return false;
}

View file

@ -20,8 +20,9 @@
#include "model.h"
class Wippersnapper_V2; ///< Forward declaration
class GPSModel; ///< Forward declaration
class GPSHardware; ///< Forward declaration
class GPSModel; ///< Forward declaration
class GPSHardware; ///< Forward declaration
class UARTHardware; ///< Forward declaration
/*!
@brief Routes messages between the GPS.proto API and the hardware.
@ -30,6 +31,8 @@ class GPSController {
public:
GPSController();
~GPSController();
bool SetInterface(UARTHardware *uart_hardware);
// TODO: Add I2C interface support
bool Handle_GPSConfig(pb_istream_t *stream);
bool RemoveGPSDevice(const char *id);
void update();
@ -37,6 +40,7 @@ private:
GPSModel *_gps_model; ///< GPS model
std::vector<GPSHardware *> _gps_devices; ///< Vector of GPS hardware instances
std::vector<drvGpsBase *> _gps_drivers; ///< Vector of GPS device drivers
UARTHardware *_uart_hardware = nullptr; ///< UART hardware instance for GPS
};
extern Wippersnapper_V2 WsV2; ///< Wippersnapper V2 instance
#endif // WS_GPS_CONTROLLER_H

View file

@ -38,8 +38,7 @@ GPSModel::~GPSModel() {
* @returns True if the GPSConfig message was decoded successfully, False otherwise.
*/
bool DecodeGPSConfig(pb_istream_t *stream) {
// TODO: Implement the decoding logic for GPSConfig
return false;
return pb_decode(stream, wippersnapper_gps_GPSConfig_fields, &_msg_gps_config);
}
/*!