From 852737f0c6f79202c69082230c2f5133b414bbf3 Mon Sep 17 00:00:00 2001 From: Sottosistema W10 Date: Tue, 14 Sep 2021 20:47:32 +0200 Subject: [PATCH] Added beacon TX from web page as #64 --- data_embed/index.html | 5 +++++ src/TTGO_T-Beam_LoRa_APRS.ino | 9 +++++++++ src/taskWebServer.cpp | 11 ++++++++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/data_embed/index.html b/data_embed/index.html index 7d23e11..13f99d3 100644 --- a/data_embed/index.html +++ b/data_embed/index.html @@ -247,6 +247,11 @@ +
+
+ +
+
diff --git a/src/TTGO_T-Beam_LoRa_APRS.ino b/src/TTGO_T-Beam_LoRa_APRS.ino index 66a9d1c..8086bc7 100644 --- a/src/TTGO_T-Beam_LoRa_APRS.ino +++ b/src/TTGO_T-Beam_LoRa_APRS.ino @@ -188,6 +188,9 @@ uint oled_timeout; // OLED Timeout, same as "Display show RX Time" bool tempOled = true; // Turn ON OLED at first startup ulong oled_timer = millis(); +// Variable to manually send beacon from html page +bool manBeacon = false; + #define ANGLE_AVGS 3 // angle averaging - x times float average_course[ANGLE_AVGS]; float avg_c_y, avg_c_x; @@ -863,6 +866,12 @@ void loop() { } } + if (manBeacon) { + enableOled(); + writedisplaytext("((WEB TX))","","","","",""); + sendpacket(); + manBeacon=false; + } // Only wake up OLED when necessary, note that DIM is to turn OFF the backlight if (enabled_oled) { display.dim(!tempOled); diff --git a/src/taskWebServer.cpp b/src/taskWebServer.cpp index 437f40a..5f750ac 100644 --- a/src/taskWebServer.cpp +++ b/src/taskWebServer.cpp @@ -16,6 +16,9 @@ extern const char web_style_css_end[] asm("_binary_data_embed_style_css_out_end" extern const char web_js_js[] asm("_binary_data_embed_js_js_out_start"); extern const char web_js_js_end[] asm("_binary_data_embed_js_js_out_end"); +// Variable needed to send beacon from html page +extern bool manBeacon; + QueueHandle_t webListReceivedQueue = nullptr; std::list receivedPackets; const int MAX_RECEIVED_LIST_SIZE = 50; @@ -130,8 +133,13 @@ void handle_Reboot() { ESP.restart(); } -void handle_Shutdown() { +void handle_Beacon() { + server.sendHeader("Location", "/"); + server.send(302,"text/html", ""); + manBeacon=true; +} +void handle_Shutdown() { #ifdef T_BEAM_V1_0 server.send(200,"text/html", "Shutdown"); axp.shutdown(); @@ -291,6 +299,7 @@ void handle_saveDeviceCfg(){ server.on("/scan_wifi", handle_ScanWifi); server.on("/save_wifi_cfg", handle_SaveWifiCfg); server.on("/reboot", handle_Reboot); + server.on("/beacon", handle_Beacon); server.on("/shutdown", handle_Shutdown); server.on("/cfg", handle_Cfg); server.on("/received_list", handle_ReceivedList);