Clean up and improve of the HTTP interface

pull/30/head
Pawel Jalocha 2020-11-20 14:14:27 +00:00
rodzic 8a9ceff73c
commit 67934134ae
4 zmienionych plików z 83 dodań i 32 usunięć

Wyświetl plik

@ -4,9 +4,7 @@
#define DEFAULT_PPSdelay 100
#define DEFAULT_FreqPlan 0
// #define WITH_HELTEC // HELTEC module: PCB LED on GPI025
// #define WITH_HELTEC_V2 // HELTEC module v2
// #define WITH_TTGO // TTGO module: PCB LED on GPIO2, GPIO25 free to use as DAC2 output
// #define WITH_TBEAM // T-Beam module
// #define WITH_TBEAM_V10 // T-Beam module
@ -15,16 +13,14 @@
// #define WITH_ILI9341 // 320x240 M5stack
// #define WITH_ST7789 // IPS 240x240 ST7789
// #define WITH_TFT_LCD // TFT LCD
// #define WITH_TFT_LCD // TFT LCD (incomplete)
// #define WITH_OLED // OLED display on the I2C: some TTGO modules are without OLED display
// #define WITH_OLED2 // 2nd OLED display, I2C address next higher
#define WITH_U8G2_OLED // I2C OLED through the U8g2 library
#define WITH_U8G2_SH1106 // correct controller for the bigger OLED
#define WITH_U8G2_FLIP // flip the OLED screen (rotate by 180deg)
#define WITH_U8G2_FLIP
#define WITH_RFM95 // RF chip selection: both HELTEC and TTGO use sx1276 which is same as RFM95
#define WITH_LORAWAN
// #define WITH_SLEEP // with software sleep mode controlled by the long-press on the button
// #define WITH_AXP // with AXP192 power controller (T-BEAM V1.0)
@ -49,15 +45,9 @@
// #define WITH_BMP280 // BMP280 pressure sensor
#define WITH_BME280 // BMP280 with humidity (but still works with BMP280)
// #define WITH_MS5607 // MS5607 pressure sensor
// #define WITH_MS5611 // MS5611 pressure sensor
// #define WITH_BMX055 // BMX055 magnetic and IMU sensor
// #define WITH_FANET
#define WITH_PFLAA // PFLAU and PFLAA for compatibility with XCsoar and LK8000
// #define WITH_POGNT
// #define WITH_GDL90
// #define WITH_PGAV5
#define WITH_LOOKOUT
#define WITH_CONFIG // interpret the console input: $POGNS to change parameters
@ -68,21 +58,24 @@
// #define WITH_KNOB
// #define WITH_VARIO
#define WITH_SD // use the SD card in SPI mode and FAT file system
#define WITH_SPIFFS // use SPIFFS file system in Flash
#define WITH_SPIFFS_FAT // FAT system in internal flash
#define WITH_LOG // log own positions and other received to SPIFFS
#define WITH_SDLOG // log own position and other data to uSD card
#define WITH_LORAWAN
#define WITH_AP
// #define WITH_STRATUX
// #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_STRATUX // connect to Stratux as a client to send GPS and Pressure data
#define WITH_AP // WiFi AcessPoint and TCP decoder port
// #define WITH_APRS // attempt to connect to the wifi router and then APRS
#define WITH_HTTP // HTTP server, works with AP dna should work with Stratux as well
#define WITH_SD // use the SD card in SPI mode and FAT file system
#define WITH_SPIFFS_FAT
#define WITH_SPIFFS // use SPIFFS file system in Flash
#define WITH_LOG // log own positions and other received to SPIFFS and possibly to uSD
#define WITH_SDLOG
// #define WITH_ENCRYPT // Encrypt (optionally) the position
#if defined(WITH_STRATUX) || defined(WITH_APRS) || defined(WITH_AP)
#define WITH_WIFI
#endif
// #define WITH_ENCRYPT // Encrypt (optionally) the position

Wyświetl plik

@ -59,18 +59,18 @@
#define WITH_LORAWAN
// #define WITH_AP
#define WITH_AP
// #define WITH_STRATUX
#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_HTTP // HTTP server, works with AP dna should work with Stratux as well
// #define WITH_SD // use the SD card in SPI mode and FAT file system
#define WITH_SPIFFS_FAT
#define WITH_SPIFFS // use SPIFFS file system in Flash
#define WITH_LOG // log own positions and other received to SPIFFS and possibly to uSD
// #define WITH_SPIFFS_LOG // log transmitted and received packets to SPIFFS
// #define WITH_ENCRYPT // Encrypt (optionally) the position
#if defined(WITH_STRATUX) || defined(WITH_APRS) || defined(WITH_AP)

Wyświetl plik

