:pserver:anonymous@intra.tektonica.com:/opt/cvs - gsmperl - Fri Dec 21 07:37 CET...
[gsmperl.git] / GSM / SMS / OTA / OTA.pm
1 package GSM::SMS::OTA::OTA;
2
3 require Exporter;
4 @ISA = qw(Exporter);
5
6 @EXPORT = qw(   OTAdecode_8bit
7                                 OTAencode_8bit); 
8
9 $VERSION = '0.1';
10
11 sub OTAdecode_8bit {
12         my ($ud) = @_;
13         my $msg;
14
15         while (length($ud)) {
16                 $msg .= pack('H2',substr($ud,0,2));
17                 $ud = substr($ud,2);
18         }
19         return $msg;
20 }
21
22
23 sub OTAencode_8bit {
24         my ($ud) = @_;
25         my $msg;
26
27         while (length($ud)) {
28                $msg .= sprintf("%.2X", ord(substr($ud,0,1)));
29                $ud = substr($ud,1);
30         }
31         return $msg;
32 }
33
34 1;
35
36 =head1 NAME
37
38 GSM::SMS::OTA::OTA
39
40 =head1 DESCRIPTION
41
42 This package contains 2 functions to decode and encode 8 bit data in an ASCII alphabet. It just writes out a byte as a 2 character string, containing the hexadecimal representation.
43
44 =head1 METHODS
45
46         $binary = OTAdecode_8bit( $text )
47         $text = OTAencode_8bit( $binary )
48
49 =head1 AUTHOR
50
51 Johan Van den Brande <johan@vandenbrande.com>