Skip to content

Commit

Permalink
Fix garbage in the first line of the downloaded APRS of IGC file
Browse files Browse the repository at this point in the history
  • Loading branch information
pjalocha committed Mar 6, 2021
1 parent fb7c0f0 commit 077688b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion main/http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -702,14 +702,15 @@ static esp_err_t SendLog_IGC(httpd_req_t *Req, const char *FileName, uint32_t Fi
FILE *File = fopen(FileName, "rb"); if(File==0) { httpd_resp_send_chunk(Req, 0, 0); return ESP_OK; }
// here we should write the IGC header
OGN_LogPacket<OGN_Packet> Packet;
Len=0;
for( ; ; )
{ if(fread(&Packet, Packet.Bytes, 1, File)!=1) break; // read the next packet
if(!Packet.isCorrect()) continue;
uint32_t Time = Packet.getTime(FileTime); // [sec] get exact time from short time in the packet and the file start time
Len+=Format_String(Line+Len, "LGNE "); // attach APRS as LGNE record
char *APRS=Line+Len;
Len+=Packet.Packet.WriteAPRS(Line+Len, Time); // packet in the APRS format
bool Own = Packet.Packet.Header.Address==Parameters.Address && Packet.Packet.Header.AddrType==Parameters.AddrType;
bool Own = Packet.Packet.Header.Address==Parameters.Address && Packet.Packet.Header.AddrType==Parameters.AddrType; //
if(Own && !Packet.Packet.Header.NonPos && !Packet.Packet.Header.Encrypted)
Len+=APRS2IGC(Line+Len, APRS, GPS_GeoidSepar); // IGC B-record
if(Len>=800) { httpd_resp_send_chunk(Req, Line, Len); Len=0; } // when more than 800 bytes then write this part to the socket
Expand All @@ -728,6 +729,7 @@ static esp_err_t SendLog_APRS(httpd_req_t *Req, const char *FileName, uint32_t F
httpd_resp_set_type(Req, "text/plain");
FILE *File = fopen(FileName, "rb"); if(File==0) { httpd_resp_send_chunk(Req, 0, 0); return ESP_OK; }
OGN_LogPacket<OGN_Packet> Packet;
Len=0;
for( ; ; )
{ if(fread(&Packet, Packet.Bytes, 1, File)!=1) break; // read the next packet
if(!Packet.isCorrect()) continue;
Expand Down

0 comments on commit 077688b

Please sign in to comment.