-
-
Notifications
You must be signed in to change notification settings - Fork 152
/
gammu-config
executable file
·357 lines (323 loc) · 11.2 KB
/
gammu-config
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
#!/bin/bash
# Gammu configuration generator
# Copyright (C) 2003 - 2009 Michal Cihar <michal@cihar.com>
# vim: expandtab sw=4 ts=4 sts=4:
DIALOG_SIZE="8 70"
MENU_SIZE="0 0 0"
INPUT_SIZE="0 0"
FILE_SIZE="20 60"
CONFIG=~/.gammurc
NAME="Gammu configurator"
VERSION="0.4"
COPYRIGHT="Copyright (C) 2003 - 2009 Michal Cihar <michal@cihar.com>"
FORCE=0
# Some defaults:
D_PORT=/dev/mobile
D_MODEL=
D_CONNECTION=at19200
D_SYNCHRONIZETIME=yes
D_LOGFILE=
D_LOGFORMAT=nothing
D_LOCKING=
D_GAMMULOC=
TEMPFILE=`mktemp /tmp/gammu-config.XXXXXXXXXX`
showhelp() {
echo "$NAME $VERSION"
echo "$COPYRIGHT"
echo
echo "Usage: `basename $0` [-f|--force] [-c|--config config]"
echo
exit 100
}
cfgread() {
grep '^[[:space:]]*'$1'[[:space:]]*=' "$CONFIG"| sed 's/^[^=]*=[[:space:]]*\([^#;]*\)[#;]\?.*$/\1/'
}
while [ "$#" -ge 1 ] ; do
case "$1" in
-f|--force)
FORCE=1
;;
-c|--config)
if [ "x$2" != "x" ] ; then
CONFIG="$2"
shift
else
showhelp
fi
;;
*)
showhelp
;;
esac
shift
done
if type dialog > /dev/null 2>&1 ; then
DIALOG=dialog
elif type cdialog > /dev/null 2>&1 ; then
DIALOG=cdialog
elif type whiptail > /dev/null 2>&1 ; then
DIALOG=whiptail
else
echo "You need dialog, cdialog or whiptail installed to make this work"
exit 1
fi
if [ -f "$CONFIG" ] ; then
if [ ! -w "$CONFIG" ] ; then
$DIALOG --msgbox "Configuration file \"$CONFIG\" is not writable!" $DIALOG_SIZE
exit 2
fi
if [ $FORCE -ne 1 ] ; then
$DIALOG --yesno "Configuration file \"$CONFIG\" exists.\nDo you still wish to configure Gammu?" $DIALOG_SIZE
if [ $? -eq 1 ] ; then
exit 0
fi
fi
$DIALOG --yesno "Configuration file \"$CONFIG\" exists.\nDo you wish to read defaults from it?" $DIALOG_SIZE
if [ $? -eq 0 ] ; then
echo "Parsing current Gammu configuration form \"$CONFIG\""
PORT=`cfgread port`
MODEL=`cfgread model`
CONNECTION=`cfgread connection`
SYNCHRONIZETIME=`cfgread synchronizetime`
LOGFILE=`cfgread logfile`
LOGFORMAT=`cfgread logformat`
LOCKING=`cfgread use_locking`
GAMMULOC=`cfgread gammuloc`
fi
fi
mainmenu() {
if [ $DIALOG = dialog ] ; then
EXTRA="--help-button --ok-label Edit --cancel-label Exit --extra-button --extra-label Save"
EXTRA_MENU=""
else
EXTRA=""
EXTRA_MENU="H Help S Save"
fi
$DIALOG $EXTRA --menu "Current Gammu configuration" $MENU_SIZE \
P "Port (${PORT:-$D_PORT})" \
C "Connection (${CONNECTION:-$D_CONNECTION})" \
M "Model (${MODEL:-$D_MODEL})" \
D "Synchronize time (${SYNCHRONIZETIME:-$D_SYNCHRONIZETIME})" \
F "Log file (${LOGFILE:-$D_LOGFILE})" \
O "Log format (${LOGFORMAT:-$D_LOGFORMAT})" \
L "Use locking (${LOCKING:-$D_LOCKING})" \
G "Gammu localisation (${GAMMULOC:-$D_GAMMULOC})" \
$EXTRA_MENU \
2>"$TEMPFILE"
BUTTON=$?
ITEM=`cat "$TEMPFILE"`
if [ "$DIALOG" = whiptail -a "$BUTTON" = 0 ] ; then
if [ "$ITEM" = H ] ; then
BUTTON=2
elif [ "$ITEM" = S ] ; then
BUTTON=3
fi
fi
}
editP() {
if [ $DIALOG = dialog ] ; then
$DIALOG --fselect "${PORT:-$D_PORT}" $FILE_SIZE 2>"$TEMPFILE"
err=$?
else
err=255
fi
if [ $err -eq 255 ] ; then
if $DIALOG --inputbox "Enter phone port" $INPUT_SIZE "${PORT:-$D_PORT}" 2>"$TEMPFILE" ; then
PORT=`cat "$TEMPFILE"`
fi
elif [ $err -eq 0 ] ; then
PORT=`cat "$TEMPFILE"`
fi
}
helpwin() {
$DIALOG --textbox /proc/self/fd/5 0 0 5<< EOT
# Port : in Windows/DOS: "com*:",
# (instead of "*" please put "1", "2", etc.)
# in other (Linux/Unix) "/dev/ttyS%"
# or "/dev/ircomm%" ("irda" connection)
# (instead of "%" please put "0", "1", "2", etc.)
# Model : use only, when Gammu doesn't recognize your phone model.
# Put it here. Example values: "6110", "6150", "6210", "8210"
# Connection : type of connection. Use "fbus" or "mbus" or "dlr3" or
# "irda" (Infrared over sockets) or "infrared" (DirectIR)
# or "at19200" (AT commands on 19200, 8 bits, None parity,
# 1 stop bit, no flow control) or "at115200" (AT commands on
# 115200, 8 bits, None parity, 1 stop bit, no flow control)
# or "atblue" (AT over BlueTooth) or "dlr3blue" (FBUS
# over BlueTooth)
# SynchronizeTime: if you want to set time from computer to phone during
# starting connection. Do not rather use this option when want
# to reset phone during connection (in some phones need to
# set time again after restart)
# Logfile : Use, when want to have logfile from communication.
# Logformat : What debug info and format should be used:
# "nothing" - no debug level, "text" - transmission dump in
# text format, "textall" - all possible info in text format,
# "errors" - errors in text format, "binary" - transmission
# dump in binary format
# Use_Locking : under Unix/Linux use "yes", if want to lock used device
# to prevent using it by other applications
# GammuLoc : name of localisation file
EOT
}
editgeneral() {
TITLE="$1"
VAR="$2"
shift
shift
if ( $DIALOG --menu "$TITLE" $MENU_SIZE "$@" 2>"$TEMPFILE" ) ; then
VALUE=`cat "$TEMPFILE"`
eval "$VAR='$VALUE'"
fi
}
editC() {
editgeneral "Select your phone connection" CONNECTION \
at "" \
at19200 "" \
at115200 "" \
fbus "" \
fbus-nodtr "" \
fbusirda "" \
fbusdlr3 "" \
fbusdku5 "" \
mbus "" \
irdaphonet "" \
irdaat "" \
irdaobex "" \
dku2phonet "" \
dku5fbus2 "" \
dku5fbus2-nodtr "" \
bluerffbus "" \
bluerfphonet "" \
bluephonet "" \
bluerfat "" \
blueat "" \
phonetblue "" \
fbusblue "" \
fbuspl2303 "" \
}
editM() {
editgeneral "Select your phone model" MODEL \
"" "Automatic detection (use this if unsure)" \
at "AT Generic phones" \
alcatel "Alcatel BE5 (501,701)" \
7110 "Nokia 6210|6250|7110|7190" \
9210 "Nokia 9210" \
6110 "Nokia 3210|33x0|3410|51x0|5210|5510|61x0|82x0|88x0" \
6510 "Nokia 3510|6310|6310i|6510|8310|8910" \
NAUTO "Nokia with autodetection"
}
editD() {
editgeneral "Synchronize time with PC on each connect?" SYNCHRONIZETIME \
yes "" \
no ""
}
editF() {
if [ $DIALOG = dialog ] ; then
$DIALOG --fselect "${LOGFILE:-$D_LOGFILE}" $FILE_SIZE 2>"$TEMPFILE"
err=$?
else
err=255
fi
if [ $err = 255 ] ; then
if ( $DIALOG --inputbox "Enter log file" $INPUT_SIZE "${LOGFILE:-$D_LOG_FILE}" 2>"$TEMPFILE" ) ; then
LOGFILE=`cat "$TEMPFILE"`
fi
elif [ $err = 0] ; then
LOGFILE=`cat "$TEMPFILE"`
fi
}
editO() {
editgeneral "Select log format" LOGFORMAT \
nothing "no debug level" \
text "transmission dump in text format" \
textdate "transmission dump in text format with date" \
textall "all possible info in text format" \
textalldate "all possible info in text format with date" \
errors "errors in text format" \
errorsdate "errors in text format with date" \
binary "transmission dump in binary format"
}
editL() {
editgeneral "Use device locking?" LOCKING \
yes "" \
no ""
}
editG() {
if [ $DIALOG = dialog ] ; then
$DIALOG --fselect "${GAMMULOC:-${D_GAMMULOC:-/}}" $FILE_SIZE 2>"$TEMPFILE"
err=$?
else
err=255
fi
if [ $err = 255 ] ; then
if ( $DIALOG --inputbox "Enter localisation file" $INPUT_SIZE "${GAMMULOC:-${D_GAMMULOC:-/}}" 2>"$TEMPFILE" ) ; then
LOGFILE=`cat "$TEMPFILE"`
fi
elif [ $err = 0] ; then
LOGFILE=`cat "$TEMPFILE"`
fi
}
mainmenu
while [ $BUTTON -eq 0 -o $BUTTON -eq 2 ] ; do
if [ $BUTTON -eq 2 ] ; then
helpwin
else
edit$ITEM
fi
mainmenu
done
if [ $BUTTON -eq 3 ] ; then
if [ -f "$CONFIG" -a $FORCE -ne 1 ] ; then
$DIALOG --yesno "Do you really wish to overwrite file \"$CONFIG\", with selected Gammu configuration?" $DIALOG_SIZE
if [ $? -eq 1 ] ; then
exit 0
fi
fi
echo save
cat > "$CONFIG" << EOT
# This is a generated gammurc file.
# It was generated by $NAME $VERSION
# In Unix/Linux : copy it into your home directory and name it .gammurc
# or into /etc and name it gammurc
# In Win32 : copy it into directory with Gammu.exe and name gammurc
# Port : in Windows/DOS: "com*:",
# (instead of "*" please put "1", "2", etc.)
# in other (Linux/Unix) "/dev/ttyS%"
# or "/dev/ircomm%" ("irda" connection)
# (instead of "%" please put "0", "1", "2", etc.)
# Model : use only, when Gammu doesn't recognize your phone model.
# Put it here. Example values: "6110", "6150", "6210", "8210"
# Connection : type of connection. Use "fbus" or "mbus" or "dlr3" or
# "irda" (Infrared over sockets) or "infrared" (DirectIR)
# or "at19200" (AT commands on 19200, 8 bits, None parity,
# 1 stop bit, no flow control) or "at115200" (AT commands on
# 115200, 8 bits, None parity, 1 stop bit, no flow control)
# or "atblue" (AT over BlueTooth) or "dlr3blue" (FBUS
# over BlueTooth)
# SynchronizeTime: if you want to set time from computer to phone during
# starting connection. Do not rather use this option when want
# to reset phone during connection (in some phones need to
# set time again after restart)
# Logfile : Use, when want to have logfile from communication.
# Logformat : What debug info and format should be used:
# "nothing" - no debug level, "text" - transmission dump in
# text format, "textall" - all possible info in text format,
# "errors" - errors in text format, "binary" - transmission
# dump in binary format
# Use_Locking : under Unix/Linux use "yes", if want to lock used device
# to prevent using it by other applications
# GammuLoc : name of localisation file
[gammu]
port = ${PORT:-$D_PORT}
model = ${MODEL:-$D_MODEL}
connection = ${CONNECTION:-$D_CONNECTION}
synchronizetime = ${SYNCHRONIZETIME:-$D_SYNCHRONIZETIME}
logfile = ${LOGFILE:-$D_LOGFILE}
logformat = ${LOGFORMAT:-$D_LOGFORMAT}
use_locking = ${LOCKING:-$D_LOCKING}
gammuloc = ${GAMMULOC:-$D_GAMMULOC}
EOT
$DIALOG --msgbox "Configuration saved to \"$CONFIG\"" $DIALOG_SIZE
fi
rm -f "$TEMPFILE"