ifm3d
swupdater.h
1 /*
2  * Copyright 2019 ifm electronic, gmbh
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 
6 #ifndef IFM3D_SWUPDATER_SWUPDATER_H
7 #define IFM3D_SWUPDATER_SWUPDATER_H
8 #pragma once
9 
10 #include <memory>
11 #include <ifm3d/device/legacy_device.h>
12 #include <ifm3d/swupdater/module_swupdater.h>
13 
14 namespace ifm3d
15 {
16  /* const for the swupdate recovery port value */
17  extern IFM3D_EXPORT const std::uint16_t SWUPDATER_RECOVERY_PORT;
18 
20  class IFM3D_EXPORT SWUpdater
21  {
22  public:
23  using Ptr = std::shared_ptr<SWUpdater>;
24 
34  using FlashStatusCb = std::function<void(float, const std::string&)>;
35 
45  SWUpdater(
46  const ifm3d::Device::Ptr& cam,
47  const ifm3d::SWUpdater::FlashStatusCb& cb = {},
48  std::uint16_t swupdate_recovery_port = ifm3d::SWUPDATER_RECOVERY_PORT,
49  std::optional<ifm3d::Device::swu_version> force_swu_version =
50  std::nullopt);
51 
52  virtual ~SWUpdater();
53 
54  // disable copy/move semantics
55  SWUpdater(SWUpdater&&) = delete;
56  SWUpdater& operator=(SWUpdater&&) = delete;
57  SWUpdater(SWUpdater&) = delete;
58  SWUpdater& operator=(const SWUpdater&) = delete;
59 
67  void RebootToRecovery();
68 
86  bool WaitForRecovery(long timeout_millis = 0);
87 
95  void RebootToProductive();
96 
114  bool WaitForProductive(long timeout_millis = 0);
115 
135  bool FlashFirmware(const std::string& swu_file, long timeout_millis = 0);
136 
137  class IFM3D_EXPORT Impl;
138 
139  private:
140  std::unique_ptr<Impl> pImpl;
141 
142  }; // end: class SWUpdater
143 
144 } // end: namespace ifm3d
145 
146 #endif // IFM3D_SWUPDATER_SWUPDATER_H
ifm3d::SWUpdater
Definition: swupdater.h:20
ifm3d::SWUpdater::FlashStatusCb
std::function< void(float, const std::string &)> FlashStatusCb
Signature for user callback to receive status information about firmware flashing.
Definition: swupdater.h:34