From f8e3179fac8d44172fb322a1c1130274c7686d7e Mon Sep 17 00:00:00 2001 From: TimoWielink Date: Fri, 14 Mar 2025 10:19:04 +0100 Subject: [PATCH 1/2] quick fix GPS compilcation --- TTGO-TBeam/TBeam-GPS-Example/.gitignore | 5 +++++ .../TBeam-GPS-Example/.vscode/extensions.json | 10 +++++++++ .../TBeam-GPS-Example/TBeam-GPS-Example.ino | 22 +++++++++++++++---- 3 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 TTGO-TBeam/TBeam-GPS-Example/.gitignore create mode 100644 TTGO-TBeam/TBeam-GPS-Example/.vscode/extensions.json diff --git a/TTGO-TBeam/TBeam-GPS-Example/.gitignore b/TTGO-TBeam/TBeam-GPS-Example/.gitignore new file mode 100644 index 0000000..89cc49c --- /dev/null +++ b/TTGO-TBeam/TBeam-GPS-Example/.gitignore @@ -0,0 +1,5 @@ +.pio +.vscode/.browse.c_cpp.db* +.vscode/c_cpp_properties.json +.vscode/launch.json +.vscode/ipch diff --git a/TTGO-TBeam/TBeam-GPS-Example/.vscode/extensions.json b/TTGO-TBeam/TBeam-GPS-Example/.vscode/extensions.json new file mode 100644 index 0000000..080e70d --- /dev/null +++ b/TTGO-TBeam/TBeam-GPS-Example/.vscode/extensions.json @@ -0,0 +1,10 @@ +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "platformio.platformio-ide" + ], + "unwantedRecommendations": [ + "ms-vscode.cpptools-extension-pack" + ] +} diff --git a/TTGO-TBeam/TBeam-GPS-Example/TBeam-GPS-Example.ino b/TTGO-TBeam/TBeam-GPS-Example/TBeam-GPS-Example.ino index 7d11508..9480aba 100644 --- a/TTGO-TBeam/TBeam-GPS-Example/TBeam-GPS-Example.ino +++ b/TTGO-TBeam/TBeam-GPS-Example/TBeam-GPS-Example.ino @@ -12,6 +12,7 @@ #include #include "arduino-timer.h" #include +#include #ifdef SERIAL_PORT_USBVIRTUAL #define Serial SERIAL_PORT_USBVIRTUAL @@ -39,9 +40,9 @@ void setup() { // given during the device provisioning then converted to a byte vector to // setup the duck NOTE: The Device ID must be exactly 8 bytes otherwise it // will get rejected - std::string deviceId("MAMAGPS1"); - std::vector devId; - devId.insert(devId.end(), deviceId.begin(), deviceId.end()); + std::string deviceId("MAMA0001"); + std::array devId; + std::copy(deviceId.begin(), deviceId.end(), devId.begin()); // Use the default setup provided by the SDK duck.setupWithDefaults(devId); @@ -124,6 +125,18 @@ String getGPSData() { return sensorVal; } +// Converting String to byte vector +std::vector stringToByteVector(const String& str) { + std::vector byteVec; + byteVec.reserve(str.length()); + + for (unsigned int i = 0; i < str.length(); ++i) { + byteVec.push_back(static_cast(str[i])); + } + + return byteVec; +} + bool runSensor(void *) { bool result; String sensorVal = getGPSData(); @@ -132,6 +145,7 @@ bool runSensor(void *) { Serial.println(sensorVal); //Send gps data - duck.sendData(topics::location, sensorVal); + std::vector message = stringToByteVector(sensorVal); + duck.sendData(topics::location, message); return true; } From e70926386fd637239c8dcea90e1327d5e111fe27 Mon Sep 17 00:00:00 2001 From: Timo Wielink <38896563+TimoWielink@users.noreply.github.com> Date: Fri, 14 Mar 2025 05:20:55 -0400 Subject: [PATCH 2/2] Delete TTGO-TBeam/TBeam-GPS-Example/.vscode/extensions.json --- TTGO-TBeam/TBeam-GPS-Example/.vscode/extensions.json | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 TTGO-TBeam/TBeam-GPS-Example/.vscode/extensions.json diff --git a/TTGO-TBeam/TBeam-GPS-Example/.vscode/extensions.json b/TTGO-TBeam/TBeam-GPS-Example/.vscode/extensions.json deleted file mode 100644 index 080e70d..0000000 --- a/TTGO-TBeam/TBeam-GPS-Example/.vscode/extensions.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - // See http://go.microsoft.com/fwlink/?LinkId=827846 - // for the documentation about the extensions.json format - "recommendations": [ - "platformio.platformio-ide" - ], - "unwantedRecommendations": [ - "ms-vscode.cpptools-extension-pack" - ] -}