Merge branch 'master' into telemetry-www

pull/75/head
mattbk 2021-09-16 14:29:55 -05:00 zatwierdzone przez GitHub
commit eb43b0baf1
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
7 zmienionych plików z 244 dodań i 55 usunięć

Wyświetl plik

@ -17,16 +17,20 @@ After connection with APRX based DIGI it can be used as KISS-TNC
* TTGO T-beam v.1.0
* Lora32 board
## User key functions:
### short press:
* if there is a GPS-FIX immediate sending of a frame with the position from the GPS
* if there is no GPS-FIX, immediate sending of the frame with the position saved in the configuration
### short press (OLED Enabled):
* if OLED is OFF a short press will wake it up and show current data (as "Display Timeout" seconds)
* if OLED is ON with GPS-FIX immediate sending of a frame with the position from the GPS
* if OLED is ON without GPS-FIX, immediate sending of the frame with the position saved in the configuration
### long press On boot
### short press (OLED Disabled):
* with a valid GPS-FIX immediate sending of a frame with the position from the GPS
* without valid GPS-FIX, immediate sending of the frame with the position saved in the configuration
### long press while booting
* reset to factory default
### long press: on or off the GPS power supply
### long press: toggle on or off GPS power supply
* if the "FIXED_BEACON_EN" option is enabled in the configuration, a beacon will be sent every set time interval
## Oled screens information
@ -38,12 +42,11 @@ After connection with APRX based DIGI it can be used as KISS-TNC
* ((FIX TX)) - information about the forced manual sending of a frame with the position saved in the configuration when GPS is off or no fix
* ((AUT TX)) - information about sending automatic positioning frame when GPS is turned off
* ((KISSTX)) - information about sending the frame sent by KISS
* ((WEB TX)) - sending frame as requested via HTTP
## How to binary first flash readme... (thanx SP6VWX)
* Download the appropriate binary file for your board from;
* https://github.com/SQ9MDD/TTGO-T-Beam-LoRa-APRS/releases
* Download current version of the esphome-flasher tool
* https://github.com/esphome/esphome-flasher/releases
* Download the appropriate binary file for your board from: https://github.com/SQ9MDD/TTGO-T-Beam-LoRa-APRS/releases
* Download current version of the esphome-flasher tool: https://github.com/esphome/esphome-flasher/releases
* Connect your board to your USB port and open ESPHome Flasher.
* If your board is not showing under Serial Port then you likely need to install the drivers for the CP210X serial chip. In Windows you can check by searching “Device Manager” and ensuring the device is shown under “Ports”.
* In ESPHome Flasher, refresh the serial ports and select your board's serial port.
@ -52,7 +55,62 @@ After connection with APRX based DIGI it can be used as KISS-TNC
* Once complete, “Done! Flashing is complete!” will be shown.
* any subsequent updates can be done via WWW
## Default WiFi Password:
## Installing from source (only for advanced users)
* Clone Git repo to any folder of your PC
* Download and install "Visual Studio Code"
* Open "Visual Studio Code" and add "PlatformIO" plugin
* Open "PlatformIO" and click on "Import Arduino Project"
* In the top part of the window choose youy board then browse to cloned repo and click "import"
* In the left column click on the ANT-shaped icon, choose your board and click on "Upload". COM port should be detected automatically Wait for procedure to finish and keep reading
## Configuring parameters
Wait for the board to reboot, connect to "N0CALL AP" WiFi network, password is: xxxxxxxxxx (10 times "x") and point your browser to "192.168.4.1". Hover your mouse to textboxes to get useful hints.
### WiFi Settings
you can scan for local SSID or manually type in name and password
* Scan WiFi: scan for local WiFi networks
* SSID: name of the AP to connect to
* Password: password of WiFi AP
* AUTO AP Password: if configured network is not reachable the AP mode will be enabled, SSID will be your callsign and this will be the password
### APRS Settings
These are main APRS settings such as callsign, SSID and symbol (refer to: http://www.aprs.org/symbols.html). Please remember to turn ON GPS in order to use it as a tracker.
* Frequency: frequency of receive and transmit
* Speed: speed of the LoRa APRS packet (default: 300)
* Callsign and SSID: Callsign of the tracker (e.g: N0CALL-10)
* Relay PATH: destination path of APRS packet
* Symbol table & Symbol: custom APRS icon
* Show altitude: allow altitude to be reported
* Show comment: includes comment in APRS packet
* Comment: custom message to send
* Show Battery: includes current battery voltage
* Fixed beacon: enables static beacon transmission
* Fixed beacon interval: beacon interval in seconds (please more than 30 minutes to avoid overflow on the network)
* Latitude & Longitude: fixed beacon position to transmit (in APRS format)
* Min interval: packet are transmitted not less than x second apart
* Max interval: maximum interval between packages
* Speed and course: variables to calculate smart beaconing
* GPS enabled: enables power to GPS module
### Device Settings
These are main device settings, hover the mouse on the checkboxes and explainations will appear.
* OLED Display enabled: Enables OLED functionalities
* Bluetooth enabled: Enables bluetooth functions (such as TNC via APRSDROID)
* LED Signaling: not yet implemented
* Auto Power OFF: activate auto power off when USB is unplugged (only for TBEAM 1.0 or later)
* Auto Power OFF delay: timer to turn off board after USB is unplugged (only if enabled)
* Display show RX Time: when a packet is received display the packet is shown for X seconds
* Display Timeout: display will turn OFF after X seconds for better power save (0 to disable and keep OLED ON)
### Received
Here is the list of recently received stations with some details
### Actions
Some shortcuts to useful functions such as manually send beacon
### Update
This box allows firmware to be uploaded via OTA
## Default WiFi Password:
* Default WiFi Password is: xxxxxxxxxx
* that is, 10 times x

Wyświetl plik

@ -25,12 +25,16 @@
<input type="button" value="Scan WiFi" id="scan_wifi_btn" onclick="scanWifi();">
</div>
<div>
<label for="wifi_ssid">SSID</label>
<input class="u-full-width" type="text" name="wifi_ssid" placeholder="Your Wifi SSID" id="wifi_ssid">
<label for="wifi_ssid">WiFi SSID</label>
<input class="u-full-width" type="text" name="wifi_ssid" placeholder="Your Wifi SSID" title="Your Wifi SSID" id="wifi_ssid">
</div>
<div>
<label for="wifi_password">Password</label>
<input class="u-full-width" type="password" name="wifi_password" id="wifi_password">
<label for="wifi_password">WiFi Password</label>
<input class="u-full-width" type="password" name="wifi_password" id="wifi_password" placeholder="Your WiFi Password" title="Your WiFi Password">
</div>
<div>
<label for="ap_password">AUTO AP Password</label>
<input class="u-full-width" type="password" name="ap_password" id="ap_password" placeholder="AUTO AP Password" title="AUTO AP Password">
</div>
</div>
<div class="grid-container full">
@ -174,8 +178,8 @@
</div>
<div class="grid-container quarters">
<div>
<label for="oled_enabled">Display dimmer enabled</label>
<input name="oled_enabled" id="oled_enabled" type="checkbox" value="1" title="enable or disable oled dimmer">
<label for="oled_enabled">OLED Display enabled</label>
<input name="oled_enabled" id="oled_enabled" type="checkbox" value="1" title="Enables or disables OLED">
</div>
<div>
<label for="bt_enabled">Bluetooth enabled</label>
@ -187,22 +191,23 @@
</div>
<div>
<label for="shutdown_act">Auto power off</label>
<input name="shutdown_act" id="shutdown_act" type="checkbox" value="1" title="activate auto shutdown after usb plug off">
<input name="shutdown_act" id="shutdown_act" type="checkbox" value="1" title="activate auto shutdown after usb plug off (not for T-BEAM 0.7)">
</div>
</div>
<div class="grid-container quarters">
<div>
<label for="sh_rxtime">Display show RX time (s)</label>
<label for="sh_rxtime">Display show RX time [s]</label>
<input name="sh_rxtime" id="sh_rxtime" type="number" min="0" max="45" title="show RX packet for seconds">
</div>
<div>
<label for="sh_oledtime">Display timeout [s]</label>
<input name="sh_oledtime" id="sh_oledtime" type="number" min="0" max="60" title="Turn OFF OLED after X seconds. Set 0 to disable">
</div>
<div>
</div>
<div>
<label for="shutdown_dt">Auto power off delay (s)</label>
<label for="shutdown_dt">Auto power off delay [s]</label>
<input name="shutdown_dt" id="shutdown_dt" type="number" min="3" max="3600" title="auto shutdown delay in seconds">
</div>
</div>
@ -255,6 +260,11 @@
<input class="button-primary" type="submit" value="Factory reset">
</div>
</form>
<form action="/beacon" method="post" onsubmit="return confirmAction('send beacon');">
<div>
<input class="button-primary" type="submit" value="Send Beacon">
</div>
</form>
</div>
</article>
</section>
@ -277,7 +287,7 @@
</section>
</div>
<footer>
<center><b>Contributors in order of appearance:</b><br> OE1ACM, OE3CJB, SQ9MDD, SQ5RWU, DJ1AN, M0IGA, SQ5WPR, DO2JMG, SP6VWX, SQ2WB</center>
<center><b>Contributors in order of appearance:</b><br> OE1ACM, OE3CJB, SQ9MDD, SQ5RWU, DJ1AN, M0IGA, SQ5WPR, DO2JMG, SP6VWX, SQ2WB, IU2FRL, DO3BOX</center>
<center><b>Latest stable version:</b> <a href=https://github.com/SQ9MDD/TTGO-T-Beam-LoRa-APRS>https://github.com/SQ9MDD/TTGO-T-Beam-LoRa-APRS</a></center>
<center><b>Licensed under:</b> CC BY-NC-SA</center>
<center><!--VERSION--></center>

Wyświetl plik

@ -477,8 +477,8 @@ html {
padding: 20px;
text-align: center;
display: grid;
grid-gap: 20px;
gap: 20px;
grid-gap: 5px;
gap: 5px;
/* by default use min 200px wide columns auto-fit into width */
grid-template-columns: minmax(200px, 1fr);

Wyświetl plik

@ -3,13 +3,13 @@
#ifndef PREF_STORAGE
#define PREF_STORAGE
#define ENABLE_PREFERENCES
extern Preferences preferences;
// MAX 15 chars for preference key!!!
static const char *const PREF_WIFI_SSID = "wifi_ssid";
static const char *const PREF_WIFI_PASSWORD = "wifi_password";
static const char *const PREF_AP_PASSWORD = "ap_password";
// LoRa settings
static const char *const PREF_LORA_FREQ_PRESET_INIT = "lora_freq_i";
static const char *const PREF_LORA_FREQ_PRESET = "lora_freq";
@ -53,7 +53,7 @@ static const char *const PREF_APRS_SB_MAX_SPEED_PRESET_INIT = "sb_max_speed_i";
static const char *const PREF_APRS_SB_ANGLE_PRESET = "sb_angle";
static const char *const PREF_APRS_SB_ANGLE_PRESET_INIT = "sb_angle_i";
//
// Device settings
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_APRS_SHOW_CMT = "show_cmt";
@ -68,6 +68,7 @@ static const char *const PREF_DEV_AUTO_SHUT = "shutdown_act";
static const char *const PREF_DEV_AUTO_SHUT_INIT = "shutdown_actini";
static const char *const PREF_DEV_AUTO_SHUT_PRESET = "shutdown_dt";
static const char *const PREF_DEV_AUTO_SHUT_PRESET_INIT = "shutdown_dtini";
static const char *const PREF_DEV_SHOW_OLED_TIME = "sh_oledtime"; // set OLED timeout
static const char *const PREF_DEV_SHOW_OLED_TIME_INIT = "sh_oledtime_i";
#endif

Wyświetl plik

@ -55,6 +55,7 @@ build_flags =
-D 'ENABLE_TNC_SELF_TELEMETRY' ; can be set from www interface
-D 'TNC_SELF_TELEMETRY_INTERVAL=3600L' ; can be set from www interface (seconds)
-D 'TNC_SELF_TELEMETRY_SEQ=0L'
-D 'SHOW_OLED_TIME=15000' ; OLED Timeout
[env:ttgo-t-beam-v1.0]
platform = espressif32 @ 3.0.0

Wyświetl plik

@ -188,6 +188,16 @@ boolean shutdown_active =true;
boolean shutdown_countdown_timer_enable = false;
boolean shutdown_usb_status_bef = false;
// Variables required to Power Save OLED
// With "Display dimmer enabled" it will turn OLED off after some time
// if the checkbox is disabled the display stays OFF
uint oled_timeout = SHOW_OLED_TIME; // OLED Timeout
bool tempOled = true; // Turn ON OLED at first startup
ulong oled_timer;
// 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;
@ -248,10 +258,10 @@ void prepareAPRSFrame(){
outString = "";
outString += Tcall;
if (relay_path){
outString += ">APLO01," + relay_path + ":!";
}else{
if (relay_path.isEmpty()){
outString += ">APLO01:!";
}else{
outString += ">APLO01," + relay_path + ":!";
}
if(gps_state && gps.location.isValid()){
@ -362,6 +372,8 @@ void batt_read(){
#ifdef T_BEAM_V1_0
BattVolts = axp.getBattVoltage()/1000;
InpVolts = axp.getVbusVoltage()/1000;
#elif T_BEAM_V0_7
BattVolts = (((float)analogRead(35) / 8192.0) * 2.0 * 3.3 * (1100.0 / 1000.0))+0.41; // fixed thanks to Luca IU2FRL
#else
BattVolts = analogRead(35)*7.221/4096;
#endif
@ -394,10 +406,10 @@ void writedisplaytext(String HeaderTxt, String Line1, String Line2, String Line3
display.println(Line5);
if (enabled_oled){
//axp.setPowerOutPut(AXP192_DCDC1, AXP202_ON); // enable oled
display.dim(true);
//display.dim(false);
}else{
//axp.setPowerOutPut(AXP192_DCDC1, AXP202_OFF); // disable oled
display.dim(false);
display.dim(true);
}
display.display();
time_to_refresh = millis() + showRXTime;
@ -407,15 +419,15 @@ String getSatAndBatInfo() {
String line5;
if(gps_state == true){
if(InpVolts > 4){
line5 = "SAT: " + String(gps.satellites.value()) + " BAT: " + String(BattVolts, 1) + "V *";
line5 = "SAT: " + String(gps.satellites.value()) + " BAT: " + String(BattVolts, 2) + "V *";
}else{
line5 = "SAT: " + String(gps.satellites.value()) + " BAT: " + String(BattVolts, 1) + "V";
line5 = "SAT: " + String(gps.satellites.value()) + " BAT: " + String(BattVolts, 2) + "V";
}
}else{
if(InpVolts > 4){
line5 = "SAT: X BAT: " + String(BattVolts, 1) + "V *";
line5 = "SAT: X BAT: " + String(BattVolts, 2) + "V *";
}else{
line5 = "SAT: X BAT: " + String(BattVolts, 1) + "V";
line5 = "SAT: X BAT: " + String(BattVolts, 2) + "V";
}
}
@ -537,6 +549,12 @@ String prepareCallsign(const String& callsign){
// + SETUP --------------------------------------------------------------+//
void setup(){
//#ifdef T_BEAM_V0_7
// adcAttachPin(35);
// adcStart(35);
// analogReadResolution(10);
//#endif
SPI.begin(SPI_sck,SPI_miso,SPI_mosi,SPI_ss); //DO2JMG Heltec Patch
Serial.begin(115200);
@ -710,6 +728,13 @@ void setup(){
preferences.putInt(PREF_DEV_SHOW_RX_TIME, showRXTime/1000);
}
showRXTime = preferences.getInt(PREF_DEV_SHOW_RX_TIME) * 1000;
// Read OLED RX Timer
if (!preferences.getBool(PREF_DEV_SHOW_OLED_TIME_INIT)){
preferences.putBool(PREF_DEV_SHOW_OLED_TIME_INIT, true);
preferences.putInt(PREF_DEV_SHOW_OLED_TIME, oled_timeout/1000);
}
oled_timeout = preferences.getInt(PREF_DEV_SHOW_OLED_TIME) * 1000;
if (!preferences.getBool(PREF_DEV_AUTO_SHUT_PRESET_INIT)){
preferences.putBool(PREF_DEV_AUTO_SHUT_PRESET_INIT, true);
@ -836,7 +861,7 @@ void setup(){
adc1_config_channel_atten(ADC1_CHANNEL_7,ADC_ATTEN_DB_6);
#endif
batt_read();
writedisplaytext("LoRa-APRS","","Init:","ADC OK!","BAT: "+String(BattVolts,1),"");
writedisplaytext("LoRa-APRS","","Init:","ADC OK!","BAT: "+String(BattVolts,2),"");
if(lora_speed==1200)
rf95.setModemConfig(BG_RF95::Bw125Cr47Sf512);
@ -876,6 +901,15 @@ void setup(){
time_to_refresh = millis() + showRXTime;
displayInvalidGPS();
digitalWrite(TXLED, HIGH);
// Hold the OLED ON at first boot
oled_timer=millis()+oled_timeout;
}
void enableOled() {
// This function enables OLED display after pressing a button
tempOled = true;
oled_timer = millis() + oled_timeout;
}
// +---------------------------------------------------------------------+//
@ -889,19 +923,47 @@ void loop() {
delay(300);
time_delay = millis() + 1500;
if(digitalRead(BUTTON)==HIGH){
if(gps_state == true && gps.location.isValid()){
writedisplaytext("((MAN TX))","","","","","");
sendpacket();
}else{
writedisplaytext("((FIX TX))","","","","","");
sendpacket();
if (!tempOled && enabled_oled) {
enableOled(); // turn ON OLED temporary
} else {
if(gps_state == true && gps.location.isValid()){
writedisplaytext("((MAN TX))","","","","","");
sendpacket();
}else{
writedisplaytext("((FIX TX))","","","","","");
sendpacket();
}
}
key_up = true;
}
}
}
if (manBeacon) {
// Manually sending beacon from html page
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) {
if (oled_timeout>0) {
display.dim(!tempOled);
} else {
// If timeout is 0 keep OLED awake
display.dim(false);
}
}
if (tempOled && millis()>= oled_timer) {
tempOled = false; // After some time reset backlight
}
if(digitalRead(BUTTON)==LOW && key_up == false && millis() >= time_delay && t_lock == false){
// enable OLED
enableOled();
//---------------
t_lock = true;
if(gps_state){
gps_state = false;
@ -913,8 +975,6 @@ void loop() {
#ifdef ENABLE_PREFERENCES
preferences.putBool(PREF_APRS_GPS_EN, false);
#endif
}else{
gps_state = true;
#ifdef T_BEAM_V1_0
@ -934,6 +994,7 @@ void loop() {
if (fixed_beacon_enabled) {
if (millis() >= next_fixed_beacon && !gps_state) {
enableOled(); // enable OLED
next_fixed_beacon = millis() + fix_beacon_interval;
writedisplaytext("((AUT TX))", "", "", "", "", "");
sendpacket();
@ -965,6 +1026,7 @@ void loop() {
String *TNC2DataFrame = nullptr;
if (tncToSendQueue) {
if (xQueueReceive(tncToSendQueue, &TNC2DataFrame, (1 / portTICK_PERIOD_MS)) == pdPASS) {
enableOled(); // enable OLED
writedisplaytext("((KISSTX))","","","","","");
time_to_refresh = millis() + showRXTime;
loraSend(txPower, lora_freq, *TNC2DataFrame);
@ -989,6 +1051,7 @@ void loop() {
loraReceivedFrameString = "";
//int rssi = rf95.lastSNR();
//Serial.println(rssi);
enableOled(); // enable OLED
for (int i=0 ; i < loraReceivedLength ; i++) {
loraReceivedFrameString += (char) lora_RXBUFF[i];
}
@ -1056,6 +1119,7 @@ void loop() {
}
if ( (lastTX+nextTX) <= millis() ) {
if (gps.location.age() < 2000) {
enableOled(); // enable OLED
writedisplaytext(" ((TX))","","LAT: "+LatShown,"LON: "+LongShown,"SPD: "+String(gps.speed.kmph(),1)+" CRS: "+String(gps.course.deg(),1),getSatAndBatInfo());
sendpacket();
} else {
@ -1111,4 +1175,4 @@ void loop() {
#endif
#endif
vTaskDelay(1);
}
}

Wyświetl plik

@ -16,12 +16,17 @@ 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 <tReceivedPacketData*> receivedPackets;
const int MAX_RECEIVED_LIST_SIZE = 50;
String apSSID = "";
String apPassword = "xxxxxxxxxx";
String apPassword;
String defApPassword = "xxxxxxxxxx";
WebServer server(80);
#ifdef KISS_PROTOCOL
WiFiServer tncServer(NETWORK_TNC_PORT);
@ -109,16 +114,38 @@ void handle_ScanWifi() {
}
void handle_SaveWifiCfg() {
if (!server.hasArg(PREF_WIFI_SSID) || !server.hasArg(PREF_WIFI_PASSWORD)){
server.send(500, "text/plain", "Invalid request");
if (!server.hasArg(PREF_WIFI_SSID) || !server.hasArg(PREF_WIFI_PASSWORD) || !server.hasArg(PREF_AP_PASSWORD)){
server.send(500, "text/plain", "Invalid request, make sure all fields are set");
}
if (!server.arg(PREF_WIFI_SSID).length()){
server.send(403, "text/plain", "Empty SSID or Password");
server.send(403, "text/plain", "Empty SSID");
} else {
// Update SSID
preferences.putString(PREF_WIFI_SSID, server.arg(PREF_WIFI_SSID));
Serial.println("Updated SSID: " + server.arg(PREF_WIFI_SSID));
}
preferences.putString(PREF_WIFI_SSID, server.arg(PREF_WIFI_SSID));
preferences.putString(PREF_WIFI_PASSWORD, server.arg(PREF_WIFI_PASSWORD));
if (server.arg(PREF_WIFI_PASSWORD)!="*" && server.arg(PREF_WIFI_PASSWORD).length()>0 && server.arg(PREF_WIFI_PASSWORD).length()<8){
server.send(403, "text/plain", "WiFi Password must be minimum 8 character");
} else {
if (server.arg(PREF_WIFI_PASSWORD)!="*") {
// Update WiFi password
preferences.putString(PREF_WIFI_PASSWORD, server.arg(PREF_WIFI_PASSWORD));
Serial.println("Updated WiFi PASS: " + server.arg(PREF_WIFI_PASSWORD));
}
}
if (server.arg(PREF_AP_PASSWORD)!="*" && server.arg(PREF_AP_PASSWORD).length()<8){
server.send(403, "text/plain", "AP Password must be minimum 8 character");
} else {
if (server.arg(PREF_AP_PASSWORD)!="*") {
// Update AP password
preferences.putString(PREF_AP_PASSWORD, server.arg(PREF_AP_PASSWORD));
Serial.println("Updated AP PASS: " + server.arg(PREF_AP_PASSWORD));
}
}
server.sendHeader("Location", "/");
server.send(302,"text/html", "");
}
@ -130,8 +157,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();
@ -151,6 +183,7 @@ void handle_Restore() {
void handle_Cfg() {
String jsonData = "{";
jsonData += String("\"") + PREF_WIFI_PASSWORD + "\": \"" + jsonEscape((preferences.getString(PREF_WIFI_PASSWORD).isEmpty() ? String("") : "*")) + R"(",)";
jsonData += String("\"") + PREF_AP_PASSWORD + "\": \"" + jsonEscape((preferences.getString(PREF_AP_PASSWORD).isEmpty() ? String("") : "*")) + R"(",)";
jsonData += jsonLineFromPreferenceString(PREF_WIFI_SSID);
jsonData += jsonLineFromPreferenceDouble(PREF_LORA_FREQ_PRESET);
jsonData += jsonLineFromPreferenceInt(PREF_LORA_SPEED_PRESET);
@ -179,6 +212,7 @@ void handle_Cfg() {
jsonData += jsonLineFromPreferenceInt(PREF_DEV_SHOW_RX_TIME);
jsonData += jsonLineFromPreferenceBool(PREF_DEV_AUTO_SHUT);
jsonData += jsonLineFromPreferenceInt(PREF_DEV_AUTO_SHUT_PRESET);
jsonData += jsonLineFromPreferenceInt(PREF_DEV_SHOW_OLED_TIME);
jsonData += jsonLineFromInt("FreeHeap", ESP.getFreeHeap());
jsonData += jsonLineFromInt("HeapSize", ESP.getHeapSize());
jsonData += jsonLineFromInt("FreeSketchSpace", ESP.getFreeSketchSpace());
@ -191,6 +225,7 @@ void handle_Cfg() {
void handle_ReceivedList() {
PSRAMJsonDocument doc(MAX_RECEIVED_LIST_SIZE * 1000);
//DynamicJsonDocument doc(MAX_RECEIVED_LIST_SIZE * 500);
JsonObject root = doc.to<JsonObject>();
auto received = root.createNestedArray("received");
for (auto element: receivedPackets){
@ -278,6 +313,10 @@ void handle_saveDeviceCfg(){
if (server.hasArg(PREF_DEV_SHOW_RX_TIME)){
preferences.putInt(PREF_DEV_SHOW_RX_TIME, server.arg(PREF_DEV_SHOW_RX_TIME).toInt());
}
// Manage OLED Timeout
if (server.hasArg(PREF_DEV_SHOW_OLED_TIME)){
preferences.putInt(PREF_DEV_SHOW_OLED_TIME, server.arg(PREF_DEV_SHOW_OLED_TIME).toInt());
}
preferences.putBool(PREF_DEV_AUTO_SHUT, server.hasArg(PREF_DEV_AUTO_SHUT));
if (server.hasArg(PREF_DEV_AUTO_SHUT_PRESET)){
preferences.putInt(PREF_DEV_AUTO_SHUT_PRESET, server.arg(PREF_DEV_AUTO_SHUT_PRESET).toInt());
@ -297,6 +336,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);
@ -338,6 +378,12 @@ void handle_saveDeviceCfg(){
String wifi_password = preferences.getString(PREF_WIFI_PASSWORD);
String wifi_ssid = preferences.getString(PREF_WIFI_SSID);
if (preferences.getString(PREF_AP_PASSWORD).length() > 8) {
// 8 characters is requirements for WPA2
apPassword = preferences.getString(PREF_AP_PASSWORD);
} else {
apPassword = defApPassword;
}
if (!wifi_ssid.length()){
WiFi.softAP(apSSID.c_str(), apPassword.c_str());
} else {
@ -353,15 +399,24 @@ void handle_saveDeviceCfg(){
retryWifi += 1;
if (retryWifi > 60) {
WiFi.softAP(apSSID.c_str(), apPassword.c_str());
//WiFi.softAP(apSSID.c_str(), "password");
Serial.println("Unable to connect to to wifi. Starting AP");
Serial.print("SSID: ");
Serial.print(apSSID.c_str());
Serial.print(" Password: ");
Serial.println(apPassword.c_str());
break;
}
}
if (WiFi.getMode() == wifi_mode_t::WIFI_MODE_AP){
//Serial.print("WiFi Mode: ");
//Serial.println(WiFi.getMode());
if (WiFi.getMode() == 3){
Serial.println("Running AP. IP: " + WiFi.softAPIP().toString());
} else {
} else if (WiFi.getMode() == 1) {
Serial.println("Connected. IP: " + WiFi.localIP().toString());
} else {
Serial.println("WiFi Mode: " + WiFi.getMode());
}
#ifdef ENABLE_SYSLOG