From c216c722afe681b32352603b92839256103114b1 Mon Sep 17 00:00:00 2001 From: Mathieu Parent Date: Fri, 2 Apr 2010 12:21:47 +0200 Subject: [PATCH] perl-skinny: Add call test - more verbose when incomplete message - guess hostname - do a basic call to Voicemail: + Newcall softkey, wait 5 + Voicemail button, wait 20 + EndCall softkey --- .../mod_skinny/Net/Skinny/Message.pm | 4 +- src/mod/endpoints/mod_skinny/test-skinny.pl | 68 ++++++++++++++++++- 2 files changed, 68 insertions(+), 4 deletions(-) diff --git a/src/mod/endpoints/mod_skinny/Net/Skinny/Message.pm b/src/mod/endpoints/mod_skinny/Net/Skinny/Message.pm index e69a80f4ba..6a1a0ef1cf 100644 --- a/src/mod/endpoints/mod_skinny/Net/Skinny/Message.pm +++ b/src/mod/endpoints/mod_skinny/Net/Skinny/Message.pm @@ -49,7 +49,9 @@ sub send { $parsed_count++; } if($parsed_count != scalar(keys %{$self->{'data'}})) { - printf "Incomplete message: %d out of %d\n", $parsed_count, scalar(keys %{$self->{'data'}}); + printf "Incomplete message (type=%s (%X)) %d out of %d\n", Net::Skinny::Protocol::skinny_message_type2str($self->{'type'}), $self->{'type'}, + $parsed_count, scalar(keys %{$self->{'data'}}); + print Dumper(@$struct); return; } $self->{'socket'}->send_data($self->{'type'}, $raw); diff --git a/src/mod/endpoints/mod_skinny/test-skinny.pl b/src/mod/endpoints/mod_skinny/test-skinny.pl index 4821fc9b50..390466f530 100644 --- a/src/mod/endpoints/mod_skinny/test-skinny.pl +++ b/src/mod/endpoints/mod_skinny/test-skinny.pl @@ -11,12 +11,13 @@ BEGIN { use strict; use warnings; +use Sys::Hostname; use Net::Skinny; use Net::Skinny::Protocol qw/:all/; use Net::Skinny::Message; #Config -my $skinny_server = '127.0.0.1'; +my $skinny_server = hostname; my $device_name = "SEP001120AABBCC"; my $device_ip = 10+256*(11+256*(12+256*13)); # 10.11.12.13 #====== @@ -70,6 +71,7 @@ $socket->receive_message(); # SoftKeyTemplateRes $socket->send_message(SOFT_KEY_SET_REQ_MESSAGE); $socket->receive_message(); # SoftKeySetRes +$socket->receive_message(); # SelectSoftKeys $socket->send_message( LINE_STAT_REQ_MESSAGE, @@ -82,8 +84,68 @@ $socket->send_message( count => 2 ); -while(1) { - $socket->sleep(20); +for(my $i = 0; $i < 1; $i++) { + $socket->sleep(5); $socket->send_message(KEEP_ALIVE_MESSAGE); $socket->receive_message(); # keepaliveack } +$socket->sleep(5); + +#NewCall +$socket->send_message( + SOFT_KEY_EVENT_MESSAGE, + event => 2, #NewCall + line_instance => 2, + call_id => 0 + ); +$socket->receive_message(); # SetRinger +$socket->receive_message(); # SetSpeakerMode +$socket->receive_message(); # SetLamp +$socket->receive_message(); # SelectSoftKeys +$socket->receive_message(); # DisplayPromptStatus +$socket->receive_message(); # ActivateCallPlane +$socket->receive_message(); # StartTone + +$socket->sleep(5); + +#VoiceMail +$socket->send_message( + STIMULUS_MESSAGE, + instance_type => 0xf, #VoiceMail + instance => 0, + ); +$socket->receive_message(); # +$socket->receive_message(); # +$socket->receive_message(); # +$socket->receive_message(); # +$socket->receive_message(); # +$socket->receive_message(); # +$socket->receive_message(); # +$socket->receive_message(); # +$socket->receive_message(); # +$socket->receive_message(); # + +# +$socket->send_message( + OPEN_RECEIVE_CHANNEL_ACK_MESSAGE, + status => 1, + ip => $device_ip, + port => 12, + pass_thru_party_id => 0, + ); +$socket->receive_message(); # StartMediaTransmission + +$socket->sleep(20); + +#EndCall +$socket->send_message( + SOFT_KEY_EVENT_MESSAGE, + event => 0x09, #NewCall + line_instance => 1, + call_id => 0 + ); + +while(1) { + $socket->receive_message(); +} +