b.liu | 8583dce | 2024-04-03 13:30:08 +0800 | [diff] [blame] | 1 | #include <ctype.h> |
| 2 | #include <errno.h> |
| 3 | #include <unistd.h> |
| 4 | #include <getopt.h> |
| 5 | #include <limits.h> |
| 6 | #include <netdb.h> |
| 7 | #include <stdbool.h> |
| 8 | #include <stdint.h> |
| 9 | #include <stdio.h> |
| 10 | #include <stdlib.h> |
| 11 | #include <string.h> |
| 12 | #include <time.h> |
| 13 | #include <syslog.h> |
| 14 | #include <pthread.h> |
| 15 | |
| 16 | #include <lynq/lynq-qser-wifi.h> |
| 17 | |
| 18 | int main(int argc, char *argv[]) |
| 19 | { |
| 20 | if (argc == 2 ) |
| 21 | { |
| 22 | if(strcmp(argv[1], "0") == 0){ |
| 23 | qser_wifi_enable(); //enable wifi |
| 24 | qser_wifi_ap_stop(LYNQ_WIFI_AP_INDEX_AP0); //Disable ap mode for wlan0 |
| 25 | qser_wifi_disable(); //Turn off WiFi |
| 26 | } |
| 27 | else if(strcmp(argv[1], "1") == 0){ |
| 28 | char pw[65] = {0}; |
| 29 | sprintf(pw, "lynq123456"); |
| 30 | qser_wifi_enable(); //enable wifi |
| 31 | qser_wifi_ap_ssid_set(LYNQ_WIFI_AP_INDEX_AP0,"hello"); //Set the ssid of wlan0 to hello |
| 32 | qser_wifi_ap_max_sta_set(LYNQ_WIFI_AP_INDEX_AP0,22); //Example Set the maximum number of connections to 22 |
| 33 | qser_wifi_ap_channel_set(LYNQ_WIFI_AP_INDEX_AP0,"CN",13); //Set the country code to CN and channel to 13 |
| 34 | qser_wifi_ap_mode_set(LYNQ_WIFI_AP_INDEX_AP0,LYNQ_WIFI_MODE_80211BGN); //Set the working protocol mode of wlan0 to 80211BGN |
| 35 | qser_wifi_ap_auth_set(LYNQ_WIFI_AP_INDEX_AP0,LYNQ_WIFI_AUTH_WPA2_PSK,pw); //Set the authentication of wlan0 to wpa2 and the password to lynq123456 |
| 36 | qser_wifi_ap_start(LYNQ_WIFI_AP_INDEX_AP0); //Set the ap mode of wlan0 |
| 37 | } |
| 38 | else if(strcmp(argv[1], "2") == 0){ |
| 39 | char pw[65] = {0}; |
| 40 | char ssid[33] = {0}; |
| 41 | char country_code[12] = {0}; |
| 42 | int channel, max_sta_num; |
| 43 | lynq_wifi_mode_type_e mode; |
| 44 | lynq_wifi_auth_e auth_mode; |
| 45 | lynq_wifi_bandwidth_type_e bandwidth; |
| 46 | int ret = -1; |
| 47 | qser_wifi_enable(); //enable wifi |
| 48 | ret = qser_wifi_ap_ssid_get(LYNQ_WIFI_AP_INDEX_AP0,ssid); //Gets the ssid of wlan0 |
| 49 | printf("[lynq-wifi-demo] ssid=%s ret = %d\n",ssid, ret); |
| 50 | ret = qser_wifi_ap_max_sta_get(LYNQ_WIFI_AP_INDEX_AP0,&max_sta_num); //Gets the maximum sta number for wlan0 |
| 51 | printf("[lynq-wifi-demo] max_sta_num = %d ret = %d\n",max_sta_num, ret); |
| 52 | ret = qser_wifi_ap_mode_get(LYNQ_WIFI_AP_INDEX_AP0,&mode); //Gets the working protocol mode for wlan0 |
| 53 | printf("[lynq-wifi-demo] mode = %d ret = %d\n",mode, ret); |
| 54 | ret = qser_wifi_ap_auth_get(LYNQ_WIFI_AP_INDEX_AP0,&auth_mode,pw); //Get wlan0's password security authentication and password |
| 55 | printf("[lynq-wifi-demo] pw = %s auth_mode = %d ret = %d\n",pw, auth_mode, ret); |
| 56 | ret = qser_wifi_ap_channel_get(LYNQ_WIFI_AP_INDEX_AP0,country_code,&channel); //Get the country code and channel of wlan0 |
| 57 | printf("[lynq-wifi-demo] country_code = %s channel = %d ret = %d\n",country_code, channel, ret); |
| 58 | ret = qser_wifi_ap_bandwidth_get(LYNQ_WIFI_AP_INDEX_AP0,&bandwidth); //Gets the bandwidth of wlan0 |
| 59 | printf("[lynq-wifi-demo] bandwidth = %d ret = %d\n",bandwidth, ret); |
| 60 | } |
| 61 | else{ |
| 62 | printf(" [lynq-wifi-demo]Parameter error, please re-enter\n"); |
| 63 | } |
| 64 | } |
| 65 | else |
| 66 | { |
| 67 | printf("[lynq-wifi-demo]Please enter one of the parameters 0,1,2\n"); |
| 68 | printf(" [lynq-wifi-demo]2: View information such as ssid, password, and channel in ap mode\n"); |
| 69 | printf(" [lynq-wifi-demo]1: initializes wifi and enables and sets ap mode\n"); |
| 70 | printf(" [lynq-wifi-demo]0: indicates off.\n"); |
| 71 | return 0; |
| 72 | } |
| 73 | |
| 74 | return 0; |
| 75 | } |
| 76 | |