Zigbee FOTA
The Zigbee firmware over-the-air (Zigbee FOTA) library provides Zigbee endpoint definition, which implements clusters responsible for transferring a firmware file through the Zigbee network. The received data is passed as an upgrade candidate through the DFU target library API.
The library uses the endpoint to:
Discover Zigbee OTA server by sending Match Descriptor Request broadcast messages.
Query the discovered server periodically to check if there is a suitable image for the update.
Transfer the new firmware using the ZCL OTA cluster commands.
Allow the OTA server to manage the upgrade process using the ZCL OTA control commands.
When used, the Zigbee FOTA library replaces the FOTA download library in nRF Connect SDK.
Note
The Zigbee FOTA functionality is available for the Zigbee: Light switch sample.
OTA upgrade entities
The following entities participate in the Zigbee OTA Upgrade process:
OTA Upgrade Client – Runs on the target, that is the device that is being upgraded, and is responsible for downloading and installing the new firmware.
OTA Upgrade Server – Provides the firmware image. The OTA Upgrade Server can be either a standalone third-party device or it can be instantiated on an nRF52840 DK using nRF Util’s DFU over Zigbee procedure.
OTA upgrade process
After querying the OTA Upgrade Server for available images and receiving information about the image, the library begins the OTA upgrade process. The library uses ZBOSS Zigbee stack’s ZCL API to download the image.
After the OTA Upgrade Client downloads the Zigbee OTA image header, the stack verifies the following mandatory fields:
Manufacturer ID - Defined by the
CONFIG_ZIGBEE_FOTA_MANUFACTURER_ID
Kconfig option.Image type - Defined by the
CONFIG_ZIGBEE_FOTA_IMAGE_TYPE
Kconfig option; it may be different than the MCUboot image type value.Hardware version - Defined by the
CONFIG_ZIGBEE_FOTA_HW_VERSION
Kconfig option.Firmware version - Defined by the
CONFIG_MCUBOOT_IMAGE_VERSION
Kconfig option; see Configuring Zigbee FOTA for details.
If all values are accepted, the OTA Upgrade Client downloads the first fragment of the firmware image.
After receiving the first fragment, the DFU target library automatically identifies the type of the image that is being downloaded. For supported upgrade types, see the library documentation page.
Once the download is started, all received data fragments are passed to the DFU target library. The library takes care of where the upgrade candidate is stored, depending on the image type that is being downloaded.
When the download is completed, the download client sends an appropriate event. At this point, the received firmware is tagged as an upgrade candidate and the OTA server is queried for an update time.
Once the OTA server triggers the update process, the library sends a ZIGBEE_FOTA_EVT_FINISHED
callback event.
When the consumer of the library receives this event, it should issue a reboot command to apply the upgrade.
Configuration
To enable the Zigbee FOTA library, set the CONFIG_ZIGBEE_FOTA
Kconfig option.
To configure the Zigbee FOTA library, use the following options:
For detailed steps about configuring the library in a Zigbee sample or application, see Configuring Zigbee FOTA.
Limitations
The Zigbee FOTA library has the following limitations:
The endpoint definition in the library includes the endpoint ID, defined with
CONFIG_ZIGBEE_FOTA_ENDPOINT
. When using the Zigbee FOTA library, this endpoint ID cannot be used for other endpoints.The Zigbee FOTA upgrades are currently only supported on the nRF52840 DK (PCA10056).
The Zigbee FOTA library does not currently support bootloader upgrades.
In case of an MCU reset between the completion of the OTA image transfer and a postponed firmware upgrade, the upgrade will be applied immediately.
API documentation
include/zigbee/zigbee_fota.h
subsys/zigbee/lib/zigbee_fota/src/
- group zigbee_fota
Library for downloading a firmware update through Zigbee network.
Discovers Zigbee OTA server, queries it for new images and downloads the matching file to the secondary partition of MCUboot. After the file has been downloaded, the secondary slot is tagged as having valid firmware inside it.
Defines
-
ZIGBEE_FOTA_EVT_DL_COMPLETE_VAL
Typedefs
-
typedef void (*zigbee_fota_callback_t)(const struct zigbee_fota_evt *evt)
Zigbee FOTA download asynchronous callback function.
- Param evt
Event.
Enums
-
enum zigbee_fota_evt_id
Zigbee FOTA download event IDs.
Values:
-
enumerator ZIGBEE_FOTA_EVT_PROGRESS
Zigbee FOTA download progress report.
-
enumerator ZIGBEE_FOTA_EVT_FINISHED
Zigbee FOTA download finished.
-
enumerator ZIGBEE_FOTA_EVT_ERASE_PENDING
Zigbee FOTA download erase pending.
-
enumerator ZIGBEE_FOTA_EVT_ERASE_DONE
Zigbee FOTA download erase done.
-
enumerator ZIGBEE_FOTA_EVT_ERROR
Zigbee FOTA download error.
-
enumerator ZIGBEE_FOTA_EVT_PROGRESS
Functions
-
int zigbee_fota_init(zigbee_fota_callback_t client_callback)
Initialize the Zigbee firmware over-the-air download library.
- Parameters
client_callback – Callback for the generated events.
- Return values
0 – If successfully initialized. Otherwise, a negative value is returned.
-
void zigbee_fota_abort(void)
Abort all pending updates performed via Zigbee network.
-
void zigbee_fota_signal_handler(zb_bufid_t bufid)
Function for passing Zigbee stack signals to the Zigbee FOTA logic.
- Parameters
bufid – [in] Reference to the Zigbee stack buffer used to pass signal.
-
void zigbee_fota_zcl_cb(zb_bufid_t bufid)
Function for passing ZCL callback events to the Zigbee FOTA logic.
- Parameters
bufid – [in] Reference to the Zigbee stack buffer used to pass event.
-
struct zigbee_fota_event_dl
- #include <zigbee_fota.h>
Zigbee FOTA download progress event data.
-
struct zigbee_fota_evt
- #include <zigbee_fota.h>
Zigbee FOTA download event data.
-
ZIGBEE_FOTA_EVT_DL_COMPLETE_VAL