blob: 0a2771d6b4eda25b7488d3daf350c509f7264bc4 [file] [log] [blame]
qs.xiong1af5daf2022-03-14 09:12:12 -04001/**@File libwifi6.h
2* @Brief :about function test
3* @details :
4* @Author : qs.xiong
5* @Date : 2022-3-14
6* @Version : V1.0
7* @copy ritght : Copyright (c) MobileTek
8*/
qs.xiong7a105ce2022-03-02 09:43:11 -05009#ifndef __LIBWIFI6_H__
10#define __LIBWIFI6_H__
11
12typedef enum {
you.chen35020192022-05-06 11:30:57 +080013 LYNQ_WIFI_BANDWIDTH_HT10 = 0, // not support in ap mode
14 LYNQ_WIFI_BANDWIDTH_HT20,
15 LYNQ_WIFI_BANDWIDTH_HT40, // not support in ap mode
16 LYNQ_WIFI_BANDWIDTH_HT80,
qs.xiong7a105ce2022-03-02 09:43:11 -050017}lynq_wifi_bandwidth_type_m;
18
19typedef enum {
you.chen35020192022-05-06 11:30:57 +080020 LYNQ_WIFI_AUTH_OPEN = 0,
qs.xiong9fbf74e2023-03-28 13:38:22 +080021 LYNQ_WIFI_AUTH_WEP, // not support WEP
you.chen35020192022-05-06 11:30:57 +080022 LYNQ_WIFI_AUTH_WPA_PSK,
23 LYNQ_WIFI_AUTH_WPA2_PSK,
qs.xiong9fbf74e2023-03-28 13:38:22 +080024 LYNQ_WIFI_AUTH_WPA2_WPA3_PSK,
25 LYNQ_WIFI_AUTH_WPA3_PSK,
you.chen35020192022-05-06 11:30:57 +080026}lynq_wifi_auth_s;
qs.xiong7a105ce2022-03-02 09:43:11 -050027
28typedef enum {
you.chen35020192022-05-06 11:30:57 +080029 LYNQ_WIFI_2G_band = 1,
30 LYNQ_WIFI_5G_band,
31 LYNQ_WIFI_2_and_5G_band, //not support
32}lynq_wifi_band_m;
qs.xiong7a105ce2022-03-02 09:43:11 -050033
qs.xiongf1b525b2022-03-31 00:58:23 -040034typedef enum {
you.chen35020192022-05-06 11:30:57 +080035 LYNQ_WIFI_AP_STATUS_DISABLE = 0,
36 LYNQ_WIFI_AP_STATUS_ENABLE, //ap is running status
37}lynq_wifi_ap_run_status_s;
38
39typedef enum {
40 LYNQ_WIFI_STA_STATUS_DISABLE = 0,
41 LYNQ_WIFI_STA_STATUS_ENABLE, //sta is running status
42}lynq_wifi_sta_run_status_s;
43
44typedef enum {
45 LYNQ_WIFI_INTERFACE_0 = 0, //sta
46 LYNQ_WIFI_INTERFACE_1, //ap
qs.xiongf1b525b2022-03-31 00:58:23 -040047}lynq_wifi_index_e;
qs.xiong7a105ce2022-03-02 09:43:11 -050048
you.chen35020192022-05-06 11:30:57 +080049typedef enum {
50 LYNQ_WIFI_STATUS_DISCONNECT = 0,
51 LYNQ_WIFI_STATUS_CONNECT,
52}lynq_wifi_ap_status_s;
53
54typedef struct ap_info
55{
56 char ap_ip[32];
57 char ap_mac[32];
qs.xiongfef46502023-02-16 15:54:49 +080058 char ap_ssid[64];
you.chen35020192022-05-06 11:30:57 +080059 char psw[64]; //password
60 lynq_wifi_auth_s auth;
61 lynq_wifi_band_m band;
62}ap_info_s;
63
64typedef struct device_info
65{
66 char sta_ip[32];
67 char sta_mac[32];
68 char hostname[32];
69 lynq_wifi_ap_status_s status;
70}device_info_s;
71
72typedef struct scan_info
73{
74 char mac[32];
qs.xiongfef46502023-02-16 15:54:49 +080075 char ssid[64];
you.chen35020192022-05-06 11:30:57 +080076 lynq_wifi_band_m band;
77 lynq_wifi_auth_s auth;
78 int rssi;
79}scan_info_s;
80
81typedef struct ap_detail_info
82{
83 struct ap_info base_info; // base_info : base info of strcut ap_info
84 lynq_wifi_ap_run_status_s status; // status:is not running 1:is running
85 int rssi; //[0~199]
86}ap_detail_info_s;
87
88typedef struct saved_ap_info
89{
90 struct ap_info base_info;
91}saved_ap_info_s;
92
93
94// insmod drive and start service of wifi
qs.xiong7a105ce2022-03-02 09:43:11 -050095int lynq_wifi_enable(void);
you.chen35020192022-05-06 11:30:57 +080096//rmmod drive
qs.xiong7a105ce2022-03-02 09:43:11 -050097int lynq_wifi_disable(void);
you.chen35020192022-05-06 11:30:57 +080098//set ssid of ap
qs.xiongf1b525b2022-03-31 00:58:23 -040099int lynq_wifi_ap_ssid_set(lynq_wifi_index_e idx,char *ap_ssid);
you.chen35020192022-05-06 11:30:57 +0800100//get ap of ssid
qs.xiongf1b525b2022-03-31 00:58:23 -0400101int lynq_wifi_ap_ssid_get(lynq_wifi_index_e idx,char *ap_ssid);
you.chen35020192022-05-06 11:30:57 +0800102
103//set frquency for ap
qs.xiongf1b525b2022-03-31 00:58:23 -0400104int lynq_wifi_ap_frequency_set(lynq_wifi_index_e idx,int lynq_wifi_frequency);
you.chen35020192022-05-06 11:30:57 +0800105//get freuency of ap
qs.xiongf1b525b2022-03-31 00:58:23 -0400106int lynq_wifi_ap_frequency_get(lynq_wifi_index_e idx,int *lynq_wifi_frequency);
you.chen35020192022-05-06 11:30:57 +0800107
108//set bandwidth for ap
109int lynq_wifi_ap_bandwidth_set(lynq_wifi_index_e idx,lynq_wifi_bandwidth_type_m bandwidth);
110//get thr bandwidth of ap
qs.xiongf1b525b2022-03-31 00:58:23 -0400111int lynq_wifi_ap_bandwidth_get(lynq_wifi_index_e idx,lynq_wifi_bandwidth_type_m *bandwidth);
you.chen35020192022-05-06 11:30:57 +0800112
113//set channel for ap
qs.xiong0fb469a2022-04-14 03:50:45 -0400114int lynq_wifi_ap_channel_set( lynq_wifi_index_e idx,int channel);
you.chen35020192022-05-06 11:30:57 +0800115//get channel of ap
qs.xiongf1b525b2022-03-31 00:58:23 -0400116int lynq_wifi_ap_channel_get( lynq_wifi_index_e idx,int* channel);
you.chen35020192022-05-06 11:30:57 +0800117
118//set auth for ap
119int lynq_wifi_ap_auth_set(lynq_wifi_index_e idx, lynq_wifi_auth_s auth);
120//get ap auth
121int lynq_wifi_ap_auth_get(lynq_wifi_index_e idx, lynq_wifi_auth_s *auth);
122
123//start ap
qs.xiongf1b525b2022-03-31 00:58:23 -0400124int lynq_wifi_ap_start(lynq_wifi_index_e idx);
you.chen35020192022-05-06 11:30:57 +0800125//stop ap
qs.xiongf1b525b2022-03-31 00:58:23 -0400126int lynq_wifi_ap_stop(lynq_wifi_index_e idx);
you.chen35020192022-05-06 11:30:57 +0800127//restart ap
128int lynq_wifi_ap_restart(lynq_wifi_index_e idx);
129
130//hide ssid
qs.xiongf1b525b2022-03-31 00:58:23 -0400131int lynq_wifi_ap_hide_ssid(lynq_wifi_index_e idx);
you.chen35020192022-05-06 11:30:57 +0800132//unhide ssid
qs.xiongf1b525b2022-03-31 00:58:23 -0400133int lynq_wifi_ap_unhide_ssid(lynq_wifi_index_e idx);
qs.xiong97fa59b2022-04-07 05:41:29 -0400134
you.chen35020192022-05-06 11:30:57 +0800135//set the password for ap
136int lynq_ap_password_set(lynq_wifi_index_e idx, char *password);
137//get the ap password
138int lynq_ap_password_get(lynq_wifi_index_e idx, char *password);
qs.xiong7a105ce2022-03-02 09:43:11 -0500139
you.chen35020192022-05-06 11:30:57 +0800140//set the password to connet to dest_ap
141int lynq_sta_ssid_password_set(lynq_wifi_index_e idx, ap_info_s *ap, char *password);
142int lynq_sta_ssid_password_get(lynq_wifi_index_e idx, ap_info_s *ap, char *password);
143
144//get the ssid of sta
145int lynq_wifi_get_sta_ssid(lynq_wifi_index_e idx,char *sta_ssid);
146//get availble device info such as:ssid mac band rssi status auth
147int lynq_wifi_get_sta_available_ap(lynq_wifi_index_e idx,ap_detail_info_s *info);
148
149
150
151//get the sta connect ap auth
152int lynq_wifi_get_sta_auth(lynq_wifi_index_e idx, lynq_wifi_auth_s* auth); //auth 0:OPEN 1:WEP 2:WPA-PSK 3:WPA2-PSK
153
154//sta start connect to dest_ap
155int lynq_wifi_sta_connect(lynq_wifi_index_e idx, char *ssid, lynq_wifi_auth_s auth, char *psw);
156//disconnect
157int lynq_wifi_sta_disconnect(lynq_wifi_index_e idx,char *ssid);
158
159//start sta mode;enable sta
160int lynq_wifi_sta_start(lynq_wifi_index_e idx);
161//stop sta:disable sta
162int lynq_wifi_sta_stop(lynq_wifi_index_e idx);
163
164//Get all device info linked ap
165int lynq_get_ap_device_list(lynq_wifi_index_e idx, ap_info_s **ap, device_info_s ** list,int * len); //list info:mac ip hostname status len:device len
166//Get scan_result info
167int lynq_get_scan_list(lynq_wifi_index_e idx, scan_info_s ** list,int * len); //list info:mac ssid band auth rssi len:scan_info len
168int lynq_sta_forget_ap(lynq_wifi_index_e idx, char *ssid,lynq_wifi_auth_s auth);
169int lynq_get_sta_saved_ap(lynq_wifi_index_e idx,saved_ap_info_s ** list,int * len); //len: length of saved_ap_info
170
171//start scan availbale ap active
172int lynq_wifi_sta_start_scan(lynq_wifi_index_e idx);
173
174/*
175 * event usage:
176 * first declare a funcion like AP_CALLBACK_FUNC_PTR to recv messge from wifi lib
177 * call lynq_reg_ap_event_callback to register whih private data pointer and the callback fuction pointer declared before
178 * when envent comes the last registered callback function will been called
179 */
180
181typedef void(*AP_CALLBACK_FUNC_PTR)(void *priv, lynq_wifi_ap_status_s status);
182int lynq_reg_ap_event_callback(void *priv, AP_CALLBACK_FUNC_PTR cb);
183int lynq_unreg_ap_event_callback(void *priv);
184
185typedef enum {
186 LYNQ_WIFI_STA_STATUS_DISCONNECT = 0,
187 LYNQ_WIFI_STA_STATUS_CONNECT,
188 LYNQ_WIFI_STA_STATUS_SCAN_RESULT, //finish sta scan
189}lynq_wifi_sta_status_s;
190typedef enum
191{
192 LYNQ_TIME_OUT = 0,
193 LYNQ_PSW_ERROR,
194 LYNQ_AUTH_ERROR,
195 LYNQ_NOT_FIND_AP,
196}error_number_s;
197
198typedef void(*STA_CALLBACK_FUNC_PTR)(void *priv, lynq_wifi_sta_status_s status, error_number_s number);
199int lynq_reg_sta_event_callback(void * priv, STA_CALLBACK_FUNC_PTR cb);
200int lynq_unreg_sta_event_callback(void * priv);
201
202//get current ap status
203int lynq_get_ap_status(lynq_wifi_index_e idx, lynq_wifi_ap_run_status_s * ap_status);
204//get curent sta status
205int lynq_get_sta_status(lynq_wifi_index_e idx, lynq_wifi_sta_run_status_s * sta_status);
206
207//set the country code
208int lynq_get_country_code(lynq_wifi_index_e idx, char *country_code);
209//get current country code
210int lynq_set_country_code(lynq_wifi_index_e idx, char *country_code);
211
212//get wlan0/ap0 ip or mac
213int lynq_get_interface_ip(lynq_wifi_index_e idx,char *ip);
214int lynq_get_interface_mac(lynq_wifi_index_e idx,char *mac);
215
216
217//get current connect ap mac rssi band
218int lynq_get_connect_ap_mac(lynq_wifi_index_e idx,char *mac);
219int lynq_get_connect_ap_rssi(lynq_wifi_index_e idx,int * rssi);
220int lynq_get_connect_ap_band(lynq_wifi_index_e idx,lynq_wifi_band_m * band);
you.chenf58b3c92022-06-21 16:53:48 +0800221int lynq_get_connect_ap_ip(lynq_wifi_index_e idx,char *ip);
qs.xiong7a105ce2022-03-02 09:43:11 -0500222
qs.xiong026c5c72022-10-17 11:15:45 +0800223/*****add limit of connected ap device number 2022.10.12 by qs.xiong
224 *
225 *sta_number:
226 * ap max be connected no more than 15
227 * so sta_number : [1-15]
228 */
229int lynq_ap_connect_num(int sta_number);
230
qs.xiong77905552022-10-17 11:19:57 +0800231/****add acs contrl api*****************
232 *
233 *idx:
234 * 1 is ap and only 1 is legal in this api
235 *acs_mode:
236 * 2 is open acs at 2.4GHz
237 * 5 is open acs at 5GHz
238 * didnt ssuport 2.4G&5G together
239 * add by qs.xiong 20221012*************/
240int lynq_enable_acs(lynq_wifi_index_e idx,int acs_mode);
241
you.chen0f5c6432022-11-07 18:31:14 +0800242//you.chen add for tv-box start
243/**
244 * @brief enableGBW, repeat call will fail before disableGBW
245 * @param mac of tv-box
246 * @return
247 */
248int enableGBW(const char* mac);
249/**
250 * @brief disableGBW
251 * @return
252 */
253int disableGBW();
254//you.chen add for tv-box end
255
qs.xiong7a105ce2022-03-02 09:43:11 -0500256#endif