-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathquectel-onoff.sh
executable file
·96 lines (81 loc) · 1.49 KB
/
quectel-onoff.sh
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
#!/bin/bash
source /opt/EMSTS/scripts/bbb/gpio
PIN_LTE5V_EN=216 # LTE_BUF_OE
PIN_LTEVBAT_EN=19
PIN_W_DISABLE=194
PIN_PWRKEY=15
PIN_RESET=13 # High reset
PIN_WAKEUP_IN=50
PIN_ANTENNA=232 # VDD_ANT_GNSS_EN
PIN_AP_READY=14
PIN_LTE_STATUS=72
MODEM_TTY="/dev/ttyUSB3"
function quectel_poweronoff() {
# Power
# disable LTE VBAT
# gpio clear $PIN_LTEVBAT_EN
# enable GNSS ANTENNA power
gpio clear $PIN_ANTENNA
# disable LTE 5V
gpio clear $PIN_LTE5V_EN
sleep 0.1
# enable LTE VBAT
#
# VBAT always powered in the circuit.
# gpio set $PIN_LTEVBAT_EN
sleep 0.1
# deassert RESET
gpio clear $PIN_RESET
# disable Airplane mode
gpio set $PIN_W_DISABLE
# stay in WAKEUP state
gpio clear $PIN_WAKEUP_IN
# Power On
gpio clear $PIN_PWRKEY
sleep 0.1
gpio set $PIN_PWRKEY
sleep 0.6
gpio clear $PIN_PWRKEY
sleep 0.1
# issue Sleep
# gpio set $PIN_WAKEUP_IN
# enable LTE 5V
gpio set $PIN_LTE5V_EN
}
quectel_poweronoff
gpio clear $PIN_AP_READY
sleep 1
is_on=0
if [ ! -c "$MODEM_TTY" ]; then
is_on=1
fi
: <<\COMMENT
for ((i = 0; i < 20; i++)); do
v=$(gpio input $PIN_LTE_STATUS)
if [ "$v" -eq "0" ]; then
is_on=1
break
fi
sleep 0.3
done
COMMENT
if [ "$is_on" -ne "0" ]; then
echo -ne "Power up LTE module"
for ((i = 0; i < 50; i++)); do
if [ -c "$MODEM_TTY" ]; then
break;
fi
sleep 0.5
echo -ne "."
done
echo "OK"
exit 0
fi
echo -ne "Power off LTE module"
# Wait the LTE module power down completely
for ((i = 0; i < 30; i++)); do
sleep 1
echo -ne "."
done
echo "OK"
exit 1