Ticket #1003: atpoff

File atpoff, 1.0 KB (added by mwester@…, 11 years ago)

/etc/rc0.d/K36atpoff

Line 
1#!/bin/sh
2#
3# atpoff - issues the power-off command to the GTA01 GSM modem
4
5PATH=/bin:/usr/bin:/sbin:/usr/sbin
6
7[ -f /etc/default/rcS ] && . /etc/default/rcS
8[ -f /etc/default/gsmd ] && . /etc/default/gsmd
9
10# Silently exit if this is not a GTA01 device
11[ -n "$GSM_DEV" ] || exit
12
13case "$1" in
14    start)
15        # Do nothing if starting; gsmd will do that.
16    ;;
17
18    stop)
19        echo -n "Stopping GSM modem: "
20
21        # Reset the modem to return it to a known state.
22        stty -F "$GSM_DEV" -crtscts
23        [ -n "$GSM_POW" ] && echo "0" >$GSM_POW
24        stty -F "$GSM_DEV" -echo
25        [ -n "$GSM_POW" ] && echo "1" >$GSM_POW
26        stty -F "$GSM_DEV" crtscts
27
28        # Send the command to power off, after waiting for the
29        # modem to be ready.
30        sleep 1
31        echo -e "AT@POFF\r" >$GSM_DEV
32
33        # Switch the serial port back to the console - carefully!
34        sleep 1
35        stty -F "$GSM_DEV" -crtscts
36        [ -n "$GSM_POW" ] && echo "0" >$GSM_POW
37
38        ;;
39    *)
40        echo "Usage: /etc/init.d/atpoff {start|stop}"
41        exit 1
42        ;;
43esac
44
45exit 0