Skip to content

Commit

Permalink
PR IntelRealSense#8672 from Nir: Add recommended on-line updates
Browse files Browse the repository at this point in the history
  • Loading branch information
maloel authored Apr 12, 2021
2 parents bb6f913 + 4516417 commit 3c769f8
Show file tree
Hide file tree
Showing 17 changed files with 586 additions and 280 deletions.
3 changes: 3 additions & 0 deletions CMake/global_config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ macro(global_set_flags)
if (ANDROID_NDK_TOOLCHAIN_INCLUDED)
message(STATUS "Android build do not support CHECK_FOR_UPDATES flag, turning it off..")
set(CHECK_FOR_UPDATES false)
elseif (NOT BUILD_GRAPHICAL_EXAMPLES)
message(STATUS "CHECK_FOR_UPDATES depends on BUILD_GRAPHICAL_EXAMPLES flag, turning it off..")
set(CHECK_FOR_UPDATES false)
else()
include(CMake/external_libcurl.cmake)
add_definitions(-DCHECK_FOR_UPDATES)
Expand Down
2 changes: 1 addition & 1 deletion CMake/lrs_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ option(BUILD_NETWORK_DEVICE "Build Network Device support" OFF)
option(FORCE_LIBUVC "Explicitly turn-on libuvc backend - deprecated, use FORCE_RSUSB_BACKEND instead" OFF)
option(FORCE_WINUSB_UVC "Explicitly turn-on winusb_uvc (for win7) backend - deprecated, use FORCE_RSUSB_BACKEND instead" OFF)
option(ANDROID_USB_HOST_UVC "Build UVC backend for Android - deprecated, use FORCE_RSUSB_BACKEND instead" OFF)
option(CHECK_FOR_UPDATES "Checks for versions updates" OFF)
option(CHECK_FOR_UPDATES "Checks for versions updates" ON)
#Performance improvement with Ubuntu 18/20
if(UNIX AND (NOT ANDROID_NDK_TOOLCHAIN_INCLUDED))
option(ENABLE_EASYLOGGINGPP_ASYNC "Switch Logger to Asynchronous Mode (set OFF for Synchronous Mode)" ON)
Expand Down
51 changes: 37 additions & 14 deletions common/fw-update-helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,21 @@ namespace rs2
else
serial = _dev.query_sensors().front().get_info(RS2_CAMERA_INFO_FIRMWARE_UPDATE_ID);

_model.related_notifications.clear();
// Clear FW update related notification to avoid dismissing the notification on ~device_model()
// We want the notification alive during the whole process.
_model.related_notifications.erase(
std::remove_if( _model.related_notifications.begin(),
_model.related_notifications.end(),
[]( std::shared_ptr< notification_model > n ) {
return n->is< fw_update_notification_model >();
} ) , end(_model.related_notifications));

for (auto&& n : _model.related_notifications)
{
if (n->is< fw_update_notification_model >()
|| n->is< sw_recommended_update_alert_model >())
n->dismiss(false);
}

_progress = 5;

Expand Down Expand Up @@ -213,16 +227,22 @@ namespace rs2
}
catch (const std::exception& e)
{
log_backup_status = "WARNING: backup failed; continuing without it...";
_viewer.not_model->output.add_log(RS2_LOG_SEVERITY_WARN,
__FILE__,
__LINE__,
log_backup_status + ", Error: " + e.what());
if (auto not_model_protected = get_protected_notification_model())
{
log_backup_status = "WARNING: backup failed; continuing without it...";
not_model_protected->output.add_log(RS2_LOG_SEVERITY_WARN,
__FILE__,
__LINE__,
log_backup_status + ", Error: " + e.what());
}
}
catch ( ... )
{
log_backup_status = "WARNING: backup failed; continuing without it...";
_viewer.not_model->add_log(log_backup_status + ", Unknown error occurred");
if (auto not_model_protected = get_protected_notification_model())
{
log_backup_status = "WARNING: backup failed; continuing without it...";
not_model_protected->add_log(log_backup_status + ", Unknown error occurred");
}
}

log(log_backup_status);
Expand Down Expand Up @@ -261,10 +281,13 @@ namespace rs2
}
}
catch (std::exception &e) {
_viewer.not_model->output.add_log( RS2_LOG_SEVERITY_WARN,
__FILE__,
__LINE__,
to_string() << "Exception caught in FW Update process-flow: " << e.what() << "; Retrying..." );
if (auto not_model_protected = get_protected_notification_model())
{
not_model_protected->output.add_log(RS2_LOG_SEVERITY_WARN,
__FILE__,
__LINE__,
to_string() << "Exception caught in FW Update process-flow: " << e.what() << "; Retrying...");
}
}
catch (...) {}
}
Expand Down Expand Up @@ -414,7 +437,7 @@ namespace rs2
{
try
{
sm->stop(fw_update_manager->get_viewer_model());
sm->stop(fw_update_manager->get_protected_notification_model());
}
catch (...)
{
Expand Down Expand Up @@ -603,7 +626,7 @@ namespace rs2
message = name;
this->severity = RS2_LOG_SEVERITY_INFO;
this->category = RS2_NOTIFICATION_CATEGORY_FIRMWARE_UPDATE_RECOMMENDED;

pinned = true;
forced = true;
}
}
8 changes: 4 additions & 4 deletions common/fw-update-helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ namespace rs2
class firmware_update_manager : public process_manager
{
public:
firmware_update_manager(viewer_model& viewer, device_model& model, device dev, context ctx, std::vector<uint8_t> fw, bool is_signed)
: process_manager("Firmware Update"), _viewer(viewer), _model(model),
firmware_update_manager(std::shared_ptr<notifications_model> not_model, device_model& model, device dev, context ctx, std::vector<uint8_t> fw, bool is_signed)
: process_manager("Firmware Update"), _not_model(not_model), _model(model),
_fw(fw), _is_signed(is_signed), _dev(dev), _ctx(ctx) {}

const device_model& get_device_model() const { return _model; }
viewer_model& get_viewer_model() { return _viewer; }
std::shared_ptr<notifications_model> get_protected_notification_model() { return _not_model.lock(); };

private:
void process_flow(std::function<void()> cleanup,
Expand All @@ -34,7 +34,7 @@ namespace rs2
std::function<bool()> action, std::function<void()> cleanup,
std::chrono::system_clock::duration delta);

viewer_model& _viewer;
std::weak_ptr<notifications_model> _not_model;
device _dev;
context _ctx;
std::vector<uint8_t> _fw;
Expand Down
Loading

0 comments on commit 3c769f8

Please sign in to comment.