m2mb API docs  30.00.007
m2mb API sets documentation
m2mb_sys.h File Reference

Base system functions for m2m application. More...

Go to the source code of this file.

Data Structures

struct  M2MB_SYS_OPERATING_MODE_T
 
struct  M2MB_SYS_GET_OPERATING_MODE_RESP_T
 
struct  M2MB_SYS_GENERIC_RESP_T
 

Typedefs

typedef HANDLE M2MB_SYS_HANDLE
 
typedef void(* m2mb_sys_ind_callback) (M2MB_SYS_HANDLE h, M2MB_SYS_IND_E sys_event, UINT16 resp_size, void *resp_struct, void *userdata)
 

Enumerations

enum  M2MB_SYS_OP_MODE_E {
  M2MB_SYS_OP_MODE_ONLINE, M2MB_SYS_OP_MODE_LOW_POWER, M2MB_SYS_OP_MODE_FACTORY_TEST_MODE, M2MB_SYS_OP_MODE_OFFLINE,
  M2MB_SYS_OP_MODE_UNKNOWN, M2MB_SYS_OP_MODE_MAX_VAL
}
 
enum  M2MB_SYS_IND_E { M2MB_SYS_NULL_RESP, M2MB_SYS_GET_OPERATING_MODE_RESP, M2MB_SYS_SET_OPERATING_MODE_RESP, M2MB_SYS_OPERATING_MODE_CHANGED_IND }
 
enum  M2MB_SYS_ERR_CAUSE_E { M2MB_SYS_ERR_OK, M2MB_SYS_ERR_UNKNOWN }
 

Functions

M2MB_RESULT_E m2mb_sys_init (M2MB_SYS_HANDLE *h, m2mb_sys_ind_callback callback, void *userdata)
 m2mb_sys_init initializes SYS service for current client. More...
 
M2MB_RESULT_E m2mb_sys_deinit (M2MB_SYS_HANDLE h)
 m2mb_sys_deinit deinitializes SYS service for current client. More...
 
M2MB_RESULT_E m2mb_sys_get_operating_mode (M2MB_SYS_HANDLE h)
 m2mb_sys_get_operating_mode gets information about operating mode. More...
 
M2MB_RESULT_E m2mb_sys_set_operating_mode (M2MB_SYS_HANDLE h, M2MB_SYS_OP_MODE_E operatingMode, BOOLEAN persistent)
 m2mb_sys_set_operating_mode sets information about operating mode. More...
 
M2MB_RESULT_E m2mb_sys_reboot (int Type)
 m2mb_sys_reboot restarts all the system More...
 

Detailed Description

Base system functions for m2m application.

m2m/m2m_generic/common/m2mb_inc/m2mb_sys.h

@notes Dependencies: m2m/m2m_generic/common/m2mb_inc/m2mb_types.h

Author
mb_
Date
29/08/2017

Enumeration Type Documentation

◆ M2MB_SYS_OP_MODE_E

Enumerator
M2MB_SYS_OP_MODE_ONLINE 

Online

M2MB_SYS_OP_MODE_LOW_POWER 

Low power

M2MB_SYS_OP_MODE_FACTORY_TEST_MODE 

Factory Test mode

M2MB_SYS_OP_MODE_OFFLINE 

Offline

Function Documentation

◆ m2mb_sys_deinit()

M2MB_RESULT_E m2mb_sys_deinit ( M2MB_SYS_HANDLE  h)

m2mb_sys_deinit deinitializes SYS service for current client.

m2mb_sys_deinit deinitialize SYS service for current client freeing the handle passed as first parameter. Calling the m2mb_sys_deinit is useful after using the SYS service in order to free memory space.

Parameters
[in]hfirst parameter is the handle to the SYS service, that will be deinitialized by the function.
Returns
returns M2MB_RESULT_SUCCESS on success, refers to M2MB_RESULT_E for different values.
Note

m2mb_sys_deinit(&h);

M2MB_RESULT_E retVal = M2MB_RESULT_SUCCESS;
M2MB_SYS_HANDLE h;
struct myStruct myUserdata;
retVal = m2mb_sys_init(&h, myCallback, (void*)myUserdata);
//... use SYS APIs ...
retVal = m2mb_sys_deinit(h);
if ( retVal == M2MB_RESULT_SUCCESS )
printf( "m2mb_sys_deinit succeeded");

◆ m2mb_sys_get_operating_mode()

M2MB_RESULT_E m2mb_sys_get_operating_mode ( M2MB_SYS_HANDLE  h)

m2mb_sys_get_operating_mode gets information about operating mode.

m2mb_sys_get_operating_mode gets information about operating mode. The function is asynchronous. This means that the function returns immediately, but the signal information is received in the callback previously set by the m2mb_sys_init function. The response event received in the callback will be the M2MB_SYS_GET_OPERATING_MODE_RESP. The resp_struct must be casted to the M2MB_SYS_GET_OPERATING_MODE_RESP_T type.

Parameters
[in]hthe handle to the SYS service, previously initialized by the m2mb_sys_init function.
Returns
returns M2MB_RESULT_SUCCESS on success, refers to M2MB_RESULT_E for different values.
Note

m2mb_sys_get_operating_mode(h);

