File: network.pl

package info (click to toggle)
libdevice-gsm-perl 1.61-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 504 kB
  • sloc: perl: 3,264; makefile: 2
file content (28 lines) | stat: -rw-r--r-- 681 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/perl
#
# Get GSM network name 

use strict;
use Device::Gsm;

my $port = $ENV{DEV_GSM_PORT} or die "Set DEV_GSM_PORT environment variable!";
my $gsm = new Device::Gsm( port => $port, log => 'file,network.log', loglevel => 'info' );

die "cannot create Device::Gsm object!" unless $gsm;

$gsm->connect( baudrate => ($ENV{DEV_GSM_BAUD} || 19200) )
    or die "cannot connect to GSM device on [$port]\n";

$gsm->register() or die "Can't register to network";

my($network, $code) = $gsm->network();

if($network || $code) {
	print "Network name the gsm software returns is [$network]\n";
    print "Its gsm code is [$code]\n";
} else { 
	print "No network name...\n";
}