Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Online updates - Enhancements #9008

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 107 additions & 28 deletions common/model-views.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3708,14 +3708,14 @@ namespace rs2
_updates->set_device_status(*_updates_profile, false);
}

void device_model::check_for_bundled_fw_update(const rs2::context &ctx, std::shared_ptr<notifications_model> not_model)
bool device_model::check_for_bundled_fw_update(const rs2::context &ctx, std::shared_ptr<notifications_model> not_model , bool reset_delay )
{
if( dev.supports( RS2_CAMERA_INFO_FIRMWARE_VERSION )
&& dev.supports( RS2_CAMERA_INFO_RECOMMENDED_FIRMWARE_VERSION )
&& dev.supports( RS2_CAMERA_INFO_PRODUCT_LINE ) )
{
std::string fw = dev.get_info( RS2_CAMERA_INFO_FIRMWARE_VERSION );
std::string recommended
std::string recommended_fw_ver
= dev.get_info( RS2_CAMERA_INFO_RECOMMENDED_FIRMWARE_VERSION );

int product_line
Expand All @@ -3725,13 +3725,13 @@ namespace rs2
configurations::update::allow_rc_firmware,
false );
bool is_rc = ( product_line == RS2_PRODUCT_LINE_D400 ) && allow_rc_firmware;
std::string available = get_available_firmware_version( product_line );
std::string available_fw_ver = get_available_firmware_version( product_line );
maloel marked this conversation as resolved.
Show resolved Hide resolved

std::shared_ptr< firmware_update_manager > manager = nullptr;

if( is_upgradeable( fw, available ) )
if( is_upgradeable( fw, available_fw_ver) )
{
recommended = available;
recommended_fw_ver = available_fw_ver;

static auto table = create_default_fw_table();

Expand All @@ -3743,30 +3743,46 @@ namespace rs2
true );
}

if( is_upgradeable( fw, recommended ) )
auto dev_name = get_device_name(dev);
if( is_upgradeable( fw, recommended_fw_ver) )
{
auto dev_name = get_device_name( dev );
std::stringstream msg;
msg << dev_name.first << " (S/N " << dev_name.second << ")\n"
<< "Current Version: " << fw << "\n";

if( is_rc )
msg << "Release Candidate: " << recommended << " Pre-Release";
msg << "Release Candidate: " << recommended_fw_ver << " Pre-Release";
else
msg << "Recommended Version: " << recommended;
msg << "Recommended Version: " << recommended_fw_ver;

auto n = std::make_shared< fw_update_notification_model >( msg.str(),
manager,
false );
n->delay_id = "dfu." + dev_name.second;
// The FW update delay ID include the dismissed recommended version and the device serial number
// This way a newer FW recommended version will not be dismissed
n->delay_id = "fw_update_alert." + recommended_fw_ver + "." + dev_name.second;
n->enable_complex_dismiss = true;

if( reset_delay ) n->reset_delay();

if( ! n->is_delayed() )
{
not_model->add_notification( n );
related_notifications.push_back( n );
return true;
}
}
else
{
std::stringstream msg;
msg << "Bundled FW is up to date for: " << dev_name.first << " (S/N " << dev_name.second << ")\n"
maloel marked this conversation as resolved.
Show resolved Hide resolved
<< "Current Version: " << fw << "\n"
<< "Recommended Version: " << recommended_fw_ver;

not_model->add_log(msg.str(), RS2_LOG_SEVERITY_DEBUG);
maloel marked this conversation as resolved.
Show resolved Hide resolved
}
}
return false;
}

