11 use GSM::SMS::NBS::Message;
14 use GSM::SMS::NBS::Lib;
15 require GSM::SMS::NBS::Alcatel;
17 $|=1; # No output buffering
28 my $opt_logo_group_send;
29 my $opt_ems_force_variable;
30 my $opt_ems_picture_wrap=1;
31 my $opt_ems_animation_wrap=1;
33 my $opt_alcatel_picture_send;
34 my $opt_alcatel_animation_send;
35 my $opt_alcatel_mseq_melody_file_send;
37 "v|verbose" => \$opt_verbose,
38 "transport:s" => \$opt_transport,
39 "ring-send:s" => \$opt_ring_send,
40 "logo-group-send:s" => \$opt_logo_group_send,
41 "ems-force-variable" => \$opt_ems_force_variable,
42 "ems-picture-send:s" => \&ems_picture_send,
43 "ems-picture-wrap!" => \$opt_ems_picture_wrap,
44 "ems-animation-send:s" => \&ems_animation_send,
45 "ems-animation-wrap!" => \$opt_ems_animation_wrap,
46 "ems-melody-file-send:s" => \&ems_melody_file_send,
47 "ems-text:s" => \&ems_text,
48 "alcatel-name:s" => \$opt_alcatel_name,
49 "alcatel-picture-send:s" => \$opt_alcatel_picture_send,
50 "alcatel-animation-send:s" => \$opt_alcatel_animation_send,
51 "alcatel-mseq-melody-file-send:s" => \$opt_alcatel_mseq_melody_file_send,
56 Usage: $0 [--verbose] [--transport=<transport.conf>]
57 [--ring-send=<rtttl file>]
58 [--logo-group-send=<image file>]
59 [--ems-force-variable]
60 [--ems-picture-send=<image file>]
61 [--ems-animation-send=<image file>]
62 [--ems-melody-file-send=<iMelody file>]
63 [--alcatel-name=<resource name>]
64 [--alcatel-picture-send=<image file>]
65 [--alcatel-animation-send=<image file>]
66 [--alcatel-mseq-melody-file-send=<MSEQ file>]
74 my $nbs = GSM::SMS::NBS->new( $opt_transport ? $opt_transport : "/dev/null" );
82 undef $/; # Read files at once, NEVER set it before as at least NBS->new() needs line-reading!
88 open F, $opt_ring_send;
89 my $rtttl_string = <F>;
91 $nbs->sendRTTTL($msisdn, $rtttl_string);
94 if ($opt_logo_group_send) {
95 $nbs->sendGroupGraphic_file($msisdn, $opt_logo_group_send);
98 if (@EMSudh || $EMStext ne "") {
99 $nbs->sendsms($msisdn, $EMStext, udh=>[ @EMSudh ]);
102 if ($opt_alcatel_picture_send) {
103 my $bitmap = GSM::SMS::Bitmap->new($opt_alcatel_picture_send);
104 my ($msg, $udh) = GSM::SMS::NBS::Alcatel->alcatel_picture($bitmap);
105 $udh->[0]{"name"}=$opt_alcatel_name if defined $opt_alcatel_name;
106 $nbs->sendsms($msisdn, $msg, udh=>$udh);
109 if ($opt_alcatel_animation_send) {
110 my @names=split /:/,$opt_alcatel_animation_send;
116 $imgmap{$_}=GSM::SMS::Bitmap->new($_) if (!exists $imgmap{$_});
120 # It needs to be used for compatibility with Alcatel 311 (firmware 101.01)
121 # - reported/tested by Daniel Vesely <jude@atspraha.cz>
122 warn "You probably need to specify initial frame display delay, converting anyway"
123 if "GSM::SMS::Bitmap" eq ref $list[0];
124 my ($msg, $udh) = GSM::SMS::NBS::Alcatel->alcatel_animation(@list);
125 $udh->[0]{"name"}=$opt_alcatel_name if defined $opt_alcatel_name;
126 $nbs->sendsms($msisdn, $msg, udh=>$udh);
129 if ($opt_alcatel_mseq_melody_file_send) {
131 open F, $opt_alcatel_mseq_melody_file_send;
132 my $mseq_melody_file_data = <F>;
134 my ($msg, $udh) = GSM::SMS::NBS::Alcatel->alcatel_mseq_melody_file($mseq_melody_file_data);
135 $nbs->sendsms($msisdn, $msg, udh=>$udh);
143 my($keyword,$arg)=@_;
145 my $bitmap = GSM::SMS::Bitmap->new($arg);
146 $bitmap->crop(0xFF*8,0xFF);
147 my ($width, $height) = ($bitmap->{"width"}, $bitmap->{"height"});
149 # pixel-payload of concat8 SMS w/one IEI_PICTURE_VARIABLE is 129 bytes
150 my $stripe=int(129/int(($width+7)/8));
151 carp "Image width too big to fit in one SMS part" if $stripe<=0; # ==0
152 # Will we need some newlines?
153 if ($opt_ems_picture_wrap && $stripe<$height) {
154 for (my $y=0;$y<$height;$y+=$stripe) {
156 "type"=>"ems_picture",
157 TEXT_POSITION=>length($EMStext),
158 "bitmap"=>GSM::SMS::Bitmap->new($bitmap,0,$y,$width,min($stripe,$height-$y)),
159 "force_variable"=>$opt_ems_force_variable,
161 $EMStext.="\n" if $y+$stripe<$height;
166 "type"=>"ems_picture",
167 TEXT_POSITION=>length($EMStext),
169 "force_variable"=>$opt_ems_force_variable,
173 sub ems_animation_send
175 my($keyword,$arg)=@_;
177 my @names=split /:/,$arg;
178 die "Required exactly 4 colon (':') delimited filenames for --ems-animation-send" if 4 != @names;
179 my @bitmaps=map { GSM::SMS::Bitmap->new($_); } @names;
180 my($width,$height)=GSM::SMS::NBS::Message::ems_animation_maxsize(\@bitmaps);
181 # Will we need some newlines?
182 if ($opt_ems_animation_wrap && $height>16) {
184 for (my $y=0;$y<$height;$y+=$height_now) {
185 $height_now=($y+8>=$height ? 8 : 16);
186 # we don't do horizontal split here
188 "type"=>"ems_animation",
189 TEXT_POSITION=>length($EMStext),
191 GSM::SMS::Bitmap->new($_,0,$y,$width,$height_now);
194 $EMStext.="\n" if $y+$height_now<$height;
199 "type"=>"ems_animation",
200 TEXT_POSITION=>length($EMStext),
201 "bitmaps"=>\@bitmaps,
205 sub ems_melody_file_send
207 my($keyword,$arg)=@_;
212 my $ems_melody_file_data = <F>;
214 warn "EMS iMelody file format not recognized, wrapping anyway"
215 if $ems_melody_file_data!~/^BEGIN:IMELODY\r\n.*END:IMELODY\r\n$/s;
217 "type"=>"ems_melody",
218 TEXT_POSITION=>length($EMStext),
219 "textdata"=>$ems_melody_file_data,
225 my($keyword,$arg)=@_;