kopia lustrzana https://github.com/pjalocha/esp32-ogn-tracker
Minor improvements, bug fixes, for higher GPS update rates, PAW TX
rodzic
0ef3ae4819
commit
4fc23fadcc
49
main/gps.cpp
49
main/gps.cpp
|
@ -76,7 +76,7 @@ static union
|
||||||
} ;
|
} ;
|
||||||
} GPS_Burst;
|
} GPS_Burst;
|
||||||
// for the autobaud on the GPS port
|
// for the autobaud on the GPS port
|
||||||
const int GPS_BurstTimeout = 200; // [ms]
|
const int GPS_BurstTimeout = 50; // [ms]
|
||||||
|
|
||||||
// static const uint8_t BaudRates=7; // number of possible baudrates choices
|
// static const uint8_t BaudRates=7; // number of possible baudrates choices
|
||||||
// static uint8_t BaudRateIdx=0; // actual choice
|
// static uint8_t BaudRateIdx=0; // actual choice
|
||||||
|
@ -287,22 +287,21 @@ static void GPS_BurstStart(void) // wh
|
||||||
}
|
}
|
||||||
UBX_RxMsg::Send(0x06, 0x08, GPS_UART_Write); // send the query for the navigation rate
|
UBX_RxMsg::Send(0x06, 0x08, GPS_UART_Write); // send the query for the navigation rate
|
||||||
UBX_RxMsg::Send(0x06, 0x24, GPS_UART_Write); // send the query for the navigation mode setting
|
UBX_RxMsg::Send(0x06, 0x24, GPS_UART_Write); // send the query for the navigation mode setting
|
||||||
if(!GPS_Status.NMEA) // if NMEA sentences are not there
|
UBX_RxMsg::Send(0x06, 0x3E, GPS_UART_Write); // send the query for the GNSS configuration
|
||||||
|
// if(!GPS_Status.NMEA) // if NMEA sentences are not there
|
||||||
{ UBX_CFG_MSG CFG_MSG; // send CFG_MSG to enable the NMEA sentences
|
{ UBX_CFG_MSG CFG_MSG; // send CFG_MSG to enable the NMEA sentences
|
||||||
CFG_MSG.msgClass = 0xF0; // NMEA class
|
CFG_MSG.msgClass = 0xF0; // NMEA class
|
||||||
CFG_MSG.rate = 1; // send every measurement event
|
CFG_MSG.rate = 1; // send every measurement event
|
||||||
// CFG_MSG.rate[0] = 1;
|
|
||||||
// CFG_MSG.rate[1] = 1;
|
|
||||||
// CFG_MSG.rate[2] = 1;
|
|
||||||
// CFG_MSG.rate[3] = 1;
|
|
||||||
// CFG_MSG.rate[4] = 1;
|
|
||||||
// CFG_MSG.rate[5] = 1;
|
|
||||||
CFG_MSG.msgID = 0x00; // ID for GGA
|
CFG_MSG.msgID = 0x00; // ID for GGA
|
||||||
UBX_RxMsg::Send(0x06, 0x01, GPS_UART_Write, (uint8_t *)(&CFG_MSG), sizeof(CFG_MSG));
|
UBX_RxMsg::Send(0x06, 0x01, GPS_UART_Write, (uint8_t *)(&CFG_MSG), sizeof(CFG_MSG));
|
||||||
CFG_MSG.msgID = 0x02; // ID for RMC
|
CFG_MSG.msgID = 0x02; // ID for RMC
|
||||||
UBX_RxMsg::Send(0x06, 0x01, GPS_UART_Write, (uint8_t *)(&CFG_MSG), sizeof(CFG_MSG));
|
UBX_RxMsg::Send(0x06, 0x01, GPS_UART_Write, (uint8_t *)(&CFG_MSG), sizeof(CFG_MSG));
|
||||||
CFG_MSG.msgID = 0x04; // ID for GSA
|
CFG_MSG.msgID = 0x04; // ID for GSA
|
||||||
UBX_RxMsg::Send(0x06, 0x01, GPS_UART_Write, (uint8_t *)(&CFG_MSG), sizeof(CFG_MSG));
|
UBX_RxMsg::Send(0x06, 0x01, GPS_UART_Write, (uint8_t *)(&CFG_MSG), sizeof(CFG_MSG));
|
||||||
|
CFG_MSG.rate = Parameters.NavRate*4; // send only at some interval
|
||||||
|
if(CFG_MSG.rate<4) CFG_MSG.rate=4;
|
||||||
|
CFG_MSG.msgID = 0x03; // ID for GSV
|
||||||
|
UBX_RxMsg::Send(0x06, 0x01, GPS_UART_Write, (uint8_t *)(&CFG_MSG), sizeof(CFG_MSG));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef WITH_GPS_MTK
|
#ifdef WITH_GPS_MTK
|
||||||
|
@ -483,18 +482,18 @@ static void GPS_BurstComplete(void) // wh
|
||||||
GPS_GeoidSepar=GPS_Pos[GPS_PosIdx].GeoidSeparation;
|
GPS_GeoidSepar=GPS_Pos[GPS_PosIdx].GeoidSeparation;
|
||||||
GPS_LatCosine=GPS_Pos[GPS_PosIdx].LatitudeCosine;
|
GPS_LatCosine=GPS_Pos[GPS_PosIdx].LatitudeCosine;
|
||||||
// GPS_FreqPlan=GPS_Pos[GPS_PosIdx].getFreqPlan();
|
// GPS_FreqPlan=GPS_Pos[GPS_PosIdx].getFreqPlan();
|
||||||
if(GPS_TimeSinceLock==1) // if we just acquired the lock a moment ago
|
if(GPS_TimeSinceLock==1) // if we just acquired the lock a moment ago
|
||||||
{ GPS_LockStart(); }
|
{ GPS_LockStart(); }
|
||||||
if(GPS_TimeSinceLock>1) // if the lock is more persistant
|
if(GPS_TimeSinceLock>1) // if the lock is more persistant
|
||||||
{ uint8_t PrevIdx=(GPS_PosIdx+PosPipeIdxMask)&PosPipeIdxMask;
|
{ uint8_t PrevIdx=(GPS_PosIdx+PosPipeIdxMask)&PosPipeIdxMask; // previous GPS data
|
||||||
int16_t TimeDiff = GPS_Pos[GPS_PosIdx].calcTimeDiff(GPS_Pos[PrevIdx]);
|
int16_t TimeDiff = GPS_Pos[GPS_PosIdx].calcTimeDiff(GPS_Pos[PrevIdx]); // difference in time
|
||||||
for( ; ; )
|
for( ; ; ) // loop
|
||||||
{ if(TimeDiff>=95) break;
|
{ if(TimeDiff>=95) break; // if at least 0.95sec then enough to calc. the differentials
|
||||||
uint8_t PrevIdx2=(PrevIdx+PosPipeIdxMask)&PosPipeIdxMask;
|
uint8_t PrevIdx2=(PrevIdx+PosPipeIdxMask)&PosPipeIdxMask; // go back one GPS position
|
||||||
if(PrevIdx2==GPS_PosIdx) break;
|
if(PrevIdx2==GPS_PosIdx) break; // if we looped all the way back: stop
|
||||||
if(!GPS_Pos[PrevIdx2].isValid()) break;
|
if(!GPS_Pos[PrevIdx2].isValid()) break; // if GPS position not valid: stop
|
||||||
TimeDiff = GPS_Pos[GPS_PosIdx].calcTimeDiff(GPS_Pos[PrevIdx2]);
|
TimeDiff = GPS_Pos[GPS_PosIdx].calcTimeDiff(GPS_Pos[PrevIdx2]); // time difference between the positions
|
||||||
PrevIdx=PrevIdx2; }
|
PrevIdx=PrevIdx2; } //
|
||||||
TimeDiff=GPS_Pos[GPS_PosIdx].calcDifferentials(GPS_Pos[PrevIdx]);
|
TimeDiff=GPS_Pos[GPS_PosIdx].calcDifferentials(GPS_Pos[PrevIdx]);
|
||||||
#ifdef DEBUG_PRINT
|
#ifdef DEBUG_PRINT
|
||||||
xSemaphoreTake(CONS_Mutex, portMAX_DELAY);
|
xSemaphoreTake(CONS_Mutex, portMAX_DELAY);
|
||||||
|
@ -591,11 +590,15 @@ static void GPS_NMEA(void) // wh
|
||||||
{ GPS_Status.NMEA=1;
|
{ GPS_Status.NMEA=1;
|
||||||
GPS_Status.BaudConfig = (GPS_getBaudRate() == GPS_TargetBaudRate);
|
GPS_Status.BaudConfig = (GPS_getBaudRate() == GPS_TargetBaudRate);
|
||||||
LED_PCB_Flash(10); // Flash the LED for 2 ms
|
LED_PCB_Flash(10); // Flash the LED for 2 ms
|
||||||
if(NMEA.isGxGSV()) ProcessGSV(NMEA); // process satellite data
|
if(NMEA.isGxGSV()) ProcessGSV(NMEA); // process satellite data
|
||||||
|
else if(NMEA.isGxRMC())
|
||||||
|
{ // if(GPS_Burst.GxRMC) { GPS_BurstComplete(); GPS_Burst.Flags=0; GPS_BurstStart(); }
|
||||||
|
GPS_Burst.GxRMC=1; }
|
||||||
|
else if(NMEA.isGxGGA())
|
||||||
|
{ // if(GPS_Burst.GxGGA) { GPS_BurstComplete(); GPS_Burst.Flags=0; GPS_BurstStart(); }
|
||||||
|
GPS_Burst.GxGGA=1; }
|
||||||
|
else if(NMEA.isGxGSA()) GPS_Burst.GxGSA=1;
|
||||||
GPS_Pos[GPS_PosIdx].ReadNMEA(NMEA); // read position elements from NMEA
|
GPS_Pos[GPS_PosIdx].ReadNMEA(NMEA); // read position elements from NMEA
|
||||||
if(NMEA.isGxRMC()) GPS_Burst.GxRMC=1;
|
|
||||||
if(NMEA.isGxGGA()) GPS_Burst.GxGGA=1;
|
|
||||||
if(NMEA.isGxGSA()) GPS_Burst.GxGSA=1;
|
|
||||||
#ifdef DEBUG_PRINT
|
#ifdef DEBUG_PRINT
|
||||||
xSemaphoreTake(CONS_Mutex, portMAX_DELAY);
|
xSemaphoreTake(CONS_Mutex, portMAX_DELAY);
|
||||||
Format_UnsDec(CONS_UART_Write, TimeSync_Time()%60, 2);
|
Format_UnsDec(CONS_UART_Write, TimeSync_Time()%60, 2);
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// extern uint8_t GPS_PowerMode; // 0=shutdown, 1=reduced, 2=normal
|
// extern uint8_t GPS_PowerMode; // 0=shutdown, 1=reduced, 2=normal
|
||||||
|
|
||||||
#ifdef WITH_ESP32
|
#ifdef WITH_ESP32
|
||||||
const uint8_t GPS_PosPipeSize = 8; // number of GPS positions held in a pipe
|
const uint8_t GPS_PosPipeSize = 16; // number of GPS positions held in a pipe
|
||||||
#else
|
#else
|
||||||
const uint8_t GPS_PosPipeSize = 4; // number of GPS positions held in a pipe
|
const uint8_t GPS_PosPipeSize = 4; // number of GPS positions held in a pipe
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -143,7 +143,7 @@ static void ParmForm_GPS(httpd_req_t *Req) // produce HTML form for GPS paramet
|
||||||
httpd_resp_send_chunk(Req, Line, Len);
|
httpd_resp_send_chunk(Req, Line, Len);
|
||||||
httpd_resp_sendstr_chunk(Req, "\"></td></tr>\n");
|
httpd_resp_sendstr_chunk(Req, "\"></td></tr>\n");
|
||||||
|
|
||||||
httpd_resp_sendstr_chunk(Req, "<tr><td>PPS delay</td><td><input type=\"text\" name=\"PPSdelay\" size=\"10\" value=\"0x");
|
httpd_resp_sendstr_chunk(Req, "<tr><td>PPS delay [ms]</td><td><input type=\"text\" name=\"PPSdelay\" size=\"10\" value=\"");
|
||||||
Len=Format_UnsDec(Line, Parameters.PPSdelay);
|
Len=Format_UnsDec(Line, Parameters.PPSdelay);
|
||||||
httpd_resp_send_chunk(Req, Line, Len);
|
httpd_resp_send_chunk(Req, Line, Len);
|
||||||
httpd_resp_sendstr_chunk(Req, "\"></td></tr>\n");
|
httpd_resp_sendstr_chunk(Req, "\"></td></tr>\n");
|
||||||
|
@ -551,6 +551,7 @@ static void Top_Bar(httpd_req_t *Req)
|
||||||
|
|
||||||
static esp_err_t parm_get_handler(httpd_req_t *Req)
|
static esp_err_t parm_get_handler(httpd_req_t *Req)
|
||||||
{ // char Line[32]; int Len;
|
{ // char Line[32]; int Len;
|
||||||
|
bool Restart=0;
|
||||||
uint16_t URLlen=httpd_req_get_url_query_len(Req);
|
uint16_t URLlen=httpd_req_get_url_query_len(Req);
|
||||||
if(URLlen)
|
if(URLlen)
|
||||||
{ char *URL = (char *)malloc(URLlen+1);
|
{ char *URL = (char *)malloc(URLlen+1);
|
||||||
|
@ -565,6 +566,7 @@ static esp_err_t parm_get_handler(httpd_req_t *Req)
|
||||||
xSemaphoreGive(CONS_Mutex);
|
xSemaphoreGive(CONS_Mutex);
|
||||||
#endif
|
#endif
|
||||||
char *Line=URL;
|
char *Line=URL;
|
||||||
|
Restart = strstr(Line,"Restart=1");
|
||||||
for( ; ; )
|
for( ; ; )
|
||||||
{ Parameters.ReadLine(Line);
|
{ Parameters.ReadLine(Line);
|
||||||
Line = strchr(Line, '&'); if(Line==0) break;
|
Line = strchr(Line, '&'); if(Line==0) break;
|
||||||
|
@ -600,21 +602,36 @@ static esp_err_t parm_get_handler(httpd_req_t *Req)
|
||||||
#endif
|
#endif
|
||||||
ParmForm_Other(Req);
|
ParmForm_Other(Req);
|
||||||
httpd_resp_sendstr_chunk(Req, "</td></tr>\n<tr><td>\n");
|
httpd_resp_sendstr_chunk(Req, "</td></tr>\n<tr><td>\n");
|
||||||
httpd_resp_sendstr_chunk(Req, "<form action=\"/parm.html\" method=\"get\">\n");
|
httpd_resp_sendstr_chunk(Req, "\
|
||||||
httpd_resp_sendstr_chunk(Req, "<input type=\"submit\" value=\"Reset to defaults\">\n");
|
<form action=\"/parm.html\" method=\"get\">\n\
|
||||||
httpd_resp_sendstr_chunk(Req, "<input type=\"hidden\" name=\"Defaults\" value=\"1\">\n");
|
<input type=\"submit\" value=\"Reset to defaults\">\n\
|
||||||
httpd_resp_sendstr_chunk(Req, "</form>\n");
|
<input type=\"hidden\" name=\"Defaults\" value=\"1\">\n\
|
||||||
|
</form>\n");
|
||||||
|
// httpd_resp_sendstr_chunk(Req, "<form action=\"/parm.html\" method=\"get\">\n");
|
||||||
|
// httpd_resp_sendstr_chunk(Req, "<input type=\"submit\" value=\"Reset to defaults\">\n");
|
||||||
|
// httpd_resp_sendstr_chunk(Req, "<input type=\"hidden\" name=\"Defaults\" value=\"1\">\n");
|
||||||
|
// httpd_resp_sendstr_chunk(Req, "</form>\n");
|
||||||
|
httpd_resp_sendstr_chunk(Req, "\
|
||||||
|
<form action=\"/parm.html\" method=\"get\">\n\
|
||||||
|
<input type=\"submit\" value=\"Restart\">\n\
|
||||||
|
<input type=\"hidden\" name=\"Restart\" value=\"1\">\n\
|
||||||
|
</form>\n");
|
||||||
|
// httpd_resp_sendstr_chunk(Req, "<form action=\"/parm.html\" method=\"get\">\n");
|
||||||
|
// httpd_resp_sendstr_chunk(Req, "<input type=\"submit\" value=\"Restart\">\n");
|
||||||
|
// httpd_resp_sendstr_chunk(Req, "<input type=\"hidden\" name=\"Restart\" value=\"1\">\n");
|
||||||
|
// httpd_resp_sendstr_chunk(Req, "</form>\n");
|
||||||
httpd_resp_sendstr_chunk(Req, "</td></tr>\n</table>\n");
|
httpd_resp_sendstr_chunk(Req, "</td></tr>\n</table>\n");
|
||||||
httpd_resp_sendstr_chunk(Req, "</body>\n</html>\n");
|
httpd_resp_sendstr_chunk(Req, "</body>\n</html>\n");
|
||||||
|
|
||||||
/*
|
|
||||||
httpd_resp_sendstr_chunk(Req, "<form action=\"/parm.html\" method=\"get\">\n");
|
|
||||||
httpd_resp_sendstr_chunk(Req, "<input type=\"submit\" value=\"Restart\">\n");
|
|
||||||
httpd_resp_sendstr_chunk(Req, "<input type=\"hidden\" name=\"Restart\" value=\"1\">");
|
|
||||||
httpd_resp_sendstr_chunk(Req, "</form>\n");
|
|
||||||
*/
|
|
||||||
// httpd_resp_sendstr_chunk(Req, 0);
|
|
||||||
httpd_resp_send_chunk(Req, 0, 0);
|
httpd_resp_send_chunk(Req, 0, 0);
|
||||||
|
|
||||||
|
if(Restart)
|
||||||
|
{
|
||||||
|
#ifdef WITH_SPIFFS
|
||||||
|
FlashLog_SaveReq=1;
|
||||||
|
#endif
|
||||||
|
vTaskDelay(1000);
|
||||||
|
esp_restart(); }
|
||||||
|
|
||||||
return ESP_OK; }
|
return ESP_OK; }
|
||||||
|
|
||||||
static esp_err_t top_get_handler(httpd_req_t *Req)
|
static esp_err_t top_get_handler(httpd_req_t *Req)
|
||||||
|
|
|
@ -96,7 +96,11 @@ class LookOut_Target
|
||||||
NMEA[Len++]=',';
|
NMEA[Len++]=',';
|
||||||
Len+=Format_SignDec(NMEA+Len, dZ/2); // [m] relative altitude
|
Len+=Format_SignDec(NMEA+Len, dZ/2); // [m] relative altitude
|
||||||
NMEA[Len++]=',';
|
NMEA[Len++]=',';
|
||||||
NMEA[Len++]='0'+((ID>>24)&0x03); // address-type (3=OGN)
|
uint8_t AddrType = (ID>>24)&0x03;
|
||||||
|
#ifdef WITH_SKYDEMON // SkyDemon hack which accepts only 1 or 2
|
||||||
|
if(AddrType!=1) AddrType=2;
|
||||||
|
#endif
|
||||||
|
NMEA[Len++]='0'+AddrType; // address-type (3=OGN)
|
||||||
NMEA[Len++]=',';
|
NMEA[Len++]=',';
|
||||||
uint32_t Addr = ID&0xFFFFFF; // [24-bit] address
|
uint32_t Addr = ID&0xFFFFFF; // [24-bit] address
|
||||||
Len+=Format_Hex(NMEA+Len, (uint8_t)(Addr>>16)); // 24-bit address: RND, ICAO, FLARM, OGN
|
Len+=Format_Hex(NMEA+Len, (uint8_t)(Addr>>16)); // 24-bit address: RND, ICAO, FLARM, OGN
|
||||||
|
@ -229,7 +233,11 @@ class LookOut
|
||||||
{ Len+=Format_UnsDec(NMEA+Len, (Tgt->HorDist)>>1, 1); }
|
{ Len+=Format_UnsDec(NMEA+Len, (Tgt->HorDist)>>1, 1); }
|
||||||
NMEA[Len++]=',';
|
NMEA[Len++]=',';
|
||||||
if(Tgt) // ID
|
if(Tgt) // ID
|
||||||
|
#ifdef WITH_SKYDEMON
|
||||||
|
{ Len+=Format_Hex(NMEA+Len, Tgt->ID & 0x00FFFFFF); }
|
||||||
|
#else
|
||||||
{ Len+=Format_Hex(NMEA+Len, Tgt->ID); }
|
{ Len+=Format_Hex(NMEA+Len, Tgt->ID); }
|
||||||
|
#endif
|
||||||
Len+=NMEA_AppendCheckCRNL(NMEA, Len);
|
Len+=NMEA_AppendCheckCRNL(NMEA, Len);
|
||||||
NMEA[Len]=0;
|
NMEA[Len]=0;
|
||||||
return Len; }
|
return Len; }
|
||||||
|
|
14
main/ogn.h
14
main/ogn.h
|
@ -425,19 +425,23 @@ template <class OGNx_Packet=OGN1_Packet>
|
||||||
|
|
||||||
uint8_t WritePFLAA(char *NMEA, uint8_t Status, int32_t LatDist, int32_t LonDist, int32_t AltDist)
|
uint8_t WritePFLAA(char *NMEA, uint8_t Status, int32_t LatDist, int32_t LonDist, int32_t AltDist)
|
||||||
{ uint8_t Len=0;
|
{ uint8_t Len=0;
|
||||||
Len+=Format_String(NMEA+Len, "$PFLAA,"); // sentence name and alarm-level (but no alarms for trackers)
|
Len+=Format_String(NMEA+Len, "$PFLAA,"); // sentence name and alarm-level (but no alarms for trackers)
|
||||||
NMEA[Len++]='0'+Status;
|
NMEA[Len++]='0'+Status;
|
||||||
NMEA[Len++]=',';
|
NMEA[Len++]=',';
|
||||||
Len+=Format_SignDec(NMEA+Len, LatDist);
|
Len+=Format_SignDec(NMEA+Len, LatDist);
|
||||||
NMEA[Len++]=',';
|
NMEA[Len++]=',';
|
||||||
Len+=Format_SignDec(NMEA+Len, LonDist);
|
Len+=Format_SignDec(NMEA+Len, LonDist);
|
||||||
NMEA[Len++]=',';
|
NMEA[Len++]=',';
|
||||||
Len+=Format_SignDec(NMEA+Len, AltDist); // [m] relative altitude
|
Len+=Format_SignDec(NMEA+Len, AltDist); // [m] relative altitude
|
||||||
NMEA[Len++]=',';
|
NMEA[Len++]=',';
|
||||||
NMEA[Len++]='0'+Packet.Header.AddrType; // address-type (3=OGN)
|
uint8_t AddrType = Packet.Header.AddrType;
|
||||||
|
#ifdef WITH_SKYDEMON
|
||||||
|
if(AddrType!=1) AddrType=2; // SkyDemon only accepts 1 or 2
|
||||||
|
#endif
|
||||||
|
NMEA[Len++]='0'+AddrType; // address-type (3=OGN)
|
||||||
NMEA[Len++]=',';
|
NMEA[Len++]=',';
|
||||||
uint32_t Addr = Packet.Header.Address; // [24-bit] address
|
uint32_t Addr = Packet.Header.Address; // [24-bit] address
|
||||||
Len+=Format_Hex(NMEA+Len, (uint8_t)(Addr>>16)); // XXXXXX 24-bit address: RND, ICAO, FLARM, OGN
|
Len+=Format_Hex(NMEA+Len, (uint8_t)(Addr>>16)); // XXXXXX 24-bit address: RND, ICAO, FLARM, OGN
|
||||||
Len+=Format_Hex(NMEA+Len, (uint16_t)Addr);
|
Len+=Format_Hex(NMEA+Len, (uint16_t)Addr);
|
||||||
NMEA[Len++]=',';
|
NMEA[Len++]=',';
|
||||||
Len+=Format_UnsDec(NMEA+Len, Packet.DecodeHeading(), 4, 1); // [deg] heading (by GPS)
|
Len+=Format_UnsDec(NMEA+Len, Packet.DecodeHeading(), 4, 1); // [deg] heading (by GPS)
|
||||||
|
@ -451,7 +455,7 @@ template <class OGNx_Packet=OGN1_Packet>
|
||||||
NMEA[Len++]=HexDigit(Packet.Position.AcftType); // [0..F] aircraft-type: 1=glider, 2=tow plane, etc.
|
NMEA[Len++]=HexDigit(Packet.Position.AcftType); // [0..F] aircraft-type: 1=glider, 2=tow plane, etc.
|
||||||
Len+=NMEA_AppendCheckCRNL(NMEA, Len);
|
Len+=NMEA_AppendCheckCRNL(NMEA, Len);
|
||||||
NMEA[Len]=0;
|
NMEA[Len]=0;
|
||||||
return Len; } // return number of formatted characters
|
return Len; } // return number of formatted characters
|
||||||
|
|
||||||
void Print(void) const
|
void Print(void) const
|
||||||
{ printf("[%02d/%+6.1fdBm/%2d] ", RxChan, -0.5*RxRSSI, RxErr);
|
{ printf("[%02d/%+6.1fdBm/%2d] ", RxChan, -0.5*RxRSSI, RxErr);
|
||||||
|
|
52
main/paw.h
52
main/paw.h
|
@ -74,7 +74,7 @@ class PAW_Packet
|
||||||
// uint32_t getAddress(void) const { return Address>>8; } // remove the sync '$'
|
// uint32_t getAddress(void) const { return Address>>8; } // remove the sync '$'
|
||||||
// void setAddress(uint32_t Addr) { Address = (Addr<<8) | 0x24; } // set new address and set the '$' sync char
|
// void setAddress(uint32_t Addr) { Address = (Addr<<8) | 0x24; } // set new address and set the '$' sync char
|
||||||
|
|
||||||
int Copy(const OGN1_Packet &Packet, bool Ext=1)
|
int Copy(const OGN1_Packet &Packet, bool Ext=0)
|
||||||
{ Clear();
|
{ Clear();
|
||||||
Address = Packet.Header.Address; // [24-bit]
|
Address = Packet.Header.Address; // [24-bit]
|
||||||
if(Packet.Header.NonPos) return 0; // encode only position packets
|
if(Packet.Header.NonPos) return 0; // encode only position packets
|
||||||
|
@ -97,6 +97,33 @@ class PAW_Packet
|
||||||
SeqMsg = 0;
|
SeqMsg = 0;
|
||||||
setCRC(); return 1; }
|
setCRC(); return 1; }
|
||||||
|
|
||||||
|
int WriteJSON(char *JSON) const
|
||||||
|
{ int Len=0;
|
||||||
|
Len+=Format_String(JSON+Len, "\"addr\":\"");
|
||||||
|
Len+=Format_Hex(JSON+Len, (uint8_t) (Address>>16));
|
||||||
|
Len+=Format_Hex(JSON+Len, (uint16_t)(Address));
|
||||||
|
JSON[Len++]='\"';
|
||||||
|
Len+=Format_String(JSON+Len, ",\"addr_type\":");
|
||||||
|
JSON[Len++] = HexDigit(getAddrType());
|
||||||
|
Len+=Format_String(JSON+Len, ",\"acft_type\":\"");
|
||||||
|
JSON[Len++] = HexDigit(AcftType);
|
||||||
|
JSON[Len++]='\"';
|
||||||
|
Len+=Format_String(JSON+Len, ",\"acft_cat\":\""); // GDL90 aircraft category
|
||||||
|
// no-info, glider, tow, heli, parachute, drop-plane, hang-glider, para-glider, powered, jet, UFO, balloon, Zeppelin, UAV, ground vehicle, static } ;
|
||||||
|
const uint8_t AcftCat[16] = { 0, 9, 1, 7, 11, 1, 12, 12, 1, 2, 0, 10, 10, 14, 18, 19 } ;
|
||||||
|
Len+=Format_Hex(JSON+Len, AcftCat[AcftType]);
|
||||||
|
JSON[Len++]='\"';
|
||||||
|
// uint32_t PosTime=Time; if(nsTime<300000000) PosTime--;
|
||||||
|
// Len+=Format_String(JSON+Len, ",\"time\":");
|
||||||
|
// Len+=Format_UnsDec(JSON+Len, PosTime);
|
||||||
|
// int64_t RxTime=(int64_t)Time-PosTime; RxTime*=1000; RxTime+=nsTime/1000000;
|
||||||
|
// Len+=Format_String(JSON+Len, ",\"rx_time\":");
|
||||||
|
// Len+=Format_SignDec(JSON+Len, RxTime, 4, 3, 1);
|
||||||
|
Len+=sprintf(JSON+Len, ",\"lat_deg\":%8.7f,\"lon_deg\":%8.7f,\"alt_msl_m\":%d", Latitude, Longitude, Altitude);
|
||||||
|
Len+=sprintf(JSON+Len, ",\"track_deg\":%d,\"speed_mps\":%3.1f", Heading, 0.514*Speed);
|
||||||
|
if(OGN) Len+=sprintf(JSON+Len, ",\"climb_mps\":%3.1f", 0.32512*Climb);
|
||||||
|
return Len; }
|
||||||
|
|
||||||
uint8_t Dump(char *Out)
|
uint8_t Dump(char *Out)
|
||||||
{ uint8_t Len=0;
|
{ uint8_t Len=0;
|
||||||
for(int Idx=0; Idx<Size; Idx++)
|
for(int Idx=0; Idx<Size; Idx++)
|
||||||
|
@ -191,32 +218,15 @@ class PAW_RxPacket // Received PilotAware packet
|
||||||
Packet.Seq, 0.25*SNR, 0.5*CSNR, 0.01*FreqOfs); }
|
Packet.Seq, 0.25*SNR, 0.5*CSNR, 0.01*FreqOfs); }
|
||||||
|
|
||||||
int WriteJSON(char *JSON) const
|
int WriteJSON(char *JSON) const
|
||||||
{ int Len=0;
|
{ int Len = Packet.WriteJSON(JSON);
|
||||||
Len+=Format_String(JSON+Len, "\"addr\":\"");
|
|
||||||
uint32_t Address = Packet.Address;
|
|
||||||
Len+=Format_Hex(JSON+Len, (uint8_t) (Address>>16));
|
|
||||||
Len+=Format_Hex(JSON+Len, (uint16_t)(Address));
|
|
||||||
JSON[Len++]='\"';
|
|
||||||
Len+=Format_String(JSON+Len, ",\"addr_type\":");
|
|
||||||
JSON[Len++] = HexDigit(Packet.getAddrType());
|
|
||||||
Len+=Format_String(JSON+Len, ",\"acft_type\":\"");
|
|
||||||
JSON[Len++] = HexDigit(Packet.AcftType);
|
|
||||||
JSON[Len++]='\"';
|
|
||||||
Len+=Format_String(JSON+Len, ",\"acft_cat\":\""); // GDL90 aircraft category
|
|
||||||
// no-info, glider, tow, heli, parachute, drop-plane, hang-glider, para-glider, powered, jet, UFO, balloon, Zeppelin, UAV, ground vehicle, static } ;
|
|
||||||
const uint8_t AcftCat[16] = { 0, 9, 1, 7, 11, 1, 12, 12, 1, 2, 0, 10, 10, 14, 18, 19 } ;
|
|
||||||
Len+=Format_Hex(JSON+Len, AcftCat[Packet.AcftType]);
|
|
||||||
JSON[Len++]='\"';
|
|
||||||
uint32_t PosTime=Time; if(nsTime<300000000) PosTime--;
|
uint32_t PosTime=Time; if(nsTime<300000000) PosTime--;
|
||||||
// if(OGN)
|
if(Packet.OGN)
|
||||||
|
{ }
|
||||||
Len+=Format_String(JSON+Len, ",\"time\":");
|
Len+=Format_String(JSON+Len, ",\"time\":");
|
||||||
Len+=Format_UnsDec(JSON+Len, PosTime);
|
Len+=Format_UnsDec(JSON+Len, PosTime);
|
||||||
int64_t RxTime=(int64_t)Time-PosTime; RxTime*=1000; RxTime+=nsTime/1000000;
|
int64_t RxTime=(int64_t)Time-PosTime; RxTime*=1000; RxTime+=nsTime/1000000;
|
||||||
Len+=Format_String(JSON+Len, ",\"rx_time\":");
|
Len+=Format_String(JSON+Len, ",\"rx_time\":");
|
||||||
Len+=Format_SignDec(JSON+Len, RxTime, 4, 3, 1);
|
Len+=Format_SignDec(JSON+Len, RxTime, 4, 3, 1);
|
||||||
Len+=sprintf(JSON+Len, ",\"lat_deg\":%8.7f,\"lon_deg\":%8.7f,\"alt_msl_m\":%d", Packet.Latitude, Packet.Longitude, Packet.Altitude);
|
|
||||||
Len+=sprintf(JSON+Len, ",\"track_deg\":%d,\"speed_mps\":%3.1f", Packet.Heading, 0.514*Packet.Speed);
|
|
||||||
if(Packet.OGN) Len+=sprintf(JSON+Len, ",\"climb_mps\":%3.1f", 0.32512*Packet.Climb);
|
|
||||||
return Len; }
|
return Len; }
|
||||||
|
|
||||||
} ;
|
} ;
|
||||||
|
|
|
@ -496,7 +496,7 @@ extern "C"
|
||||||
OGN1_Packet TxPkt = TxPkt0->Packet;
|
OGN1_Packet TxPkt = TxPkt0->Packet;
|
||||||
TxPkt.Dewhiten();
|
TxPkt.Dewhiten();
|
||||||
XorShift32(RX_Random);
|
XorShift32(RX_Random);
|
||||||
if(!TxPkt.Header.Relay && (RX_Random&0xC0)==0x00 && Packet.Copy(TxPkt))
|
if(!TxPkt.Header.Relay && (RX_Random&0xC0)==0x00 && Packet.Copy(TxPkt) && TxPkt.Position.Time<60)
|
||||||
{ TRX.WriteMode(RF_OPMODE_STANDBY);
|
{ TRX.WriteMode(RF_OPMODE_STANDBY);
|
||||||
TRX.PAW_Configure(PAW_SYNC);
|
TRX.PAW_Configure(PAW_SYNC);
|
||||||
TRX.WriteTxPower(Parameters.TxPower+6);
|
TRX.WriteTxPower(Parameters.TxPower+6);
|
||||||
|
|
|
@ -21,7 +21,7 @@ static FILE *LogFile = 0;
|
||||||
|
|
||||||
static uint16_t LogDate = 0; // [~days] date = FatTime>>16
|
static uint16_t LogDate = 0; // [~days] date = FatTime>>16
|
||||||
static TickType_t LogOpenTime; // [msec] when was the log file (re)open
|
static TickType_t LogOpenTime; // [msec] when was the log file (re)open
|
||||||
static const TickType_t LogReopen = 20000; // [msec] when to close and re-open the log file
|
static const TickType_t LogReopen = 30000; // [msec] when to close and re-open the log file
|
||||||
|
|
||||||
const size_t FIFOsize = 16384;
|
const size_t FIFOsize = 16384;
|
||||||
static FIFO<char, FIFOsize> Log_FIFO; // 16K buffer for SD-log
|
static FIFO<char, FIFOsize> Log_FIFO; // 16K buffer for SD-log
|
||||||
|
|
|
@ -168,7 +168,7 @@ class UBX_CFG_PRT // 0x06 0x00
|
||||||
|
|
||||||
class UBX_CFG_MSG // 0x06 0x01
|
class UBX_CFG_MSG // 0x06 0x01
|
||||||
{ public:
|
{ public:
|
||||||
uint8_t msgClass; // 0xF0:00=GGA, 0xF0:02=GSA, 0xF0:04=RMC, 0xF0:41=TXT
|
uint8_t msgClass; // 0xF0:00=GGA, 0xF0:02=GSA, 0xF0:03=GSV, 0xF0:04=RMC, 0xF0:41=TXT
|
||||||
uint8_t msgID;
|
uint8_t msgID;
|
||||||
uint8_t rate; // message send rate
|
uint8_t rate; // message send rate
|
||||||
} ;
|
} ;
|
||||||
|
|
Ładowanie…
Reference in New Issue