![]() |
The reboot persistence feature is enabled by default.
|
![]() |
If you do not connect the edge client to the ThingWorx Platform before starting the SCM client, you will encounter up to a 60-second delay while the reboot survival feature times out.
|
![]() |
If a job is in the TW_SWUPDATE_INSTALLING state when the reboot occurs, a restored job in this state is converted to TW_SWUPDATE_COMPLETED.
|
![]() |
For purposes of fitting this example on the page, line feeds have been inserted.
|
![]() |
For purposes of fitting thi example on the page, the startScm line has been broken up into three lines using line feeds.
|
To Change
|
Use
|
---|---|
Whether the reboot persistence feature is enabled.
|
twSwUpdate_SetRebootSurvivalEnabled(char enabled);
|
The name of the JSON file in which the job list is stored
|
void twSwUpdate_SetRebootSurvivalFileName(char *filename);
|
The path to the JSON file where the job list is stored
|
twSwUpdate_SetRebootSurvivalFilePath(char *path);
|
The path to and the name of the file for warning the client of an imminent shutdown.
|
void twSwUpdate_SetRebootWarningFileFunction(char * fullPathToFile);
|
Handler/Function | Parameters
|
Description | Possible Return Values (if any)
|
---|---|
void persistJobStateToDiskHandler(twSwUpdate* job)
job — This parameter is not used. It is required by the declaration of twSwUpdate_StateChangeHandler.
|
A handler compatible with twSwUpdateNotification_AddRemoveStateChangeHandler(), which, if called, will persist all jobs in the software update manager to disk.
|
void restoreStateFromDiskStartupHandler(twSwUpdateManager *swUpdateManager);
where
swUpdateManager — The software update manager.
|
A handler compatible with twSwUpdate_AddRemoveStartupHandler() that is expected to be called when the manager starts up. This handler reads the current reboot survival file back into the manager.
|
int twSwUpdate_PersistJob(twSwUpdateJob* job,cJSON ** jobObject);
where
job — A twSwUpdateJob structure from the Software Manager list, updatesInProgress.
jobObject — A pointer to a pointer to a JSON object that will be created by this function.
|
Creates a new JSON object as jobObject and populates its fields with the values of the job.
Returns TW_OK on success. On failure, returns TW_INVALID_PARAM or TW_ERROR_ALLOCATING_MEMORY
|
int twSwUpdate_ReadJob(cJSON * jobObject,twSwUpdateJob** job);
where
jobObject — A JSON object, most likely read from a file as part of an array.
job— A pointer to a pointer to atwSwUpdateJob. This job is allocated and populated.
|
Converts a JSON object found at jobObject into a twSwUpdateJob. Note that the twSwUpdateJob is allocated and returned in job.
Returns TW_OK on success. On failure, returns TW_INVALID_PARAM or TW_ERROR_ALLOCATING_MEMORY
|
int twSwUpdate_PersistJobs(const char* pathToJobFile);
where
pathToJobFile — The path on disk of the file to be created.
|
Takes all jobs inside the manager updatesInProgress list and persists them as a JSON file that can be used on restart to restore the service state. The manager should be locked before calling this function
Returns TW_OK on success. On failure, returns TW_INVALID_PARAM or TW_ERROR_WRITING_FILE
|
int twSwUpdate_ReadJobs(const char* pathToJobFile);
where
pathToJobFile — The path on disk of the file to be read.
|
Reads and restores the list of SCM jobs inside the job manager from a JSON file
Returns TW_OK on success. On failure, returns TW_INVALID_PARAM or TW_ERROR_READING_FILE
|
void twSwUpdate_SetRebootSurvivalFilePath(char *path);
where
path — A new path in which to create a reboot survival file. You are responsible for de-allocation of this string on shutdown.
filename — The name to use for the file.
|
Used to override the default reboot survival file path. The default path is the current working directory (application default directory), which is assumed to be writable.
|
void twSwUpdate_SetRebootSurvivalFileName(char *filename);
where
filename — Set a new name for the reboot survival file. You are responsible for de-allocation of this string on shutdown.
|
Used to override the default reboot survival file name. The default value is joblist.json.
|
void twSwUpdate_SetRebootSurvivalEnabled(char enabled);
where
enabled — TRUE to enable these handlers or FALSE to disable them.
|
Used to disable simultaneously the persistJobStateToDiskHandler() and the restoreStateFromDiskStartUpHandler(). These handlers could also be removed from their respective handler lists.
|
void twSwUpdate_SetRebootWarningFileFunction(char * fullPathToFile);
where
fullPathToFile — Set a name for the reboot warning file. You are responsible for deallocation of this string on shutdown.
|
Used to specify the name of a warning file that can be used to alert the client that a shutdown is about to occur. The client can then prepare for the reboot.
|
void twSwUpdate_PersistJobStateToDiskNow();
|
Intended for use in panic situations where a shutdown must occur. Will persist the job list to disk.
|
void twSwUpdate_DeleteJobListFile();
|
Intended ONLY for tests that start a manager with no existing job list.
|
Parameter
|
Description
|
---|---|
entityName
|
The name of the entity associated with this update.
|
json
|
A ::cJSON structure that contains the information provided by the platform for the new ::twSwUpdateJob structure.
|
vdir
|
The virtual path to the directory to which the update file(s) would be downloaded.
|
downloadFunc
|
The function to execute for a download. If the default server file push is used, can be NULL.. WHAT IS the "default server file push"?
|
installFunc
|
The function to execute to perform the installation. Must not be NULL.
|
![]() |
The calling function retains ownership of the \p pointer
The calling function gains ownership of the returned ::twSwUpdateJob structure and is responsible for freeing it with twSwUpdateJob_Delete().
|
![]() |
For publishing purposes, a linefeed and spaces have been added to the signature above. Refer to twSwJob.h in the c subdirectory of the SCM Edge Extension installation.
|
![]() |
For purposes for fitting this example on the page, line feeds have been inserted to break up the value of the scriptParams twId property. In an actual JSON file, the value would appear on one continuous line.
|