4 # http://www.jankratochvil.net/project/line9k/
5 # Modem / Nokia 9110 incoming GSM data gate
7 # /etc/ppp/chap-secrets:
8 # Secrets for authentication using CHAP
9 # client server secret IP addresses
10 # username1a line9k secret1a 192.168.90.11
11 # username1b line9k secret1b 192.168.90.11
12 # username2 linecr secret2 192.168.90.12
15 # l9:2345:respawn:/usr/local/sbin/line9k line9k
16 # lc:2345:respawn:/usr/local/sbin/line9k linecr
20 # RS232 DTR------|>|------ --------------+-------------- ----AC conn.
26 # RS232 GND----|______|--- ----PS/2 +5V PS/2 GND-+-- ----AC conn.
27 # RELSIA05-500 RAS-0515
29 # Manual charge control:
30 # /usr/local/sbin/line9k charge on # Force charging on
31 # /usr/local/sbin/line9k charge off # Automatic charging
32 # /usr/local/sbin/line9k charge # Query charging force
37 # Local IP address of setup pointtopoint interfaces
38 LOCAL_IP=192.168.90.10
40 # Nameserver for remote clients:
43 # Percent of battery where charging starts
46 # Charger control port
47 charge_ttyS=/dev/ttyS0
49 # Time in seconds to charge the battery after reaching 100% state
50 max_limit_time=$[3*60*60];
54 PORT=/dev/ttyS4 # 9110
56 # Local IP address of setup pointtopoint interfaces
57 REMOTE_IP=192.168.90.11
59 OPTIONS="-crtscts xonxoff asyncmap a0000"
60 # "server" field in /etc/ppp/chap-secrets
65 PORT=/dev/ttyS3 # Courier
67 REMOTE_IP=192.168.90.12
69 OPTIONS="crtscts asyncmap 0"
74 ##############################################################################
75 # Configuration section ends here.
76 ##############################################################################
81 echo -n "Charging force: "
82 if test -f $charge_ttyS.charge;then
89 if [ "$2" = on -o "$2" = yes ];then
91 touch $charge_ttyS.charge
93 elif [ "$2" = off -o "$2" = no ];then
95 rm -f $charge_ttyS.charge
98 stty -F $charge_ttyS -hup clocal $baud 2>/dev/null
99 [ -n "$2" ] && chargestate
103 echo "Unknown device: $device"
109 while [ $RINGS -gt 0 ];do
110 # FIXME: timeout is not reset after stray ring(s)
111 RINGSTR="$RINGSTR $RING1"
114 LOGGER="logger -i -t $device"
116 # Use single AT/OK after ATZ to set terminal speed for USRobotics Courier
117 exec pppd "$PORT" "$BAUD" modem lock $OPTIONS $LOCAL_IP:$REMOTE_IP ms-dns "$NS" \
127 ABORT "NO\sDIAL\sTONE"
131 while test $rc -eq 3; do
140 ABORT "+CBC: 0,100" \
142 '"`if $CHARGE;then echo "AT+CBC" NOTREACHED;fi`"' \
145 rc=$?; test $rc -eq 0 -o $rc -ge 4 || exit $rc;
147 charge_arr=(0 25 50 75 100);
148 charge_val=${charge_arr[$[$rc-4]]};
149 charge_force_le='$charge_force_le';
151 max_limit_time='$max_limit_time';
153 charge_ttyS='$charge_ttyS';
154 if test -f $charge_ttyS.charge;then
157 if test $baud = nocontrol;then
160 if test $charge_val -le $charge_force_le;then baud=9600;fi;
161 if test $charge_val -gt $charge_limit_gt;then
162 limit_date=$[`date +%s`];
163 if test $limit_date_last -eq 0;then
164 limit_date_last=$limit_date;
165 if test $baud -ne 0;then
166 '"$LOGGER"' "CHARGE state: full-stage charging entered";
169 if test $baud -ne 0 -a $[$limit_date-$limit_date_last] -gt $max_limit_time;then
170 '"$LOGGER"' "CHARGE state: full-stage charging terminated";
178 if test $charge_val_last -ne $charge_val -o $baud_last '!=' $baud;then
179 '"$LOGGER"' "CHARGE state: charge=$charge_val; baud=$baud";
181 charge_val_last=$charge_val;
183 if test $baud '!=' nocontrol;then
184 stty -F $charge_ttyS -hup clocal $baud 2>/dev/null;
192 rc=$?; test $rc -eq 0 -o $rc -eq 3 || exit $rc;
201 rc=$?; test $rc -eq 0 || exit $rc;
203 stty -F $charge_ttyS -hup clocal $baud 2>/dev/null;
205 -ccp nodefaultroute lcp-echo-interval 30 lcp-echo-failure 4 lcp-max-configure 30 -detach debug nologfd kdebug 255 \
206 require-chap -pap auth name $AUTH_NAME