Release 2.0 beta
[framework/connectivity/libnet-client.git] / include / wifi / network-wifi-intf.h
1 /*
2  *  Network Client Library
3  *
4 * Copyright 2012  Samsung Electronics Co., Ltd
5
6 * Licensed under the Flora License, Version 1.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9
10 * http://www.tizenopensource.org/license
11
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17  *
18  */
19
20
21 #ifndef __NETWORK_WIFI_INTF_H_
22 #define __NETWORK_WIFI_INTF_H_
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28 /**
29  * @file network-wifi-intf.h
30  * @brief This file defines the Wi-Fi specific interface with the application/Connection Manager.
31 */
32
33 /**
34  * \addtogroup  wifi_specific
35  * \{
36 */
37 /*****************************************************************************
38  *      Standard headers
39  *****************************************************************************/
40
41 /*****************************************************************************
42  *      Platform headers
43  *****************************************************************************/
44
45 #include "network-pm-wlan.h"
46 #include "network-cm-intf.h"
47
48 /*****************************************************************************
49  *      Macros and Typedefs
50  *****************************************************************************/
51
52
53 /*****************************************************************************
54  *      Global Enums 
55  *****************************************************************************/
56
57 /**
58 * @enum net_wifi_state_t
59 * This enum indicates wifi state
60 */
61 typedef enum {
62         /** Unknown state */
63         WIFI_UNKNOWN = 0x00,
64         /** Wi-Fi is Off */
65         WIFI_OFF,
66         /** Wi-Fi is On(idle/failure) */
67         WIFI_ON,
68         /** Trying to connect(association/configuration) */
69         WIFI_CONNECTING,
70         /** Wi-Fi is connected to an AP(ready/online) */
71         WIFI_CONNECTED,
72         /** Trying to disconnect(connected, but disconnecting process is on going) */
73         WIFI_DISCONNECTING,
74 } net_wifi_state_t; 
75
76 /**
77 *@enum net_wifi_background_scan_mode_t
78 * This enum indicates background scanning mode.
79 */
80 typedef enum {
81         /** scan cycle : 4, 8, 16, ...128s */
82         WIFI_BGSCAN_MODE_EXPONENTIAL = 0x00,
83         /** scan cycle : 10s */
84         WIFI_BGSCAN_MODE_PERIODIC,
85 } net_wifi_background_scan_mode_t;
86
87 /**
88 *@enum net_wifi_wps_type_t
89 * This enum indicates WPS type.
90 */
91 typedef enum
92 {
93         /** WPS type is PBC */
94         WIFI_WPS_PBC = 0x00,
95         /** WPS type is PIN */
96         WIFI_WPS_PIN
97 } net_wifi_wps_type_t;
98
99 /*****************************************************************************
100  *      Global Structures
101  *****************************************************************************/
102
103 /**
104  * This is the structure to connect with WPS network.
105  */
106 typedef struct {
107         /** PBC / PIN */
108         net_wifi_wps_type_t type;
109         
110         /** Optional. This pin is needed when the user input PIN code */
111         char pin[NET_WLAN_MAX_WPSPIN_LEN + 1];
112 } net_wifi_wps_info_t;
113
114 /**
115  * This is the profile structure to connect hidden WiFi network.
116  */
117 typedef struct {
118         /** Basic feature */
119         char essid[NET_WLAN_ESSID_LEN + 1];
120
121         /** Infrastructure / ad-hoc / auto mode */
122         wlan_connection_mode_type_t wlan_mode;
123
124         /** Security mode and authentication info */
125         wlan_security_info_t security_info;
126 } net_wifi_connection_info_t;
127
128 /*****************************************************************************
129  *      Typedefs 
130  *****************************************************************************/
131
132
133 /*****************************************************************************
134  *      Global Functions 
135  *****************************************************************************/
136
137         
138 /*****************************************************************************
139  *      ConnMan Wi-Fi Client Interface Synchronous API Declaration
140  *****************************************************************************/
141
142
143 /**
144  * @fn   int net_get_wifi_state(net_wifi_state_t *current_state, net_profile_name_t *profile_name)
145  *
146  * This function requests current state of wifi.
147  *
148  * \par Sync (or) Async:
149  * These is a Synchronous API.
150  *
151  * @param[in]    none
152  * @param[out]   current_state  Current wifi state
153  * @param[out]   profile_name   Profile name of current Wi-Fi state\n
154  *                              (valid for WIFI_CONNECTING, WIFI_CONNECTED, WIFI_DISCONNECTING state only)
155  *
156  * @return       NET_ERR_NONE on success, negative values for errors
157  */
158
159 int net_get_wifi_state(net_wifi_state_t *current_state, net_profile_name_t *profile_name);
160
161
162 /**
163  * @fn   int net_wifi_set_background_scan_mode(net_wifi_background_scan_mode_t scan_mode)
164  *
165  * This function sends set background scan mode request to ConnMan daemon,
166  * with background scan mode - default/periodic/exponential
167  * Background scan trigger is restarted if the same mode is set again.
168  *
169  * \par Sync (or) Async:
170  * These is a Synchronous API.
171  *
172  * @param[in]    scan_mode  default/periodic/exponential
173  * @param[out]   none
174  *
175  * @return       NET_ERR_NONE on success, negative values for errors
176  */
177
178 int net_wifi_set_background_scan_mode(net_wifi_background_scan_mode_t scan_mode);
179
180 /**
181  * @fn   int net_specific_scan_wifi(const char *ssid)
182  *
183  * This function sends specific scan request to NetConfig daemon,
184  * with ssid - any AP name
185  *
186  * \par Sync (or) Async:
187  * This is Asynchronous API.
188  *
189  * @param[in]    ssid  Wi-Fi AP name
190  * @param[out]   none
191  *
192  * @return       NET_ERR_NONE on success, negative values for errors
193  */
194
195 int net_specific_scan_wifi(const char *ssid);
196
197 /*****************************************************************************
198  *      ConnMan Wi-Fi Client Interface Asynchronous Function Declaration
199  *****************************************************************************/
200
201 /**
202  * @fn   int net_open_connection_with_wifi_info(const net_wifi_connection_info_t *wifi_info)
203  *
204  * This function requests Wi-Fi open connection. This should be used only for opening
205  * connection with hidden ap
206  *
207  * \par Sync (or) Async:
208  * This is an Asynchronous API.
209  *
210  * @param[in]    wifi_info  Pointer to connection information structure
211  * @param[out]   none
212  *
213  * \par Async Response Message:
214  *        NET_EVENT_OPEN_RSP: Connection Establishment response will be sent asynchronously to the App in the callback function registered.\n
215  *        refer to net_event_cb_t()
216  *
217  * @return       NET_ERR_NONE on success, negative values for errors
218  */
219
220 int net_open_connection_with_wifi_info(const net_wifi_connection_info_t *wifi_info);
221
222
223 /**
224  * @fn   int net_scan_wifi(void)
225  *
226  * This function sends scan request to ConnMan daemon.\n
227  * You can receive scan completion response(NET_EVENT_WIFI_SCAN_RSP) via the callback function registered,\n
228  * and then get scan result by using net_get_profile_list().
229  *
230  *\par Sync (or) Async:
231  * This is an Asynchronous API.
232  *
233  * @param[in]    none
234  * @param[out]   none
235  *
236  * \par Async Response Message:
237  *        NET_EVENT_WIFI_SCAN_RSP: Scan completion response will be sent asynchronously to the App in the callback function registered.\n
238  *        refer to net_event_cb_t()
239  *
240  * @return       NET_ERR_NONE on success, negative values for errors
241  */
242
243 int net_scan_wifi(void);
244
245
246 /**
247  * @fn   int net_wifi_power_on(void)
248  *
249  * This function requests wifi power on.
250  *
251  * \par Sync (or) Async:
252  * This is an Asynchronous API.
253  *
254  * @param[in]    none
255  * @param[out]   none
256  *
257  * \par Async Response Message:
258  *        NET_EVENT_WIFI_POWER_RSP: Wi-Fi Power on response will be sent asynchronously to the App in the callback function registered.\n
259  *        refer to net_event_cb_t()
260  *
261  * @return       NET_ERR_NONE on success, negative values for errors
262  */
263
264 int net_wifi_power_on(void);
265
266
267 /**
268  * @fn   int net_wifi_power_off(void)
269  *
270  * This function requests wifi power off.
271  *
272  * \par Sync (or) Async:
273  * This is an Asynchronous API.
274  *
275  * @param[in]    none
276  * @param[out]   none
277  *
278  * \par Async Response Message:
279  *        NET_EVENT_WIFI_POWER_RSP: Wi-Fi Power off response will be sent asynchronously to the App in the callback function registered.\n
280  *        refer to net_event_cb_t()
281  *
282  * @return       NET_ERR_NONE on success, negative values for errors
283  */
284
285 int net_wifi_power_off(void);
286
287
288 /**
289  * @fn   int net_wifi_enroll_wps(const char *profile_name, net_wifi_wps_info_t *wps_info)
290  *
291  * This function sends enroll wps request to ConnMan daemon,
292  * with profile name and wps information.
293  *
294  * \par Sync (or) Async:
295  * This is an Asynchronous API.
296  *
297  * @param[in]    profile_name  Profile Name to be connected
298  * @param[in]    wps_info      wps type and pin code for WPS PIN(optional)
299  * @param[out]   none
300  *
301  * \par Async Response Message:
302  *        NET_EVENT_WIFI_WPS_RSP : enroll wps response will be sent asynchronously to the App in the callback function registered.\n
303  *        refer to net_event_cb_t()
304  *
305  * @return       NET_ERR_NONE on success, negative values for errors
306  */
307
308 int net_wifi_enroll_wps(const char *profile_name, net_wifi_wps_info_t *wps_info);
309
310
311 /**
312  * \}
313  */
314
315 #ifdef __cplusplus
316 }
317 #endif
318
319 #endif /** __NETWORK_WIFI_INTF_H_ */