Over The Air (OTA) Update Library
All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages

General Description

Functions to start/stop and query the OTA Agent.

OTA functions for starting, stopping, and getting information about the OTA Agent.

Functions

cy_rslt_t cy_ota_agent_start (cy_ota_network_params_t *network_params, cy_ota_agent_params_t *agent_params, cy_ota_storage_interface_t *storage_interface, cy_ota_context_ptr *ctx_ptr)
 Start the OTA Background Agent. More...
 
cy_rslt_t cy_ota_agent_stop (cy_ota_context_ptr *ctx_ptr)
 Stop OTA Background Agent. More...
 
cy_rslt_t cy_ota_get_update_now (cy_ota_context_ptr ctx_ptr)
 Check for OTA update availability and download update now. More...
 
void cy_ota_set_log_level (CY_LOG_LEVEL_T level)
 Set the OTA log output level. More...
 
cy_rslt_t cy_ota_get_state (cy_ota_context_ptr ota_ptr, cy_ota_agent_state_t *ota_state)
 Get the OTA Agent State. More...
 
cy_rslt_t cy_ota_get_last_error (void)
 Get the last OTA error. More...
 
const char * cy_ota_get_error_string (cy_rslt_t error)
 Get a string representation of the error. More...
 
const char * cy_ota_get_state_string (cy_ota_agent_state_t state_value)
 Get a string Representation of the OTA state. More...
 
const char * cy_ota_get_callback_reason_string (cy_ota_cb_reason_t reason)
 Get a string representation for the callback reason. More...
 
cy_rslt_t cy_ota_ble_download_prepare (cy_ota_context_ptr ctx_ptr)
 Prepare for Bluetooth® OTA Download. More...
 
cy_rslt_t cy_ota_ble_download (cy_ota_context_ptr ctx_ptr, uint32_t update_file_size)
 Bluetooth® OTA Download starting. More...
 
cy_rslt_t cy_ota_ble_download_write (cy_ota_context_ptr ctx_ptr, uint8_t *data_buf, uint16_t len, uint16_t offset)
 Bluetooth® OTA data write. More...
 
cy_rslt_t cy_ota_ble_download_verify (cy_ota_context_ptr ctx_ptr, uint32_t update_file_crc, bool verify_crc_or_signature)
 Bluetooth® OTA Verify download. More...
 
cy_rslt_t cy_ota_ble_download_abort (cy_ota_context_ptr ctx_ptr)
 Abort Bluetooth® OTA download. More...
 

Function Documentation

cy_rslt_t cy_ota_agent_start ( cy_ota_network_params_t network_params,
cy_ota_agent_params_t agent_params,
cy_ota_storage_interface_t storage_interface,
cy_ota_context_ptr ctx_ptr 
)

Start the OTA Background Agent.

Start a thread to monitor for OTA updates. This consumes resources until cy_ota_agent_stop() is called.

Parameters
[in]network_paramsPointer to cy_ota_network_params_t.
[in]agent_paramsPointer to cy_ota_agent_params_t.
[in]storage_interfacePointer to cy_ota_storage_interface_t.
[out]ctx_ptrHandle to store the OTA Agent context structure pointer, Which is used for other OTA calls.
Returns
CY_RSLT_SUCCESS CY_RSLT_OTA_ERROR_BADARG CY_RSLT_OTA_ERROR_ALREADY_STARTED CY_RSLT_OTA_ERROR
cy_rslt_t cy_ota_agent_stop ( cy_ota_context_ptr ctx_ptr)

Stop OTA Background Agent.

Stop the thread to monitor OTA updates and release resources.

Parameters
[in]ctx_ptrPointer to the OTA Agent context storage returned from cy_ota_agent_start();
Returns
CY_RSLT_SUCCESS CY_RSLT_OTA_ERROR_BADARG
cy_rslt_t cy_ota_get_update_now ( cy_ota_context_ptr  ctx_ptr)

Check for OTA update availability and download update now.

Once cy_ota_start() has returned CY_RSLT_SUCCESS, you can initiate an OTA update availability check whenever you require; this supercedes the timing values. It does not change the timer values, and will set the timer to the current values after an OTA download cycle.

