FrogPilot features - Automatic updates
This commit is contained in:
parent
c25749b752
commit
37265f8241
@ -27,10 +27,26 @@ def github_pinged(url="https://github.com", timeout=5):
|
|||||||
except (urllib.error.URLError, socket.timeout, http.client.RemoteDisconnected):
|
except (urllib.error.URLError, socket.timeout, http.client.RemoteDisconnected):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def time_checks(deviceState, now, params, params_memory):
|
def automatic_update_check(params):
|
||||||
|
update_available = params.get_bool("UpdaterFetchAvailable")
|
||||||
|
update_ready = params.get_bool("UpdateAvailable")
|
||||||
|
update_state_idle = params.get("UpdaterState", encoding='utf8') == "idle"
|
||||||
|
|
||||||
|
if update_ready:
|
||||||
|
HARDWARE.reboot()
|
||||||
|
elif update_available:
|
||||||
|
os.system("pkill -SIGHUP -f selfdrive.updated.updated")
|
||||||
|
elif update_state_idle:
|
||||||
|
os.system("pkill -SIGUSR1 -f selfdrive.updated.updated")
|
||||||
|
|
||||||
|
def time_checks(automatic_updates, deviceState, now, params, params_memory):
|
||||||
screen_off = deviceState.screenBrightnessPercent == 0
|
screen_off = deviceState.screenBrightnessPercent == 0
|
||||||
wifi_connection = deviceState.networkType == WIFI
|
wifi_connection = deviceState.networkType == WIFI
|
||||||
|
|
||||||
|
if screen_off and wifi_connection:
|
||||||
|
if automatic_updates:
|
||||||
|
automatic_update_check(params)
|
||||||
|
|
||||||
def frogpilot_thread(frogpilot_toggles):
|
def frogpilot_thread(frogpilot_toggles):
|
||||||
config_realtime_process(5, Priority.CTRL_LOW)
|
config_realtime_process(5, Priority.CTRL_LOW)
|
||||||
|
|
||||||
@ -71,9 +87,9 @@ def frogpilot_thread(frogpilot_toggles):
|
|||||||
if not time_validated:
|
if not time_validated:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if now.second == 0 or first_run:
|
if now.second == 0 or first_run or params_memory.get_bool("ManualUpdateInitiated"):
|
||||||
if not started and github_pinged():
|
if not started and github_pinged():
|
||||||
time_checks(deviceState, now, params, params_memory)
|
time_checks(frogpilot_toggles.automatic_updates, deviceState, now, params, params_memory)
|
||||||
|
|
||||||
if now.day != current_day:
|
if now.day != current_day:
|
||||||
params.remove("FingerprintLogged")
|
params.remove("FingerprintLogged")
|
||||||
|
@ -29,6 +29,12 @@ SoftwarePanel::SoftwarePanel(QWidget* parent) : ListWidget(parent), scene(uiStat
|
|||||||
versionLbl = new LabelControl(tr("Current Version"), "");
|
versionLbl = new LabelControl(tr("Current Version"), "");
|
||||||
addItem(versionLbl);
|
addItem(versionLbl);
|
||||||
|
|
||||||
|
// automatic updates toggle
|
||||||
|
ParamControl *automaticUpdatesToggle = new ParamControl("AutomaticUpdates", tr("Automatically Update FrogPilot"),
|
||||||
|
tr("FrogPilot will automatically update itself and it's assets when you're offroad and connected to Wi-Fi."), "");
|
||||||
|
connect(automaticUpdatesToggle, &ToggleControl::toggleFlipped, this, updateFrogPilotToggles);
|
||||||
|
addItem(automaticUpdatesToggle);
|
||||||
|
|
||||||
// download update btn
|
// download update btn
|
||||||
downloadBtn = new ButtonControl(tr("Download"), tr("CHECK"));
|
downloadBtn = new ButtonControl(tr("Download"), tr("CHECK"));
|
||||||
connect(downloadBtn, &ButtonControl::clicked, [=]() {
|
connect(downloadBtn, &ButtonControl::clicked, [=]() {
|
||||||
@ -38,6 +44,7 @@ SoftwarePanel::SoftwarePanel(QWidget* parent) : ListWidget(parent), scene(uiStat
|
|||||||
} else {
|
} else {
|
||||||
std::system("pkill -SIGHUP -f selfdrive.updated.updated");
|
std::system("pkill -SIGHUP -f selfdrive.updated.updated");
|
||||||
}
|
}
|
||||||
|
paramsMemory.putBool("ManualUpdateInitiated", true);
|
||||||
});
|
});
|
||||||
addItem(downloadBtn);
|
addItem(downloadBtn);
|
||||||
|
|
||||||
|
5
selfdrive/updated/updated.py
Executable file → Normal file
5
selfdrive/updated/updated.py
Executable file → Normal file
@ -471,11 +471,16 @@ def main() -> None:
|
|||||||
params.put("InstallDate", datetime.datetime.now().astimezone(ZoneInfo('America/Phoenix')).strftime("%B %d, %Y - %I:%M%p").encode('utf8'))
|
params.put("InstallDate", datetime.datetime.now().astimezone(ZoneInfo('America/Phoenix')).strftime("%B %d, %Y - %I:%M%p").encode('utf8'))
|
||||||
install_date_set = True
|
install_date_set = True
|
||||||
|
|
||||||
|
if not (params.get_bool("AutomaticUpdates") or params_memory.get_bool("ManualUpdateInitiated")):
|
||||||
|
wait_helper.sleep(60*60*24*365*100)
|
||||||
|
continue
|
||||||
|
|
||||||
update_failed_count += 1
|
update_failed_count += 1
|
||||||
|
|
||||||
# check for update
|
# check for update
|
||||||
params.put("UpdaterState", "checking...")
|
params.put("UpdaterState", "checking...")
|
||||||
updater.check_for_update()
|
updater.check_for_update()
|
||||||
|
params_memory.put_bool("ManualUpdateInitiated", False)
|
||||||
|
|
||||||
# download update
|
# download update
|
||||||
last_fetch = read_time_from_param(params, "UpdaterLastFetchTime")
|
last_fetch = read_time_from_param(params, "UpdaterLastFetchTime")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user