# send initialisation string
$self->send($self->pc38()) if DXNode->get_all();
$self->send($self->pc18());
- $self->{state} = 'incoming';
+ $self->state('normal');
+ $self->pc50_t(time);
}
#
SWITCH: {
if ($pcno == 10) {last SWITCH;}
- if ($pcno == 11) {last SWITCH;}
+ if ($pcno == 11) { # dx spot
+
+ last SWITCH;
+ }
if ($pcno == 12) {last SWITCH;}
if ($pcno == 13) {last SWITCH;}
if ($pcno == 14) {last SWITCH;}
$self->send($out);
}
$self->send($self->pc22());
+ return;
+ }
+ if ($pcno == 21) { # delete a cluster from the list
+
last SWITCH;
}
- if ($pcno == 21) {last SWITCH;}
if ($pcno == 22) {last SWITCH;}
if ($pcno == 23) {last SWITCH;}
if ($pcno == 24) {last SWITCH;}
if ($pcno == 47) {last SWITCH;}
if ($pcno == 48) {last SWITCH;}
if ($pcno == 49) {last SWITCH;}
- if ($pcno == 50) {last SWITCH;}
- if ($pcno == 51) {last SWITCH;}
+ if ($pcno == 50) {
+ last SWITCH;
+ }
+ if ($pcno == 51) { # incoming ping requests/answers
+
+ # is it for us?
+ if ($field[1] eq $main::mycall) {
+ my $flag = $field[3];
+ $flag ^= 1;
+ $self->send($self->pc51($field[2], $field[1], $flag));
+ } else {
+ # route down an appropriate thingy
+ $self->route($field[1], $line);
+ }
+ return;
+ }
}
# if get here then rebroadcast the thing with its Hop count decremented (if
my $hopfield = pop @field;
push @field, $hopfield;
- if ($hopfield =~ /H\d\d./o) {
- my ($hops) = $hopfield =~ /H(\d+)/o;
- $hops--;
- if ($hops > 0) {
- $line =~ s/\^H\d+(\^\~.)$/\^H$hops$1/; # change the hop count
+ my $hops;
+ if (($hops) = $hopfield =~ /H(\d+)\^\~?$/o) {
+ my $newhops = $hops - 1;
+ if ($newhops > 0) {
+ $line =~ s/\^H$hops(\^\~?)$/\^H$newhops$1/; # change the hop count
DXProt->broadcast($line, $self); # send it to everyone but me
}
}
next if !$chan->is_ak1a();
# send a pc50 out on this channel
- if ($t >= $chan->t + $DXProt::pc50_interval) {
+ if ($t >= $chan->pc50_t + $DXProt::pc50_interval) {
$chan->send(pc50());
- $chan->t($t);
+ $chan->pc50_t($t);
}
}
}
# some active measures
#
+#
+# route a message down an appropriate interface for a callsign
+#
+# expects $self to indicate 'from' and is called $self->route(to, pcline);
+#
+sub route
+{
+ my ($self, $call, $line) = @_;
+ my $cl = DXCluster->get($call);
+ if ($cl) {
+ my $dxchan = $cl->{dxchan};
+ $cl->send($line) if $dxchan;
+ }
+}
+
# broadcast a message to all clusters [except those mentioned after buffer]
sub broadcast
{
return "PC38^" . join(',', @nodes) . "^~";
}
+# periodic update of users, plus keep link alive device (always H99)
sub pc50
{
my $n = DXNodeuser->count;
return "PC50^$main::mycall^$n^H99^";
}
+# generate pings
+sub pc51
+{
+ my ($self, $to, $from, $val) = @_;
+ return "PC51^$to^$from^$val^";
+}
1;
__END__