feat: add handling for reboot and reupdate in firmware update callbacks

This commit is contained in:
ob-yalian
2025-12-15 16:03:06 +08:00
parent c4dee75e96
commit c9b25331f3
2 changed files with 7 additions and 6 deletions
@@ -93,7 +93,8 @@ class OBCameraNodeDriver : public rclcpp::Node {
std::string config_path_;
std::unique_ptr<ob::Context> ctx_ = nullptr;
rclcpp::Logger logger_;
uint64_t device_changed_callback_id_ = 0; // Store callback ID for unregistering (OBCallbackId)
OBCallbackId device_changed_callback_id_ =
INVALID_CALLBACK_ID; // Store callback ID for unregistering
std::unique_ptr<OBCameraNode> ob_camera_node_ = nullptr;
std::unique_ptr<orbbec_lidar::OBLidarNode> ob_lidar_node_ = nullptr;
std::shared_ptr<ob::Device> device_ = nullptr;
+5 -5
View File
@@ -1071,9 +1071,7 @@ void OBCameraNodeDriver::initializeDevice(const std::shared_ptr<ob::Device> &dev
if (need_reupdate_) {
// Some devices require a second update after reboot
RCLCPP_INFO(logger_, "Firmware update completed but not finalized.");
RCLCPP_INFO(logger_, "The device will reboot and perform a second update automatically.");
RCLCPP_INFO(logger_, "Please wait for the device to reconnect...");
// Set flag to indicate we're waiting for device to reboot for second update
is_reupdating_ = true;
// Keep upgrade_firmware_ path and wait for device to reconnect
@@ -1409,6 +1407,9 @@ void OBCameraNodeDriver::presetUpdateCallback(bool firstCall, OBFwUpdateState st
case STAT_DONE:
std::cout << "Update completed" << std::endl;
break;
case STAT_DONE_REBOOT_AND_REUPDATE:
std::cout << "Update completed, requires reboot and reupdate" << std::endl;
break;
case STAT_DONE_WITH_DUPLICATES:
std::cout << "Update completed, duplicated presets have been ignored" << std::endl;
break;
@@ -1448,7 +1449,7 @@ void OBCameraNodeDriver::firmwareUpdateCallback(OBFwUpdateState state, const cha
break;
case STAT_DONE_REBOOT_AND_REUPDATE:
need_reupdate_ = true;
std::cout << "Update completed" << std::endl;
std::cout << "Update completed (requires reboot and reupdate)" << std::endl;
break;
case STAT_IN_PROGRESS:
std::cout << "Upgrade in progress" << std::endl;
@@ -1485,13 +1486,12 @@ void OBCameraNodeDriver::firmwareUpdateCallback(OBFwUpdateState state, const cha
ob_lidar_node_.reset();
}
device_connected_ = false;
firmware_update_success_ = true;
if (state == STAT_DONE_REBOOT_AND_REUPDATE) {
// Keep upgrade_firmware_ path for second update
RCLCPP_INFO(logger_, "Firmware update requires a second update after reboot");
} else {
upgrade_firmware_ = "";
firmware_update_success_ = true;
}
}
}