diff --git a/scripts/sxmo_appmenu.sh b/scripts/sxmo_appmenu.sh index 9ae229b..6d5b019 100755 --- a/scripts/sxmo_appmenu.sh +++ b/scripts/sxmo_appmenu.sh @@ -10,6 +10,7 @@ programchoicesinit() { Apps ^ 0 ^ sxmo_appmenu.sh applications Volume ↑ ^ 1 ^ sxmo_vol.sh up Volume ↓ ^ 1 ^ sxmo_vol.sh down + Dialer ^ 1 ^ sxmo_phonecaller.exp dial Camera ^ 0 ^ sxmo_camera.sh Wifi ^ 0 ^ st -e "nmtui" System Config ^ 0 ^ sxmo_appmenu.sh control @@ -42,6 +43,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 Rotate ^ 1 ^ rotate Wifi ^ 0 ^ st -e "nmtui" Upgrade Pkgs ^ 0 ^ st -e sxmo_upgrade.sh diff --git a/scripts/sxmo_phonecaller.exp b/scripts/sxmo_phonecaller.exp new file mode 100755 index 0000000..be636fe --- /dev/null +++ b/scripts/sxmo_phonecaller.exp @@ -0,0 +1,82 @@ +#!/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]} +} diff --git a/scripts/sxmo_phoneinfo.exp b/scripts/sxmo_phoneinfo.exp new file mode 100755 index 0000000..450b0b7 --- /dev/null +++ b/scripts/sxmo_phoneinfo.exp @@ -0,0 +1,34 @@ +#!/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>" diff --git a/scripts/sxmo_phoneringwatcher.exp b/scripts/sxmo_phoneringwatcher.exp new file mode 100755 index 0000000..8ef6a2b --- /dev/null +++ b/scripts/sxmo_phoneringwatcher.exp @@ -0,0 +1,45 @@ +#!/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 +}