Browse Source

BT enable/disable from WWW

pull/22/head
Rysiek Labus 1 year ago
parent
commit
deec9b55f2
  1. 39
      data_embed/index.html
  2. 2
      include/taskWebServer.h
  3. 26
      src/TTGO_T-Beam_LoRa_APRS.ino
  4. 9
      src/taskWebServer.cpp

39
data_embed/index.html

@ -19,9 +19,8 @@
<article>
<form action="/save_wifi_cfg" method="post">
<div class="grid-container quarters">
<div>
<div id="wifi_list">
</div>
<div id="wifi_list">
<label for="wifi_ssid">Network</label>
<input type="button" value="Scan WiFi" id="scan_wifi_btn" onclick="scanWifi();">
</div>
<div>
@ -32,10 +31,10 @@
<label for="wifi_password">Password</label>
<input class="u-full-width" type="password" name="wifi_password" id="wifi_password">
</div>
<div>
<input class="button-primary" type="submit" value="Save">
</div>
</div>
<div class="grid-container full">
<input class="button-primary" type="submit" value="Save">
</div>
</form>
</article>
</section>
@ -107,6 +106,34 @@
</form>
</article>
</section>
<section>
<article>
<form action="/save_device_cfg" method="post">
<div class="grid-container full">
<h2 class="u-full-width">Device Settings</h2>
</div>
<div class="grid-container quarters">
<div>
<label for="bt_enabled">Bluetooth enabled</label>
<input name="bt_enabled" id="bt_enabled" type="checkbox" value="1" title="enable or disable bluetooth">
</div>
<div>
<label for="oled_enabled">Oled display enabled</label>
<input name="oled_enabled" id="oled_enabled" type="checkbox" value="1" title="enable or disable oled lcd" DISABLED>
</div>
<div>
<label for="led_enable">LED signaling</label>
<input name="led_enable" id="led_enable" type="checkbox" value="1" title="enable or disable LED" DISABLED>
</div>
</div>
<div class="grid-container full">
<div>
<input class="button-primary u-full-width" type="submit" value="Save" title="save settings, remember reboot tracker after save">
</div>
</div>
</form>
</article>
</section>
<section>
<div class="grid-container full">
<h2 class="u-full-width">Actions</h2>

2
include/taskWebServer.h

@ -37,6 +37,8 @@ static const char *const PREF_APRS_FIXED_BEACON_INTERVAL_PRESET = "aprs_fb_inter
static const char *const PREF_APRS_FIXED_BEACON_INTERVAL_PRESET_INIT = "aprs_fb_in_init";
static const char *const PREF_APRS_GPS_EN = "gps_enabled";
static const char *const PREF_APRS_GPS_EN_INIT = "gps_state_init";
static const char *const PREF_DEV_BT_EN = "bt_enabled";
static const char *const PREF_DEV_BT_EN_INIT = "bt_enabled_init";
typedef struct {
String callsign;

26
src/TTGO_T-Beam_LoRa_APRS.ino

@ -77,6 +77,11 @@ boolean fixed_beacon_enabled = false;
#else
boolean showBattery = false;
#endif
#ifdef ENABLE_BLUETOOTH
boolean enable_bluetooth = true;
#else
boolean enable_bluetooth = false;
#endif
// Variables and Constants
String loraReceivedFrameString = ""; //data on buff is copied to this string
@ -470,6 +475,12 @@ void setup(){
}
}
if (!preferences.getBool(PREF_DEV_BT_EN_INIT)){
preferences.putBool(PREF_DEV_BT_EN_INIT, true);
preferences.putBool(PREF_DEV_BT_EN, enable_bluetooth);
}
enable_bluetooth = preferences.getBool(PREF_DEV_BT_EN);
#endif
for (int i=0;i<ANGLE_AVGS;i++) { // set average_course to "0"
@ -557,13 +568,16 @@ void setup(){
xTaskCreatePinnedToCore(taskTNC, "taskTNC", 10000, nullptr, 1, nullptr, xPortGetCoreID());
#endif
#if defined(ENABLE_BLUETOOTH) && defined(KISS_PROTOCOL)
#ifdef BLUETOOTH_PIN
SerialBT.setPin(BLUETOOTH_PIN);
#endif
SerialBT.begin(String("TTGO LORA APRS ") + Tcall);
writedisplaytext("LoRa-APRS","","Init:","BT OK!","","");
#if defined(KISS_PROTOCOL)
if (enable_bluetooth){
#ifdef BLUETOOTH_PIN
SerialBT.setPin(BLUETOOTH_PIN);
#endif
SerialBT.begin(String("TTGO LORA APRS ") + Tcall);
writedisplaytext("LoRa-APRS","","Init:","BT OK!","","");
}
#endif
#ifdef ENABLE_WIFI
webServerCfg = {.callsign = Tcall};
xTaskCreate(taskWebServer, "taskWebServer", 40000, (void*)(&webServerCfg), 1, nullptr);

9
src/taskWebServer.cpp

@ -119,6 +119,7 @@ void handle_Cfg() {
jsonData += jsonLineFromPreferenceBool(PREF_APRS_FIXED_BEACON_PRESET);
jsonData += jsonLineFromPreferenceBool(PREF_APRS_SHOW_ALTITUDE);
jsonData += jsonLineFromPreferenceBool(PREF_APRS_GPS_EN);
jsonData += jsonLineFromPreferenceBool(PREF_DEV_BT_EN);
jsonData += jsonLineFromString("FreeHeap", String(ESP.getFreeHeap()).c_str());
jsonData += jsonLineFromString("HeapSize", String(ESP.getHeapSize()).c_str());
jsonData += jsonLineFromString("FreeSketchSpace", String(ESP.getFreeSketchSpace()).c_str(), true);
@ -156,9 +157,16 @@ void handle_SaveAPRSCfg() {
preferences.putBool(PREF_APRS_SHOW_ALTITUDE, server.hasArg(PREF_APRS_SHOW_ALTITUDE));
preferences.putBool(PREF_APRS_FIXED_BEACON_PRESET, server.hasArg(PREF_APRS_FIXED_BEACON_PRESET));
preferences.putBool(PREF_APRS_GPS_EN, server.hasArg(PREF_APRS_GPS_EN));
server.sendHeader("Location", "/");
server.send(302,"text/html", "");
}
void handle_saveDeviceCfg(){
preferences.putBool(PREF_DEV_BT_EN, server.hasArg(PREF_DEV_BT_EN));
server.sendHeader("Location", "/");
server.send(302,"text/html", "");
}
[[noreturn]] void taskWebServer(void *parameter) {
@ -174,6 +182,7 @@ void handle_SaveAPRSCfg() {
server.on("/reboot", handle_Reboot);
server.on("/cfg", handle_Cfg);
server.on("/save_aprs_cfg", handle_SaveAPRSCfg);
server.on("/save_device_cfg", handle_saveDeviceCfg);
server.on("/restore", handle_Restore);
server.onNotFound(handle_NotFound);

Loading…
Cancel
Save