X-Git-Url: http://git.rot13.org/?p=huawei.git;a=blobdiff_plain;f=at-chat.pl;h=a9a8756563627f7f01a960c9b9434d43ed22514d;hp=7157a30559d8198da1b9fa5e07c6ac05dd2c40c8;hb=a9d46f9399516b6a48cb12bffd812024a802a264;hpb=86f97ad79d997e1846fd5c567f13697b369789cf diff --git a/at-chat.pl b/at-chat.pl index 7157a30..a9a8756 100755 --- a/at-chat.pl +++ b/at-chat.pl @@ -5,7 +5,7 @@ use strict; use Device::SerialPort; use Data::Dump qw(dump); -my $device = $ENV{DEVICE} || '/dev/ttyUSB0'; +my $device = $ENV{DEVICE} || shift @ARGV || '/dev/ttyUSB0'; my $port = Device::SerialPort->new( $device ) || die "$device: $!"; $port->baudrate(115200) || die "fail $device baudrate"; @@ -35,7 +35,9 @@ sub c { print STDERR ">>> $cmd >>> $message\n"; $port->write("$cmd\r"); # $port->write_done(1); # flush - $port->write_drain; +# $port->write_drain; + $port->read( length($cmd) + 1 ); # slurp echo + my $ret = $port->read(1); again: while ( my $c = $port->input ) { @@ -49,12 +51,14 @@ again: return $ret; } -c 'ATE0' => 'echo off'; -#c 'ATZ' => 'reset'; -# +#c 'ATE0' => 'echo off'; +c 'ATZ' => 'reset'; + c 'ATI' => 'info'; -c 'AT+CGMI' => 'manufacturer'; +c 'AT+CPIN?' => 'SIM pin'; + +my $manufacturer = c 'AT+CGMI' => 'manufacturer'; c 'AT+CGMM' => 'model'; @@ -72,6 +76,10 @@ c 'AT+CNUM' => 'MSISDN'; c 'AT+CLCK=?' => 'facility lock'; +if ( $manufacturer =~ m/Huawei/i ) { + +print "# Huawei\n"; + c 'AT^HWVER' => 'hardware version'; c 'AT^CVOICE?' => 'is voice enabled?'; @@ -80,6 +88,17 @@ c 'AT^DDSETEX=?' => 'voice output'; c 'AT^SYSINFO' => 'sys info'; +} elsif ( $manufacturer =~ m/ZTE/i ) { + +print "# ZTE\n"; + +c 'AT+GMR' => 'revision'; + +c 'AT+GCI?' => '?'; + +c 'AT+ZOPRT?' => '?'; + +} $port->close || die "can't close port $!";