IoTivity-Lite
Software Update

Notify the application of a new software update and perform the update. More...

Typedefs

typedef bool(* oc_swupdate_on_validate_update_error_fn_t) (const oc_rep_t *rep, oc_swupdate_validate_update_error_t error, void *data)
 callback invoked by oc_swupdate_validate_update when an error is encountered More...
 

Enumerations

enum  oc_swupdate_result_t {
  OC_SWUPDATE_RESULT_IDLE = 0 , OC_SWUPDATE_RESULT_SUCCESS , OC_SWUPDATE_RESULT_LESS_RAM , OC_SWUPDATE_RESULT_LESS_FLASH ,
  OC_SWUPDATE_RESULT_CONN_FAIL , OC_SWUPDATE_RESULT_SVV_FAIL , OC_SWUPDATE_RESULT_INVALID_URL , OC_SWUPDATE_RESULT_UNSUPPORTED_PROT ,
  OC_SWUPDATE_RESULT_UPGRADE_FAIL
}
 OCF defined software update results. More...
 
enum  oc_swupdate_validate_update_error_t {
  OC_SWUPDATE_VALIDATE_UPDATE_ERROR_INVALID_IMPLEMENTATION , OC_SWUPDATE_VALIDATE_UPDATE_ERROR_INVALID_PROPERTY = -8 , OC_SWUPDATE_VALIDATE_UPDATE_ERROR_READONLY_PROPERTY , OC_SWUPDATE_VALIDATE_UPDATE_ERROR_INVALID_PROPERTY_VALUE ,
  OC_SWUPDATE_VALIDATE_UPDATE_ERROR_UPDATETIME_NOT_SET , OC_SWUPDATE_VALIDATE_UPDATE_ERROR_UPDATETIME_INVALID , OC_SWUPDATE_VALIDATE_UPDATE_ERROR_PURL_NOT_SET , OC_SWUPDATE_VALIDATE_UPDATE_ERROR_PURL_INVALID
}
 Validation error codes. More...
 

Functions

long oc_swupdate_dump (size_t device)
 Save device swupdate to storage. More...
 
long oc_swupdate_load (size_t device)
 Load device swupdate from storage. More...
 
void oc_swupdate_notify_done (size_t device, oc_swupdate_result_t result)
 callback to notify if a new software version is complete More...
 
void oc_swupdate_notify_downloaded (size_t device, const char *version, oc_swupdate_result_t result)
 callback to notify if a new software version is downloaded More...
 
void oc_swupdate_notify_new_version_available (size_t device, const char *version, oc_swupdate_result_t result)
 callback to notify if a new software version is available More...
 
void oc_swupdate_notify_upgrading (size_t device, const char *version, oc_clock_time_t timestamp, oc_swupdate_result_t result)
 callback to notify if a new software version is upgrading More...
 
void oc_swupdate_set_impl (const oc_swupdate_cb_t *swupdate_impl)
 sets the callbacks for software upgrade More...
 
bool oc_swupdate_validate_update (size_t device, const oc_rep_t *rep, oc_swupdate_on_validate_update_error_fn_t on_error, void *data)
 validates the payload of a software update request More...
 

Detailed Description

Notify the application of a new software update and perform the update.

Typedef Documentation

◆ oc_swupdate_on_validate_update_error_fn_t

typedef bool(* oc_swupdate_on_validate_update_error_fn_t) (const oc_rep_t *rep, oc_swupdate_validate_update_error_t error, void *data)

callback invoked by oc_swupdate_validate_update when an error is encountered

Parameters
repproperty that caused the error (for OC_SWUPDATE_VALIDATE_UPDATE_ERROR_INVALID_PROPERTY, OC_SWUPDATE_VALIDATE_UPDATE_ERROR_READONLY_PROPERTY, OC_SWUPDATE_VALIDATE_UPDATE_ERROR_INVALID_PROPERTY_VALUE), NULL for other errors
errorerror code
datauser data
Returns
true if oc_swupdate_validate_update should continue
false if oc_swupdate_validate_update should stop

Enumeration Type Documentation

◆ oc_swupdate_result_t

OCF defined software update results.

Enumerator
OC_SWUPDATE_RESULT_IDLE 

Idle.

