-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patholed_contorl
executable file
·172 lines (157 loc) · 4.33 KB
/
oled_contorl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#!/bin/sh
print_err()
{
echo "Usage: oled_contorl <option> <contorl> ..."
echo " <Option>: <contorl>:"
echo " base_page on/off Enable or disable Basic information page"
echo " wifi_2g on/off Enable or disable 2Gwifi page"
echo " wifi_5g on/off Enable or disable 5Gwifi page"
echo " lan_ip on/off Enable or disable IP addresses page"
echo " vpn_status on/off Enable or disable VPN_status page"
echo " wifi_password on/off Enable or disable wifi_password page"
echo " custom on/off <custom_info> Display custom information"
echo " version read Read mcu version"
echo " mcu_status read Read battery information and temperature"
}
if [ "$#" -lt 1 ]; then
print_err
exit 0
fi
page=$1
contorl=$2
if [ "$contorl" == "help" ];then
print_err
exit 0
fi
custom_info=$3
base_page_contorl()
{
if [ "$contorl" == "on" ];then
uci set mcu.global.main_enabled='1'
elif [ "$contorl" == "off" ];then
uci set mcu.global.main_enabled='0'
else
print_err
fi
}
wifi_2g_contorl()
{
if [ "$contorl" == "on" ];then
uci set mcu.global.wifi_2g_enabled='1'
elif [ "$contorl" == "off" ];then
uci set mcu.global.wifi_2g_enabled='0'
else
print_err
fi
}
wifi_5g_contorl()
{
if [ "$contorl" == "on" ];then
uci set mcu.global.wifi_5g_enabled='1'
elif [ "$contorl" == "off" ];then
uci set mcu.global.wifi_5g_enabled='0'
else
print_err
fi
}
lan_ip_contorl()
{
if [ "$contorl" == "on" ];then
uci set mcu.global.lan_enabled='1'
elif [ "$contorl" == "off" ];then
uci set mcu.global.lan_enabled='0'
else
print_err
fi
}
vpn_status_contorl()
{
if [ "$contorl" == "on" ];then
uci set mcu.global.vpn_enabled='1'
elif [ "$contorl" == "off" ];then
uci set mcu.global.vpn_enabled='0'
else
print_err
fi
}
wifi_password_contorl()
{
if [ "$contorl" == "on" ];then
uci set mcu.global.wifi_password_enabled='1'
elif [ "$contorl" == "off" ];then
uci set mcu.global.wifi_password_enabled='0'
else
print_err
fi
}
custom_contorl()
{
if [ "$contorl" == "on" ];then
local info="$custom_info"
if [ -z "$info"];then
print_err
fi
uci set mcu.global.custom_enabled='1'
uci set mcu.global.content="$info"
elif [ "$contorl" == "off" ];then
uci set mcu.global.wifi_password_enabled='0'
else
print_err
fi
}
version_read()
{
if [ "$contorl" == "read" ];then
local ver="$(ubus call mcu version | grep version | cut -d ':' -f2 | tr -d '"')"
echo "$ver"
else
print_err
fi
}
mcu_status_read()
{
if [ "$contorl" == "read" ];then
local res="$(ubus call mcu status)"
local capacity="$(echo $res | awk -F "," '{print $1}' | grep charge_percent | cut -d ':' -f2 | tr -d '"')"
local temp="$(echo $res | awk -F "," '{print $2}' | grep temperature | cut -d ':' -f2 | tr -d '"')"
local chg_state="$(echo $res | awk -F "," '{print $3}' | grep charge_cnt | cut -d ':' -f2 | tr -d '"')"
local charge_cycle="$(echo $res | awk -F "," '{print $4}' | grep charging_status | cut -d ':' -f2 | tr -d '"')"
echo "Battery_capacity=$capacity,temperature=$temp,Charging_state=$chg_state,Charging_cycle=$chg_state"
else
print_err
fi
}
case "$page" in
"base_page")
base_page_contorl
;;
"wifi_2g")
wifi_2g_contorl
;;
"wifi_5g")
wifi_5g_contorl
;;
"lan_ip")
lan_ip_contorl
;;
"vpn_status")
vpn_status_contorl
;;
"wifi_password")
wifi_password_contorl
;;
"custom")
custom_contorl
;;
"version")
version_read
;;
"mcu_status")
mcu_status_read
;;
*)
print_err
;;
esac
uci commit mcu
ubus call mcu reload