void device_model::refresh_notifications(viewer_model& viewer)
Expand Down Expand Up @@ -4876,7 +4892,7 @@ namespace rs2
error_message = e.what();
}
}
void device_model::check_for_device_updates(viewer_model& viewer)
void device_model::check_for_device_updates(viewer_model& viewer, bool activated_by_user )
{
std::weak_ptr< updates_model > updates_model_protected( viewer.updates );
std::weak_ptr< dev_updates_profile::update_profile > update_profile_protected(
Expand All @@ -4887,7 +4903,8 @@ namespace rs2
updates_model_protected,
notification_model_protected,
this,
update_profile_protected]() {
update_profile_protected,
activated_by_user]() {
try
{
bool need_to_check_bundle = true;
Expand All @@ -4905,9 +4922,10 @@ namespace rs2
}
sw_update::dev_updates_profile updates_profile( dev, server_url, use_local_file );

bool sw_online_update_available = updates_profile.retrieve_updates( sw_update::LIBREALSENSE );
bool fw_online_update_available = updates_profile.retrieve_updates( sw_update::FIRMWARE );

bool fail_access_db = false;
bool sw_online_update_available = updates_profile.retrieve_updates( sw_update::LIBREALSENSE, fail_access_db);
bool fw_online_update_available = updates_profile.retrieve_updates( sw_update::FIRMWARE, fail_access_db);
bool fw_bundled_update_available = false;
if (sw_online_update_available || fw_online_update_available)
{
if (auto update_profile = update_profile_protected.lock())
Expand All @@ -4917,14 +4935,39 @@ namespace rs2
ctx,
this);

// For essential policy we don't need the update info, if essential update exist we take the whole update profile for full updates display
dev_updates_profile::version_info dummy_update_info;
if (update_profile->get_sw_update(sw_update::ESSENTIAL, dummy_update_info) || update_profile->get_fw_update(sw_update::ESSENTIAL, dummy_update_info))
dev_updates_profile::version_info sw_update_info, fw_update_info;
bool essential_sw_update_found = update_profile->get_sw_update(sw_update::ESSENTIAL, sw_update_info);
bool essential_fw_update_found = update_profile->get_fw_update(sw_update::ESSENTIAL, fw_update_info);
if (essential_sw_update_found || essential_fw_update_found)
{
if (auto viewer_updates = updates_model_protected.lock())
{
viewer_updates->add_profile(updates_profile_model);
need_to_check_bundle = false;

// Log the essential updates
if (auto nm = notification_model_protected.lock())
{
if( essential_sw_update_found )
nm->add_log(
to_string()
<< update_profile->device_name << " (S/N "
<< update_profile->serial_number << ")\n"
<< "Current SW version: " << std::string( update_profile->software_version )
<< "\nEssential SW version: "
<< std::string( sw_update_info.ver ),
RS2_LOG_SEVERITY_WARN );

if( essential_fw_update_found )
nm->add_log(
to_string()
<< update_profile->device_name << " (S/N "
<< update_profile->serial_number << ")\n"
<< "Current FW version: " << std::string( update_profile->firmware_version )
<< "\nEssential FW version: "
<< std::string( fw_update_info.ver ),
RS2_LOG_SEVERITY_WARN );
}
}
}
else
Expand All @@ -4942,14 +4985,14 @@ namespace rs2
{
if (auto nm = notification_model_protected.lock())
{
handle_online_sw_update( nm, update_profile );
handle_online_sw_update( nm, update_profile, activated_by_user);
}
}
if (fw_online_update_available)
{
if (auto nm = notification_model_protected.lock())
{
need_to_check_bundle = !handle_online_fw_update( ctx, nm, update_profile );
need_to_check_bundle = !handle_online_fw_update( ctx, nm, update_profile , activated_by_user);
}
}
}
Expand All @@ -4964,7 +5007,12 @@ namespace rs2
}
else if( auto nm = notification_model_protected.lock() )
{
nm->add_log( "No online SW / FW updates available" );
if ( activated_by_user && fail_access_db )
nm->add_notification( { to_string() << textual_icons::wifi << " Unable to retrieve updates.\nPlease check your network connection.\n",
RS2_LOG_SEVERITY_ERROR,
RS2_NOTIFICATION_CATEGORY_UNKNOWN_ERROR } );
else
nm->add_log( "No online SW / FW updates available" );
}

// If no on-line updates notification, offer bundled FW update if needed
Expand All @@ -4973,7 +5021,23 @@ namespace rs2
{
if( auto nm = notification_model_protected.lock() )
{
check_for_bundled_fw_update( ctx, nm );
fw_bundled_update_available = check_for_bundled_fw_update( ctx, nm , activated_by_user);
}
}

// When no updates available (on-line + bundled), add a notification to indicate "all up to date"
if( activated_by_user && ! fail_access_db && ! sw_online_update_available
&& ! fw_online_update_available && ! fw_bundled_update_available )
{
auto n = std::make_shared< sw_update_up_to_date_model >();
auto name = get_device_name(dev);
n->delay_id = "no_updates_alert." + name.second;
n->enable_complex_dismiss = true; // allow advanced dismiss menu
maloel marked this conversation as resolved.
Show resolved Hide resolved

if (auto nm = notification_model_protected.lock())
{
nm->add_notification(n);
related_notifications.push_back(n);
}
}
}
Expand Down Expand Up @@ -5274,7 +5338,7 @@ namespace rs2
n->dismiss( false ); // No need for snooze, if needed a new notification will be popped
}

check_for_device_updates( viewer );
check_for_device_updates( viewer , true);
}
}

Expand Down Expand Up @@ -5574,26 +5638,38 @@ namespace rs2
}
}

