Z-Wave Protocol Controller Reference
zwave_command_class_firmware_update.c File Reference
#include "zwave_command_class_firmware_update.h"
#include "zwave_command_class_firmware_update_internals.h"
#include "zwave_command_classes_utils.h"
#include "zwave_command_class_version_types.h"
#include <stdio.h>
#include <string.h>
#include "attribute_store_defined_attribute_types.h"
#include "zwave_tx_scheme_selector.h"
#include "zpc_attribute_store_network_helper.h"
#include "attribute_store_helper.h"
#include "attribute_timeouts.h"
#include "ota_time.h"
#include "sl_log.h"
Include dependency graph for zwave_command_class_firmware_update.c:

Macros

#define ATTRIBUTE(type)   ATTRIBUTE_COMMAND_CLASS_FWU_MD_##type
 
#define FIRMWARE_TRANSFER_TIMEOUT   120 * CLOCK_SECOND
 
#define LOG_TAG   "zwave_command_class_firmware_update"
 
#define FWU_DATA_REPORT_ENCAPSULATION_OVERHEAD   6
 Number of bytes used by a Firmware Update Meta Data Report Command (apart from the Data field) More...
 

Functions

static attribute_store_node_t create_firmware_transfer_attribute (attribute_store_node_t firmware_update_node)
 Creates a Firmware Transfer node under an endpoint. More...
 
static void abort_transfer_if_ongoing (attribute_store_node_t firmware_transfer_node)
 Abort a firmware transfer by setting the firmware update state from ONGOING to IDLE, and the last status to ABORTED. More...
 
static size_t get_file_size (const char *file_name)
 Finds the size of a file, in bytes. More...
 
static void start_firmware_update_operation (attribute_store_node_t firmware_transfer_node)
 Helper function that starts a firmware update. More...
 
sl_status_t set_firmware_transfer_file (attribute_store_node_t firmware_transfer_node, const char *file_name)
 Sets the Firmware data file for a Firmware Update. More...
 
sl_status_t set_firmware_transfer_last_status (attribute_store_node_t firmware_transfer_node, zwave_firmware_transfer_status_t status)
 Sets the Firmware transfer last status for a Firmware Update. More...
 
sl_status_t set_transfer_offset (attribute_store_node_t firmware_transfer_node, uint32_t transfer_offset)
 Sets the current offset for a Firmware Transfer. More...
 
uint16_t firmware_transfer_get_theoretical_max_fragment_size (attribute_store_node_t endpoint_node)
 Gets the theoretical max fragment size with a node/endpoint. More...
 
sl_status_t set_firmware_transfer_fragment_size (attribute_store_node_t firmware_transfer_node)
 Sets the Firmware transfer fragment size for a Firmware Update. More...
 
bool node_supports_firmware_activation (attribute_store_node_t endpoint_node)
 Verifies if a node supports Firmware Activation. More...
 
bool node_supports_cc (attribute_store_node_t endpoint_node)
 Verifies if a node supports Firmware CC, which indicates if the supporting node’s Command Classes functionality will continue to function normally during Firmware Update transfer. More...
 
bool is_firmware_target_valid (attribute_store_node_t endpoint_node, uint32_t firmware_target)
 Verifies if a Firmware Target value is valid for an endpoint. More...
 
bool is_firmware_update_ongoing (attribute_store_node_t endpoint_node)
 Verifies if a Firmware Update is ongoing for an endpoint. More...
 
sl_status_t postpone_firmware_update_expiry (attribute_store_node_t endpoint_node)
 Postpones the Firmware Update expiry for an Endpoint. More...
 
sl_status_t command_class_firmware_update_initiate_firmware_update (zwave_node_id_t node_id, zwave_endpoint_id_t endpoint_id, uint32_t firmware_target, unsigned long apply_after, const char *file_name)
 Attempts to start a Firmware Update procedure for a node. More...
 
void command_class_firmware_update_abort_ongoing_firmware_operation (zwave_node_id_t node_id, zwave_endpoint_id_t endpoint_id)
 Abort any ongoing Firmware operation with a node. More...
 

Macro Definition Documentation

◆ ATTRIBUTE

#define ATTRIBUTE (   type)    ATTRIBUTE_COMMAND_CLASS_FWU_MD_##type

◆ FIRMWARE_TRANSFER_TIMEOUT

#define FIRMWARE_TRANSFER_TIMEOUT   120 * CLOCK_SECOND

Timeout after which we consider a firmware update aborted if we don't hear anything. This should stay higher than SEND_DATA_EMERGENCY_TIMEOUT

◆ FWU_DATA_REPORT_ENCAPSULATION_OVERHEAD

#define FWU_DATA_REPORT_ENCAPSULATION_OVERHEAD   6

Number of bytes used by a Firmware Update Meta Data Report Command (apart from the Data field)

◆ LOG_TAG

#define LOG_TAG   "zwave_command_class_firmware_update"

Function Documentation

◆ abort_transfer_if_ongoing()

static void abort_transfer_if_ongoing ( attribute_store_node_t  firmware_transfer_node)
static

Abort a firmware transfer by setting the firmware update state from ONGOING to IDLE, and the last status to ABORTED.

Nothing will happen if the reported state is not ONGOING. (i.e. already idle, waiting for activation or reboot)

Parameters
firmware_transfer_nodeAttribute Store node for Firmware Update attribute (ATTRIBUTE(FW_TRANSFER))
Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_firmware_transfer_attribute()

static attribute_store_node_t create_firmware_transfer_attribute ( attribute_store_node_t  firmware_update_node)
static

Creates a Firmware Transfer node under an endpoint.

Parameters
firmware_update_nodeAttribute Store node for Firmware Update attribute (ATTRIBUTE(FWU))
Returns
attribute_store_node_t for the created firmware_transfer_node.
Here is the caller graph for this function:

◆ get_file_size()

static size_t get_file_size ( const char *  file_name)
static

Finds the size of a file, in bytes.

Parameters
file_nameThe path of the file to determine the file size
Returns
The size of the file, in bytes
Here is the caller graph for this function:

◆ start_firmware_update_operation()

static void start_firmware_update_operation ( attribute_store_node_t  firmware_transfer_node)
static

Helper function that starts a firmware update.

Parameters
firmware_transfer_nodeAttribute Store node under which the Firmware Target must be set.
Here is the caller graph for this function: