summaryrefslogtreecommitdiff
path: root/xpp/utils/zconf/Zaptel/Chans.pm
diff options
context:
space:
mode:
Diffstat (limited to 'xpp/utils/zconf/Zaptel/Chans.pm')
-rw-r--r--xpp/utils/zconf/Zaptel/Chans.pm38
1 files changed, 36 insertions, 2 deletions
diff --git a/xpp/utils/zconf/Zaptel/Chans.pm b/xpp/utils/zconf/Zaptel/Chans.pm
index 31bc5f7..3364060 100644
--- a/xpp/utils/zconf/Zaptel/Chans.pm
+++ b/xpp/utils/zconf/Zaptel/Chans.pm
@@ -5,9 +5,12 @@ package Zaptel::Chans;
# This program is free software; you can redistribute and/or
# modify it under the same terms as Perl itself.
#
-#use strict;
+# $Id$
+#
+use strict;
# Accessors (miniperl does not have Class:Accessor)
+our $AUTOLOAD;
sub AUTOLOAD {
my $self = shift;
my $name = uc($AUTOLOAD);
@@ -36,11 +39,42 @@ sub new($$$$$) {
$type = $1; # One of our AB
} elsif(defined $info) {
$type = (split(/\s+/, $info))[0];
+ $type = 'FXS' if $type =~ /^FXS/;
+ $type = 'FXO' if $type =~ /^FXO/;
} else {
- $type = $fqn;
+ $type = undef;
}
$self->type($type);
return $self;
}
+my $ztcfg = $ENV{ZTCFG} || '/sbin/ztcfg';
+sub probe_type($) {
+ my $self = shift;
+ my $fqn = $self->fqn;
+ my $num = $self->num;
+ my $type;
+
+ if($fqn =~ m:WCTDM/|\ WRTDM/|OPVXA1200/:) {
+ my %maybe;
+
+ undef %maybe;
+ foreach my $sig (qw(fxo fxs)) {
+ my $cmd = "echo ${sig}ks=$num | $ztcfg -c /dev/fd/0";
+
+ $maybe{$sig} = system("$cmd >/dev/null 2>&1") == 0;
+ }
+ if($maybe{fxo} and $maybe{fxs}) {
+ $type = 'EMPTY';
+ } elsif($maybe{fxo}) {
+ $type = 'FXS';
+ } elsif($maybe{fxs}) {
+ $type = 'FXO';
+ }
+ } else {
+ $type = $self->type;
+ }
+ return $type;
+}
+
1;