libwifi-direct refactoring
[platform/core/connectivity/libwifi-direct.git] / include / wifi-direct.h
1 /*
2  * libwifi-direct
3  *
4  * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Sungsik Jang <sungsik.jang@samsung.com>, Dongwook Lee <dwmax.lee@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22 #ifndef __WIFI_DIRECT_INTERFACE_H_
23 #define __WIFI_DIRECT_INTERFACE_H_
24
25 #include <errno.h>
26 #include <stdbool.h>
27
28 #ifdef __cplusplus
29 extern "C"
30 {
31 #endif
32
33
34 /**
35  * @addtogroup CAPI_NET_WIFI_DIRECT_MODULE
36  * @{
37  */
38
39 /**
40  * @brief Enumeration for Wi-Fi Direct error code
41  */
42 typedef enum
43 {
44         WIFI_DIRECT_ERROR_NONE = 0,  /**< Successful */
45         WIFI_DIRECT_ERROR_NOT_PERMITTED = -EPERM,  /** Operation not permitted(1) */
46         WIFI_DIRECT_ERROR_OUT_OF_MEMORY = -ENOMEM,  /** Out of memory(12) */
47         WIFI_DIRECT_ERROR_RESOURCE_BUSY = -EBUSY,  /** Device or resource busy(16) */
48         WIFI_DIRECT_ERROR_INVALID_PARAMETER = -EINVAL,  /** Invalid function parameter(22) */
49         WIFI_DIRECT_ERROR_CONNECTION_TIME_OUT = -ETIMEDOUT,  /**< Connection timed out(110) */
50         WIFI_DIRECT_ERROR_NOT_INITIALIZED = -0x00008000|0x0201,  /**< Not initialized */
51         WIFI_DIRECT_ERROR_COMMUNICATION_FAILED = -0x00008000|0x0202,  /**< I/O error */
52         WIFI_DIRECT_ERROR_WIFI_USED = -0x00008000|0x0203,  /**< WiFi is being used */
53         WIFI_DIRECT_ERROR_MOBILE_AP_USED = -0x00008000|0x0204,  /**< Mobile AP is being used */
54         WIFI_DIRECT_ERROR_CONNECTION_FAILED = -0x00008000|0x0205,  /**< Connection failed */
55         WIFI_DIRECT_ERROR_AUTH_FAILED = -0x00008000|0x0206,  /**< Authentication failed */
56         WIFI_DIRECT_ERROR_OPERATION_FAILED = -0x00008000|0x0207,  /**< Operation failed */
57         WIFI_DIRECT_ERROR_TOO_MANY_CLIENT = -0x00008000|0x0208,  /**< Too many client */
58 } wifi_direct_error_e;
59
60 /**
61  * @brief Enumeration for Wi-Fi Direct link status
62  */
63 typedef enum
64 {
65         WIFI_DIRECT_STATE_DEACTIVATED = 0,
66                                                                         /**< */
67         WIFI_DIRECT_STATE_DEACTIVATING, /**< */
68         WIFI_DIRECT_STATE_ACTIVATING,           /**< */
69         WIFI_DIRECT_STATE_ACTIVATED,            /**< */
70         WIFI_DIRECT_STATE_DISCOVERING,  /**< */
71         WIFI_DIRECT_STATE_CONNECTING,   /**< */
72         WIFI_DIRECT_STATE_DISCONNECTING,        /**< */
73         WIFI_DIRECT_STATE_CONNECTED,            /**< */
74         WIFI_DIRECT_STATE_GROUP_OWNER   /**< */
75 } wifi_direct_state_e;
76
77 /**
78  * @brief Enumeration for Wi-Fi Direct device state
79  */
80 typedef enum
81 {
82         WIFI_DIRECT_DEVICE_STATE_ACTIVATED,
83         WIFI_DIRECT_DEVICE_STATE_DEACTIVATED,
84 } wifi_direct_device_state_e;
85
86 /**
87  * @brief Enumeration for Wi-Fi Direct discovery state
88  */
89 typedef enum
90 {
91         WIFI_DIRECT_ONLY_LISTEN_STARTED,
92         WIFI_DIRECT_DISCOVERY_STARTED,
93         WIFI_DIRECT_DISCOVERY_FOUND,
94         WIFI_DIRECT_DISCOVERY_FINISHED,
95 } wifi_direct_discovery_state_e;
96
97 /**
98  * @brief Enumeration for Wi-Fi Direct connection state
99  */
100 typedef enum
101 {
102         WIFI_DIRECT_CONNECTION_REQ,                     /**< */
103         WIFI_DIRECT_CONNECTION_WPS_REQ,         /**< */
104         WIFI_DIRECT_CONNECTION_IN_PROGRESS,                     /**< */
105         WIFI_DIRECT_CONNECTION_RSP,                     /**< */
106         WIFI_DIRECT_DISASSOCIATION_IND,                 /**< */
107         WIFI_DIRECT_DISCONNECTION_RSP,                  /**< */
108         WIFI_DIRECT_DISCONNECTION_IND,                  /**< */
109         WIFI_DIRECT_GROUP_CREATED,                      /**< */
110         WIFI_DIRECT_GROUP_DESTROYED,                    /**< */
111         WIFI_DIRECT_INVITATION_REQ,
112 } wifi_direct_connection_state_e;
113
114 /**
115  * @brief Enumeration for Wi-Fi Direct secondary device type
116  */
117 typedef enum
118 {
119         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_COMPUTER_PC = 1,                      /**< */
120         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_COMPUTER_SERVER = 2,          /**< */
121         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_COMPUTER_MEDIA_CTR = 3,       /**< */
122         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_COMPUTER_UMPC = 4,            /**< */
123         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_COMPUTER_NOTEBOOK = 5,        /**< */
124         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_COMPUTER_DESKTOP = 6,         /**< */
125         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_COMPUTER_MID = 7,                     /**< */
126         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_COMPUTER_NETBOOK = 8,         /**< */
127         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_INPUT_KEYBOARD = 1,                           /**< */
128         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_INPUT_MOUSE = 2,                      /**< */
129         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_INPUT_JOYSTICK = 3,           /**< */
130         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_INPUT_TRACKBALL = 4,          /**< */
131         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_INPUT_CONTROLLER = 5,         /**< */
132         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_INPUT_REMOTE = 6,                     /**< */
133         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_INPUT_TOUCHSCREEN = 7,/**< */
134         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_INPUT_BIO_READER = 8,         /**< */
135         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_INPUT_BAR_READER = 9,         /**< */
136         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_PRINTER_PRINTER = 1,          /**< */
137         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_PRINTER_SCANNER = 2,          /**< */
138         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_PRINTER_FAX = 3,                              /**< */
139         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_PRINTER_COPIER = 4,           /**< */
140         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_PRINTER_ALLINONE = 5,         /**< */
141         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_CAMERA_DIGITAL_STILL = 1,             /**< */
142         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_CAMERA_VIDEO = 2,                     /**< */
143         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_CAMERA_WEBCAM = 3,            /**< */
144         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_CAMERA_SECONDARYURITY = 4,    /**< */
145         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_STORAGE_NAS = 1,                      /**< */
146         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_NETWORK_INFRA_AP = 1,                                 /**< */
147         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_NETWORK_INFRA_ROUTER = 2,                     /**< */
148         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_NETWORK_INFRA_SWITCH = 3,                     /**< */
149         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_NETWORK_INFRA_GATEWAY = 4,            /**< */
150         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_DISPLAY_TV = 1,                               /**< */
151         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_DISPLAY_PIC_FRAME = 2,        /**< */
152         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_DISPLAY_PROJECTOR = 3,        /**< */
153         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_DISPLAY_MONITOR = 4,          /**< */
154         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_MULTIMEDIA_DAR = 1,                           /**< */
155         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_MULTIMEDIA_PVR = 2,                           /**< */
156         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_MULTIMEDIA_MCX = 3,                           /**< */
157         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_MULTIMEDIA_STB = 4,                           /**< */
158         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_MULTIMEDIA_MSMAME = 5,                /**< */
159         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_MULTIMEDIA_PVP = 6,                           /**< */
160         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_GAME_XBOX = 1,                /**< */
161         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_GAME_XBOX_360 = 2,    /**< */
162         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_GAME_PS = 3,                          /**< */
163         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_GAME_CONSOLE = 4,             /**< */
164         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_GAME_PORTABLE = 5,    /**< */
165         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_PHONE_WM = 1,                 /**< */
166         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_PHONE_SINGLE = 2,             /**< */
167         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_PHONE_DUAL = 3,               /**< */
168         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_PHONE_SM_SINGLE = 4,
169                                                                                                                 /**< */
170         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_PHONE_SM_DUAL = 5,    /**< */
171         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_AUDIO_TUNER = 1,              /**< */
172         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_AUDIO_SPEAKER = 2,    /**< */
173         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_AUDIO_PMP = 3,                /**< */
174         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_AUDIO_HEADSET = 4,    /**< */
175         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_AUDIO_HEADPHONE = 5,
176                                                                                                                 /**< */
177         WIFI_DIRECT_SECONDARY_DEVICE_TYPE_AUDIO_MIC = 6,                /**< */
178 } wifi_direct_secondary_device_type_e;
179
180 /**
181  * @brief Enumeration for Wi-Fi Direct primary device type
182  */
183 typedef enum
184 {
185         WIFI_DIRECT_PRIMARY_DEVICE_TYPE_COMPUTER = 1,           /**< */
186         WIFI_DIRECT_PRIMARY_DEVICE_TYPE_INPUT_DEVICE = 2,       /**< */
187         WIFI_DIRECT_PRIMARY_DEVICE_TYPE_PRINTER = 3,            /**< */
188         WIFI_DIRECT_PRIMARY_DEVICE_TYPE_CAMERA = 4,             /**< */
189         WIFI_DIRECT_PRIMARY_DEVICE_TYPE_STORAGE = 5,            /**< */
190         WIFI_DIRECT_PRIMARY_DEVICE_TYPE_NETWORK_INFRA = 6,              /**< */
191         WIFI_DIRECT_PRIMARY_DEVICE_TYPE_DISPLAY = 7,            /**< */
192         WIFI_DIRECT_PRIMARY_DEVICE_TYPE_MULTIMEDIA_DEVICE = 8,          /**< */
193         WIFI_DIRECT_PRIMARY_DEVICE_TYPE_GAME_DEVICE = 9,        /**< */
194         WIFI_DIRECT_PRIMARY_DEVICE_TYPE_TELEPHONE = 10, /**< */
195         WIFI_DIRECT_PRIMARY_DEVICE_TYPE_AUDIO = 11,             /**< */
196         WIFI_DIRECT_PRIMARY_DEVICE_TYPE_OTHER = 255                     /**< */
197 } wifi_direct_primary_device_type_e;
198
199 /**
200 * @brief Enumeration for Wi-Fi WPS type
201 */
202 typedef enum {
203         WIFI_DIRECT_WPS_TYPE_NONE = 0x00,  /**< No WPS type */
204         WIFI_DIRECT_WPS_TYPE_PBC = 0x01,  /**< Push Button Configuration */
205         WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY = 0x02,  /**< Display PIN code */
206         WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD = 0x04,  /**< Provide the keypad to input the PIN */
207 } wifi_direct_wps_type_e;
208
209
210 /**
211  * @struct wifi_direct_discovered_peer_info_s
212  * Wi-Fi Direct buffer structure to store result of peer discovery
213  */
214 typedef struct
215 {
216         char *device_name;  /** Null-terminated device friendly name. */
217         char *mac_address;  /** Device's P2P Device Address */
218         char *interface_address;  /** Device's P2P Interface Address. Valid only if device is a P2P GO. */
219         int channel;  /** Channel the device is listening on. */
220         bool is_connected;  /** Is peer connected*/
221         bool is_group_owner;  /** Is an active P2P Group Owner */
222         bool is_persistent_group_owner;  /** Is a stored Persistent GO */
223         wifi_direct_primary_device_type_e primary_device_type;  /** Primary category of device */
224         wifi_direct_secondary_device_type_e secondary_device_type;  /** Sub category of device */
225         int supported_wps_types;  /** The list of supported WPS type. \n
226         The OR operation on #wifi_direct_wps_type_e can be used like #WIFI_DIRECT_WPS_TYPE_PBC | #WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY */
227         char *ssid;  /**< Service set identifier - DEPRECATED */
228 } wifi_direct_discovered_peer_info_s;
229
230
231 /**
232  * @struct wifi_direct_connected_peer_info_s
233  * Wi-Fi Direct buffer structure to store information of connected peer
234  */
235 typedef struct
236 {
237         char* device_name;  /** Device friendly name. */
238         char* ip_address;  /**< The IP address */
239         char* mac_address;  /** Device's P2P Device Address */
240         char* interface_address;  /** Device's P2P Interface Address */
241         bool p2p_supported;  /* whether peer is a P2P device */
242         wifi_direct_primary_device_type_e       primary_device_type;  /* primary category of device */
243         int channel;  /* Operating channel */
244         char* ssid;  /**< Service set identifier - DEPRECATED */
245 } wifi_direct_connected_peer_info_s;
246
247 /**
248  * Notification callback function type. \n
249  *
250  * Discover notifications can occur at the peers or P2P groups are found.
251  *
252  * @param event             Specifies the types of notifications.
253  *                          - WIFI_DIRECT_DISCOVERY_STARTED
254  *                          - WIFI_DIRECT_ONLY_LISTEN_STARTED
255  *                          - WIFI_DIRECT_DISCOVERY_FOUND
256  *                          - WIFI_DIRECT_DISCOVERY_FINISHED
257  * @param error_code        In failure case.
258  * @param user_data         User can transfer the user specific data in callback.
259  *
260  */
261 typedef void (*wifi_direct_discovery_state_chagned_cb) (int error_code,
262                                                                                                                 wifi_direct_discovery_state_e discovery_state,
263                                                                                                                 void *user_data);
264
265 /**
266  * Notification callback function type. \n
267  *
268  * Activation notifications callback function type.
269  *
270  * @param event             Specifies the types of notifications.
271  *                          - WIFI_DIRECT_DEVICE_STATE_ACTIVATED
272  *                          - WIFI_DIRECT_DEVICE_STATE_DEACTIVATED
273  * @param error_code        In failure case.
274  * @param user_data         User can transfer the user specific data in callback.
275  *
276  */
277 typedef void (*wifi_direct_device_state_changed_cb) (int error_code,
278                                                                                                          wifi_direct_device_state_e device_state,
279                                                                                                          void *user_data);
280
281 /**
282  * connection notification callback function type. \n
283  *
284  * @param event             Specifies the types of notifications.
285  *                          - WIFI_DIRECT_CONNECTION_REQ
286  *                          - WIFI_DIRECT_CONNECTION_WPS_REQ
287  *                          - WIFI_DIRECT_CONNECTION_IN_PROGRESS
288  *                          - WIFI_DIRECT_CONNECTION_RSP
289  *                          - WIFI_DIRECT_DISASSOCIATION_IND
290  *                          - WIFI_DIRECT_DISCONNECTION_RSP
291  *                          - WIFI_DIRECT_DISCONNECTION_IND
292  *                          - WIFI_DIRECT_GROUP_CREATED
293  *                          - WIFI_DIRECT_GROUP_DESTROYED
294  *
295  * @param error_code        In failure case.
296  *
297  * @param param1        additional data for connection. ex) MAC
298  * @param param2        additional data for connection. ex) SSID
299  *
300  * @param user_data         User can transfer the user specific data in callback.
301  *
302  */
303 typedef void (*wifi_direct_connection_state_changed_cb) (int error_code,
304                                                                                                                  wifi_direct_connection_state_e connection_state,
305                                                                                                                  const char *mac_address,
306                                                                                                                  void *user_data);
307
308 /**
309 * @brief Called when IP address of client is assigned when your device is group owner.
310 * @param[in] mac_address  The MAC address of connection peer
311 * @param[in] ip_address  The IP address of connection peer
312 * @param[in] interface_address  The interface address of connection peer
313 * @param[in] user_data  The user data passed from the callback registration function
314 * @see wifi_direct_set_client_ip_address_assigned_cb()
315 * @see wifi_direct_unset_client_ip_address_assigned_cb()
316 */
317 typedef void (*wifi_direct_client_ip_address_assigned_cb) (const char *mac_address,
318                                                                                                                  const char *ip_address,
319                                                                                                                  const char *interface_address,
320                                                                                                                  void *user_data);
321
322
323
324 /*=============================================================================
325                                          Wifi Direct Client APIs
326 =============================================================================*/
327
328 /*****************************************************************************/
329 /* wifi_direct_initialize API function prototype
330  * int wifi_direct_initialize (void);
331  */
332 /**
333  * \brief       This API shall register the client application with the Wi-Fi Direct server and  initialize the various variables. \n
334  *
335  * \pre None.
336  *
337  * \post Application is registered.
338  *
339  * \see wifi_direct_device_state_changed_cb
340  * \see wifi_direct_discovery_state_chagned_cb
341  * \see wifi_direct_connection_state_changed_cb
342  *
343  * \par Sync (or) Async:
344  * This is a Synchronous API.
345  *
346  * \warning
347  *  None
348  *
349  * \return Return Type (int) \n
350  *
351  * - WIFI_DIRECT_ERROR_NONE on success \n
352  * - WIFI_DIRECT_ERROR_OPERATION_FAILED for "Unkown error" \n
353  * - WIFI_DIRECT_ERROR_OUT_OF_MEMORY for "Out of memory" \n
354  * - WIFI_DIRECT_ERROR_COMMUNICATION_FAILED for "I/O error" \n
355  * - WIFI_DIRECT_ERROR_TOO_MANY_CLIENT for "Too many users" \n
356  * - WIFI_DIRECT_ERROR_RESOURCE_BUSY for "Device or resource busy" \n
357  * - WIFI_DIRECT_ERROR_STRANGE_CLIENT for "Invalid Client" \n
358  *
359  * \par Prospective Clients:
360  * External Apps.
361  *
362  * \remarks None.
363  * \code
364  *
365  * #include <wifi-direct.h>
366  *
367  * void foo(void)
368  * {
369  *
370  * int result;
371  *
372  * result = wifi_direct_initialize();
373  *
374  * if(result == WIFI_DIRECT_ERROR_NONE).........// Successfully connected to the wifi direct server
375  *
376  * \endcode
377  ******************************************************************************/
378 int wifi_direct_initialize(void);
379
380
381 /*****************************************************************************************/
382 /* wifi_direct_deinitialize API function prototype
383  * int wifi_direct_deinitialize(void);
384  */
385
386 /**
387  * \brief This API shall deregister the client application with the Wi-Fi Direct server and releases all resources.
388  *
389  * \pre Application must be already registered to the Wi-Fi Direct server.
390  *
391  * \post Application is de-registered.
392  *
393  * \see wifi_direct_initialize
394  *
395  * \par Sync (or) Async:
396  * This is a Synchronous API.
397  *
398  * \warning
399  *  None
400  *
401  *
402  * \par Async Response Message:
403  *        None
404  *
405  *
406  * \return Return Type (int) \n
407  * - WIFI_DIRECT_ERROR_NONE on success \n
408  * - WIFI_DIRECT_ERROR_OPERATION_FAILED for "Unkown error" \n
409  * - WIFI_DIRECT_ERROR_OUT_OF_MEMORY for "Out of memory" \n
410  * - WIFI_DIRECT_ERROR_COMMUNICATION_FAILED for "I/O error" \n
411  * - WIFI_DIRECT_ERROR_NOT_PERMITTED for "Operation not permitted" \n
412  * - WIFI_DIRECT_ERROR_RESOURCE_BUSY for "Device or resource busy" \n
413  * - WIFI_DIRECT_ERROR_STRANGE_CLIENT for "Invalid Client" \n
414  *
415  * \par Prospective Clients:
416  * External Apps.
417  *
418  * \code
419  *
420  * #include <wifi-direct.h>
421  *
422  * void foo(void)
423  * {
424
425  * int result;
426  *
427  * result = wifi_direct_deinitialize();
428  *
429  * if(result == WIFI_DIRECT_ERROR_NONE)......... // Deregister is successful
430  *
431  *\endcode
432  *
433  *\remarks None.
434  *
435  ******************************************************************************/
436 int wifi_direct_deinitialize(void);
437
438
439 /*****************************************************************************/
440 /* wifi_direct_set_connection_state_changed_cb API function prototype
441  * int wifi_direct_set_connection_state_changed_cb(wifi_direct_device_state_changed_cb cb, void* user_data)
442  */
443 /**
444  * \brief       This API shall register the activation callback function and user data from client. \n
445  *
446  * \pre The Client should be initialized.
447  *
448  * \see wifi_direct_initialize
449  * \see wifi_direct_device_state_changed_cb
450  *
451  * \par Sync (or) Async:
452  * This is a Synchronous API.
453  *
454  * \warning
455  *  None
456  *
457  * \param[in] cb    Application Callback function pointer to receive Wi-Fi Direct events
458  * \param[in] user_data    user data
459  *
460  * \return Return Type (int) \n
461  *
462  * - WIFI_DIRECT_ERROR_NONE on success \n
463  * - WIFI_DIRECT_ERROR_NOT_PERMITTED for "Operation not permitted" \n
464  *
465  * \par Prospective Clients:
466  * External Apps.
467  *
468  * \remarks None.
469  * \code
470  *
471  * #include <wifi-direct.h>
472  *
473  * void foo(void)
474  * {
475  *
476  * int result;
477  *
478  * result = wifi_direct_set_connection_state_changed_cb(_cb_activation, void* user_data);
479  *
480  * if(result == WIFI_DIRECT_ERROR_NONE).........// Successfully registered the callback function
481  *
482  * \endcode
483  ******************************************************************************/
484 int wifi_direct_set_device_state_changed_cb(wifi_direct_device_state_changed_cb cb, void *user_data);
485
486
487 /*****************************************************************************/
488 /* wifi_direct_unset_connection_state_changed_cb API function prototype
489  * int wifi_direct_unset_connection_state_changed_cb(void)
490  */
491 /**
492  * \brief       This API shall deregister the activation callback function and user data from client. \n
493  *
494  * \pre The Client should be initialized.
495  *
496  * \see wifi_direct_initialize
497  * \see wifi_direct_set_connection_state_changed_cb
498  *
499  * \par Sync (or) Async:
500  * This is a Synchronous API.
501  *
502  * \warning
503  *  None
504  *
505  * \return Return Type (int) \n
506  *
507  * - WIFI_DIRECT_ERROR_NONE on success \n
508  * - WIFI_DIRECT_ERROR_NOT_PERMITTED for "Operation not permitted" \n
509  *
510  * \par Prospective Clients:
511  * External Apps.
512  *
513  * \remarks None.
514  * \code
515  *
516  * #include <wifi-direct.h>
517  *
518  * void foo(void)
519  * {
520  *
521  * int result;
522  *
523  * result = wifi_direct_unset_connection_state_changed_cb();
524  *
525  * if(result == WIFI_DIRECT_ERROR_NONE).........// Successfully deregistered the callback function
526  *
527  * \endcode
528  ******************************************************************************/
529 int wifi_direct_unset_device_state_changed_cb(void);
530
531
532
533 /*****************************************************************************/
534 /* wifi_direct_set_discovery_state_changed_cb API function prototype
535  * int wifi_direct_set_discover_state_changed_cb(wifi_direct_discovery_state_chagned_cb cb, void* user_data)
536  */
537 /**
538  * \brief       This API shall register the discover callback function and user data from client. \n
539  *
540  * \pre The Client should be initialized.
541  *
542  * \see wifi_direct_initialize
543  * \see wifi_direct_discovery_state_chagned_cb
544  *
545  * \par Sync (or) Async:
546  * This is a Synchronous API.
547  *
548  * \warning
549  *  None
550  *
551  * \param[in] cb    Application Callback function pointer to receive Wi-Fi Direct events
552  * \param[in] user_data    user data
553  *
554  * \return Return Type (int) \n
555  *
556  * - WIFI_DIRECT_ERROR_NONE on success \n
557  * - WIFI_DIRECT_ERROR_NOT_PERMITTED for "Operation not permitted" \n
558  *
559  * \par Prospective Clients:
560  * External Apps.
561  *
562  * \remarks None.
563  * \code
564  *
565  * #include <wifi-direct.h>
566  *
567  * void foo(void)
568  * {
569  *
570  * int result;
571  *
572  * result = wifi_direct_set_discovery_state_changed_cb(_cb_discover, void* user_data);
573  *
574  * if(result == WIFI_DIRECT_ERROR_NONE).........// Successfully registered the callback function
575  *
576  * \endcode
577  ******************************************************************************/
578 int wifi_direct_set_discovery_state_changed_cb(wifi_direct_discovery_state_chagned_cb cb, void *user_data);
579
580
581 /*****************************************************************************/
582 /* wifi_direct_unset_discovery_state_changed_cb API function prototype
583  * int wifi_direct_unset_discovery_state_changed_cb(void)
584  */
585 /**
586  * \brief       This API shall deregister the discover callback function and user data from client. \n
587  *
588  * \pre The Client should be initialized.
589  *
590  * \see wifi_direct_initialize
591  * \see wifi_direct_set_discovery_state_changed_cb
592  *
593  * \par Sync (or) Async:
594  * This is a Synchronous API.
595  *
596  * \warning
597  *  None
598  *
599  * \return Return Type (int) \n
600  *
601  * - WIFI_DIRECT_ERROR_NONE on success \n
602  * - WIFI_DIRECT_ERROR_NOT_PERMITTED for "Operation not permitted" \n
603  *
604  * \par Prospective Clients:
605  * External Apps.
606  *
607  * \remarks None.
608  * \code
609  *
610  * #include <wifi-direct.h>
611  *
612  * void foo(void)
613  * {
614  *
615  * int result;
616  *
617  * result = wifi_direct_unset_discovery_state_changed_cb();
618  *
619  * if(result == WIFI_DIRECT_ERROR_NONE).........// Successfully deregistered the callback function
620  *
621  * \endcode
622  ******************************************************************************/
623 int wifi_direct_unset_discovery_state_changed_cb(void);
624
625
626
627 /*****************************************************************************/
628 /* wifi_direct_set_connection_state_changed_cb API function prototype
629  * int wifi_direct_set_connection_state_changed_cb(wifi_direct_connection_state_changed_cb cb, void* user_data)
630  */
631 /**
632  * \brief       This API shall register the connection callback function and user data from client. \n
633  *
634  * \pre The Client should be initialized.
635  *
636  * \see wifi_direct_initialize
637  * \see wifi_direct_connection_state_changed_cb
638  *
639  * \par Sync (or) Async:
640  * This is a Synchronous API.
641  *
642  * \warning
643  *  None
644  *
645  * \param[in] cb    Application Callback function pointer to receive Wi-Fi Direct events
646  * \param[in] user_data    user data
647  *
648  * \return Return Type (int) \n
649  *
650  * - WIFI_DIRECT_ERROR_NONE on success \n
651  * - WIFI_DIRECT_ERROR_NOT_PERMITTED for "Operation not permitted" \n
652  *
653  * \par Prospective Clients:
654  * External Apps.
655  *
656  * \remarks None.
657  * \code
658  *
659  * #include <wifi-direct.h>
660  *
661  * void foo(void)
662  * {
663  *
664  * int result;
665  *
666  * result = wifi_direct_set_connection_state_changed_cb(_cb_connection, void* user_data);
667  *
668  * if(result == WIFI_DIRECT_ERROR_NONE).........// Successfully registered the callback function
669  *
670  * \endcode
671  ******************************************************************************/
672 int wifi_direct_set_connection_state_changed_cb(wifi_direct_connection_state_changed_cb cb, void *user_data);
673
674
675 /*****************************************************************************/
676 /* wifi_direct_unset_connection_state_changed_cb API function prototype
677  * int wifi_direct_unset_connection_state_changed_cb(void)
678  */
679 /**
680  * \brief       This API shall deregister the connection callback function and user data from client. \n
681  *
682  * \pre The Client should be initialized.
683  *
684  * \see wifi_direct_initialize
685  * \see wifi_direct_set_connection_state_changed_cb
686  *
687  * \par Sync (or) Async:
688  * This is a Synchronous API.
689  *
690  * \warning
691  *  None
692  *
693  * \return Return Type (int) \n
694  *
695  * - WIFI_DIRECT_ERROR_NONE on success \n
696  * - WIFI_DIRECT_ERROR_NOT_PERMITTED for "Operation not permitted" \n
697  *
698  * \par Prospective Clients:
699  * External Apps.
700  *
701  * \remarks None.
702  * \code
703  *
704  * #include <wifi-direct.h>
705  *
706  * void foo(void)
707  * {
708  *
709  * int result;
710  *
711  * result = wifi_direct_unset_connection_state_changed_cb();
712  *
713  * if(result == WIFI_DIRECT_ERROR_NONE).........// Successfully deregistered the callback function
714  *
715  * \endcode
716  ******************************************************************************/
717 int wifi_direct_unset_connection_state_changed_cb(void);
718
719
720 /**
721 * @brief Registers the callback called when IP address of client is assigned when your device is group owner.
722 * @param[in] cb  The callback function to invoke
723 * @param[in] user_data  The user data to be passed to the callback function
724 * @return 0 on success, otherwise a negative error value.
725 * @retval #WIFI_DIRECT_ERROR_NONE  Successful
726 * @retval #WIFI_DIRECT_ERROR_INVALID_PARAMETER  Invalid parameter
727 * @retval #WIFI_DIRECT_ERROR_NOT_INITIALIZED  Not initialized
728 * @pre Wi-Fi Direct service must be initialized by wifi_direct_initialize().
729 * @see wifi_direct_initialize()
730 * @see wifi_direct_unset_client_ip_address_assigned_cb()
731 * @see wifi_direct_client_ip_address_assigned_cb()
732 */
733 int wifi_direct_set_client_ip_address_assigned_cb(wifi_direct_client_ip_address_assigned_cb cb, void *user_data);
734
735
736 /**
737 * @brief Unregisters the callback called when IP address of client is assigned when your device is group owner.
738 * @return 0 on success, otherwise a negative error value.
739 * @retval #WIFI_DIRECT_ERROR_NONE  Successful
740 * @retval #WIFI_DIRECT_ERROR_NOT_INITIALIZED  Not initialized
741 * @pre Wi-Fi Direct service must be initialized by wifi_direct_initialize().
742 * @see wifi_direct_initialize()
743 * @see wifi_direct_set_connection_state_changed_cb()
744 */
745 int wifi_direct_unset_client_ip_address_assigned_cb(void);
746
747
748
749
750 /*****************************************************************************************/
751 /* wifi_direct_activate API function prototype
752  * int wifi_direct_activate(void);
753  */
754
755 /**
756  * \brief This API shall open a wireless adapter device for P2P use.
757
758  * \pre Application must be already registered to the Wi-Fi Direct server.
759  *
760  * \post wireless adapter device will be ready to use.
761  *
762  * \see wifi_direct_initialize
763  *
764  * \par Sync (or) Async:
765  * This is a Asynchronous API.
766  *
767  * \warning
768  *  None
769  *
770  *
771  * \par Async Response Message:
772  *  - WIFI_DIRECT_DEVICE_STATE_ACTIVATED : Application will receive this event via wifi_direct_device_state_changed_cb, when activation  process is completed. \n
773  *
774  *
775  * \return Return Type (int*) \n
776  * - WIFI_DIRECT_ERROR_NONE on success \n
777  * - WIFI_DIRECT_ERROR_OPERATION_FAILED for "Unkown error" \n
778  * - WIFI_DIRECT_ERROR_OUT_OF_MEMORY for "Out of memory" \n
779  * - WIFI_DIRECT_ERROR_COMMUNICATION_FAILED for "I/O error" \n
780  * - WIFI_DIRECT_ERROR_NOT_PERMITTED for "Operation not permitted" \n
781  * - WIFI_DIRECT_ERROR_RESOURCE_BUSY for "Device or resource busy" \n
782  * - WIFI_DIRECT_ERROR_STRANGE_CLIENT for "Invalid Client" \n
783  * - WIFI_DIRECT_ERROR_WIFI_USED for "WiFi is being used" \n
784  * - WIFI_DIRECT_ERROR_MOBILE_AP_USED for "Mobile AP is being used" \n
785  *
786  *
787  * \par Prospective Clients:
788  * External Apps.
789  *
790  * \code
791  *
792  * #include <wifi-direct.h>
793  *
794  * void foo(void)
795  * {
796
797  * int result;
798  *
799  * result = wifi_direct_activate();
800  *
801  * if(result == WIFI_DIRECT_ERROR_NONE)......... // activation is successful
802  *
803  *\endcode
804  *
805  *\remarks None.
806  *
807  ******************************************************************************/
808 int wifi_direct_activate(void);
809
810
811 /*****************************************************************************************/
812 /* wifi_direct_deactivate API function prototype
813  * int wifi_direct_deactivate(void);
814  */
815
816 /**
817  * \brief This API shall close a wireless adapter device for P2P use
818
819  * \pre Wireless adapter device must be already opened.
820  *
821  * \post wireless adapter device will be closed.
822  *
823  * \see wifi_direct_activate
824  *
825  * \par Sync (or) Async:
826  * This is a Asynchronous API.
827  *
828  * \warning
829  *  None
830  *
831  *
832  * \par Async Response Message:
833  *  - WIFI_DIRECT_DEVICE_STATE_DEACTIVATED : Application will receive this event via wifi_direct_device_state_changed_cb, when deactivation  process is completed. \n
834
835  * \return Return Type (int) \n
836  * - WIFI_DIRECT_ERROR_NONE on success \n
837  * - WIFI_DIRECT_ERROR_OPERATION_FAILED for "Unkown error" \n
838  * - WIFI_DIRECT_ERROR_OUT_OF_MEMORY for "Out of memory" \n
839  * - WIFI_DIRECT_ERROR_COMMUNICATION_FAILED for "I/O error" \n
840  * - WIFI_DIRECT_ERROR_NOT_PERMITTED for "Operation not permitted" \n
841  * - WIFI_DIRECT_ERROR_RESOURCE_BUSY for "Device or resource busy" \n
842  * - WIFI_DIRECT_ERROR_STRANGE_CLIENT for "Invalid Client" \n
843  *
844  *
845  * \par Prospective Clients:
846  * External Apps.
847  *
848  * \code
849  *
850  * #include <wifi-direct.h>
851  *
852  * void foo(void)
853  * {
854  * int result;
855  *
856  * result = wifi_direct_deactivate();
857  *
858  * if(result == WIFI_DIRECT_ERROR_NONE)......... // Deactivation is successful
859  *
860  *\endcode
861  *
862  *\remarks None.
863  *
864  ******************************************************************************/
865 int wifi_direct_deactivate(void);
866
867
868 /*****************************************************************************************/
869 /* wifi_direct_start_discovery API function prototype
870  * int wifi_direct_start_discovery(bool listen_only, int timeout);
871  */
872 /**
873  * \brief This API shall Start a discovery to find all P2P capable devices. \n
874  *        Applications will be notified event via wifi_direct_discovery_state_chagned_cb(). \n
875  *
876  * @param listen_only    if true, skip the initial 802.11 scan and then enter
877  *                       Listen state instead of cycling between Search and Listen.
878  * @param timeout        Specifies the duration of discovery period, in seconds.
879  *                       APs. If 0, a default value will be used, which depends on UX guideline.
880  *
881  * \pre Wireless adapter device must be already opened.
882  *
883  *
884  * \see wifi_direct_get_discovery_result
885  *
886  * \par Sync (or) Async:
887  * This is a Asynchronous API.
888  *
889  * \warning
890  *  None
891  *
892  *
893  * \par Async Response Message:
894  *  - WIFI_DIRECT_DISCOVERY_STARTED : Application will receive this event via wifi_direct_discovery_state_chagned_cb (), when discover process (80211 Scan) started. \n
895  *  - WIFI_DIRECT_ONLY_LISTEN_STARTED : Application will receive this event via wifi_direct_discovery_state_chagned_cb (), when discover process (listen only mode) started. \n
896  *  - WIFI_DIRECT_DISCOVERY_FOUND : Application will receive this event via wifi_direct_discovery_state_chagned_cb (), when peer or group is found. \n
897  *  - WIFI_DIRECT_DISCOVERY_FINISHED : Once the whole discovery process is completed, applications will receive it via wifi_direct_discovery_state_chagned_cb (). \n
898  *                                 Applications may then call wifi_direct_foreach_discovered_peers() to get the final result.  \n
899  *                                 With the intermediate or final list of P2P capable devices, applications can update their UI if needed. \n
900  *                                 It is up to the applications to control how often to update their UI display. \n
901  *
902  *
903  * \return Return Type (int) \n
904  * - WIFI_DIRECT_ERROR_NONE on success \n
905  * - WIFI_DIRECT_ERROR_OPERATION_FAILED for "Unkown error" \n
906  * - WIFI_DIRECT_ERROR_OUT_OF_MEMORY for "Out of memory" \n
907  * - WIFI_DIRECT_ERROR_COMMUNICATION_FAILED for "I/O error" \n
908  * - WIFI_DIRECT_ERROR_NOT_PERMITTED for "Operation not permitted" \n
909  * - WIFI_DIRECT_ERROR_INVALID_PARAMETER for "Invalid function parameter" \n
910  * - WIFI_DIRECT_ERROR_RESOURCE_BUSY for "Device or resource busy" \n
911  * - WIFI_DIRECT_ERROR_STRANGE_CLIENT for "Invalid Client" \n
912  *
913  *
914  * \par Prospective Clients:
915  * External Apps.
916  *
917  * \code
918  *
919  * #include <wifi-direct.h>
920  *
921  * void foo(void)
922  * {
923
924  * int result;
925  *
926  * result = wifi_direct_start_discovery(TRUE, 0);
927  *
928  * if(result == WIFI_DIRECT_ERROR_NONE)......... // discovery request is successful
929  *
930  *\endcode
931  *
932  *\remarks If discover is over, peer can not find the device and the device can not find peer, too.
933  *
934  ******************************************************************************/
935 int wifi_direct_start_discovery(bool listen_only, int timeout);
936
937
938 /*****************************************************************************************/
939 /* wifi_direct_cancel_discovery API function prototype
940  * int wifi_direct_cancel_discovery(void);
941  */
942 /**
943  * \brief This API shall cancel the discovery process started from wifi_direct_start_discovery. \n
944  *
945  * \pre discovery process must be started.
946  *
947  * \post discovery process stopped.
948  *
949  * \see wifi_direct_client_start_discovery
950  *
951  * \par Sync (or) Async:
952  * This is a Asynchronous API.
953  *
954  * \warning
955  *  None
956  *
957  *
958  * \par Async Response Message:
959  *    - WIFI_DIRECT_DISCOVERY_FINISHED :  Applications will receive a this event
960  *                                   via callback when the discovery process is cancelled or completed.
961  *
962  *
963  * \return Return Type (int) \n
964  * - WIFI_DIRECT_ERROR_NONE on success \n
965  * - WIFI_DIRECT_ERROR_OPERATION_FAILED for "Unkown error" \n
966  * - WIFI_DIRECT_ERROR_OUT_OF_MEMORY for "Out of memory" \n
967  * - WIFI_DIRECT_ERROR_COMMUNICATION_FAILED for "I/O error" \n
968  * - WIFI_DIRECT_ERROR_NOT_PERMITTED for "Operation not permitted" \n
969  * - WIFI_DIRECT_ERROR_RESOURCE_BUSY for "Device or resource busy" \n
970  * - WIFI_DIRECT_ERROR_STRANGE_CLIENT for "Invalid Client" \n
971  *
972  * \par Prospective Clients:
973  * External Apps.
974  *
975  * \code
976  *
977  * #include <wifi-direct.h>
978  *
979  * void foo(void)
980  * {
981
982  * int result;
983  *
984  * result = wifi_direct_cancel_discovery();
985  *
986  * if(result == WIFI_DIRECT_ERROR_NONE)......... // discovery cancel request is successful
987  *
988  *\endcode
989  *
990  *\remarks None.
991  *
992  ******************************************************************************/
993 int wifi_direct_cancel_discovery(void);
994
995
996 /**
997  * discorverd peers notification callback function type. \n
998  *
999  * @param peer The discovered peer information.
1000  * @param user_data The user data passed from the foreach function.
1001  * @return @c true to continue with the next iteration of the loop,
1002  * \n @c false to break out of the loop.
1003  *
1004  * @pre wifi_direct_foreach_discovered_peers() will invoke this function.
1005  *
1006  * @see wifi_direct_foreach_discovered_peers()
1007  *
1008  */
1009 typedef bool(*wifi_direct_discovered_peer_cb)   (wifi_direct_discovered_peer_info_s *peer, void *user_data);
1010
1011
1012 /*****************************************************************************************/
1013 /* wifi_direct_foreach_discovered_peers API function prototype
1014  * int wifi_direct_foreach_discovered_peers(wifi_direct_discovered_peer_cb, void* user_data)
1015  */
1016 /**
1017  * \brief This API shall get the information of all discovered peers. \n
1018  *
1019  * @param callback The callback function to invoke.
1020  * @param user_data The user data passed from the foreach function.
1021  *
1022  * \see wifi_direct_discovered_peer_cb
1023  *
1024  * \par Sync (or) Async:
1025  * This is a Synchronous API.
1026  *
1027  * \warning
1028  *  None
1029  *
1030  * \return Return Type (int) \n
1031  * - WIFI_DIRECT_ERROR_NONE on success \n
1032  * - WIFI_DIRECT_ERROR_OPERATION_FAILED for "Unkown error" \n
1033  * - WIFI_DIRECT_ERROR_OUT_OF_MEMORY for "Out of memory" \n
1034  * - WIFI_DIRECT_ERROR_COMMUNICATION_FAILED for "I/O error" \n
1035  * - WIFI_DIRECT_ERROR_NOT_PERMITTED for "Operation not permitted" \n
1036  * - WIFI_DIRECT_ERROR_INVALID_PARAMETER for "Invalid function parameter" \n
1037  * - WIFI_DIRECT_ERROR_RESOURCE_BUSY for "Device or resource busy" \n
1038  * - WIFI_DIRECT_ERROR_STRANGE_CLIENT for "Invalid Client" \n
1039  *
1040  *
1041  * \par Prospective Clients:
1042  * External Apps.
1043  *
1044  * \code
1045  *
1046  * #include <wifi-direct.h>
1047  *
1048  * bool _cb_discovered_peers_impl(wifi_direct_discovered_peer_info_s* peer, void* user_data)
1049  * {
1050  *      struct appdata* ad = (struct appdata*) user_data;
1051  *
1052  *      if(NULL != peer)
1053  *      {
1054  *              if ( ad->peer_count >= MAX_PEER_NUM )
1055  *                      return false;   // break out of the loop
1056  *
1057  *              memcpy(&ad->peer_list[ad->peer_count], peer, sizeof(wifi_direct_discovered_peer_info_s));
1058  *              ad->peer_count++;
1059  *      }
1060  *
1061  *      return true;    // continue with the next iteration of the loop
1062  * }
1063  *
1064  *
1065  * void foo()
1066  * {
1067  *      int result;
1068  *
1069  *      ad->peer_list = NULL;
1070  *      ad->peer_count = 0;
1071  *      ad ->selected_peer_index = 0;
1072  *      result = wifi_direct_foreach_discovered_peers(_cb_discovered_peers_impl, (void*)ad);
1073  *
1074  *      if(result == WIFI_DIRECT_ERROR_NONE)......... // get discovery result is successful
1075  *
1076  *\endcode
1077  *
1078  *\remarks None.
1079  *
1080  ******************************************************************************/
1081 int wifi_direct_foreach_discovered_peers(wifi_direct_discovered_peer_cb callback,
1082                                                                                                 void *user_data);
1083
1084
1085 /*****************************************************************************************/
1086 /* wifi_direct_connect API function prototype
1087  * int wifi_direct_connect(const char* mac_address);
1088  */
1089 /**
1090  * \brief This API shall connect to specified peer by automatically determining whether to perform group \n
1091  * formation, join an existing group, invite, re-invoke a group. The decision is \n
1092  * based on the current state of the peers (i.e. GO, STA, not connected) and the \n
1093  * availability of persistent data. \n
1094  *
1095  * @param mac_addr Device address of target peer.
1096  *
1097  * \par Sync (or) Async:
1098  * This is a Asynchronous API.
1099  *
1100  * \warning
1101  *  None
1102  *
1103  *
1104  * \par Async Response Message:
1105  *    - WIFI_DIRECT_CONNECTION_IN_PROGRESS :  Applications will receive this event
1106  *                                   via callback when the connection process is started.
1107  *    - WIFI_DIRECT_CONNECTION_RSP :  Applications will receive this event
1108  *                                   via callback when the connection process is completed or failed.
1109  *
1110  * \return Return Type (int) \n
1111  * - WIFI_DIRECT_ERROR_NONE on success \n
1112  * - WIFI_DIRECT_ERROR_OPERATION_FAILED for "Unkown error" \n
1113  * - WIFI_DIRECT_ERROR_OUT_OF_MEMORY for "Out of memory" \n
1114  * - WIFI_DIRECT_ERROR_COMMUNICATION_FAILED for "I/O error" \n
1115  * - WIFI_DIRECT_ERROR_NOT_PERMITTED for "Operation not permitted" \n
1116  * - WIFI_DIRECT_ERROR_INVALID_PARAMETER for "Invalid function parameter" \n
1117  * - WIFI_DIRECT_ERROR_RESOURCE_BUSY for "Device or resource busy" \n
1118  * - WIFI_DIRECT_ERROR_CONNECTION_TIME_OUT for "Connection timed out" \n
1119  * - WIFI_DIRECT_ERROR_STRANGE_CLIENT for "Invalid Client" \n
1120  * - WIFI_DIRECT_ERROR_CONNECTION_FAILED for "Create Link fail" \n
1121  * - WIFI_DIRECT_ERROR_AUTH_FAILED for "Create Link Auth fail" \n
1122  *
1123  *
1124  * \par Prospective Clients:
1125  * External Apps.
1126  *
1127  * \code
1128  *
1129  * #include <wifi-direct.h>
1130  *
1131  * void foo(unsigned char* mac_addr)
1132  * {
1133
1134  * int result;
1135  *
1136  * result = wifi_direct_connect(mac_addr);
1137  *
1138  * if(result == WIFI_DIRECT_ERROR_NONE)......... // connect request is successful
1139  *
1140  *\endcode
1141  *
1142  *\remarks This API will try to send provisioning request befre connecting.
1143  *
1144  ******************************************************************************/
1145 int wifi_direct_connect(const char *mac_address);
1146
1147
1148 /*****************************************************************************************/
1149 /* wifi_direct_disconnect_all API function prototype
1150  * int wifi_direct_disconnect_all(void);
1151  */
1152 /**
1153  * \brief This API shall tear down all connected links to peers (stop soft AP, and close interface).  \n
1154  *
1155  * \see wifi_direct_connect
1156  *
1157  * \par Sync (or) Async:
1158  * This is a Asynchronous API.
1159  *
1160  * \warning
1161  *  None
1162  *
1163  *
1164  * \par Async Response Message:
1165  *    - WIFI_DIRECT_DISCONNECTION_RSP :  Applications will receive this event
1166  *                                   via callback when the disconnection process is completed.
1167  *
1168  *
1169  * \return Return Type (int) \n
1170  * - WIFI_DIRECT_ERROR_NONE on success \n
1171  * - WIFI_DIRECT_ERROR_OPERATION_FAILED for "Unkown error" \n
1172  * - WIFI_DIRECT_ERROR_OUT_OF_MEMORY for "Out of memory" \n
1173  * - WIFI_DIRECT_ERROR_COMMUNICATION_FAILED for "I/O error" \n
1174  * - WIFI_DIRECT_ERROR_NOT_PERMITTED for "Operation not permitted" \n
1175  * - WIFI_DIRECT_ERROR_RESOURCE_BUSY for "Device or resource busy" \n
1176  * - WIFI_DIRECT_ERROR_STRANGE_CLIENT for "Invalid Client" \n
1177  *
1178  *
1179  * \par Prospective Clients:
1180  * External Apps.
1181  *
1182  * \code
1183  *
1184  * #include <wifi-direct.h>
1185  *
1186  * void foo(void)
1187  * {
1188
1189  * int result;
1190  *
1191  * result = wifi_direct_disconnect_all();
1192  *
1193  * if(result == WIFI_DIRECT_ERROR_NONE)......... // disconnect request is successful
1194  *
1195  *\endcode
1196  *
1197  *\remarks None.
1198  *
1199  ******************************************************************************/
1200 int wifi_direct_disconnect_all(void);
1201
1202
1203
1204 /*****************************************************************************************/
1205 /* wifi_direct_disconnect API function prototype
1206  * int wifi_direct_disconnect(const char* mac_address);
1207  */
1208 /**
1209  * \brief This API shall disconnect the specified peer by mac address.
1210  *
1211  * @param mac_addr Device address of target peer.
1212  *
1213  * \see
1214  *
1215  * \par Sync (or) Async:
1216  * This is a Asynchronous API.
1217  *
1218  * \warning
1219  *  None
1220  *
1221  *
1222  * \par Async Response Message:
1223  *    - WIFI_DIRECT_DISCONNECTION_RSP :  Applications will receive a this event
1224  *                                   via callback when a peer is disconnected.
1225  *
1226  * \return Return Type (int) \n
1227  * - WIFI_DIRECT_ERROR_NONE on success \n
1228  * - WIFI_DIRECT_ERROR_OPERATION_FAILED for "Unkown error" \n
1229  * - WIFI_DIRECT_ERROR_OUT_OF_MEMORY for "Out of memory" \n
1230  * - WIFI_DIRECT_ERROR_COMMUNICATION_FAILED for "I/O error" \n
1231  * - WIFI_DIRECT_ERROR_NOT_PERMITTED for "Operation not permitted" \n
1232  * - WIFI_DIRECT_ERROR_INVALID_PARAMETER for "Invalid function parameter" \n
1233  * - WIFI_DIRECT_ERROR_RESOURCE_BUSY for "Device or resource busy" \n
1234  * - WIFI_DIRECT_ERROR_STRANGE_CLIENT for "Invalid Client" \n
1235  *
1236  *
1237  * \par Prospective Clients:
1238  * External Apps.
1239  *
1240  * \code
1241  *
1242  * #include <wifi-direct.h>
1243  *
1244  * void foo(unsigned char* mac_addr)
1245  * {
1246
1247  * int result;
1248  *
1249  * result = wifi_direct_disconnect(mac_addr);
1250  *
1251  * if(result == WIFI_DIRECT_ERROR_NONE)......... // disconnect request is successful
1252  *
1253  *\endcode
1254  *
1255  *\remarks None.
1256  *
1257  ******************************************************************************/
1258 int wifi_direct_disconnect(const char *mac_address);
1259
1260
1261
1262 /**
1263  * connected peers notification callback function type. \n
1264  *
1265  * @param peer The connected peer information.
1266  * @param user_data The user data passed from the foreach function.
1267  * @return @c true to continue with the next iteration of the loop,
1268  * \n @c false to break out of the loop.
1269  *
1270  * @pre wifi_direct_foreach_connected_peers() will invoke this function.
1271  *
1272  * @see wifi_direct_foreach_connected_peers()
1273  *
1274  */
1275 typedef bool(*wifi_direct_connected_peer_cb) (wifi_direct_connected_peer_info_s *peer,
1276                                                                                                                 void *user_data);
1277
1278
1279 /*****************************************************************************************/
1280 /* wifi_direct_foreach_connected_peers API function prototype
1281  * int wifi_direct_foreach_connected_peers(wifi_direct_connected_peer_cb, void* user_data)
1282  */
1283 /**
1284  * \brief This API shall get the information of all connected peers. \n
1285  *
1286  * @param callback The callback function to invoke.
1287  * @param user_data The user data passed from the foreach function.
1288  *
1289  * \see wifi_direct_connected_peer_cb
1290  *
1291  * \par Sync (or) Async:
1292  * This is a Synchronous API.
1293  *
1294  * \warning
1295  *  None
1296  *
1297  * \return Return Type (int) \n
1298  * - WIFI_DIRECT_ERROR_NONE on success \n
1299  * - WIFI_DIRECT_ERROR_OPERATION_FAILED for "Unkown error" \n
1300  * - WIFI_DIRECT_ERROR_OUT_OF_MEMORY for "Out of memory" \n
1301  * - WIFI_DIRECT_ERROR_COMMUNICATION_FAILED for "I/O error" \n
1302  * - WIFI_DIRECT_ERROR_NOT_PERMITTED for "Operation not permitted" \n
1303  * - WIFI_DIRECT_ERROR_INVALID_PARAMETER for "Invalid function parameter" \n
1304  * - WIFI_DIRECT_ERROR_RESOURCE_BUSY for "Device or resource busy" \n
1305  * - WIFI_DIRECT_ERROR_STRANGE_CLIENT for "Invalid Client" \n
1306  *
1307  * \par Prospective Clients:
1308  * External Apps.
1309  *
1310  * \code
1311  *
1312  * #include <wifi-direct.h>
1313  *
1314  * bool _cb_connected_peers_impl(wifi_direct_connected_peer_info_s* peer, void* user_data)
1315  *{
1316  *
1317  *      struct appdata* ad = (struct appdata*) user_data;
1318  *
1319  *      if(NULL != peer)
1320  *      {
1321  *              if ( ad->connected_peer_count >= MAX_PEER_NUM )
1322  *                      return false;   // break out of the loop
1323  *
1324  *              memcpy(&ad->connected_peer_list[ad->connected_peer_count], peer, sizeof(wifi_direct_connected_peer_info_s));
1325  *              ad->connected_peer_count++;
1326  *
1327  *      }
1328  *
1329  *      return true;    // continue with the next iteration of the loop
1330  *}
1331  *
1332  * void foo()
1333  * {
1334  *      int result;
1335  *
1336  *      ad->connected_peer_list = NULL;
1337  *      ad->connected_peer_count = 0;
1338  *
1339  *      result = wifi_direct_foreach_connected_peers(_cb_connected_peers_impl, (void*)ad);
1340  *
1341  * if(result == WIFI_DIRECT_ERROR_NONE)......... // get discovery result is successful
1342  *
1343  *\endcode
1344  *
1345  *\remarks None.
1346  *
1347  ******************************************************************************/
1348 int wifi_direct_foreach_connected_peers(wifi_direct_connected_peer_cb
1349                                                                                 callback, void *user_data);
1350
1351
1352
1353 /*****************************************************************************************/
1354 /* wifi_direct_create_group API function prototype
1355  * int wifi_direct_create_group();
1356  */
1357 /**
1358  * \brief This API shall set up device as a Group Owner and wait for clients to connect. \n
1359  * Create a soft AP, start the WPS registrar, start the DHCP server. \n
1360  *
1361  * \see wifi_direct_destroy_group
1362  *
1363  * \par Sync (or) Async:
1364  * This is a Asynchronous API.
1365  *
1366  * \warning
1367  *  None
1368  *
1369  *
1370  * \par Async Response Message:
1371  *    - WIFI_DIRECT_GROUP_CREATED :  Applications will receive this event
1372  *                                   via callback when the group creating request is successful. \n
1373  *                                Errorcode will be set to the WFD_ERROR_CREATE_LINK_FAIL value. \n
1374  *
1375  * \return Return Type (int) \n
1376  * - WIFI_DIRECT_ERROR_NONE on success \n
1377  * - WIFI_DIRECT_ERROR_OPERATION_FAILED for "Unkown error" \n
1378  * - WIFI_DIRECT_ERROR_OUT_OF_MEMORY for "Out of memory" \n
1379  * - WIFI_DIRECT_ERROR_COMMUNICATION_FAILED for "I/O error" \n
1380  * - WIFI_DIRECT_ERROR_NOT_PERMITTED for "Operation not permitted" \n
1381  * - WIFI_DIRECT_ERROR_RESOURCE_BUSY for "Device or resource busy" \n
1382  * - WIFI_DIRECT_ERROR_STRANGE_CLIENT for "Invalid Client" \n
1383  * - WIFI_DIRECT_ERROR_CONNECTION_FAILED for "Create Link fail" \n
1384  * - WIFI_DIRECT_ERROR_AUTH_FAILED for "Create Link Auth fail" \n
1385  *
1386  *
1387  * \par Prospective Clients:
1388  * External Apps.
1389  *
1390  * \code
1391  *
1392  * #include <wifi-direct.h>
1393  *
1394  * void foo()
1395  * {
1396
1397  * int result;
1398  *
1399  * result = wifi_direct_create_group();
1400  *
1401  * if(result == WIFI_DIRECT_ERROR_NONE)......... // create group request is successful
1402  *
1403  *\endcode
1404  *
1405  *\remarks None.
1406  *
1407  ******************************************************************************/
1408 int wifi_direct_create_group(void);
1409
1410
1411
1412 /*****************************************************************************************/
1413 /* wifi_direct_destroy_group API function prototype
1414  * int wifi_direct_destroy_group();
1415  */
1416 /**
1417  * \brief This API shall cancel P2P Group create or tear down a P2P Group that we own. \n
1418  *
1419  * \see wifi_direct_create_group
1420  *
1421  * \par Sync (or) Async:
1422  * This is a Asynchronous API.
1423  *
1424  * \warning
1425  *  None
1426  *
1427  *
1428  * \par Async Response Message:
1429  *    - WIFI_DIRECT_GROUP_DESTROYED :  Applications will receive this event via callback when the group is cancelled. \n
1430  *
1431  * \return Return Type (int) \n
1432  * - WIFI_DIRECT_ERROR_NONE on success \n
1433  * - WIFI_DIRECT_ERROR_OPERATION_FAILED for "Unkown error" \n
1434  * - WIFI_DIRECT_ERROR_OUT_OF_MEMORY for "Out of memory" \n
1435  * - WIFI_DIRECT_ERROR_COMMUNICATION_FAILED for "I/O error" \n
1436  * - WIFI_DIRECT_ERROR_NOT_PERMITTED for "Operation not permitted" \n
1437  * - WIFI_DIRECT_ERROR_RESOURCE_BUSY for "Device or resource busy" \n
1438  * - WIFI_DIRECT_ERROR_STRANGE_CLIENT for "Invalid Client" \n
1439  * - WIFI_DIRECT_ERROR_CONNECTION_FAILED for "Create Link fail" \n
1440  * - WIFI_DIRECT_ERROR_AUTH_FAILED for "Create Link Auth fail" \n
1441  *
1442  *
1443  * \par Prospective Clients:
1444  * External Apps.
1445  *
1446  * \code
1447  *
1448  * #include <wifi-direct.h>
1449  *
1450  * void foo()
1451  * {
1452
1453  * int result;
1454  *
1455  * result = wifi_direct_destroy_group();
1456  *
1457  * if(result == WIFI_DIRECT_ERROR_NONE)......... // cancel group request is successful
1458  *
1459  *\endcode
1460  *
1461  *\remarks None.
1462  *
1463  ******************************************************************************/
1464 int wifi_direct_destroy_group(void);
1465
1466
1467 /*****************************************************************************************/
1468 /* wifi_direct_is_group_owner API function prototype
1469  * int wifi_direct_is_group_owner(bool *owner);
1470  */
1471 /**
1472  * \brief This API shall check whether the currunt client is group owner or not.
1473  * @param owner              Memory to store the value of TURE or FALSE. Application must allocate memory.
1474  *
1475  * \see wifi_direct_create_group
1476  *
1477  * \par Sync (or) Async:
1478  * This is a Synchronous API.
1479  *
1480  * \warning
1481  *  None
1482  *
1483  * \return Return Type (int) \n
1484  * - WIFI_DIRECT_ERROR_NONE on success \n
1485  * - WIFI_DIRECT_ERROR_OPERATION_FAILED for "Unkown error" \n
1486  * - WIFI_DIRECT_ERROR_OUT_OF_MEMORY for "Out of memory" \n
1487  * - WIFI_DIRECT_ERROR_COMMUNICATION_FAILED for "I/O error" \n
1488  * - WIFI_DIRECT_ERROR_NOT_PERMITTED for "Operation not permitted" \n
1489  * - WIFI_DIRECT_ERROR_INVALID_PARAMETER for "Invalid function parameter" \n
1490  * - WIFI_DIRECT_ERROR_RESOURCE_BUSY for "Device or resource busy" \n
1491  * - WIFI_DIRECT_ERROR_STRANGE_CLIENT for "Invalid Client" \n
1492  *
1493  * \par Prospective Clients:
1494  * External Apps.
1495  *
1496  * \code
1497  *
1498  * #include <wifi-direct.h>
1499  *
1500  * void foo(void)
1501  * {
1502
1503  * int result;
1504  * bool owner;
1505  *
1506  * result = wifi_direct_is_group_owner(&owner);
1507  *
1508  *
1509  * if(result == WIFI_DIRECT_ERROR_NONE)......... // checking the value is successful
1510  *
1511  *\endcode
1512  *
1513  *\remarks None.
1514  *
1515  ******************************************************************************/
1516 int wifi_direct_is_group_owner(bool *is_group_owner);
1517
1518
1519
1520 /*****************************************************************************************/
1521 /* wifi_direct_is_autonomous_group API function prototype
1522  * int wifi_direct_is_autonomous_group(bool *autonomous_group);
1523  */
1524 /**
1525  * \brief This API shall check whether the currunt group is autonomous group or not.
1526  * @param autonomous_group              Memory to store the value of TURE or FALSE. Application must allocate memory.
1527  *
1528  * \see wifi_direct_create_group
1529  *
1530  * \par Sync (or) Async:
1531  * This is a Synchronous API.
1532  *
1533  * \warning
1534  *  None
1535  *
1536  * \return Return Type (int) \n
1537  * - WIFI_DIRECT_ERROR_NONE on success \n
1538  * - WIFI_DIRECT_ERROR_OPERATION_FAILED for "Unkown error" \n
1539  * - WIFI_DIRECT_ERROR_OUT_OF_MEMORY for "Out of memory" \n
1540  * - WIFI_DIRECT_ERROR_COMMUNICATION_FAILED for "I/O error" \n
1541  * - WIFI_DIRECT_ERROR_NOT_PERMITTED for "Operation not permitted" \n
1542  * - WIFI_DIRECT_ERROR_INVALID_PARAMETER for "Invalid function parameter" \n
1543  * - WIFI_DIRECT_ERROR_RESOURCE_BUSY for "Device or resource busy" \n
1544  * - WIFI_DIRECT_ERROR_STRANGE_CLIENT for "Invalid Client" \n
1545  *
1546  * \par Prospective Clients:
1547  * External Apps.
1548  *
1549  * \code
1550  *
1551  * #include <wifi-direct.h>
1552  *
1553  * void foo(void)
1554  * {
1555
1556  * int result;
1557  * bool autonomous_group;
1558  *
1559  * result = wifi_direct_is_autonomous_group(&autonomous_group);
1560  *
1561  *
1562  * if(result == WIFI_DIRECT_ERROR_NONE)......... // checking the value is successful
1563  *
1564  *\endcode
1565  *
1566  *\remarks None.
1567  *
1568  ******************************************************************************/
1569 int wifi_direct_is_autonomous_group(bool *is_autonomous_group);
1570
1571
1572
1573
1574 /*****************************************************************************************/
1575 /* wifi_direct_set_ssid API function prototype
1576  * int wifi_direct_set_ssid(const char* ssid);
1577  */
1578 /**
1579  * \brief This API shall set or update ssid of local device. \n
1580  * @param ssid              new ssid to set. Application must set the new ssid before.
1581  *
1582  * \see wifi_direct_get_ssid
1583  *
1584  * \par Sync (or) Async:
1585  * This is a Synchronous API.
1586  *
1587  * \warning
1588  *  None
1589  *
1590  *
1591  * \return Return Type (int) \n
1592  * - WIFI_DIRECT_ERROR_NONE on success \n
1593  * - WIFI_DIRECT_ERROR_OPERATION_FAILED for "Unkown error" \n
1594  * - WIFI_DIRECT_ERROR_OUT_OF_MEMORY for "Out of memory" \n
1595  * - WIFI_DIRECT_ERROR_COMMUNICATION_FAILED for "I/O error" \n
1596  * - WIFI_DIRECT_ERROR_NOT_PERMITTED for "Operation not permitted" \n
1597  * - WIFI_DIRECT_ERROR_INVALID_PARAMETER for "Invalid function parameter" \n
1598  * - WIFI_DIRECT_ERROR_RESOURCE_BUSY for "Device or resource busy" \n
1599  * - WIFI_DIRECT_ERROR_STRANGE_CLIENT for "Invalid Client" \n
1600  *
1601  *
1602  * \par Prospective Clients:
1603  * External Apps.
1604  *
1605  * \code
1606  *
1607  * #include <wifi-direct.h>
1608  *
1609  * void foo()
1610  * {
1611  * int  result;
1612  * char ssid[11] = {0,};
1613  *
1614  * memset(pin, 0x00, sizeof(pin));
1615  * printf("Input 8 digit PIN number :\n");
1616  * scanf("%s", pin);
1617  *
1618  *if( strlen(ssid) > 0 )
1619  *      result = wifi_direct_set_ssid(ssid);
1620  *
1621  * if(result == WIFI_DIRECT_ERROR_NONE)......... // setting ssid is successful
1622  *
1623  *\endcode
1624  *
1625  *\remarks When the wifi direct is re-activated, ssid will be reset to the device name. \n
1626  *
1627  *
1628  ******************************************************************************/
1629 int wifi_direct_set_ssid(const char *ssid);
1630
1631
1632 /**
1633  * @brief Sets the friendly name of local device.
1634  * @details This device name is shown to other devices during device discovery.
1635  * @remarks The name set by you is only valid during activated state.
1636  * After Wi-Fi Direct is deactivated, this name will be as the phone name.
1637  * @param[in] device_name  The name to local device
1638  * @return 0 on success, otherwise a negative error value.
1639  * @retval #WIFI_DIRECT_ERROR_NONE  Successful
1640  * @retval #WIFI_DIRECT_ERROR_INVALID_PARAMETER  Invalid parameter
1641  * @retval #WIFI_DIRECT_ERROR_OPERATION_FAILED  Operation failed
1642  * @retval #WIFI_DIRECT_ERROR_COMMUNICATION_FAILED  Communication failed
1643  * @retval #WIFI_DIRECT_ERROR_NOT_PERMITTED  Operation not permitteds
1644  * @retval #WIFI_DIRECT_ERROR_NOT_INITIALIZED  Not initialized
1645  * @retval #WIFI_DIRECT_ERROR_RESOURCE_BUSY  Device or resource busy
1646  * @pre Wi-Fi Direct must be activated by wifi_direct_activate().
1647  * @see wifi_direct_activate()
1648  * @see wifi_direct_get_device_name()
1649  */
1650 int wifi_direct_set_device_name(const char *device_name);
1651
1652 /**
1653  * @brief Gets the name of local device.
1654  * @remarks @a device_name must be released with free() by you.
1655  * @param[out] device_name  The name to local device
1656  * @return 0 on success, otherwise a negative error value.
1657  * @retval #WIFI_DIRECT_ERROR_NONE  Successful
1658  * @retval #WIFI_DIRECT_ERROR_INVALID_PARAMETER  Invalid parameter
1659  * @retval #WIFI_DIRECT_ERROR_OPERATION_FAILED  Operation failed
1660  * @retval #WIFI_DIRECT_ERROR_COMMUNICATION_FAILED  Communication failed
1661  * @retval #WIFI_DIRECT_ERROR_NOT_INITIALIZED  Not initialized
1662  * @retval #WIFI_DIRECT_ERROR_RESOURCE_BUSY  Device or resource busy
1663  * @pre Wi-Fi Direct service must be initialized by wifi_direct_initialize().
1664  * @see wifi_direct_initialize()
1665  * @see wifi_direct_set_device_name()
1666  */
1667 int wifi_direct_get_device_name(char **device_name);
1668
1669 /*****************************************************************************************/
1670 /* wifi_direct_get_ssid API function prototype
1671  * int wifi_direct_get_ssid(char** ssid)
1672  */
1673 /**
1674  * \brief This API shall get ssid of local device. \n
1675  * @param ssid              Pointer to store ssid. Application must free this memory.
1676  *
1677  * \par Sync (or) Async:
1678  * This is a Synchronous API.
1679  *
1680  * \warning
1681  *  None
1682  *
1683  *
1684  * \return Return Type (int) \n
1685  * - WIFI_DIRECT_ERROR_NONE on success \n
1686  * - WIFI_DIRECT_ERROR_OPERATION_FAILED for "Unkown error" \n
1687  * - WIFI_DIRECT_ERROR_OUT_OF_MEMORY for "Out of memory" \n
1688  * - WIFI_DIRECT_ERROR_COMMUNICATION_FAILED for "I/O error" \n
1689  * - WIFI_DIRECT_ERROR_NOT_PERMITTED for "Operation not permitted" \n
1690  * - WIFI_DIRECT_ERROR_INVALID_PARAMETER for "Invalid function parameter" \n
1691  * - WIFI_DIRECT_ERROR_RESOURCE_BUSY for "Device or resource busy" \n
1692  * - WIFI_DIRECT_ERROR_STRANGE_CLIENT for "Invalid Client" \n
1693  *
1694  *
1695  * \par Prospective Clients:
1696  * External Apps.
1697  *
1698  * \code
1699  *
1700  * #include <wifi-direct.h>
1701  *
1702  * void foo()
1703  * {
1704  * int  result;
1705  * char* ssid = NULL;
1706  *
1707  * result = wifi_direct_get_ssid(&ssid);
1708  *
1709  * if(result == WIFI_DIRECT_ERROR_NONE)......... // getting ssid is successful
1710  *
1711  * free(ssid); // Application should free the memory.
1712  *
1713  *
1714  *\endcode
1715  *
1716  *\remarks None.
1717  *
1718  ******************************************************************************/
1719 int wifi_direct_get_ssid(char **ssid);
1720
1721
1722 /**
1723 * @brief Gets the name of network interface. For example, eth0 and pdp0.
1724 * @remarks @a name must be released with free() by you.
1725 * @param[out] name  The name of network interface
1726 * @return 0 on success, otherwise negative error value.
1727 * @retval #WIFI_DIRECT_ERROR_NONE  Successful
1728 * @retval #WIFI_DIRECT_ERROR_INVALID_PARAMETER  Invalid parameter
1729 * @retval #WIFI_DIRECT_ERROR_OPERATION_FAILED  Operation failed
1730 * @retval #WIFI_DIRECT_ERROR_OUT_OF_MEMORY  Out of memory
1731 * @retval #WIFI_DIRECT_ERROR_COMMUNICATION_FAILED  Communication failed
1732 * @retval #WIFI_DIRECT_ERROR_NOT_PERMITTED  Operation not permitted
1733 * @retval #WIFI_DIRECT_ERROR_NOT_INITIALIZED  Not initialized
1734 * @retval #WIFI_DIRECT_ERROR_RESOURCE_BUSY  Device or resource busy
1735 * @pre Wi-Fi Direct service must be activated by wifi_direct_activate().
1736 * @see wifi_direct_activate()
1737 */
1738 int wifi_direct_get_network_interface_name(char **name);
1739
1740
1741 /*****************************************************************************************/
1742 /* wifi_direct_get_ip_address API function prototype
1743  * int wifi_direct_get_ip_address(char** ip_address)
1744  */
1745 /**
1746  * \brief This API shall get IP address of local device interface. \n
1747  * @param ip_addr              Pointer to store ip address. Application must free this memory.
1748  *
1749  * \par Sync (or) Async:
1750  * This is a Synchronous API.
1751  *
1752  * \warning
1753  *  None
1754  *
1755  *
1756  * \return Return Type (int) \n
1757  * - WIFI_DIRECT_ERROR_NONE on success \n
1758  * - WIFI_DIRECT_ERROR_OPERATION_FAILED for "Unkown error" \n
1759  * - WIFI_DIRECT_ERROR_OUT_OF_MEMORY for "Out of memory" \n
1760  * - WIFI_DIRECT_ERROR_COMMUNICATION_FAILED for "I/O error" \n
1761  * - WIFI_DIRECT_ERROR_NOT_PERMITTED for "Operation not permitted" \n
1762  * - WIFI_DIRECT_ERROR_INVALID_PARAMETER for "Invalid function parameter" \n
1763  * - WIFI_DIRECT_ERROR_RESOURCE_BUSY for "Device or resource busy" \n
1764  * - WIFI_DIRECT_ERROR_STRANGE_CLIENT for "Invalid Client" \n
1765  *
1766  *
1767  * \par Prospective Clients:
1768  * External Apps.
1769  *
1770  * \code
1771  *
1772  * #include <wifi-direct.h>
1773  *
1774  * void foo()
1775  * {
1776  * int  result;
1777  * char* ip = NULL;
1778  *
1779  * result = wifi_direct_get_ip_address(&ip);
1780  *
1781  * if(result == WIFI_DIRECT_ERROR_NONE)......... // getting IP is successful
1782  *
1783  * free(ip); // Application should free the memory.
1784  *
1785  *\endcode
1786  *
1787  *\remarks None.
1788  *
1789  ******************************************************************************/
1790 int wifi_direct_get_ip_address(char **ip_address);
1791
1792 /**
1793 * @brief Gets the Subnet Mask.
1794 * @remarks @a subnet_mask must be released with free() by you.
1795 * @param[out] subnet_mask  The subnet mask
1796 * @return 0 on success, otherwise negative error value.
1797 * @retval #WIFI_DIRECT_ERROR_NONE  Successful
1798 * @retval #WIFI_DIRECT_ERROR_INVALID_PARAMETER  Invalid parameter
1799 * @retval #WIFI_DIRECT_ERROR_OPERATION_FAILED  Operation failed
1800 * @retval #WIFI_DIRECT_ERROR_OUT_OF_MEMORY  Out of memory
1801 * @retval #WIFI_DIRECT_ERROR_COMMUNICATION_FAILED  Communication failed
1802 * @retval #WIFI_DIRECT_ERROR_NOT_PERMITTED  Operation not permitted
1803 * @retval #WIFI_DIRECT_ERROR_NOT_INITIALIZED  Not initialized
1804 * @retval #WIFI_DIRECT_ERROR_RESOURCE_BUSY  Device or resource busy
1805 * @pre Wi-Fi Direct service must be activated by wifi_direct_activate().
1806 * @see wifi_direct_activate()
1807 */
1808 int wifi_direct_get_subnet_mask(char **subnet_mask);
1809
1810
1811 /**
1812 * @brief Gets the Gateway address.
1813 * @remarks @a gateway_address must be released with free() by you.
1814 * @param[out] gateway_address  The gateway address
1815 * @return 0 on success, otherwise negative error value.
1816 * @retval #WIFI_DIRECT_ERROR_NONE  Successful
1817 * @retval #WIFI_DIRECT_ERROR_INVALID_PARAMETER  Invalid parameter
1818 * @retval #WIFI_DIRECT_ERROR_OPERATION_FAILED  Operation failed
1819 * @retval #WIFI_DIRECT_ERROR_OUT_OF_MEMORY  Out of memory
1820 * @retval #WIFI_DIRECT_ERROR_COMMUNICATION_FAILED  Communication failed
1821 * @retval #WIFI_DIRECT_ERROR_NOT_PERMITTED  Operation not permitted
1822 * @retval #WIFI_DIRECT_ERROR_NOT_INITIALIZED  Not initialized
1823 * @retval #WIFI_DIRECT_ERROR_RESOURCE_BUSY  Device or resource busy
1824 * @pre Wi-Fi Direct service must be activated by wifi_direct_activate().
1825 * @see wifi_direct_activate()
1826 */
1827 int wifi_direct_get_gateway_address(char **gateway_address);
1828
1829
1830
1831 /*****************************************************************************************/
1832 /* wifi_direct_get_mac_addr API function prototype
1833  * int wifi_direct_get_mac_address(char **mac_address)
1834  */
1835 /**
1836  * \brief This API shall get device MAC address of local device.\n
1837  * @param mac_addr              Pointer to store MAC address. Application must free this memory.
1838  *
1839  * \par Sync (or) Async:
1840  * This is a Synchronous API.
1841  *
1842  * \warning
1843  *  None
1844  *
1845  *
1846  * \return Return Type (int) \n
1847  * - WIFI_DIRECT_ERROR_NONE on success \n
1848  * - WIFI_DIRECT_ERROR_OPERATION_FAILED for "Unkown error" \n
1849  * - WIFI_DIRECT_ERROR_OUT_OF_MEMORY for "Out of memory" \n
1850  * - WIFI_DIRECT_ERROR_COMMUNICATION_FAILED for "I/O error" \n
1851  * - WIFI_DIRECT_ERROR_NOT_PERMITTED for "Operation not permitted" \n
1852  * - WIFI_DIRECT_ERROR_INVALID_PARAMETER for "Invalid function parameter" \n
1853  * - WIFI_DIRECT_ERROR_RESOURCE_BUSY for "Device or resource busy" \n
1854  * - WIFI_DIRECT_ERROR_STRANGE_CLIENT for "Invalid Client" \n
1855  *
1856  *
1857  * \par Prospective Clients:
1858  * External Apps.
1859  *
1860  * \code
1861  *
1862  * #include <wifi-direct.h>
1863  *
1864  * void foo()
1865  * {
1866  * int  result;
1867  * char* mac_addr =NULL;
1868  *
1869  * result = wifi_direct_get_mac_addr(&mac_addr);
1870  *
1871  * if(result == WIFI_DIRECT_ERROR_NONE)......... // getting device MAC is successful
1872  *
1873  *\endcode
1874  *
1875  *\remarks None.
1876  *
1877  ******************************************************************************/
1878 int wifi_direct_get_mac_address(char **mac_address);
1879
1880
1881 /*****************************************************************************************/
1882 /* wifi_direct_get_state API function prototype
1883  * int wifi_direct_get_state(wifi_direct_state_e * status);
1884  */
1885 /**
1886  * \brief This API shall get current Wi-Fi direct link status. \n
1887  * @param status Memory to store link status information. Application must allocate memory.
1888  *
1889  * \see wifi_direct_state_e
1890  *
1891  * \par Sync (or) Async:
1892  * This is a Synchronous API.
1893  *
1894  * \warning
1895  *  None
1896  *
1897  *
1898  * \return Return Type (int) \n
1899  * - WIFI_DIRECT_ERROR_NONE on success \n
1900  * - WIFI_DIRECT_ERROR_OPERATION_FAILED for "Unkown error" \n
1901  * - WIFI_DIRECT_ERROR_OUT_OF_MEMORY for "Out of memory" \n
1902  * - WIFI_DIRECT_ERROR_COMMUNICATION_FAILED for "I/O error" \n
1903  * - WIFI_DIRECT_ERROR_NOT_PERMITTED for "Operation not permitted" \n
1904  * - WIFI_DIRECT_ERROR_INVALID_PARAMETER for "Invalid function parameter" \n
1905  * - WIFI_DIRECT_ERROR_RESOURCE_BUSY for "Device or resource busy" \n
1906  * - WIFI_DIRECT_ERROR_STRANGE_CLIENT for "Invalid Client" \n
1907  *
1908  *
1909  * \par Prospective Clients:
1910  * External Apps.
1911  *
1912  * \code
1913  *
1914  * #include <wifi-direct.h>
1915  *
1916  * void foo()
1917  * {
1918  * int result;
1919  * wifi_direct_state_e status;
1920  *
1921  * result = wifi_direct_get_state(&status);
1922  *
1923  * if(result == WIFI_DIRECT_ERROR_NONE)......... // getting link status is successful
1924  *
1925  *\endcode
1926  *
1927  *\remarks None.
1928  *
1929  ******************************************************************************/
1930 int wifi_direct_get_state(wifi_direct_state_e *state);
1931
1932
1933
1934 /**
1935 * @brief Checks whether this device is discoverable or not by P2P discovery.
1936 * @details If you call wifi_direct_start_discovery(), then your device can be discoverable.
1937 * @param[out] discoverable  The status of discoverable: (@c true = discoverable, @c false = non-discoverable)
1938 * @return 0 on success, otherwise a negative error value.
1939 * @retval #WIFI_DIRECT_ERROR_NONE  Successful
1940 * @retval #WIFI_DIRECT_ERROR_INVALID_PARAMETER  Invalid parameter
1941 * @retval #WIFI_DIRECT_ERROR_OPERATION_FAILED  Operation failed
1942 * @retval #WIFI_DIRECT_ERROR_COMMUNICATION_FAILED  Communication failed
1943 * @retval #WIFI_DIRECT_ERROR_NOT_PERMITTED  Operation not permitted
1944 * @retval #WIFI_DIRECT_ERROR_NOT_INITIALIZED  Not initialized
1945 * @retval #WIFI_DIRECT_ERROR_RESOURCE_BUSY  Device or resource busy
1946 * @pre Wi-Fi Direct service must be initialized by wifi_direct_initialize().
1947 * @see wifi_direct_initialize()
1948 * @see wifi_direct_start_discovery()
1949 * @see wifi_direct_cancel_discovery()
1950 */
1951 int wifi_direct_is_discoverable(bool *discoverable);
1952
1953 /**
1954 * @brief Checks whether the local device is listening only.
1955 * @details If you call wifi_direct_start_discovery() with @a listen_only as @c true,
1956 * then skip the initial 802.11 Scan and then enter Listen state instead of cycling between Scan andListen.
1957 * @param[out] listen_only  The status of listen only: (@c true = listen only, @c false = cycling between Scan and Listen or not in discovery state)
1958 * @return 0 on success, otherwise a negative error value.
1959 * @retval #WIFI_DIRECT_ERROR_NONE  Successful
1960 * @retval #WIFI_DIRECT_ERROR_INVALID_PARAMETER  Invalid parameter
1961 * @retval #WIFI_DIRECT_ERROR_OPERATION_FAILED  Operation failed
1962 * @retval #WIFI_DIRECT_ERROR_COMMUNICATION_FAILED  Communication failed
1963 * @retval #WIFI_DIRECT_ERROR_NOT_PERMITTED  Operation not permitted
1964 * @retval #WIFI_DIRECT_ERROR_NOT_INITIALIZED  Not initialized
1965 * @retval #WIFI_DIRECT_ERROR_RESOURCE_BUSY  Device or resource busy
1966 * @pre Wi-Fi Direct service must be activated by wifi_direct_activate().
1967 * @see wifi_direct_start_discovery()
1968 * @see wifi_direct_cancel_discovery()
1969 * @see wifi_direct_is_discoverable()
1970 */
1971 int wifi_direct_is_listening_only(bool *listen_only);
1972
1973 /**
1974 * @brief Gets the primary device type of local device.
1975 * @param[out] type  The primary device type
1976 * @return 0 on success, otherwise a negative error value.
1977 * @retval #WIFI_DIRECT_ERROR_NONE  Successful
1978 * @retval #WIFI_DIRECT_ERROR_INVALID_PARAMETER  Invalid parameter
1979 * @retval #WIFI_DIRECT_ERROR_OPERATION_FAILED  Operation failed
1980 * @retval #WIFI_DIRECT_ERROR_COMMUNICATION_FAILED  Communication failed
1981 * @retval #WIFI_DIRECT_ERROR_NOT_PERMITTED  Operation not permitted
1982 * @retval #WIFI_DIRECT_ERROR_NOT_INITIALIZED  Not initialized
1983 * @retval #WIFI_DIRECT_ERROR_RESOURCE_BUSY  Device or resource busy
1984 * @pre Wi-Fi Direct service must be initialized by wifi_direct_initialize().
1985 * @see wifi_direct_initialize()
1986 */
1987 int wifi_direct_get_primary_device_type(wifi_direct_primary_device_type_e *type);
1988
1989  /**
1990 * @brief Gets the secondary device type of local device.
1991 * @param[out] type  The secondary device type
1992 * @return 0 on success, otherwise a negative error value.
1993 * @retval #WIFI_DIRECT_ERROR_NONE  Successful
1994 * @retval #WIFI_DIRECT_ERROR_INVALID_PARAMETER  Invalid parameter
1995 * @retval #WIFI_DIRECT_ERROR_OPERATION_FAILED  Operation failed
1996 * @retval #WIFI_DIRECT_ERROR_COMMUNICATION_FAILED  Communication failed
1997 * @retval #WIFI_DIRECT_ERROR_NOT_PERMITTED  Operation not permitted
1998 * @retval #WIFI_DIRECT_ERROR_NOT_INITIALIZED  Not initialized
1999 * @retval #WIFI_DIRECT_ERROR_RESOURCE_BUSY  Device or resource busy
2000 * @pre Wi-Fi Direct service must be initialized by wifi_direct_initialize().
2001 * @see wifi_direct_initialize()
2002 */
2003 int wifi_direct_get_secondary_device_type(wifi_direct_secondary_device_type_e *type);
2004
2005
2006 /*****************************************************************************************/
2007 /* wifi_direct_accept_connection API function prototype
2008  * int wifi_direct_accept_connection(char* mac_address);
2009  */
2010 /**
2011  * \brief This API shall accept connection request from specified peer. \n
2012  * This API shall be used to respond the connection request event, WIFI_DIRECT_CONNECTION_REQ.
2013  *
2014  * @param mac_addr Device address of target peer.
2015  *
2016  * \see wifi_direct_connect
2017  *
2018  * \par Sync (or) Async:
2019  * This is a Asynchronous API.
2020  *
2021  * \warning
2022  *  None
2023  *
2024  * \par Async Response Message:
2025  *    - WIFI_DIRECT_CONNECTION_IN_PROGRESS :  Applications will receive this event
2026  *                                   via callback when the connection process is started.
2027  *    - WIFI_DIRECT_CONNECTION_RSP :  Applications will receive this event
2028  *                                   via callback when the connection process is completed or failed.
2029  *
2030  * \return Return Type (int) \n
2031  * - WIFI_DIRECT_ERROR_NONE on success \n
2032  * - WIFI_DIRECT_ERROR_OPERATION_FAILED for "Unkown error" \n
2033  * - WIFI_DIRECT_ERROR_OUT_OF_MEMORY for "Out of memory" \n
2034  * - WIFI_DIRECT_ERROR_COMMUNICATION_FAILED for "I/O error" \n
2035  * - WIFI_DIRECT_ERROR_NOT_PERMITTED for "Operation not permitted" \n
2036  * - WIFI_DIRECT_ERROR_INVALID_PARAMETER for "Invalid function parameter" \n
2037  * - WIFI_DIRECT_ERROR_RESOURCE_BUSY for "Device or resource busy" \n
2038  * - WIFI_DIRECT_ERROR_CONNECTION_TIME_OUT for "Connection timed out" \n
2039  * - WIFI_DIRECT_ERROR_STRANGE_CLIENT for "Invalid Client" \n
2040  * - WIFI_DIRECT_ERROR_CONNECTION_FAILED for "Create Link fail" \n
2041  * - WIFI_DIRECT_ERROR_AUTH_FAILED for "Create Link Auth fail" \n
2042  *
2043  *
2044  * \par Prospective Clients:
2045  * External Apps.
2046  *
2047  * \code
2048  *
2049  * #include <wifi-direct.h>
2050  *
2051  * void foo(unsigned char* mac_addr)
2052  * {
2053  * int result;
2054  *
2055  * result = wifi_direct_accept_connection(mac_addr);
2056  *
2057  * if(result == WIFI_DIRECT_ERROR_NONE)......... // connect request is successful
2058  *
2059  *\endcode
2060  *
2061  *\remarks This API will not try to send provisioning request.
2062  *
2063  ******************************************************************************/
2064 int wifi_direct_accept_connection(char *mac_address);
2065
2066
2067 /*****************************************************************************************/
2068 /* wifi_direct_get_passphrase API function prototype
2069  * int wifi_direct_get_passphrase(char** passphrase)
2070  */
2071 /**
2072  * \brief If a client create Group (Soft AP), this API shall get wpa password. \n
2073  * @param passphrase              Pointer to store wpa password. Application must free this memory.
2074  *
2075  *
2076  * \par Sync (or) Async:
2077  * This is a Synchronous API.
2078  *
2079  * \warning
2080  *  None
2081  *
2082  *
2083  * \return Return Type (int) \n
2084  * - WIFI_DIRECT_ERROR_NONE on success \n
2085  * - WIFI_DIRECT_ERROR_OPERATION_FAILED for "Unkown error" \n
2086  * - WIFI_DIRECT_ERROR_OUT_OF_MEMORY for "Out of memory" \n
2087  * - WIFI_DIRECT_ERROR_COMMUNICATION_FAILED for "I/O error" \n
2088  * - WIFI_DIRECT_ERROR_NOT_PERMITTED for "Operation not permitted" \n
2089  * - WIFI_DIRECT_ERROR_INVALID_PARAMETER for "Invalid function parameter" \n
2090  * - WIFI_DIRECT_ERROR_RESOURCE_BUSY for "Device or resource busy" \n
2091  * - WIFI_DIRECT_ERROR_STRANGE_CLIENT for "Invalid Client" \n
2092  *
2093  * \par Prospective Clients:
2094  * External Apps.
2095  *
2096  * \code
2097  *
2098  * #include <wifi-direct.h>
2099  *
2100  * void foo()
2101  * {
2102  * int  result;
2103  * char* wpa = NULL;
2104  *
2105  * result=wifi_direct_get_passphrase(&wpa);
2106  *
2107  * if(result == WIFI_DIRECT_ERROR_NONE)........//getting wpa passphrase is successful
2108  *
2109  * free(wpa); // Application should free the memory
2110  *
2111  *\endcode
2112  *
2113  *\remarks None.
2114  *
2115  ******************************************************************************/
2116 int wifi_direct_get_passphrase(char **passphrase);
2117
2118
2119 /*****************************************************************************************/
2120 /* wifi_direct_set_wpa_passphrase API function prototype
2121  * int wifi_direct_set_wpa_passphrase(char* passphrase)
2122  */
2123 /**
2124  * \brief This API shall set or update wpa password. If a client create Group (Soft AP), this password will be used. \n
2125  * @param passphrase              new wpa password to set. Application must set the new password before.
2126  *
2127  *
2128  * \par Sync (or) Async:
2129  * This is a Synchronous API.
2130  *
2131  * \warning
2132  *  None
2133  *
2134  *
2135  * \return Return Type (int) \n
2136  * - WIFI_DIRECT_ERROR_NONE on success \n
2137  * - WIFI_DIRECT_ERROR_OPERATION_FAILED for "Unkown error" \n
2138  * - WIFI_DIRECT_ERROR_OUT_OF_MEMORY for "Out of memory" \n
2139  * - WIFI_DIRECT_ERROR_COMMUNICATION_FAILED for "I/O error" \n
2140  * - WIFI_DIRECT_ERROR_NOT_PERMITTED for "Operation not permitted" \n
2141  * - WIFI_DIRECT_ERROR_INVALID_PARAMETER for "Invalid function parameter" \n
2142  * - WIFI_DIRECT_ERROR_RESOURCE_BUSY for "Device or resource busy" \n
2143  * - WIFI_DIRECT_ERROR_STRANGE_CLIENT for "Invalid Client" \n
2144  *
2145  * \par Prospective Clients:
2146  * External Apps.
2147  *
2148  * \code
2149  *
2150  * #include <wifi-direct.h>
2151  *
2152  * void foo()
2153  * {
2154  * int  result;
2155  * char new_wpa[64+1] = {0,};
2156  *
2157  * printf("Input new WPA:\n");
2158  * scanf("%s",new_wpa);
2159  *
2160  *if( strlen(new_wpa) > 0 )
2161  *      result = wifi_direct_set_wpa_passphrase(new_wpa);
2162  *
2163  * if(result == WIFI_DIRECT_ERROR_NONE)......... // setting password is successful
2164  *
2165  *\endcode
2166  *
2167  *\remarks None.
2168  *
2169  ******************************************************************************/
2170 int wifi_direct_set_wpa_passphrase(char *passphrase);
2171
2172
2173 /*****************************************************************************************/
2174 /* wifi_direct_activate_pushbutton API function prototype
2175  * int wifi_direct_activate_pushbutton(void);
2176  */
2177 /**
2178  * \brief This API shall start wps PBC.
2179
2180  * \pre Device must support the pbc button mode.
2181  *
2182  * \see wifi_direct_foreach_supported_wps_types
2183  *
2184  * \par Sync (or) Async:
2185  * This is a Synchronous API.
2186  *
2187  * \warning
2188  *  None
2189  *
2190  * \return Return Type (int) \n
2191  * - WIFI_DIRECT_ERROR_NONE on success \n
2192  * - WIFI_DIRECT_ERROR_OPERATION_FAILED for "Unkown error" \n
2193  * - WIFI_DIRECT_ERROR_OUT_OF_MEMORY for "Out of memory" \n
2194  * - WIFI_DIRECT_ERROR_COMMUNICATION_FAILED for "I/O error" \n
2195  * - WIFI_DIRECT_ERROR_NOT_PERMITTED for "Operation not permitted" \n
2196  * - WIFI_DIRECT_ERROR_RESOURCE_BUSY for "Device or resource busy" \n
2197  * - WIFI_DIRECT_ERROR_STRANGE_CLIENT for "Invalid Client" \n
2198  *
2199  * \par Prospective Clients:
2200  * External Apps.
2201  *
2202  * \code
2203  *
2204  * #include <wifi-direct.h>
2205  *
2206  * void foo(void)
2207  * {
2208
2209  * int result;
2210  *
2211  * result = wifi_direct_activate_pushbutton();
2212  *
2213  * if(result == WIFI_DIRECT_ERROR_NONE)......... // activating push button is successful
2214  *
2215  *\endcode
2216  *
2217  *\remarks None.
2218  *
2219  ******************************************************************************/
2220 int wifi_direct_activate_pushbutton(void);
2221
2222
2223 /*****************************************************************************************/
2224 /* wifi_direct_set_wps_pin API function prototype
2225  * int wifi_direct_set_wps_pin(char* pin)
2226  */
2227 /**
2228  * \brief This API shall set or update the WPS PIN number user expects. \n
2229  * @param pin              new pin to set. Application must set the new pin number before.
2230  *
2231  * \see wifi_direct_generate_wps_pin.
2232  * \see wifi_direct_get_wps_pin
2233  *
2234  * \par Sync (or) Async:
2235  * This is a Synchronous API.
2236  *
2237  * \warning
2238  *  None
2239  *
2240  *
2241  * \return Return Type (int) \n
2242  * - WIFI_DIRECT_ERROR_NONE on success \n
2243  * - WIFI_DIRECT_ERROR_OPERATION_FAILED for "Unkown error" \n
2244  * - WIFI_DIRECT_ERROR_OUT_OF_MEMORY for "Out of memory" \n
2245  * - WIFI_DIRECT_ERROR_COMMUNICATION_FAILED for "I/O error" \n
2246  * - WIFI_DIRECT_ERROR_NOT_PERMITTED for "Operation not permitted" \n
2247  * - WIFI_DIRECT_ERROR_INVALID_PARAMETER for "Invalid function parameter" \n
2248  * - WIFI_DIRECT_ERROR_RESOURCE_BUSY for "Device or resource busy" \n
2249  * - WIFI_DIRECT_ERROR_STRANGE_CLIENT for "Invalid Client" \n
2250  *
2251  *
2252  * \par Prospective Clients:
2253  * External Apps.
2254  *
2255  * \code
2256  *
2257  * #include <wifi-direct.h>
2258  *
2259  * void foo()
2260  * {
2261  * int  result;
2262  * char pin[WIFI_DIRECT_WPS_PIN_LEN+1]= { 0, };
2263  *
2264  * memset(pin, 0x00, sizeof(pin));
2265  * printf("Input 8 digit PIN number :\n");
2266  * scanf("%s", pin);
2267  *
2268  *if( strlen(pin) > 0 )
2269  *      result = wifi_direct_set_wps_pin(pin);
2270  *
2271  * if(result == WIFI_DIRECT_ERROR_NONE)......... // setting wps pin number is successful
2272  *
2273  *\endcode
2274  *
2275  *\remarks None.
2276  *
2277  ******************************************************************************/
2278 int wifi_direct_set_wps_pin(char *pin);
2279
2280
2281 /*****************************************************************************************/
2282 /* wifi_direct_get_wps_pin API function prototype
2283  * int wifi_direct_get_wps_pin(char** pin)
2284  */
2285 /**
2286  * \brief This API shall get the WPS PIN number. \n
2287  * @param pin              Pointer to store pin number. Application must free this memory.
2288  *
2289  * \see wifi_direct_set_wps_pin
2290  *
2291  * \par Sync (or) Async:
2292  * This is a Synchronous API.
2293  *
2294  * \warning
2295  *  None
2296  *
2297  *
2298  * \return Return Type (int) \n
2299  * - WIFI_DIRECT_ERROR_NONE on success \n
2300  * - WIFI_DIRECT_ERROR_OPERATION_FAILED for "Unkown error" \n
2301  * - WIFI_DIRECT_ERROR_OUT_OF_MEMORY for "Out of memory" \n
2302  * - WIFI_DIRECT_ERROR_COMMUNICATION_FAILED for "I/O error" \n
2303  * - WIFI_DIRECT_ERROR_NOT_PERMITTED for "Operation not permitted" \n
2304  * - WIFI_DIRECT_ERROR_INVALID_PARAMETER for "Invalid function parameter" \n
2305  * - WIFI_DIRECT_ERROR_RESOURCE_BUSY for "Device or resource busy" \n
2306  * - WIFI_DIRECT_ERROR_STRANGE_CLIENT for "Invalid Client" \n
2307  *
2308  *
2309  * \par Prospective Clients:
2310  * External Apps.
2311  *
2312  * \code
2313  *
2314  * #include <wifi-direct.h>
2315  *
2316  * void foo()
2317  * {
2318  * int  result;
2319  * char* pin = NULL;
2320  *
2321  * result = wifi_direct_get_wps_pin(&pin);
2322  *
2323  * if(result == WIFI_DIRECT_ERROR_NONE)......... // getting wps pin number is successful
2324  *
2325  * free(pin); // Application should free the memory.
2326  *
2327  *\endcode
2328  *
2329  *\remarks None.
2330  *
2331  ******************************************************************************/
2332 int wifi_direct_get_wps_pin(char **pin);
2333
2334
2335 /*****************************************************************************************/
2336 /* wifi_direct_generate_wps_pin API function prototype
2337  * wifi_direct_generate_wps_pin(void);
2338  */
2339 /**
2340  * \brief This API shall generate the random WPS PIN number.\n
2341  *              To get the generated PIN number, use wifi_direct_get_wps_pin() API.
2342  *
2343  * \see wifi_direct_set_wps_pin
2344  * \see wifi_direct_get_wps_pin
2345  *
2346  * \par Sync (or) Async:
2347  * This is a Synchronous API.
2348  *
2349  * \warning
2350  *  None
2351  *
2352  *
2353  * \return Return Type (int) \n
2354  * - WIFI_DIRECT_ERROR_NONE on success \n
2355  * - WIFI_DIRECT_ERROR_OPERATION_FAILED for "Unkown error" \n
2356  * - WIFI_DIRECT_ERROR_OUT_OF_MEMORY for "Out of memory" \n
2357  * - WIFI_DIRECT_ERROR_COMMUNICATION_FAILED for "I/O error" \n
2358  * - WIFI_DIRECT_ERROR_NOT_PERMITTED for "Operation not permitted" \n
2359  * - WIFI_DIRECT_ERROR_RESOURCE_BUSY for "Device or resource busy" \n
2360  * - WIFI_DIRECT_ERROR_STRANGE_CLIENT for "Invalid Client" \n
2361  *
2362  *
2363  * \par Prospective Clients:
2364  * External Apps.
2365  *
2366  * \code
2367  *
2368  * #include <wifi-direct.h>
2369  *
2370  * void foo()
2371  * {
2372  * int  result;
2373  *
2374  * result = wifi_direct_generate_wps_pin();
2375  *
2376  * if(result == WIFI_DIRECT_ERROR_NONE)......... // generating wps pin number is successful
2377  *
2378  *\endcode
2379  *
2380  *\remarks None.
2381  *
2382  ******************************************************************************/
2383 int wifi_direct_generate_wps_pin(void);
2384
2385
2386 /*****************************************************************************************/
2387 /* wifi_direct_get_supported_wps_mode API function prototype
2388  * int wifi_direct_get_supported_wps_mode(int *wps_mode);
2389  */
2390 /**
2391  * \brief This API shall get the supported wps mode. \n
2392  *              The result is bit flag.
2393  *
2394  * @param wps_mode              Memory to store supported wps mode. Application must allocate memory.
2395  *
2396  * \see wifi_direct_wps_type_e
2397  *
2398  * \par Sync (or) Async:
2399  * This is a Synchronous API.
2400  *
2401  * \warning
2402  *  None
2403  *
2404  *
2405  * \return Return Type (int) \n
2406  * - WIFI_DIRECT_ERROR_NONE on success \n
2407  * - WIFI_DIRECT_ERROR_OPERATION_FAILED for "Unkown error" \n
2408  * - WIFI_DIRECT_ERROR_OUT_OF_MEMORY for "Out of memory" \n
2409  * - WIFI_DIRECT_ERROR_COMMUNICATION_FAILED for "I/O error" \n
2410  * - WIFI_DIRECT_ERROR_NOT_PERMITTED for "Operation not permitted" \n
2411  * - WIFI_DIRECT_ERROR_INVALID_PARAMETER for "Invalid function parameter" \n
2412  * - WIFI_DIRECT_ERROR_RESOURCE_BUSY for "Device or resource busy" \n
2413  * - WIFI_DIRECT_ERROR_STRANGE_CLIENT for "Invalid Client" \n
2414  *
2415  *
2416  * \par Prospective Clients:
2417  * External Apps.
2418  *
2419  * \code
2420  *
2421  * #include <wifi-direct.h>
2422  *
2423  * void foo()
2424  * {
2425  * int  result;
2426  * int supported_wps_mode = 0;
2427  *
2428  * result = wifi_direct_get_supported_wps_mode(&supported_wps_mode);
2429  *
2430  * if(result == WIFI_DIRECT_ERROR_NONE)......... // getting supported wps mode is successful
2431  *
2432  *\endcode
2433  *
2434  *\remarks None.
2435  *
2436  ******************************************************************************/
2437 int wifi_direct_get_supported_wps_mode(int *wps_mode);
2438
2439
2440 /**
2441 * @brief Called when you get the supported WPS(Wi-Fi Protected Setup) type repeatedly.
2442 * @param[in] type  The type of WPS
2443 * @param[in] user_data  The user data passed from the request function
2444 * @return  @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
2445 * @pre  wifi_direct_foreach_supported_wps_types() will invoke this callback.
2446 * @see  wifi_direct_foreach_supported_wps_types()
2447 */
2448 typedef bool(*wifi_direct_supported_wps_type_cb)(wifi_direct_wps_type_e type, void *user_data);
2449
2450 /**
2451 * @brief Gets the supported WPS(Wi-Fi Protected Setup) types.
2452 * @param[in] callback  The callback function to invoke
2453 * @param[in] user_data  The user data to be passed to the callback function
2454 * @retval #WIFI_DIRECT_ERROR_NONE  Successful
2455 * @retval #WIFI_DIRECT_ERROR_INVALID_PARAMETER  Invalid parameter
2456 * @see wifi_direct_supported_wps_type_cb()
2457 */
2458 int wifi_direct_foreach_supported_wps_types(wifi_direct_supported_wps_type_cb callback, void *user_data);
2459
2460 /**
2461  * @brief Gets the WPS(Wi-Fi Protected Setup) type.
2462  * @param[out] type  The type of WPS
2463  * @retval #WIFI_DIRECT_ERROR_NONE  Successful
2464  * @retval #WIFI_DIRECT_ERROR_INVALID_PARAMETER  Invalid parameter
2465  * @see wifi_direct_foreach_supported_wps_types()
2466  */
2467 int wifi_direct_get_local_wps_type(wifi_direct_wps_type_e *type);
2468
2469 /**
2470  * @brief Sets the requested WPS(Wi-Fi Protected Setup) type.
2471  * @param[in] type  The type of WPS
2472  * @retval #WIFI_DIRECT_ERROR_NONE  Successful
2473  * @retval #WIFI_DIRECT_ERROR_INVALID_PARAMETER  Invalid parameter
2474  * @see wifi_direct_foreach_supported_wps_types()
2475  */
2476 int wifi_direct_set_req_wps_type(wifi_direct_wps_type_e type);
2477
2478 /**
2479  * @brief Gets the requested WPS(Wi-Fi Protected Setup) type.
2480  * @param[out] type  The type of WPS
2481  * @retval #WIFI_DIRECT_ERROR_NONE  Successful
2482  * @retval #WIFI_DIRECT_ERROR_INVALID_PARAMETER  Invalid parameter
2483  * @see wifi_direct_foreach_supported_wps_types()
2484  */
2485 int wifi_direct_get_req_wps_type(wifi_direct_wps_type_e *type);
2486
2487 /**
2488 * @brief Sets the intent of a group owner.
2489 * @remakrs The range of intent is 0 ~ 15.
2490 * @param[in] intent  The intent of a group owner
2491 * @retval #WIFI_DIRECT_ERROR_NONE  Successful
2492 * @retval #WIFI_DIRECT_ERROR_INVALID_PARAMETER  Invalid parameter
2493 * @see wifi_direct_get_group_owner_intent()
2494 */
2495 int wifi_direct_set_group_owner_intent(int intent);
2496
2497 /**
2498 * @brief Gets the intent of a group owner.
2499 * @param[out] intent  The intent of a group owner
2500 * @retval #WIFI_DIRECT_ERROR_NONE  Successful
2501 * @retval #WIFI_DIRECT_ERROR_INVALID_PARAMETER  Invalid parameter
2502 * @see wifi_direct_set_group_owner_intent()
2503 */
2504 int wifi_direct_get_group_owner_intent(int *intent);
2505
2506 /**
2507 * @brief Sets the max number of clients.
2508 * @param[in] max  The max number of clients
2509 * @retval #WIFI_DIRECT_ERROR_NONE  Successful
2510 * @retval #WIFI_DIRECT_ERROR_INVALID_PARAMETER  Invalid parameter
2511 * @see wifi_direct_get_max_clients()
2512 */
2513 int wifi_direct_set_max_clients(int max);
2514
2515 /**
2516 * @brief Gets the max number of clients.
2517 * @param[in] max  The max number of clients
2518 * @retval #WIFI_DIRECT_ERROR_NONE  Successful
2519 * @retval #WIFI_DIRECT_ERROR_INVALID_PARAMETER  Invalid parameter
2520 * @see wifi_direct_set_max_clients()
2521 */
2522 int wifi_direct_get_max_clients(int *max);
2523
2524
2525 /**
2526 * @brief Gets the channel of own group. - DEPRECATED
2527 * @param[out] channel  The channel of own group
2528 * @return 0 on success, otherwise a negative error value.
2529 * @retval #WIFI_DIRECT_ERROR_NONE  Successful
2530 * @retval #WIFI_DIRECT_ERROR_INVALID_PARAMETER  Invalid parameter
2531 * @retval #WIFI_DIRECT_ERROR_OPERATION_FAILED  Operation failed
2532 * @retval #WIFI_DIRECT_ERROR_COMMUNICATION_FAILED  Communication failed
2533 * @retval #WIFI_DIRECT_ERROR_NOT_PERMITTED  Operation not permitted
2534 * @retval #WIFI_DIRECT_ERROR_NOT_INITIALIZED  Not initialized
2535 * @retval #WIFI_DIRECT_ERROR_RESOURCE_BUSY  Device or resource busy
2536 * @pre Wi-Fi Direct service must be initialized by wifi_direct_initialize().
2537 * @see wifi_direct_initialize()
2538 */
2539 int wifi_direct_get_own_group_channel(int *channel);
2540
2541
2542 /**
2543 * @brief Gets the operating channel.
2544 * @param[out] channel  The operating channel
2545 * @return 0 on success, otherwise a negative error value.
2546 * @retval #WIFI_DIRECT_ERROR_NONE  Successful
2547 * @retval #WIFI_DIRECT_ERROR_INVALID_PARAMETER  Invalid parameter
2548 * @retval #WIFI_DIRECT_ERROR_OPERATION_FAILED  Operation failed
2549 * @retval #WIFI_DIRECT_ERROR_COMMUNICATION_FAILED  Communication failed
2550 * @retval #WIFI_DIRECT_ERROR_NOT_PERMITTED  Operation not permitted
2551 * @retval #WIFI_DIRECT_ERROR_NOT_INITIALIZED  Not initialized
2552 * @retval #WIFI_DIRECT_ERROR_RESOURCE_BUSY  Device or resource busy
2553 * @pre Wi-Fi Direct service must be initialized by wifi_direct_initialize().
2554 * @see wifi_direct_initialize()
2555 */
2556 int wifi_direct_get_operating_channel(int *channel);
2557
2558 /**
2559  * @brief Sets the Autoconnection mode.
2560  * @param[in]
2561  * @retval #WIFI_DIRECT_ERROR_NONE  Successful
2562  * @retval #WIFI_DIRECT_ERROR_INVALID_PARAMETER  Invalid parameter
2563  * @see wifi_direct_foreach_supported_wps_types()
2564  */
2565 int wifi_direct_set_autoconnection_mode(bool mode);
2566
2567 int wifi_direct_is_autoconnection_mode(bool *mode);
2568
2569 /**
2570 * @brief Enables the persistent group.
2571 * @details If @a enabled is true, then P2P persisten group will be used when creating a group and establishing a connection.
2572 * @param[in] enabled  The status of persistent group: (@c true = enabled, @c false = disabled)
2573 * @retval #WIFI_DIRECT_ERROR_NONE  Successful
2574 * @retval #WIFI_DIRECT_ERROR_OPERATION_FAILED  Operation failed
2575 * @retval #WIFI_DIRECT_ERROR_COMMUNICATION_FAILED  Communication failed
2576 * @retval #WIFI_DIRECT_ERROR_NOT_PERMITTED  Operation not permitted
2577 * @retval #WIFI_DIRECT_ERROR_NOT_INITIALIZED  Not initialized
2578 * @retval #WIFI_DIRECT_ERROR_RESOURCE_BUSY  Device or resource busy
2579 * @pre Wi-Fi Direct service must be initialized by wifi_direct_initialize().
2580 * @see wifi_direct_initialize()
2581 * @see wifi_direct_is_persistent_group_enabled()
2582 */
2583 int wifi_direct_set_persistent_group_enabled(bool enabled);
2584
2585 /**
2586 * @brief Checks whether the persistent group is enabled or disabled.
2587 * @param[out] enabled  The status of persistent group: (@c true = enabled, @c false = disabled)
2588 * @retval #WIFI_DIRECT_ERROR_NONE  Successful
2589 * @retval #WIFI_DIRECT_ERROR_INVALID_PARAMETER  Invalid parameter
2590 * @retval #WIFI_DIRECT_ERROR_OPERATION_FAILED  Operation failed
2591 * @retval #WIFI_DIRECT_ERROR_COMMUNICATION_FAILED  Communication failed
2592 * @retval #WIFI_DIRECT_ERROR_NOT_PERMITTED  Operation not permitted
2593 * @retval #WIFI_DIRECT_ERROR_NOT_INITIALIZED  Not initialized
2594 * @retval #WIFI_DIRECT_ERROR_RESOURCE_BUSY  Device or resource busy
2595 * @pre Wi-Fi Direct service must be initialized by wifi_direct_initialize().
2596 * @see wifi_direct_initialize()
2597 * @see wifi_direct_set_persistent_group_enabled()
2598 */
2599 int wifi_direct_is_persistent_group_enabled(bool *enabled);
2600
2601
2602 /**
2603 * @brief Called when you get the persistent groups repeatedly.
2604 * @param[in] mac_address  The MAC address of persistent group owner
2605 * @param[in] ssid  The SSID(Service Set Identifier) of persistent group owner
2606 * @param[in] user_data  The user data passed from the request function
2607 * @return  @c true to continue with the next iteration of the loop, \n @c false to break out of theloop
2608 * @pre  wifi_direct_foreach_persistent_groups() will invoke this callback.
2609 * @see  wifi_direct_foreach_persistent_groups()
2610 */
2611 typedef bool(*wifi_direct_persistent_group_cb)(const char *mac_address, const char *ssid, void *user_data);
2612
2613 /**
2614 * @brief Gets the persistent groups.
2615 * @param[in] callback  The callback function to invoke
2616 * @param[in] user_data  The user data to be passed to the callback function
2617 * @retval #WIFI_DIRECT_ERROR_NONE  Successful
2618 * @retval #WIFI_DIRECT_ERROR_INVALID_PARAMETER  Invalid parameter
2619 * @retval #WIFI_DIRECT_ERROR_OPERATION_FAILED  Operation failed
2620 * @retval #WIFI_DIRECT_ERROR_COMMUNICATION_FAILED  Communication failed
2621 * @retval #WIFI_DIRECT_ERROR_NOT_PERMITTED  Operation not permitted
2622 * @retval #WIFI_DIRECT_ERROR_NOT_INITIALIZED  Not initialized
2623 * @retval #WIFI_DIRECT_ERROR_RESOURCE_BUSY  Device or resource busy
2624 * @pre Wi-Fi Direct service must be initialized by wifi_direct_initialize().
2625 * @post wifi_direct_persistent_group_cb() will be called.
2626 * @see wifi_direct_initialize()
2627 * @see wifi_direct_persistent_group_cb()
2628 */
2629 int wifi_direct_foreach_persistent_groups(wifi_direct_persistent_group_cb callback, void *user_data);
2630
2631 /**
2632 * @brief Remove a persistent group.
2633 * @param[in] mac_address  The MAC address of persistent group owner
2634 * @param[in] ssid  The SSID(Service Set Identifier) of persistent group owner
2635 * @retval #WIFI_DIRECT_ERROR_NONE  Successful
2636 * @retval #WIFI_DIRECT_ERROR_INVALID_PARAMETER  Invalid parameter
2637 * @retval #WIFI_DIRECT_ERROR_OPERATION_FAILED  Operation failed
2638 * @retval #WIFI_DIRECT_ERROR_COMMUNICATION_FAILED  Communication failed
2639 * @retval #WIFI_DIRECT_ERROR_NOT_PERMITTED  Operation not permitted
2640 * @retval #WIFI_DIRECT_ERROR_NOT_INITIALIZED  Not initialized
2641 * @retval #WIFI_DIRECT_ERROR_RESOURCE_BUSY  Device or resource busy
2642 * @pre Wi-Fi Direct service must be initialized by wifi_direct_initialize().
2643 * @see wifi_direct_initialize()
2644 * @see wifi_direct_foreach_persistent_groups()
2645 */
2646 int wifi_direct_remove_persistent_group(const char *mac_address, const char *ssid);
2647
2648
2649 /**
2650  * @}
2651  */
2652
2653 #ifdef __cplusplus
2654 }
2655 #endif
2656
2657 #endif                                                  //__WIFI_DIRECT_INTERFACE_H_