Browse Source

Added (optinal) static IP-config

master
Torsten Stauder 5 years ago
parent
commit
4efd4372d5
  1. 1
      README.md
  2. 2
      platformio.ini
  3. 2
      src/logmessages.h
  4. 2
      src/logmessages_EN.h
  5. 15
      src/main.cpp
  6. 9
      src/settings.h

1
README.md

@ -26,6 +26,7 @@ Finally, the long announced Tonuino-PCB for Wemos' Lolin32 is [there](https://gi
<br />More to come... <br />More to come...
* 23.12.2020: User-config is now split into general part (settings.h) and develboard-specific part (e.g. settings-lolin32.h) * 23.12.2020: User-config is now split into general part (settings.h) and develboard-specific part (e.g. settings-lolin32.h)
* 13.01.2020: Added fileexlorer to webgui (thanks @grch87 for contribution!). Now files and directories can be renamed, uploaded and deleted via webgui. * 13.01.2020: Added fileexlorer to webgui (thanks @grch87 for contribution!). Now files and directories can be renamed, uploaded and deleted via webgui.
* 17.01.2020: Added directive `STATIC_IP_ENABLE`: (optional) static IPv4-configuration
## Known bugs ## Known bugs
* Some webstreams don't run. Guess it's a combination of saturated connection-pool and lack of heap-memory. Works probably better if ESP32-WROVER (e.g. Lolin D32 pro) is used, as this chip has PSRAM. Advice: Don't enable modules (e.g. MQTT) if you don't need them as this could save memory (and trouble). * Some webstreams don't run. Guess it's a combination of saturated connection-pool and lack of heap-memory. Works probably better if ESP32-WROVER (e.g. Lolin D32 pro) is used, as this chip has PSRAM. Advice: Don't enable modules (e.g. MQTT) if you don't need them as this could save memory (and trouble).
* English translation for webgui is currently outdated. This will be fixed soon when i18n-support will be integrated. * English translation for webgui is currently outdated. This will be fixed soon when i18n-support will be integrated.

2
platformio.ini

@ -13,7 +13,7 @@ lib_deps_builtin =
SPI SPI
Wire Wire
lib_deps_external = lib_deps_external =
https://github.com/schreibfaul1/ESP32-audioI2S.git
https://github.com/schreibfaul1/ESP32-audioI2S.git#a816a19 ; currently not master-version as commit a816a19 not compatible with latest stable ESP32-Arduino
https://github.com/madhephaestus/ESP32Encoder.git https://github.com/madhephaestus/ESP32Encoder.git
https://github.com/knolleary/pubsubclient.git https://github.com/knolleary/pubsubclient.git
https://github.com/biologist79/ESP32FTPServer https://github.com/biologist79/ESP32FTPServer

2
src/logmessages.h

@ -169,3 +169,5 @@ static const char trackPausedAtPos[] PROGMEM = "Titel pausiert bei Position";
static const char freeHeapWithoutFtp[] PROGMEM = "Freier Heap-Speicher vor FTP-Instanzierung"; static const char freeHeapWithoutFtp[] PROGMEM = "Freier Heap-Speicher vor FTP-Instanzierung";
static const char freeHeapWithFtp[] PROGMEM = "Freier Heap-Speicher nach FTP-Instanzierung"; static const char freeHeapWithFtp[] PROGMEM = "Freier Heap-Speicher nach FTP-Instanzierung";
static const char freeHeapAfterSetup[] PROGMEM = "Freier Heap-Speicher nach Setup-Routine"; static const char freeHeapAfterSetup[] PROGMEM = "Freier Heap-Speicher nach Setup-Routine";
static const char tryStaticIpConfig[] PROGMEM = "Statische IP-Konfiguration wird durchgeführt...";
static const char staticIPConfigFailed[] PROGMEM = "Statische IP-Konfiguration fehlgeschlagen";

2
src/logmessages_EN.h

@ -169,3 +169,5 @@ static const char trackPausedAtPos[] PROGMEM = "Track paused at position";
static const char freeHeapWithoutFtp[] PROGMEM = "Free heap before FTP-allocation"; static const char freeHeapWithoutFtp[] PROGMEM = "Free heap before FTP-allocation";
static const char freeHeapWithFtp[] PROGMEM = "Free heap after FTP-allocation"; static const char freeHeapWithFtp[] PROGMEM = "Free heap after FTP-allocation";
static const char freeHeapAfterSetup[] PROGMEM = "Free heap after setup"; static const char freeHeapAfterSetup[] PROGMEM = "Free heap after setup";
static const char tryStaticIpConfig[] PROGMEM = "Performing static IP-configuration...";
static const char staticIPConfigFailed[] PROGMEM = "Static IP-configuration failed";

15
src/main.cpp

