diff --git a/main/ogn.h b/main/ogn.h index ab9831a..db8f10e 100644 --- a/main/ogn.h +++ b/main/ogn.h @@ -237,6 +237,7 @@ template if(Packet.Header.Relay) return; // no rank for relayed packets (only single relay) if(RxRSSI>128) // [-0.5dB] weaker signal => higher rank 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 if(RxAltitude>0) Rank += RxAltitude>>9; // 2points/100m of altitude below @@ -643,7 +644,10 @@ template Out[Len++]=' '; Len+=Format_Hex(Out+Len, Rank); // print the slot Rank 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_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, 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) 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 - 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 private: diff --git a/main/proc.cpp b/main/proc.cpp index b360197..19ba3b8 100644 --- a/main/proc.cpp +++ b/main/proc.cpp @@ -135,7 +135,8 @@ static bool GetRelayPacket(OGN_TxPacket *Packet) // prepare a p 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.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 RelayQueue.decrRank(Idx); // reduce the rank of the packet selected for relay 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 *RxPacket, uint8_t RxPacketIdx, uint32_t RxTime) // process every (correctly) received packet { 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 ) && ( RxPacket->Packet.Header.AddrType == Parameters.AddrType ); 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 *PrevRxPacket = RelayQueue.addNew(RxPacketIdx); + return; } bool DistOK = RxPacket->Packet.calcDistanceVector(LatDist, LonDist, GPS_Latitude, GPS_Longitude, GPS_LatCosine)>=0; if(DistOK) { RxPacket->calcRelayRank(GPS_Altitude/10); // calculate the relay-rank (priority for relay)