#include <firmware_update_trigger.hpp>
Classes | |
struct | NextNodeIDSearchPredicate |
Public Member Functions | |
FirmwareUpdateTrigger (INode &node, IFirmwareVersionChecker &checker) | |
unsigned | getNumPendingNodes () const |
MonotonicDuration | getRequestInterval () const |
bool | isTimerRunning () const |
void | setRequestInterval (const MonotonicDuration interval) |
int | start (NodeInfoRetriever &node_info_retriever, const FirmwareFilePath &arg_common_path_prefix=FirmwareFilePath(), const TransferPriority priority=TransferPriority::OneHigherThanLowest) |
~FirmwareUpdateTrigger () | |
![]() | |
virtual void | handleNodeStatusMessage (const ReceivedDataStructure< protocol::NodeStatus > &msg) |
virtual | ~INodeInfoListener () |
Private Types | |
enum | { DefaultRequestIntervalMs = 1000 } |
typedef MethodBinder< FirmwareUpdateTrigger *, void(FirmwareUpdateTrigger::*)(const ServiceCallResult< protocol::file::BeginFirmwareUpdate > &)> | BeginFirmwareUpdateResponseCallback |
typedef IFirmwareVersionChecker::FirmwareFilePath | FirmwareFilePath |
Private Member Functions | |
INode & | getNode () |
void | handleBeginFirmwareUpdateResponse (const ServiceCallResult< protocol::file::BeginFirmwareUpdate > &result) |
virtual void | handleNodeInfoRetrieved (const NodeID node_id, const protocol::GetNodeInfo::Response &node_info) |
virtual void | handleNodeInfoUnavailable (NodeID node_id) |
virtual void | handleNodeStatusChange (const NodeStatusMonitor::NodeStatusChangeEvent &event) |
virtual void | handleTimerEvent (const TimerEvent &) |
NodeID | pickNextNodeID () const |
void | trySetPendingNode (const NodeID node_id, const FirmwareFilePath &path) |
![]() | |
MonotonicTime | getDeadline () const |
MonotonicDuration | getPeriod () const |
Scheduler & | getScheduler () const |
bool | isRunning () const |
void | startOneShotWithDeadline (MonotonicTime deadline) |
void | startOneShotWithDelay (MonotonicDuration delay) |
void | startPeriodic (MonotonicDuration period) |
void | stop () |
TimerBase (INode &node) | |
Private Attributes | |
ServiceClient< protocol::file::BeginFirmwareUpdate, BeginFirmwareUpdateResponseCallback > | begin_fw_update_client_ |
IFirmwareVersionChecker & | checker_ |
FirmwareFilePath | common_path_prefix_ |
uint8_t | last_queried_node_id_ |
NodeInfoRetriever * | node_info_retriever_ |
Map< NodeID, FirmwareFilePath > | pending_nodes_ |
MonotonicDuration | request_interval_ |
This class subscribes to updates from NodeInfoRetriever in order to detect nodes that need firmware updates. The decision process of whether a firmware update is needed is relayed to the application via IFirmwareVersionChecker. If the application confirms that the update is needed, this class will begin sending uavcan.protocol.file.BeginFirmwareUpdate periodically (period is configurable) to every node that needs an update in a round-robin fashion. There are the following termination conditions for the periodical sending process:
Since the target node (i.e. node that is being updated) will try to retrieve the specified firmware file using the file services (uavcan.protocol.file.*), the provided firmware path must be reachable for the file server (FileServer, BasicFileServer). Normally, an application that serves as UAVCAN firmware update server will include at least the following components:
Implementation details: the class uses memory pool to keep the list of nodes that have not responded yet, which limits the maximum length of the path to the firmware file, which is covered in IFirmwareVersionChecker. To somewhat relieve the maximum path length limitation, the class can be supplied with a common prefix that will be prepended to firmware pathes before sending requests. Interval at which requests are being sent is configurable, but the default value should cover the needs of virtually all use cases (as always).
Definition at line 136 of file firmware_update_trigger.hpp.
|
private |
Definition at line 141 of file firmware_update_trigger.hpp.
|
private |
Definition at line 143 of file firmware_update_trigger.hpp.
|
private |
Enumerator | |
---|---|
DefaultRequestIntervalMs |
Definition at line 145 of file firmware_update_trigger.hpp.
|
inline |
Definition at line 366 of file firmware_update_trigger.hpp.
|
inline |
Definition at line 376 of file firmware_update_trigger.hpp.
|
inlineprivate |
Definition at line 225 of file firmware_update_trigger.hpp.
|
inline |
Definition at line 465 of file firmware_update_trigger.hpp.
|
inline |
Interval at which uavcan.protocol.file.BeginFirmwareUpdate requests are being sent. Note that default value should be OK for any use case.
Definition at line 442 of file firmware_update_trigger.hpp.
|
inlineprivate |
Definition at line 278 of file firmware_update_trigger.hpp.
|
inlineprivatevirtual |
Called when a response to GetNodeInfo request is received. This happens shortly after the node restarts or becomes online for the first time.
Implements uavcan::INodeInfoListener.
Definition at line 196 of file firmware_update_trigger.hpp.
|
inlineprivatevirtual |
Called when the retriever decides that the node does not support the GetNodeInfo service. This method will never be called if the number of attempts is unlimited.
Implements uavcan::INodeInfoListener.
Definition at line 190 of file firmware_update_trigger.hpp.
|
inlineprivatevirtual |
This call is routed directly from NodeStatusMonitor. Default implementation does nothing.
event | Node status change event |
Reimplemented from uavcan::INodeInfoListener.
Definition at line 213 of file firmware_update_trigger.hpp.
|
inlineprivatevirtual |
Implement this method in your class to receive callbacks.
Implements uavcan::TimerBase.
Definition at line 323 of file firmware_update_trigger.hpp.
|
inline |
This method is mostly needed for testing. When triggering is not in progress, the class consumes zero CPU time.
Definition at line 463 of file firmware_update_trigger.hpp.
|
inlineprivate |
Definition at line 243 of file firmware_update_trigger.hpp.
|
inline |
Definition at line 443 of file firmware_update_trigger.hpp.
|
inline |
Starts the object. Once started, it can't be stopped unless destroyed.
node_info_retriever | The object will register itself against this retriever. When the destructor is called, the object will unregister itself. |
common_path_prefix | If set, this path will be prefixed to all firmware pathes provided by the application interface. The prefix does not need to end with path separator; the last trailing one will be removed (so use '//' if you need '/'). By default the prefix is empty. |
Definition at line 397 of file firmware_update_trigger.hpp.
|
inlineprivate |
Definition at line 227 of file firmware_update_trigger.hpp.
|
private |
Definition at line 173 of file firmware_update_trigger.hpp.
|
private |
Definition at line 175 of file firmware_update_trigger.hpp.
|
private |
Definition at line 183 of file firmware_update_trigger.hpp.
|
mutableprivate |
Definition at line 185 of file firmware_update_trigger.hpp.
|
private |
Definition at line 177 of file firmware_update_trigger.hpp.
|
private |
Definition at line 179 of file firmware_update_trigger.hpp.
|
private |
Definition at line 181 of file firmware_update_trigger.hpp.