1 package GSM::SMS::OTA::Operatorlogo;
2 use GSM::SMS::OTA::Bitmap;
7 @EXPORT = qw( OTAOperatorlogo_makestream
9 OTAOperatorlogo_fromb64
10 OTAOperatorlogo_fromfile
15 use constant OTAOperatorlogo_PORT => 5506;
17 sub OTAOperatorlogo_fromb64 {
18 my ($countrycode, $operatorcode, $b64, $format) = @_;
20 my $arr = OTABitmap_fromb64( $b64, $format );
21 return -1 if $arr == -1;
23 return OTAOperatorlogo_makestream( $countrycode, $operatorcode, 72, 14, 1, $arr );
26 sub OTAOperatorlogo_fromfile {
27 my ($countrycode, $operatorcode, $file) = @_;
29 my $arr = OTABitmap_fromfile( $file );
30 return -1 if $arr == -1;
32 return OTAOperatorlogo_makestream( $countrycode, $operatorcode, 72, 14, 1, $arr );
36 sub OTAOperatorlogo_makestream {
37 my ($countrycode, $operatorcode, $width, $height, $depth, $ref_bytearray) = @_;
41 $stream.= encodeOperatorID($countrycode, $operatorcode);
42 $stream.='00'; # Nokia stuff for validity period
43 $stream.=OTABitmap_makestream($width, $height, $depth, $ref_bytearray);
48 # encode the operator ID (country, operator) into a litlle endian BCD string
49 sub encodeOperatorID {
50 my ($country, $operator) = @_;
52 my $c = sprintf("%03d", $country);
53 my $o = sprintf("%02d", $operator);
55 my @arr = split /|/, sprintf("%03d%02d", $country, $operator);
58 $enc[0] = ($arr[1] & 0x0F) << 4 | ($arr[0] & 0x0F);
59 $enc[1] = (0x0F << 4) | ($arr[2] & 0x0F);
60 $enc[2] = ($arr[4] & 0x0F) << 4 | ($arr[3] & 0x0F);
62 return join("", map { sprintf("%02X", $_) } @enc );
69 GSM::SMS::OTA::Operatorlogo
73 This package implements encoding of an Operatorlogo icon.
77 =head2 OTAOperatorlogo_fromb64
79 $stream = OTAOperatorlogo_fromb64($countrycode, $operatorcode, $b64, $format);
81 Create a operator logo from a b64 encoded image in the specified format ( gif, png, ...). The countrycode and operator code are 2 codes that specfify either the operator or the country of the receiving handset.
83 =head2 OTAOperatorlogo_fromfile
85 $stream = OTAOperatorlogo_fromfile($countrycode, $operatorcode, $file );
87 Create a operator logo from a file.
89 =head2 OTAOperatorlogo_PORT
91 NSB Port number for Operator logos.
95 The country and operator coe have to be provided manually. It would be
96 interesting to have other modules: GSM::SMS::Countrycode and GSM::SMS::OPeratorcode , that handle this automatically. Give them a msisdn and they provide you with the code.
100 Johan Van den Brande <johan@vandenbrande.com>