MCPcopy Create free account
hub / github.com/TactilityProject/Tactility / getAck

Function getAck

Tactility/Source/hal/gps/Probe.cpp:46–81  ·  view source on GitHub ↗

* From: https://github.com/meshtastic/firmware/blob/f81d3b045dd1b7e3ca7870af3da915ff4399ea98/src/gps/GPS.cpp */

Source from the content-addressed store, hash-verified

44 * From: https://github.com/meshtastic/firmware/blob/f81d3b045dd1b7e3ca7870af3da915ff4399ea98/src/gps/GPS.cpp
45 */
46GpsResponse getAck(::Device* uart, const char* message, uint32_t waitMillis) {
47 uint8_t buffer[768] = {0};
48 uint8_t b;
49 int bytesRead = 0;
50 uint32_t startTimeout = kernel::getMillis() + waitMillis;
51#ifdef GPS_DEBUG
52 std::string debugmsg = "";
53#endif
54 while (kernel::getMillis() < startTimeout) {
55 size_t available = 0;
56 uart_controller_get_available(uart, &available);
57 if (available > 0) {
58 uart_controller_read_byte(uart, &b, 1);
59
60#ifdef GPS_DEBUG
61 debugmsg += vformat("%c", (b >= 32 && b <= 126) ? b : '.');
62#endif
63 buffer[bytesRead] = b;
64 bytesRead++;
65 if ((bytesRead == 767) || (b == '\r')) {
66 if (strnstr((char*)buffer, message, bytesRead) != nullptr) {
67#ifdef GPS_DEBUG
68 LOGGER.debug("Found: {}", message); // Log the found message
69#endif
70 return GpsResponse::Ok;
71 } else {
72 bytesRead = 0;
73#ifdef GPS_DEBUG
74 LOGGER.debug("{}", debugmsg);
75#endif
76 }
77 }
78 }
79 }
80 return GpsResponse::None;
81}
82
83/**
84 * From: https://github.com/meshtastic/firmware/blob/f81d3b045dd1b7e3ca7870af3da915ff4399ea98/src/gps/GPS.cpp

Callers

nothing calls this directly

Calls 5

getMillisFunction · 0.85
strnstrFunction · 0.85
debugMethod · 0.80

Tested by

no test coverage detected