Skip to content

Commit f3286ef

Browse files
committed
GPS - break out config handler
1 parent 09bfdcf commit f3286ef

File tree

4 files changed

+37
-24
lines changed

4 files changed

+37
-24
lines changed

src/Wippersnapper_demo.ino.cpp

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/components/gps/controller.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,43 @@ GPSController::~GPSController() {
4141
}
4242
}
4343

44+
/*!
45+
* @brief Handles a GPSConfig message from the protobuf stream.
46+
* @param stream
47+
* Pointer to a pb_istream_t object.
48+
* @returns True if the message was handled successfully, False otherwise.
49+
*/
50+
bool GPSController::Handle_GPSConfig(pb_istream_t *stream) {
51+
// Attempt to decode the GPSConfig message
52+
WS_DEBUG_PRINTLN("[gps] Decoding GPSConfig message...");
53+
if (!_gps_model->DecodeGPSConfig(stream)) {
54+
WS_DEBUG_PRINTLN("[gps] ERROR: Failed to decode GPSConfig message!");
55+
return false;
56+
}
57+
WS_DEBUG_PRINTLN("[gps] GPSConfig message decoded successfully!");
58+
59+
if (_driver_type == GPS_DRV_MTK) {
60+
// handle commands for mtk driver
61+
WS_DEBUG_PRINTLN("[gps] Handling GPSConfig for MediaTek driver...");
62+
wippersnapper_gps_GPSConfig *gps_config = _gps_model->GetGPSConfigMsg();
63+
if (gps_config == nullptr) {
64+
WS_DEBUG_PRINTLN("[gps] ERROR: No GPSConfig message found!");
65+
return false;
66+
}
67+
// Iterate through the commands and send them to the GPS module
68+
for (size_t i = 0; i < gps_config->commands_count; i++) {
69+
WS_DEBUG_PRINT("[gps] Sending command to MediaTek GPS: ");
70+
WS_DEBUG_PRINTLN(gps_config->commands[i]);
71+
_ada_gps->sendCommand(gps_config->commands[i]);
72+
}
73+
} else {
74+
WS_DEBUG_PRINTLN("[gps] ERROR: Unsupported GPS driver type!");
75+
return false;
76+
}
77+
78+
return true;
79+
}
80+
4481
/*!
4582
* @brief Sets a UART hardware interface for the GPS controller.
4683
* @param serial

src/components/gps/controller.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ class GPSController {
5858
bool DetectMediatek();
5959
// Protobuf API methods
6060
bool Handle_GPSConfig(pb_istream_t *stream);
61-
bool RemoveGPSDevice(const char *id);
62-
void update();
6361

6462
private:
6563
GPSModel *_gps_model; ///< GPS model

src/components/uart/controller.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,6 @@ bool UARTController::Handle_UartWrite(pb_istream_t *stream) {
247247
void UARTController::update() {
248248
if (_uart_drivers.empty())
249249
return; // bail-out
250-
WS_DEBUG_PRINTLN("[uart] Polling UART drivers for events...");
251250

252251
for (drvUartBase *drv : _uart_drivers) {
253252

0 commit comments

Comments
 (0)