-
Notifications
You must be signed in to change notification settings - Fork 3
/
huawey_voice_call.pl
executable file
·90 lines (69 loc) · 1.69 KB
/
huawey_voice_call.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/perl
use IO::File;
my $number='+79814621397';
$number='+79114531517';
$OPT_I = "/dev/ttyUSB1"; $OPT_O = "/dev/ttyUSB2"; $PATH_WAV = "all-circuits-busy.wav";
open (SENDPORT, '+<', $OPT_O) or die "Can't open '$OPT_O': $!\n";
print SENDPORT "AT;\r";
print "SEND: AT;\n";
my $test=1;
while ( $test ) {
my $recive=<SENDPORT>;
print "RECIVE: [$recive]\n";
$test=0 if $recive=~/OK/;
}
print SENDPORT "AT^DDSETEX=2\r";
print "SEND: AT^DDSETEX=2\n";
$test=1;
while ( $test ) {
my $recive=<SENDPORT>;
print "RECIVE: [$recive]\n";
$test=0 if $recive=~/OK/;
}
print SENDPORT "ATD$number;\r";
print "SEND: ATD$number;\n";
$test=1;
while ( $test ) {
my $recive=<SENDPORT>;
print "RECIVE: [$recive]\n";
$test=0 if $recive=~/OK/;
}
$test=1;
while ( $test ) {
my $recive=<SENDPORT>;
print "RECIVE: [$recive]\n";
$test=0 if $recive=~/\^CONN:1,0/;
sleep 1;
}
print "GO GO GO\n";
print SENDPORT "AT^DDSETEX=2\r";
print "SEND: AT^DDSETEX=2\n";
$test=1;
while ( $test ) {
my $recive=<SENDPORT>;
print "RECIVE: [$recive]\n";
$test=0 if $recive=~/OK/;
}
#$test=1;
#while ( $test ) {
# my $recive=<SENDPORT>;
# print "RECIVE: [$recive]\n";
# #$test=0 if $recive=~/\^CONN:1,0/;
# sleep 1;
#}
close SENDPORT;
sleep 1;
open (SENDPORT_WAV, '+<', $OPT_I) or die "Can't open '$OPT_I': $!\n";
my $FILE = new IO::File "< $PATH_WAV" or die "Cannot open $PATH_WAV : $!";
binmode($FILE);
my $BUFER;
my $BUFLEN = 320;
seek($FILE,44,0);
while (read($FILE,$BUFER,$BUFLEN)) {
print SENDPORT_WAV $BUFER; sleep(0.2);
}
close SENDPORT_WAV;
sleep 3;
open (SENDPORT, '+<', $OPT_O) or die "Can't open '$OPT_O': $!\n";
print SENDPORT "AT+CHUP\r";
close SENDPORT;