Skip to content

Commit 0d60027

Browse files
committed
Add mqttClientIsNeeded() and productVariantSupportsAssistNow()
1 parent 2b629cf commit 0d60027

File tree

2 files changed

+45
-30
lines changed

2 files changed

+45
-30
lines changed

Firmware/RTK_Everywhere/MQTT_Client.ino

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,34 @@ static uint32_t mqttClientTimer;
154154
// MQTT Client Routines
155155
//----------------------------------------
156156

157+
bool mqttClientIsNeeded()
158+
{
159+
// If PointPerfectCorrections are not enabled, return false
160+
if (!settings.enablePointPerfectCorrections)
161+
return false;
162+
163+
// For the mosaic-X5, settings.enablePointPerfectCorrections will be true if
164+
// we are using the PPL and getting keys via ZTP. BUT the Facet mosaic-X5
165+
// uses the L-Band (only) plan. It should not and can not subscribe to PP IP
166+
// MQTT corrections. So, return false - even though the L-Band frequencies topic
167+
// and key distribution topic could be beneficial.
168+
// We could use present.gnss_mosaicX5, but let's not. See notes on EVK below.
169+
if (productVariant == RTK_FACET_MOSAIC)
170+
return false;
171+
172+
// For the Facet v2 L-Band, the same is true. It uses the L-Band (only) plan.
173+
// We get keys during ZTP (HTTP_Client). It should not and can not subscribe
174+
// to PP IP MQTT corrections. So, return true only if AssistNow is enabled -
175+
// even though the L-Band frequencies topic and key distribution topic could
176+
// be beneficial.
177+
// Note: EVK supports both L-Band and IP, so we cannot use present.lband_neo
178+
if (productVariant == RTK_FACET_V2_LBAND)
179+
if (!settings.useAssistNow)
180+
return false;
181+
182+
return true;
183+
}
184+
157185
// Determine if another connection is possible or if the limit has been reached
158186
bool mqttClientConnectLimitReached()
159187
{
@@ -163,9 +191,7 @@ bool mqttClientConnectLimitReached()
163191
// Retry the connection a few times
164192
limitReached = (mqttClientConnectionAttempts >= MAX_MQTT_CLIENT_CONNECTION_ATTEMPTS);
165193

166-
bool enableMqttClient = true;
167-
if (!settings.enablePointPerfectCorrections)
168-
enableMqttClient = false;
194+
bool enableMqttClient = mqttClientIsNeeded();
169195

170196
// Restart the MQTT client
171197
MQTT_CLIENT_STOP(limitReached || (!enableMqttClient));
@@ -242,18 +268,7 @@ void mqttClientPrintStatus()
242268
byte minutes;
243269
byte seconds;
244270

245-
bool enableMqttClient = true;
246-
if (!settings.enablePointPerfectCorrections)
247-
enableMqttClient = false;
248-
249-
// For the mosaic-X5, settings.enablePointPerfectCorrections will be true if
250-
// we are using the PPL and getting keys via ZTP. BUT the Facet mosaic-X5
251-
// uses the L-Band (only) plan. It should not and can not subscribe to PP IP
252-
// MQTT corrections. So, if present.gnss_mosaicX5 is true, set enableMqttClient
253-
// to false.
254-
// TODO : review this. This feels like a bit of a hack...
255-
if (present.gnss_mosaicX5)
256-
enableMqttClient = false;
271+
bool enableMqttClient = mqttClientIsNeeded();
257272

258273
// Display MQTT Client status and uptime
259274
if (enableMqttClient && (EQ_RTK_MODE(mqttClientMode)))
@@ -595,7 +610,7 @@ void mqttClientSetState(uint8_t newState)
595610
}
596611
systemPrintln();
597612
systemPrint("MQTT Client subscribed topics: ");
598-
for (auto it = mqttSubscribedTopics.begin(); it != mqttSubscribedTopics.end(); it = std::next(it))
613+
for (auto it = mqttClientSubscribedTopics.begin(); it != mqttClientSubscribedTopics.end(); it = std::next(it))
599614
{
600615
String topic = *it;
601616
systemPrint(topic);
@@ -692,18 +707,7 @@ bool mqttClientNeedsNetwork()
692707
// MQTT_CLIENT_RECEIVE_DATA_TIMEOUT
693708
void mqttClientUpdate()
694709
{
695-
bool enableMqttClient = true;
696-
if (!settings.enablePointPerfectCorrections)
697-
enableMqttClient = false;
698-
699-
// For the mosaic-X5, settings.enablePointPerfectCorrections will be true if
700-
// we are using the PPL and getting keys via ZTP. BUT the Facet mosaic-X5
701-
// uses the L-Band (only) plan. It should not and can not subscribe to PP IP
702-
// MQTT corrections. So, if present.gnss_mosaicX5 is true, set enableMqttClient
703-
// to false.
704-
// TODO : review this. This feels like a bit of a hack...
705-
if (present.gnss_mosaicX5)
706-
enableMqttClient = false;
710+
bool enableMqttClient = mqttClientIsNeeded();
707711

708712
// Shutdown the MQTT client when the mode or setting changes
709713
DMW_st(mqttClientSetState, mqttClientState);

Firmware/RTK_Everywhere/menuPP.ino

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ MqttClient *menuppMqttClient;
2828
// L-Band Routines - compiled out
2929
//----------------------------------------
3030

31+
bool productVariantSupportsAssistNow()
32+
{
33+
if (productVariant == RTK_FACET_MOSAIC)
34+
return false;
35+
if (productVariant == RTK_TORCH)
36+
return false;
37+
if (productVariant == RTK_POSTCARD)
38+
return false;
39+
return true;
40+
}
41+
3142
void menuPointPerfectKeys()
3243
{
3344
while (1)
@@ -979,7 +990,7 @@ void menuPointPerfect()
979990
systemPrint(localizedDistributionTileLevelNames[settings.localizedDistributionTileLevel]);
980991
systemPrintln(")");
981992
}
982-
if (productVariant != RTK_FACET_MOSAIC)
993+
if (productVariantSupportsAssistNow())
983994
{
984995
systemPrint("a) Use AssistNow: ");
985996
if (settings.useAssistNow == true)
@@ -1030,7 +1041,7 @@ void menuPointPerfect()
10301041
if (settings.localizedDistributionTileLevel >= LOCALIZED_DISTRIBUTION_TILE_LEVELS)
10311042
settings.localizedDistributionTileLevel = 0;
10321043
}
1033-
else if (incoming == 'a' && pointPerfectIsEnabled() && (productVariant != RTK_FACET_MOSAIC))
1044+
else if (incoming == 'a' && pointPerfectIsEnabled() && productVariantSupportsAssistNow())
10341045
{
10351046
settings.useAssistNow ^= 1;
10361047
}

0 commit comments

Comments
 (0)