Skip to content

Commit 55daec6

Browse files
committed
Add support for AssistNow
1 parent b2af920 commit 55daec6

File tree

3 files changed

+44
-4
lines changed

3 files changed

+44
-4
lines changed

Firmware/RTK_Everywhere/MQTT_Client.ino

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,14 @@ MQTT_Client.ino
6666
// mqttClientSubscribedTopics contains the topics we are currently subscribed to
6767
// While connected, the mqttClientUpdate state machine compares mqttClientSubscribedTopics to mqttSubscribeTopics
6868
// 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)
6970
// Topics no longer on mqttSubscribeTopics are unsubscribed one at a time (one topic per call of mqttClientUpdate)
71+
// (ditto)
7072
// 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
7174
// If localised distribution is enabled and we have a 3D fix, we subscribe to the dict topic
7275
// 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
7377

7478
#ifdef COMPILE_MQTT_CLIENT
7579

@@ -108,7 +112,8 @@ const int mqttClientStateNameEntries = sizeof(mqttClientStateName) / sizeof(mqtt
108112

109113
const RtkMode_t mqttClientMode = RTK_MODE_ROVER | RTK_MODE_BASE_SURVEY_IN;
110114

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
112117
// Note: the key and correction topics are now stored in settings - extracted from ZTP
113118
const char localizedPrefix[] = "pp/ip/L"; // The localized distribution topic prefix. Note: starts with "pp", not "/pp"
114119

@@ -284,9 +289,11 @@ void mqttClientPrintStatus()
284289
// Called when a subscribed message arrives
285290
void mqttClientReceiveMessage(int messageSize)
286291
{
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
290297
{
291298
if (online.psram == true)
292299
mqttData = (uint8_t *)ps_malloc(mqttLimit);
@@ -387,6 +394,16 @@ void mqttClientReceiveMessage(int messageSize)
387394
break; // Break now - the dict topic should not be pushed
388395
}
389396

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+
390407
// Are these keys? If so, update our local copy
391408
if ((strlen(settings.pointPerfectKeyDistributionTopic) > 0 )
392409
&& (strcmp(topic, settings.pointPerfectKeyDistributionTopic) == 0))
@@ -487,6 +504,10 @@ void mqttClientReceiveMessage(int messageSize)
487504
else
488505
{
489506
// 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+
490511
gnssPushRawData(mqttData, mqttCount);
491512
bytesPushed += mqttCount;
492513
}
@@ -812,6 +833,11 @@ void mqttClientUpdate()
812833
localisedDistributionDictTopic = "";
813834
localisedDistributionTileTopic = "";
814835

836+
// Subscribe to AssistNow MGA if enabled
837+
if (settings.useAssistNow)
838+
{
839+
mqttSubscribeTopics.push_back(MQTT_TOPIC_ASSISTNOW);
840+
}
815841
// Subscribe to the key distribution topic
816842
mqttSubscribeTopics.push_back(String(settings.pointPerfectKeyDistributionTopic));
817843
// Subscribe to the continental correction topic for our region - if we have one. L-Band-only does not.

Firmware/RTK_Everywhere/menuPP.ino

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,14 @@ void menuPointPerfect()
975975
systemPrint(localisedDistributionTileLevelNames[settings.localisedDistributionTileLevel]);
976976
systemPrintln(")");
977977
}
978+
if (productVariant != RTK_FACET_MOSAIC)
979+
{
980+
systemPrint("a) Use AssistNow: ");
981+
if (settings.useAssistNow == true)
982+
systemPrintln("Enabled");
983+
else
984+
systemPrintln("Disabled");
985+
}
978986
#endif // COMPILE_NETWORK
979987

980988
systemPrintln("c) Clear the Keys");
@@ -1018,6 +1026,10 @@ void menuPointPerfect()
10181026
if (settings.localisedDistributionTileLevel >= LOCALISED_DISTRIBUTION_TILE_LEVELS)
10191027
settings.localisedDistributionTileLevel = 0;
10201028
}
1029+
else if (incoming == 'a' && pointPerfectIsEnabled() && (productVariant != RTK_FACET_MOSAIC))
1030+
{
1031+
settings.useAssistNow ^= 1;
1032+
}
10211033
#endif // COMPILE_NETWORK
10221034
else if (incoming == 'c' && pointPerfectIsEnabled())
10231035
{

Firmware/RTK_Everywhere/settings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,6 +1372,7 @@ struct Settings
13721372
// Localised distribution
13731373
bool useLocalisedDistribution = false;
13741374
uint8_t localisedDistributionTileLevel = 5;
1375+
bool useAssistNow = false;
13751376

13761377
// Add new settings to appropriate group above or create new group
13771378
// Then also add to the same group in rtkSettingsEntries below
@@ -1880,6 +1881,7 @@ const RTK_Settings_Entry rtkSettingsEntries[] =
18801881
// Localised distribution
18811882
{ 0, 1, 1, 0, 1, 1, 1, 1, _bool, 0, & settings.useLocalisedDistribution, "useLocalisedDistribution", },
18821883
{ 0, 1, 1, 0, 1, 1, 1, 1, _uint8_t, 0, & settings.localisedDistributionTileLevel, "localisedDistributionTileLevel", },
1884+
{ 0, 1, 1, 0, 1, 1, 0, 1, _bool, 0, & settings.useAssistNow, "useAssistNow", },
18831885

18841886
// Add new settings to appropriate group above or create new group
18851887
// Then also add to the same group in settings above

0 commit comments

Comments
 (0)