1 /******************************************************************************
2  * Copyright (c) 2013-2016 Realtek Semiconductor Corp.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16   ******************************************************************************
17   * @file    wifi_ind.h
18   * @author
19   * @version
20   * @brief   This file provides the functions related to event handler mechanism.
21   ******************************************************************************
22   */
23 
24 #ifndef _WIFI_INDICATE_H
25 #define _WIFI_INDICATE_H
26 
27 /** @addtogroup nic NIC
28  *  @ingroup    wlan
29  *  @brief      NIC functions
30  *  @{
31  */
32 
33 #include "wifi_conf.h"
34 
35 #ifdef __cplusplus
36   extern "C" {
37 #endif
38 
39 typedef void (*rtw_event_handler_t)(char *buf, int buf_len, int flags, void* handler_user_data );
40 
41 typedef struct
42 {
43 //	rtw_event_indicate_t	event_cmd;
44 	rtw_event_handler_t	handler;
45 	void*	handler_user_data;
46 } event_list_elem_t;
47 
48 /**
49  * @brief  Initialize the event callback list.
50  * @warning  Please make sure this function has been invoked before
51  *  	 using the event handler related mechanism.
52  * @param  None
53  * @return  None
54  */
55 void init_event_callback_list(void);
56 
57 /**
58   * @brief  Wlan driver indicate event to upper layer through wifi_indication.
59   * @param[in]  event: An event reported from driver to upper layer application. Please refer to rtw_event_indicate_t enum.
60   * @param[in]  buf: If it is not NUL, buf is a pointer to the buffer for message string.
61   * @param[in]  buf_len: The length of the buffer.
62   * @param[in]  flags: Indicate some extra information, sometimes it is 0.
63   * @retval None
64   * @note  If upper layer application triggers additional operations on receiving of wext_wlan_indicate,
65   *			please strictly check current stack size usage (by using uxTaskGetStackHighWaterMark() ),
66   *			and tries not to share the same stack with wlan driver if remaining stack space is not available
67   *			for the following operations.
68   *			ex: using semaphore to notice another thread instead of handing event directly in wifi_indication().
69   */
70 extern void wifi_indication( rtw_event_indicate_t event, char *buf, int buf_len, int flags);
71 
72 /**
73  * @brief  Register the event listener.
74  * @param[in] event_cmds : The event command number indicated.
75  * @param[in] handler_func : the callback function which will
76  *  			  receive and process the event.
77  * @param[in] handler_user_data : user specific data that will be
78  *  			   passed directly to the callback function.
79  * @return  RTW_SUCCESS : if successfully registers the event.
80  * @return  RTW_ERROR : if an error occurred.
81  * @note  Set the same event_cmds with empty handler_func will
82  *  	 unregister the event_cmds.
83  */
84 extern void wifi_reg_event_handler(unsigned int event_cmds, rtw_event_handler_t handler_func, void *handler_user_data);
85 
86 /**
87  * @brief  Un-register the event listener.
88  * @param[in] event_cmds : The event command number indicated.
89  * @param[in] handler_func : the callback function which will
90  *  			  receive and process the event.
91  *
92  * @return  RTW_SUCCESS : if successfully un-registers the event .
93  * @return  RTW_ERROR : if an error occurred.
94  */
95 extern void wifi_unreg_event_handler(unsigned int event_cmds, rtw_event_handler_t handler_func);
96 
97 #ifdef __cplusplus
98   }
99 #endif
100 
101 /*\@}*/
102 
103 #endif //_WIFI_INDICATE_H
104 
105