From 492083a4a83491aeb0578b3bbe4303debbe33f70 Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Tue, 29 Jun 2021 11:08:37 +0200 Subject: [PATCH] nav: pull next location while onroad (#21421) old-commit-hash: 60cc07c62ac5dd8a5cd63312758353695cf040de --- selfdrive/ui/qt/maps/map_settings.cc | 2 +- selfdrive/ui/qt/request_repeater.cc | 4 ++-- selfdrive/ui/qt/request_repeater.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/selfdrive/ui/qt/maps/map_settings.cc b/selfdrive/ui/qt/maps/map_settings.cc index 0868b8fef1..3c83abe924 100644 --- a/selfdrive/ui/qt/maps/map_settings.cc +++ b/selfdrive/ui/qt/maps/map_settings.cc @@ -84,7 +84,7 @@ MapPanel::MapPanel(QWidget* parent) : QWidget(parent) { // Destination set while offline { std::string url = "https://api.commadotai.com/v1/navigation/" + dongle_id + "/next"; - RequestRepeater* repeater = new RequestRepeater(this, QString::fromStdString(url), "", 10); + RequestRepeater* repeater = new RequestRepeater(this, QString::fromStdString(url), "", 10, true); QObject::connect(repeater, &RequestRepeater::receivedResponse, [](QString resp) { auto params = Params(); diff --git a/selfdrive/ui/qt/request_repeater.cc b/selfdrive/ui/qt/request_repeater.cc index 7db708d400..7c11c0f8a4 100644 --- a/selfdrive/ui/qt/request_repeater.cc +++ b/selfdrive/ui/qt/request_repeater.cc @@ -1,11 +1,11 @@ #include "selfdrive/ui/qt/request_repeater.h" RequestRepeater::RequestRepeater(QObject *parent, const QString &requestURL, const QString &cacheKey, - int period) : HttpRequest(parent, requestURL) { + int period, bool while_onroad) : HttpRequest(parent, requestURL) { timer = new QTimer(this); timer->setTimerType(Qt::VeryCoarseTimer); QObject::connect(timer, &QTimer::timeout, [=]() { - if (!QUIState::ui_state.scene.started && QUIState::ui_state.awake && reply == NULL) { + if ((!QUIState::ui_state.scene.started || while_onroad) && QUIState::ui_state.awake && reply == NULL) { sendRequest(requestURL); } }); diff --git a/selfdrive/ui/qt/request_repeater.h b/selfdrive/ui/qt/request_repeater.h index 1574d19305..fa80100d22 100644 --- a/selfdrive/ui/qt/request_repeater.h +++ b/selfdrive/ui/qt/request_repeater.h @@ -6,7 +6,7 @@ class RequestRepeater : public HttpRequest { public: - RequestRepeater(QObject *parent, const QString &requestURL, const QString &cacheKey = "", int period = 0); + RequestRepeater(QObject *parent, const QString &requestURL, const QString &cacheKey = "", int period = 0, bool while_onroad=false); private: Params params;