@ -242,16 +242,65 @@ static void Table_GPS(httpd_req_t *Req)
httpd_resp_sendstr_chunk(Req, "</table>\n"); }
// -------------------------------------------------------------------------------------------------------------
#ifdef WITH_LOOKOUT
static void Table_LookOut(httpd_req_t *Req)
{ char Line[128]; int Len;
httpd_resp_sendstr_chunk(Req, "<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\">\n");
httpd_resp_sendstr_chunk(Req, "<tr><th><b>LookOut</th><td align=\"center\"></td><td align=\"center\"></td></tr>\n");
for( uint8_t Idx=0; Idx<Look.MaxTargets; Idx++)
{ const LookOut_Target *Tgt = Look.Target+Idx; if(!Tgt->Alloc) continue;
Len =Format_String(Line, "<tr><td>");
Len+=Format_Hex(Line+Len, Tgt->ID, 7);
Len+=Format_String(Line+Len, "</td><td>");
Len+=Format_UnsDec(Line+Len, Tgt->TimeMargin>>1, 2);
Len+=Format_String(Line+Len, "s</td><td>");
Len+=Format_UnsDec(Line+Len, ((Tgt->HorDist>>1)+5)/10, 2, 2);
Len+=Format_String(Line+Len, "km</td></tr>\n");
httpd_resp_send_chunk(Req, Line, Len); }
httpd_resp_sendstr_chunk(Req, "</table>\n"); }
#endif
// -------------------------------------------------------------------------------------------------------------
static void Table_Relay(httpd_req_t *Req)
{ char Line[128]; int Len;
httpd_resp_sendstr_chunk(Req, "<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\">\n");
httpd_resp_sendstr_chunk(Req, "<tr><th><b>Relay</th><td align=\"center\">Rank</td><td align=\"center\">[sec]</td></tr>\n");
for( uint8_t Idx=0; Idx<RelayQueueSize; Idx++)
{ OGN_RxPacket<OGN_Packet> *Packet = RelayQueue.Packet+Idx; if(Packet->Rank==0) continue;
Len =Format_String(Line, "<tr><td>");
Line[Len++]='0'+Packet->Packet.Header.AddrType;
Line[Len++]=':';
Len+=Format_Hex(Line+Len, Packet->Packet.Header.Address, 6);
Len+=Format_String(Line+Len, "</td><td>");
Len+=Format_Hex(Line+Len, Packet->Rank);
Len+=Format_String(Line+Len, "</td><td>");
Len+=Format_UnsDec(Line+Len, Packet->Packet.Position.Time, 2);
Len+=Format_String(Line+Len, "</td></tr>\n");
httpd_resp_send_chunk(Req, Line, Len); }
httpd_resp_sendstr_chunk(Req, "</table>\n"); }
// -------------------------------------------------------------------------------------------------------------
static void Table_RF(httpd_req_t *Req)
{ char Line[128]; int Len;
httpd_resp_sendstr_chunk(Req, "<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\">\n");
Len=Format_String(Line, "<tr><th><b>RF chip</th><td>");
Len=Format_String(Line, "<tr><th><b>RF chip</th><td align=\"center\">");
#ifdef WITH_RFM69
Len+=Format_String(Line+Len, "sx1276");
Len+=Format_String(Line+Len, "RFM69");
#endif
#ifdef WITH_RFM95
Len+=Format_String(Line+Len, "RFM95");
Len+=Format_String(Line+Len, "sx1276");
#endif
#ifdef WITH_SX1272
Len+=Format_String(Line+Len, "sx1272");
#endif
Len+=Format_String(Line+Len, "</td></tr>\n");
httpd_resp_send_chunk(Req, Line, Len);
@ -298,6 +347,8 @@ static uint8_t BattCapacity(uint16_t mVolt)
if(mVolt<=3600) return 0;
return (mVolt-3600+2)/5; }
// -------------------------------------------------------------------------------------------------------------
static void Table_Batt(httpd_req_t *Req)
{ char Line[128]; int Len;
@ -367,6 +418,8 @@ static void Table_Batt(httpd_req_t *Req)
httpd_resp_sendstr_chunk(Req, "</table>\n"); }
// -------------------------------------------------------------------------------------------------------------
static void Top_Bar(httpd_req_t *Req)
{ char Line[32]; int Len;
@ -381,7 +434,6 @@ static void Top_Bar(httpd_req_t *Req)
<th><a href=\"/parm.html\">Configuration</a></th>\n\
<th><a href=\"/log.html\">Log files</a></th>\n\
</tr></table><br />\n");
}
// ============================================================================================================
@ -463,6 +515,12 @@ static esp_err_t top_get_handler(httpd_req_t *Req)
Table_RF(Req);
httpd_resp_sendstr_chunk(Req, "<br />\n");
Table_Batt(Req);
#ifdef WITH_LOOKOUT
httpd_resp_sendstr_chunk(Req, "<br />\n");
Table_LookOut(Req);
#endif
httpd_resp_sendstr_chunk(Req, "<br />\n");
Table_Relay(Req);
httpd_resp_sendstr_chunk(Req, "</body></html>\n");
httpd_resp_sendstr_chunk(Req, 0);

Wyświetl plik

@ -584,9 +584,9 @@ void vTaskPROC(void* pvParameters)
if(Parameters.Encrypt) TxPacket->Packet.Encrypt(Parameters.EncryptKey); // if encryption is requested then encrypt
else TxPacket->Packet.Whiten(); // otherwise only whiten
#else
TxPacket->Packet.Whiten();
TxPacket->Packet.Whiten(); // just whiten if there is no encryption
#endif
TxPacket->calcFEC(); // whiten and calculate FEC code
TxPacket->calcFEC(); // calculate FEC code
#ifdef DEBUG_PRINT
xSemaphoreTake(CONS_Mutex, portMAX_DELAY);
Format_UnsDec(CONS_UART_Write, TimeSync_Time()%60, 2);