OC_SWUPDATE_RESULT_SUCCESS 

software update successful

OC_SWUPDATE_RESULT_LESS_RAM 

not enough RAM

OC_SWUPDATE_RESULT_LESS_FLASH 

not enough FLASH

OC_SWUPDATE_RESULT_CONN_FAIL 

connection failure

OC_SWUPDATE_RESULT_SVV_FAIL 

version failure

OC_SWUPDATE_RESULT_INVALID_URL 

invalid URL

OC_SWUPDATE_RESULT_UNSUPPORTED_PROT 

unsupported protocol for URL

OC_SWUPDATE_RESULT_UPGRADE_FAIL 

upgrade failure

◆ oc_swupdate_validate_update_error_t

Validation error codes.

Enumerator
OC_SWUPDATE_VALIDATE_UPDATE_ERROR_INVALID_IMPLEMENTATION 

software update callbacks not assigned correctly

OC_SWUPDATE_VALIDATE_UPDATE_ERROR_INVALID_PROPERTY 

invalid property

OC_SWUPDATE_VALIDATE_UPDATE_ERROR_READONLY_PROPERTY 

trying to update a read-only property

OC_SWUPDATE_VALIDATE_UPDATE_ERROR_INVALID_PROPERTY_VALUE 

invalid property value

OC_SWUPDATE_VALIDATE_UPDATE_ERROR_UPDATETIME_NOT_SET 

updatetime property is not set

OC_SWUPDATE_VALIDATE_UPDATE_ERROR_UPDATETIME_INVALID 

updatetime property has invalid value

OC_SWUPDATE_VALIDATE_UPDATE_ERROR_PURL_NOT_SET 

purl property not set

OC_SWUPDATE_VALIDATE_UPDATE_ERROR_PURL_INVALID 

purl property has invalid value

Function Documentation

◆ oc_swupdate_dump()

long oc_swupdate_dump ( size_t  device)

Save device swupdate to storage.

Parameters
deviceindex of the device
Returns
<0 on error
>=0 on success, number of bytes written to storage

◆ oc_swupdate_load()

long oc_swupdate_load ( size_t  device)

Load device swupdate from storage.

Parameters
deviceindex of the device
Returns
<0 on error
>=0 on success, number of bytes read from storage

◆ oc_swupdate_notify_done()

void oc_swupdate_notify_done ( size_t  device,
oc_swupdate_result_t  result 
)

callback to notify if a new software version is complete

Parameters
devicethe device identifier
resultstatus

◆ oc_swupdate_notify_downloaded()

void oc_swupdate_notify_downloaded ( size_t  device,
const char *  version,
oc_swupdate_result_t  result 
)

callback to notify if a new software version is downloaded

Parameters
devicethe device identifier
versionversion of the software (cannot be NULL)
resultstatus

◆ oc_swupdate_notify_new_version_available()

void oc_swupdate_notify_new_version_available ( size_t  device,
const char *  version,
oc_swupdate_result_t  result 
)

callback to notify if a new software version is available

Parameters
devicethe device identifier
versionversion of the software (cannot be NULL)
resultstatus

◆ oc_swupdate_notify_upgrading()

void oc_swupdate_notify_upgrading ( size_t  device,
const char *  version,
oc_clock_time_t  timestamp,
oc_swupdate_result_t  result 
)

callback to notify if a new software version is upgrading

Parameters
devicethe device identifier
versionversion of the software (cannot be NULL)
timestamptimestamp when the upgrade starts
resultstatus

◆ oc_swupdate_set_impl()

void oc_swupdate_set_impl ( const oc_swupdate_cb_t *  swupdate_impl)

sets the callbacks for software upgrade

Parameters
swupdate_implthe structure with the software update callbacks
Note
the callbacks are copied to runtime variable, so the validity of the structure is only required during the call to this function

◆ oc_swupdate_validate_update()

bool oc_swupdate_validate_update ( size_t  device,
const oc_rep_t *  rep,
oc_swupdate_on_validate_update_error_fn_t  on_error,
void *  data 
)

validates the payload of a software update request

Parameters
devicedevice index
repparsed payload of sofware update request to verify
on_errorcallback invoked when an error is encountered
datacustom user data passed to on_error
Returns
true if the payload is valid
false if the payload is invalid