• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * @file hi_wifi_csi_api.h
3  *
4  * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 /**
19  * @defgroup hi_wifi_csi CSI
20  * @ingroup hi_wifi
21  */
22 
23 #ifndef __HI_WIFI_CSI_API_H__
24 #define __HI_WIFI_CSI_API_H__
25 
26 #include "hi_wifi_api.h"
27 
28 #ifdef __cplusplus
29 #if __cplusplus
30 extern "C" {
31 #endif
32 #endif
33 
34 /**
35  * @ingroup hi_wifi_csi
36  *
37  * Sample period of CSI.CNcomment:CSI 上报采样周期CNend
38  */
39 typedef enum {
40     CSI_REPORT_PERIOD_EVERY_FRAME = 0,
41     CSI_REPORT_PERIOD_256US = 1,
42     CSI_REPORT_PERIOD_512US = 2,
43     CSI_REPORT_PERIOD_1024US = 3,
44     CSI_REPORT_PERIOD_2048US = 4,
45     CSI_REPORT_PERIOD_4096US = 5,
46     CSI_REPORT_PERIOD_8192US = 6,
47     CSI_REPORT_PERIOD_16384US = 7,
48     CSI_REPORT_PERIOD_32768US = 8,
49     CSI_REPORT_PERIOD_65536US = 9,
50     CSI_REPORT_PERIOD_131072US = 10,
51     CSI_REPORT_PERIOD_262144US = 11,
52     CSI_REPORT_PERIOD_524288US = 12,
53     CSI_REPORT_PERIOD_1048576US = 13,
54     CSI_REPORT_PERIOD_2097152US = 14,
55     CSI_REPORT_PERIOD_4194304US = 15,
56     CSI_REPORT_PERIOD_BUTT
57 } hi_wifi_csi_period_enum;
58 
59 /**
60  * @ingroup hi_wifi_csi
61  *
62  * Frame type of CSI report.CNcomment:CSI 上报数据帧类型CNend
63  */
64 typedef enum {
65     CSI_FRAME_TYPE_DATA = 1,        /**< data. CNcomment: 数据帧.CNend */
66     CSI_FRAME_TYPE_MGMT = 2,        /**< management. CNcomment: 管理帧.CNend */
67     CSI_FRAME_TYPE_MGMT_DATA = 3,   /**< management and data. CNcomment: 管理帧和数据帧.CNend */
68     CSI_FRAME_TYPE_CTRL = 4,        /**< control. CNcomment: 控制帧.CNend */
69     CSI_FRAME_TYPE_CTRL_DATA = 5,   /**< control and data. CNcomment: 控制帧和数据帧.CNend */
70     CSI_FRAME_TYPE_CTRL_MGMT = 6,   /**< control adn management. CNcomment: 控制帧和管理帧.CNend */
71     CSI_FRAME_TYPE_ALL  = 7,        /**< control and data and management. CNcomment: 控制帧和数据帧和管理帧.CNend */
72     CSI_FRAME_TYPE_BUTT
73 } hi_wifi_csi_frame_type_enum;
74 
75 /**
76  * @ingroup hi_wifi_csi
77  *
78  * Struct of CSI reporting config.CNcomment:CSI 上报参数配置CNend
79  */
80 typedef struct {
81     unsigned char mac[HI_WIFI_MAC_LEN];     /**< Mac address. CNcomment: MAC地址.CNend */
82     hi_wifi_csi_frame_type_enum frame_type; /**< Report frame type. CNcomment: 上报帧类型.CNend */
83     hi_wifi_csi_period_enum sample_period;  /**< Sample period. CNcomment: 信道采样周期.CNend */
84 } hi_wifi_csi_entry;
85 
86 /**
87 * @ingroup  hi_wifi_csi
88 * @brief    CSI data report callback.
89 *
90 * @par Description:
91 *           user's callback to handle csi report data.
92             CNcomment:用户注册的回调函数,用于处理CSI上报的数据。CNend
93 *
94 * @attention  NULL
95 * @param  csi_data        [IN]     Type  #unsigned char *, 4 bytes extend timestamp + 184 bytes 64bit big endian data.
96                                          CNcomment:4字节扩展时间戳+184字节64位小端存储格式的CSI数据。CNend
97 * @param  len             [IN]     Type  #int, data length. CNcomment:数据长度,固定为188字节。CNend
98 *
99 * @retval void
100 * @par Dependency:
101 *            @li hi_wifi_csi_api.h: WiFi API
102 * @see  NULL
103 */
104 typedef void (*hi_wifi_csi_data_cb)(unsigned char *csi_data, int len);
105 
106 /**
107 * @ingroup  hi_wifi_csi
108 * @brief    Config CSI.
109 *
110 * @par Description:
111 *           Config CSI basic parameters, config csi will colse low power, stop csi can open low power again.
112             CNcomment:配置CSI数据上报功能的基本参数,配置后会关闭低功耗,暂时不启用CSI可通过stop命令开启低功耗。CNend
113 *
114 * @attention  NULL
115 * @param  ifname               [IN]     Type  #char *,interface which enable CSI, wlan0 or ap0.
116 * @param  report_min_interval  [IN]     Type  #unsigned int, report period: minimum 50 ms.
117                                               CNcomment:CSI数据上报最小间隔,最小周期50ms,小于50ms默认为50ms。CNend
118 * @param  entry_list           [IN]     Type  #hi_wifi_csi_entry *, configuration struct.
119 * @param  entry_num            [IN]     Type  #int, list number.CNcomment:entry_list的数量,可添加最大白名单数量为6。CNend
120 *
121 * @retval #HI_ERR_SUCCESS  Excute successfully
122 * @retval #Other           Error code
123 * @par Dependency:
124 *            @li hi_wifi_csi_api.h: WiFi API
125 * @see  NULL
126 */
127 int hi_wifi_csi_set_config(const char *ifname, unsigned int report_min_interval,
128                            const hi_wifi_csi_entry *entry_list, int entry_num);
129 
130 /**
131 * @ingroup  hi_wifi_csi
132 * @brief    Register report callback of CSI.CNcomment:注册CSI数据上报回调函数。CNend
133 *
134 * @par Description:
135 *           CSI data report interface.CNcomment:由用户注册回调函数,用于上报CSI数据。CNend
136 *
137 * @attention  NULL
138 * @param  data_cb         [IN]     Type  #hi_wifi_csi_data_cb, callback pointer.
139 *
140 * @retval #HI_ERR_SUCCESS  Excute successfully
141 * @retval #Other           Error code
142 * @par Dependency:
143 *            @li hi_wifi_csi_api.h: WiFi API
144 * @see  NULL
145 */
146 int hi_wifi_csi_register_data_recv_func(hi_wifi_csi_data_cb data_cb);
147 
148 /**
149 * @ingroup  hi_wifi_csi
150 * @brief    Start CSI.
151 *
152 * @par Description:
153 *           Start CSI.
154 *
155 * @attention  NULL
156 * @param  NULL
157 *
158 * @retval #HI_ERR_SUCCESS  Excute successfully
159 * @retval #Other           Error code
160 * @par Dependency:
161 *            @li hi_wifi_csi_api.h: WiFi API
162 * @see  NULL
163 */
164 int hi_wifi_csi_start(void);
165 
166 /**
167 * @ingroup  hi_wifi_csi
168 * @brief    Close CSI.
169 *
170 * @par Description:
171 *           Close CSI.
172 *
173 * @attention  NULL
174 * @param  NULL
175 *
176 * @retval #HI_ERR_SUCCESS  Excute successfully
177 * @retval #Other           Error code
178 * @par Dependency:
179 *            @li hi_wifi_csi_api.h: WiFi API
180 * @see  NULL
181 */
182 int hi_wifi_csi_stop(void);
183 
184 #ifdef __cplusplus
185 #if __cplusplus
186     }
187 #endif
188 #endif
189 
190 #endif /* end of hi_wifi_csi_api.h */
191 
192