--ems-melody-file-send wrapper implemented
[gsmperl.git] / GSM / examples / commandline / gsmcmd
index c378ee4..8adb0da 100755 (executable)
@@ -24,6 +24,7 @@ my $opt_logo_group_send;
 my $opt_ems_force_variable;
 my $opt_ems_picture_send;
 my $opt_ems_animation_send;
+my $opt_ems_melody_file_send;
 my $opt_alcatel_name;
 my $opt_alcatel_picture_send;
 my $opt_alcatel_animation_send;
@@ -36,6 +37,7 @@ GetOptions(
        "ems-force-variable"              => \$opt_ems_force_variable,
        "ems-picture-send:s"              => \$opt_ems_picture_send,
        "ems-animation-send:s"            => \$opt_ems_animation_send,
+       "ems-melody-file-send:s"          => \$opt_ems_melody_file_send,
        "alcatel-name:s"                  => \$opt_alcatel_name,
        "alcatel-picture-send:s"          => \$opt_alcatel_picture_send,
        "alcatel-animation-send:s"        => \$opt_alcatel_animation_send,
@@ -50,6 +52,7 @@ Usage: $0 [--verbose] [--transport=<transport.conf>]
        [--ems-force-variable]
        [--ems-picture-send=<image file>]
        [--ems-animation-send=<image file>]
+       [--ems-melody-file-send=<iMelody file>]
        [--alcatel-name=<resource name>]
        [--alcatel-picture-send=<image file>]
        [--alcatel-animation-send=<image file>]
@@ -106,6 +109,20 @@ for $msisdn (@ARGV) {
                } ]);
        }
 
+       if ($opt_ems_melody_file_send) {
+               local (*F);
+               open F, $opt_ems_melody_file_send;
+               my $ems_melody_file_data = <F>;
+               close F;
+               warn "EMS iMelody file format not recognized, wrapping anyway"
+                               if $ems_melody_file_data!~/^BEGIN:IMELODY\r\n.*END:IMELODY\r\n$/s;
+               $nbs->sendsms($msisdn, "", udh=>[ {
+                               "type"=>"ems_melody",
+                               TEXT_POSITION=>0,
+                               "textdata"=>$ems_melody_file_data,
+               } ]);
+       }
+
        if ($opt_alcatel_picture_send) {
                my $bitmap = GSM::SMS::Bitmap->new($opt_alcatel_picture_send);
                my ($msg, $udh) = GSM::SMS::NBS::Alcatel->alcatel_picture($bitmap);