Initial pass on phone dialer/incoming/status functionality
This commit is contained in:
parent
ed09f2b8b3
commit
334c74ad39
4 changed files with 163 additions and 0 deletions
|
@ -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
|
||||
|
|
82
scripts/sxmo_phonecaller.exp
Executable file
82
scripts/sxmo_phonecaller.exp
Executable file
|
@ -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]}
|
||||
}
|
34
scripts/sxmo_phoneinfo.exp
Executable file
34
scripts/sxmo_phoneinfo.exp
Executable file
|
@ -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>"
|
45
scripts/sxmo_phoneringwatcher.exp
Executable file
45
scripts/sxmo_phoneringwatcher.exp
Executable file
|
@ -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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue