@@ -66,10 +66,14 @@ MQTT_Client.ino
66
66
// mqttClientSubscribedTopics contains the topics we are currently subscribed to
67
67
// While connected, the mqttClientUpdate state machine compares mqttClientSubscribedTopics to mqttSubscribeTopics
68
68
// New topics on mqttSubscribeTopics are subscribed to one at a time (one topic per call of mqttClientUpdate)
69
+ // (this will make things easier for cellular - the LARA-R6 can only subscribe to one topic at once)
69
70
// Topics no longer on mqttSubscribeTopics are unsubscribed one at a time (one topic per call of mqttClientUpdate)
71
+ // (ditto)
70
72
// Initially we subscribe to the key distribution topic and the continental correction topic (if available)
73
+ // If enabled, we also subscribe to the AssistNow MGA topic
71
74
// If localised distribution is enabled and we have a 3D fix, we subscribe to the dict topic
72
75
// When the dict is received, we subscribe to the nearest localised topic and unsubscribe from the continental topic
76
+ // When the AssistNow MGA data arrives, we unsubscribe and subscribe to AssistNow updates
73
77
74
78
#ifdef COMPILE_MQTT_CLIENT
75
79
@@ -108,7 +112,8 @@ const int mqttClientStateNameEntries = sizeof(mqttClientStateName) / sizeof(mqtt
108
112
109
113
const RtkMode_t mqttClientMode = RTK_MODE_ROVER | RTK_MODE_BASE_SURVEY_IN;
110
114
111
- const char MQTT_TOPIC_ASSISTNOW[] = " /pp/ubx/mga" ; // AssistNow (MGA) topic
115
+ const String MQTT_TOPIC_ASSISTNOW = " /pp/ubx/mga" ; // AssistNow (MGA) topic
116
+ const String MQTT_TOPIC_ASSISTNOW_UPDATES = " /pp/ubx/mga/updates" ; // AssistNow (MGA) topic - updates only
112
117
// Note: the key and correction topics are now stored in settings - extracted from ZTP
113
118
const char localizedPrefix[] = " pp/ip/L" ; // The localized distribution topic prefix. Note: starts with "pp", not "/pp"
114
119
@@ -284,9 +289,11 @@ void mqttClientPrintStatus()
284
289
// Called when a subscribed message arrives
285
290
void mqttClientReceiveMessage (int messageSize)
286
291
{
287
- const uint16_t mqttLimit = 26000 ; // The Level 3 localised distribution dictionary topic can be up to 25KB
288
- static uint8_t *mqttData = nullptr ; // Allocate memory to hold the MQTT data. Never freed
289
- if (mqttData == nullptr )
292
+ // The Level 3 localised distribution dictionary topic can be up to 25KB
293
+ // The full AssistNow (MGA) topic can be ~11KB
294
+ const uint16_t mqttLimit = 26000 ;
295
+ static uint8_t *mqttData = nullptr ;
296
+ if (mqttData == nullptr ) // Allocate memory to hold the MQTT data. Never freed
290
297
{
291
298
if (online.psram == true )
292
299
mqttData = (uint8_t *)ps_malloc (mqttLimit);
@@ -387,6 +394,16 @@ void mqttClientReceiveMessage(int messageSize)
387
394
break ; // Break now - the dict topic should not be pushed
388
395
}
389
396
397
+ // Is this the full AssistNow MGA data? If so, unsubscribe and subscribe to updates
398
+ if (strcmp (topic, MQTT_TOPIC_ASSISTNOW.c_str ()) == 0 )
399
+ {
400
+ std::vector<String>::iterator pos = std::find (mqttSubscribeTopics.begin (), mqttSubscribeTopics.end (), MQTT_TOPIC_ASSISTNOW);
401
+ if (pos != mqttSubscribeTopics.end ())
402
+ mqttSubscribeTopics.erase (pos);
403
+
404
+ mqttSubscribeTopics.push_back (MQTT_TOPIC_ASSISTNOW_UPDATES);
405
+ }
406
+
390
407
// Are these keys? If so, update our local copy
391
408
if ((strlen (settings.pointPerfectKeyDistributionTopic ) > 0 )
392
409
&& (strcmp (topic, settings.pointPerfectKeyDistributionTopic ) == 0 ))
@@ -487,6 +504,10 @@ void mqttClientReceiveMessage(int messageSize)
487
504
else
488
505
{
489
506
// KEYS or MGA
507
+ if (((settings.debugMqttClientData == true ) || (settings.debugCorrections == true )) &&
508
+ !inMainMenu)
509
+ systemPrintf (" Pushing %d bytes from %s topic to GNSS\r\n " , mqttCount, topic);
510
+
490
511
gnssPushRawData (mqttData, mqttCount);
491
512
bytesPushed += mqttCount;
492
513
}
@@ -812,6 +833,11 @@ void mqttClientUpdate()
812
833
localisedDistributionDictTopic = " " ;
813
834
localisedDistributionTileTopic = " " ;
814
835
836
+ // Subscribe to AssistNow MGA if enabled
837
+ if (settings.useAssistNow )
838
+ {
839
+ mqttSubscribeTopics.push_back (MQTT_TOPIC_ASSISTNOW);
840
+ }
815
841
// Subscribe to the key distribution topic
816
842
mqttSubscribeTopics.push_back (String (settings.pointPerfectKeyDistributionTopic ));
817
843
// Subscribe to the continental correction topic for our region - if we have one. L-Band-only does not.
0 commit comments