• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
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  * Description: wifi_p2p_config.h 的头文件
15  */
16 
17 
18 #ifndef SERVICE_WIFI_P2P_CONFIG_C_H
19 #define SERVICE_WIFI_P2P_CONFIG_C_H
20 
21 #include "wifi_device_config.h"
22 
23 #ifdef __cplusplus
24 #if __cplusplus
25 extern "C" {
26 #endif
27 #endif
28 
29 /**
30  * @defgroup middleware_service_wifi_p2p_config WiFi P2P Config
31  * @ingroup middleware_service_wifi
32  * @{
33  */
34 
35 /**
36  * @if Eng
37  * @brief  Maximum length of the WPS device name.
38  * @else
39  * @brief  device名称最大长度。
40  * @endif
41  */
42 #define WPS_DEV_NAME_LEN 33
43 
44 
45 /**
46  * @if Eng
47  * @brief  WPS connection mode.
48  * @else
49  * @brief  wps连接方式。
50  * @endif
51  */
52 typedef enum {
53     WPS_PBC,           /*!< @if Eng PBC connection.
54                             @else   PBC方式连接。  @endif */
55     WPS_PIN_DISPLAY,   /*!< @if Eng Connected in PIN DISPLAY mode, which is not supported in 92.
56                             @else   PIN DISPLAY方式连接,92不支持。  @endif */
57     WPS_PIN_KEYPAD,    /*!< @if Eng Connected in PIN KEYPAD mode, which is not supported in 92.
58                             @else   PIN KEYPAD方式连接,92不支持。  @endif */
59     WPS_PIN_LABEL,     /*!< @if Eng Connected in PIN LABEL mode, which is not supported in 92.
60                             @else   PIN LABEL方式连接,92不支持。  @endif */
61     WPS_OTHER,         /*!< @if Eng Connected in other mode, which is not supported in 92.
62                             @else   其他方式连接,92不支持。  @endif */
63 } wps_method_enum;
64 
65 
66 /**
67  * @if Eng
68  * @brief  P2P mode.
69  * @else
70  * @brief  p2p模式。
71  * @endif
72  */
73 typedef enum {
74     P2P_MODE_GC,             /*!< @if Eng P2P GC mode.
75                                   @else   P2P GC模式。  @endif */
76     P2P_MODE_GO,             /*!< @if Eng P2P GO mode.
77                                   @else   P2P GO模式。  @endif */
78     P2P_MODE_DEVICE_ONLY,    /*!< @if Eng P2P not negotiated GO.
79                                   @else   P2P未协商GO。  @endif */
80     P2P_MODE_BUTT,
81 } p2p_mode_enum;
82 
83 
84 /**
85  * @if Eng
86  * @brief  P2P association status.
87  * @else
88  * @brief  p2p关联状态。
89  * @endif
90  */
91 typedef enum {
92     P2P_DISCONNECTED,   /*!< @if Eng Disconnected.
93                              @else   断连。  @endif */
94     P2P_CONNECTED,      /*!< @if Eng Connected.
95                              @else   已连接。  @endif */
96     P2P_CONNECTING,     /*!< @if Eng Connecting.
97                              @else   连接中。  @endif */
98     P2P_CONN_STATUS_BUTT,
99 } p2p_conn_state_enum;
100 
101 
102 /**
103  * @if Eng
104  * @brief  WFD-related information structure.
105  * @else
106  * @brief  WFD相关信息结构体。
107  * @endif
108  */
109 typedef struct wfd_info_stru {
110     int16_t device_info;    /*!< @if Eng WFD Device Type.
111                               @else   WFD设备类型。  @endif */
112     int16_t ctrl_port;      /*!< @if Eng Control port number.
113                               @else   控制端口号。  @endif */
114     int16_t max_throughput; /*!< @if Eng Maximum throughput.
115                               @else   最大吞吐量。  @endif */
116     int8_t reserved[2];
117 } wfd_info_stru;
118 
119 
120 /**
121  * @if Eng
122  * @brief  P2P scanning result.
123  * @else
124  * @brief  p2p扫描结果。
125  * @endif
126  */
127 typedef struct p2p_device_stru {
128     int8_t name[WPS_DEV_NAME_LEN];  /*!< @if Eng Device name.
129                                          @else   设备device名称。  @endif */
130     uint8_t bssid[WIFI_MAC_LEN];    /*!< @if Eng Device MAC address.
131                                          @else   设备device MAC地址。  @endif */
132     uint8_t wps_method;             /*!< @if Eng WPS connection mode supported.
133                                                  - Bit 0 indicates the PBC,
134                                                  - bit 1 indicates the PIN LABEL,
135                                                  - bit 2 indicates the PIN DISPLAY,
136                                                  - bit 3 indicates the PIN KEYPAD,
137                                                  - bit 4 indicates other modes.
138                                          @else   支持的WPS连接方式,
139                                                  - bit0表示PBC
140                                                  - bit1表示PIN LABEL
141                                                  - bit2表示PIN DISPLAY
142                                                  - bit3表示PIN KEYPAD
143                                                  - bit4表示其他方式。  @endif */
144     uint8_t is_go           : 1;    /*!< @if Eng Check whether the scanned device is a P2P go device.
145                                          @else   扫描出来的设备是否是p2p go。  @endif */
146     uint8_t enable_add_group : 1;   /*!< @if Eng Indicates whether to allow GC to be added to the group corresponding
147                                                  to the scanned go.
148                                          @else   扫描出的go对应的group,是否允许添加gc。  @endif */
149     uint8_t reserved       : 6;
150     int8_t reserved1[3];
151     wfd_info_stru wfd_info;         /*!< @if Eng Not used temporarily.
152                                          @else   暂不使用。  @endif */
153 } p2p_device_stru;
154 
155 
156 /**
157  * @if Eng
158  * @brief  P2P association configuration information.
159  * @else
160  * @brief  p2p关联的配置信息。
161  * @endif
162  */
163 typedef struct p2p_config_stru {
164     uint8_t bssid[WIFI_MAC_LEN];           /*!< @if Eng Device MAC address of the peer.
165                                                 @else   peer的device MAC地址。  @endif */
166     int8_t pin[WIFI_WPS_PIN_MAX_LEN_NUM];  /*!< @if Eng Pin Code of WPS.
167                                                 @else   WPS的Pin码。  @endif */
168     uint8_t wps_method;                    /*!< @if Eng Connection mode of WPS.
169                                                 @else   WPS的连接方式。  @endif */
170     uint8_t go_intent;                     /*!< @if Eng Go intent, the value ranges from 0 to 15.
171                                                 @else   go intent,有效范围0~15。  @endif */
172     uint8_t persistent;                    /*!< @if Eng 1: Persistent network storage;
173                                                         0: not based on permanent network storage.
174                                                 @else   1:按照永久网络存储;0:不按照永久网络存储。  @endif */
175     int8_t reserved[2];
176 } p2p_config_stru;
177 
178 
179 /**
180  * @if Eng
181  * @brief  P2P association status information.
182  * @else
183  * @brief  p2p设置信息。
184  * @endif
185  */
186 typedef struct p2p_status_info_stru {
187     int32_t operation_channel;            /*!< @if Eng Center frequency of the working channel after the GO/GC
188                                                        connection.
189                                                        This parameter is valid when wpa_state is set to CONNECTED.
190                                                @else   GO/GC连接之后工作信道的中心频点,在wpa_state为CONNECTED时有效。  @endif */
191     uint8_t mode;                         /*!< @if Eng P2P mode, which corresponds to P2pMode.
192                                                @else   P2P模式, 和P2pMode对应。  @endif */
193     uint8_t wpa_state;                    /*!< @if Eng P2P association status, which corresponds to P2pConnState.
194                                                @else   p2p关联状态,和P2pConnState对应.。  @endif */
195     int8_t group_ssid[WPS_DEV_NAME_LEN];  /*!< @if Eng Group SSID, valid only when wpa_state is set to CONNECTED
196                                                        and P2P WPS succeeds.
197                                                @else   Group SSID,并且P2P的WPS关联成功(当前阶段组协商成功)时有效。  @endif */
198     uint8_t group_bssid[WIFI_MAC_LEN];    /*!< @if Eng Group BSSID==go bssid, valid only when wpa_state is set to
199                                                        CONNECTED and P2P WPS succeeds.
200                                                @else   Group BSSID==go bssid,在wpa_state为CONNECTED,
201                                                        并且P2P的WPS关联成功(当前阶段组协商成功)时有效。  @endif */
202     int8_t reserved[3];
203 } p2p_status_info_stru;
204 
205 
206 /**
207  * @if Eng
208  * @brief  P2P connected GC information.
209  * @else
210  * @brief  p2p已连接的gc信息。
211  * @endif
212  */
213 typedef struct p2p_client_info_stru {
214     uint8_t gc_bssid[WIFI_MAC_LEN];           /*!< @if Eng MAC address of the client connected to the GO.
215                                                    @else   与go相连的client mac地址。  @endif */
216     uint8_t gc_device_bssid[WIFI_MAC_LEN];    /*!< @if Eng Device address of the client connected to the GO.
217                                                    @else   与go相连的client dev地址。  @endif */
218     int8_t gc_device_name[WPS_DEV_NAME_LEN];  /*!< @if Eng Client device name.
219                                                    @else   client 设备名称。  @endif */
220     int8_t reserved[3];
221 } p2p_client_info_stru;
222 
223 
224 /**
225  * @if Eng
226  * @brief  P2P device information.
227  * @else
228  * @brief  p2p设备信息。
229  * @endif
230  */
231 typedef struct {
232     int8_t dev_name[WPS_DEV_NAME_LEN];      /*!< @if Eng Device name.
233                                                  @else   设备名称。  @endif */
234     uint8_t wps_method;                     /*!< @if Eng WPS connection mode supported.The options are WpsMethod.
235                                                          The options are 0, 1, 2, and 3.
236                                                  @else   支持的WPS连接方式,可选项为WpsMethod,仅支持配置0/1/2/3。  @endif */
237     int32_t listen_channel;                 /*!< @if Eng Channel for replying to the probe response.
238                                                  @else   回复probe response的信道。  @endif */
239     int32_t oper_channel;                   /*!< @if Eng Recommended working channel: 0 indicates a random channel.
240                                                          A non-zero valid value indicates the recommended channel.
241                                                  @else   建议的工作信道:0表示随机信道;非0有效值表示建议的信道。  @endif */
242 } p2p_device_config_stru;
243 
244 /**
245  * @}
246  */
247 
248 #ifdef __cplusplus
249 #if __cplusplus
250 }
251 #endif
252 #endif
253 
254 #endif // SERVICE_WIFI_P2P_CONFIG_C_H
255