Various progess on calling & texting; reorganize scripts dirs by category

This commit is contained in:
Miles Alan 2020-04-04 23:55:45 -05:00
parent 334c74ad39
commit ae983ef8c8
35 changed files with 1002 additions and 221 deletions

View file

@ -20,4 +20,4 @@ RESULT="$(
[[ "CLOSE_MENU" == "$RESULT" ]] && exit 0
URL=$(echo "$RESULT" | awk -F " " '{print $NF}')
st -e mpv --ytdl-format='[height<420]' "$URL"
st -e mpv --ytdl-format='[height<420]' $@ "$URL"

View file

@ -1,5 +1,6 @@
#!/usr/bin/env sh
WIN=$(xdotool getwindowfocus)
INCOMINGCALL=$(cat /tmp/sxmo_incomingcall || echo NOCALL)
programchoicesinit() {
WMCLASS="${1:-$(xprop -id $(xdotool getactivewindow) | grep WM_CLASS | cut -d ' ' -f3-)}"
@ -8,9 +9,10 @@ programchoicesinit() {
CHOICES="$(echo "
Scripts ^ 0 ^ sxmo_appmenu.sh scripts
Apps ^ 0 ^ sxmo_appmenu.sh applications
Volume ↑ ^ 1 ^ sxmo_vol.sh up
Volume ↓ ^ 1 ^ sxmo_vol.sh down
Volume ↑ ^ 1 ^ sxmo_vol.sh up
Volume ↓ ^ 1 ^ sxmo_vol.sh down
Dialer ^ 1 ^ sxmo_phonecaller.exp dial
Texts ^ 0 ^ sxmo_readtexts.sh
Camera ^ 0 ^ sxmo_camera.sh
Wifi ^ 0 ^ st -e "nmtui"
System Config ^ 0 ^ sxmo_appmenu.sh control
@ -18,6 +20,11 @@ programchoicesinit() {
Close Menu ^ 0 ^ quit
")" && WINNAME=Sys
# E.g. for the system menu if there's an incoming call pop it on top of menu
echo "$INCOMINGCALL" | grep -v NOCALL && CHOICES="$(echo "
Pickup $INCOMINGCALL ^ 0 ^ sxmo_phonecaller.exp pickup $INCOMINGCALL
")""$CHOICES"
echo $WMCLASS | grep -i "applications" && CHOICES="$(echo "
Surf ^ 0 ^ surf
NetSurf ^ 0 ^ netsurf
@ -32,7 +39,7 @@ programchoicesinit() {
echo $WMCLASS | grep -i "scripts" && CHOICES="$(echo "
Timer ^ 0 ^ sxmo_timermenu.sh
Youtube ^ 0 ^ sxmo_youtube.sh
Youtube (Audio) ^ 0 ^ sxmo_youtube.sh
Youtube (Audio) ^ 0 ^ sxmo_youtube.sh --no-video
Weather ^ 0 ^ sxmo_weather.sh
RSS ^ 0 ^ sxmo_rss.sh
Close Menu ^ 0 ^ quit
@ -43,7 +50,7 @@ programchoicesinit() {
Volume ↓ ^ 1 ^ sxmo_vol.sh down
Brightesss ↑ ^ 1 ^ sxmo_brightness.sh up
Brightness ↓ ^ 1 ^ sxmo_brightness.sh down
Modem Info ^ 1 ^ sxmo_phoneinfo.exp
Modem Info ^ 1 ^ st -e 'mmcli -m 0 && read'
Rotate ^ 1 ^ rotate
Wifi ^ 0 ^ st -e "nmtui"
Upgrade Pkgs ^ 0 ^ st -e sxmo_upgrade.sh
@ -81,9 +88,9 @@ programchoicesinit() {
# St hotkeys
echo $WMCLASS | grep -i "sthotkeys" && CHOICES="$(echo "
Send Ctrl-C ^ 0 ^ key Ctrl+C
Send Ctrl-L ^ 0 ^ key Ctrl+L
Send Ctrl- ^ 0 ^ key Ctrl+L
Send Ctrl-C ^ 0 ^ key Ctrl+c
Send Ctrl-L ^ 0 ^ key Ctrl+l
Send Ctrl-D ^ 0 ^ key Ctrl+d
Close Menu ^ 0 ^ quit
")" && WINNAME=st
@ -135,14 +142,12 @@ key() {
}
quit() {
xset r off
exit 0
}
boot() {
DMENUIDX=0
PICKED=""
xset r on
pgrep -f sxmo_appmenu.sh | grep -Ev "^${$}$" | xargs kill -9
pkill -9 dmenu
}
@ -169,3 +174,4 @@ mainloop() {
boot
programchoicesinit $@
mainloop

View file

@ -73,9 +73,7 @@ function link_select() {
link_normalize $(xprop -id $SURF_WINDOW _SURF_URI | cut -d '"' -f 2)
}
xset r off
pidof svkbd-sxmo || svkbd-sxmo &
VAL="$(link_select)"
pkill svkbd-sxmo
xset r on
echo "$VAL"

View file

@ -6,8 +6,9 @@ which $BROWSER || export BROWSER=surf
xsetroot -mod 3 2 -fg '#000000' -bg '#888888'
conky -c /usr/share/sxmo/conky.conf -d
lisgd &
sxmo_statusbar.sh &
xset s off -dpms
xset r off
#xset r off
alsactl --file /usr/share/sxmo/default_alsa_sound.conf restore
exec dbus-run-session dwm 2> ~/.dwm.log

126
scripts/modem/sxmo_modemcall.sh Executable file
View file

@ -0,0 +1,126 @@
#!/usr/bin/env sh
err() {
echo $1 | dmenu -fn Terminus-20 -c -l 10
exit 1
}
toggleflag() {
TOGGLEFLAG=$1
shift
FLAGS="$@"
echo -- "$FLAGS" | grep -- "$TOGGLEFLAG" >&2 &&
NEWFLAGS="$(echo -- "$FLAGS" | sed "s/$TOGGLEFLAG//g")" ||
NEWFLAGS="$(echo -- "$FLAGS $TOGGLEFLAG")"
NEWFLAGS="$(echo -- "$NEWFLAGS" | sed "s/--//g; s/ / /g")"
sxmo_megiaudioroute $NEWFLAGS
echo -- $NEWFLAGS
}
dialmenu() {
NUMS=$(ls -1 ~/.sxmo || "")
NUMBER="$(
echo -e "$NUMS\nTest Number 804-222-1111" |
dmenu -l 10 -p Number -c -fn Terminus-20 |
awk -F' ' '{print $NF}' |
tr -d -
)"
echo "Attempting to dial: $NUMBER" >&2
VID=$(
sudo mmcli -m 0 --voice-create-call "number=$NUMBER" | grep -Eo Call/[0-9]+ | grep -oE [0-9]+
)
echo "Starting call with VID: $VID" >&2
echo "$(startcall $VID)"
}
startcall() {
VID=$1
sudo mmcli -m 0 -o $VID --start | grep "successfully started" || err "Couldn't start call!"
echo $VID
}
hangup() {
VID=$1
sudo mmcli -m 0 -o $VID --hangup
exit 1
}
incallmenu() {
DMENUIDX=0
VID="$1"
# E.g. Run once w/o -2, and then run once with -2
FLAGS="-e -m"
sxmo_megiaudioroute $FLAGS
FLAGS="$FLAGS -2"
sxmo_megiaudioroute $FLAGS
while true
do
echo -- "$FLAGS" | grep -- "-m" && TMUTE="Mute" || TMUTE="Unmute"
echo -- "$FLAGS" | grep -- "-z" && TECHO="Echomic Off" || TECHO="Echomic On"
echo -- "$FLAGS" | grep -- "-e" && TEARPIECE="Earpiece Off" || TEARPIECE="Earpiece On"
echo -- "$FLAGS" | grep -- "-h" && TLINEJACK="Linejack Off" || TLINEJACK="Linejack On"
echo -- "$FLAGS" | grep -- "-s" && TSPEAKER="Speakerphone Off" || TSPEAKER="Speakerphone On"
CHOICES="$(echo -ne '
Volume ↑ ^ sxmo_vol.sh up
Volume ↓ ^ sxmo_vol.sh down
TMUTE ^ FLAGS="$(toggleflag "-m" "$FLAGS")"
TECHO ^ FLAGS="$(toggleflag "-z" "$FLAGS")"
TEARPIECE ^ FLAGS="$(toggleflag "-e" "$FLAGS")"
TLINEJACK ^ FLAGS="$(toggleflag "-h" "$FLAGS")"
TSPEAKER ^ FLAGS="$(toggleflag "-s" "$FLAGS")"
DTMF Tones ^ dtmfmenu $VID
Hangup ^ hangup $VID
Lock Screen ^ hangup
' | sed "s/TMUTE/$TMUTE/;s/TECHO/$TECHO/;s/TEARPIECE/$TEARPIECE/;s/TLINEJACK/$TLINEJACK/;s/TSPEAKER/$TSPEAKER/"
)"
PICKED=$(
echo "$CHOICES" |
xargs -0 echo |
cut -d'^' -f1 |
sed '/^[[:space:]]*$/d' |
awk '{$1=$1};1' |
dmenu -idx $DMENUIDX -l 14 -c -fn "Terminus-30" -p "$VID"
)
CMD=$(echo "$CHOICES" | grep "$PICKED" | cut -d '^' -f2)
DMENUIDX=$(echo $(echo "$CHOICES" | grep -n "$PICKED" | cut -d ':' -f1) - 1 | bc)
eval $CMD
done
}
dtmfmenu() {
VID=$1
DMENUIDX=0
NUMS="0123456789*#ABCD"
while true
do
PICKED="$(
echo $NUMS | grep -o . | sed '1 iReturn to Call Menu' |
dmenu -l 20 -fn Terminus-20 -c -idx $DMENUIDX -p "DTMF Tone"
)"
DMENUIDX=$(echo $NUMS | grep -bo $PICKED | cut -d: -f1 | xargs -IN echo 2+N | bc)
echo $PICKED | grep "Return to Call Menu" && break
mmcli -m 0 -o $VID --send-dtmf="$PICKED"
done
}
dial() {
VID="$(dialmenu)"
incallmenu $VID
}
pickup() {
startcall $1
}
$@

View file

@ -0,0 +1,57 @@
#!/usr/bin/env sh
TIMEOUT=3
MODEM=$(mmcli -L | grep -o "Modem/[0-9]" | grep -o [0-9]$)
newcall() {
sxmo_setpineled green 1
echo "Incoming Call:"
INCOMINGNUMBER=$(
mmcli -m 0 --voice-list-calls -o 3 -K |
grep call.properties.number |
cut -d ':' -f 2
)
echo "Number: $INCOMINGNUMBER"
}
newtexts() {
sxmo_setpineled green 1
echo "New Texts:"
for i in $(echo -e "$1") ; do
DAT="$(mmcli -m 0 -s $i -K)"
TEXT="$(echo "$DAT" | grep sms.content.text | sed -E 's/^sms\.content\.text\s+:\s+//')"
NUM="$(echo "$DAT" | grep sms.content.number | sed -E 's/^sms\.content\.number\s+:\s+[+]?//')"
TIME="$(echo "$DAT" | grep sms.properties.timestamp | sed -E 's/^sms\.properties\.timestamp\s+:\s+//')"
TEXTSIZE="$(echo $TEXT | wc -c)"
mkdir -p ~/.sxmo/$NUM
echo -ne "$NUM at $TIME:\n$TEXT\n\n" >> ~/.sxmo/$NUM/sms.txt
echo -ne "$TIME\trecv_txt\t$NUM\t$TEXTSIZE chars\n" >> ~/.sxmo/$NUM/log.tsv
sudo mmcli -m $MODEM --messaging-delete-sms=$i
done
}
while true
do
sxmo_setpineled green 0
VOICECALLID="$(
mmcli -m 0 --voice-list-calls -a |
grep -Eo '[0-9]+ incoming \(ringing-in\)' |
grep -Eo '[0-9]+'
)"
TEXTIDS="$(
mmcli -m 0 --messaging-list-sms |
grep -Eo '/SMS/[0-9] \(received\)' |
grep -Eo '[0-9]+'
)"
echo VIDS $VOICECALLID
echo TIDS $TEXTIDS
echo "$VOICECALLID" | grep . && newcall "$VOICECALLID"
echo "$TEXTIDS" | grep . && newtexts "$TEXTIDS"
sleep $TIMEOUT
done

View file

@ -0,0 +1,53 @@
#!/usr/bin/env sh
EDITOR=vis
modem() {
mmcli -L | grep -o "Modem/[0-9]" | grep -o [0-9]$
}
editmsg() {
TMP="$(mktemp --suffix $1_msg)"
echo "$2" > "$TMP"
TEXT="$(st -e $EDITOR $TMP)"
cat $TMP
}
sendmsg() {
MODEM=$(modem)
SMSNO=$(
sudo mmcli -m $MODEM --messaging-create-sms="text='$2',number=$1" |
grep -o [0-9]*$
)
sudo mmcli -s ${SMSNO} --send
for i in $(mmcli -m $MODEM --messaging-list-sms | grep " (sent)" | cut -f5 -d' ') ; do
sudo mmcli -m $MODEM --messaging-delete-sms=$i
done
}
main() {
modem || st -e "echo Couldn't determine modem number - is modem online?"
# Prompt for number
NUMBER=$(
echo -e "Enter Number: \nCancel" |
dmenu -p "Number" -fn "Terminus-20" -l 10 -c
)
echo "$NUMBER" | grep -E "^Cancel$" && exit 1
# Compose first version of msg
TEXT="$(editmsg $NUMBER 'Enter text message here')"
while true
do
CHARS=$(echo "$TEXT" | wc -c)
CONFIRM=$(
echo -e "Message ($CHARS) to -> $NUMBER: ($TEXT)\nEdit\nSend\nCancel" |
dmenu -c -idx 1 -p "Confirm" -fn "Terminus-20" -l 10
)
echo "$CONFIRM" | grep -E "^Send$" && sendmsg "$NUMBER" "$TEXT" && exit 0
echo "$CONFIRM" | grep -E "^Cancel$" && exit 1
echo "$CONFIRM" | grep -E "^Edit$" && TEXT="$(editmsg "$NUMBER" "$TEXT")"
done
}
main

View file

@ -0,0 +1,145 @@
#!/usr/bin/expect -f
proc setup {} {
set timeout 5
exp_internal 1
set ::env(DISPLAY) :0
spawn sh -c "screen -rx dialer || screen -S dialer /dev/ttyUSB2 115200"
set modem_pid $spawn_id
sleep 0.2
send -i $modem_pid "AT+QDAI=1,0,0,2,0,1,1,1;\r"
expect {
-i $modem_pid "OK" { return $modem_pid }
}
puts "Couldn't establish connection to modem?"
exit
}
proc dialermenu {} {
# Prompt user for number to dial
spawn sh -c "pidof svkbd-sxmo || svkbd-sxmo"
spawn sh -c "
echo Test Number 804-222-1111 |
dmenu -l 10 -p Number -c -fn Terminus-20 |
awk -F' ' '{print \$NF}' |
tr -d -
"
wait
expect -re "(\\d+)"
return $expect_out(buffer)
}
proc call {modem_pid number} {
puts "Calling <$number>"
send -i $modem_pid "ATD$number;\r"
expect {
-i $modem_pid "OK" { incallmenu $modem_pid $number }
}
spawn sh -c "echo 'Failed to connect?' | dmenu -fn Terminus-20 -c"
wait
exit
}
proc lremove {l p} {
set p [lsearch -exact $l $p]
return "[lrange $l 0 $p-1] [lrange $l $p+1 end]"
}
proc iteminlist {l i} {
return [expr [lsearch -exact $l $i] >= 0]
}
proc applyaudiorouting {flags} {
puts "Applying audio routing flags: $flags"
spawn sxmo_megiaudioroute {*}$flags
wait
}
proc incallmenu {modem_pid number} {
# E.g. default earpiece to listen and mic to speak
set flags { -e -m }
applyaudiorouting $flags
lappend flags -2
applyaudiorouting $flags
while 1 {
set mutetext [expr {[iteminlist $flags -m] ? "Mute" : "Unmute"}]
set echotext [expr {[iteminlist $flags -z] ? "Echomic Off" : "Echomic On"}]
set earpiecetext [expr {[iteminlist $flags -e] ? "Earpiece Off" : "Earpiece On"}]
set headphonetext [expr {[iteminlist $flags -h] ? "Linejack Off" : "Linejack On"}]
set speakerphonetext [expr {[iteminlist $flags -s] ? "Speakerphone Off" : "Speakerphone On"}]
spawn sh -c "
echo -e '
Volume ↑
Volume ↓
$mutetext
$echotext
$earpiecetext
$headphonetext
$speakerphonetext
Windowify
Hangup
Lock Screen
Number Input
' | sed -r '/^\s*$/d' | awk '{\$1=\$1};1' | dmenu -c -fn Terminus-20 -l 10 -p '$number'
"
wait
expect {
"Mute" { set flags [lremove $flags -m]; applyaudiorouting $flags }
"Unmute" { lappend flags -m; applyaudiorouting $flags }
"Echomic Off" { set flags [lremove $flags -z]; applyaudiorouting $flags }
"Echomic On" { lappend flags -z; applyaudiorouting $flags }
"Earpiece Off" { set flags [lremove $flags -e]; applyaudiorouting $flags }
"Earpiece On" { lappend flags -e; applyaudiorouting $flags }
"Linejack Off" { set flags [lremove $flags -h]; applyaudiorouting $flags }
"Linejack On" { lappend flags -h; applyaudiorouting $flags }
"Speakerphone Off" { set flags [lremove $flags -s]; applyaudiorouting $flags }
"Speakerphone On" { lappend flags -s; applyaudiorouting $flags }
"Volume ↑" { spawn sxmo_vol.sh up }
"Volume ↓" { spawn sxmo_vol.sh down }
"Numberpad" { spawn sxmo_vol.sh down }
"Lock Screen" { spawn sxmo_screenlock; wait }
"Windowify" { spawn sxmo_phonecallerwindowify.tcl; wait }
"Hangup" { hangup $modem_pid }
}
}
}
proc hangup {modem_pid} {
spawn sxmo_megiaudioroute -h
send -i $modem_pid "ATH;\r"
expect {
-i $modem_pid "OK" exit
}
puts "Failed to hangup?"
exit
}
proc dial {modem_pid} {
puts "Dialer"
set number [dialermenu]
call $modem_pid $number
}
proc pickup {modem_pid number} {
spawn rm -f /tmp/sxmo_incomingcall
puts "Pickup"
send -i $modem_pid "ATA;\r"
expect {
-i $modem_pid "OK" { incallmenu $modem_pid $number }
}
puts "Failed to pickup?"
exit
}
switch [lindex $argv 0] {
"pickup" {pickup [setup] [lindex $argv 1]}
"dial" {dial [setup]}
}

View file

@ -0,0 +1,10 @@
#!/usr/bin/env tclsh
package require Tk
proc callwindowify {number} {
font create AppHighlightFont -size 40 -weight bold
grid [ttk::label .l -text "In Call with $number" -font AppHighlightFont]
grid [ttk::button .button -text "Return to Call Menu (unwindowify)" -command exit]
}
callwindowify [lindex $argv 0]

View file

@ -0,0 +1,107 @@
#!/usr/bin/expect -f
proc setup {} {
set timeout 1
exp_internal 0
log_user 0
set ::env(DISPLAY) :0
spawn sh -c "screen -wipe"
spawn sh -c "screen -rx dialer || screen -S dialer /dev/ttyUSB2 115200"
sleep 0.3
set modem_pid $spawn_id
sleep 0.2
# Set audio routing
messagemodem $modem_pid "AT+QDAI=1,0,0,2,0,1,1,1;\r" 1
# Setup text message to immediatly show text response on +CMT recvs
messagemodem $modem_pid "AT+CNMI=1,2,0,1,0;\r" 1
# Set message format as PDU
messagemodem $modem_pid "AT+CMGF=0;\r" 1
return $modem_pid
}
proc messagemodem {modem_pid message fatal} {
send -i $modem_pid $message
expect {
-i $modem_pid "OK" {
return 1
}
}
if {$fatal} {
puts "Couldn't run command on modem: $message"
exit
}
return 0
}
set modem_pid [setup]
sleep 0.2
# E.g. consume the thing
expect -i $modem_pid eof
proc writenumber {number} {
exec sh -c "echo '$number' > /tmp/sxmo_incomingcall"
puts "Ring for incoming call: <$number>"
spawn sxmo_setpineled blue 0
sleep 0.3
}
proc ring {modem_pid} {
send -i $modem_pid "AT+CLCC\r"
expect {
-i $modem_pid -re {\n\+CLCC: 4,.+\+(\d+)} { writenumber $expect_out(1,string) }
-i $modem_pid -re {\n\+CLCC: 3} { writenumber "UNKNOWN" }
}
}
proc textmsg {modem_pid pdutext} {
puts "New text msg - pdu text $pdutext"
spawn sxmo_pdudecode $pdutext
wait
expect -i $spawn_id -re {Date: ([\-0-9]+)\r\nNumber: \+?([^\n]+)\r\nMessage:\r\n(.+)$} { puts "Matched ok"; }
set date $expect_out(1,string)
set number $expect_out(2,string)
set msg [string trim $expect_out(3,string)]
puts "<date: $date>"
puts "<number: $number>"
puts "<msg: $msg>"
spawn date "+%Y/%m/%d %H:%M:%S" -d "@$date"
wait
expect
set prettydate [string trim $expect_out(buffer)]
set USER $::env(USER)
spawn mkdir -p "/home/$USER/.sxmo/$number"
wait
set fp "/home/$USER/.sxmo/$number/log.txt"
set logf [open $fp a]
puts $logf "$number at \[$prettydate\]:\n$msg\n"
close $logf
}
proc nocarrier {modem_pid} {
spawn sxmo_setpineled blue 0
exec sh -c "rm -f /tmp/sxmo_incomingcall"
puts "No carrier"
}
while 1 {
set is_ringing 0
set timeout 2
expect {
-i $modem_pid -re {\nRING\r} {ring $modem_pid; set is_ringing 1}
-i $modem_pid -re {\nNO CARRIER\r} {nocarrier $modem_pid; set is_ringing 0}
-i $modem_pid -re {\n\+CMT: \S+\r\n([0-9A-F]+)} {textmsg $modem_pid $expect_out(1,string)} }
if { $is_ringing } {
spawn sxmo_setpineled blue 1
} else {
spawn sxmo_setpineled blue 0
}
sleep 2
}

View file

@ -0,0 +1,8 @@
#!/usr/bin/env sh
DIR=/home/$USER/.sxmo
# Warn for no texts
ls -1 $DIR | wc -l | grep -E '^0$' && echo "No texts!" | dmenu -fn Terminus-20 -l 10 -c && exit 1
# Display
ls -1 $DIR | dmenu -p Messages -c -fn Terminus-20 -l 10 | xargs -INUMBER st -e tail -f $DIR/NUMBER/sms.txt

View file

@ -1,15 +0,0 @@
move() {
xdotool keydown Alt
echo "Move done?" | dmenu
xdotool keyup Alt
}
resize() {
xdotool keydown Alt
xdotool mousedown 3
echo "Resize done?" | dmenu
xdotool keyup Alt
xdotool mouseup 3
}
$@

View file

@ -1,82 +0,0 @@
#!/usr/bin/expect -f
proc setup {} {
set timeout 5
exp_internal 1
# Cleanup - set DISPLAY & if screen to modem already on, kill it
set ::env(DISPLAY) :0
#spawn screen -XS dialer quit
spawn sh -c "screen -rx dialer || screen -S dialer /dev/ttyUSB2 115200"
return $spawn_id
}
proc dialermenu {} {
# Prompt user for number to dial
spawn sh -c "pidof svkbd-sxmo || svkbd-sxmo"
spawn sh -c "
echo Test Number 804-222-1111 |
dmenu -l 10 -p Number -c -fn Terminus-20 |
awk -F' ' '{print \$NF}' |
tr -d -
"
wait
expect -re "(\\d+)"
return $expect_out(buffer)
}
proc call {modem_pid number} {
puts "Calling <$number>"
send -i $modem_pid "ATD$number;\r"
expect {
-i $modem_pid "OK" { incallmenu $modem_pid $number }
}
spawn sh -c "echo 'Failed to connect?' | dmenu -fn Terminus-20 -c"
wait
exit
}
proc incallmenu {modem_pid number} {
while 1 {
spawn sh -c "
echo -e '
Mute
Hangup
Lock Screen
Number Input
' | sed -r '/^\s*$/d' | awk '{\$1=\$1};1' | dmenu -c -fn Terminus-20 -l 10 -p '$number'
"
wait
expect {
"Mute" mute
"Volume ↑" { spawn sxmo_vol.sh up }
"Volume ↓" { spawn sxmo_vol.sh down }
"Numberpad" { spawn sxmo_vol.sh down }
"Unmute" unmute
"Hangup" { hangup $modem_pid }
}
}
}
proc hangup {modem_pid} {
send -i $modem_pid "ATH;\r"
expect {
-i $modem_pid "OK" exit
}
puts "Failed to hangup?"
exit
}
proc dial {modem_pid} {
puts "Dialer"
set number [dialermenu]
call $modem_pid $number
}
proc pickup {modem_pid} {
puts "Pickup"
}
switch [lindex $argv 0] {
"pickup" {pickup [setup]}
"dial" {dial [setup]}
}

View file

@ -1,34 +0,0 @@
#!/usr/bin/expect -f
proc setup {} {
set timeout 5
#exp_internal 1
log_user 0
set ::env(DISPLAY) :0
spawn sh -c "screen -wipe"
spawn sh -c "screen -rx dialer || screen -S dialer /dev/ttyUSB2 115200"
return $spawn_id
}
set modem_pid [setup]
sleep 0.2
send -i $modem_pid "AT+CNUM\r"
expect -i $modem_pid -re {\n\+CNUM: ([^\r]+)\r}
set f $expect_out(1,string)
puts "My number: <$f>"
send -i $modem_pid "AT+CSQ\r"
expect -i $modem_pid -re {\n\+CSQ: ([^\r]+)\r}
set f $expect_out(1,string)
puts "Modem signal strength: <$f>"
send -i $modem_pid "AT+QCCID\r"
expect -i $modem_pid -re {\n\+QCCID: ([^\r]+)\r}
set f $expect_out(1,string)
puts "ICCID: <$f>"
send -i $modem_pid "AT+QNWINFO\r"
expect -i $modem_pid -re {\n\+QNWINFO: ([^\r]+)\r}
set f $expect_out(1,string)
puts "Network Info: <$f>"

View file

@ -1,45 +0,0 @@
#!/usr/bin/expect -f
proc setup {} {
set timeout 1
exp_internal 0
log_user 0
set ::env(DISPLAY) :0
spawn sh -c "screen -wipe"
spawn sh -c "screen -rx dialer || screen -S dialer /dev/ttyUSB2 115200"
#spawn dialerscreen.sh
#spawn sh -c "screen -S dialer /dev/ttyUSB2 115200"
return $spawn_id
}
set modem_pid [setup]
sleep 0.2
# E.g. consume the thing
expect -i $modem_pid eof
proc ring {modem_pid} {
puts "Ringing"
send -i $modem_pid "AT+CLCC\r"
expect -i $modem_pid -re {\n\+CLCC: 3,([^\r]+)\r}
set f $expect_out(1,string)
puts "Modem signal strength: <$f>"
}
proc nocarrier {modem_pid} {
puts "No carrier"
}
while 1 {
set is_ringing 0
set timeout 2
#send -i $modem_pid "AT+CPAS\r"
expect {
-i $modem_pid -re {\nRING\r} {ring $modem_pid}
-i $modem_pid -re {\nNO CARRIER\r} {nocarrier $modem_pid}
}
#set status $expect_out(1,string)
#puts "My number: <$status>"
sleep 2
}