@ -3192,7 +3192,18 @@ wl_status_t wifiManager(void) {
} else { } else {
loggerNl((char *) FPSTR(wifiHostnameNotSet), LOGLEVEL_INFO); loggerNl((char *) FPSTR(wifiHostnameNotSet), LOGLEVEL_INFO);
} }
// ...and create a connection with it. If not successful, an access-point is opened
// Add configration of static IP (if requested)
#ifdef STATIC_IP_ENABLE
snprintf(logBuf, serialLoglength, "%s", (char *) FPSTR(tryStaticIpConfig));
loggerNl(logBuf, LOGLEVEL_NOTICE);
if (!WiFi.config(local_IP, gateway, subnet, primaryDNS)) {
snprintf(logBuf, serialLoglength, "%s", (char *) FPSTR(staticIPConfigFailed));
loggerNl(logBuf, LOGLEVEL_ERROR);
}
#endif
// Try to join local WiFi. If not successful, an access-point is opened
WiFi.begin(_ssid, _pwd); WiFi.begin(_ssid, _pwd);
uint8_t tryCount=0; uint8_t tryCount=0;
@ -3810,7 +3821,7 @@ void explorerHandleFileStorageTask(void *parameter) {
uploadFile = FSystem.open((char *)parameter, "w"); uploadFile = FSystem.open((char *)parameter, "w");
snprintf(logBuf, serialLoglength, "%s: %s", (char *) FPSTR(writingFile), parameter);
snprintf(logBuf, serialLoglength, "%s: %s", (char *) FPSTR(writingFile), (char *) parameter);
loggerNl(logBuf, LOGLEVEL_INFO); loggerNl(logBuf, LOGLEVEL_INFO);
for(;;) { for(;;) {

9
src/settings.h

@ -22,6 +22,7 @@
#define NEOPIXEL_ENABLE // Don't forget configuration of NUM_LEDS if enabled #define NEOPIXEL_ENABLE // Don't forget configuration of NUM_LEDS if enabled
#define NEOPIXEL_REVERSE_ROTATION // Some Neopixels are adressed/soldered counter-clockwise. This can be configured here. #define NEOPIXEL_REVERSE_ROTATION // Some Neopixels are adressed/soldered counter-clockwise. This can be configured here.
#define LANGUAGE 1 // 1 = deutsch; 2 = english #define LANGUAGE 1 // 1 = deutsch; 2 = english
//#define STATIC_IP_ENABLE // Enables static IP-configuration (change static ip-section accordingly)
//#define HEADPHONE_ADJUST_ENABLE // Used to adjust (lower) volume for optional headphone-pcb (refer maxVolumeSpeaker / maxVolumeHeadphone) //#define HEADPHONE_ADJUST_ENABLE // Used to adjust (lower) volume for optional headphone-pcb (refer maxVolumeSpeaker / maxVolumeHeadphone)
#define SHUTDOWN_IF_SD_BOOT_FAILS // Will put ESP to deepsleep if boot fails due to SD. Really recommend this if there's in battery-mode no other way to restart ESP! Interval adjustable via deepsleepTimeAfterBootFails. #define SHUTDOWN_IF_SD_BOOT_FAILS // Will put ESP to deepsleep if boot fails due to SD. Really recommend this if there's in battery-mode no other way to restart ESP! Interval adjustable via deepsleepTimeAfterBootFails.
#define MEASURE_BATTERY_VOLTAGE // Enables battery-measurement via GPIO (ADC) and voltage-divider #define MEASURE_BATTERY_VOLTAGE // Enables battery-measurement via GPIO (ADC) and voltage-divider
@ -51,6 +52,14 @@
// Serial-logging-configuration // Serial-logging-configuration
const uint8_t serialDebug = LOGLEVEL_DEBUG; // Current loglevel for serial console const uint8_t serialDebug = LOGLEVEL_DEBUG; // Current loglevel for serial console
// Static ip-configuration
#ifdef STATIC_IP_ENABLE
IPAddress local_IP(192, 168, 2, 100); // Tonuino's IP
IPAddress gateway(192, 168, 2, 1); // IP of the gateway/router
IPAddress subnet(255, 255, 255, 0); // Netmask of your network (/24 => 255.255.255.0)
IPAddress primaryDNS(192, 168, 2, 1); // DNS-server of your network; in private networks it's usually the gatewy's IP
#endif
// Buttons (better leave unchanged if in doubts :-)) // Buttons (better leave unchanged if in doubts :-))
uint8_t buttonDebounceInterval = 50; // Interval in ms to software-debounce buttons uint8_t buttonDebounceInterval = 50; // Interval in ms to software-debounce buttons
uint16_t intervalToLongPress = 700; // Interval in ms to distinguish between short and long press of previous/next-button uint16_t intervalToLongPress = 700; // Interval in ms to distinguish between short and long press of previous/next-button

Loading…
Cancel
Save