void rs2::device_model::handle_online_sw_update(std::shared_ptr < notifications_model > nm , std::shared_ptr < dev_updates_profile::update_profile >update_profile )
void rs2::device_model::handle_online_sw_update(
std::shared_ptr< notifications_model > nm,
std::shared_ptr< dev_updates_profile::update_profile > update_profile,
bool reset_delay )
{
dev_updates_profile::version_info recommended_sw_update_info;
update_profile->get_sw_update(sw_update::RECOMMENDED, recommended_sw_update_info);
auto n = std::make_shared< sw_recommended_update_alert_model >(
RS2_API_FULL_VERSION_STR,
recommended_sw_update_info.ver,
recommended_sw_update_info.download_link);
auto name = get_device_name(dev);
n->delay_id = "update_alert." + name.second;

auto dev_name = get_device_name(dev);
// The SW update delay ID include the dismissed recommended version and the device serial number
// This way a newer SW recommended version will not be dismissed.
n->delay_id = "sw_update_alert." + std::string(recommended_sw_update_info.ver) + "." + dev_name.second;
n->enable_complex_dismiss = true; // allow advanced dismiss menu

if ( reset_delay ) n->reset_delay();

if (!n->is_delayed())
{
nm->add_notification(n);
related_notifications.push_back(n);
}
}

bool rs2::device_model::handle_online_fw_update( const context& ctx, std::shared_ptr < notifications_model > nm, std::shared_ptr< dev_updates_profile::update_profile> update_profile )
bool rs2::device_model::handle_online_fw_update(
const context & ctx,
std::shared_ptr< notifications_model > nm,
std::shared_ptr< dev_updates_profile::update_profile > update_profile,
bool reset_delay )
{
bool fw_update_notification_raised = false;
std::shared_ptr< firmware_update_manager > manager = nullptr;
Expand Down Expand Up @@ -5640,8 +5716,11 @@ namespace rs2
msg.str(),
manager,
false);
n->delay_id = "dfu." + dev_name.second;
n->delay_id = "fw_update_alert." + std::string(recommended_fw_update_info.ver) + "." + dev_name.second;
n->enable_complex_dismiss = true;

if ( reset_delay ) n->reset_delay();

if (!n->is_delayed())
{
nm->add_notification(n);
Expand Down
15 changes: 10 additions & 5 deletions common/model-views.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ namespace rs2
static const textual_icon mail { u8"\uF01C" };
static const textual_icon cube { u8"\uf1b2" };
static const textual_icon measure { u8"\uf545" };
static const textual_icon wifi { u8"\uf1eb" };
}

class subdevice_model;
Expand Down Expand Up @@ -767,7 +768,9 @@ namespace rs2
void resume_record();

void refresh_notifications(viewer_model& viewer);
void check_for_bundled_fw_update(const rs2::context& ctx, std::shared_ptr<notifications_model> not_model);
bool check_for_bundled_fw_update( const rs2::context & ctx,
std::shared_ptr< notifications_model > not_model,
bool reset_delay = false );

int draw_playback_panel(ux_window& window, ImFont* font, viewer_model& view);
bool draw_advanced_controls(viewer_model& view, ux_window& window, std::string& error_message);
Expand All @@ -784,7 +787,7 @@ namespace rs2
void begin_update(std::vector<uint8_t> data,
viewer_model& viewer, std::string& error_message);
void begin_update_unsigned(viewer_model& viewer, std::string& error_message);
void check_for_device_updates(viewer_model& viewer);
void check_for_device_updates(viewer_model& viewer, bool activated_by_user = false);


std::shared_ptr< atomic_objects_in_frame > get_detected_objects() const { return _detected_objects; }
Expand Down Expand Up @@ -844,13 +847,15 @@ namespace rs2
void load_viewer_configurations(const std::string& json_str);
void save_viewer_configurations(std::ofstream& outfile, nlohmann::json& j);
void handle_online_sw_update(
std::shared_ptr < notifications_model > nm,
std::shared_ptr< sw_update::dev_updates_profile::update_profile > update_profile );
std::shared_ptr< notifications_model > nm,
std::shared_ptr< sw_update::dev_updates_profile::update_profile > update_profile,
bool reset_delay = false );

bool handle_online_fw_update(
const context & ctx,
std::shared_ptr< notifications_model > nm,
std::shared_ptr< sw_update::dev_updates_profile::update_profile > update_profile );
std::shared_ptr< sw_update::dev_updates_profile::update_profile > update_profile,
bool reset_delay = false );

std::shared_ptr<recorder> _recorder;
std::vector<std::shared_ptr<subdevice_model>> live_subdevices;
Expand Down
Loading