Set UBX NavRate and NavMode, add HTTP setup manu for those

pull/30/head
Pawel Jalocha 2020-12-01 01:04:11 +00:00
rodzic 5aa91dd9a8
commit c3e7a235e2
6 zmienionych plików z 123 dodań i 17 usunięć

Wyświetl plik

@ -60,8 +60,8 @@
#define WITH_LORAWAN #define WITH_LORAWAN
#define WITH_AP #define WITH_AP // creat WiFi Access Point for data, setup and log files
// #define WITH_STRATUX // #define WITH_STRATUX // connect to Stratux WiFi as a client
// #define WITH_BT_SPP // Bluetooth serial port for smartphone/tablet link // #define WITH_BT_SPP // Bluetooth serial port for smartphone/tablet link
// #define WITH_APRS // attempt to connect to the wifi router for uploading the log files to APRS // #define WITH_APRS // attempt to connect to the wifi router for uploading the log files to APRS

Wyświetl plik

@ -24,10 +24,10 @@
// #define DEBUG_PRINT // #define DEBUG_PRINT
#ifdef DEBUG_PRINT // #ifdef DEBUG_PRINT
static char Line[128]; static char Line[128];
static void CONS_HexDump(char Byte) { Format_Hex(CONS_UART_Write, (uint8_t)Byte); } static void CONS_HexDump(char Byte) { Format_Hex(CONS_UART_Write, (uint8_t)Byte); }
#endif // #endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -255,6 +255,28 @@ static void GPS_BurstStart(void) // wh
{ if(!GPS_Status.ModeConfig) // if GPS navigation mode is not done yet { if(!GPS_Status.ModeConfig) // if GPS navigation mode is not done yet
{ // Format_String(CONS_UART_Write, "CFG_NAV5 query...\n"); { // Format_String(CONS_UART_Write, "CFG_NAV5 query...\n");
#ifdef WITH_GPS_UBX #ifdef WITH_GPS_UBX
if(Parameters.NavRate)
{ UBX_CFG_RATE CFG_RATE;
CFG_RATE.measRate = 1000/Parameters.NavRate;
CFG_RATE.navRate = 1;
CFG_RATE.timeRef = 0;
UBX_RxMsg::Send(0x06, 0x08, GPS_UART_Write, (uint8_t*)(&CFG_RATE), sizeof(CFG_RATE));
// #ifdef DEBUG_PRINT
Format_String(CONS_UART_Write, "GPS <- CFG-RATE: ");
UBX_RxMsg::Send(0x06, 0x08, CONS_HexDump, (uint8_t*)(&CFG_RATE), sizeof(CFG_RATE));
Format_String(CONS_UART_Write, "\n");
// #endif
}
{ UBX_CFG_NAV5 CFG_NAV5;
CFG_NAV5.setDynModel(Parameters.NavMode);
UBX_RxMsg::Send(0x06, 0x24, GPS_UART_Write, (uint8_t*)(&CFG_NAV5), sizeof(CFG_NAV5));
// #ifdef DEBUG_PRINT
Format_String(CONS_UART_Write, "GPS <- CFG-NAV5: ");
UBX_RxMsg::Send(0x06, 0x24, CONS_HexDump, (uint8_t*)(&CFG_NAV5), sizeof(CFG_NAV5));
Format_String(CONS_UART_Write, "\n");
// #endif
}
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 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

Wyświetl plik

@ -23,6 +23,7 @@
// ============================================================================================================ // ============================================================================================================
// generic HTML list for submit forms
static void SelectList(httpd_req_t *Req, const char *Name, const char **List, int Size, int Sel=0) static void SelectList(httpd_req_t *Req, const char *Name, const char **List, int Size, int Sel=0)
{ char Line[64]; int Len; { char Line[64]; int Len;
Len =Format_String(Line, "<select name=\""); Len =Format_String(Line, "<select name=\"");
@ -40,7 +41,8 @@ static void SelectList(httpd_req_t *Req, const char *Name, const char **List, in
httpd_resp_send_chunk(Req, Line, Len); } httpd_resp_send_chunk(Req, Line, Len); }
httpd_resp_sendstr_chunk(Req, "</select>\n"); } httpd_resp_sendstr_chunk(Req, "</select>\n"); }
static void ParmForm_Info(httpd_req_t *Req) // produce HTML form for aircraft parameters // HTML form for the Info parameters
static void ParmForm_Info(httpd_req_t *Req)
{ {
httpd_resp_sendstr_chunk(Req, "<form action=\"/parm.html\" method=\"get\" id=\"Info\">\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\">\n"); httpd_resp_sendstr_chunk(Req, "<form action=\"/parm.html\" method=\"get\" id=\"Info\">\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\">\n");
httpd_resp_sendstr_chunk(Req, "<tr><th><b>Info</th><td><input type=\"submit\" value=\"Apply\"></td></tr>\n"); httpd_resp_sendstr_chunk(Req, "<tr><th><b>Info</th><td><input type=\"submit\" value=\"Apply\"></td></tr>\n");
@ -75,7 +77,8 @@ static void ParmForm_Info(httpd_req_t *Req) // produce HTML form for aircraft p
httpd_resp_sendstr_chunk(Req, "</table></form>\n"); } httpd_resp_sendstr_chunk(Req, "</table></form>\n"); }
static void ParmForm_Acft(httpd_req_t *Req) // produce HTML form for aircraft parameters // HTML form for the Aircraft identification: address, address-type, aircraft-type
static void ParmForm_Acft(httpd_req_t *Req)
{ char Line[16]; { char Line[16];
httpd_resp_sendstr_chunk(Req, "<form action=\"/parm.html\" method=\"get\" id=\"Acft\">\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\">\n"); httpd_resp_sendstr_chunk(Req, "<form action=\"/parm.html\" method=\"get\" id=\"Acft\">\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\">\n");
@ -99,13 +102,51 @@ static void ParmForm_Acft(httpd_req_t *Req) // produce HTML form for aircraft p
httpd_resp_sendstr_chunk(Req, "</table></form>\n"); } httpd_resp_sendstr_chunk(Req, "</table></form>\n"); }
static void ParmForm_GPS(httpd_req_t *Req) // produce HTML form for GPS parameters
{ char Line[16]; int Len;
httpd_resp_sendstr_chunk(Req, "<form action=\"/parm.html\" method=\"get\" id=\"GPS\">\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\">\n");
#ifdef WITH_GPS_UBX
httpd_resp_sendstr_chunk(Req, "<tr><th><b>GPS: UBX</th><td><input type=\"submit\" value=\"Apply\"></td></tr>\n");
#else
#ifdef WITH_GPS_MTK
httpd_resp_sendstr_chunk(Req, "<tr><th><b>GPS: MTK</th><td><input type=\"submit\" value=\"Apply\"></td></tr>\n");
#else
httpd_resp_sendstr_chunk(Req, "<tr><th><b>GPS</th><td><input type=\"submit\" value=\"Apply\"></td></tr>\n");
#endif
#endif
httpd_resp_sendstr_chunk(Req, "<tr><td>Nav. rate [Hz]</td><td><input type=\"text\" name=\"NavRate\" size=\"10\" value=\"");
Len=Format_UnsDec(Line, Parameters.NavRate);
httpd_resp_send_chunk(Req, Line, Len);
httpd_resp_sendstr_chunk(Req, "\"></td></tr>\n");
httpd_resp_sendstr_chunk(Req, "<tr><td>Nav. mode</td><td><input type=\"text\" name=\"NavMode\" size=\"10\" value=\"");
Len=Format_UnsDec(Line, Parameters.NavMode);
httpd_resp_send_chunk(Req, Line, Len);
httpd_resp_sendstr_chunk(Req, "\"></td></tr>\n");
httpd_resp_sendstr_chunk(Req, "<tr><td>Geoid-Separ.</td><td>\n");
const char *GeoidSeparTable[2] = { "GPS", "Override" } ;
SelectList(Req, "manGeoidSepar", GeoidSeparTable, 2, Parameters.manGeoidSepar);
httpd_resp_sendstr_chunk(Req, "<input type=\"text\" name=\"GeoidSepar\" size=\"3\" value=\"");
Len=Format_SignDec(Line, Parameters.GeoidSepar, 2, 1);
httpd_resp_send_chunk(Req, Line, Len);
httpd_resp_sendstr_chunk(Req, "\">\n");
httpd_resp_sendstr_chunk(Req, "</td></tr>\n");
httpd_resp_sendstr_chunk(Req, "</table></form>\n"); }
static void ParmForm_Other(httpd_req_t *Req) // produce HTML form for aircraft parameters static void ParmForm_Other(httpd_req_t *Req) // produce HTML form for aircraft parameters
{ char Line[16]; int Len; { char Line[16]; int Len;
httpd_resp_sendstr_chunk(Req, "<form action=\"/parm.html\" method=\"get\" id=\"Other\">\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\">\n"); httpd_resp_sendstr_chunk(Req, "<form action=\"/parm.html\" method=\"get\" id=\"Other\">\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\">\n");
httpd_resp_sendstr_chunk(Req, "<tr><th><b>Other</th><td><input type=\"submit\" value=\"Apply\"></td></tr>\n"); httpd_resp_sendstr_chunk(Req, "<tr><th><b>Other</th><td><input type=\"submit\" value=\"Apply\"></td></tr>\n");
const char *FreqPlanTable[16] = { "Auto", "Europe/Africa", "USA/Canada", "Australia/Chile", "New Zeeland", "Izrael" }; const char *FreqPlanTable[6] = { "Auto", "Europe/Africa", "USA/Canada", "Australia/Chile", "New Zeeland", "Izrael" };
httpd_resp_sendstr_chunk(Req, "<tr><td>Freq. plan</td><td>\n"); httpd_resp_sendstr_chunk(Req, "<tr><td>Freq. plan</td><td>\n");
SelectList(Req, "FreqPlan", FreqPlanTable, 6, Parameters.FreqPlan); SelectList(Req, "FreqPlan", FreqPlanTable, 6, Parameters.FreqPlan);
httpd_resp_sendstr_chunk(Req, "</td></tr>\n"); httpd_resp_sendstr_chunk(Req, "</td></tr>\n");
@ -161,12 +202,12 @@ static void ParmForm_Stratux(httpd_req_t *Req) // Connection to Stratux WiFi par
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>Tx [dBm]</td><td><input type=\"text\" name=\"StratuxTxPwr\" size=\"10\" value=\""); httpd_resp_sendstr_chunk(Req, "<tr><td>Tx power [dBm]</td><td><input type=\"text\" name=\"StratuxTxPwr\" size=\"10\" value=\"");
Len=Format_UnsDec(Line, (10*Parameters.StratuxTxPwr+2)>>2, 2, 1); Len=Format_UnsDec(Line, (10*Parameters.StratuxTxPwr+2)>>2, 2, 1);
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>Min. signal [dBm]</td><td><input type=\"text\" name=\"StratuxMinSig\" size=\"10\" value=\""); httpd_resp_sendstr_chunk(Req, "<tr><td>Min. RSSI [dBm]</td><td><input type=\"text\" name=\"StratuxMinSig\" size=\"10\" value=\"");
Len=Format_SignDec(Line, Parameters.StratuxMinSig); Len=Format_SignDec(Line, Parameters.StratuxMinSig);
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");
@ -194,7 +235,7 @@ static void ParmForm_AP(httpd_req_t *Req) // Wi-Fi access point parameters { cha
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>Tx [dBm]</td><td><input type=\"text\" name=\"APtxPwr\" size=\"10\" value=\""); httpd_resp_sendstr_chunk(Req, "<tr><td>Tx power [dBm]</td><td><input type=\"text\" name=\"APtxPwr\" size=\"10\" value=\"");
Len=Format_UnsDec(Line, (10*Parameters.APtxPwr+2)>>2, 2, 1); Len=Format_UnsDec(Line, (10*Parameters.APtxPwr+2)>>2, 2, 1);
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");
@ -461,7 +502,7 @@ static void Top_Bar(httpd_req_t *Req)
{ char Line[32]; int Len; { char Line[32]; int Len;
httpd_resp_sendstr_chunk(Req, "<h2>OGN-Tracker</h2>\n"); httpd_resp_sendstr_chunk(Req, "<h2>OGN-Tracker</h2>\n");
httpd_resp_sendstr_chunk(Req, "<b>CPU ID: "); httpd_resp_sendstr_chunk(Req, "<b>EUID: ");
Len=Format_Hex(Line, getUniqueID()); Len=Format_Hex(Line, getUniqueID());
httpd_resp_send_chunk(Req, Line, Len); httpd_resp_send_chunk(Req, Line, Len);
httpd_resp_sendstr_chunk(Req, "</b><br />\n"); httpd_resp_sendstr_chunk(Req, "</b><br />\n");
@ -514,6 +555,8 @@ static esp_err_t parm_get_handler(httpd_req_t *Req)
httpd_resp_sendstr_chunk(Req, "</td></tr>\n<tr><td>\n"); httpd_resp_sendstr_chunk(Req, "</td></tr>\n<tr><td>\n");
ParmForm_Info(Req); ParmForm_Info(Req);
httpd_resp_sendstr_chunk(Req, "</td></tr>\n<tr><td>\n"); httpd_resp_sendstr_chunk(Req, "</td></tr>\n<tr><td>\n");
ParmForm_GPS(Req);
httpd_resp_sendstr_chunk(Req, "</td></tr>\n<tr><td>\n");
#ifdef WITH_AP #ifdef WITH_AP
ParmForm_AP(Req); ParmForm_AP(Req);
httpd_resp_sendstr_chunk(Req, "</td></tr>\n<tr><td>\n"); httpd_resp_sendstr_chunk(Req, "</td></tr>\n<tr><td>\n");

Wyświetl plik

@ -141,7 +141,7 @@ inline uint8_t NMEA_AppendCheckCRNL(char *NMEA, uint8_t Len) { return NMEA_Appen
if(Data[4]!='G') return 0; if(Data[4]!='G') return 0;
return Data[5]=='A'; } return Data[5]=='A'; }
uint8_t isGPGSA(void) const // uint8_t isGPGSA(void) const // GPS satellite data
{ if(!isGP()) return 0; { if(!isGP()) return 0;
if(Data[3]!='G') return 0; if(Data[3]!='G') return 0;
if(Data[4]!='S') return 0; if(Data[4]!='S') return 0;

Wyświetl plik

@ -212,12 +212,14 @@ uint16_t StratuxPort;
Flags = 0; Flags = 0;
#ifdef WITH_GPS_UBX #ifdef WITH_GPS_UBX
NavMode = 6; // Avionic mode 1g for UBX NavMode = 6; // 6 = Avionic mode 1g for UBX
#endif #endif
#ifdef WITH_GPS_MTK #ifdef WITH_GPS_MTK
NavMode = 2; // Avionic mode for MTK NavMode = 2; // 2 = Avionic mode for MTK
#endif #endif
NavRate = 1; // [Hz] NavRate = 1; // [Hz]
GeoidSepar = 10*DEFAULT_GeoidSepar; // [0.1m]
Verbose = 1; Verbose = 1;
RFchipTempCorr = 0; // [degC] RFchipTempCorr = 0; // [degC]
@ -225,7 +227,6 @@ uint16_t StratuxPort;
CONprot = 0xFF; CONprot = 0xFF;
PressCorr = 0; // [0.25Pa] PressCorr = 0; // [0.25Pa]
TimeCorr = 0; // [sec] TimeCorr = 0; // [sec]
GeoidSepar = 10*DEFAULT_GeoidSepar; // [0.1m]
FreqPlan = DEFAULT_FreqPlan; // [0..5] FreqPlan = DEFAULT_FreqPlan; // [0..5]
PPSdelay = DEFAULT_PPSdelay; // [ms] PPSdelay = DEFAULT_PPSdelay; // [ms]

Wyświetl plik

@ -57,6 +57,41 @@ class UBX_NAV_SOL // 0x01 0x06
uint8_t reserved2[4]; // uint8_t reserved2[4]; //
} ; } ;
class UBX_NAV_PVT // 0x01 0x07
{ public:
uint32_t iTOW; // [ms]
uint16_t year;
uint8_t month;
uint8_t day;
uint8_t hour;
uint8_t min;
uint8_t sec;
uint8_t valid;
uint32_t tAcc;
int32_t nano;
uint8_t fixType;
uint8_t flags;
uint8_t flags2;
uint8_t numSV;
int32_t lon;
int32_t lat;
int32_t height;
int32_t hMSL;
uint32_t hAcc;
uint32_t vAcc;
int32_t velN;
int32_t velE;
int32_t velD;
int32_t gSpeed;
int32_t headMot;
uint32_t sAcc;
uint32_t headAcc;
uint16_t pDOP;
uint8_t reserved1[6];
int32_t headVeh;
uint8_t reserved2[4];
} ;
class UBX_NAV_VELNED // 0x01 0x12 class UBX_NAV_VELNED // 0x01 0x12
{ public: { public:
uint32_t iTOW; // [ms] Time-of-Week uint32_t iTOW; // [ms] Time-of-Week
@ -126,6 +161,9 @@ class UBX_CFG_PRT // 0x06 0x00
int16_t outProtoMask; // bit 0:UBX, bit 1:NMEA int16_t outProtoMask; // bit 0:UBX, bit 1:NMEA
uint16_t flags; // bit 1:extendedTxTimeout uint16_t flags; // bit 1:extendedTxTimeout
uint16_t reserved2; uint16_t reserved2;
public:
// void setBaudRate(uint32_t BaudRate)
// { }
} ; } ;
class UBX_CFG_MSG // 0x06 0x01 class UBX_CFG_MSG // 0x06 0x01
@ -171,6 +209,8 @@ class UBX_CFG_NAV5 // 0x06 0x24
uint8_t reserved2[2]; uint8_t reserved2[2];
uint32_t reserved3; uint32_t reserved3;
uint32_t reserved4; uint32_t reserved4;
public:
void setDynModel(uint8_t DynModel) { mask = 0x0001; dynModel=DynModel; } // only change the dynamic model
} ; } ;
// UBX Class packet numbers // UBX Class packet numbers
@ -280,9 +320,9 @@ class UBX_RxMsg // receiver for the UBX sentences
CheckB += CheckA; CheckB += CheckA;
(*SendByte)(DataLen); (*SendByte)(DataLen);
CheckA += DataLen; CheckA += DataLen;
CheckB += CheckA; // pass PollDataLen CheckB += CheckA; // pass DataLen LSB
(*SendByte)(0x00); (*SendByte)(0x00);
CheckB += CheckA; // pass 0x00 CheckB += CheckA; // pass DataLen MSB = 0x00
if(Data) if(Data)
{ for(uint8_t Idx=0; Idx<DataLen; Idx++) { for(uint8_t Idx=0; Idx<DataLen; Idx++)
{ (*SendByte)(Data[Idx]); { (*SendByte)(Data[Idx]);