void myCallback(M2MB_SYS_HANDLE h, M2MB_SYS_IND_E sys_event, UINT16 resp_size, void *resp_struct, void *myUserdata)
{
switch(sys_event)
{
//...
case M2MB_SYS_GET_OPERATING_MODE_RESP:
{
printf("GET OPERATING MODE resp is err %d, operatingMode %d, persistent %d", resp->err, resp->operatingMode_s.operatingMode, resp->operatingMode_s.persistent);
}
//...
}
}
int main()
{
M2MB_RESULT_E retVal = M2MB_RESULT_SUCCESS;
M2MB_SYS_HANDLE h;
struct myStruct myUserdata;
retVal = m2mb_sys_init(&h, myCallback, (void*)myUserdata);
//...
if ( retVal == M2MB_RESULT_SUCCESS )
printf( "m2mb_sys_get_operating_mode request succeeded");
}

◆ m2mb_sys_init()

M2MB_RESULT_E m2mb_sys_init ( M2MB_SYS_HANDLE *  h,
m2mb_sys_ind_callback  callback,
void *  userdata 
)

m2mb_sys_init initializes SYS service for current client.

m2mb_sys_init initialize SYS service for current client returning the handle that must be passed as first parameter for all SYS actions. Calling the m2mb_sys_init is mandatory before using the SYS service.

Parameters
[in]*hfirst parameter is the handle to the SYS service, that will be initialized by the function.
[in]callbacksecond parameter is the callback that will be called if an event or a response happens.
[in]userdatathird parameter is a pointer to generic user data that will be returned as it is in the callback.
Returns
returns M2MB_RESULT_SUCCESS on success, refers to M2MB_RESULT_E for different values.

m2mb_sys_init(&h, myCallback, myUserdata);

void myCallback(M2MB_SYS_HANDLE h, M2MB_SYS_IND_E sys_event, UINT16 resp_size, void *resp_struct, void *myUserdata)
{
//my code
}
int main()
{
M2MB_RESULT_E retVal = M2MB_RESULT_SUCCESS;
M2MB_SYS_HANDLE h;
struct myStruct myUserdata;
retVal = m2mb_sys_init(&h, myCallback, (void*)myUserdata);
if ( retVal == M2MB_RESULT_SUCCESS )
printf( "m2mb_sys_init succeeded");
}

◆ m2mb_sys_reboot()

M2MB_RESULT_E m2mb_sys_reboot ( int  Type)

m2mb_sys_reboot restarts all the system

This function performs a system reboot

Parameters
[in]TypeUnused, usually must be set to 0
Returns
returns M2MB_RESULT_SUCCESS on success, refers to M2MB_RESULT_E for different values.

m2mb_sys_reboot(0)

M2MB_RESULT_E Ret = m2mb_sys_reboot(0);

◆ m2mb_sys_set_operating_mode()

M2MB_RESULT_E m2mb_sys_set_operating_mode ( M2MB_SYS_HANDLE  h,
M2MB_SYS_OP_MODE_E  operatingMode,
BOOLEAN  persistent 
)

m2mb_sys_set_operating_mode sets information about operating mode.

m2mb_sys_set_operating_mode sets information about operating mode. The function is asynchronous. This means that the function returns immediately, but the signal information is received in the callback previously set by the m2mb_sys_init function. The indication event received in the callback will be the M2MB_SYS_OPERATING_MODE_CHANGED_IND. The resp_struct must be casted to the M2MB_SYS_OPERATING_MODE_T type.

Parameters
[in]hthe handle to the SYS service, previously initialized by the m2mb_sys_init function.
[in]operatingModeoperating mode to set
[in]persistentwhether the operating mode must be persistent or not
Returns
returns M2MB_RESULT_SUCCESS on success, refers to M2MB_RESULT_E for different values.
Note

m2mb_sys_set_operating_mode(h, operatingMode, persistent);

void myCallback(M2MB_SYS_HANDLE h, M2MB_SYS_IND_E sys_event, UINT16 resp_size, void *resp_struct, void *myUserdata)
{
switch(sys_event)
{
//...
case M2MB_SYS_OPERATING_MODE_CHANGED_IND:
{
printf("SET OPERATING MODE is operatingMode %d, persistent %d", resp->operatingMode, resp->persistent);
}
//...
}
}
int main()
{
M2MB_RESULT_E retVal = M2MB_RESULT_SUCCESS;
M2MB_SYS_HANDLE h;
struct myStruct myUserdata;
retVal = m2mb_sys_init(&h, myCallback, (void*)myUserdata);
//...
if ( retVal == M2MB_RESULT_SUCCESS )
printf( "m2mb_sys_set_operating_mode request succeeded");
}
M2MB_SYS_GET_OPERATING_MODE_RESP_T
Definition: m2mb_sys.h:58
M2MB_SYS_OP_MODE_LOW_POWER
Definition: m2mb_sys.h:31
M2MB_SYS_OPERATING_MODE_T
Definition: m2mb_sys.h:52
m2mb_sys_deinit
M2MB_RESULT_E m2mb_sys_deinit(M2MB_SYS_HANDLE h)
m2mb_sys_deinit deinitializes SYS service for current client.
m2mb_sys_get_operating_mode
M2MB_RESULT_E m2mb_sys_get_operating_mode(M2MB_SYS_HANDLE h)
m2mb_sys_get_operating_mode gets information about operating mode.
m2mb_sys_init
M2MB_RESULT_E m2mb_sys_init(M2MB_SYS_HANDLE *h, m2mb_sys_ind_callback callback, void *userdata)
m2mb_sys_init initializes SYS service for current client.
m2mb_sys_reboot
M2MB_RESULT_E m2mb_sys_reboot(int Type)
m2mb_sys_reboot restarts all the system
m2mb_sys_set_operating_mode
M2MB_RESULT_E m2mb_sys_set_operating_mode(M2MB_SYS_HANDLE h, M2MB_SYS_OP_MODE_E operatingMode, BOOLEAN persistent)
m2mb_sys_set_operating_mode sets information about operating mode.