Skip to content

Commit a49b9f4

Browse files
author
philmoz
committed
Prevent lock up / crash when too many sensors discovered.
1 parent 8d1fa10 commit a49b9f4

File tree

5 files changed

+20
-8
lines changed

5 files changed

+20
-8
lines changed

radio/src/gui/128x64/model_telemetry.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ void menuModelTelemetry(event_t event)
214214
pushMenu(menuModelSensor);
215215
}
216216
else {
217-
allowNewSensors = 0;
217+
allowNewSensors = false;
218218
POPUP_WARNING(STR_TELEMETRYFULL);
219219
}
220220
}

radio/src/gui/212x64/model_telemetry.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ void menuModelTelemetry(event_t event)
218218
pushMenu(menuModelSensor);
219219
}
220220
else {
221-
allowNewSensors = 0;
221+
allowNewSensors = false;
222222
POPUP_WARNING(STR_TELEMETRYFULL);
223223
}
224224
}

radio/src/gui/colorlcd/model/model_telemetry.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,14 @@ void ModelTelemetryPage::checkEvents()
773773
{
774774
int _lastKnownIndex = availableTelemetryIndex();
775775

776-
if (lastKnownIndex >= 0 && lastKnownIndex != _lastKnownIndex) {
776+
if (_lastKnownIndex < 0) {
777+
if (discover->checked()) {
778+
rebuild(window);
779+
discover->setText(STR_DISCOVER_SENSORS);
780+
discover->check(false);
781+
POPUP_WARNING(STR_TELEMETRYFULL);
782+
}
783+
} else if (lastKnownIndex != _lastKnownIndex) {
777784
rebuild(window);
778785
lastKnownIndex = _lastKnownIndex;
779786
}
@@ -784,7 +791,8 @@ void ModelTelemetryPage::checkEvents()
784791
void ModelTelemetryPage::rebuild(Window* window, int8_t focusSensorIndex)
785792
{
786793
buildSensorList(focusSensorIndex);
787-
lastKnownIndex = availableTelemetryIndex();
794+
if (availableTelemetryIndex() >= 0)
795+
lastKnownIndex = availableTelemetryIndex();
788796
}
789797

790798
void ModelTelemetryPage::editSensor(Window* window, uint8_t index)
@@ -822,7 +830,7 @@ void ModelTelemetryPage::buildSensorList(int8_t focusSensorIndex)
822830
SET_DIRTY();
823831
rebuild(window, newIndex);
824832
} else {
825-
new FullScreenDialog(WARNING_TYPE_ALERT, "", STR_TELEMETRYFULL);
833+
POPUP_WARNING(STR_TELEMETRYFULL);
826834
}
827835
});
828836
menu->addLine(STR_DELETE, [=]() {
@@ -904,7 +912,7 @@ void ModelTelemetryPage::build(Window* window)
904912
if (idx >= 0)
905913
editSensor(window, idx);
906914
else
907-
new FullScreenDialog(WARNING_TYPE_ALERT, "", STR_TELEMETRYFULL);
915+
POPUP_WARNING(STR_TELEMETRYFULL);
908916
return 0;
909917
});
910918
lv_obj_set_grid_cell(b->getLvObj(), LV_GRID_ALIGN_STRETCH, 1, 1,

radio/src/telemetry/telemetry_sensors.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
#endif
5757

5858
TelemetryItem telemetryItems[MAX_TELEMETRY_SENSORS];
59-
uint8_t allowNewSensors;
59+
bool allowNewSensors;
6060

6161
bool isFaiForbidden(source_t idx)
6262
{
@@ -597,7 +597,11 @@ int setTelemetryValue(TelemetryProtocol protocol, uint16_t id, uint8_t subId,
597597
return index;
598598
}
599599
else {
600+
allowNewSensors = false;
601+
#if !defined(COLORLCD)
602+
// Not safe on color LCD - handled in telemetry page instead
600603
POPUP_WARNING(STR_TELEMETRYFULL);
604+
#endif
601605
return -1;
602606
}
603607
}

radio/src/telemetry/telemetry_sensors.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,5 +130,5 @@ class TelemetryItem
130130
};
131131

132132
extern TelemetryItem telemetryItems[MAX_TELEMETRY_SENSORS];
133-
extern uint8_t allowNewSensors;
133+
extern bool allowNewSensors;
134134
bool isFaiForbidden(source_t idx);

0 commit comments

Comments
 (0)