Aktualizr
C++ SOTA Client
|
This class provides the main APIs necessary for launching and controlling libaktualizr. More...
#include <aktualizr.h>
Classes | |
struct | InstallationLogEntry |
Get log of installations. More... | |
Public Types | |
using | InstallationLog = std::vector< InstallationLogEntry > |
using | SigHandler = std::function< void(std::shared_ptr< event::BaseEvent >)> |
Public Member Functions | |
Aktualizr (const Config &config) | |
Aktualizr requires a configuration object. More... | |
Aktualizr (const Aktualizr &)=delete | |
Aktualizr & | operator= (const Aktualizr &)=delete |
void | Initialize () |
Initialize aktualizr. More... | |
bool | IsRegistered () const |
Returns true if the device has been registered to the backend succesffully. | |
std::future< void > | RunForever () |
Asynchronously run aktualizr indefinitely until Shutdown is called. More... | |
void | Shutdown () |
Shuts down currently running RunForever() method. | |
std::future< result::CampaignCheck > | CampaignCheck () |
Check for campaigns. More... | |
std::future< void > | CampaignControl (const std::string &campaign_id, campaign::Cmd cmd) |
Act on campaign: accept, decline or postpone. More... | |
std::future< void > | SendDeviceData () |
Send local device data to the server. More... | |
std::future< result::UpdateCheck > | CheckUpdates () |
Fetch Uptane metadata and check for updates. More... | |
std::future< result::Download > | Download (const std::vector< Uptane::Target > &updates) |
Download targets. More... | |
InstallationLog | GetInstallationLog () |
std::vector< Uptane::Target > | GetStoredTargets () |
Get list of targets currently in storage. More... | |
void | DeleteStoredTarget (const Uptane::Target &target) |
Delete a stored target from storage. More... | |
std::unique_ptr< StorageTargetRHandle > | OpenStoredTarget (const Uptane::Target &target) |
Get target downloaded in Download call. More... | |
std::future< result::Install > | Install (const std::vector< Uptane::Target > &updates) |
Install targets. More... | |
std::future< bool > | SendManifest (const Json::Value &custom=Json::nullValue) |
Send installation report to the backend. More... | |
result::Pause | Pause () |
Pause the library operations. More... | |
result::Pause | Resume () |
Resume the library operations. More... | |
void | Abort () |
Aborts the currently running command, if it can be aborted, or waits for it to finish; then removes all other queued calls. More... | |
bool | UptaneCycle () |
Synchronously run an Uptane cycle: check for updates, download any new targets, install them, and send a manifest back to the server. More... | |
void | AddSecondary (const std::shared_ptr< Uptane::SecondaryInterface > &secondary) |
Add new secondary to aktualizr. More... | |
void | SetSecondaryData (const Uptane::EcuSerial &ecu, const std::string &data) |
Store some free-form data to be associated with a particular secondary, to be retrieved later through GetSecondaries | |
std::vector< SecondaryInfo > | GetSecondaries () const |
Returns a list of the registered secondaries, along with some associated metadata. More... | |
boost::signals2::connection | SetSignalHandler (const SigHandler &handler) |
Provide a function to receive event notifications. More... | |
Protected Member Functions | |
Aktualizr (Config config, std::shared_ptr< INvStorage > storage_in, std::shared_ptr< HttpInterface > http_in) | |
Protected Attributes | |
std::shared_ptr< SotaUptaneClient > | uptane_client_ |
This class provides the main APIs necessary for launching and controlling libaktualizr.
Definition at line 20 of file aktualizr.h.
|
explicit |
Aktualizr requires a configuration object.
Examples can be found in the config directory.
Definition at line 13 of file aktualizr.cc.
void Aktualizr::Abort | ( | ) |
Aborts the currently running command, if it can be aborted, or waits for it to finish; then removes all other queued calls.
This doesn't reset the Paused
state, i.e. if the queue was previously paused, it will remain paused, but with an emptied queue. The call is blocking.
Definition at line 183 of file aktualizr.cc.
void Aktualizr::AddSecondary | ( | const std::shared_ptr< Uptane::SecondaryInterface > & | secondary | ) |
Add new secondary to aktualizr.
Must be called before Initialize.
secondary | An object to perform installation on a secondary ECU. |
Definition at line 100 of file aktualizr.cc.
std::future< result::CampaignCheck > Aktualizr::CampaignCheck | ( | ) |
Check for campaigns.
Campaigns are a concept outside of Uptane, and allow for user approval of updates before the contents of the update are known.
Definition at line 115 of file aktualizr.cc.
std::future< void > Aktualizr::CampaignControl | ( | const std::string & | campaign_id, |
campaign::Cmd | cmd | ||
) |
Act on campaign: accept, decline or postpone.
Accepted campaign will be removed from the campaign list but no guarantee is made for declined or postponed items. Applications are responsible for tracking their state but this method will notify the server for device state monitoring purposes.
campaign_id | Campaign ID as provided by CampaignCheck. |
cmd | action to apply on the campaign: accept, decline or postpone |
Definition at line 120 of file aktualizr.cc.
std::future< result::UpdateCheck > Aktualizr::CheckUpdates | ( | ) |
Fetch Uptane metadata and check for updates.
This collects a client manifest, PUTs it to the director, updates the Uptane metadata (including root and targets), and then checks the metadata for target updates.
Definition at line 144 of file aktualizr.cc.
void Aktualizr::DeleteStoredTarget | ( | const Uptane::Target & | target | ) |
Delete a stored target from storage.
This only affects storage of the actual binary data and does not preclude a re-download if a target matches current metadata.
target | Target object matching the desired target in the storage |
Definition at line 214 of file aktualizr.cc.
std::future< result::Download > Aktualizr::Download | ( | const std::vector< Uptane::Target > & | updates | ) |
Download targets.
updates | Vector of targets to download as provided by CheckUpdates. |
Definition at line 149 of file aktualizr.cc.
std::vector< SecondaryInfo > Aktualizr::GetSecondaries | ( | ) | const |
Returns a list of the registered secondaries, along with some associated metadata.
Definition at line 108 of file aktualizr.cc.
std::vector< Uptane::Target > Aktualizr::GetStoredTargets | ( | ) |
Get list of targets currently in storage.
This is intended to be used with DeleteStoredTarget and targets are not guaranteed to be verified and up-to-date with current metadata.
Definition at line 212 of file aktualizr.cc.
void Aktualizr::Initialize | ( | ) |
Initialize aktualizr.
Any secondaries should be added before making this call. This will provision with the server if required. This must be called before using any other aktualizr functions except AddSecondary.
Definition at line 28 of file aktualizr.cc.
std::future< result::Install > Aktualizr::Install | ( | const std::vector< Uptane::Target > & | updates | ) |
Install targets.
updates | Vector of targets to install as provided by CheckUpdates or Download. |
Definition at line 155 of file aktualizr.cc.
std::unique_ptr< StorageTargetRHandle > Aktualizr::OpenStoredTarget | ( | const Uptane::Target & | target | ) |
Get target downloaded in Download call.
Returned target is guaranteed to be verified and up-to-date according to the Uptane metadata downloaded in CheckUpdates call.
target | Target object matching the desired target in the storage. |
Definition at line 216 of file aktualizr.cc.
result::Pause Aktualizr::Pause | ( | ) |
Pause the library operations.
In progress target downloads will be paused and API calls will be deferred.
Definition at line 165 of file aktualizr.cc.
result::Pause Aktualizr::Resume | ( | ) |
Resume the library operations.
Target downloads will resume and API calls issued during the pause will execute in fifo order.
Definition at line 174 of file aktualizr.cc.
std::future< void > Aktualizr::RunForever | ( | ) |
Asynchronously run aktualizr indefinitely until Shutdown is called.
Definition at line 72 of file aktualizr.cc.
std::future< void > Aktualizr::SendDeviceData | ( | ) |
Send local device data to the server.
This includes network status, installed packages, hardware etc.
Definition at line 139 of file aktualizr.cc.
std::future< bool > Aktualizr::SendManifest | ( | const Json::Value & | custom = Json::nullValue | ) |
Send installation report to the backend.
Note that the device manifest is also sent as a part of CheckUpdates and SendDeviceData calls, as well as after a reboot if it was initiated by Aktualizr as a part of an installation process. All these manifests will not include the custom data provided in this call.
custom | Project-specific data to put in the custom field of Uptane manifest |
Definition at line 160 of file aktualizr.cc.
boost::signals2::connection Aktualizr::SetSignalHandler | ( | const SigHandler & | handler | ) |
Provide a function to receive event notifications.
handler | a function that can receive event objects. |
Definition at line 185 of file aktualizr.cc.
bool Aktualizr::UptaneCycle | ( | ) |
Synchronously run an Uptane cycle: check for updates, download any new targets, install them, and send a manifest back to the server.
false
, if the restart is required to continue, true
otherwise Definition at line 35 of file aktualizr.cc.