3 # This module impliments the outgoing PCxx generation routines
5 # These are all the namespace of DXProt and are separated for "clarity"
7 # Copyright (c) 1998 Dirk Koopman G1TLH
14 @ISA = qw(DXProt DXChannel);
22 use vars qw($sentencelth);
27 # All the PCxx generation routines
30 # create a talk string ($from, $to, $via, $text)
33 my ($from, $to, $via, $text, $origin) = @_;
35 if ($via && $via ne $to && $via ne '*') {
42 $origin ||= $main::mycall;
44 $text = ' ' unless $text && length $text > 0;
46 return "PC10^$from^$user1^$text^*^$user2^$origin^~";
49 # create a dx message (call, freq, dxcall, text)
52 my ($mycall, $freq, $dxcall, $text) = @_;
53 my $hops = get_hops(11);
55 $text = ' ' if !$text;
57 return sprintf "PC11^%.1f^$dxcall^%s^%s^$text^$mycall^$main::mycall^$hops^~", $freq, cldate($t), ztime($t);
60 # create an announce message
63 my ($call, $text, $tonode, $sysop, $wx, $origin) = @_;
64 my $hops = get_hops(12);
70 $origin ||= $main::mycall;
71 return "PC12^$call^$tonode^$text^$sysop^$origin^$wx^$hops^~";
75 # add one or more users (I am expecting references that have 'call',
76 # 'conf' & 'here' method)
78 # this will create a list of PC16 with up pc16_max_users in each
79 # called $self->pc16(..)
84 my $ncall = $node->call;
91 my $str = sprintf "^%s %s %d", $ref->call, $ref->conf ? '*' : '-', $ref->here;
92 if (length($s) + length($str) > $sentencelth) {
93 push @out, "PC16^$ncall" . $s . sprintf "^%s^", get_hops(16);
98 push @out, "PC16^$ncall" . $s . sprintf "^%s^", get_hops(16);
102 # remove a local user
109 my $hops = get_hops(17);
110 my $ncall = $node->call;
111 my $ucall = $ref->call;
112 push @out, "PC17^$ucall^$ncall^$hops^";
117 # Request init string
121 $flags .= " xml" if DXXml::available();
122 return "PC18^DXSpider Version: $main::version Build: $main::subversion.$main::build$flags^$DXProt::myprot_version^";
126 # add one or more nodes
137 my $call = $ref->call;
138 my $here = $ref->here;
139 my $conf = $ref->conf;
140 my $version = $ref->version;
141 my $str = "^$here^$call^$conf^$version";
142 if (length($s) + length($str) > $sentencelth) {
143 push @out, "PC19" . $s . sprintf "^%s^", get_hops(19);
148 push @out, "PC19" . $s . sprintf "^%s^", get_hops(19);
164 my $hops = get_hops(21);
165 my $call = $node->call;
166 push @out, "PC21^$call^Gone^$hops^";
181 my $call = $self->call;
182 my $flag = $self->here ? '1' : '0';
183 my $hops = shift || get_hops(24);
185 return "PC24^$call^$flag^$hops^";
189 # create a merged dx message (freq, dxcall, t, text, spotter, orig-node)
192 my ($freq, $dxcall, $t, $text, $spotter, $orignode) = @_;
193 $text = ' ' unless $text;
194 $orignode = $main::mycall unless $orignode;
195 return sprintf "PC26^%.1f^$dxcall^%s^%s^$text^$spotter^$orignode^ ^~", $freq, cldate($t), ztime($t);
198 # create a merged WWV spot (logger, t, sfi, a, k, forecast, orig-node)
201 my ($logger, $t, $sfi, $a, $k, $forecast, $orignode) = @_;
202 return sprintf "PC27^%s^%-2.2s^$sfi^$a^$k^$forecast^$logger^$orignode^ ^~", cldate($t), ztime($t);
205 # message start (fromnode, tonode, to, from, t, private, subject, origin)
208 my ($tonode, $fromnode, $to, $from, $t, $private, $subject, $origin, $rr) = @_;
209 my $date = cldate($t);
210 my $time = ztime($t);
211 $private = $private ? '1' : '0';
212 $rr = $rr ? '1' : '0';
214 return "PC28^$tonode^$fromnode^$to^$from^$date^$time^$private^$subject^ ^5^$rr^ ^$origin^~";
217 # message text (from and to node same way round as pc29)
220 my ($fromnode, $tonode, $stream, $text) = @_;
221 $text = ' ' unless defined $text && length $text > 0;
222 $text =~ s/\^/%5E/og; # remove ^
223 return "PC29^$fromnode^$tonode^$stream^$text^~";
226 # subject acknowledge (will have to and from node reversed to pc28)
229 my ($fromnode, $tonode, $stream) = @_;
230 return "PC30^$fromnode^$tonode^$stream^";
233 # acknowledge this tranche of lines (to and from nodes reversed to pc29 and pc28
236 my ($fromnode, $tonode, $stream) = @_;
237 return "PC31^$fromnode^$tonode^$stream^";
240 # end of message from the sending end (pc28 node order)
243 my ($fromnode, $tonode, $stream) = @_;
244 return "PC32^$fromnode^$tonode^$stream^";
247 # acknowledge end of message from receiving end (opposite pc28 node order)
250 my ($fromnode, $tonode, $stream) = @_;
251 return "PC33^$fromnode^$tonode^$stream^";
257 my($fromnode, $tonode, $msg) = @_;
258 return "PC34^$tonode^$fromnode^$msg^~";
264 my($fromnode, $tonode, $msg) = @_;
265 return "PC35^$tonode^$fromnode^$msg^~";
268 # send all the DX clusters I reckon are connected
271 return join '^', "PC38", map {$_->call} Route::Node::get_all();
274 # tell the local node to discconnect
277 my ($call, $reason) = @_;
278 my $hops = get_hops(39);
279 $reason = "Gone." if !$reason;
280 return "PC39^$call^$reason^$hops^";
283 # cue up bulletin or file for transfer
286 my ($to, $from, $fn, $bull) = @_;
287 $bull = $bull ? '1' : '0';
288 return "PC40^$to^$from^$fn^$bull^5^";
295 $call = shift if ref $call;
297 my $sort = shift || '0';
298 my $info = shift || ' ';
299 my $hops = shift || get_hops(41);
300 return "PC41^$call^$sort^$info^$hops^~";
306 my ($fromnode, $tonode, $stream) = @_;
307 return "PC42^$fromnode^$tonode^$stream^";
313 my ($fromnode, $tonode, $stream, $db, $req, $call) = @_;
315 return "PC44^$tonode^$fromnode^$stream^$db^$req^$call^";
321 my ($fromnode, $tonode, $stream, $data) = @_;
322 return "PC45^$tonode^$fromnode^$stream^$data^";
325 # remote db data complete
328 my ($fromnode, $tonode, $stream) = @_;
329 return "PC46^$tonode^$fromnode^$stream^";
335 my ($from, $subject) = @_;
336 my $hops = get_hops(49);
337 return "PC49^$from^$subject^$hops^~";
340 # periodic update of users, plus keep link alive device (always H99)
344 my $call = $self->call;
345 my $n = shift || '0';
346 my $hops = shift || 'H99';
347 return "PC50^$call^$n^$hops^";
353 my ($to, $from, $val) = @_;
354 return "PC51^$to^$from^$val^";
357 # clx remote cmd send
360 my($fromnode, $tonode, $call, $msg) = @_;
361 return "PC84^$tonode^$fromnode^$call^$msg^~";
364 # clx remote cmd reply
367 my($fromnode, $tonode, $call, $msg) = @_;
368 return "PC85^$tonode^$fromnode^$call^$msg^~";
371 # spider route broadcasts
379 my $s = "PC92^$main::mycall^" . gen_pc9x_t() . "^$sort";
381 $s .= "^" . _encode_pc92_call($_, $ext);
386 sub gen_pc92_with_time
392 my $s = "PC92^$call^$t^$sort";
394 $s .= "^" . _encode_pc92_call($_, $ext);
402 return _gen_pc92('A', 0, @_);
408 return _gen_pc92('D', 0, @_);
414 return _gen_pc92('C', 1, @_);
417 # send a 'find' message
422 return "PC92^$main::mycall^" . gen_pc9x_t() . "^F^$from^$target^H99^"
425 # send a 'reply' message
432 return "PC92^$main::mycall^" . gen_pc9x_t() . "^R^$to^$target^$flag^$ms^H99^"
437 my $to = shift; # *, callsign, chat group name, sysop
438 my $from = shift; # from user callsign
439 my $via = shift || '*'; # *, node call
440 my $line = shift; # the text
441 my $origin = shift; # this will be present on proxying from PC10
443 $line = unpad($line);
444 $line =~ s/\^/\\5E/g; # remove any ^ characters
445 my $s = "PC93^$main::mycall^" . gen_pc9x_t() . "^$to^$from^$via^$line";
446 $s .= "^$origin" if $origin;