lvgl_t113
0.1
t113-s3 86盒的LVGL桌面时钟程序
载入中...
搜索中...
未找到
device
check_device_status.c
浏览该文件的文档.
1
18
#include "
check_device_status.h
"
19
#include <stdio.h>
20
30
int
check_wifi_state
(
char
*interface) {
31
FILE *fp;
32
char
operstate[10];
33
34
// 构建路径
35
char
path[50];
36
snprintf(path,
sizeof
(path),
"/sys/class/net/%s/operstate"
, interface);
37
38
// 打开文件读取操作状态
39
fp = fopen(path,
"r"
);
40
if
(fp == NULL) {
41
perror(
"Failed to open operstate file"
);
42
return
1;
43
}
44
45
// 读取状态
46
if
(fgets(operstate,
sizeof
(operstate), fp) != NULL) {
47
if
(strncmp(operstate,
"up"
, 2) == 0) {
48
printf(
"WiFi interface %s is up\n"
, interface);
49
fclose(fp);
50
return
0;
51
}
else
{
52
printf(
"WiFi interface %s is down\n"
, interface);
53
fclose(fp);
54
return
1;
55
}
56
}
else
{
57
printf(
"Failed to read WiFi state\n"
);
58
fclose(fp);
59
return
1;
60
}
61
62
fclose(fp);
63
return
1;
64
}
check_wifi_state
int check_wifi_state(char *interface)
检查WIFI的工作状态
定义
check_device_status.c:30
check_device_status.h
制作者
1.12.0