kopia lustrzana https://github.com/pjalocha/esp32-ogn-tracker
Relay encrypted packets
rodzic
a35802e4c0
commit
9a335daaa2
10
main/ogn.h
10
main/ogn.h
|
@ -237,6 +237,7 @@ template <class OGNx_Packet=OGN1_Packet>
|
||||||
if(Packet.Header.Relay) return; // no rank for relayed packets (only single relay)
|
if(Packet.Header.Relay) return; // no rank for relayed packets (only single relay)
|
||||||
if(RxRSSI>128) // [-0.5dB] weaker signal => higher rank
|
if(RxRSSI>128) // [-0.5dB] weaker signal => higher rank
|
||||||
Rank += (RxRSSI-128)>>2; // 1point/2dB less signal
|
Rank += (RxRSSI-128)>>2; // 1point/2dB less signal
|
||||||
|
if(Packet.Header.Encrypted) return; // for exncrypted packets we only take signal strength
|
||||||
RxAltitude -= 10*Packet.DecodeAltitude(); // [0.1m] lower altitude => higher rank
|
RxAltitude -= 10*Packet.DecodeAltitude(); // [0.1m] lower altitude => higher rank
|
||||||
if(RxAltitude>0)
|
if(RxAltitude>0)
|
||||||
Rank += RxAltitude>>9; // 2points/100m of altitude below
|
Rank += RxAltitude>>9; // 2points/100m of altitude below
|
||||||
|
@ -643,7 +644,10 @@ template<class OGNx_Packet, uint8_t Size=8>
|
||||||
Out[Len++]=' '; Len+=Format_Hex(Out+Len, Rank); // print the slot Rank
|
Out[Len++]=' '; Len+=Format_Hex(Out+Len, Rank); // print the slot Rank
|
||||||
if(Rank) // if Rank is none-zero
|
if(Rank) // if Rank is none-zero
|
||||||
{ Out[Len++]='/'; Len+=Format_Hex(Out+Len, Packet[Idx].Packet.getAddressAndType() ); // print address-type and address
|
{ Out[Len++]='/'; Len+=Format_Hex(Out+Len, Packet[Idx].Packet.getAddressAndType() ); // print address-type and address
|
||||||
Out[Len++]=':'; Len+=Format_UnsDec(Out+Len, Packet[Idx].Packet.Position.Time, 2 ); } // [sec] print time
|
Out[Len++]=':';
|
||||||
|
if(Packet[Idx].Header.Encrypted) Len+=Format_String(Out+Len, "ee");
|
||||||
|
else Len+=Format_UnsDec(Out+Len, Packet[Idx].Packet.Position.Time, 2); // [sec] print time
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Out[Len++]=' '; Len+=Format_Hex(Out+Len, Sum); // sum of all Ranks
|
Out[Len++]=' '; Len+=Format_Hex(Out+Len, Sum); // sum of all Ranks
|
||||||
Out[Len++]='/'; Len+=Format_Hex(Out+Len, LowIdx); // index of the lowest Rank or a free slot
|
Out[Len++]='/'; Len+=Format_Hex(Out+Len, LowIdx); // index of the lowest Rank or a free slot
|
||||||
|
@ -798,9 +802,9 @@ class GPS_Time
|
||||||
return Same; } // return 1 when time did not change (both RMC and GGA were for same time)
|
return Same; } // return 1 when time did not change (both RMC and GGA were for same time)
|
||||||
|
|
||||||
int8_t ReadDate(const char *Param) // read the field DDMMYY
|
int8_t ReadDate(const char *Param) // read the field DDMMYY
|
||||||
{ Day=Read_Dec2(Param); if(Day<0) return -1; // read calendar year (two digits - thus need to be extended to four)
|
{ Day=Read_Dec2(Param); if(Day<0) return -1; // read calendar day
|
||||||
Month=Read_Dec2(Param+2); if(Month<0) return -1; // read calendar month
|
Month=Read_Dec2(Param+2); if(Month<0) return -1; // read calendar month
|
||||||
Year=Read_Dec2(Param+4); if(Year<0) return -1; // read calendar day
|
Year=Read_Dec2(Param+4); if(Year<0) return -1; // read calendar year (two digits - thus need to be extended to four)
|
||||||
return 0; } // return 0 when field valid and was read correctly
|
return 0; } // return 0 when field valid and was read correctly
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -135,7 +135,8 @@ static bool GetRelayPacket(OGN_TxPacket<OGN_Packet> *Packet) // prepare a p
|
||||||
memcpy(Packet->Packet.Byte(), RelayQueue[Idx]->Byte(), OGN_Packet::Bytes); // copy the packet
|
memcpy(Packet->Packet.Byte(), RelayQueue[Idx]->Byte(), OGN_Packet::Bytes); // copy the packet
|
||||||
Packet->Packet.Header.Relay=1; // increment the relay count (in fact we only do single relay)
|
Packet->Packet.Header.Relay=1; // increment the relay count (in fact we only do single relay)
|
||||||
// Packet->Packet.calcAddrParity();
|
// Packet->Packet.calcAddrParity();
|
||||||
Packet->Packet.Whiten(); Packet->calcFEC(); // whiten and calc. the FEC code => packet ready for transmission
|
if(!Packet->Packet.Header.Encrypted) Packet->Packet.Whiten(); // whiten but only for non-encrypted packets
|
||||||
|
Packet->calcFEC(); // Calc. the FEC code => packet ready for transmission
|
||||||
// PrintRelayQueue(Idx); // for debug
|
// PrintRelayQueue(Idx); // for debug
|
||||||
RelayQueue.decrRank(Idx); // reduce the rank of the packet selected for relay
|
RelayQueue.decrRank(Idx); // reduce the rank of the packet selected for relay
|
||||||
return 1; }
|
return 1; }
|
||||||
|
@ -330,10 +331,14 @@ static uint8_t WritePFLAU(char *NMEA, uint8_t GPS=1) // produce the (mostly d
|
||||||
|
|
||||||
static void ProcessRxPacket(OGN_RxPacket<OGN_Packet> *RxPacket, uint8_t RxPacketIdx, uint32_t RxTime) // process every (correctly) received packet
|
static void ProcessRxPacket(OGN_RxPacket<OGN_Packet> *RxPacket, uint8_t RxPacketIdx, uint32_t RxTime) // process every (correctly) received packet
|
||||||
{ int32_t LatDist=0, LonDist=0; uint8_t Warn=0;
|
{ int32_t LatDist=0, LonDist=0; uint8_t Warn=0;
|
||||||
if( RxPacket->Packet.Header.NonPos || RxPacket->Packet.Header.Encrypted ) return ; // status packet or encrypted: ignore
|
if( RxPacket->Packet.Header.NonPos /* || RxPacket->Packet.Header.Encrypted */ ) return ; // status packet or encrypted: ignore
|
||||||
uint8_t MyOwnPacket = ( RxPacket->Packet.Header.Address == Parameters.Address )
|
uint8_t MyOwnPacket = ( RxPacket->Packet.Header.Address == Parameters.Address )
|
||||||
&& ( RxPacket->Packet.Header.AddrType == Parameters.AddrType );
|
&& ( RxPacket->Packet.Header.AddrType == Parameters.AddrType );
|
||||||
if(MyOwnPacket) return; // don't process my own (relayed) packets
|
if(MyOwnPacket) return; // don't process my own (relayed) packets
|
||||||
|
if(RxPacket->Packet.Header.Encrypted && RxPacket->RxErr<10) // here we attempt to relay encrypted packets
|
||||||
|
{ RxPacket->calcRelayRank(GPS_Altitude/10);
|
||||||
|
OGN_RxPacket<OGN_Packet> *PrevRxPacket = RelayQueue.addNew(RxPacketIdx);
|
||||||
|
return; }
|
||||||
bool DistOK = RxPacket->Packet.calcDistanceVector(LatDist, LonDist, GPS_Latitude, GPS_Longitude, GPS_LatCosine)>=0;
|
bool DistOK = RxPacket->Packet.calcDistanceVector(LatDist, LonDist, GPS_Latitude, GPS_Longitude, GPS_LatCosine)>=0;
|
||||||
if(DistOK)
|
if(DistOK)
|
||||||
{ RxPacket->calcRelayRank(GPS_Altitude/10); // calculate the relay-rank (priority for relay)
|
{ RxPacket->calcRelayRank(GPS_Altitude/10); // calculate the relay-rank (priority for relay)
|
||||||
|
|
Ładowanie…
Reference in New Issue