天嵌二次封装库使用手册  V2.1.2
lib_wifi.h
浏览该文件的文档.
1 
7 #ifndef LINUX_LIBV2_SOURCE_WIFI_LIB_WIFI_H_
8 #define LINUX_LIBV2_SOURCE_WIFI_LIB_WIFI_H_
9 
10 // Copyright 2024
11 
12 #include "wpa_ctrl.h"
13 #include <net/if.h>
14 #include <sys/ioctl.h>
15 #include <netinet/in.h>
16 // const int IP_SIZE = 16; ///< IP地址长度
17 
18 #ifdef __cplusplus
19 #define WIFI_API extern "C"
20 #else
21 #define WIFI_API
22 #endif
23 
27  struct WIFI
28  {
29  /* data */
30  char *ssid;
31  char *bssid;
32  int frequency;
34  char *flag;
35  };
42  WIFI_API struct WIFI *init_wifi();
47  WIFI_API void release_wifi(struct WIFI *wifi);
58  WIFI_API int Extract_information(char *src, char *dest, char *key, int dest_size);
68  WIFI_API int send_command(struct wpa_ctrl *ctrl, char *cmd);
76  WIFI_API int scan(struct wpa_ctrl *ctrl);
86  WIFI_API int scan_result(struct wpa_ctrl *ctrl, struct WIFI *wifi, int index);
97  WIFI_API int connect_wifi(struct wpa_ctrl *ctrl, char *ssid, char *passwork);
108  WIFI_API int get_wifi_status_value(struct wpa_ctrl *ctrl, char *key, char *dest, int dest_size);
114  WIFI_API int get_wifi_rssi(struct wpa_ctrl *ctrl);
122  WIFI_API int disconnect_wifi(struct wpa_ctrl *ctrl);
130  WIFI_API int reconnect_wifi(struct wpa_ctrl *ctrl);
131 
132  WIFI_API void display_wifi(struct WIFI *wifi);
133 
134 #endif //LIB_WIFI_H
WIFI_API int get_wifi_status_value(struct wpa_ctrl *ctrl, char *key, char *dest, int dest_size)
通过"STATUS"指令,获取所需参数。
char * flag
标志位
Definition: lib_wifi.h:34
WIFI_API int disconnect_wifi(struct wpa_ctrl *ctrl)
关闭WIFI使能
用来存放一个WIFI的基本参数
Definition: lib_wifi.h:27
int frequency
频率
Definition: lib_wifi.h:32
WIFI_API int scan_result(struct wpa_ctrl *ctrl, struct WIFI *wifi, int index)
获取WIFI扫描结果
WIFI_API struct WIFI * init_wifi()
初始化WIFI结构体
WIFI_API int scan(struct wpa_ctrl *ctrl)
扫描WIFI列表
WIFI_API int reconnect_wifi(struct wpa_ctrl *ctrl)
开启WIFI使能
WIFI_API void display_wifi(struct WIFI *wifi)
WIFI_API int get_wifi_rssi(struct wpa_ctrl *ctrl)
获取已连接的wifi的信号强度
WIFI_API int connect_wifi(struct wpa_ctrl *ctrl, char *ssid, char *passwork)
连接wifi
WIFI_API int send_command(struct wpa_ctrl *ctrl, char *cmd)
用于发送只返回OK,FAIL的指令
WIFI_API int Extract_information(char *src, char *dest, char *key, int dest_size)
提取特定类型的字符串
控制接口库的内部结构
Definition: wpa_ctrl.h:38
int signalLevel
信号强度
Definition: lib_wifi.h:33
WIFI_API void release_wifi(struct WIFI *wifi)
释放WIFI指针
#define WIFI_API
Definition: lib_wifi.h:21
char * ssid
wifi名称
Definition: lib_wifi.h:30
char * bssid
MAC地址
Definition: lib_wifi.h:31