Aktualizr
C++ SOTA Client
secondaryinterface.h
1 #ifndef UPTANE_SECONDARYINTERFACE_H
2 #define UPTANE_SECONDARYINTERFACE_H
3 
4 #include <string>
5 
6 #include "json/json.h"
7 
8 #include "uptane/secondaryconfig.h"
9 #include "uptane/tuf.h"
10 #include "utilities/events.h"
11 
12 /* Json snippet returned by sendMetaXXX():
13  * {
14  * valid = true/false,
15  * wait_for_target = true/false
16  * }
17  */
18 
19 namespace Uptane {
20 
22  public:
23  explicit SecondaryInterface(SecondaryConfig sconfig_in) : sconfig(std::move(sconfig_in)) {}
24  virtual ~SecondaryInterface() = default;
25  virtual EcuSerial getSerial() { return Uptane::EcuSerial(sconfig.ecu_serial); }
26  virtual Uptane::HardwareIdentifier getHwId() { return Uptane::HardwareIdentifier(sconfig.ecu_hardware_id); }
27  virtual PublicKey getPublicKey() = 0;
28 
29  virtual Json::Value getManifest() = 0;
30  virtual bool putMetadata(const RawMetaPack& meta_pack) = 0;
31  virtual int32_t getRootVersion(bool director) = 0;
32  virtual bool putRoot(const std::string& root, bool director) = 0;
33 
34  virtual bool sendFirmwareAsync(const std::shared_ptr<std::string>& data) = 0;
35  const SecondaryConfig sconfig;
36  void addEventsChannel(std::shared_ptr<event::Channel> channel) { events_channel = std::move(channel); }
37 
38  protected:
39  void sendEvent(std::shared_ptr<event::BaseEvent> event) {
40  if (events_channel) {
41  (*events_channel)(std::move(event));
42  }
43  }
44 
45  private:
46  std::shared_ptr<event::Channel> events_channel;
47 };
48 } // namespace Uptane
49 
50 #endif // UPTANE_SECONDARYINTERFACE_H
General data structures.
Definition: types.cc:6
Base data types that are used in The Update Framework (TUF), part of UPTANE.
Aktualizr status events.
Definition: events.cc:4