1 /*
2  * Copyright (c) 2020 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /**
17  * @addtogroup wifiservice
18  * @{
19  *
20  * @brief Provides functions for the Wi-Fi station and hotspot modes.
21  *
22  * You can use this module to enable and disable the Wi-Fi station or hotspot mode, connect to and disconnect from a
23  * station or hotspot, query the station or hotspot status, and listen for events. \n
24  *
25  * @since 7
26  */
27 
28 /**
29  * @file wifi_event.h
30  *
31  * @brief Defines callbacks and structure of Wi-Fi events.
32  *
33  * {@link RegisterWifiEvent} can be used to listen for Wi-Fi connection, disconnection, and scan events. \n
34  *
35  * @since 7
36  */
37 #ifndef WIFI_EVENT_C_H
38 #define WIFI_EVENT_C_H
39 
40 #include "wifi_linked_info.h"
41 #include "station_info.h"
42 #include "wifi_error_code.h"
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 /**
49  * @brief Indicates that the Wi-Fi station mode is enabled.
50  *
51  */
52 #define WIFI_STA_ACTIVE 1
53 /**
54  * @brief Indicates that the Wi-Fi station mode is disabled.
55  *
56  */
57 #define WIFI_STA_NOT_ACTIVE 0
58 
59 /**
60  * @brief Indicates that the Wi-Fi hotspot mode is enabled.
61  *
62  */
63 #define WIFI_HOTSPOT_ACTIVE 1
64 /**
65  * @brief Indicates that the Wi-Fi hotspot mode is disabled.
66  *
67  */
68 #define WIFI_HOTSPOT_NOT_ACTIVE 0
69 
70 /**
71  * @brief Indicates the maximum number of event listeners that can be registered using {@link RegisterWifiEvent}.
72  *
73  * When the maximum number is reached, you need to unregister at least one listener before registering new ones. \n
74  */
75 #define WIFI_MAX_EVENT_SIZE 10
76 
77 /**
78  * @brief Represents the pointer to a Wi-Fi event callback for station and hotspot connection, disconnection, or scan.
79  *
80  *
81  * If you do not need a callback, set the value of its pointer to <b>NULL</b>. \n
82  *
83  * @since 7
84  */
85 typedef struct {
86     /** Connection state change */
87     void (*OnWifiConnectionChanged)(int state, WifiLinkedInfo *info);
88     /** Scan state change */
89     void (*OnWifiScanStateChanged)(int state, int size);
90     /** Hotspot state change */
91     void (*OnHotspotStateChanged)(int state);
92     /** Station connected */
93     void (*OnHotspotStaJoin)(StationInfo *info);
94     /** Station disconnected */
95     void (*OnHotspotStaLeave)(StationInfo *info);
96 } WifiEvent;
97 
98 /**
99  * @brief Enumerates states in Wi-Fi events.
100  *
101  *
102  *
103  * @since 7
104  */
105 typedef enum {
106     /** Unavailable state */
107     WIFI_STATE_NOT_AVAILABLE = 0,
108     /** Available state */
109     WIFI_STATE_AVAILABLE
110 } WifiEventState;
111 
112 #ifdef __cplusplus
113 }
114 #endif
115 
116 #endif // WIFI_EVENT_C_H
117 /** @} */
118