wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1 | #include <stdint.h> |
| 2 | #include <stdio.h> |
| 3 | #include <string.h> |
| 4 | |
| 5 | |
| 6 | #ifdef __cplusplus |
| 7 | extern "C" { |
| 8 | #endif |
| 9 | |
| 10 | #include "sc_tel_types.h" |
| 11 | #include "sc_wifi.h" |
| 12 | #include "lynq-qser-wifi.h" |
| 13 | |
| 14 | /******************************************************************** |
| 15 | * @brief: qser_wifi_enable, Enable WiFi function |
| 16 | * @return : int, If equal to 0 succeeds, others fail |
| 17 | * @todo: NA |
| 18 | * @see: NA |
| 19 | * @warning: NA |
| 20 | *********************************************************************/ |
| 21 | int qser_wifi_enable(void) |
| 22 | { |
| 23 | int ret = sc_wifi_init(); |
| 24 | if (0 != ret) |
| 25 | { |
| 26 | return -1; |
| 27 | } |
| 28 | return sc_wifi_enable(); |
| 29 | } |
| 30 | |
| 31 | /******************************************************************** |
| 32 | * @brief: qser_wifi_disable, Turn off WiFi |
| 33 | * @return : int, If equal to 0 succeeds, others fail |
| 34 | * @todo: NA |
| 35 | * @see: NA |
| 36 | * @warning: NA |
| 37 | *********************************************************************/ |
| 38 | int qser_wifi_disable(void) |
| 39 | { |
| 40 | int ret = sc_wifi_disable(); |
| 41 | if (0 != ret) |
| 42 | { |
| 43 | return -1; |
| 44 | } |
| 45 | return sc_wifi_uninit(); |
| 46 | } |
| 47 | |
| 48 | /******************************************************************** |
| 49 | * @brief: qser_wifi_ap_ssid_set, Set the name of the ssid of wlan0 or wlan1 |
| 50 | * @param idx [IN]: int, Set wlan0 or wlan1 |
| 51 | * @param ssid [IN]: const char *, Set the ssid name |
| 52 | * @return : int, If equal to 0 succeeds, others fail |
| 53 | * @todo: NA |
| 54 | * @see: NA |
| 55 | * @warning: NA |
| 56 | *********************************************************************/ |
| 57 | int qser_wifi_ap_ssid_set(int idx, const char *ssid) |
| 58 | { |
| 59 | return sc_wifi_ap_ssid_set((sc_wifi_ap_index_e)idx, ssid); |
| 60 | } |
| 61 | |
| 62 | /******************************************************************** |
| 63 | * @brief: qser_wifi_ap_mode_set, Set the working protocol mode of wlan0 or wlan1 |
| 64 | * @param idx [IN]: int, Set wlan0 or wlan1 |
| 65 | * @param mode [IN]: lynq_wifi_mode_type_e, Set the working protocol mode |
| 66 | * @return : int, If equal to 0 succeeds, others fail |
| 67 | * @todo: NA |
| 68 | * @see: NA |
| 69 | * @warning: NA |
| 70 | *********************************************************************/ |
| 71 | int qser_wifi_ap_mode_set(int idx, lynq_wifi_mode_type_e mode) |
| 72 | { |
| 73 | sc_wifi_ap_mode_type_e type; |
| 74 | switch(mode) |
| 75 | { |
| 76 | case LYNQ_WIFI_MODE_80211BGN: |
| 77 | type = SC_WIFI_AP_MODE_80211BGN; |
| 78 | break; |
| 79 | case LYNQ_WIFI_MODE_80211BGNAX_2G: |
| 80 | type = SC_WIFI_AP_MODE_80211BGNAX_2G; |
| 81 | break; |
| 82 | default: |
| 83 | type = SC_WIFI_AP_MODE_MIN; |
| 84 | break; |
| 85 | } |
| 86 | return sc_wifi_ap_mode_set((sc_wifi_ap_index_e)idx, type); |
| 87 | } |
| 88 | |
| 89 | /******************************************************************** |
| 90 | * @brief: qser_wifi_ap_bandwidth_set, Set the bandwidth of wlan0 or wlan1 |
| 91 | * @param idx [IN]: int, Set wlan0 or wlan1 |
| 92 | * @param bandwidth [IN]: lynq_wifi_bandwidth_type_e, Set the bandwidth |
| 93 | * @return : int, If equal to 0 succeeds, others fail |
| 94 | * @todo: NA |
| 95 | * @see: NA |
| 96 | * @warning: NA |
| 97 | *********************************************************************/ |
| 98 | int qser_wifi_ap_bandwidth_set(int idx, lynq_wifi_bandwidth_type_e bandwidth) |
| 99 | { |
| 100 | return sc_wifi_ap_bandwidth_set((sc_wifi_ap_index_e)idx, (sc_wifi_bandwidth_e)bandwidth); |
| 101 | } |
| 102 | |
| 103 | /******************************************************************** |
| 104 | * @brief: qser_wifi_ap_channel_set, Set the channel for wlan0 or wlan1 |
| 105 | * @param idx [IN]: int, Set wlan0 or wlan1 |
| 106 | * @param country_code [IN]: const char *, Set country code |
| 107 | * @param channel [IN]: int, Set the channel |
| 108 | * @return : int, If equal to 0 succeeds, others fail |
| 109 | * @todo: NA |
| 110 | * @see: NA |
| 111 | * @warning: NA |
| 112 | *********************************************************************/ |
| 113 | int qser_wifi_ap_channel_set(int idx, const char *country_code, int channel) |
| 114 | { |
| 115 | return sc_wifi_ap_cc_ch_set((sc_wifi_ap_index_e)idx, country_code, channel); |
| 116 | } |
| 117 | |
| 118 | /******************************************************************** |
| 119 | * @brief: qser_wifi_ap_auth_set, Set the security authentication mode and password of wlan0 or wlan1 |
| 120 | * @param idx [IN]: int, Set wlan0 or wlan1 |
| 121 | * @param auth_mode [IN]: lynq_wifi_auth_e, Set the security authentication mode |
| 122 | * @param auth_passwd [IN]: const char *, Set password |
| 123 | * @return : int, If equal to 0 succeeds, others fail |
| 124 | * @todo: NA |
| 125 | * @see: NA |
| 126 | * @warning: NA |
| 127 | *********************************************************************/ |
| 128 | int qser_wifi_ap_auth_set(int idx, lynq_wifi_auth_e auth_mode, const char *auth_passwd) |
| 129 | { |
| 130 | sc_wifi_auth_e type; |
| 131 | switch (auth_mode) |
| 132 | { |
| 133 | case LYNQ_WIFI_AUTH_OPEN: |
| 134 | type = SC_WIFI_AUTH_OPEN; |
| 135 | break; |
| 136 | case LYNQ_WIFI_AUTH_WPA2_PSK: |
| 137 | type = SC_WIFI_AUTH_WPA2_PSK; |
| 138 | break; |
| 139 | case LYNQ_WIFI_AUTH_WPA_WPA2_PSK_BOTH: |
| 140 | type = SC_WIFI_AUTH_WPA_WPA2_PSK_BOTH; |
| 141 | break; |
| 142 | case LYNQ_WIFI_AUTH_WPA3_PSK: |
| 143 | type = SC_WIFI_AUTH_WPA3_PSK; |
| 144 | break; |
| 145 | case LYNQ_WIFI_AUTH_WPA2_WPA3_PSK_BOTH: |
| 146 | type = SC_WIFI_AUTH_WPA2_WPA3_PSK_BOTH; |
| 147 | break; |
| 148 | default: |
| 149 | type = SC_WIFI_AUTH_MIN; |
| 150 | break; |
| 151 | } |
| 152 | sc_wifi_ap_auth_t auth; |
| 153 | auth.auth = (sc_wifi_auth_e)type; |
| 154 | strncpy(auth.passwd, auth_passwd, sizeof(auth.passwd) - 1); |
| 155 | return sc_wifi_ap_auth_set((sc_wifi_ap_index_e)idx, &auth); |
| 156 | } |
| 157 | |
| 158 | /******************************************************************** |
| 159 | * @brief: qser_wifi_ap_max_sta_set, Set the maximum number of STAs for wlan0 or wlan1 |
| 160 | * @param idx [IN]: int, Set wlan0 or wlan1 |
| 161 | * @param max_sta_num [IN]: int, Set the maximum number |
| 162 | * @return : int, If equal to 0 succeeds, others fail |
| 163 | * @todo: NA |
| 164 | * @see: NA |
| 165 | * @warning: NA |
| 166 | *********************************************************************/ |
| 167 | int qser_wifi_ap_max_sta_set(int idx, int max_sta_num) |
| 168 | { |
| 169 | return sc_wifi_ap_max_sta_num_set((sc_wifi_ap_index_e)idx, max_sta_num); |
| 170 | } |
| 171 | |
| 172 | /******************************************************************** |
| 173 | * @brief: qser_wifi_ap_start, Set the ap mode of wlan0 or wlan1 to enable |
| 174 | * @param idx [IN]: int, Set wlan0 or wlan1 |
| 175 | * @return : int, If equal to 0 succeeds, others fail |
| 176 | * @todo: NA |
| 177 | * @see: NA |
| 178 | * @warning: NA |
| 179 | *********************************************************************/ |
| 180 | int qser_wifi_ap_start(int idx) |
| 181 | { |
| 182 | return sc_wifi_ap_start((sc_wifi_ap_index_e)idx); |
| 183 | } |
| 184 | |
| 185 | /******************************************************************** |
| 186 | * @brief: qser_wifi_ap_stop, Disable ap mode for wlan0 or wlan1 |
| 187 | * @param idx [IN]: int, Set wlan0 or wlan1 |
| 188 | * @return : int, If equal to 0 succeeds, others fail |
| 189 | * @todo: NA |
| 190 | * @see: NA |
| 191 | * @warning: NA |
| 192 | *********************************************************************/ |
| 193 | int qser_wifi_ap_stop(int idx) |
| 194 | { |
| 195 | return sc_wifi_ap_stop((sc_wifi_ap_index_e)idx); |
| 196 | } |
| 197 | |
| 198 | /******************************************************************** |
| 199 | * @brief: qser_wifi_ap_restart, Set the ap mode of wlan0 or wlan1 to restart |
| 200 | * @param idx [IN]: int, Set wlan0 or wlan1 |
| 201 | * @return : int, If equal to 0 succeeds, others fail |
| 202 | * @todo: NA |
| 203 | * @see: NA |
| 204 | * @warning: NA |
| 205 | *********************************************************************/ |
| 206 | int qser_wifi_ap_restart(int idx) |
| 207 | { |
| 208 | int ret = sc_wifi_ap_stop((sc_wifi_ap_index_e)idx); |
| 209 | if (0 != ret) |
| 210 | { |
| 211 | return -1; |
| 212 | } |
| 213 | return sc_wifi_ap_start((sc_wifi_ap_index_e)idx); |
| 214 | } |
| 215 | |
| 216 | //DEFINE_LYNQ_LIB_LOG(LYNQ_WIFI) |
| 217 | |
| 218 | #ifdef __cplusplus |
| 219 | } |
| 220 | #endif |