m2mb API docs  25.30.003
m2mb API sets documentation
m2mb_backup.h File Reference

Header file for m2mb_backup APIs. More...

Go to the source code of this file.

Typedefs

typedef void * M2MB_BACKUP_HANDLE
 
typedef void(* m2mb_backup_ind_callback) (M2MB_BACKUP_HANDLE h, M2MB_BACKUP_EVT_E backup_event, UINT16 resp_size, void *resp_struct, void *userdata)
 

Enumerations

enum  M2MB_BACKUP_EVT_E { M2MB_BACKUP_EVENT_DUMMY }
 

Functions

M2MB_RESULT_E m2mb_backup_init (M2MB_BACKUP_HANDLE *pHandle, m2mb_backup_ind_callback callback, void *userdata)
 m2mb_backup_init initializes the backup system More...
 
M2MB_RESULT_E m2mb_backup_deinit (M2MB_BACKUP_HANDLE handle)
 m2mb_backup_deinit deinitializes the backup management system More...
 
M2MB_RESULT_E m2mb_backup_get_enable (M2MB_BACKUP_HANDLE handle, BOOLEAN *isEnabled)
 m2mb_backup_get_enable verifies if the backup system is enabled More...
 
M2MB_RESULT_E m2mb_backup_set_enable (M2MB_BACKUP_HANDLE handle, BOOLEAN isEnabled)
 m2mb_backup_set_enable enables or disables backup. More...
 

Detailed Description

Header file for m2mb_backup APIs.

m2m/m2m_common/m2mb_inc/m2mb_backup.h

m2mb_backup APIs provide actions and events for file backup management. When the user enables the backup, after reboot, the system verify if the FIRST user application has been backuped. If not, the system verify if the CRC of the file in filesystem is correct and if yes, it backs up the user application in a specific nand sector. Every time at boot the system verify if the user application in filesystem is correct, and if not, it restores the application present in nand. The first user application is that has the lower delay in ini file (appcfg.ini).

@notes

Author
Alessandro Bonetti
Date
26/09/2018

Function Documentation

◆ m2mb_backup_deinit()

M2MB_RESULT_E m2mb_backup_deinit ( M2MB_BACKUP_HANDLE  handle)

m2mb_backup_deinit deinitializes the backup management system

It returns a NULL pointer for a specific handle, and in case of last handle has to be freed, it frees the main handle

Parameters
[in]handleIt is the handle to the backup service, that will be freed by the function.
Returns
returns M2MB_RESULT_SUCCESS on success, a different value on error.
Note
<Notes>

m2mb_backup_deinit(h);

int main()
{
M2MB_RESULT_E retVal = M2MB_RESULT_SUCCESS;
M2MB_BACKUP_HANDLE h = NULL;
retVal = m2mb_backup_init(&h, NULL, NULL);
if ( retVal == M2MB_RESULT_SUCCESS )
printf( "m2mb_backup_init succeeded");
}

◆ m2mb_backup_get_enable()

M2MB_RESULT_E m2mb_backup_get_enable ( M2MB_BACKUP_HANDLE  handle,
BOOLEAN *  isEnabled 
)

m2mb_backup_get_enable verifies if the backup system is enabled

It returns information about enabling backup system

Parameters
[in]handleIt is the handle to the backup service, that will be freed by the function.
[out]*isEnabledIt is the pointer where information about enabling will be stored
Returns
returns M2MB_RESULT_SUCCESS on success, a different value on error.
Note
<Notes>

m2mb_backup_get_enable(h);

int main()
{
M2MB_RESULT_E retVal = M2MB_RESULT_SUCCESS;
M2MB_BACKUP_HANDLE h = NULL;
BOOLEAN enbled;
retVal = m2mb_backup_init(&h, NULL, NULL);
if ( retVal == M2MB_RESULT_SUCCESS )
printf( "m2mb_backup_init succeeded");
retVal = m2mb_backup_get_enable(h, &enbled);
if ( retVal == M2MB_RESULT_SUCCESS )
{
if (enbled == TRUE)
{
printf( "Backup enabled");
}
else
{
printf( "Backup disabled");
}
}
}

◆ m2mb_backup_init()

M2MB_RESULT_E m2mb_backup_init ( M2MB_BACKUP_HANDLE *  pHandle,
m2mb_backup_ind_callback  callback,
void *  userdata 
)

m2mb_backup_init initializes the backup system

m2mb_backup_init initializes the backup handle and the backup state machine

Parameters
[out]*pHandleIt is the handle to the backup service, that will be initialized by the function.
[in]callbackIt is the callback that will be called if an event or a response happens. In this case is a dummy callback, it will never be called.
[in]*userdataIt is a pointer to generic user data that will be returned as it is in the callback. As the callback, it is a dummy parameter.
Returns
returns M2MB_RESULT_SUCCESS on success, a different value on error.
Note
<Notes>

m2mb_backup_init(&h);

int main()
{
M2MB_RESULT_E retVal = M2MB_RESULT_SUCCESS;
M2MB_BACKUP_HANDLE h = NULL;
retVal = m2mb_backup_init(&h, NULL, NULL);
if ( retVal == M2MB_RESULT_SUCCESS )
printf( "m2mb_backup_init succeeded");
}

◆ m2mb_backup_set_enable()

M2MB_RESULT_E m2mb_backup_set_enable ( M2MB_BACKUP_HANDLE  handle,
BOOLEAN  isEnabled 
)

m2mb_backup_set_enable enables or disables backup.

In order to apply that value the system must be rebooted

Parameters
[in]handleIt is the handle to the backup service, that will be freed by the function.
[in]isEnabledIt is the enable/disable of backup system
Returns
returns M2MB_RESULT_SUCCESS on success, a different value on error.
Note
In case of isEnable=FALSE, the system erase the NAND back up partition and set the flag in filesystem

m2mb_backup_set_enable(h);

int main()
{
M2MB_RESULT_E retVal = M2MB_RESULT_SUCCESS;
M2MB_BACKUP_HANDLE h = NULL;
BOOLEAN enbled = TRUE;
retVal = m2mb_backup_init(&h, NULL, NULL);
if ( retVal == M2MB_RESULT_SUCCESS )
printf( "m2mb_backup_init succeeded");
retVal = m2mb_backup_set_enable(h, enbled);
if ( retVal == M2MB_RESULT_SUCCESS )
{
printf( "Backup enabled");
}
}
m2mb_backup_deinit
M2MB_RESULT_E m2mb_backup_deinit(M2MB_BACKUP_HANDLE handle)
m2mb_backup_deinit deinitializes the backup management system
m2mb_backup_set_enable
M2MB_RESULT_E m2mb_backup_set_enable(M2MB_BACKUP_HANDLE handle, BOOLEAN isEnabled)
m2mb_backup_set_enable enables or disables backup.
m2mb_backup_init
M2MB_RESULT_E m2mb_backup_init(M2MB_BACKUP_HANDLE *pHandle, m2mb_backup_ind_callback callback, void *userdata)
m2mb_backup_init initializes the backup system
m2mb_backup_get_enable
M2MB_RESULT_E m2mb_backup_get_enable(M2MB_BACKUP_HANDLE handle, BOOLEAN *isEnabled)
m2mb_backup_get_enable verifies if the backup system is enabled