-
Notifications
You must be signed in to change notification settings - Fork 42
/
xbee-init
49 lines (44 loc) · 857 Bytes
/
xbee-init
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
#!/bin/sh
# Linux GPIOs on XBee lines
XBEE_RESET_N_GPIO="##XBEE_RESET_N_GPIO##"
XBEE_SLEEP_RQ_GPIO="##XBEE_SLEEP_RQ_GPIO##"
xbee_init() {
# Set low XBEE_SLEEP_RQ
gpioset ${3} ${4}=0
# Power cycle XBEE_RESET_N
gpioset ${1} ${2}=0
gpioset ${1} ${2}=1
}
xbee_iterate_list() {
i=0
for RESET in $(echo ${XBEE_RESET_N_GPIO} | sed "s/,/ /g"); do
j=0
for SLEEP in $(echo ${XBEE_SLEEP_RQ_GPIO} | sed "s/,/ /g"); do
if [ "${i}" = "${j}" ]; then
if [ "${1}" = "start" ]; then
xbee_init $(echo ${RESET} | sed "s/@/ /g") $(echo ${SLEEP} | sed "s/@/ /g")
fi
fi
j="$((j + 1))"
done
i="$((i + 1))"
done
}
case "$1" in
start)
echo -n "Starting XBee hardware: "
xbee_iterate_list start
echo "done."
;;
stop)
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac