v0.5: merging modifications from devel branch

- DL2MF's commits
 - WiFi connection in background

Squashed commit of the following:

commit 5c37b3f0fa
Author: Hans P. Reiser <hr@sec.uni-passau.de>
Date:   Sun Apr 28 14:17:52 2019 +0200

    version from config.h also for html page; minor polishing

commit 9fea636d20
Author: Hans P. Reiser <hr@sec.uni-passau.de>
Date:   Sun Apr 28 14:17:37 2019 +0200

    version from config.h also for html page; minor polishing

commit 75eb15cc24
Author: Hans P. Reiser <hr@sec.uni-passau.de>
Date:   Sun Apr 28 13:29:58 2019 +0200

    version info in version.h, some code formatting (arduino style)

commit 8da577a313
Author: Hans P. Reiser <hr@sec.uni-passau.de>
Date:   Sun Apr 28 13:29:53 2019 +0200

    version info in version.h, some code formatting (arduino style)

commit b68ffee8b0
Author: Mike <mail@dl2mf.de>
Date:   Sat Apr 27 20:54:20 2019 +0200

    merging DL2MF's 71cc86cff0

commit c67a4fc734
Author: DL2MF <meinhard.guenther@gmail.com>
Date:   Sat Apr 27 00:10:11 2019 +0200

    merging DL2MF's e2161c57d1

commit 6e665cb6ab
Author: DL2MF <meinhard.guenther@gmail.com>
Date:   Fri Apr 26 19:21:11 2019 +0200

    merging DL2MF's 25b438db84 to current devel branch

commit b467f25c05
Author: Hans P. Reiser <hr@sec.uni-passau.de>
Date:   Fri Apr 26 23:54:36 2019 +0200

    working new Wifi support

commit 2959dfad4f
Author: Hans P. Reiser <hr@sec.uni-passau.de>
Date:   Fri Apr 26 23:09:09 2019 +0200

    background wifi scan/connected/reconnect. partial code, incomplete, for testing station mode only (wifi=1)
pull/22/head
Hans P. Reiser 2019-04-28 14:33:53 +02:00
rodzic 0518f070a2
commit ca3fa52a3b
7 zmienionych plików z 625 dodań i 368 usunięć

Wyświetl plik

