Version 0.3.1 Added: 1. Freq config via WWW 2. APRS Mode config via WWW (300/1200) 3.Txpower setting via www

master
US1GHQ 2021-07-27 18:23:56 +03:00
parent 69568a2f91
commit b505b002cf
6 changed files with 114 additions and 36 deletions

View File

@ -42,10 +42,10 @@
</div>
<article>
<form action="/save_aprs_cfg" method="post">
<div class="grid-container quarters">
<div class="grid-container full">
<h5 class="u-full-width">Station Settings</h5>
</div>
<div class="grid-container quarters">
<div>
<label for="aprs_callsign">Callsign and SSID</label>
<input class="u-full-width" type="text" minlength="3" name="aprs_callsign" placeholder="NOCALL-1" id="aprs_callsign" title="your callsign with SSID">
@ -78,10 +78,10 @@
<label for="aprs_batt">Show Battery</label>
<input name="aprs_batt" id="aprs_batt" type="checkbox" value="1" title=" show battery voltage after personal comment">
</div>
</div>
<div class="grid-container full">
<h5 class="u-full-width">Fixed Beaconing Settings</h5>
</div>
</div>
<div class="grid-container quarters">
<div>
<label for="aprs_fixed_beac">Fixed Beacon</label>
@ -106,19 +106,19 @@
<div class="grid-container quarters">
<div>
<label for="sb_min_interv">Min interval [s]</label>
<input name="sb_min_interv" id="sb_min_interv" type="number" min="60" title="Minimal time for Smart Beaconing">
<input name="sb_min_interv" id="sb_min_interv" size="10" type="number" min="60" title="Minimal time for Smart Beaconing">
</div>
<div>
<label for="sb_max_interv">Max interval [s]</label>
<input name="sb_max_interv" id="sb_max_interv" type="number" min="120" title="Maximal time for Smart Beaconing">
<input name="sb_max_interv" id="sb_max_interv" size="10" type="number" min="120" title="Maximal time for Smart Beaconing">
</div>
<div>
<label for="sb_min_speed">Min speed [km/h]</label>
<input name="sb_min_speed" id="sb_min_speed" type="number" min="0" title="Minimal speed for Smart Beaconing">
<input name="sb_min_speed" id="sb_min_speed" size="10" type="number" min="0" title="Minimal speed for Smart Beaconing">
</div>
<div>
<label for="sb_max_speed">Max speed [km/h]</label>
<input name="sb_max_speed" id="sb_max_speed" type="number" min="1" title="Maximal speed for Smart Beaconing">
<input name="sb_max_speed" id="sb_max_speed" size="10" type="number" min="1" title="Maximal speed for Smart Beaconing">
</div>
</div>
<div class="grid-container quarters">
@ -142,6 +142,24 @@
<h2 class="u-full-width">Device Settings</h2>
</div>
<div class="grid-container quarters">
<div>
<label for="aprs_freq">APRS FREQ MHz:</label>
<input class="u-full-width" type="number" min="0" step="0.001" name="aprs_freq" id="aprs_freq" title="APRS FREQ Default: 433.775">
</div>
<div>
<label for="aprs_mode">APRS MODE:</label>
<select name="aprs_mode" id="aprs_mode" title="APRS MODE 1200 or 300 Default: 300">
<option value="1200">1200</option>
<option value="300">300</option>
</select>
</div>
<div>
<label for="aprs_txpower">APRS TX POWER dBm:</label>
<input class="u-full-width" type="number" min="0" max="23" name="aprs_txpower" id="aprs_txpower" title="APRS TX POWER Default: 20">
</div>
<div>
</div>
<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">

View File

