nRF5 IoT SDK  v0.9.0
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Application IoT DFU

API for upgrading firmware in user application. More...

Data Structures

struct  iot_dfu_firmware_block_t
 Description of single block of firmware. More...
 
struct  iot_dfu_firmware_desc_t
 Description of the new firmware that has been written into flash memory. More...
 

Typedefs

typedef void(* iot_dfu_callback_t )(uint32_t result, iot_dfu_evt_t evt)
 IOT DFU module's application callback. More...
 

Enumerations

enum  iot_dfu_evt_t {
  IOT_DFU_WRITE_COMPLETE,
  IOT_DFU_ERROR
}
 IoT DFU module's events. More...
 

Functions

uint32_t iot_dfu_init (iot_dfu_callback_t cb)
 Function for initializing IOT DFU module. More...
 
uint32_t iot_dfu_file_create (iot_file_t **pp_file)
 Function for creating a PStorage IoT File reference for flash operations and setting start address of PStorage File. More...
 
uint32_t iot_dfu_firmware_validate (iot_dfu_firmware_desc_t *p_firmware_desc)
 Function for validating the CRC of the received image. More...
 
uint32_t iot_dfu_firmware_apply (iot_dfu_firmware_desc_t *p_firmware_desc)
 Function for rebooting device and trigger bootloader to swap the new firmware. More...
 

Detailed Description

API for upgrading firmware in user application.

Typedef Documentation

typedef void(* iot_dfu_callback_t)(uint32_t result, iot_dfu_evt_t evt)

IOT DFU module's application callback.

Parameters
[in]resultResult of the received event.
[in]eventEvent from IoT DFU module.
Return values
None.

Enumeration Type Documentation

IoT DFU module's events.

Enumerator
IOT_DFU_WRITE_COMPLETE 

Write operation finishes with success.

IOT_DFU_ERROR 

DFU event indicating that an error occurs during update.

Function Documentation

uint32_t iot_dfu_file_create ( iot_file_t **  pp_file)

Function for creating a PStorage IoT File reference for flash operations and setting start address of PStorage File.

Note
Application should ensure that correct word sized alignment is given at the beginning and between Application image and Softdevice image while updating them at the same time.
Parameters
[out]pp_fileReference to PStorage File.
Return values
NRF_SUCCESSon success, an error_code otherwise.
uint32_t iot_dfu_firmware_apply ( iot_dfu_firmware_desc_t p_firmware_desc)

Function for rebooting device and trigger bootloader to swap the new firmware.

Note
Currently the following combinations are allowed:
  • Application
  • Bootloader
  • SoftDevice with Application
  • SoftDevice with Bootloader
Parameters
[in]p_firmware_descDescription of the firmware. Must have been set to zeros on all unused fields.
Returns
NRF_SUCCESS on success, an error_code otherwise.
uint32_t iot_dfu_firmware_validate ( iot_dfu_firmware_desc_t p_firmware_desc)

Function for validating the CRC of the received image.

Parameters
[in]p_firmware_descDescription of the firmware. Must have been set to zeros on all unused fields.
Return values
NRF_SUCCESSon success, an error_code otherwise.
uint32_t iot_dfu_init ( iot_dfu_callback_t  cb)

Function for initializing IOT DFU module.

Note
The iot_dfu does not hold any state. The application must ensure that only one firmware image is written at once. Remember to register pstorage event handler to allow IoT File module to work.

err_code = softdevice_sys_evt_handler_set(sys_evt_dispatch); APP_ERROR_CHECK(err_code);

static void sys_evt_dispatch(uint32_t sys_evt) { pstorage_sys_event_handler(sys_evt); }

err_code = pstorage_init(); APP_ERROR_CHECK(err_code);

Parameters
[in]cbCallback to be called upon IoT file write success and failure, or any IoT DFU error event.
Return values
NRF_SUCCESSon success, an error_code otherwise.