m2mb API docs  25.30.003
m2mb API sets documentation
m2mb_appMng.h
Go to the documentation of this file.
1 /*===============================================================================================*/
2 /* >>> Copyright (C) Telit Communications S.p.A. Italy All Rights Reserved. <<< */
23 #ifndef M2MB_APPMNG_H
24 #define M2MB_APPMNG_H
25 /* Include ======================================================================================*/
26 
27 
28 /* Global declarations ==========================================================================*/
29 
30 #define M2MB_APPMNG_INVALID 0
31 
32 #define M2MB_APPMNG_AUTOSTART 1
33 #define M2MB_APPMNG_NOT_AUTOSTART 0
34 
35 /* max length for each argument */
36 #define M2MB_APPMNG_MAX_ARG_LEN 32
37 /* max numbers of args per app allowed */
38 #define M2MB_APPMNG_MAX_ARG_NUM 10
39 /* max delay start that can be set */
40 #define M2MB_APPMNG_MAX_DELAY 60
41 /* application file extension must be APP_FILE_EXTENSION */
42 #define APP_FILE_EXTENSION ".bin"
43 /* max and minimum filename lenght (extension included) for application file */
44 #define M2MB_APPMNG_MIN_FILEBIN_LEN 5
45 #define M2MB_APPMNG_MAX_FILEBIN_LEN 64
46 
47 #define M2MB_APPMNG_MOD_DIR "/mod/"
48 /* the main application manager directory */
49 
50 /* Global typedefs ==============================================================================*/
51 
52 /* error for App Manager */
53 typedef enum M2MB_APPMNG_RESULT
54 {
55  M2MB_APPMNG_RESULT_SUCCESS,
56  M2MB_APPMNG_RESULT_ERROR,
57  M2MB_APPMNG_RESULT_PTR_ERROR,
58  M2MB_APPMNG_RESULT_NO_MEMORY,
59  M2MB_APPMNG_RESULT_START_ERROR,
60  M2MB_APPMNG_RESULT_STOP_ERROR,
61  M2MB_APPMNG_RESULT_SET_ERROR,
62  M2MB_APPMNG_RESULT_GET_ERROR,
63  M2MB_APPMNG_RESULT_INVALID_STOP,
64  M2MB_APPMNG_RESULT_INVALID_START,
65  /* generic error to analyse */
66  M2MB_APPMNG_RESULT_GENERIC_ERROR,
67  /* provided args on API do not match expected values */
68  M2MB_APPMNG_RESULT_INVALID_ARG,
69  /* virtual address of application is not valid or already in use */
70  M2MB_APPMNG_RESULT_INVALID_ADDRESS,
71  /* not enough RAM memory available */
72  M2MB_APPMNG_RESULT_ERR_AVAILABLE_RAM,
73  /* app file not found in FS: maybe deleted after being inserted in execution list */
74  M2MB_APPMNG_RESULT_ERR_NO_ENTRY,
75  /* internal init error */
76  M2MB_APPMNG_RESULT_ERR_FILEINI,
77  /* no applications in execution list */
78  M2MB_APPMNG_RESULT_ERR_EMPTY_LIST,
79  /* application not in execution list as executable */
80  M2MB_APPMNG_RESULT_NOT_EXE,
81  /* integrity check on binary file fails */
82  M2MB_APPMNG_RESULT_ERR_CRC,
83  M2MB_APPMNG_RESULT_DIFF_CRC_PREAMBLE,
84  /* error during update parameter procedure */
85  M2MB_APPMNG_RESULT_UPDATE_ERROR,
86  /* wrong arg format */
87  M2MB_APPMNG_RESULT_ARG_FORMAT_ERROR,
88  /* arglen exceeded maximum value or 0 */
89  M2MB_APPMNG_RESULT_LEN_ARG_ERROR,
90  /* command not supported, e.g app stop for old version in place */
91  M2MB_APPMNG_RESULT_NOT_SUPPORTED,
92 
93  M2MB_APPMNG_RESULT_ERR_UNKNOWN = 255,
94  M2MB_APPMNG_RESULT_END,
95 
96  ENUM_TO_INT( M2MB_APPMNG_RESULT_E )
97 } M2MB_APPMNG_RESULT_E;
98 
99 typedef enum
100 {
101  /* lenght name of app */
102  M2MB_APPMNG_SEL_CMD_LNAME_APP,
103  /* app name */
104  M2MB_APPMNG_SEL_CMD_NAME,
105  /* not allowed set in user space: checks automatically also integrity: fail in case of integrity error
106  it is current virtual address if app is in running, otherwise it is the address the application will request to run
107  */
108  M2MB_APPMNG_SEL_CMD_ADDRESS,
109  /* only get: total RAM occupied by app in case of running; RAM that will be required to run in case of app not
110  running with about 8K boundary tolerance. Automatic check of integrity is performed: fail in case of integrity error
111  */
112  M2MB_APPMNG_SEL_CMD_RAM,
113  /* number of total args */
114  M2MB_APPMNG_SEL_CMD_TOT_ARGS,
115  /* N arg selected, in get or set, it starts from index 1, index 0 is reserved for name of app ( index 0 => arg[0] )
116  the max length of arg[0] is M2MB_APPMNG_MAX_FILEBIN_LEN */
117  M2MB_APPMNG_SEL_CMD_ARG_N,
118  /* Only for get len of specified arg N: arglen of arg N. Args must be passed as string terminating with NULL carachter'\0'.
119  MAX ARG LEN IS M2MB_APPMNG_MAX_ARG_LEN.
120  */
121  M2MB_APPMNG_SEL_CMD_ARGLEN_N,
122  /* current delay, volatile value, used to delay start or stop of the application */
123  M2MB_APPMNG_SEL_CMD_DELAY,
124  /* permanent saved value of delay in *ini file */
125  M2MB_APPMNG_SEL_CMD_DELAY_INI,
126  /* run flag in file *.ini : permanent */
127  M2MB_APPMNG_SEL_CMD_SET_EXE_AUTO_INI,
128  M2MB_APPMNG_SEL_CMD_STATE,
129  /* set or get more arguments separated by comma, at once as unique string */
130  M2MB_APPMNG_SEL_CMD_ARGS,
131  /* delete all arguments: only for set */
132  M2MB_APPMNG_SEL_CMD_ARGS_DELETE,
133 
134  /* ---- */
135  M2MB_APPMNG_SEL_CMD_END,
136  ENUM_TO_INT( M2MB_APPMNG_SEL_CMD_E )
137 } M2MB_APPMNG_SEL_CMD_E;
138 
139 typedef enum
140 {
141  /* application ready to start */
142  M2MB_APPMNG_STATE_READY,
143  /* application is in the starting process, but it's not yet in the run state( start with delay ) */
144  M2MB_APPMNG_STATE_STARTING,
145  /* application is in the run state */
146  M2MB_APPMNG_STATE_RUN,
147  /* application is in the stopping process, but it's not yet in the stop state( stop with delay ) */
148  M2MB_APPMNG_STATE_STOPPING,
149  /* application is in the stop state */
150  M2MB_APPMNG_STATE_STOP,
151 
152  ENUM_TO_INT( M2MB_APPMNG_STATE_E )
153 } M2MB_APPMNG_STATE_E;
154 
155 typedef struct M2MB_APPMNG_HANDLE_TAG *M2MB_APPMNG_HANDLE;
156 
157 /* Global functions =============================================================================*/
158 /*-----------------------------------------------------------------------------------------------*/
209 /*-----------------------------------------------------------------------------------------------*/
210 
211 M2MB_APPMNG_RESULT_E m2mb_appMng_add( M2MB_APPMNG_HANDLE *pAppMngHandle, CHAR* appName, UINT32 delayStart );
212 
213 /*-----------------------------------------------------------------------------------------------*/
250 /*-----------------------------------------------------------------------------------------------*/
251 
252 M2MB_APPMNG_RESULT_E m2mb_appMng_del( M2MB_APPMNG_HANDLE appMngHandle );
253 
254 /*-----------------------------------------------------------------------------------------------*/
300 /*-----------------------------------------------------------------------------------------------*/
301 
302 M2MB_APPMNG_RESULT_E m2mb_appMng_start( M2MB_APPMNG_HANDLE appMngHandle );
303 
304 /*-----------------------------------------------------------------------------------------------*/
305 
352 /*-----------------------------------------------------------------------------------------------*/
353 
354 M2MB_APPMNG_RESULT_E m2mb_appMng_stop( M2MB_APPMNG_HANDLE appMngHandle );
355 
356 /*-----------------------------------------------------------------------------------------------*/
357 
473 /*-----------------------------------------------------------------------------------------------*/
474 
475 M2MB_APPMNG_RESULT_E m2mb_appMng_setItem( M2MB_APPMNG_HANDLE appMngHandle,
476  M2MB_APPMNG_SEL_CMD_E selCmd,
477  void *pIn,
478  void *pOption
479  );
480 
481 /*-----------------------------------------------------------------------------------------------*/
482 
645 /*-----------------------------------------------------------------------------------------------*/
646 
647 M2MB_APPMNG_RESULT_E m2mb_appMng_getItem( M2MB_APPMNG_HANDLE appMngHandle,
648  M2MB_APPMNG_SEL_CMD_E selCmd,
649  MEM_W *pOut,
650  void *pIn
651  );
652 
653 /*-----------------------------------------------------------------------------------------------*/
654 
681 /*-----------------------------------------------------------------------------------------------*/
682 
683 UINT8 m2mb_appMng_appsNumber( void );
684 
685 /*-----------------------------------------------------------------------------------------------*/
686 
719 /*-----------------------------------------------------------------------------------------------*/
720 
721 M2MB_APPMNG_HANDLE m2mb_appMng_getHandleByN( UINT8 n );
722 
723 /*-----------------------------------------------------------------------------------------------*/
724 
755 /*-----------------------------------------------------------------------------------------------*/
756 
757 M2MB_APPMNG_HANDLE m2mb_appMng_getHandleByName( char *name );
758 
759 /*-----------------------------------------------------------------------------------------------*/
760 
791 /*-----------------------------------------------------------------------------------------------*/
792 
793 M2MB_APPMNG_HANDLE m2mb_appMng_getMyHandle( void );
794 
795 /*-----------------------------------------------------------------------------------------------*/
837 /*-----------------------------------------------------------------------------------------------*/
838 M2MB_APPMNG_RESULT_E m2mb_appMng_checkIntegrity( CHAR* appName, MEM_W *pAddress, UINT32 *pTotRam );
839 
840 /* Global define ================================================================================*/
841 
842 #endif /* M2MB_APPMNG_H */
m2mb_appMng_stop
M2MB_APPMNG_RESULT_E m2mb_appMng_stop(M2MB_APPMNG_HANDLE appMngHandle)
m2mb_appMng_stop
m2mb_appMng_getHandleByName
M2MB_APPMNG_HANDLE m2mb_appMng_getHandleByName(char *name)
m2mb_appMng_getHandleByName
m2mb_appMng_getHandleByN
M2MB_APPMNG_HANDLE m2mb_appMng_getHandleByN(UINT8 n)
m2mb_appMng_getHandleByN
m2mb_appMng_getItem
M2MB_APPMNG_RESULT_E m2mb_appMng_getItem(M2MB_APPMNG_HANDLE appMngHandle, M2MB_APPMNG_SEL_CMD_E selCmd, MEM_W *pOut, void *pIn)
m2mb_appMng_getItem
m2mb_appMng_del
M2MB_APPMNG_RESULT_E m2mb_appMng_del(M2MB_APPMNG_HANDLE appMngHandle)
m2mb_appMng_del
m2mb_appMng_getMyHandle
M2MB_APPMNG_HANDLE m2mb_appMng_getMyHandle(void)
m2mb_appMng_getMyHandle
m2mb_appMng_checkIntegrity
M2MB_APPMNG_RESULT_E m2mb_appMng_checkIntegrity(CHAR *appName, MEM_W *pAddress, UINT32 *pTotRam)
Function to verify integrity of an application file.
m2mb_appMng_appsNumber
UINT8 m2mb_appMng_appsNumber(void)
m2mb_appMng_appsNumber
m2mb_appMng_start
M2MB_APPMNG_RESULT_E m2mb_appMng_start(M2MB_APPMNG_HANDLE appMngHandle)
m2mb_appMng_start
m2mb_appMng_add
M2MB_APPMNG_RESULT_E m2mb_appMng_add(M2MB_APPMNG_HANDLE *pAppMngHandle, CHAR *appName, UINT32 delayStart)
m2mb_appMng_add
m2mb_appMng_setItem
M2MB_APPMNG_RESULT_E m2mb_appMng_setItem(M2MB_APPMNG_HANDLE appMngHandle, M2MB_APPMNG_SEL_CMD_E selCmd, void *pIn, void *pOption)
m2mb_appMng_setItem