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 
9 #include <memory>
10 #include <vector>
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(ifm3d::Device::Ptr cam,
46  const ifm3d::SWUpdater::FlashStatusCb& cb = {},
47  const std::uint16_t swupdate_recovery_port =
48  ifm3d::SWUPDATER_RECOVERY_PORT);
49 
50  virtual ~SWUpdater();
51 
52  // disable copy/move semantics
53  SWUpdater(SWUpdater&&) = delete;
54  SWUpdater& operator=(SWUpdater&&) = delete;
55  SWUpdater(SWUpdater&) = delete;
56  SWUpdater& operator=(const SWUpdater&) = delete;
57 
65  void RebootToRecovery();
66 
84  bool WaitForRecovery(long timeout_millis = 0);
85 
93  void RebootToProductive();
94 
112  bool WaitForProductive(long timeout_millis = 0);
113 
133  bool FlashFirmware(const std::string& swu_file, long timeout_millis = 0);
134 
135  class IFM3D_NO_EXPORT Impl;
136 
137  private:
138  std::unique_ptr<Impl> pImpl;
139 
140  }; // end: class SWUpdater
141 
142 } // end: namespace ifm3d
143 
144 #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