From 67934134ae8e41c9c4c008f67d721ed2157990c6 Mon Sep 17 00:00:00 2001 From: Pawel Jalocha Date: Fri, 20 Nov 2020 14:14:27 +0000 Subject: [PATCH] Clean up and improve of the HTTP interface --- FollowMe_old.cfg | 37 +++++++++++--------------- T-Beam_v10_LCD.cfg | 8 +++--- main/http.cpp | 66 +++++++++++++++++++++++++++++++++++++++++++--- main/proc.cpp | 4 +-- 4 files changed, 83 insertions(+), 32 deletions(-) diff --git a/FollowMe_old.cfg b/FollowMe_old.cfg index 204d91e..c808af8 100644 --- a/FollowMe_old.cfg +++ b/FollowMe_old.cfg @@ -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 - diff --git a/T-Beam_v10_LCD.cfg b/T-Beam_v10_LCD.cfg index 25bc7a1..1e574e6 100644 --- a/T-Beam_v10_LCD.cfg +++ b/T-Beam_v10_LCD.cfg @@ -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) diff --git a/main/http.cpp b/main/http.cpp index 43accaa..5b00699 100644 --- a/main/http.cpp +++ b/main/http.cpp @@ -242,16 +242,65 @@ static void Table_GPS(httpd_req_t *Req) httpd_resp_sendstr_chunk(Req, "\n"); } +// ------------------------------------------------------------------------------------------------------------- + +#ifdef WITH_LOOKOUT +static void Table_LookOut(httpd_req_t *Req) +{ char Line[128]; int Len; + httpd_resp_sendstr_chunk(Req, "\n"); + httpd_resp_sendstr_chunk(Req, "\n"); + + for( uint8_t Idx=0; IdxAlloc) continue; + Len =Format_String(Line, "\n"); + httpd_resp_send_chunk(Req, Line, Len); } + + httpd_resp_sendstr_chunk(Req, "
LookOut
"); + Len+=Format_Hex(Line+Len, Tgt->ID, 7); + Len+=Format_String(Line+Len, ""); + Len+=Format_UnsDec(Line+Len, Tgt->TimeMargin>>1, 2); + Len+=Format_String(Line+Len, "s"); + Len+=Format_UnsDec(Line+Len, ((Tgt->HorDist>>1)+5)/10, 2, 2); + Len+=Format_String(Line+Len, "km
\n"); } +#endif + +// ------------------------------------------------------------------------------------------------------------- + +static void Table_Relay(httpd_req_t *Req) +{ char Line[128]; int Len; + httpd_resp_sendstr_chunk(Req, "\n"); + httpd_resp_sendstr_chunk(Req, "\n"); + + for( uint8_t Idx=0; Idx *Packet = RelayQueue.Packet+Idx; if(Packet->Rank==0) continue; + Len =Format_String(Line, "\n"); + httpd_resp_send_chunk(Req, Line, Len); } + + httpd_resp_sendstr_chunk(Req, "
RelayRank[sec]
"); + Line[Len++]='0'+Packet->Packet.Header.AddrType; + Line[Len++]=':'; + Len+=Format_Hex(Line+Len, Packet->Packet.Header.Address, 6); + Len+=Format_String(Line+Len, ""); + Len+=Format_Hex(Line+Len, Packet->Rank); + Len+=Format_String(Line+Len, ""); + Len+=Format_UnsDec(Line+Len, Packet->Packet.Position.Time, 2); + Len+=Format_String(Line+Len, "
\n"); } + +// ------------------------------------------------------------------------------------------------------------- + static void Table_RF(httpd_req_t *Req) { char Line[128]; int Len; httpd_resp_sendstr_chunk(Req, "\n"); - Len=Format_String(Line, "\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, "
RF chip"); + Len=Format_String(Line, "
RF chip"); #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, "
\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) Configuration\n\ Log files\n\
\n"); - } // ============================================================================================================ @@ -463,6 +515,12 @@ static esp_err_t top_get_handler(httpd_req_t *Req) Table_RF(Req); httpd_resp_sendstr_chunk(Req, "
\n"); Table_Batt(Req); +#ifdef WITH_LOOKOUT + httpd_resp_sendstr_chunk(Req, "
\n"); + Table_LookOut(Req); +#endif + httpd_resp_sendstr_chunk(Req, "
\n"); + Table_Relay(Req); httpd_resp_sendstr_chunk(Req, "\n"); httpd_resp_sendstr_chunk(Req, 0); diff --git a/main/proc.cpp b/main/proc.cpp index edeefc4..c0b1421 100644 --- a/main/proc.cpp +++ b/main/proc.cpp @@ -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);