kopia lustrzana https://github.com/pjalocha/esp32-ogn-tracker
Handling of encrypted OGN packets
rodzic
8ebaedec4d
commit
ba86322585
38
main/ogn1.h
38
main/ogn1.h
|
@ -199,6 +199,25 @@ class OGN1_Packet // Packet structure for the OGN tracker
|
||||||
(1.0/64)*DecodeVoltage(), Status.TxPower+4, -0.5*Status.RadioNoise, (1<<Status.RxRate)-1 );
|
(1.0/64)*DecodeVoltage(), Status.TxPower+4, -0.5*Status.RadioNoise, (1<<Status.RxRate)-1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int WriteDeviceInfo(char *Out)
|
||||||
|
{ int Len=0;
|
||||||
|
char Value[16];
|
||||||
|
uint8_t InfoType;
|
||||||
|
uint8_t Idx=0;
|
||||||
|
for( ; ; )
|
||||||
|
{ uint8_t Chars = readInfo(Value, InfoType, Idx);
|
||||||
|
if(Chars==0) break;
|
||||||
|
Out[Len++]=' ';
|
||||||
|
if(InfoType<InfoParmNum)
|
||||||
|
{ Len += Format_String(Out+Len, InfoParmName(InfoType)); }
|
||||||
|
else
|
||||||
|
{ Out[Len++]='#'; Out[Len++]=HexDigit(InfoType); }
|
||||||
|
Out[Len++]='=';
|
||||||
|
Len += Format_String(Out+Len, Value);
|
||||||
|
Idx+=Chars; }
|
||||||
|
Out[Len]=0; return Len; }
|
||||||
|
|
||||||
|
/*
|
||||||
int WriteDeviceInfo(char *Out)
|
int WriteDeviceInfo(char *Out)
|
||||||
{ int Len=0;
|
{ int Len=0;
|
||||||
char Value[16];
|
char Value[16];
|
||||||
|
@ -211,9 +230,9 @@ class OGN1_Packet // Packet structure for the OGN tracker
|
||||||
{ Len += sprintf(Out+Len, " %s=%s", InfoParmName(InfoType), Value); }
|
{ Len += sprintf(Out+Len, " %s=%s", InfoParmName(InfoType), Value); }
|
||||||
else
|
else
|
||||||
{ Len += sprintf(Out+Len, " #%d=%s", InfoType, Value); }
|
{ Len += sprintf(Out+Len, " #%d=%s", InfoType, Value); }
|
||||||
Idx+=Chars; }
|
Idx+=Chars; }
|
||||||
Out[Len]=0; return Len; }
|
Out[Len]=0; return Len; }
|
||||||
|
*/
|
||||||
void Print(void) const
|
void Print(void) const
|
||||||
{ if(!Header.NonPos) { PrintPosition(); return; }
|
{ if(!Header.NonPos) { PrintPosition(); return; }
|
||||||
if(Status.ReportType==0) { PrintDeviceStatus(); return; }
|
if(Status.ReportType==0) { PrintDeviceStatus(); return; }
|
||||||
|
@ -518,17 +537,26 @@ class OGN1_Packet // Packet structure for the OGN tracker
|
||||||
{ memcpy(Msg+Len, ",RELAY*", 7); Len+=7; }
|
{ memcpy(Msg+Len, ",RELAY*", 7); Len+=7; }
|
||||||
Msg[Len++] = ':';
|
Msg[Len++] = ':';
|
||||||
|
|
||||||
if(Header.NonPos && Status.ReportType!=0) return 0; // give up if neither position nor status
|
if(Header.NonPos && Status.ReportType>1) { Msg[Len]=0; return 0; } // give up if neither position nor status nor info
|
||||||
|
|
||||||
if(Position.Time<60)
|
if(Position.Time<60)
|
||||||
{ uint32_t DayTime=Time%86400; int Sec=DayTime%60; // second of the time the packet was recevied
|
{ uint32_t DayTime=Time%86400; int Sec=DayTime%60; // second of the time the packet was recevied
|
||||||
int DiffSec=Position.Time-Sec; if(DiffSec>4) DiffSec-=60; // difference should always be zero or negative, but can be small positive for predicted positions
|
int DiffSec=Position.Time-Sec; if(DiffSec>4) DiffSec-=60; // difference should always be zero or negative, but can be small positive for predicted positions
|
||||||
Time+=DiffSec; } // get out the correct position time
|
Time+=DiffSec; } // get out the correct position time
|
||||||
Msg[Len++] = Header.NonPos?'>':'/';
|
Msg[Len++] = Header.NonPos || Header.Encrypted?'>':'/';
|
||||||
Len+=Format_HHMMSS(Msg+Len, Time);
|
Len+=Format_HHMMSS(Msg+Len, Time);
|
||||||
Msg[Len++] = 'h';
|
Msg[Len++] = 'h';
|
||||||
|
|
||||||
if(Header.NonPos) { Len+=WriteStatus(Msg+Len); Msg[Len++]='\n'; Msg[Len]=0; return Len; }
|
if(Header.NonPos) // status and info packets
|
||||||
|
{ if(Status.ReportType==0) Len+=WriteStatus(Msg+Len);
|
||||||
|
else Len+=WriteDeviceInfo(Msg+Len);
|
||||||
|
Msg[Len++]='\n'; Msg[Len]=0; return Len; }
|
||||||
|
|
||||||
|
if(Header.Encrypted) // encrypted packets
|
||||||
|
{ Msg[Len++]=' ';
|
||||||
|
for(int Idx=0; Idx<4; Idx++)
|
||||||
|
{ Len+=EncodeAscii85(Msg+Len, Data[Idx]); }
|
||||||
|
Msg[Len++]='\n'; Msg[Len]=0; return Len; }
|
||||||
|
|
||||||
const char *Icon = getAprsIcon(Position.AcftType);
|
const char *Icon = getAprsIcon(Position.AcftType);
|
||||||
|
|
||||||
|
|
|
@ -506,9 +506,10 @@ extern "C"
|
||||||
{ const uint8_t *PktData=TxPktData0;
|
{ const uint8_t *PktData=TxPktData0;
|
||||||
if(PktData==0) PktData=TxPktData1;
|
if(PktData==0) PktData=TxPktData1;
|
||||||
if(PktData) // if there is a packet to transmit
|
if(PktData) // if there is a packet to transmit
|
||||||
{ OGN1_Packet *OGN = (OGN1_Packet *)PktData; OGN->Dewhiten();
|
{ OGN1_Packet *OGN = (OGN1_Packet *)PktData; if(!OGN->Header.Encrypted) OGN->Dewhiten();
|
||||||
uint8_t *TxPacket;
|
uint8_t *TxPacket;
|
||||||
bool Short = !OGN->Header.NonPos && OGN->Header.AddrType==3 && OGN->Header.Address==(uint32_t)(getUniqueAddress()&0x00FFFFFF);
|
bool Short = !OGN->Header.NonPos && !OGN->Header.Encrypted
|
||||||
|
&& OGN->Header.AddrType==3 && OGN->Header.Address==(uint32_t)(getUniqueAddress()&0x00FFFFFF);
|
||||||
if(Short)
|
if(Short)
|
||||||
{ TxPktLen=WANdev.getDataPacket(&TxPacket, PktData+4, 16, 1, ((RX_Random>>16)&0xF)==0x8 ); }
|
{ TxPktLen=WANdev.getDataPacket(&TxPacket, PktData+4, 16, 1, ((RX_Random>>16)&0xF)==0x8 ); }
|
||||||
else
|
else
|
||||||
|
|
Ładowanie…
Reference in New Issue