@ -10,8 +10,7 @@
#include <Sonde.h>
#include <Scanner.h>
#include <aprs.h>
#define LORA_LED 9
#include "version.h"
// UNCOMMENT one of the constructor lines below
U8X8_SSD1306_128X64_NONAME_SW_I2C *u8x8 = NULL; // initialize later after reading config file
@ -19,6 +18,7 @@ U8X8_SSD1306_128X64_NONAME_SW_I2C *u8x8=NULL; // initialize later after reading
//U8G2_SSD1306_128X64_NONAME_1_SW_I2C Display(U8G2_R0, /* clock=*/ OLED_SCL, /* data=*/ OLED_SDA, /* reset=*/ OLED_RST); // Page buffer, SW I2C
//U8G2_SSD1306_128X64_NONAME_F_SW_I2C Display(U8G2_R0, /* clock=*/ OLED_SCL, /* data=*/ OLED_SDA, /* reset=*/ OLED_RST); // Full framebuffer, SW I2C
int LORA_LED = 9; // default POUT for LORA LED used as serial monitor
int e;
AsyncWebServer server(80);
@ -46,18 +46,24 @@ String processor(const String& var){
Serial.print(ledState);
return ledState;
}
if(var == "VERSION_NAME") {
return String(version_name);
}
if(var == "VERSION_ID") {
return String(version_id);
}
return String();
}
#define MAX_QRG 10
const String sondeTypeSelect(int activeType) {
String sts = "";
for (int i = 0; i < 3; i++) {
sts += "<option value=\"";
sts += sondeTypeStr[i];
sts += "\"";
if(activeType==i) { sts += " selected"; }
if (activeType == i) {
sts += " selected";
}
sts += ">";
sts += sondeTypeStr[i];
sts += "</option>";
@ -91,9 +97,15 @@ void setupChannelList() {
*space = 0;
float freq = atof(line.c_str());
SondeType type;
if(space[1]=='4') { type=STYPE_RS41; }
else if (space[1]=='9') { type=STYPE_DFM09; }
else if (space[1]=='6') { type=STYPE_DFM06; }
if (space[1] == '4') {
type = STYPE_RS41;
}
else if (space[1] == '9') {
type = STYPE_DFM09;
}
else if (space[1] == '6') {
type = STYPE_DFM06;
}
else continue;
int active = space[3] == '+' ? 1 : 0;
char *launchsite = strchr(line.c_str(), ' ');
@ -137,7 +149,7 @@ const char *handleQRGPost(AsyncWebServerRequest *request) {
Serial.println(request->getParam(i)->name().c_str());
}
#endif
for(int i=1; i<=MAX_QRG; i++) {
for (int i = 1; i <= sonde.config.maxsonde; i++) {
snprintf(label, 10, "A%d", i);
AsyncWebParameter *active = request->getParam(label, true);
snprintf(label, 10, "F%d", i);
@ -164,7 +176,10 @@ const char *handleQRGPost(AsyncWebServerRequest *request) {
#define MAX_WIFI 10
int nNetworks;
struct { String id; String pw; } networks[MAX_WIFI];
struct {
String id;
String pw;
} networks[MAX_WIFI];
// FIXME: For now, we don't uspport wifi networks that contain newline or null characters
// ... would require a more sophisicated file format (currently one line SSID; one line Password
@ -185,7 +200,11 @@ void setupWifiList() {
}
nNetworks = i;
Serial.print(i); Serial.println(" networks in networks.txt\n");
for(int j=0; j<i; j++) { Serial.print(networks[j].id); Serial.print(": "); Serial.println(networks[j].pw); }
for (int j = 0; j < i; j++) {
Serial.print(networks[j].id);
Serial.print(": ");
Serial.println(networks[j].pw);
}
}
@ -286,8 +305,8 @@ struct st_configitems {
int type; // 0: numeric; i>0 string of length i; -1: separator; -2: type selector
void *data;
};
#define N_CONFIG 20
struct st_configitems config_list[N_CONFIG] = {
struct st_configitems config_list[] = {
{"ShowSpectrum (s)", 0, &sonde.config.spectrum},
{"Startfreq (MHz)", 0, &sonde.config.startfreq},
{"Bandwidth (kHz)", 0, &sonde.config.channelbw},
@ -309,6 +328,7 @@ struct st_configitems config_list[N_CONFIG] = {
{"---", -1, NULL},
{"Spectrum noise floor", 0, &sonde.config.noisefloor}
};
const static int N_CONFIG=(sizeof(config_list)/sizeof(struct st_configitems));
void addConfigStringEntry(char *ptr, int idx, const char *label, int len, char *field) {
sprintf(ptr + strlen(ptr), "<tr><td>%s</td><td><input name=\"CFG%d\" type=\"text\" value=\"%s\"/></td></tr>\n",
@ -359,6 +379,7 @@ const char *createConfigForm() {
const char* PARAM_MESSAGE = "message";
void SetupAsyncServer() {
server.reset();
// Route for root / web page
server.on("/", HTTP_GET, [](AsyncWebServerRequest * request) {
request->send(SPIFFS, "/index.html", String(), false, processor);
@ -411,6 +432,19 @@ void SetupAsyncServer() {
server.begin();
}
int fetchWifiIndex(const char *id) {
for (int i = 0; i < nNetworks; i++) {
if (strcmp(id, networks[i].id.c_str()) == 0) return i;
}
return -1;
}
const char *fetchWifiSSID(int i) {
return networks[i].id.c_str();
}
const char *fetchWifiPw(int i) {
return networks[i].pw.c_str();
}
const char *fetchWifiPw(const char *id) {
for (int i = 0; i < nNetworks; i++) {
@ -448,8 +482,12 @@ void IRAM_ATTR buttonISR() {
} else { //Button up
unsigned int elapsed = millis() - button1.press_ts;
if (elapsed > 1500) {
if(elapsed<4000) { button1.pressed=KP_MID; }
else { button1.pressed=KP_LONG; }
if (elapsed < 4000) {
button1.pressed = KP_MID;
}
else {
button1.pressed = KP_LONG;
}
} else {
if (button1.doublepress) button1.pressed = KP_DOUBLE;
else button1.pressed = KP_SHORT;
@ -484,6 +522,7 @@ void setup()
}
setupConfigData(); // configuration must be read first due to OLED ports!!!
LORA_LED = sonde.config.led_pout;
u8x8 = new U8X8_SSD1306_128X64_NONAME_SW_I2C(/* clock=*/ sonde.config.oled_scl, /* data=*/ sonde.config.oled_sda, /* reset=*/ sonde.config.oled_rst); // Unbuffered, basic graphics, software I2C
u8x8->begin();
@ -492,9 +531,11 @@ void setup()
u8x8->clear();
u8x8->setFont(u8x8_font_7x14_1x2_r);
u8x8->drawString(1, 1, "RDZ_TTGO_SONDE");
u8x8->drawString(2, 3, " V0.1e");
u8x8->drawString(1, 5, "Mods by DL2MF");
u8x8->drawString(8 - strlen(version_name) / 2, 1, version_name);
u8x8->drawString(8 - strlen(version_id) / 2, 3, version_id);
u8x8->setFont(u8x8_font_chroma48medium8_r);
u8x8->drawString(0, 5, "by Hansi, DL9RDZ");
u8x8->drawString(1, 6, "Mods by DL2MF");
delay(3000);
sonde.clearDisplay();
@ -523,7 +564,7 @@ void setup()
u8x8->drawString(6, 3, buf);
delay(1000);
itoa(sonde.config.led_pin, buf, 10);
itoa(sonde.config.led_pout, buf, 10);
u8x8->drawString(0, 4, " LED:");
u8x8->drawString(6, 4, buf);
@ -593,11 +634,12 @@ void setup()
// == setup default channel list if qrg.txt read fails =========== //
sonde.setup();
WiFi.onEvent(WiFiEvent);
}
enum MainState { ST_DECODER, ST_SCANNER, ST_SPECTRUM, ST_WIFISCAN };
static MainState mainState = ST_WIFISCAN;
static MainState mainState = ST_WIFISCAN; // ST_WIFISCAN;
void enterMode(int mode) {
mainState = (MainState)mode;
@ -673,7 +715,12 @@ void loopScanner() {
}
}
static unsigned long specTimer;
void loopSpectrum() {
int marker = 0;
char buf[10];
switch (getKeyPress()) {
case KP_SHORT: /* move selection of peak, TODO */
sonde.nextConfig(); // TODO: Should be set specific frequency
@ -686,8 +733,37 @@ void loopSpectrum() {
case KP_DOUBLE: /* ignore */ break;
default: break;
}
scanner.scan();
scanner.plotResult();
if (sonde.config.marker != 0) {
itoa((sonde.config.startfreq), buf, 10);
u8x8->drawString(0, 1, buf);
u8x8->drawString(7, 1, "MHz");
itoa((sonde.config.startfreq + 6), buf, 10);
u8x8->drawString(13, 1, buf);
}
if (sonde.config.timer) {
int remaining = sonde.config.spectrum - (millis() - specTimer)/1000;
itoa(remaining, buf, 10);
if (sonde.config.marker != 0) {
marker = 1;
}
u8x8->drawString(0, 1 + marker, buf);
u8x8->drawString(2, 1 + marker, "Sec.");
if (remaining <= 0) {
enterMode(ST_SCANNER);
}
}
}
void startSpectrumDisplay() {
sonde.clearDisplay();
u8x8->setFont(u8x8_font_chroma48medium8_r);
u8x8->drawString(0, 0, "Spectrum Scan...");
delay(500);
specTimer = millis();
enterMode(ST_SPECTRUM);
}
String translateEncryptionType(wifi_auth_mode_t encryptionType) {
@ -707,34 +783,245 @@ String translateEncryptionType(wifi_auth_mode_t encryptionType) {
}
}
//wifi event handler
void WiFiEvent(WiFiEvent_t event){
switch(event) {
case SYSTEM_EVENT_STA_GOT_IP:
//When connected set
Serial.print("WiFi connected! IP address: ");
Serial.println(WiFi.localIP());
//initializes the UDP state
//This initializes the transfer buffer
void enableNetwork(bool enable) {
if (enable) {
SetupAsyncServer();
udp.begin(WiFi.localIP(), LOCALUDPPORT);
connected = true;
} else {
connected = false;
}
}
enum t_wifi_state { WIFI_DISABLED, WIFI_SCAN, WIFI_CONNECT, WIFI_CONNECTED, WIFI_APMODE };
static t_wifi_state wifi_state = WIFI_DISABLED;
// Events used only for debug output right now
void WiFiEvent(WiFiEvent_t event)
{
Serial.printf("[WiFi-event] event: %d\n", event);
switch (event) {
case SYSTEM_EVENT_WIFI_READY:
Serial.println("WiFi interface ready");
break;
case SYSTEM_EVENT_SCAN_DONE:
Serial.println("Completed scan for access points");
break;
case SYSTEM_EVENT_STA_START:
Serial.println("WiFi client started");
break;
case SYSTEM_EVENT_STA_STOP:
Serial.println("WiFi clients stopped");
break;
case SYSTEM_EVENT_STA_CONNECTED:
Serial.println("Connected to access point");
break;
case SYSTEM_EVENT_STA_DISCONNECTED:
Serial.println("WiFi lost connection");
connected = false;
Serial.println("Disconnected from WiFi access point");
if (wifi_state == WIFI_CONNECT) {
// If we get a disconnect event while waiting for connection (as I do sometimes with my FritzBox),
// just start from scratch with WiFi scan
wifi_state = WIFI_DISABLED;
WiFi.disconnect(true);
}
break;
case SYSTEM_EVENT_STA_AUTHMODE_CHANGE:
Serial.println("Authentication mode of access point has changed");
break;
case SYSTEM_EVENT_STA_GOT_IP:
Serial.print("Obtained IP address: ");
Serial.println(WiFi.localIP());
break;
case SYSTEM_EVENT_STA_LOST_IP:
Serial.println("Lost IP address and IP address is reset to 0");
break;
case SYSTEM_EVENT_STA_WPS_ER_SUCCESS:
Serial.println("WiFi Protected Setup (WPS): succeeded in enrollee mode");
break;
case SYSTEM_EVENT_STA_WPS_ER_FAILED:
Serial.println("WiFi Protected Setup (WPS): failed in enrollee mode");
break;
case SYSTEM_EVENT_STA_WPS_ER_TIMEOUT:
Serial.println("WiFi Protected Setup (WPS): timeout in enrollee mode");
break;
case SYSTEM_EVENT_STA_WPS_ER_PIN:
Serial.println("WiFi Protected Setup (WPS): pin code in enrollee mode");
break;
case SYSTEM_EVENT_AP_START:
Serial.println("WiFi access point started");
break;
case SYSTEM_EVENT_AP_STOP:
Serial.println("WiFi access point stopped");
break;
case SYSTEM_EVENT_AP_STACONNECTED:
Serial.println("Client connected");
break;
case SYSTEM_EVENT_AP_STADISCONNECTED:
Serial.println("Client disconnected");
break;
case SYSTEM_EVENT_AP_STAIPASSIGNED:
Serial.println("Assigned IP address to client");
break;
case SYSTEM_EVENT_AP_PROBEREQRECVED:
Serial.println("Received probe request");
break;
case SYSTEM_EVENT_GOT_IP6:
Serial.println("IPv6 is preferred");
break;
case SYSTEM_EVENT_ETH_START:
Serial.println("Ethernet started");
break;
case SYSTEM_EVENT_ETH_STOP:
Serial.println("Ethernet stopped");
break;
case SYSTEM_EVENT_ETH_CONNECTED:
Serial.println("Ethernet connected");
break;
case SYSTEM_EVENT_ETH_DISCONNECTED:
Serial.println("Ethernet disconnected");
break;
case SYSTEM_EVENT_ETH_GOT_IP:
Serial.println("Obtained IP address");
break;
}
}
int wifiConnect(int16_t res) {
Serial.printf("WLAN scan result: found %d networks\n", res);
// pick best network
int bestEntry = -1;
int bestRSSI = INT_MIN;
uint8_t bestBSSID[6];
int32_t bestChannel = 0;
for (int8_t i = 0; i < res; i++) {
String ssid_scan;
int32_t rssi_scan;
uint8_t sec_scan;
uint8_t* BSSID_scan;
int32_t chan_scan;
WiFi.getNetworkInfo(i, ssid_scan, sec_scan, rssi_scan, BSSID_scan, chan_scan);
int networkEntry = fetchWifiIndex(ssid_scan.c_str());
if (networkEntry < 0) continue;
if (rssi_scan <= bestRSSI) continue;
bestEntry = networkEntry;
bestRSSI = rssi_scan;
bestChannel = chan_scan;
memcpy((void*) &bestBSSID, (void*) BSSID_scan, sizeof(bestBSSID));
}
WiFi.scanDelete();
if (bestEntry >= 0) {
Serial.printf("WiFi Connecting BSSID: %02X:%02X:%02X:%02X:%02X:%02X SSID: %s PW %s Channel: %d (RSSI %d)\n", bestBSSID[0], bestBSSID[1], bestBSSID[2], bestBSSID[3], bestBSSID[4], bestBSSID[5], fetchWifiSSID(bestEntry), fetchWifiPw(bestEntry), bestChannel, bestRSSI);
WiFi.begin(fetchWifiSSID(bestEntry), fetchWifiPw(bestEntry), bestChannel, bestBSSID);
wifi_state = WIFI_CONNECT;
} else {
// rescan
// wifiStart();
WiFi.disconnect(true);
wifi_state = WIFI_DISABLED;
}
}
static int wifi_cto;
void loopWifiBackground() {
Serial.printf("WifiBackground: state %d\n", wifi_state);
// handle Wifi station mode in background
if (sonde.config.wifi == 0 || sonde.config.wifi == 2) return; // nothing to do if disabled or access point mode
if (wifi_state == WIFI_DISABLED) { // stopped => start can
wifi_state = WIFI_SCAN;
Serial.println("WLAN start scan");
WiFi.scanNetworks(true); // scan in async mode
} else if (wifi_state == WIFI_SCAN) {
int16_t res = WiFi.scanComplete();
if (res == 0 || res == WIFI_SCAN_FAILED) {
// retry
Serial.println("WLAN restart scan");
WiFi.disconnect(true);
wifi_state = WIFI_DISABLED;
return;
}
if (res == WIFI_SCAN_RUNNING) {
return;
}
// Scan finished, try to connect
wifiConnect(res);
wifi_cto = 0;
} else if (wifi_state == WIFI_CONNECT) {
wifi_cto++;
if (WiFi.isConnected()) {
wifi_state = WIFI_CONNECTED;
// update IP in display
sonde.setIP(WiFi.localIP().toString().c_str(), false);
sonde.updateDisplayIP();
enableNetwork(true);
}
if (wifi_cto > 20) { // failed, restart scanning
wifi_state = WIFI_DISABLED;
WiFi.disconnect(true);
}
} else if (wifi_state == WIFI_CONNECTED) {
if (!WiFi.isConnected()) {
sonde.clearIP();
sonde.updateDisplayIP();
wifi_state = WIFI_DISABLED; // restart scan
enableNetwork(false);
WiFi.disconnect(true);
}
}
}
void startAP() {
Serial.println("Activating access point mode");
wifi_state = WIFI_APMODE;
WiFi.softAP(networks[0].id.c_str(), networks[0].pw.c_str());
IPAddress myIP = WiFi.softAPIP();
sonde.setIP(myIP.toString().c_str(), true);
sonde.updateDisplayIP();
SetupAsyncServer();
}
void initialMode() {
if (sonde.config.spectrum != 0) { // enable Spectrum in config.txt: spectrum=number_of_seconds
startSpectrumDisplay();
//done in startSpectrumScan(): enterMode(ST_SPECTRUM);
} else {
enterMode(ST_SCANNER);
}
}
// Wifi modes
// 0: disabled. directly start initial mode (spectrum or scanner)
// 1: station mode in background. directly start initial mode (spectrum or scanner)
// 2: access point mode in background. directly start initial mode (spectrum or scanner)
// 3: traditional sync. WifiScan. Tries to connect to a network, in case of failure activates AP.
// Mode 3 shows more debug information on serial port and display.
static char* _scan[2] = {"/", "\\"};
void loopWifiScan() {
if (sonde.config.wifi == 0) { // no Wifi
wifi_state = WIFI_DISABLED;
initialMode();
return;
}
if (sonde.config.wifi == 1) { // station mode, setup in background
wifi_state = WIFI_DISABLED; // will start scanning in wifiLoopBackgroiund
initialMode();
return;
}
if (sonde.config.wifi == 2) { // AP mode, setup in background
startAP();
initialMode();
return;
}
// wifi==3 => original mode with non-async wifi setup
u8x8->setFont(u8x8_font_chroma48medium8_r);
if (sonde.config.wifi != 0) {
u8x8->drawString(0, 0, "WiFi Scan...");
}
else if (sonde.config.wifiap != 0) {
u8x8->drawString(0,0,"WiFi AP-Mode:");
}
int line = 0;
int cnt = 0;
@ -743,10 +1030,7 @@ void loopWifiScan() {
WiFi.disconnect(true);
WiFi.mode(WIFI_STA);
const char *id, *pw;
char idstr[64]="test";
if (sonde.config.wifi != 0) {
int index = -1;
int n = WiFi.scanNetworks();
for (int i = 0; i < n; i++) {
Serial.print("Network name: ");
@ -761,100 +1045,61 @@ void loopWifiScan() {
String encryptionTypeDescription = translateEncryptionType(WiFi.encryptionType(i));
Serial.println(encryptionTypeDescription);
Serial.println("-----------------------");
id=WiFi.SSID(i).c_str();
pw=fetchWifiPw(id);
if(pw) { strncpy(idstr, id, 63); }
const char *id = WiFi.SSID(i).c_str();
int curidx = fetchWifiIndex(id);
if (curidx >= 0 && index == -1) {
index = curidx;
}
if(!pw) { pw="test"; }
Serial.print("Connecting to: "); Serial.println(idstr);
}
if (index >= 0) { // some network was found
Serial.print("Connecting to: "); Serial.println(fetchWifiSSID(index));
u8x8->drawString(0, 6, "Conn:");
u8x8->drawString(6,6, idstr);
//register event handler
WiFi.onEvent(WiFiEvent);
WiFi.begin(idstr, pw);
}
while(WiFi.status() != WL_CONNECTED) {
u8x8->drawString(6, 6, fetchWifiSSID(index));
WiFi.begin(fetchWifiSSID(index), fetchWifiPw(index));
while (WiFi.status() != WL_CONNECTED && cnt < 20) {
delay(500);
Serial.print(".");
if (cnt == 5) {
// my FritzBox needs this for reconnecting
WiFi.disconnect(true);
delay(500);
WiFi.begin(fetchWifiSSID(index), fetchWifiPw(index));
delay(500);
}
u8x8->drawString(15, 7, _scan[cnt & 1]);
cnt++;
#if 0
if(cnt==4) {
WiFi.disconnect(true); // retry, for my buggy FritzBox
WiFi.onEvent(WiFiEvent);
WiFi.begin(idstr, pw);
}
#endif
if(cnt==15) {
}
if (index < 0 || cnt >= 15) { // no network found, or connect not successful
WiFi.disconnect(true);
if (sonde.config.wifiap != 0) { // enable WiFi AP mode in config.txt: wifi=1
delay(1000);
WiFi.softAP(networks[0].id.c_str(),networks[0].pw.c_str());
startAP();
IPAddress myIP = WiFi.softAPIP();
Serial.print("AP IP address: ");
Serial.println(myIP);
u8x8->drawString(0, 6, "AP: ");
u8x8->drawString(6, 6, networks[0].id.c_str());
sonde.setIP(myIP.toString().c_str(), true);
sonde.updateDisplayIP();
SetupAsyncServer();
delay(3000);
}
if (sonde.config.spectrum != 0) { // enable Spectrum in config.txt: spectrum=number_of_seconds
sonde.clearDisplay();
u8x8->setFont(u8x8_font_chroma48medium8_r);
u8x8->drawString(0, 0, "Spectrum Scan...");
delay(500);
enterMode(ST_SPECTRUM);
for (int i = 0; i < sonde.config.spectrum; i++) {
scanner.scan();
scanner.plotResult();
if (sonde.config.marker != 0) {
itoa((sonde.config.startfreq), buf, 10);
u8x8->drawString(0, 1, buf);
u8x8->drawString(7, 1, "MHz");
itoa((sonde.config.startfreq + 6), buf, 10);
u8x8->drawString(13, 1, buf);
}
if (sonde.config.timer != 0) {
itoa((sonde.config.spectrum - i), buf, 10);
if (sonde.config.marker != 0) {
marker = 1;
}
u8x8->drawString(0, 1+marker, buf);
u8x8->drawString(2, 1+marker, "Sec.");
}
}
delay(1000);
}
enterMode(ST_SCANNER);
return;
}
}
} else {
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
sonde.setIP(WiFi.localIP().toString().c_str(), false);
sonde.updateDisplayIP();
wifi_state = WIFI_CONNECTED;
delay(3000);
}
SetupAsyncServer();
delay(2000);
initialMode();
// enterMode(ST_DECODER); ### 2019-04-20 - changed DL2MF
if (sonde.config.spectrum != 0) { // enable Spectrum in config.txt: spectrum=number_of_seconds
//startSpectrumDisplay();
enterMode(ST_SPECTRUM);
} else {
enterMode(ST_SCANNER);
}
}
void loop() {
Serial.println("Running main loop");
@ -873,4 +1118,5 @@ void loop() {
Serial.print(" LNA Gain: "),
Serial.println(gain);
#endif
loopWifiBackground();
}

Wyświetl plik

@ -3,7 +3,7 @@
#-------------------------------#
button_pin=0
# LED port
led_pin=25
led_pout=9
# OLED Setup is depending on hardware of LoRa board
# TTGO v1: SDA=4 SCL=15, RST=16
# TTGO v2: SDA=21 SCL=22, RST=16
@ -15,7 +15,7 @@ oled_rst=16
#-------------------------------#
maxsonde=20
debug=0
wifi=0
wifi=1
wifiap=1
#-------------------------------#
# Spectrum display settings

Wyświetl plik

@ -18,7 +18,7 @@
<button class="tablinks" onclick="selTab(event,'QRG')" id="defaultTab">QRG</button>
<button class="tablinks" onclick="selTab(event,'WLAN')">WLAN</button>
<button class="tablinks" onclick="selTab(event,'Data')">Data</button>
<button class="tablinks" onclick="selTab(event,'WebWX')">Webwx</button>
<button class="tablinks" onclick="selTab(event,'SondeMap')">SondeMap</button>
<button class="tablinks" onclick="selTab(event,'Config')">Config</button>
<button class="tablinks" onclick="selTab(event,'About')">About</button>
</div>
@ -38,9 +38,8 @@
<iframe src="status.html" style="border:none;" width="100%%" height="100%%"></iframe>
</div>
<div id="Data" class="tabcontent">
<h3>wetterson.de</h3>
<iframe src="https://wetterson.de/karte/" style="border:none;" width="100%%" height="100%%"></iframe>
<div id="SondeMap" class="tabcontent">
<iframe src="https://wx.dl2mf.de/#?" style="border:none;" width="98%%" height="98%%"></iframe>
</div>
<div id="Config" class="tabcontent">
@ -50,10 +49,10 @@
<div id="About" class="tabcontent">
<h3>About</h3>
RDZSonde<br>
%VERSION_NAME%<br>
Copyright &copy; 2019 by Hansi Reiser, DL9RDZ<br>
(master-version v0.4)<br>
with mods by Meinhard Guenther, DL2MF<br>
(version %VERSION_ID%)<br>
with mods by <a href="https://www.dl2mf.de/" target="_blank">Meinhard Guenther, DL2MF</a><br>
<br>
This program is free software; you can redistribute it and/or<br>
modify it under the terms of the GNU General Public License as<br>

2
RX_FSK/version.h 100644
Wyświetl plik

@ -0,0 +1,2 @@
const char *version_name = "RDZ_TTGO_SONDE";
const char *version_id = "master v0.5";

Wyświetl plik

@ -51,6 +51,10 @@ void Scanner::plotResult()
if( ((i+j)%TICK2)==0) { row[j] |= 0x01; }
}
for(int y=0; y<8; y++) {
if(sonde.config.marker && y==1) {
// don't overwrite MHz marker text
if(i<3*8 || (i>=7*8&&i<10*8) || i>=13*8) continue;
}
u8x8->drawTile(i/8, y, 1, row+8*y);
}
}

Wyświetl plik

@ -49,6 +49,7 @@ static uint8_t ap_tile[8]={0x00,0x04,0x22,0x92, 0x92, 0x22, 0x04, 0x00};
Sonde::Sonde() {
config.button_pin = 0;
config.led_pout = 9;
config.oled_sda = 4;
config.oled_scl = 15;
config.oled_rst = 16;
@ -98,8 +99,8 @@ void Sonde::setConfig(const char *cfg) {
strncpy(config.passcode, val, 9);
} else if(strcmp(cfg,"button_pin")==0) {
config.button_pin = atoi(val);
} else if(strcmp(cfg,"led_pin")==0) {
config.led_pin = atoi(val);
} else if(strcmp(cfg,"led_pout")==0) {
config.led_pout = atoi(val);
} else if(strcmp(cfg,"oled_sda")==0) {
config.oled_sda = atoi(val);
} else if(strcmp(cfg,"oled_scl")==0) {
@ -153,6 +154,10 @@ void Sonde::setConfig(const char *cfg) {
}
}
void Sonde::clearIP() {
memset(myIP_tiles, 0, 11*8);
}
void Sonde::setIP(const char *ip, bool AP) {
memset(myIP_tiles, 0, 11*8);
int len = strlen(ip);

Wyświetl plik

@ -13,8 +13,8 @@ enum SondeType { STYPE_DFM06, STYPE_DFM09, STYPE_RS41 };
extern const char *sondeTypeStr[5];
typedef struct st_rdzconfig {
int button_pin; // pin number of second button (for some boards)
int led_pin; // pin number of LED
int button_pin; // PIN port number menu button (for some boards)
int led_pout; // POUT port number of LED (used as serial monitor)
int oled_sda; // OLED data pin
int oled_scl; // OLED clock pin
int oled_rst; // OLED reset pin
@ -92,6 +92,7 @@ public:
void updateDisplayScanner();
void clearDisplay();
void setIP(const char *ip, bool isAP);
void clearIP();
};
extern Sonde sonde;