@ -8,6 +8,7 @@
extern Preferences preferences;
// MAX 15 chars for preferenece key!!!
//MAIN SETTINGS
static const char *const PREF_WIFI_SSID = "wifi_ssid";
static const char *const PREF_WIFI_PASSWORD = "wifi_password";
static const char *const PREF_APRS_CALLSIGN = "aprs_callsign";
@ -29,6 +30,7 @@ static const char *const PREF_APRS_FIXED_BEACON_PRESET = "aprs_fixed_beac";
static const char *const PREF_APRS_FIXED_BEACON_PRESET_INIT = "aprs_fix_b_init";
static const char *const PREF_APRS_FIXED_BEACON_INTERVAL_PRESET = "aprs_fb_interv";
static const char *const PREF_APRS_FIXED_BEACON_INTERVAL_PRESET_INIT = "aprs_fb_in_init";
// SMART BEACONING
static const char *const PREF_APRS_SB_MIN_INTERVAL_PRESET = "sb_min_interv";
static const char *const PREF_APRS_SB_MIN_INTERVAL_PRESET_INIT = "sb_min_interv_i";
@ -38,7 +40,15 @@ static const char *const PREF_APRS_SB_MIN_SPEED_PRESET = "sb_min_speed";
static const char *const PREF_APRS_SB_MIN_SPEED_PRESET_INIT = "sb_min_speed_i";
static const char *const PREF_APRS_SB_MAX_SPEED_PRESET = "sb_max_speed";
static const char *const PREF_APRS_SB_MAX_SPEED_PRESET_INIT = "sb_max_speed_i";
// FREQ AND MODE SET
static const char *const PREF_APRS_FREQ = "aprs_freq"; //freq default: 433.775
static const char *const PREF_APRS_FREQ_INIT = "aprs_freq_i";
static const char *const PREF_APRS_MODE = "aprs_mode"; //300 or 1200b
static const char *const PREF_APRS_MODE_INIT = "aprs_mode_i";
static const char *const PREF_APRS_TXPOWER = "aprs_txpower"; //default 20dbm
static const char *const PREF_APRS_TXPOWER_INIT = "aprs_txpower_i";
//Other 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";

View File

@ -43,7 +43,7 @@ build_flags =
-D 'SHOW_BATT'
-D 'SHOW_RX_PACKET'
-D 'SHOW_RX_TIME=10000'
-D 'TXFREQ=433.775'
-D 'TXFREQ="433.775"'
; -D 'SPEED_1200' ; comment out to set 300baud
-D 'TXdbmW=20'
-D 'ENABLE_OLED'
@ -125,8 +125,8 @@ board = esp32dev
;board_build.f_cpu = 80000000L
build_flags =
${env.build_flags}
; -D ENABLE_WIFI
-D ENABLE_BLUETOOTH
-D ENABLE_WIFI
; -D ENABLE_BLUETOOTH
-D ESP32_DEV_V1
[env:ttgo-t-beam-v1.0-development]

View File

