More complete rework of packet parsing and packet generation with f279d85 - and testing passes

This commit is contained in:
2024-05-20 21:31:21 +10:00
parent b30ab2f999
commit ab2e288f06
14 changed files with 227 additions and 210 deletions

View File

@@ -63,34 +63,36 @@ final class FSC39 extends Packet
*/
protected function header(): string
{
$oldest = $this->messages->sortBy('datetime')->last();
try {
return pack(collect(self::HEADER)->pluck(1)->join(''),
$this->ff, // Orig Node
$this->tf, // Dest Node
Arr::get($this->header,'y'), // Year
Arr::get($this->header,'m'), // Month
Arr::get($this->header,'d'), // Day
Arr::get($this->header,'H'), // Hour
Arr::get($this->header,'M'), // Minute
Arr::get($this->header,'S'), // Second
0, // Baud
2, // Packet Version (should be 2)
$this->fn, // Orig Net
$this->tn, // Dest Net
(Setup::PRODUCT_ID & 0xff), // Product Code Lo
Setup::PRODUCT_VERSION_MAJ, // Product Version Major
$this->password, // Packet Password
$this->fz, // Orig Zone
$this->tz, // Dest Zone
'', // Reserved
$this->fftn_p->node_id, // Orig Node
$this->tftn_p->node_id, // Dest Node
$oldest->datetime->format('Y'), // Year
$oldest->datetime->format('m')-1, // Month
$oldest->datetime->format('d'), // Day
$oldest->datetime->format('H'), // Hour
$oldest->datetime->format('i'), // Minute
$oldest->datetime->format('s'), // Second
0, // Baud
2, // Packet Version (should be 2)
$this->fftn_p->host_id, // Orig Net
$this->tftn_p->host_id, // Dest Net
(Setup::PRODUCT_ID & 0xff), // Product Code Lo
Setup::PRODUCT_VERSION_MAJ, // Product Version Major
$this->pass_p ?: $this->tftn_p->session('pktpass'), // Packet Password
$this->fftn_p->zone->zone_id, // Orig Zone
$this->tftn_p->zone->zone_id, // Dest Zone
'', // Reserved
Arr::get($this->header,'capvalid',1<<0), // fsc-0039.004 (copy of 0x2c)
((Setup::PRODUCT_ID >> 8) & 0xff), // Product Code Hi
Setup::PRODUCT_VERSION_MIN, // Product Version Minor
Arr::get($this->header,'capword',1<<0), // Capability Word
$this->fz, // Orig Zone
$this->tz, // Dest Zone
$this->fp, // Orig Point
$this->tp, // Dest Point
((Setup::PRODUCT_ID >> 8) & 0xff), // Product Code Hi
Setup::PRODUCT_VERSION_MIN, // Product Version Minor
1<<0, // Capability Word
$this->fftn_p->zone->zone_id, // Orig Zone
$this->tftn_p->zone->zone_id, // Dest Zone
$this->fftn_p->point_id, // Orig Point
$this->tftn_p->point_id, // Dest Point
strtoupper(hexstr(Setup::PRODUCT_ID)), // ProdData
);

View File

@@ -44,22 +44,22 @@ final class FSC45 extends Packet
{
try {
return pack(collect(self::HEADER)->pluck(1)->join(''),
$this->ff, // Orig Node
$this->tf, // Dest Node
$this->fp, // Orig Point
$this->tp, // Dest Point
'', // Reserved
2, // Sub Version (should be 2)
2, // Packet Version (should be 2)
$this->fn, // Orig Net
$this->tn, // Dest Net
(Setup::PRODUCT_ID & 0xff), // Product Code
Setup::PRODUCT_VERSION_MAJ, // Product Version
$this->password, // Packet Password
$this->fz, // Orig Zone
$this->tz, // Dest Zone
$this->fd, // Orig Domain
$this->td, // Dest Domain
$this->fftn_p->node_id, // Orig Node
$this->tftn_p->node_id, // Dest Node
$this->fp, // Orig Point
$this->tp, // Dest Point
'', // Reserved
2, // Sub Version (should be 2)
2, // Packet Version (should be 2)
$this->fftn_p->host_id, // Orig Net
$this->tftn_p->host_id, // Dest Net
(Setup::PRODUCT_ID & 0xff), // Product Code
Setup::PRODUCT_VERSION_MAJ, // Product Version
$this->pass_p ?: $this->tftn_p->session('pktpass'), // Packet Password
$this->fftn_p->zone->zone_id, // Orig Zone
$this->tftn_p->zone->zone_id, // Dest Zone
$this->fftn_p->zone->domain->name, // Orig Domain
$this->tftn_p->zone->domain->name, // Dest Domain
strtoupper(hexstr(Setup::PRODUCT_ID)), // ProdData
);

View File

@@ -43,26 +43,28 @@ final class FTS1 extends Packet
*/
protected function header(): string
{
$oldest = $this->messages->sortBy('datetime')->last();
try {
return pack(collect(self::HEADER)->pluck(1)->join(''),
$this->ff, // Orig Node
$this->tf, // Dest Node
Arr::get($this->header,'y'), // Year
Arr::get($this->header,'m'), // Month
Arr::get($this->header,'d'), // Day
Arr::get($this->header,'H'), // Hour
Arr::get($this->header,'M'), // Minute
Arr::get($this->header,'S'), // Second
0, // Baud
2, // Packet Version (should be 2)
$this->fn, // Orig Net
$this->tn, // Dest Net
(Setup::PRODUCT_ID & 0xff), // Product Code Lo
Setup::PRODUCT_VERSION_MAJ, // Product Version Major
$this->password, // Packet Password
$this->fz, // Orig Zone
$this->tz, // Dest Zone
'', // Reserved
$this->fftn_p->node_id, // Orig Node
$this->tftn_p->node_id, // Dest Node
$oldest->datetime->format('Y'), // Year
$oldest->datetime->format('m')-1, // Month
$oldest->datetime->format('d'), // Day
$oldest->datetime->format('H'), // Hour
$oldest->datetime->format('i'), // Minute
$oldest->datetime->format('s'), // Second
0, // Baud
2, // Packet Version (should be 2)
$this->fftn_p->host_id, // Orig Net
$this->tftn_p->host_id, // Dest Net
(Setup::PRODUCT_ID & 0xff), // Product Code Lo
Setup::PRODUCT_VERSION_MAJ, // Product Version Major
$this->pass_p ?: $this->tftn_p->session('pktpass'), // Packet Password
$this->fftn_p->zone->zone_id, // Orig Zone
$this->tftn_p->zone->zone_id, // Dest Zone
'', // Reserved
);
} catch (\Exception $e) {