MCPcopy Create free account
hub / github.com/bmorcelli/Launcher / ota_function

Function ota_function

src/onlineLauncher.cpp:126–181  ·  view source on GitHub ↗

** Function name: ota_function ** Description: Start OTA function ***************************************************************************************/

Source from the content-addressed store, hash-verified

124** Description: Start OTA function
125***************************************************************************************/
126void ota_function() {
127#ifndef DISABLE_OTA
128 bool fav = false;
129 if (!launcherWifiIsConnected()) connectWifi();
130 if (launcherWifiIsConnected()) {
131 // Debug
132 // Serial.printf("Favorite size: %d\n", favorite.size());
133 // serializeJsonPretty(favorite, Serial);
134 // Debug
135 if (favorite.size() > 0) {
136 options = {
137 {"OTA List", [&]() { fav = false; } },
138 {"Favorite List", [&]() { fav = true; } },
139 {"Main Menu", [=]() { returnToMenu = true; }}
140 };
141 loopOptions(options);
142 }
143 if (returnToMenu) return;
144 if (fav) {
145 int idx = 0;
146 auto NavMenu = [&](int fw) {
147 options.clear();
148 if (favorite[fw]["fid"].as<String>().length() > 0) {
149 options.push_back({"View firmware", [=]() {
150 loopVersions(favorite[fw]["fid"].as<String>());
151 }});
152 } else {
153 options.push_back({"Install", [=]() {
154 installExtFirmware(favorite[fw]["link"].as<String>());
155 }});
156 }
157 options.push_back({"Remove Favorite", [=]() {
158 favorite.remove(fw);
159 saveConfigs();
160 }});
161 options.push_back({"Back to List", [=]() { /* Do nothing, just return */ }});
162 options.push_back({"Main Menu", [=]() { returnToMenu = true; }});
163 loopOptions(options);
164 };
165 RELOAD:
166 options.clear();
167 int count = 0;
168 for (JsonObject item : favorite) {
169 options.push_back({item["name"].as<String>(), [=]() { NavMenu(count); }});
170 count++;
171 }
172 options.push_back({"Main Menu", [=]() { returnToMenu = true; }, ALCOLOR});
173 idx = loopOptions(options, false, FGCOLOR, BGCOLOR, false, idx);
174 if (!returnToMenu && idx != -1) goto RELOAD;
175 } else {
176 if (GetJsonFromLauncherHub()) loopFirmware();
177 }
178 }
179 tft->fillScreen(BGCOLOR);
180#endif
181}
182
183#ifndef DISABLE_OTA

Callers 1

loopFunction · 0.85

Calls 10

launcherWifiIsConnectedFunction · 0.85
connectWifiFunction · 0.85
loopOptionsFunction · 0.85
loopVersionsFunction · 0.85
installExtFirmwareFunction · 0.85
saveConfigsFunction · 0.85
GetJsonFromLauncherHubFunction · 0.85
loopFirmwareFunction · 0.85
clearMethod · 0.45
fillScreenMethod · 0.45

Tested by

no test coverage detected