Added WiFi support
This commit is contained in:
+493
-300
@@ -1,7 +1,11 @@
|
|||||||
|
#include <WiFiClient.h>
|
||||||
#include <EEPROM.h>
|
#include <EEPROM.h>
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#include <TFT_eSPI.h> // https://github.com/Bodmer/TFT_eSPI
|
#include <TFT_eSPI.h> // https://github.com/Bodmer/TFT_eSPI
|
||||||
#include <TimeLib.h> // https://github.com/PaulStoffregen/Time
|
#include <TimeLib.h> // https://github.com/PaulStoffregen/Time
|
||||||
|
#include <Hash.h> // https://github.com/bbx10/Hash_tng
|
||||||
|
#include "src/WiFiConnect.h"
|
||||||
|
#include "src/WiFiConnectParam.h"
|
||||||
#include "src/font.h"
|
#include "src/font.h"
|
||||||
#include "src/TEF6686.h"
|
#include "src/TEF6686.h"
|
||||||
#include "src/constants.h"
|
#include "src/constants.h"
|
||||||
@@ -13,8 +17,8 @@
|
|||||||
#define FONT7 &Aura2Pro_Light7pt8b
|
#define FONT7 &Aura2Pro_Light7pt8b
|
||||||
#define FONTDEC &Digital7num36pt7b
|
#define FONTDEC &Digital7num36pt7b
|
||||||
|
|
||||||
#define GUI2_FONT8 &Aura2Regular8pt8b
|
//#define GUI2_FONT8 &Aura2Regular8pt8b
|
||||||
#define GUI2_FONT12 &Aura2Regular12pt8b
|
//#define GUI2_FONT12 &Aura2Regular12pt8b
|
||||||
|
|
||||||
#define TFT_GREYOUT 0x38E7
|
#define TFT_GREYOUT 0x38E7
|
||||||
#define ROTARY_PIN_A 34
|
#define ROTARY_PIN_A 34
|
||||||
@@ -39,6 +43,7 @@ TFT_eSPI tft = TFT_eSPI(240, 320);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool edgebeep;
|
bool edgebeep;
|
||||||
|
bool RDSSpy;
|
||||||
bool BWreset;
|
bool BWreset;
|
||||||
bool change2;
|
bool change2;
|
||||||
bool cleanup;
|
bool cleanup;
|
||||||
@@ -68,12 +73,18 @@ bool tuned;
|
|||||||
bool USBstatus;
|
bool USBstatus;
|
||||||
bool USBmode = 1;
|
bool USBmode = 1;
|
||||||
bool XDRMute;
|
bool XDRMute;
|
||||||
|
bool XDRGTKdata;
|
||||||
|
bool wifi;
|
||||||
|
bool wificonnected;
|
||||||
|
bool XDRGTKTCP;
|
||||||
byte region;
|
byte region;
|
||||||
byte regionold;
|
byte regionold;
|
||||||
byte language;
|
byte language;
|
||||||
byte theme;
|
byte theme;
|
||||||
byte tunemode;
|
byte tunemode;
|
||||||
byte memorypos;
|
byte memorypos;
|
||||||
|
String salt;
|
||||||
|
String saltkey = " ";
|
||||||
byte memoryposold;
|
byte memoryposold;
|
||||||
byte menupage = 1;
|
byte menupage = 1;
|
||||||
byte menupagestotal = 2;
|
byte menupagestotal = 2;
|
||||||
@@ -146,9 +157,11 @@ String PSold;
|
|||||||
String PTYold;
|
String PTYold;
|
||||||
String rds_clock;
|
String rds_clock;
|
||||||
String rds_clockold;
|
String rds_clockold;
|
||||||
|
String cryptedpassword;
|
||||||
String RDSSPYRDS;
|
String RDSSPYRDS;
|
||||||
String RDSSPYRDSold;
|
String RDSSPYRDSold;
|
||||||
String RTold;
|
String RTold;
|
||||||
|
String XDRGTK_key;
|
||||||
String XDRGTKRDS;
|
String XDRGTKRDS;
|
||||||
String XDRGTKRDSold;
|
String XDRGTKRDSold;
|
||||||
uint16_t BW;
|
uint16_t BW;
|
||||||
@@ -174,12 +187,15 @@ unsigned long rtticker;
|
|||||||
|
|
||||||
TEF6686 radio;
|
TEF6686 radio;
|
||||||
TFT_eSprite sprite = TFT_eSprite(&tft);
|
TFT_eSprite sprite = TFT_eSprite(&tft);
|
||||||
|
WiFiConnect wc;
|
||||||
|
WiFiServer Server(7373);
|
||||||
|
WiFiClient RemoteClient;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
setupmode = true;
|
setupmode = true;
|
||||||
EEPROM.begin(234);
|
EEPROM.begin(244);
|
||||||
if (EEPROM.readByte(43) != 22) {
|
if (EEPROM.readByte(43) != 23) {
|
||||||
EEPROM.writeByte(43, 22);
|
EEPROM.writeByte(43, 23);
|
||||||
EEPROM.writeUInt(0, 10000);
|
EEPROM.writeUInt(0, 10000);
|
||||||
EEPROM.writeInt(4, 0);
|
EEPROM.writeInt(4, 0);
|
||||||
EEPROM.writeUInt(8, 0);
|
EEPROM.writeUInt(8, 0);
|
||||||
@@ -210,11 +226,14 @@ void setup() {
|
|||||||
EEPROM.writeByte(52, 0);
|
EEPROM.writeByte(52, 0);
|
||||||
EEPROM.writeByte(53, 0);
|
EEPROM.writeByte(53, 0);
|
||||||
EEPROM.writeByte(54, 0);
|
EEPROM.writeByte(54, 0);
|
||||||
|
EEPROM.writeByte(55, 0);
|
||||||
for (int i = 0; i < 30; i++) EEPROM.writeByte(i + 60, 0);
|
for (int i = 0; i < 30; i++) EEPROM.writeByte(i + 60, 0);
|
||||||
for (int i = 0; i < 30; i++) EEPROM.writeUInt((i * 4) + 100, 8750);
|
for (int i = 0; i < 30; i++) EEPROM.writeUInt((i * 4) + 100, 8750);
|
||||||
EEPROM.writeUInt(221, 180);
|
EEPROM.writeUInt(221, 180);
|
||||||
EEPROM.writeUInt(225, 540);
|
EEPROM.writeUInt(225, 540);
|
||||||
EEPROM.writeUInt(229, 1800);
|
EEPROM.writeUInt(229, 1800);
|
||||||
|
EEPROM.writeString(233, "password");
|
||||||
|
|
||||||
EEPROM.commit();
|
EEPROM.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,9 +267,11 @@ void setup() {
|
|||||||
region = EEPROM.readByte(52);
|
region = EEPROM.readByte(52);
|
||||||
radio.rds.underscore = EEPROM.readByte(53);
|
radio.rds.underscore = EEPROM.readByte(53);
|
||||||
USBmode = EEPROM.readByte(54);
|
USBmode = EEPROM.readByte(54);
|
||||||
|
wifi = EEPROM.readByte(55);
|
||||||
frequency_LW = EEPROM.readUInt(221);
|
frequency_LW = EEPROM.readUInt(221);
|
||||||
frequency_MW = EEPROM.readUInt(225);
|
frequency_MW = EEPROM.readUInt(225);
|
||||||
frequency_SW = EEPROM.readUInt(229);
|
frequency_SW = EEPROM.readUInt(229);
|
||||||
|
XDRGTK_key = EEPROM.readString(233);
|
||||||
|
|
||||||
LWLowEdgeSet = FREQ_LW_LOW_EDGE_MIN; // later will read from flash
|
LWLowEdgeSet = FREQ_LW_LOW_EDGE_MIN; // later will read from flash
|
||||||
LWHighEdgeSet = FREQ_LW_HIGH_EDGE_MAX; // later will read from flash
|
LWHighEdgeSet = FREQ_LW_HIGH_EDGE_MAX; // later will read from flash
|
||||||
@@ -436,6 +457,11 @@ void setup() {
|
|||||||
Wire.endTransmission();
|
Wire.endTransmission();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (wifi == true) {
|
||||||
|
tryWiFi();
|
||||||
|
delay(2000);
|
||||||
|
}
|
||||||
|
|
||||||
SelectBand();
|
SelectBand();
|
||||||
ShowSignalLevel();
|
ShowSignalLevel();
|
||||||
ShowBW();
|
ShowBW();
|
||||||
@@ -528,6 +554,7 @@ void loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (USBmode) RDSSpyRoutine(); else XDRGTKRoutine();
|
if (USBmode) RDSSpyRoutine(); else XDRGTKRoutine();
|
||||||
|
if (wifi) WiFihandler();
|
||||||
|
|
||||||
if (menu == true && menuopen == true && menupage == 1 && menuoption == 110) {
|
if (menu == true && menuopen == true && menupage == 1 && menuoption == 110) {
|
||||||
if (band == BAND_FM) radio.getStatus(SStatus, USN, WAM, OStatus, BW, MStatus); else radio.getStatusAM(SStatus, USN, WAM, OStatus, BW, MStatus);
|
if (band == BAND_FM) radio.getStatus(SStatus, USN, WAM, OStatus, BW, MStatus); else radio.getStatusAM(SStatus, USN, WAM, OStatus, BW, MStatus);
|
||||||
@@ -816,6 +843,7 @@ void ModeButtonPress() {
|
|||||||
EEPROM.writeByte(52, region);
|
EEPROM.writeByte(52, region);
|
||||||
EEPROM.writeByte(53, radio.rds.underscore);
|
EEPROM.writeByte(53, radio.rds.underscore);
|
||||||
EEPROM.writeByte(54, USBmode);
|
EEPROM.writeByte(54, USBmode);
|
||||||
|
EEPROM.writeByte(55, wifi);
|
||||||
EEPROM.commit();
|
EEPROM.commit();
|
||||||
Serial.end();
|
Serial.end();
|
||||||
if (USBmode) Serial.begin(19200); else Serial.begin(115200);
|
if (USBmode) Serial.begin(19200); else Serial.begin(115200);
|
||||||
@@ -1093,9 +1121,42 @@ void ButtonPress() {
|
|||||||
tft.setTextColor(TFT_YELLOW);
|
tft.setTextColor(TFT_YELLOW);
|
||||||
if (USBmode) tft.drawCentreString("RDS Spy", 155, 110, GFXFF); else tft.drawCentreString("XDR-GTK", 155, 110, GFXFF);
|
if (USBmode) tft.drawCentreString("RDS Spy", 155, 110, GFXFF); else tft.drawCentreString("XDR-GTK", 155, 110, GFXFF);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 190:
|
||||||
|
tft.setTextColor(TFT_WHITE);
|
||||||
|
tft.drawCentreString(myLanguage[language][51], 155, 70, GFXFF);
|
||||||
|
tft.setTextColor(TFT_YELLOW);
|
||||||
|
if (wifi) tft.drawCentreString(myLanguage[language][42], 155, 110, GFXFF); else tft.drawCentreString(myLanguage[language][30], 155, 110, GFXFF);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 210:
|
||||||
|
tft.setTextColor(TFT_WHITE);
|
||||||
|
tft.drawCentreString(myLanguage[language][53], 155, 50, GFXFF);
|
||||||
|
tft.drawCentreString("ESP_" + String(ESP_getChipId()), 155, 90, GFXFF);
|
||||||
|
tft.drawCentreString(myLanguage[language][54], 155, 130, GFXFF);
|
||||||
|
char key [9];
|
||||||
|
XDRGTK_key.toCharArray(key, 9);
|
||||||
|
WiFiConnectParam XDRGTK_key_text("Set XDRGTK Password: (max 8 characters)");
|
||||||
|
WiFiConnectParam XDRGTK_key_input("XDRGTK_key", "Password", key, 9);
|
||||||
|
wc.addParameter(&XDRGTK_key_text);
|
||||||
|
wc.addParameter(&XDRGTK_key_input);
|
||||||
|
wc.startConfigurationPortal(AP_WAIT);
|
||||||
|
XDRGTK_key = XDRGTK_key_input.getValue();
|
||||||
|
EEPROM.writeString(233, XDRGTK_key);
|
||||||
|
EEPROM.commit();
|
||||||
|
tryWiFi();
|
||||||
|
delay(2000);
|
||||||
|
BuildMenu();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Serial.println(menupage);
|
||||||
|
Serial.println(menuoption);
|
||||||
|
if (menupage == 2 && menuoption == 190 && wifi == true) {
|
||||||
|
tryWiFi();
|
||||||
|
delay(2000);
|
||||||
|
}
|
||||||
menuopen = false;
|
menuopen = false;
|
||||||
BuildMenu();
|
BuildMenu();
|
||||||
}
|
}
|
||||||
@@ -1335,6 +1396,13 @@ void KeyUp() {
|
|||||||
if (USBmode) tft.drawCentreString("RDS Spy", 155, 110, GFXFF); else tft.drawCentreString("XDR-GTK", 155, 110, GFXFF);
|
if (USBmode) tft.drawCentreString("RDS Spy", 155, 110, GFXFF); else tft.drawCentreString("XDR-GTK", 155, 110, GFXFF);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 190:
|
||||||
|
tft.setTextColor(TFT_BLACK);
|
||||||
|
if (wifi) tft.drawCentreString(myLanguage[language][42], 155, 110, GFXFF); else tft.drawCentreString(myLanguage[language][30], 155, 110, GFXFF);
|
||||||
|
if (wifi) wifi = false; else wifi = true;
|
||||||
|
tft.setTextColor(TFT_YELLOW);
|
||||||
|
if (wifi) tft.drawCentreString(myLanguage[language][42], 155, 110, GFXFF); else tft.drawCentreString(myLanguage[language][30], 155, 110, GFXFF);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1574,6 +1642,14 @@ void KeyDown() {
|
|||||||
tft.setTextColor(TFT_YELLOW);
|
tft.setTextColor(TFT_YELLOW);
|
||||||
if (USBmode) tft.drawCentreString("RDS Spy", 155, 110, GFXFF); else tft.drawCentreString("XDR-GTK", 155, 110, GFXFF);
|
if (USBmode) tft.drawCentreString("RDS Spy", 155, 110, GFXFF); else tft.drawCentreString("XDR-GTK", 155, 110, GFXFF);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 190:
|
||||||
|
tft.setTextColor(TFT_BLACK);
|
||||||
|
if (wifi) tft.drawCentreString(myLanguage[language][42], 155, 110, GFXFF); else tft.drawCentreString(myLanguage[language][30], 155, 110, GFXFF);
|
||||||
|
if (wifi) wifi = false; else wifi = true;
|
||||||
|
tft.setTextColor(TFT_YELLOW);
|
||||||
|
if (wifi) tft.drawCentreString(myLanguage[language][42], 155, 110, GFXFF); else tft.drawCentreString(myLanguage[language][30], 155, 110, GFXFF);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1869,6 +1945,8 @@ void BuildMenu() {
|
|||||||
tft.drawString(myLanguage[language][46], 14, 130, GFXFF);
|
tft.drawString(myLanguage[language][46], 14, 130, GFXFF);
|
||||||
tft.drawString(myLanguage[language][49], 14, 150, GFXFF);
|
tft.drawString(myLanguage[language][49], 14, 150, GFXFF);
|
||||||
tft.drawString(myLanguage[language][50], 14, 170, GFXFF);
|
tft.drawString(myLanguage[language][50], 14, 170, GFXFF);
|
||||||
|
if (wifi) tft.drawString(String(myLanguage[language][51]) + " IP: " + String(WiFi.localIP().toString()), 14, 190, GFXFF); else tft.drawString(myLanguage[language][51], 14, 190, GFXFF);
|
||||||
|
tft.drawString(myLanguage[language][52], 14, 210, GFXFF);
|
||||||
tft.setTextColor(TFT_YELLOW);
|
tft.setTextColor(TFT_YELLOW);
|
||||||
tft.drawRightString(myLanguage[language][0], 305, 30, GFXFF);
|
tft.drawRightString(myLanguage[language][0], 305, 30, GFXFF);
|
||||||
if (showrdserrors) tft.drawRightString(myLanguage[language][42], 305, 50, GFXFF); else tft.drawRightString(myLanguage[language][30], 305, 50, GFXFF);
|
if (showrdserrors) tft.drawRightString(myLanguage[language][42], 305, 50, GFXFF); else tft.drawRightString(myLanguage[language][30], 305, 50, GFXFF);
|
||||||
@@ -1879,6 +1957,8 @@ void BuildMenu() {
|
|||||||
if (region == 1) tft.drawRightString(myLanguage[language][48], 305, 130, GFXFF);
|
if (region == 1) tft.drawRightString(myLanguage[language][48], 305, 130, GFXFF);
|
||||||
if (radio.rds.underscore) tft.drawRightString(myLanguage[language][42], 305, 150, GFXFF); else tft.drawRightString(myLanguage[language][30], 305, 150, GFXFF);
|
if (radio.rds.underscore) tft.drawRightString(myLanguage[language][42], 305, 150, GFXFF); else tft.drawRightString(myLanguage[language][30], 305, 150, GFXFF);
|
||||||
if (USBmode) tft.drawRightString("RDS Spy", 305, 170, GFXFF); else tft.drawRightString("XDR-GTK", 305, 170, GFXFF);
|
if (USBmode) tft.drawRightString("RDS Spy", 305, 170, GFXFF); else tft.drawRightString("XDR-GTK", 305, 170, GFXFF);
|
||||||
|
if (wifi) tft.drawRightString(myLanguage[language][42], 305, 190, GFXFF); else tft.drawRightString(myLanguage[language][30], 305, 190, GFXFF);
|
||||||
|
tft.drawRightString("→", 305, 210, GFXFF);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
analogWrite(SMETERPIN, 0);
|
analogWrite(SMETERPIN, 0);
|
||||||
@@ -1982,7 +2062,8 @@ void BuildDisplay() {
|
|||||||
|
|
||||||
|
|
||||||
// WORKING ON THIS!
|
// WORKING ON THIS!
|
||||||
if (theme == 1) {
|
/*
|
||||||
|
if (theme == 1) {
|
||||||
tft.setFreeFont(FONT7);
|
tft.setFreeFont(FONT7);
|
||||||
tft.fillScreen(TFT_BLACK);
|
tft.fillScreen(TFT_BLACK);
|
||||||
tft.fillRect(12, 105, 2, 50, TFT_RED);
|
tft.fillRect(12, 105, 2, 50, TFT_RED);
|
||||||
@@ -2083,8 +2164,8 @@ void BuildDisplay() {
|
|||||||
tft.drawString("20 50 70 100 120", 204, 220, GFXFF);
|
tft.drawString("20 50 70 100 120", 204, 220, GFXFF);
|
||||||
|
|
||||||
for (;;);
|
for (;;);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
RDSstatusold = false;
|
RDSstatusold = false;
|
||||||
Stereostatusold = false;
|
Stereostatusold = false;
|
||||||
ShowFreq(0);
|
ShowFreq(0);
|
||||||
@@ -2771,320 +2852,346 @@ void RDSSpyRoutine() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void XDRGTKRoutine() {
|
void XDRGTKprint(String string) {
|
||||||
if (Serial.available()) {
|
if (USBmode == 0 && USBstatus == true) Serial.print(string);
|
||||||
buff[buff_pos] = Serial.read();
|
if (XDRGTKTCP) RemoteClient.print(string);
|
||||||
if (buff[buff_pos] != '\n' && buff_pos != 16 - 1) {
|
}
|
||||||
buff_pos++;
|
|
||||||
} else {
|
|
||||||
buff[buff_pos] = 0;
|
|
||||||
buff_pos = 0;
|
|
||||||
|
|
||||||
switch (buff[0]) {
|
void XDRGTKRoutine() {
|
||||||
case 'x':
|
if (!USBmode) {
|
||||||
Serial.println("OK");
|
if (Serial.available())
|
||||||
|
{
|
||||||
|
buff[buff_pos] = Serial.read();
|
||||||
|
if (buff[buff_pos] != '\n' && buff_pos != 16 - 1)
|
||||||
|
{
|
||||||
|
buff_pos++;
|
||||||
|
} else {
|
||||||
|
buff[buff_pos] = 0;
|
||||||
|
buff_pos = 0;
|
||||||
|
XDRGTKdata = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (XDRGTKTCP) {
|
||||||
|
if (RemoteClient.available() > 0) {
|
||||||
|
buff[buff_pos] = RemoteClient.read();
|
||||||
|
if (buff[buff_pos] != '\n' && buff_pos != 16 - 1)
|
||||||
|
{
|
||||||
|
buff_pos++;
|
||||||
|
} else {
|
||||||
|
buff[buff_pos] = 0;
|
||||||
|
buff_pos = 0;
|
||||||
|
XDRGTKdata = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (XDRGTKdata) {
|
||||||
|
switch (buff[0]) {
|
||||||
|
case 'x':
|
||||||
|
XDRGTKprint("OK\n");
|
||||||
|
if (band != BAND_FM) {
|
||||||
|
band = BAND_FM;
|
||||||
|
SelectBand();
|
||||||
|
}
|
||||||
|
XDRGTKprint("T" + String(frequency * 10) + "A0\nD0\nG00\n");
|
||||||
|
USBstatus = true;
|
||||||
|
ShowUSBstatus();
|
||||||
|
if (menu == true) ModeButtonPress();
|
||||||
|
if (Squelch != Squelchold) {
|
||||||
|
if (screenmute == false) {
|
||||||
|
tft.setFreeFont(FONT7);
|
||||||
|
tft.setTextColor(TFT_BLACK);
|
||||||
|
if (Squelchold == -100) tft.drawCentreString(myLanguage[language][33], 224, 167, GFXFF); else if (Squelchold > 920) tft.drawCentreString("ST", 224, 167, GFXFF); else tft.drawCentreString(String(Squelchold / 10), 224, 167, GFXFF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'A':
|
||||||
|
AGC = atol(buff + 1);
|
||||||
|
XDRGTKprint("A" + String(AGC) + "\n");
|
||||||
|
radio.setAGC(AGC);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'C':
|
||||||
|
byte scanmethod;
|
||||||
|
scanmethod = atol(buff + 1);
|
||||||
|
if (seek == false) {
|
||||||
|
if (scanmethod == 1) {
|
||||||
|
XDRGTKprint("C1\n");
|
||||||
|
direction = true;
|
||||||
|
seek = true;
|
||||||
|
Seek(direction);
|
||||||
|
}
|
||||||
|
if (scanmethod == 2) {
|
||||||
|
XDRGTKprint("C2\n");
|
||||||
|
direction = false;
|
||||||
|
seek = true;
|
||||||
|
Seek(direction);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
seek = false;
|
||||||
|
}
|
||||||
|
XDRGTKprint("C0\n");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'N':
|
||||||
|
doStereoToggle();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'D':
|
||||||
|
DeEmphasis = atol(buff + 1);
|
||||||
|
XDRGTKprint("D" + String(DeEmphasis) + "\n");
|
||||||
|
radio.setDeemphasis(DeEmphasis);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'F':
|
||||||
|
XDRBWset = atol(buff + 1);
|
||||||
|
if (XDRBWset < 16) {
|
||||||
|
XDRBWsetold = XDRBWset;
|
||||||
|
BWset = XDRBWset + 1;
|
||||||
|
} else {
|
||||||
|
XDRBWset = XDRBWsetold;
|
||||||
|
}
|
||||||
|
doBW();
|
||||||
|
XDRGTKprint("F" + String(XDRBWset) + "\n");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'G':
|
||||||
|
LevelOffset = atol(buff + 1);
|
||||||
|
if (LevelOffset == 0) {
|
||||||
|
MuteScreen(0);
|
||||||
|
LowLevelSet = EEPROM.readInt(47);
|
||||||
|
XDRGTKprint("G00\n");
|
||||||
|
}
|
||||||
|
if (LevelOffset == 10) {
|
||||||
|
MuteScreen(1);
|
||||||
|
LowLevelSet = EEPROM.readInt(47);
|
||||||
|
XDRGTKprint("G10\n");
|
||||||
|
}
|
||||||
|
if (LevelOffset == 1) {
|
||||||
|
MuteScreen(0);
|
||||||
|
LowLevelSet = 120;
|
||||||
|
XDRGTKprint("G01\n");
|
||||||
|
}
|
||||||
|
if (LevelOffset == 11) {
|
||||||
|
LowLevelSet = 120;
|
||||||
|
MuteScreen(1);
|
||||||
|
XDRGTKprint("G11\n");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'M':
|
||||||
|
byte XDRband;
|
||||||
|
XDRband = atol(buff + 1);
|
||||||
|
if (XDRband == BAND_FM) { // here XDRGTK need add four bands switch too
|
||||||
|
band = BAND_FM;
|
||||||
|
SelectBand();
|
||||||
|
XDRGTKprint("M0\nT" + String(frequency * 10) + "\n");
|
||||||
|
} else if (XDRband == BAND_LW) {
|
||||||
|
band = BAND_LW;
|
||||||
|
SelectBand();
|
||||||
|
XDRGTKprint("M1\nT" + String(frequency_AM) + "\n");
|
||||||
|
} else if (XDRband == BAND_MW) {
|
||||||
|
band = BAND_MW;
|
||||||
|
SelectBand();
|
||||||
|
XDRGTKprint("M2\nT" + String(frequency_AM) + "\n");
|
||||||
|
} else if (XDRband == BAND_SW) {
|
||||||
|
band = BAND_SW;
|
||||||
|
SelectBand();
|
||||||
|
XDRGTKprint("M3\nT" + String(frequency_AM) + "\n");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'T':
|
||||||
|
unsigned int freqtemp;
|
||||||
|
freqtemp = atoi(buff + 1);
|
||||||
|
if (seek == true) seek = false;
|
||||||
|
if (freqtemp >= LWLowEdgeSet && freqtemp <= LWHighEdgeSet) {
|
||||||
|
frequency_AM = freqtemp;
|
||||||
|
if (band != BAND_LW) {
|
||||||
|
band = BAND_LW;
|
||||||
|
SelectBand();
|
||||||
|
} else {
|
||||||
|
radio.SetFreqAM(frequency_AM);
|
||||||
|
}
|
||||||
|
XDRGTKprint("M1\n");
|
||||||
|
} else if (freqtemp >= MWLowEdgeSet && freqtemp <= MWHighEdgeSet) {
|
||||||
|
frequency_AM = freqtemp;
|
||||||
|
if (band != BAND_MW) {
|
||||||
|
band = BAND_MW;
|
||||||
|
SelectBand();
|
||||||
|
} else {
|
||||||
|
radio.SetFreqAM(frequency_AM);
|
||||||
|
}
|
||||||
|
XDRGTKprint("M2\n");
|
||||||
|
} else if (freqtemp >= SWLowEdgeSet && freqtemp <= SWHighEdgeSet) {
|
||||||
|
frequency_AM = freqtemp;
|
||||||
|
if (band != BAND_SW) {
|
||||||
|
band = BAND_SW;
|
||||||
|
SelectBand();
|
||||||
|
} else {
|
||||||
|
radio.SetFreqAM(frequency_AM);
|
||||||
|
}
|
||||||
|
XDRGTKprint("M3\n");
|
||||||
|
} else if (freqtemp >= FREQ_FM_START && freqtemp < FREQ_FM_END) {
|
||||||
|
frequency = freqtemp / 10;
|
||||||
if (band != BAND_FM) {
|
if (band != BAND_FM) {
|
||||||
band = BAND_FM;
|
band = BAND_FM;
|
||||||
SelectBand();
|
SelectBand();
|
||||||
}
|
XDRGTKprint("M0\n");
|
||||||
Serial.print("T" + String(frequency * 10) + "A0\nD0\nG00\n");
|
|
||||||
USBstatus = true;
|
|
||||||
ShowUSBstatus();
|
|
||||||
if (menu == true) ModeButtonPress();
|
|
||||||
if (Squelch != Squelchold) {
|
|
||||||
if (screenmute == false) {
|
|
||||||
tft.setFreeFont(FONT7);
|
|
||||||
tft.setTextColor(TFT_BLACK);
|
|
||||||
if (Squelchold == -100) tft.drawCentreString(myLanguage[language][33], 224, 167, GFXFF); else if (Squelchold > 920) tft.drawCentreString("ST", 224, 167, GFXFF); else tft.drawCentreString(String(Squelchold / 10), 224, 167, GFXFF);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'A':
|
|
||||||
AGC = atol(buff + 1);
|
|
||||||
Serial.print("A" + String(AGC) + "\n");
|
|
||||||
radio.setAGC(AGC);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'C':
|
|
||||||
byte scanmethod;
|
|
||||||
scanmethod = atol(buff + 1);
|
|
||||||
if (seek == false) {
|
|
||||||
if (scanmethod == 1) {
|
|
||||||
Serial.print("C1\n");
|
|
||||||
direction = true;
|
|
||||||
seek = true;
|
|
||||||
Seek(direction);
|
|
||||||
}
|
|
||||||
if (scanmethod == 2) {
|
|
||||||
Serial.print("C2\n");
|
|
||||||
direction = false;
|
|
||||||
seek = true;
|
|
||||||
Seek(direction);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
seek = false;
|
radio.SetFreq(frequency);
|
||||||
}
|
}
|
||||||
Serial.print("C0\n");
|
}
|
||||||
break;
|
if (band == BAND_FM) XDRGTKprint("T" + String(frequency * 10) + "\n"); else XDRGTKprint("T" + String(frequency_AM) + "\n");
|
||||||
|
radio.clearRDS(fullsearchrds);
|
||||||
|
RDSstatus = 0;
|
||||||
|
ShowFreq(0);
|
||||||
|
break;
|
||||||
|
|
||||||
case 'N':
|
case 'S':
|
||||||
doStereoToggle();
|
if (buff[1] == 'a') {
|
||||||
break;
|
scanner_start = (atol(buff + 2) + 5) / 10;
|
||||||
|
} else if (buff[1] == 'b') {
|
||||||
case 'D':
|
scanner_end = (atol(buff + 2) + 5) / 10;
|
||||||
DeEmphasis = atol(buff + 1);
|
} else if (buff[1] == 'c') {
|
||||||
Serial.print("D" + String(DeEmphasis) + "\n");
|
scanner_step = (atol(buff + 2) + 5) / 10;
|
||||||
radio.setDeemphasis(DeEmphasis);
|
} else if (buff[1] == 'f') {
|
||||||
break;
|
scanner_filter = atol(buff + 2);
|
||||||
|
} else if (scanner_start > 0 && scanner_end > 0 && scanner_step > 0 && scanner_filter >= 0) {
|
||||||
case 'F':
|
frequencyold = frequency;
|
||||||
XDRBWset = atol(buff + 1);
|
radio.SetFreq(scanner_start);
|
||||||
if (XDRBWset < 16) {
|
XDRGTKprint("U");
|
||||||
XDRBWsetold = XDRBWset;
|
if (scanner_filter < 0) {
|
||||||
BWset = XDRBWset + 1;
|
BWset = 0;
|
||||||
} else {
|
} else if (scanner_filter == 0) {
|
||||||
XDRBWset = XDRBWsetold;
|
BWset = 1;
|
||||||
|
} else if (scanner_filter == 26) {
|
||||||
|
BWset = 2;
|
||||||
|
} else if (scanner_filter == 1) {
|
||||||
|
BWset = 3;
|
||||||
|
} else if (scanner_filter == 28) {
|
||||||
|
BWset = 4;
|
||||||
|
} else if (scanner_filter == 29) {
|
||||||
|
BWset = 5;
|
||||||
|
} else if (scanner_filter == 3) {
|
||||||
|
BWset = 6;
|
||||||
|
} else if (scanner_filter == 4) {
|
||||||
|
BWset = 7;
|
||||||
|
} else if (scanner_filter == 5) {
|
||||||
|
BWset = 8;
|
||||||
|
} else if (scanner_filter == 7) {
|
||||||
|
BWset = 9;
|
||||||
|
} else if (scanner_filter == 8) {
|
||||||
|
BWset = 10;
|
||||||
|
} else if (scanner_filter == 9) {
|
||||||
|
BWset = 11;
|
||||||
|
} else if (scanner_filter == 10) {
|
||||||
|
BWset = 12;
|
||||||
|
} else if (scanner_filter == 11) {
|
||||||
|
BWset = 13;
|
||||||
|
} else if (scanner_filter == 12) {
|
||||||
|
BWset = 14;
|
||||||
|
} else if (scanner_filter == 13) {
|
||||||
|
BWset = 15;
|
||||||
|
} else if (scanner_filter == 15) {
|
||||||
|
BWset = 16;
|
||||||
}
|
}
|
||||||
doBW();
|
doBW();
|
||||||
Serial.print("F" + String(XDRBWset) + "\n");
|
if (screenmute == false) {
|
||||||
break;
|
ShowFreq(1);
|
||||||
|
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||||
|
tft.setCursor (90, 60);
|
||||||
|
tft.setFreeFont(FONT14);
|
||||||
|
tft.drawCentreString(myLanguage[language][34], 140, 60, GFXFF);
|
||||||
|
}
|
||||||
|
frequencyold = frequency / 10;
|
||||||
|
for (freq_scan = scanner_start; freq_scan <= scanner_end; freq_scan += scanner_step) {
|
||||||
|
radio.SetFreq(freq_scan);
|
||||||
|
XDRGTKprint(String(freq_scan * 10, DEC));
|
||||||
|
XDRGTKprint("=");
|
||||||
|
delay(10);
|
||||||
|
if (band == BAND_FM) radio.getStatus(SStatus, USN, WAM, OStatus, BW, MStatus); else radio.getStatusAM(SStatus, USN, WAM, OStatus, BW, MStatus);
|
||||||
|
XDRGTKprint(String((SStatus / 10) + 10, DEC));
|
||||||
|
XDRGTKprint(",");
|
||||||
|
}
|
||||||
|
XDRGTKprint("\n");
|
||||||
|
if (screenmute == false) {
|
||||||
|
tft.setTextColor(TFT_BLACK);
|
||||||
|
tft.drawCentreString(myLanguage[language][34], 140, 60, GFXFF);
|
||||||
|
}
|
||||||
|
radio.SetFreq(frequencyold);
|
||||||
|
if (screenmute == false) ShowFreq(0);
|
||||||
|
radio.setFMABandw();
|
||||||
|
BWset = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 'G':
|
case 'Y':
|
||||||
LevelOffset = atol(buff + 1);
|
VolSet = atoi(buff + 1);
|
||||||
if (LevelOffset == 0) {
|
if (VolSet == 0) {
|
||||||
MuteScreen(0);
|
radio.setMute();
|
||||||
LowLevelSet = EEPROM.readInt(47);
|
XDRMute = true;
|
||||||
Serial.print("G00\n");
|
SQ = true;
|
||||||
}
|
} else {
|
||||||
if (LevelOffset == 10) {
|
radio.setVolume((VolSet - 70) / 10);
|
||||||
MuteScreen(1);
|
XDRMute = false;
|
||||||
LowLevelSet = EEPROM.readInt(47);
|
}
|
||||||
Serial.print("G10\n");
|
XDRGTKprint("Y" + String(VolSet) + "\n");
|
||||||
}
|
break;
|
||||||
if (LevelOffset == 1) {
|
|
||||||
MuteScreen(0);
|
|
||||||
LowLevelSet = 120;
|
|
||||||
Serial.print("G01\n");
|
|
||||||
}
|
|
||||||
if (LevelOffset == 11) {
|
|
||||||
LowLevelSet = 120;
|
|
||||||
MuteScreen(1);
|
|
||||||
Serial.print("G11\n");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'M':
|
case 'X':
|
||||||
byte XDRband;
|
XDRGTKprint("X\n");
|
||||||
XDRband = atol(buff + 1);
|
ESP.restart();
|
||||||
if (XDRband == BAND_FM) { // here XDRGTK need add four bands switch too
|
break;
|
||||||
band = BAND_FM;
|
|
||||||
SelectBand();
|
|
||||||
Serial.print("M0\nT" + String(frequency * 10) + "\n");
|
|
||||||
} else if (XDRband == BAND_LW) {
|
|
||||||
band = BAND_LW;
|
|
||||||
SelectBand();
|
|
||||||
Serial.print("M1\nT" + String(frequency_AM) + "\n");
|
|
||||||
} else if (XDRband == BAND_MW) {
|
|
||||||
band = BAND_MW;
|
|
||||||
SelectBand();
|
|
||||||
Serial.print("M2\nT" + String(frequency_AM) + "\n");
|
|
||||||
} else if (XDRband == BAND_SW) {
|
|
||||||
band = BAND_SW;
|
|
||||||
SelectBand();
|
|
||||||
Serial.print("M3\nT" + String(frequency_AM) + "\n");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'T':
|
case 'Z':
|
||||||
unsigned int freqtemp;
|
byte iMSEQX;
|
||||||
freqtemp = atoi(buff + 1);
|
iMSEQX = atol(buff + 1);
|
||||||
if (seek == true) seek = false;
|
if (iMSEQX == 0) {
|
||||||
if (freqtemp >= LWLowEdgeSet && freqtemp <= LWHighEdgeSet) {
|
iMSset = 1;
|
||||||
frequency_AM = freqtemp;
|
EQset = 1;
|
||||||
if (band != BAND_LW) {
|
iMSEQ = 2;
|
||||||
band = BAND_LW;
|
}
|
||||||
SelectBand();
|
if (iMSEQX == 1) {
|
||||||
} else {
|
iMSset = 0;
|
||||||
radio.SetFreqAM(frequency_AM);
|
EQset = 1;
|
||||||
}
|
iMSEQ = 3;
|
||||||
Serial.print("M1\n");
|
}
|
||||||
} else if (freqtemp >= MWLowEdgeSet && freqtemp <= MWHighEdgeSet) {
|
if (iMSEQX == 2) {
|
||||||
frequency_AM = freqtemp;
|
iMSset = 1;
|
||||||
if (band != BAND_MW) {
|
EQset = 0;
|
||||||
band = BAND_MW;
|
iMSEQ = 4;
|
||||||
SelectBand();
|
}
|
||||||
} else {
|
if (iMSEQX == 3) {
|
||||||
radio.SetFreqAM(frequency_AM);
|
iMSset = 0;
|
||||||
}
|
EQset = 0;
|
||||||
Serial.print("M2\n");
|
iMSEQ = 1;
|
||||||
} else if (freqtemp >= SWLowEdgeSet && freqtemp <= SWHighEdgeSet) {
|
}
|
||||||
frequency_AM = freqtemp;
|
updateiMS();
|
||||||
if (band != BAND_SW) {
|
updateEQ();
|
||||||
band = BAND_SW;
|
XDRGTKprint("Z" + String(iMSEQX) + "\n");
|
||||||
SelectBand();
|
break;
|
||||||
} else {
|
|
||||||
radio.SetFreqAM(frequency_AM);
|
|
||||||
}
|
|
||||||
Serial.print("M3\n");
|
|
||||||
} else if (freqtemp >= FREQ_FM_START && freqtemp < FREQ_FM_END) {
|
|
||||||
frequency = freqtemp / 10;
|
|
||||||
if (band != BAND_FM) {
|
|
||||||
band = BAND_FM;
|
|
||||||
SelectBand();
|
|
||||||
Serial.print("M0\n");
|
|
||||||
} else {
|
|
||||||
radio.SetFreq(frequency);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (band == BAND_FM) Serial.print("T" + String(frequency * 10) + "\n"); else Serial.print("T" + String(frequency_AM) + "\n");
|
|
||||||
radio.clearRDS(fullsearchrds);
|
|
||||||
RDSstatus = 0;
|
|
||||||
ShowFreq(0);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'S':
|
|
||||||
if (buff[1] == 'a') {
|
|
||||||
scanner_start = (atol(buff + 2) + 5) / 10;
|
|
||||||
} else if (buff[1] == 'b') {
|
|
||||||
scanner_end = (atol(buff + 2) + 5) / 10;
|
|
||||||
} else if (buff[1] == 'c') {
|
|
||||||
scanner_step = (atol(buff + 2) + 5) / 10;
|
|
||||||
} else if (buff[1] == 'f') {
|
|
||||||
scanner_filter = atol(buff + 2);
|
|
||||||
} else if (scanner_start > 0 && scanner_end > 0 && scanner_step > 0 && scanner_filter >= 0) {
|
|
||||||
frequencyold = frequency;
|
|
||||||
radio.SetFreq(scanner_start);
|
|
||||||
Serial.print('U');
|
|
||||||
if (scanner_filter < 0) {
|
|
||||||
BWset = 0;
|
|
||||||
} else if (scanner_filter == 0) {
|
|
||||||
BWset = 1;
|
|
||||||
} else if (scanner_filter == 26) {
|
|
||||||
BWset = 2;
|
|
||||||
} else if (scanner_filter == 1) {
|
|
||||||
BWset = 3;
|
|
||||||
} else if (scanner_filter == 28) {
|
|
||||||
BWset = 4;
|
|
||||||
} else if (scanner_filter == 29) {
|
|
||||||
BWset = 5;
|
|
||||||
} else if (scanner_filter == 3) {
|
|
||||||
BWset = 6;
|
|
||||||
} else if (scanner_filter == 4) {
|
|
||||||
BWset = 7;
|
|
||||||
} else if (scanner_filter == 5) {
|
|
||||||
BWset = 8;
|
|
||||||
} else if (scanner_filter == 7) {
|
|
||||||
BWset = 9;
|
|
||||||
} else if (scanner_filter == 8) {
|
|
||||||
BWset = 10;
|
|
||||||
} else if (scanner_filter == 9) {
|
|
||||||
BWset = 11;
|
|
||||||
} else if (scanner_filter == 10) {
|
|
||||||
BWset = 12;
|
|
||||||
} else if (scanner_filter == 11) {
|
|
||||||
BWset = 13;
|
|
||||||
} else if (scanner_filter == 12) {
|
|
||||||
BWset = 14;
|
|
||||||
} else if (scanner_filter == 13) {
|
|
||||||
BWset = 15;
|
|
||||||
} else if (scanner_filter == 15) {
|
|
||||||
BWset = 16;
|
|
||||||
}
|
|
||||||
doBW();
|
|
||||||
if (screenmute == false) {
|
|
||||||
ShowFreq(1);
|
|
||||||
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
|
||||||
tft.setCursor (90, 60);
|
|
||||||
tft.setFreeFont(FONT14);
|
|
||||||
tft.drawCentreString(myLanguage[language][34], 140, 60, GFXFF);
|
|
||||||
}
|
|
||||||
frequencyold = frequency / 10;
|
|
||||||
for (freq_scan = scanner_start; freq_scan <= scanner_end; freq_scan += scanner_step) {
|
|
||||||
radio.SetFreq(freq_scan);
|
|
||||||
Serial.print(freq_scan * 10, DEC);
|
|
||||||
Serial.print('=');
|
|
||||||
delay(10);
|
|
||||||
if (band == BAND_FM) radio.getStatus(SStatus, USN, WAM, OStatus, BW, MStatus); else radio.getStatusAM(SStatus, USN, WAM, OStatus, BW, MStatus);
|
|
||||||
Serial.print((SStatus / 10) + 10, DEC);
|
|
||||||
Serial.print(',');
|
|
||||||
}
|
|
||||||
Serial.print('\n');
|
|
||||||
if (screenmute == false) {
|
|
||||||
tft.setTextColor(TFT_BLACK);
|
|
||||||
tft.drawCentreString(myLanguage[language][34], 140, 60, GFXFF);
|
|
||||||
}
|
|
||||||
radio.SetFreq(frequencyold);
|
|
||||||
if (screenmute == false) ShowFreq(0);
|
|
||||||
radio.setFMABandw();
|
|
||||||
BWset = 0;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'Y':
|
|
||||||
VolSet = atoi(buff + 1);
|
|
||||||
if (VolSet == 0) {
|
|
||||||
radio.setMute();
|
|
||||||
XDRMute = true;
|
|
||||||
SQ = true;
|
|
||||||
} else {
|
|
||||||
radio.setVolume((VolSet - 70) / 10);
|
|
||||||
XDRMute = false;
|
|
||||||
}
|
|
||||||
Serial.print("Y" + String(VolSet) + "\n");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'X':
|
|
||||||
Serial.print("X\n");
|
|
||||||
ESP.restart();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'Z':
|
|
||||||
byte iMSEQX;
|
|
||||||
iMSEQX = atol(buff + 1);
|
|
||||||
if (iMSEQX == 0) {
|
|
||||||
iMSset = 1;
|
|
||||||
EQset = 1;
|
|
||||||
iMSEQ = 2;
|
|
||||||
}
|
|
||||||
if (iMSEQX == 1) {
|
|
||||||
iMSset = 0;
|
|
||||||
EQset = 1;
|
|
||||||
iMSEQ = 3;
|
|
||||||
}
|
|
||||||
if (iMSEQX == 2) {
|
|
||||||
iMSset = 1;
|
|
||||||
EQset = 0;
|
|
||||||
iMSEQ = 4;
|
|
||||||
}
|
|
||||||
if (iMSEQX == 3) {
|
|
||||||
iMSset = 0;
|
|
||||||
EQset = 0;
|
|
||||||
iMSEQ = 1;
|
|
||||||
}
|
|
||||||
updateiMS();
|
|
||||||
updateEQ();
|
|
||||||
Serial.print("Z" + String(iMSEQX) + "\n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (USBstatus == true) {
|
if (USBstatus == true) {
|
||||||
Stereostatus = radio.getStereoStatus();
|
Stereostatus = radio.getStereoStatus();
|
||||||
if (StereoToggle == false) {
|
if (StereoToggle == false) {
|
||||||
Serial.print("SS");
|
XDRGTKprint("SS");
|
||||||
} else if (Stereostatus == true && band == BAND_FM) {
|
} else if (Stereostatus == true && band == BAND_FM) {
|
||||||
Serial.print("Ss");
|
XDRGTKprint("Ss");
|
||||||
} else {
|
} else {
|
||||||
Serial.print("Sm");
|
XDRGTKprint("Sm");
|
||||||
}
|
}
|
||||||
if (SStatus > (SStatusold + 10) || SStatus < (SStatusold - 10)) {
|
if (SStatus > (SStatusold + 10) || SStatus < (SStatusold - 10)) {
|
||||||
Serial.print(String(((SStatus * 100) + 10875) / 1000) + "." + String(((SStatus * 100) + 10875) / 100 % 10));
|
XDRGTKprint(String(((SStatus * 100) + 10875) / 1000) + "." + String(((SStatus * 100) + 10875) / 100 % 10));
|
||||||
} else {
|
} else {
|
||||||
Serial.print(String(((SStatusold * 100) + 10875) / 1000) + "." + String(((SStatus * 100) + 10875) / 100 % 10));
|
XDRGTKprint(String(((SStatusold * 100) + 10875) / 1000) + "." + String(((SStatus * 100) + 10875) / 100 % 10));
|
||||||
}
|
}
|
||||||
Serial.print("," + String(WAM / 10, DEC) + "," + String(SNR, DEC) + "\n");
|
XDRGTKprint("," + String(WAM / 10, DEC) + "," + String(SNR, DEC) + "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3290,3 +3397,89 @@ void read_encoder() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tryWiFi() {
|
||||||
|
tft.drawRoundRect(1, 60, 319, 140, 5, TFT_WHITE);
|
||||||
|
tft.fillRoundRect(3, 62, 315, 136, 5, TFT_BLACK);
|
||||||
|
tft.setFreeFont(FONT14);
|
||||||
|
tft.setTextColor(TFT_WHITE);
|
||||||
|
tft.drawCentreString(myLanguage[language][55], 155, 80, GFXFF);
|
||||||
|
if (wc.autoConnect()) {
|
||||||
|
Server.begin();
|
||||||
|
tft.setTextColor(TFT_GREEN);
|
||||||
|
tft.drawCentreString(myLanguage[language][57], 155, 120, GFXFF);
|
||||||
|
wifi = true;
|
||||||
|
} else {
|
||||||
|
tft.setTextColor(TFT_RED);
|
||||||
|
tft.drawCentreString(myLanguage[language][56], 155, 120, GFXFF);
|
||||||
|
wifi = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WiFihandler() {
|
||||||
|
if (Server.hasClient())
|
||||||
|
{
|
||||||
|
if (!RemoteClient.connected())
|
||||||
|
{
|
||||||
|
// Server.available().stop();
|
||||||
|
// } else {
|
||||||
|
wificonnected = true;
|
||||||
|
RemoteClient = Server.available();
|
||||||
|
passwordcrypt();
|
||||||
|
RemoteClient.print(saltkey + "\n");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (Server.hasClient()) Server.available().stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wificonnected == true && !RemoteClient.connected()) {
|
||||||
|
wificonnected = false;
|
||||||
|
XDRGTKTCP = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (XDRGTKTCP == false && wificonnected == true && RemoteClient.available()) {
|
||||||
|
String data_str = RemoteClient.readStringUntil('\n');
|
||||||
|
int data = data_str.toInt();
|
||||||
|
if (data_str.length() > 30 && data_str.equals(cryptedpassword))
|
||||||
|
{
|
||||||
|
if (band != BAND_FM) {
|
||||||
|
band = BAND_FM;
|
||||||
|
SelectBand();
|
||||||
|
}
|
||||||
|
XDRGTKTCP = true;
|
||||||
|
RemoteClient.print("o1,0\n");
|
||||||
|
} else if (RDSSpy == false && XDRGTKTCP == false && data_str.length() < 5 && data_str == ("*R?F"))
|
||||||
|
{
|
||||||
|
RDSSpy = true;
|
||||||
|
} else if (RDSSpy == true) {
|
||||||
|
int symPos = data_str.indexOf("*F");
|
||||||
|
if (symPos >= 5) {
|
||||||
|
String freq = data_str.substring(0, symPos);
|
||||||
|
freq = freq.substring(0, freq.length() - 1);
|
||||||
|
frequency = freq.toInt();
|
||||||
|
radio.SetFreq(frequency);
|
||||||
|
radio.clearRDS(fullsearchrds);
|
||||||
|
if (band != BAND_FM) {
|
||||||
|
band = BAND_FM;
|
||||||
|
SelectBand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
RemoteClient.print("a0\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void passwordcrypt() {
|
||||||
|
int generated = 0;
|
||||||
|
while (generated < 16)
|
||||||
|
{
|
||||||
|
byte randomValue = random(0, 26);
|
||||||
|
char letter = randomValue + 'a';
|
||||||
|
if (randomValue > 26) letter = (randomValue - 26);
|
||||||
|
saltkey.setCharAt(generated, letter);
|
||||||
|
generated ++;
|
||||||
|
}
|
||||||
|
salt = saltkey + XDRGTK_key;
|
||||||
|
cryptedpassword = String(sha1(salt));
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,77 @@
|
|||||||
|
/*!
|
||||||
|
* @file WC_AP_HTML.h
|
||||||
|
*
|
||||||
|
* HTML snippets to build the Access Point portal and the Parameters Portal.
|
||||||
|
*
|
||||||
|
* Written by Stuart Blair
|
||||||
|
*
|
||||||
|
* GNU General Public License v3.0 licence, all text here must be included in any redistribution and you should receive a copy of the license file.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef WC_AP_HTML
|
||||||
|
#define WC_AP_HTML ///< Define to stop re-inclusion
|
||||||
|
/*! \def char AP_HTTP_HEAD[] PROGMEM
|
||||||
|
Start of HTML output
|
||||||
|
*/
|
||||||
|
const char AP_HTTP_HEAD[] PROGMEM = "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\"/><title>{v}</title>";
|
||||||
|
/*! \def AP_HTTP_STYLE[] PROGMEM
|
||||||
|
Style for our access point
|
||||||
|
*/
|
||||||
|
const char AP_HTTP_STYLE[] PROGMEM = "<style type=\"text/css\">h1 { font-weight: normal; } .msgbox { font-size:1.2rem; line-height: 1.8em; padding: 0.5em; background-color: #ddffff; border-left: 6px solid #ccc; margin-bottom:1em; } .c{text-align:center}div,input{padding:5px;font-size:1em}input{width:95%;margin-top:5px;margin-bottom:10px}body{text-align:center;font-family:verdana;}button{border:0;border-radius:.3rem;background-color:#1fa3ec;color:#fff;line-height:2.6rem;font-size:1.2rem;width:100%}.q{float:right;width:64px;text-align:right}.l{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAALVBMVEX///8EBwfBwsLw8PAzNjaCg4NTVVUjJiZDRUUUFxdiZGSho6OSk5Pg4eFydHTCjaf3AAAAZElEQVQ4je2NSw7AIAhEBamKn97/uMXEGBvozkWb9C2Zx4xzWykBhFAeYp9gkLyZE0zIMno9n4g19hmdY39scwqVkOXaxph0ZCXQcqxSpgQpONa59wkRDOL93eAXvimwlbPbwwVAegLS1HGfZAAAAABJRU5ErkJggg==) no-repeat left center;background-size:1em;}.cfail,.cok{text-align:center; font-size:1.2rem; line-height: 2em; margin-top: 1em; padding: 0.7em; display:none;} .cfail{color: #FFFFFF;background-color: #ff8433;} .cok{ background-color: #6aff33;}</style>";
|
||||||
|
/** Scripts for our page */
|
||||||
|
const char AP_HTTP_SCRIPT[] PROGMEM = "<script>function c(l){document.getElementById('s').value=l.innerText||l.textContent;document.getElementById('p').focus();}</script>";
|
||||||
|
/** End of the header section and beginning of the body */
|
||||||
|
const char AP_HTTP_HEAD_END[] PROGMEM = "</head><body><div style='text-align:left;display:inline-block;min-width:260px;'>";
|
||||||
|
/** Start of our HTMl configuration Form */
|
||||||
|
const char AP_HTTP_PORTAL_OPTIONS[] PROGMEM = "<div class=\"msgbox\">Connect this device to a WiFi network. Select the option to find a WiFi network.</div><form action=\"/wifi\" method=\"get\"><button>Configure WiFi (Auto Scan)</button></form><br/><form action=\"/0wifi\" method=\"get\"><button style=\"background-color:#bbbbbb;\">Configure WiFi (Manual)</button></form><!--<br/><form action=\"/i\" method=\"get\"><button>Info</button></form><br/></form>-->";
|
||||||
|
/** HTML snippet for wifi scanning */
|
||||||
|
const char AP_HTTP_ITEM[] PROGMEM = "<div><a href='#p' onclick='c(this)'>{v}</a> <span class='q {i}'>{r}%</span></div>";
|
||||||
|
/** HTML form for saving wifi connection details */
|
||||||
|
const char AP_HTTP_FORM_START[] PROGMEM ="<form method=\"post\" action=\"wifisave\"><label>Enter WiFi Name ('SSID'):</label><input id=\"s\" name=\"s\" length=32 placeholder=\"Example: Home_Network_2002\"><label>Enter WiFi Password:</label><input id=\"p\" name=\"p\" length=64 type=\"password\" placeholder=\"Password123\"><br/>";;
|
||||||
|
/** HTML snippet for our custom parameters */
|
||||||
|
const char AP_HTTP_FORM_PARAM[] PROGMEM = "<br/><input id='{i}' name='{n}' maxlength={l} placeholder='{p}' value='{v}' {c}>";
|
||||||
|
/** The end of our HTML Form */
|
||||||
|
const char AP_HTTP_FORM_END[] PROGMEM = "<br/><button type='submit'>Save and Connect</button></form>";
|
||||||
|
/** HTML snippet to recan for networks */
|
||||||
|
const char AP_HTTP_SCAN_LINK[] PROGMEM = "<br/><div class=\"c\"><a href=\"/wifi\">Re-scan</a></div>";
|
||||||
|
/** HTML snippet for saved confirmation */
|
||||||
|
// https://stackoverflow.com/questions/20760635/why-does-setting-xmlhttprequest-responsetype-before-calling-open-throw
|
||||||
|
// https://esprima.org/demo/validate.html
|
||||||
|
// https://javascript-minifier.com/
|
||||||
|
|
||||||
|
/* Use JavaScript to ping the ESP periodically @ the AP IP address.
|
||||||
|
* If it comes back as an AP again then we know the connection to the WiFi didn't work.
|
||||||
|
* We wait about 30 seconds to determine this outcome. This isn't 100% foolproof, but should be good enough.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
<script type="text/javascript">
|
||||||
|
function doPing() {
|
||||||
|
//if ( timeout_count > 20 ) {
|
||||||
|
if ( attempt_count > 20 ) { // wait about a minute
|
||||||
|
window.clearInterval(myPinger), document.getElementById("conn_ok").style.display = "block"
|
||||||
|
}
|
||||||
|
|
||||||
|
var o = new XMLHttpRequest;
|
||||||
|
o.onload = function() {
|
||||||
|
console.log(this.responseText), document.getElementById("conn_fail").style.display = "block", window.clearInterval(myPinger)
|
||||||
|
}, o.ontimeout = function(o) {
|
||||||
|
console.log("Timeout Counter is: " + timeout_count++)
|
||||||
|
}, o.open("GET", "/foo"), o.timeout = 1000, o.send(null), console.log("Ping counter is: " + attempt_count++)
|
||||||
|
}
|
||||||
|
|
||||||
|
attempt_count = 0;
|
||||||
|
timeout_count = 0;
|
||||||
|
var myPinger = window.setInterval(doPing, 3000);
|
||||||
|
|
||||||
|
</script>
|
||||||
|
*/
|
||||||
|
const char AP_HTTP_SAVED[] PROGMEM = "<div>Credentials Saved.<br />Attempting to connect to WiFi network. Please wait.... <br /><script type=\"text/javascript\">function doPing(){attempt_count>20&&(window.clearInterval(myPinger),document.getElementById(\"conn_ok\").style.display=\"block\");var t=new XMLHttpRequest;t.onload=function(){console.log(this.responseText),document.getElementById(\"conn_fail\").style.display=\"block\",window.clearInterval(myPinger)},t.ontimeout=function(t){console.log(\"Timeout Counter is: \"+timeout_count++)},t.open(\"GET\",\"/foo\"),t.timeout=1e3,t.send(null),console.log(\"Ping counter is: \"+attempt_count++)}attempt_count=0,timeout_count=0;var myPinger=window.setInterval(doPing,3e3);</script><div class=\"cok\" id=\"conn_ok\">Connected to {ap} !<br />You may now close this window. </div><div class=\"cfail\" id=\"conn_fail\">Failed to connect to {ap}!<br /><a href=\"/\">Click here</a> to try again.</div></div>";
|
||||||
|
/** End of the HTML page */
|
||||||
|
const char AP_HTTP_END[] PROGMEM = "</div></body></html>";
|
||||||
|
/** HTML snippet for our custom parameters portal form */
|
||||||
|
const char AP_HTTP_PORTAL_PARAM_OPTIONS[] PROGMEM = "<form action=\"/params\" method=\"get\"><button>Configure Parameters</button></form><br/><form action=\"/i\" method=\"get\"><button>Info</button></form><br/>";
|
||||||
|
/** HTML snippet for our custom parameters save */
|
||||||
|
const char AP_HTTP_FORM_PARAM_START[] PROGMEM ="<form method=\"get\" action=\"wifisave\">";
|
||||||
|
|
||||||
|
#endif
|
||||||
+1337
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,187 @@
|
|||||||
|
/*!
|
||||||
|
@file WiFiConnect.h
|
||||||
|
|
||||||
|
This is the documentation for WiFiConnect for the Arduino platform.
|
||||||
|
It is a WiFi connection manager for use with the popular ESP8266 and ESP32 chips.
|
||||||
|
It contains a captive portal to allow easy connection and changing of WiFi netwoks
|
||||||
|
via a web based interface and allows for additional user parameters.
|
||||||
|
|
||||||
|
You can view the project at <a href="https://github.com/smurf0969/WiFiConnect">https://github.com/smurf0969/WiFiConnect</a>.
|
||||||
|
Further information is also available in the project <a href="https://github.com/smurf0969/WiFiConnect/wiki">Wiki</a>.
|
||||||
|
|
||||||
|
This is a heavily customised version from the origional <a href="https://github.com/tzapu/WiFiManager">WiFiManager</a>
|
||||||
|
developed by https://github.com/tzapu .
|
||||||
|
|
||||||
|
This library depends on <a href="https://github.com/esp8266/Arduino">
|
||||||
|
ESP8266 Arduino Core</a> and <a href="https://github.com/espressif/arduino-esp32">ESP32 Arduino Core</a> being present on your system.
|
||||||
|
Please make sure you have installed the latest version before using this library.
|
||||||
|
|
||||||
|
Written by Stuart Blair.
|
||||||
|
|
||||||
|
GNU General Public License v3.0 licence, all text here must be included in any redistribution and you should receive a copy of the license file.
|
||||||
|
|
||||||
|
*/
|
||||||
|
#ifndef WiFiConnect_h
|
||||||
|
#define WiFiConnect_h
|
||||||
|
#include <Arduino.h>
|
||||||
|
#if defined(ESP8266)
|
||||||
|
#include <ESP8266WiFi.h>
|
||||||
|
#include <ESP8266WebServer.h>
|
||||||
|
#else
|
||||||
|
#include <WiFi.h>
|
||||||
|
#include <WebServer.h>
|
||||||
|
#endif
|
||||||
|
#include <DNSServer.h>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#if defined(ESP8266)
|
||||||
|
extern "C" {
|
||||||
|
#include "user_interface.h"
|
||||||
|
}
|
||||||
|
#define ESP_getChipId() (ESP.getChipId()) ///< Gets an ID from the chip
|
||||||
|
#else
|
||||||
|
#include <esp_wifi.h>
|
||||||
|
#define ESP_getChipId() ((uint32_t)ESP.getEfuseMac())///< Gets an ID from the chip
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "WC_AP_HTML.h"
|
||||||
|
#include "WiFiConnectParam.h"
|
||||||
|
/** Options for how a access point should continue if no WiFi connected */
|
||||||
|
enum AP_Continue {
|
||||||
|
AP_NONE, ///< No action, continues to run code
|
||||||
|
AP_LOOP, ///< Stalls execution with an infinate loop
|
||||||
|
AP_RESTART, ///< Restarts the chip, allowing it to try to setup again. Handy for sensors when wifi is lost.
|
||||||
|
AP_RESET, ///< Same as AP_RESTART
|
||||||
|
AP_WAIT // Keep the AP and webserver running, sit quietly and be patient.
|
||||||
|
};
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Class that helps to connect to WiFi networks, that also has
|
||||||
|
captive portal web interface for configuration.
|
||||||
|
This is the base class for WiFiConntectOLED which displays
|
||||||
|
information on a OLED display.
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
|
class WiFiConnect {
|
||||||
|
public:
|
||||||
|
/// Create WiFiConnect class
|
||||||
|
WiFiConnect();
|
||||||
|
|
||||||
|
boolean startConfigurationPortal();
|
||||||
|
boolean startConfigurationPortal(AP_Continue apcontinue);
|
||||||
|
boolean startConfigurationPortal(AP_Continue apcontinue, const char* apName, const char* apPassword = NULL, bool paramsMode = false);
|
||||||
|
|
||||||
|
boolean startParamsPortal();
|
||||||
|
boolean startParamsPortal(AP_Continue apcontinue);
|
||||||
|
boolean startParamsPortal(AP_Continue apcontinue, const char* apName, const char* apPassword = NULL);
|
||||||
|
|
||||||
|
void addParameter(WiFiConnectParam *p);
|
||||||
|
|
||||||
|
void setAPName(const char* apName);
|
||||||
|
const char* getAPName();
|
||||||
|
|
||||||
|
void resetSettings();
|
||||||
|
|
||||||
|
boolean autoConnect();
|
||||||
|
boolean autoConnect(const char* ssidName, const char* ssidPassword = NULL, WiFiMode_t acWiFiMode = WIFI_STA);
|
||||||
|
|
||||||
|
|
||||||
|
//sets a custom ip /gateway /subnet configuration
|
||||||
|
void setAPStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn);
|
||||||
|
//sets config for a static IP
|
||||||
|
void setSTAStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn);
|
||||||
|
|
||||||
|
//called when AP mode and config portal is started
|
||||||
|
void setAPCallback( void (*func)(WiFiConnect*) );
|
||||||
|
//called when settings have been changed and connection was successful
|
||||||
|
void setSaveConfigCallback( void (*func)(void) );
|
||||||
|
|
||||||
|
void setDebug(boolean isDebug);
|
||||||
|
|
||||||
|
void setRetryAttempts(int attempts);
|
||||||
|
void setConnectionTimeoutSecs(int timeout);
|
||||||
|
void setAPModeTimeoutMins(int mins);
|
||||||
|
|
||||||
|
boolean captivePortal();
|
||||||
|
|
||||||
|
//helpers
|
||||||
|
const char* statusToString(int state);
|
||||||
|
int getRSSIasQuality(int RSSI);
|
||||||
|
boolean isIp(String str);
|
||||||
|
String toStringIp(IPAddress ip);
|
||||||
|
virtual void displayTurnOFF(int ms = 5000); ///< Virtual method overriden in WiFiConnectOLED
|
||||||
|
virtual void displayLoop(); ///< Virtual method overriden in WiFiConnectOLED
|
||||||
|
virtual void displayON(); ///< Virtual method overriden in WiFiConnectOLED
|
||||||
|
protected:
|
||||||
|
boolean _debug = false; ///< Flag to determine wheter to output mesages or not
|
||||||
|
template <typename Generic>
|
||||||
|
void DEBUG_WC(Generic text);
|
||||||
|
virtual void displayConnecting(int attempt, int totalAttempts); ///< Virtual method overriden in WiFiConnectOLED
|
||||||
|
virtual void displayConnected(); ///< Virtual method overriden in WiFiConnectOLED
|
||||||
|
virtual void displayAP(); ///< Virtual method overriden in WiFiConnectOLED
|
||||||
|
virtual void displayParams(); ///< Virtual method overriden in WiFiConnectOLED
|
||||||
|
virtual void displayManualReset(); ///< Virtual method overriden in WiFiConnectOLED
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
int _retryAttempts = 3; ///< Number of attempts when trying to connect to WiFi network
|
||||||
|
int _connectionTimeoutSecs = 10; ///< How log to wait for the connection to succeed or fail
|
||||||
|
int _apTimeoutMins = 3; ///< The amount of minutes of inactivity before the access point exits it routine
|
||||||
|
// DNS server
|
||||||
|
const byte DNS_PORT = 53; ///< Standard DNS Port number
|
||||||
|
|
||||||
|
long _lastAPPage = 0; ///< The last time a page was accessed in the portal. Used for the inactivity timeout.
|
||||||
|
boolean _removeDuplicateAPs = true; ///< Flag to remove duplicate networks from scan results.
|
||||||
|
int _minimumQuality = 8; ///< The minimum netqork quality to be included in scan results.
|
||||||
|
int _paramsCount = 0; ///< The amount of custom parameters added via addParameter
|
||||||
|
boolean _readyToConnect = false; ///< Flag used in access point to determine if it should try to connect to the network.
|
||||||
|
String _ssid = " "; ///< Tempory holder for the network ssid
|
||||||
|
String _password = " "; ///< Tempory holder for the network password
|
||||||
|
|
||||||
|
WiFiConnectParam* _params[WiFiConnect_MAX_PARAMS]; ///< Array to hold custom parameters
|
||||||
|
|
||||||
|
std::unique_ptr<DNSServer> dnsServer; ///< DNS Server for captive portal to redirect to Access Point
|
||||||
|
#ifdef ESP8266
|
||||||
|
std::unique_ptr<ESP8266WebServer> server; ///< Web server for serving access point pages
|
||||||
|
#else
|
||||||
|
std::unique_ptr<WebServer> server; ///< Web server for serving access point pages
|
||||||
|
#endif
|
||||||
|
|
||||||
|
char _apName[33] ; ///< Holder for the access point name
|
||||||
|
char _apPassword[65] ; ///< Holder for the access point password
|
||||||
|
|
||||||
|
IPAddress _ap_static_ip; ///< Variable for holding Static IP Address for the access point
|
||||||
|
IPAddress _ap_static_gw; ///< Variable for holding Static Gateway IP Address for the access point
|
||||||
|
IPAddress _ap_static_sn; ///< Variable for holding Static Subnet Mask IP Address for the access point
|
||||||
|
IPAddress _sta_static_ip; ///< Variable for holding Static IP Address for the network connection
|
||||||
|
IPAddress _sta_static_gw; ///< Variable for holding Static Gateway IP Address for the network connection
|
||||||
|
IPAddress _sta_static_sn; ///< Variable for holding Static Subnet Mask IP Address for the network connection
|
||||||
|
|
||||||
|
void (*_apcallback)(WiFiConnect*) = NULL;
|
||||||
|
void (*_savecallback)(void) = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void handleRoot();
|
||||||
|
void handleParamRoot();
|
||||||
|
void handleParams();
|
||||||
|
void handleWifi(boolean scan);
|
||||||
|
void handleWifiSave();
|
||||||
|
void handleInfo();
|
||||||
|
void handleReset();
|
||||||
|
void handle204();
|
||||||
|
void handleNotFound();
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
auto optionalIPFromString(T *obj, const char *s) -> decltype( obj->fromString(s) ) {
|
||||||
|
return obj->fromString(s);
|
||||||
|
}
|
||||||
|
auto optionalIPFromString(...) -> bool {
|
||||||
|
DEBUG_WC("NO fromString METHOD ON IPAddress, you need ESP8266 core 2.1.0 or newer for Custom IP configuration to work.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,166 @@
|
|||||||
|
/*!
|
||||||
|
@file WiFiConnectParam.cpp
|
||||||
|
|
||||||
|
WiFi Connection Manager with Captive Portal
|
||||||
|
|
||||||
|
Introduction
|
||||||
|
|
||||||
|
This is the documentation for WiFiConnect for the Arduino platform.
|
||||||
|
It is a WiFi connection manager for use with the popular ESP8266 and ESP32 chips.
|
||||||
|
It contains a captive portal to allow easy connection and changing of WiFi netwoks
|
||||||
|
via a web based interface and allows for additional user parameters.
|
||||||
|
It can also display messages via a OLED screen see WiFiConnectOLED class.
|
||||||
|
|
||||||
|
This is a heavily customised version from the original <a href="https://github.com/tzapu/WiFiManager">WiFiManager</a>
|
||||||
|
developed by https://github.com/tzapu .
|
||||||
|
|
||||||
|
Dependencies
|
||||||
|
|
||||||
|
This library depends on <a href="https://github.com/esp8266/Arduino">
|
||||||
|
ESP8266 Arduino Core</a> and <a href="https://github.com/espressif/arduino-esp32">ESP32 Arduino Core</a> being present on your system.
|
||||||
|
Please make sure you have installed the latest version before using this library.
|
||||||
|
|
||||||
|
|
||||||
|
Written by Stuart Blair.
|
||||||
|
|
||||||
|
License
|
||||||
|
|
||||||
|
GNU General Public License v3.0 licence, all text here must be included in any redistribution and you should receive a copy of the license file.
|
||||||
|
|
||||||
|
*/
|
||||||
|
#include "WiFiConnectParam.h"
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Class object initialiser
|
||||||
|
@param custom
|
||||||
|
Custom HTML to be displayed in the access point for this item.
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
|
WiFiConnectParam::WiFiConnectParam(const char *custom) {
|
||||||
|
_id = NULL;
|
||||||
|
_placeholder = NULL;
|
||||||
|
_length = 0;
|
||||||
|
_value = NULL;
|
||||||
|
|
||||||
|
_customHTML = custom;
|
||||||
|
}
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Class object initialiser
|
||||||
|
@param id
|
||||||
|
The unique ID for the html input box markup for this item
|
||||||
|
@param placeholder
|
||||||
|
Text to be displayed as the input box placeholder for this item
|
||||||
|
@param defaultValue
|
||||||
|
Default text to be displayed in the input box for this item
|
||||||
|
@param length
|
||||||
|
The maximum input text length for this item
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
|
WiFiConnectParam::WiFiConnectParam(const char *id, const char *placeholder, const char *defaultValue, int length) {
|
||||||
|
init(id, placeholder, defaultValue, length, "");
|
||||||
|
}
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Class object initialiser
|
||||||
|
@param id
|
||||||
|
The unique ID for the html input box markup for this item
|
||||||
|
@param placeholder
|
||||||
|
Text to be displayed as the input box placeholder for this item
|
||||||
|
@param defaultValue
|
||||||
|
Default text to be displayed in the input box for this item
|
||||||
|
@param length
|
||||||
|
The maximum input text length for this item
|
||||||
|
@param custom
|
||||||
|
Custom HTML to be displayed in the access point for this item.
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
|
WiFiConnectParam::WiFiConnectParam(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom) {
|
||||||
|
init(id, placeholder, defaultValue, length, custom);
|
||||||
|
}
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Initialiser method
|
||||||
|
@param id
|
||||||
|
The unique ID for the html input box markup for this item
|
||||||
|
@param placeholder
|
||||||
|
Text to be displayed as the input box placeholder for this item
|
||||||
|
@param defaultValue
|
||||||
|
Default text to be displayed in the input box for this item
|
||||||
|
@param length
|
||||||
|
The maximum input text length for this item
|
||||||
|
@param custom
|
||||||
|
Custom HTML to be displayed in the access point for this item.
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
|
void WiFiConnectParam::init(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom) {
|
||||||
|
_id = id;
|
||||||
|
_placeholder = placeholder;
|
||||||
|
_length = length;
|
||||||
|
setValue(defaultValue);
|
||||||
|
|
||||||
|
_customHTML = custom;
|
||||||
|
}
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Method to change the current value of the item
|
||||||
|
@param newValue
|
||||||
|
The new string value for the item
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
|
void WiFiConnectParam::setValue(const char *newValue){
|
||||||
|
if(_length>0){
|
||||||
|
_value = new char[_length + 1];
|
||||||
|
for (int i = 0; i < _length; i++) {
|
||||||
|
_value[i] = 0;
|
||||||
|
}
|
||||||
|
if (newValue != NULL) {
|
||||||
|
strncpy(_value, newValue, _length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Function to get the current value of the item
|
||||||
|
@return The current value
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
|
const char* WiFiConnectParam::getValue() {
|
||||||
|
return _value;
|
||||||
|
}
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Function to get the current id of the item
|
||||||
|
@return The current id
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
|
const char* WiFiConnectParam::getID() {
|
||||||
|
return _id;
|
||||||
|
}
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Function to get the current placeholder text of the item
|
||||||
|
@return The current placeholder text
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
|
const char* WiFiConnectParam::getPlaceholder() {
|
||||||
|
return _placeholder;
|
||||||
|
}
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Function to get the maximum length allowed for the value of the item
|
||||||
|
@return The current maximum value length
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
|
int WiFiConnectParam::getValueLength() {
|
||||||
|
return _length;
|
||||||
|
}
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Function to get the current custom html markup of the item
|
||||||
|
@return The current custom html markup
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
|
const char* WiFiConnectParam::getCustomHTML() {
|
||||||
|
return _customHTML;
|
||||||
|
}
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
/*!
|
||||||
|
@file WiFiConnectParam.h
|
||||||
|
|
||||||
|
WiFi Connection Manager with Captive Portal
|
||||||
|
|
||||||
|
Introduction
|
||||||
|
|
||||||
|
This is the documentation for WiFiConnect for the Arduino platform.
|
||||||
|
It is a WiFi connection manager for use with the popular ESP8266 and ESP32 chips.
|
||||||
|
It contains a captive portal to allow easy connection and changing of WiFi netwoks
|
||||||
|
via a web based interface and allows for additional user parameters.
|
||||||
|
It can also display messages via a OLED screen see WiFiConnectOLED class.
|
||||||
|
|
||||||
|
This is a heavily customised version from the original <a href="https://github.com/tzapu/WiFiManager">WiFiManager</a>
|
||||||
|
developed by https://github.com/tzapu .
|
||||||
|
|
||||||
|
Dependencies
|
||||||
|
|
||||||
|
This library depends on <a href="https://github.com/esp8266/Arduino">
|
||||||
|
ESP8266 Arduino Core</a> and <a href="https://github.com/espressif/arduino-esp32">ESP32 Arduino Core</a> being present on your system.
|
||||||
|
Please make sure you have installed the latest version before using this library.
|
||||||
|
|
||||||
|
|
||||||
|
Written by Stuart Blair.
|
||||||
|
|
||||||
|
License
|
||||||
|
|
||||||
|
GNU General Public License v3.0 licence, all text here must be included in any redistribution and you should receive a copy of the license file.
|
||||||
|
|
||||||
|
*/
|
||||||
|
#ifndef WIFI_CONNECT_PARAM
|
||||||
|
#define WIFI_CONNECT_PARAM
|
||||||
|
|
||||||
|
#ifndef WiFiConnect_MAX_PARAMS
|
||||||
|
#define WiFiConnect_MAX_PARAMS 10 ///< The maximum size of the param array and how many custom parameters we may have
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Class that stores a custom parameter
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
|
class WiFiConnectParam {
|
||||||
|
public:
|
||||||
|
WiFiConnectParam(const char *custom);
|
||||||
|
WiFiConnectParam(const char *id, const char *placeholder, const char *defaultValue, int length);
|
||||||
|
WiFiConnectParam(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom);
|
||||||
|
|
||||||
|
const char *getID();
|
||||||
|
const char *getValue();
|
||||||
|
const char *getPlaceholder();
|
||||||
|
int getValueLength();
|
||||||
|
const char *getCustomHTML();
|
||||||
|
void setValue(const char *newValue);
|
||||||
|
private:
|
||||||
|
const char *_id;
|
||||||
|
const char *_placeholder;
|
||||||
|
char *_value;
|
||||||
|
int _length;
|
||||||
|
const char *_customHTML;
|
||||||
|
|
||||||
|
void init(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom);
|
||||||
|
|
||||||
|
friend class WiFiConnect; ///< Declarion for WiFiConnect class
|
||||||
|
|
||||||
|
};
|
||||||
|
#endif
|
||||||
+2
-1
@@ -1,3 +1,4 @@
|
|||||||
|
/*
|
||||||
const uint8_t Aura2Regular12pt8bBitmaps[] PROGMEM = {
|
const uint8_t Aura2Regular12pt8bBitmaps[] PROGMEM = {
|
||||||
0xFF, 0xFF, 0xFF, 0xC2, 0xF0, 0xCF, 0x3C, 0xF3, 0x8E, 0x30, 0x08, 0xC0,
|
0xFF, 0xFF, 0xFF, 0xC2, 0xF0, 0xCF, 0x3C, 0xF3, 0x8E, 0x30, 0x08, 0xC0,
|
||||||
0x8C, 0x18, 0xC1, 0x8C, 0x7F, 0xF1, 0x8C, 0x18, 0x81, 0x88, 0x11, 0x83,
|
0x8C, 0x18, 0xC1, 0x8C, 0x7F, 0xF1, 0x8C, 0x18, 0x81, 0x88, 0x11, 0x83,
|
||||||
@@ -5072,7 +5073,7 @@ const GFXfont Aura2Regular8pt8b PROGMEM = {
|
|||||||
(uint8_t *)Aura2Regular8pt8bBitmaps,
|
(uint8_t *)Aura2Regular8pt8bBitmaps,
|
||||||
(GFXglyph *)Aura2Regular8pt8bGlyphs,
|
(GFXglyph *)Aura2Regular8pt8bGlyphs,
|
||||||
0x20, 0x400, 20 };
|
0x20, 0x400, 20 };
|
||||||
|
*/
|
||||||
const uint8_t Aura2Pro_Light7pt8bBitmaps[] PROGMEM = {
|
const uint8_t Aura2Pro_Light7pt8bBitmaps[] PROGMEM = {
|
||||||
0xFF, 0x60, 0x99, 0x99, 0x24, 0x48, 0x93, 0xF2, 0x49, 0x12, 0x24, 0xFC,
|
0xFF, 0x60, 0x99, 0x99, 0x24, 0x48, 0x93, 0xF2, 0x49, 0x12, 0x24, 0xFC,
|
||||||
0x91, 0x20, 0x10, 0xE5, 0x64, 0x91, 0x43, 0x85, 0x14, 0x51, 0x7E, 0x10,
|
0x91, 0x20, 0x10, 0xE5, 0x64, 0x91, 0x43, 0x85, 0x14, 0x51, 0x7E, 0x10,
|
||||||
|
|||||||
+73
-10
@@ -1,6 +1,6 @@
|
|||||||
// [number of languages][number of texts][max. length of text]
|
// [number of languages][number of texts][max. length of text]
|
||||||
|
|
||||||
const char myLanguage[9][51][100] = {
|
static const char myLanguage[9][58][78] = {
|
||||||
{ "English", // English
|
{ "English", // English
|
||||||
"Rotary direction changed",
|
"Rotary direction changed",
|
||||||
"Please release button",
|
"Please release button",
|
||||||
@@ -51,7 +51,14 @@ const char myLanguage[9][51][100] = {
|
|||||||
"Europe",
|
"Europe",
|
||||||
"USA",
|
"USA",
|
||||||
"Show underscore in RDS",
|
"Show underscore in RDS",
|
||||||
"USB mode"
|
"USB mode",
|
||||||
|
"Wi-Fi active",
|
||||||
|
"Configure Wi-Fi",
|
||||||
|
"Connect to: ",
|
||||||
|
"to configure Wi-Fi",
|
||||||
|
"Trying to connect with Wi-Fi",
|
||||||
|
"FAILED.. WiFi disabled",
|
||||||
|
"CONNECTED!"
|
||||||
},
|
},
|
||||||
|
|
||||||
{ "Nederlands", // Dutch
|
{ "Nederlands", // Dutch
|
||||||
@@ -104,7 +111,14 @@ const char myLanguage[9][51][100] = {
|
|||||||
"Europa",
|
"Europa",
|
||||||
"USA",
|
"USA",
|
||||||
"Toon underscore in RDS",
|
"Toon underscore in RDS",
|
||||||
"USB mode"
|
"USB mode",
|
||||||
|
"Wi-Fi aktief",
|
||||||
|
"Configureer Wi-Fi",
|
||||||
|
"Verbind met: ",
|
||||||
|
"om Wi-Fi in te stellen",
|
||||||
|
"Verbinden met Wi-Fi...",
|
||||||
|
"MISLUKT.. WiFi uitgeschakeld",
|
||||||
|
"VERBONDEN!"
|
||||||
},
|
},
|
||||||
|
|
||||||
{ "Polski", // Polish
|
{ "Polski", // Polish
|
||||||
@@ -157,7 +171,14 @@ const char myLanguage[9][51][100] = {
|
|||||||
"Europa",
|
"Europa",
|
||||||
"USA",
|
"USA",
|
||||||
"Pokaz podkreslenia w RDS",
|
"Pokaz podkreslenia w RDS",
|
||||||
"Tryb USB"
|
"Tryb USB",
|
||||||
|
"Wi-Fi active",
|
||||||
|
"Configure Wi-Fi",
|
||||||
|
"Connect to: ",
|
||||||
|
"to configure Wi-Fi",
|
||||||
|
"Trying to connect with Wi-Fi",
|
||||||
|
"FAILED.. WiFi disabled",
|
||||||
|
"CONNECTED!"
|
||||||
},
|
},
|
||||||
|
|
||||||
{ "Hrvatski", // Croatian
|
{ "Hrvatski", // Croatian
|
||||||
@@ -210,7 +231,14 @@ const char myLanguage[9][51][100] = {
|
|||||||
"Europa",
|
"Europa",
|
||||||
"SAD",
|
"SAD",
|
||||||
"Prikaži donju crtu u RDS-u",
|
"Prikaži donju crtu u RDS-u",
|
||||||
"Način rada USB-a"
|
"Način rada USB-a",
|
||||||
|
"Wi-Fi active",
|
||||||
|
"Configure Wi-Fi",
|
||||||
|
"Connect to: ",
|
||||||
|
"to configure Wi-Fi",
|
||||||
|
"Trying to connect with Wi-Fi",
|
||||||
|
"FAILED.. WiFi disabled",
|
||||||
|
"CONNECTED!"
|
||||||
},
|
},
|
||||||
|
|
||||||
{ "Ελληνικά", // Greek
|
{ "Ελληνικά", // Greek
|
||||||
@@ -263,7 +291,14 @@ const char myLanguage[9][51][100] = {
|
|||||||
"Ευρώπη",
|
"Ευρώπη",
|
||||||
"Η.Π.Α.",
|
"Η.Π.Α.",
|
||||||
"Εμφάνιση κάτω παύλας στο RDS",
|
"Εμφάνιση κάτω παύλας στο RDS",
|
||||||
"USB mode"
|
"USB mode",
|
||||||
|
"Wi-Fi active",
|
||||||
|
"Configure Wi-Fi",
|
||||||
|
"Connect to: ",
|
||||||
|
"to configure Wi-Fi",
|
||||||
|
"Trying to connect with Wi-Fi",
|
||||||
|
"FAILED.. WiFi disabled",
|
||||||
|
"CONNECTED!"
|
||||||
},
|
},
|
||||||
|
|
||||||
{ "Romana", // Romana
|
{ "Romana", // Romana
|
||||||
@@ -316,7 +351,14 @@ const char myLanguage[9][51][100] = {
|
|||||||
"Europa",
|
"Europa",
|
||||||
"SUA",
|
"SUA",
|
||||||
"Arata evidentiat in RDS",
|
"Arata evidentiat in RDS",
|
||||||
"USB mode"
|
"USB mode",
|
||||||
|
"Wi-Fi active",
|
||||||
|
"Configure Wi-Fi",
|
||||||
|
"Connect to: ",
|
||||||
|
"to configure Wi-Fi",
|
||||||
|
"Trying to connect with Wi-Fi",
|
||||||
|
"FAILED.. WiFi disabled",
|
||||||
|
"CONNECTED!"
|
||||||
},
|
},
|
||||||
|
|
||||||
{ "Deutsch", // German
|
{ "Deutsch", // German
|
||||||
@@ -369,7 +411,14 @@ const char myLanguage[9][51][100] = {
|
|||||||
"Europa",
|
"Europa",
|
||||||
"USA",
|
"USA",
|
||||||
"Zeige Unterstrich im RDS",
|
"Zeige Unterstrich im RDS",
|
||||||
"USB mode"
|
"USB mode",
|
||||||
|
"Wi-Fi active",
|
||||||
|
"Configure Wi-Fi",
|
||||||
|
"Connect to: ",
|
||||||
|
"to configure Wi-Fi",
|
||||||
|
"Trying to connect with Wi-Fi",
|
||||||
|
"FAILED.. WiFi disabled",
|
||||||
|
"CONNECTED!"
|
||||||
},
|
},
|
||||||
{ "Czech", // English
|
{ "Czech", // English
|
||||||
"Směr enkóderu byl změněn",
|
"Směr enkóderu byl změněn",
|
||||||
@@ -421,7 +470,14 @@ const char myLanguage[9][51][100] = {
|
|||||||
"Evropa",
|
"Evropa",
|
||||||
"USA",
|
"USA",
|
||||||
"Zobrazit podtržítka v RDS",
|
"Zobrazit podtržítka v RDS",
|
||||||
"USB mode"
|
"USB mode",
|
||||||
|
"Wi-Fi active",
|
||||||
|
"Configure Wi-Fi",
|
||||||
|
"Connect to: ",
|
||||||
|
"to configure Wi-Fi",
|
||||||
|
"Trying to connect with Wi-Fi",
|
||||||
|
"FAILED.. WiFi disabled",
|
||||||
|
"CONNECTED!"
|
||||||
},
|
},
|
||||||
{ "Slovak", // English
|
{ "Slovak", // English
|
||||||
"Smer enkóderu bol zmenený",
|
"Smer enkóderu bol zmenený",
|
||||||
@@ -473,6 +529,13 @@ const char myLanguage[9][51][100] = {
|
|||||||
"Európa",
|
"Európa",
|
||||||
"USA",
|
"USA",
|
||||||
"Zobraziť podtržítka v RDS",
|
"Zobraziť podtržítka v RDS",
|
||||||
"USB mode"
|
"USB mode",
|
||||||
|
"Wi-Fi active",
|
||||||
|
"Configure Wi-Fi",
|
||||||
|
"Connect to: ",
|
||||||
|
"to configure Wi-Fi",
|
||||||
|
"Trying to connect with Wi-Fi",
|
||||||
|
"FAILED.. WiFi disabled",
|
||||||
|
"CONNECTED!"
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user