Parameters
[in]ctx_ptrPointer to the OTA Agent context storage returned from cy_ota_agent_start();
Returns
CY_RSLT_SUCCESS CY_RSLT_OTA_ERROR_BADARG CY_RSLT_OTA_ERROR_ALREADY_STARTED
void cy_ota_set_log_level ( CY_LOG_LEVEL_T  level)

Set the OTA log output level.

To get the OTA log output, first call cy_log_init(). Call this routine at any time to set the OTA logging level.

Parameters
[in]levelRequired logging level from OTA logs.
Returns
N/A
cy_rslt_t cy_ota_get_state ( cy_ota_context_ptr  ota_ptr,
cy_ota_agent_state_t ota_state 
)

Get the OTA Agent State.

Use this function to determine what state the OTA Agent is in. Do not check if the OTA Agent is in CY_OTA_STATE_AGENT_WAITING because it will interrupt an OTA cycle.

Parameters
[in]ota_ptrPointer to the OTA Agent context returned from cy_ota_agent_start();
[out]ota_stateCurrent OTA State.
Returns
CY_RSLT_SUCCESS sets cy_ota_agent_state_t CY_RSLT_OTA_ERROR_GENERAL
cy_rslt_t cy_ota_get_last_error ( void  )

Get the last OTA error.

The last error value is persistent, and can be queried after cy_ota_agent_stop().

Returns
the last error that occurred (see cy_rslt_t).
const char* cy_ota_get_error_string ( cy_rslt_t  error)

Get a string representation of the error.

This can be called at any time.

Parameters
[in]errorValue returned from cy_ota_get_last_error().
Returns
Pointer to a string (NULL for unknown error).
const char* cy_ota_get_state_string ( cy_ota_agent_state_t  state_value)

Get a string Representation of the OTA state.

This can be called at any time.

Parameters
[in]state_valuecy_ota_agent_state_t
Returns
Pointer to the string (NULL for unknown state).
const char* cy_ota_get_callback_reason_string ( cy_ota_cb_reason_t  reason)

Get a string representation for the callback reason.

This can be called at any time.

Parameters
[in]reasoncy_ota_cb_reason_t
Returns
Pointer to the string (NULL for unknown reason).
cy_rslt_t cy_ota_ble_download_prepare ( cy_ota_context_ptr  ctx_ptr)

Prepare for Bluetooth® OTA Download.

Parameters
[in]ctx_ptrPointer to OTA agent context cy_ota_context_ptr
Returns
CY_RSLT_SUCCESS CY_RSLT_OTA_ERROR_BLE_STORAGE
cy_rslt_t cy_ota_ble_download ( cy_ota_context_ptr  ctx_ptr,
uint32_t  update_file_size 
)

Bluetooth® OTA Download starting.

Parameters
[in]ctx_ptrPointer to OTA agent context cy_ota_context_ptr
[in]update_file_sizeOTA update file size.
Returns
CY_RSLT_SUCCESS CY_RSLT_OTA_ERROR_BLE_STORAGE
cy_rslt_t cy_ota_ble_download_write ( cy_ota_context_ptr  ctx_ptr,
uint8_t *  data_buf,
uint16_t  len,
uint16_t  offset 
)

Bluetooth® OTA data write.

Parameters
[in]ctx_ptrPointer to OTA agent context cy_ota_context_ptr
[in]data_bufPointer to data buffer.
[in]lenData length.
[in]offsetData buffer offset.
Returns
CY_RSLT_SUCCESS CY_RSLT_OTA_ERROR_BLE_STORAGE
cy_rslt_t cy_ota_ble_download_verify ( cy_ota_context_ptr  ctx_ptr,
uint32_t  update_file_crc,
bool  verify_crc_or_signature 
)

Bluetooth® OTA Verify download.

Parameters
[in]ctx_ptrPointer to OTA agent context cy_ota_context_ptr
[in]update_file_crc32 Bit CRC sent from the Host.
[in]verify_crc_or_signatureOTA library need to verify CRC.
Returns
CY_RSLT_SUCCESS CY_RSLT_OTA_ERROR_BLE_VERIFY
cy_rslt_t cy_ota_ble_download_abort ( cy_ota_context_ptr  ctx_ptr)

Abort Bluetooth® OTA download.

Parameters
[in]ctx_ptrPointer to OTA agent context cy_ota_context_ptr
Returns
CY_RSLT_SUCCESS