GSM-SMS

 view release on metacpan or  search on metacpan

lib/GSM/SMS/Transport/Serial.pm  view on Meta::CPAN

	return -1;
}

=item B<init> - Initialise this transport layer

  No init file -> default initfile for transport
 
=cut

sub init {
	my ($self) = @_;

	# Start of log ...
	logdbg "debug","Starting Serial Transport for " . $self->get_name();
	
	# Get configuration from config file

	my $port 	= $self->get_serial_port();
	my $br   	= $self->get_baud_rate();
	my $pc   	= $self->get_pin_code();
	my $csca 	= $self->get_csca();
	my $modem 	= $self->get_name();
	
	logdbg "debug", "serial-port: $port";
	logdbg "debug", "baud-rate: $br";
	logdbg "debug", "pin-code: $pc";
	logdbg "debug", "csca: $csca";
	logdbg "debug", "name: $modem";

	# Start up serial port

	my $portobject = GSM::SMS::Support::SerialPort->new ($port);
   	$portobject->baudrate($br);
   	$portobject->parity("none");
   	$portobject->databits(8);
   	$portobject->stopbits(1);
	$self->set_serialport_object( $portobject );

	unless ( $portobject ) {
		logdbg "debug", "Could not open serial port";
		logerr "Could not open serial port";
		return undef;
	}

	# Try to communicate to the port
	$self->_at("ATZ\r", $__TO);
	$self->_at("ATE0\r", $__TO);
	my $res = $self->_at("AT\r", $__TO);
	
	logdbg "debug", "Serial: AT yielded [$res]";
	unless ($res =~/OK/is) {
		logerr "Could not communicate to $port, expected 'OK' but got '$res'";
		return undef;
	}

	# Check the modem status (PIN, CSCA and network connection)
	return undef unless ( $self->_register );

	$self->{MSGARRAY} = [];

	logdbg "debug", "Modem is alive! (SQ=" . $self->_getSQ() . "dBm)";
	return $self;
}

=item B<close> - Close the init file

=cut

sub close {
	my ($self) =@_;

	my $l = $self->{log};
	my $portobject = $self->get_serialport_object();
	$portobject->close;
	undef $portobject;

	logdbg "debug", "Serial:" . $self->get_name() . " closed";
}

=item B<ping> - A ping command

  .. just return an informative string on success

=cut

sub ping {
	my ($self) = @_;

	return $self->_getSQ();
}

=item B<get_info> - Give some info about this transport

=cut

sub get_info {
	my ($self) = @_;

	my $revision = '$Revision: 1.7 $';
	my $date = '$Date: 2003/01/11 14:16:34 $';

print <<EOT;
Serial transport $VERSION

Revision: $revision

Date: $date

EOT
}

=back

=cut

###############################################################################
# Transport layer specific functions
#
sub _getSMS {
	my ($self) = @_;
	my $result = [];



( run in 1.963 second using v1.01-cache-2.11-cpan-39bf76dae61 )