Delete dead tcl code

master
Miles Alan 5 years ago
parent 8ef3749b8b
commit fd286101d8
  1. 145
      scripts/modem/sxmo_phonecaller.exp
  2. 10
      scripts/modem/sxmo_phonecallerwindowify.tcl
  3. 107
      scripts/modem/sxmo_phoneringwatcher.exp

@ -1,145 +0,0 @@
#!/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]}
}

@ -1,10 +0,0 @@
#!/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]

@ -1,107 +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"
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
}
Loading…
Cancel
Save