@ -62,11 +62,11 @@
#define BUZZER 15 // enter your buzzer pin gpio
const byte TXLED = 4; //pin number for LED on TX Tracker
#elif LORA32_21
#define I2C_SDA 4
#define I2C_SCL 15
#define I2C_SDA 21
#define I2C_SCL 22
#define BUTTON 2 //pin number for BUTTO
#define BUZZER 13 // enter your buzzer pin gpio
const byte TXLED = 4; //pin number for LED on TX Tracker
const byte TXLED = 25; //pin number for LED on TX Tracker
#elif LORA32_2
#define I2C_SDA 21
#define I2C_SCL 22
@ -113,6 +113,15 @@ String relay_path;
String aprsComment = MY_COMMENT;
String aprsLatPreset = LATIDUDE_PRESET;
String aprsLonPreset = LONGITUDE_PRESET;
String aprsFreq = TXFREQ;
#ifdef SPEED_1200
int aprsMode = 1200;
#else
int aprsMode = 300;
#endif
boolean gps_state = true;
boolean key_up = true;
boolean t_lock = false;
@ -344,16 +353,16 @@ void sendpacket(){
#endif
batt_read();
prepareAPRSFrame();
loraSend(txPower, TXFREQ, outString); //send the packet, data is in TXbuff from lora_TXStart to lora_TXEnd
loraSend(txPower, aprsFreq, outString); //send the packet, data is in TXbuff from lora_TXStart to lora_TXEnd
}
/**
* Send message as APRS LoRa packet
* @param lora_LTXPower
* @param lora_FREQ
* @param txPower
* @param aprsFreq
* @param message
*/
void loraSend(byte lora_LTXPower, float lora_FREQ, const String &message) {
void loraSend(byte txPower, String aprsFreq, const String &message) {
#ifdef TX_RX_LNA
digitalWrite(TXPIN, HIGH);
digitalWrite(RXPIN, LOW);
@ -366,13 +375,17 @@ void loraSend(byte lora_LTXPower, float lora_FREQ, const String &message) {
int messageSize = min(message.length(), sizeof(lora_TXBUFF) - 1);
message.toCharArray((char*)lora_TXBUFF, messageSize + 1, 0);
#ifdef SPEED_1200
if (aprsMode == 1200)
{
rf95.setModemConfig(BG_RF95::Bw125Cr47Sf512);
#else
}
else
{
rf95.setModemConfig(BG_RF95::Bw125Cr45Sf4096);
#endif
rf95.setFrequency(lora_FREQ);
rf95.setTxPower(lora_LTXPower);
}
float aprsFreq2 = aprsFreq.toFloat();
rf95.setFrequency(aprsFreq2);
rf95.setTxPower(txPower);
rf95.sendAPRS(lora_TXBUFF, messageSize);
rf95.waitPacketSent();
#ifdef TX_RX_LNA
@ -644,7 +657,6 @@ void setup(){
}
sb_max_interval = preferences.getInt(PREF_APRS_SB_MAX_INTERVAL_PRESET) * 1000;
if (!preferences.getBool(PREF_APRS_SB_MIN_SPEED_PRESET_INIT)){
preferences.putBool(PREF_APRS_SB_MIN_SPEED_PRESET_INIT, true);
preferences.putInt(PREF_APRS_SB_MIN_SPEED_PRESET, sb_min_speed);
@ -656,7 +668,25 @@ void setup(){
preferences.putInt(PREF_APRS_SB_MAX_SPEED_PRESET, sb_max_speed);
}
sb_max_speed = preferences.getInt(PREF_APRS_SB_MAX_SPEED_PRESET);
//
//Set parameters (freq,mode,txpower)
if (!preferences.getBool(PREF_APRS_FREQ_INIT)){
preferences.putBool(PREF_APRS_FREQ_INIT, true);
preferences.putString(PREF_APRS_FREQ, aprsFreq);
}
aprsFreq = preferences.getString(PREF_APRS_FREQ);
if (!preferences.getBool(PREF_APRS_MODE_INIT)){
preferences.putBool(PREF_APRS_MODE_INIT, true);
preferences.putInt(PREF_APRS_MODE, aprsMode);
}
aprsMode = preferences.getInt(PREF_APRS_MODE);
if (!preferences.getBool(PREF_APRS_TXPOWER_INIT)){
preferences.putBool(PREF_APRS_TXPOWER_INIT, true);
preferences.putInt(PREF_APRS_TXPOWER, txPower);
}
txPower = preferences.getInt(PREF_APRS_TXPOWER);
//End set parameters
if (!preferences.getBool(PREF_DEV_SHOW_RX_TIME_INIT)){
preferences.putBool(PREF_DEV_SHOW_RX_TIME_INIT, true);
preferences.putInt(PREF_DEV_SHOW_RX_TIME, showRXTime/1000);
@ -800,12 +830,16 @@ void setup(){
#endif
batt_read();
writedisplaytext("LoRa-APRS","","Init:","ADC OK!","BAT: "+String(BattVolts,1),"");
#ifdef SPEED_1200
if (aprsMode == 1200)
{
rf95.setModemConfig(BG_RF95::Bw125Cr47Sf512);
#else
}
else
{
rf95.setModemConfig(BG_RF95::Bw125Cr45Sf4096);
#endif
rf95.setFrequency(433.775);
}
float aprsFreq2 = aprsFreq.toFloat();
rf95.setFrequency(aprsFreq2);
rf95.setTxPower(txPower);
delay(250);
#ifdef KISS_PROTOCOL
@ -930,7 +964,7 @@ void loop() {
if (xQueueReceive(tncToSendQueue, &TNC2DataFrame, (1 / portTICK_PERIOD_MS)) == pdPASS) {
writedisplaytext("((KISSTX))","","","","","");
time_to_refresh = millis() + showRXTime;
loraSend(txPower, TXFREQ, *TNC2DataFrame);
loraSend(txPower, aprsFreq, *TNC2DataFrame);
delete TNC2DataFrame;
}
}

View File

@ -56,6 +56,9 @@ String jsonLineFromPreferenceBool(const char *preferenceName, bool last=false){
String jsonLineFromPreferenceInt(const char *preferenceName, bool last=false){
return String("\"") + preferenceName + "\":" + (preferences.getInt(preferenceName)) + (last ? + R"()" : + R"(,)");
}
String jsonLineFromPreferenceFloat(const char *preferenceName, bool last=false){
return String("\"") + preferenceName + "\":\"" + (preferences.getFloat(preferenceName)) + (last ? + R"(")" : + R"(",)");
}
String jsonLineFromString(const char *name, const char *value, bool last=false){
return String("\"") + name + "\":\"" + jsonEscape(value) + "\"" + (last ? + R"()" : + R"(,)");
}
@ -146,6 +149,9 @@ void handle_Cfg() {
jsonData += jsonLineFromPreferenceBool(PREF_APRS_FIXED_BEACON_PRESET);
jsonData += jsonLineFromPreferenceBool(PREF_APRS_SHOW_ALTITUDE);
jsonData += jsonLineFromPreferenceBool(PREF_APRS_GPS_EN);
jsonData += jsonLineFromPreferenceString(PREF_APRS_FREQ);
jsonData += jsonLineFromPreferenceInt(PREF_APRS_MODE);
jsonData += jsonLineFromPreferenceInt(PREF_APRS_TXPOWER);
jsonData += jsonLineFromPreferenceBool(PREF_DEV_OL_EN);
jsonData += jsonLineFromPreferenceBool(PREF_APRS_SHOW_CMT);
jsonData += jsonLineFromPreferenceBool(PREF_DEV_BT_EN);
@ -215,6 +221,7 @@ void handle_SaveAPRSCfg() {
preferences.putString(PREF_APRS_LONGITUDE_PRESET, server.arg(PREF_APRS_LONGITUDE_PRESET));
}
preferences.putBool(PREF_APRS_SHOW_BATTERY, server.hasArg(PREF_APRS_SHOW_BATTERY));
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));
@ -235,6 +242,15 @@ void handle_saveDeviceCfg(){
if (server.hasArg(PREF_DEV_AUTO_SHUT_PRESET)){
preferences.putInt(PREF_DEV_AUTO_SHUT_PRESET, server.arg(PREF_DEV_AUTO_SHUT_PRESET).toInt());
}
if (server.hasArg(PREF_APRS_FREQ)){
preferences.putString(PREF_APRS_FREQ, server.arg(PREF_APRS_FREQ));
}
if (server.hasArg(PREF_APRS_MODE)){
preferences.putInt(PREF_APRS_MODE, server.arg(PREF_APRS_MODE).toInt());
}
if (server.hasArg(PREF_APRS_TXPOWER)){
preferences.putInt(PREF_APRS_TXPOWER, server.arg(PREF_APRS_TXPOWER).toInt());
}
server.sendHeader("Location", "/");
server.send(302,"text/html", "");
}
@ -341,7 +357,7 @@ void handle_saveDeviceCfg(){
tncServer.begin();
#endif
if (MDNS.begin(webServerCfg->callsign.c_str())) {
MDNS.setInstanceName(webServerCfg->callsign + " TTGO LoRa APRS TNC " + TXFREQ + "MHz");
MDNS.setInstanceName(webServerCfg->callsign + " LoRa APRS TNC ");
MDNS.addService("http", "tcp", 80);
#ifdef KISS_PROTOCOL
MDNS.addService("kiss-tnc", "tcp", NETWORK_TNC_PORT);

View File

@ -1,6 +1,6 @@
FILENAME_BUILDNO = '.pio/versioning'
FILENAME_VERSION_H = 'include/version.h'
version = 'v0.3.'
version = 'v0.3.1.'
import datetime
from subprocess import *
@ -11,7 +11,7 @@ try:
build_no = int(f.readline()) + 1
except:
print('Starting build number from 1..')
build_no = 143
build_no = 1
with open(FILENAME_BUILDNO, 'w+') as f:
f.write(str(build_no))
print('Build number: {}'.format(build_no))