| #include <stdint.h> |
| #include <stdio.h> |
| #include <string.h> |
| |
| |
| #ifdef __cplusplus |
| extern "C" { |
| #endif |
| |
| #include "sc_tel_types.h" |
| #include "sc_wifi.h" |
| #include "lynq-qser-wifi.h" |
| |
| /******************************************************************** |
| * @brief: qser_wifi_enable, Enable WiFi function |
| * @return : int, If equal to 0 succeeds, others fail |
| * @todo: NA |
| * @see: NA |
| * @warning: NA |
| *********************************************************************/ |
| int qser_wifi_enable(void) |
| { |
| int ret = sc_wifi_init(); |
| if (0 != ret) |
| { |
| return -1; |
| } |
| return sc_wifi_enable(); |
| } |
| |
| /******************************************************************** |
| * @brief: qser_wifi_disable, Turn off WiFi |
| * @return : int, If equal to 0 succeeds, others fail |
| * @todo: NA |
| * @see: NA |
| * @warning: NA |
| *********************************************************************/ |
| int qser_wifi_disable(void) |
| { |
| int ret = sc_wifi_disable(); |
| if (0 != ret) |
| { |
| return -1; |
| } |
| return sc_wifi_uninit(); |
| } |
| |
| /******************************************************************** |
| * @brief: qser_wifi_ap_ssid_set, Set the name of the ssid of wlan0 or wlan1 |
| * @param idx [IN]: int, Set wlan0 or wlan1 |
| * @param ssid [IN]: const char *, Set the ssid name |
| * @return : int, If equal to 0 succeeds, others fail |
| * @todo: NA |
| * @see: NA |
| * @warning: NA |
| *********************************************************************/ |
| int qser_wifi_ap_ssid_set(int idx, const char *ssid) |
| { |
| return sc_wifi_ap_ssid_set((sc_wifi_ap_index_e)idx, ssid); |
| } |
| |
| /******************************************************************** |
| * @brief: qser_wifi_ap_mode_set, Set the working protocol mode of wlan0 or wlan1 |
| * @param idx [IN]: int, Set wlan0 or wlan1 |
| * @param mode [IN]: lynq_wifi_mode_type_e, Set the working protocol mode |
| * @return : int, If equal to 0 succeeds, others fail |
| * @todo: NA |
| * @see: NA |
| * @warning: NA |
| *********************************************************************/ |
| int qser_wifi_ap_mode_set(int idx, lynq_wifi_mode_type_e mode) |
| { |
| sc_wifi_ap_mode_type_e type; |
| switch(mode) |
| { |
| case LYNQ_WIFI_MODE_80211BGN: |
| type = SC_WIFI_AP_MODE_80211BGN; |
| break; |
| case LYNQ_WIFI_MODE_80211BGNAX_2G: |
| type = SC_WIFI_AP_MODE_80211BGNAX_2G; |
| break; |
| default: |
| type = SC_WIFI_AP_MODE_MIN; |
| break; |
| } |
| return sc_wifi_ap_mode_set((sc_wifi_ap_index_e)idx, type); |
| } |
| |
| /******************************************************************** |
| * @brief: qser_wifi_ap_bandwidth_set, Set the bandwidth of wlan0 or wlan1 |
| * @param idx [IN]: int, Set wlan0 or wlan1 |
| * @param bandwidth [IN]: lynq_wifi_bandwidth_type_e, Set the bandwidth |
| * @return : int, If equal to 0 succeeds, others fail |
| * @todo: NA |
| * @see: NA |
| * @warning: NA |
| *********************************************************************/ |
| int qser_wifi_ap_bandwidth_set(int idx, lynq_wifi_bandwidth_type_e bandwidth) |
| { |
| return sc_wifi_ap_bandwidth_set((sc_wifi_ap_index_e)idx, (sc_wifi_bandwidth_e)bandwidth); |
| } |
| |
| /******************************************************************** |
| * @brief: qser_wifi_ap_channel_set, Set the channel for wlan0 or wlan1 |
| * @param idx [IN]: int, Set wlan0 or wlan1 |
| * @param country_code [IN]: const char *, Set country code |
| * @param channel [IN]: int, Set the channel |
| * @return : int, If equal to 0 succeeds, others fail |
| * @todo: NA |
| * @see: NA |
| * @warning: NA |
| *********************************************************************/ |
| int qser_wifi_ap_channel_set(int idx, const char *country_code, int channel) |
| { |
| return sc_wifi_ap_cc_ch_set((sc_wifi_ap_index_e)idx, country_code, channel); |
| } |
| |
| /******************************************************************** |
| * @brief: qser_wifi_ap_auth_set, Set the security authentication mode and password of wlan0 or wlan1 |
| * @param idx [IN]: int, Set wlan0 or wlan1 |
| * @param auth_mode [IN]: lynq_wifi_auth_e, Set the security authentication mode |
| * @param auth_passwd [IN]: const char *, Set password |
| * @return : int, If equal to 0 succeeds, others fail |
| * @todo: NA |
| * @see: NA |
| * @warning: NA |
| *********************************************************************/ |
| int qser_wifi_ap_auth_set(int idx, lynq_wifi_auth_e auth_mode, const char *auth_passwd) |
| { |
| sc_wifi_auth_e type; |
| switch (auth_mode) |
| { |
| case LYNQ_WIFI_AUTH_OPEN: |
| type = SC_WIFI_AUTH_OPEN; |
| break; |
| case LYNQ_WIFI_AUTH_WPA2_PSK: |
| type = SC_WIFI_AUTH_WPA2_PSK; |
| break; |
| case LYNQ_WIFI_AUTH_WPA_WPA2_PSK_BOTH: |
| type = SC_WIFI_AUTH_WPA_WPA2_PSK_BOTH; |
| break; |
| case LYNQ_WIFI_AUTH_WPA3_PSK: |
| type = SC_WIFI_AUTH_WPA3_PSK; |
| break; |
| case LYNQ_WIFI_AUTH_WPA2_WPA3_PSK_BOTH: |
| type = SC_WIFI_AUTH_WPA2_WPA3_PSK_BOTH; |
| break; |
| default: |
| type = SC_WIFI_AUTH_MIN; |
| break; |
| } |
| sc_wifi_ap_auth_t auth; |
| auth.auth = (sc_wifi_auth_e)type; |
| strncpy(auth.passwd, auth_passwd, sizeof(auth.passwd) - 1); |
| return sc_wifi_ap_auth_set((sc_wifi_ap_index_e)idx, &auth); |
| } |
| |
| /******************************************************************** |
| * @brief: qser_wifi_ap_max_sta_set, Set the maximum number of STAs for wlan0 or wlan1 |
| * @param idx [IN]: int, Set wlan0 or wlan1 |
| * @param max_sta_num [IN]: int, Set the maximum number |
| * @return : int, If equal to 0 succeeds, others fail |
| * @todo: NA |
| * @see: NA |
| * @warning: NA |
| *********************************************************************/ |
| int qser_wifi_ap_max_sta_set(int idx, int max_sta_num) |
| { |
| return sc_wifi_ap_max_sta_num_set((sc_wifi_ap_index_e)idx, max_sta_num); |
| } |
| |
| /******************************************************************** |
| * @brief: qser_wifi_ap_start, Set the ap mode of wlan0 or wlan1 to enable |
| * @param idx [IN]: int, Set wlan0 or wlan1 |
| * @return : int, If equal to 0 succeeds, others fail |
| * @todo: NA |
| * @see: NA |
| * @warning: NA |
| *********************************************************************/ |
| int qser_wifi_ap_start(int idx) |
| { |
| return sc_wifi_ap_start((sc_wifi_ap_index_e)idx); |
| } |
| |
| /******************************************************************** |
| * @brief: qser_wifi_ap_stop, Disable ap mode for wlan0 or wlan1 |
| * @param idx [IN]: int, Set wlan0 or wlan1 |
| * @return : int, If equal to 0 succeeds, others fail |
| * @todo: NA |
| * @see: NA |
| * @warning: NA |
| *********************************************************************/ |
| int qser_wifi_ap_stop(int idx) |
| { |
| return sc_wifi_ap_stop((sc_wifi_ap_index_e)idx); |
| } |
| |
| /******************************************************************** |
| * @brief: qser_wifi_ap_restart, Set the ap mode of wlan0 or wlan1 to restart |
| * @param idx [IN]: int, Set wlan0 or wlan1 |
| * @return : int, If equal to 0 succeeds, others fail |
| * @todo: NA |
| * @see: NA |
| * @warning: NA |
| *********************************************************************/ |
| int qser_wifi_ap_restart(int idx) |
| { |
| int ret = sc_wifi_ap_stop((sc_wifi_ap_index_e)idx); |
| if (0 != ret) |
| { |
| return -1; |
| } |
| return sc_wifi_ap_start((sc_wifi_ap_index_e)idx); |
| } |
| |
| //DEFINE_LYNQ_LIB_LOG(LYNQ_WIFI) |
| |
| #ifdef __cplusplus |
| } |
| #endif |