You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
uint8_t ok = myGNSS.setI2COutput(COM_TYPE_UBX); //Turn off NMEA noise
199
+
if (ok) ok = myGNSS.setPortInput(COM_PORT_I2C, COM_TYPE_UBX | COM_TYPE_NMEA | COM_TYPE_SPARTN); // Be sure SPARTN input is enabled.
200
+
201
+
if (ok) ok = myGNSS.setDGNSSConfiguration(SFE_UBLOX_DGNSS_MODE_FIXED); // Set the differential mode - ambiguities are fixed whenever possible
202
+
if (ok) ok = myGNSS.setNavigationFrequency(1); //Set output in Hz.
203
+
if (ok) ok = myGNSS.setVal8(UBLOX_CFG_SPARTN_USE_SOURCE, 0); // Use IP source (default). Change this to 1 for L-Band (PMP)
204
+
205
+
if (ok) ok = myGNSS.setAutoPVTcallbackPtr(&printPVTdata); // Enable automatic NAV PVT messages with callback to printPVTdata so we can watch the carrier solution go to fixed
206
+
207
+
if (ok) ok = myGNSS.setVal8(UBLOX_CFG_MSGOUT_UBX_RXM_COR_I2C, 1); // Enable UBX-RXM-COR messages on I2C
208
+
if (ok) ok = myGNSS.setRXMCORcallbackPtr(&printRXMCOR); // Print the contents of UBX-RXM-COR messages so we can check if the SPARTN data is being decrypted successfully
209
+
210
+
//if (ok) ok = myGNSS.saveConfiguration(VAL_CFG_SUBSEC_IOPORT | VAL_CFG_SUBSEC_MSGCONF); //Optional: Save the ioPort and message settings to NVM
211
+
212
+
Serial.print(F("GNSS: configuration "));
213
+
Serial.println(OK(ok));
214
+
72
215
Serial.print(F("Connecting to local WiFi"));
73
216
WiFi.begin(ssid, password);
74
217
while (WiFi.status() != WL_CONNECTED) {
@@ -81,45 +224,66 @@ void setup()
81
224
Serial.println(WiFi.localIP());
82
225
83
226
while (Serial.available()) Serial.read();
227
+
228
+
Serial.println(F("Press any key to start MQTT/SPARTN Client."));
229
+
84
230
}
85
231
86
232
voidloop()
87
233
{
88
234
if (Serial.available())
89
235
{
90
236
beginClient();
237
+
91
238
while (Serial.available()) Serial.read(); //Empty buffer of any newline chars
239
+
240
+
Serial.println(F("Press any key to start MQTT/SPARTN Client."));
92
241
}
93
242
94
-
Serial.println(F("Press any key to start MQTT/SPARTN Client."));
95
-
96
-
delay(1000);
243
+
myGNSS.checkUblox(); // Check for the arrival of new GNSS data and process it.
244
+
myGNSS.checkCallbacks(); // Check if any GNSS callbacks are waiting to be processed.
97
245
}
98
246
99
247
WiFiClientSecure wifiClient = WiFiClientSecure();
100
248
MqttClient mqttClient(wifiClient);
101
249
102
-
voidmqttMessageHandler(int messageSize) {
103
-
uint8_t spartnData[512 * 4]; //Most incoming data is around 500 bytes but may be larger
104
-
int spartnCount = 0;
105
-
Serial.print(F("Pushed data from "));
250
+
voidmqttMessageHandler(int messageSize)
251
+
{
252
+
constuint16_t mqttLimit = 512;
253
+
uint8_t *mqttData = newuint8_t[mqttLimit]; // Allocate memory to hold the MQTT data
254
+
if (mqttData == NULL)
255
+
{
256
+
Serial.println(F("Memory allocation for mqttData failed!"));
257
+
return;
258
+
}
259
+
260
+
Serial.print(F("Pushing data from "));
106
261
Serial.print(mqttClient.messageTopic());
107
262
Serial.println(F(" topic to ZED"));
263
+
108
264
while (mqttClient.available())
109
265
{
110
-
char ch = mqttClient.read();
111
-
//Serial.write(ch); //Pipe to serial port is fine but beware, it's a lot of binary data
112
-
spartnData[spartnCount++] = ch;
113
-
if (spartnCount == sizeof(spartnData))
114
-
break;
115
-
}
266
+
uint16_t mqttCount = 0;
116
267
117
-
if (spartnCount > 0)
118
-
{
119
-
//Push KEYS or SPARTN data to GNSS module over I2C
0 commit comments