EVENT API 参考
宏定义:
-
WM_EVENT_DECLARE_GROUP(group)
declare event group
Used in moudle’s api header file, Users can only use the name declared by WM_EVENTDECLARE_GROUP
-
WM_EVENT_DEFINE_GROUP(group)
define event group
Used in moudle’s source file,only define one time
-
WM_EVENT_ANY_GROUP
any event group
-
WM_EVENT_ANY_TYPE
any event type
类型定义:
-
typedef const char *wm_event_group_t
group type, Must use the names defined by WM_EVENT_DEFINE_GROUP and declared by WM_EVENT_DECLARE_GROUP
-
typedef void (*wm_event_callback)(wm_event_group_t group, int event, void *data, void *priv)
event callback
- Param group:
[in] event group,module define by WM_EVENT_DEFINE_GROUP
- Param event:
[in] event type
- Param data:
[in] pointer to module event data
- Param priv:
[in] user private data,come from wm_event_add_callback
接口定义:
-
int wm_event_init(void)
init event
- 返回:
WM_ERR_SUCCESS: succeed
WM_ERR_FAILED: failed
-
int wm_event_deinit(void)
deinit event remove all callback before deinit
- 返回:
WM_ERR_SUCCESS: succeed
WM_ERR_FAILED: failed
-
int wm_event_add_callback(wm_event_group_t group, int event, wm_event_callback callback, void *priv)
add callback
备注
This function will send the add action to the event task, the callback will be added at the task loop.
- 参数:
group – [in] event group,module define by WM_EVENT_DEFINE_GROUP, WM_EVENT_ANY_GROUP for filter all group
event – [in] event type,define by modules WM_EVENT_ANY_EVENT for all event in group
callback – [in] user callback function
priv – [in] user private data,it will transfer from callback to user
- 返回:
WM_ERR_SUCCESS: succeed
WM_ERR_FAILED: failed
WM_ERR_INVALID_PARAM: invalid param
-
int wm_event_remove_callback(wm_event_group_t group, int event, wm_event_callback callback, void *priv)
remove callback,all params need same to wm_event_add_callback
备注
This function will send the remove action to the event task, The remove operation will be executed in the task loop, so the function will return WM_SUCCESS even if the callback does not exist.
- 参数:
group – [in] event group,module define by WM_EVENT_DEFINE_GROUP, WM_EVENT_ANY_GROUP for filter all group
event – [in] event type,define by modules WM_EVENT_ANY_EVENT for all event in group
callback – [in] user callback function
priv – [in] user private data
- 返回:
WM_ERR_SUCCESS: succeed
WM_ERR_FAILED: failed
WM_ERR_INVALID_PARAM: invalid param
-
int wm_event_send(wm_event_group_t group, int event, void *data, size_t size)
send event to event queue, it will be process by event task
- 参数:
group – [in] event group, defined by WM_EVENT_DEFINE_GROUP,Do not directly use the char * variable
event – [in] event type
data – [in] pointer to event data will be send
size – [in] data size
- 返回:
WM_ERR_SUCCESS: succeed
WM_ERR_FAILED: failed
WM_ERR_INVALID_PARAM: invalid param