fix SSID ambiguity on spotter in DX
[spider.git] / perl / Aranea.pm
index 3a2190e7389ccabfe697172d615245594a4db180..75fcee8e07519bff04faa5d341f3ad24c62eb07a 100644 (file)
@@ -126,7 +126,7 @@ sub start
        unless ($self->{outbound}) {
                my $thing = Thingy::Rt->new_cf;
                $thing->broadcast;
-               $self->lastcf($main::systime);
+               $main::me->lastcf($main::systime);
        }
        
        # run a script send the output to the debug file
@@ -148,7 +148,7 @@ sub normal
 # periodic processing (every second)
 #
 
-my $lastmin = 0;
+my $lastmin = time;
 
 sub process
 {
@@ -160,10 +160,8 @@ sub process
                $daystart = $main::systime - ($main::systime % 86400);
        }
        if ($main::systime >= $lastmin + 60) {
-               if ($lastmin) {
-                       per_minute();
-                       $lastmin = $main::systime;
-               }
+               per_minute();
+               $lastmin = $main::systime;
        }
 }
 
@@ -171,24 +169,42 @@ sub per_minute
 {
        # send hello and cf packages periodically
        foreach my $dxchan (DXChannel::get_all()) {
-               next if $dxchan == $main::me;
                next if $dxchan->is_aranea;
-               if ($main::systime > $dxchan->lasthello + $hello_interval) {
-                       my $thing = Thingy::Hello->new(user => $dxchan->call, h => $dxchan->here);
+               if ($main::systime >= $dxchan->lasthello + $hello_interval) {
+                       my $thing = Thingy::Hello->new(h => $dxchan->here);
+                       $thing->{user} = $dxchan->{call} unless $dxchan == $main::me;
+                       if (my $v = $dxchan->{version}) {
+                               if ($dxchan->is_spider) {
+                                       $thing->{sw} = 'DXSp';
+                               }
+                               $thing->{v} = $v;
+                       }
+                       $thing->{b} = $dxchan->{build} if $dxchan->{build};
                        $thing->broadcast($dxchan);
                        $dxchan->lasthello($main::systime);
                }
                if ($dxchan->is_node) {
-                       if ($main::systime > $dxchan->lasthello + $hello_interval) {
+                       if ($main::systime >= $dxchan->lastcf + $cf_interval) {
                                my $call = $dxchan->call;
-                               my $thing = Thingy::Rt->new(user => $call);
-                               if (my $nref = Route::Node::get($call)) {
-                                       $thing->copy_pc16_data($nref);
-                                       $thing->broadcast($dxchan);
+                               if ($dxchan == $main::me) {
+
+                                       # i am special but, currently, still a node
+                                       my $thing = Thingy::Rt->new_cf;
+                                       $thing->broadcast;
                                        $dxchan->lastcf($main::systime);
                                } else {
-                                       dbg("Aranea::per_minute: Route::Node for $call disappeared");
-                                       $dxchan->disconnect;
+
+                                       # i am a pc protocol node connected directly
+                                       my $thing = Thingy::Rt->new();
+                                       $thing->{user} = $call unless $dxchan == $main::me;
+                                       if (my $nref = Route::Node::get($call)) {
+                                               $thing->copy_pc16_data($nref);
+                                               $thing->broadcast($dxchan);
+                                               $dxchan->lastcf($main::systime);
+                                       } else {
+                                               dbg("Aranea::per_minute: Route::Node for $call disappeared");
+                                               $dxchan->disconnect;
+                                       }
                                }
                        }
                }
@@ -286,7 +302,7 @@ sub genheader
 sub decode_dts
 {
        my $dts = shift;
-       my ($dt, $seqno) = map {hex} unpack "H6H4", $dts;
+       my ($dt, $seqno) = map {hex} unpack "A6 A4", $dts;
        my $secs = $dt & 0x3FFFF;
        $dt >>= 18;
        my $day = $dt >> 1;
@@ -374,6 +390,7 @@ sub input
        my $class = 'Thingy::' . ucfirst(lc $cmd);
        my $thing;
        my ($t, $seqno, $ntp) = decode_dts($dts) unless $err;
+       dbg("dts: $dts = $ntp $t($main::systime) $seqno") if isdbg('dts');
        $err .= "invalid date/seq," unless $t;
        
        if ($err) {