Browse Source

Code-reformat + tiny fixes

master
Torsten Stauder 4 years ago
parent
commit
f27d15df59
  1. 1177
      src/AudioPlayer.cpp
  2. 152
      src/Battery.cpp
  3. 58
      src/Bluetooth.cpp
  4. 347
      src/Button.cpp
  5. 618
      src/Cmd.cpp
  6. 174
      src/Common.h
  7. 108
      src/Ftp.cpp
  8. 64
      src/HTMLaccesspoint.h
  9. 130
      src/HTMLaccesspoint_DE.h
  10. 4
      src/HTMLaccesspoint_EN.h
  11. 1111
      src/HTMLmanagement.h
  12. 726
      src/HTMLmanagement_DE.h
  13. 4
      src/HTMLmanagement_EN.h
  14. 254
      src/IrReceiver.cpp
  15. 876
      src/Led.cpp
  16. 22
      src/Log.cpp
  17. 364
      src/LogMessages_DE.cpp
  18. 364
      src/LogMessages_EN.cpp
  19. 759
      src/Mqtt.cpp
  20. 89
      src/Port.cpp
  21. 23
      src/Queues.cpp
  22. 66
      src/RfidCommon.cpp
  23. 143
      src/RfidMfrc522.cpp
  24. 391
      src/RfidPn5180.cpp
  25. 97
      src/RotaryEncoder.cpp
  26. 196
      src/SdCard.cpp
  27. 145
      src/System.cpp
  28. 566
      src/Web.cpp
  29. 133
      src/Wlan.cpp
  30. 175
      src/main.cpp

1177
src/AudioPlayer.cpp
File diff suppressed because it is too large
View File

152
src/Battery.cpp

@ -13,101 +13,83 @@ uint8_t voltageCheckInterval = s_voltageCheckInterval;
float voltageIndicatorLow = s_voltageIndicatorLow; float voltageIndicatorLow = s_voltageIndicatorLow;
float voltageIndicatorHigh = s_voltageIndicatorHigh; float voltageIndicatorHigh = s_voltageIndicatorHigh;
void Battery_Init()
{
#ifdef MEASURE_BATTERY_VOLTAGE
// Get voltages from NVS for Neopixel
float vLowIndicator = gPrefsSettings.getFloat("vIndicatorLow", 999.99);
if (vLowIndicator <= 999)
{
voltageIndicatorLow = vLowIndicator;
snprintf(Log_Buffer, Log_BufferLength, "%s: %.2f V", (char *)FPSTR(voltageIndicatorLowFromNVS), vLowIndicator);
Log_Println(Log_Buffer, LOGLEVEL_INFO);
}
else
{ // preseed if not set
gPrefsSettings.putFloat("vIndicatorLow", voltageIndicatorLow);
}
void Battery_Init() {
#ifdef MEASURE_BATTERY_VOLTAGE
// Get voltages from NVS for Neopixel
float vLowIndicator = gPrefsSettings.getFloat("vIndicatorLow", 999.99);
if (vLowIndicator <= 999) {
voltageIndicatorLow = vLowIndicator;
snprintf(Log_Buffer, Log_BufferLength, "%s: %.2f V", (char *) FPSTR(voltageIndicatorLowFromNVS), vLowIndicator);
Log_Println(Log_Buffer, LOGLEVEL_INFO);
} else { // preseed if not set
gPrefsSettings.putFloat("vIndicatorLow", voltageIndicatorLow);
}
float vHighIndicator = gPrefsSettings.getFloat("vIndicatorHigh", 999.99);
if (vHighIndicator <= 999)
{
voltageIndicatorHigh = vHighIndicator;
snprintf(Log_Buffer, Log_BufferLength, "%s: %.2f V", (char *)FPSTR(voltageIndicatorHighFromNVS), vHighIndicator);
Log_Println(Log_Buffer, LOGLEVEL_INFO);
}
else
{
gPrefsSettings.putFloat("vIndicatorHigh", voltageIndicatorHigh);
}
float vHighIndicator = gPrefsSettings.getFloat("vIndicatorHigh", 999.99);
if (vHighIndicator <= 999) {
voltageIndicatorHigh = vHighIndicator;
snprintf(Log_Buffer, Log_BufferLength, "%s: %.2f V", (char *) FPSTR(voltageIndicatorHighFromNVS), vHighIndicator);
Log_Println(Log_Buffer, LOGLEVEL_INFO);
} else {
gPrefsSettings.putFloat("vIndicatorHigh", voltageIndicatorHigh);
}
float vLowWarning = gPrefsSettings.getFloat("wLowVoltage", 999.99);
if (vLowWarning <= 999)
{
warningLowVoltage = vLowWarning;
snprintf(Log_Buffer, Log_BufferLength, "%s: %.2f V", (char *)FPSTR(warningLowVoltageFromNVS), vLowWarning);
Log_Println(Log_Buffer, LOGLEVEL_INFO);
}
else
{
gPrefsSettings.putFloat("wLowVoltage", warningLowVoltage);
}
float vLowWarning = gPrefsSettings.getFloat("wLowVoltage", 999.99);
if (vLowWarning <= 999) {
warningLowVoltage = vLowWarning;
snprintf(Log_Buffer, Log_BufferLength, "%s: %.2f V", (char *) FPSTR(warningLowVoltageFromNVS), vLowWarning);
Log_Println(Log_Buffer, LOGLEVEL_INFO);
} else {
gPrefsSettings.putFloat("wLowVoltage", warningLowVoltage);
}
uint32_t vInterval = gPrefsSettings.getUInt("vCheckIntv", 17777);
if (vInterval != 17777)
{
voltageCheckInterval = vInterval;
snprintf(Log_Buffer, Log_BufferLength, "%s: %u Minuten", (char *)FPSTR(voltageCheckIntervalFromNVS), vInterval);
Log_Println(Log_Buffer, LOGLEVEL_INFO);
}
else
{
gPrefsSettings.putUInt("vCheckIntv", voltageCheckInterval);
}
#endif
uint32_t vInterval = gPrefsSettings.getUInt("vCheckIntv", 17777);
if (vInterval != 17777) {
voltageCheckInterval = vInterval;
snprintf(Log_Buffer, Log_BufferLength, "%s: %u Minuten", (char *) FPSTR(voltageCheckIntervalFromNVS), vInterval);
Log_Println(Log_Buffer, LOGLEVEL_INFO);
} else {
gPrefsSettings.putUInt("vCheckIntv", voltageCheckInterval);
}
#endif
} }
// The average of several analog reads will be taken to reduce the noise (Note: One analog read takes ~10µs) // The average of several analog reads will be taken to reduce the noise (Note: One analog read takes ~10µs)
float Battery_GetVoltage(void)
{
#ifdef MEASURE_BATTERY_VOLTAGE
float factor = 1 / ((float)rdiv2 / (rdiv2 + rdiv1));
float averagedAnalogValue = 0;
uint8_t i;
for (i = 0; i <= 19; i++)
{
averagedAnalogValue += (float)analogRead(VOLTAGE_READ_PIN);
}
averagedAnalogValue /= 20.0;
return (averagedAnalogValue / maxAnalogValue) * referenceVoltage * factor + offsetVoltage;
#endif
float Battery_GetVoltage(void) {
#ifdef MEASURE_BATTERY_VOLTAGE
float factor = 1 / ((float) rdiv2 / (rdiv2 + rdiv1));
float averagedAnalogValue = 0;
uint8_t i;
for (i = 0; i <= 19; i++) {
averagedAnalogValue += (float) analogRead(VOLTAGE_READ_PIN);
}
averagedAnalogValue /= 20.0;
return (averagedAnalogValue / maxAnalogValue) * referenceVoltage * factor + offsetVoltage;
#endif
} }
// Measures voltage of a battery as per interval or after bootup (after allowing a few seconds to settle down) // Measures voltage of a battery as per interval or after bootup (after allowing a few seconds to settle down)
void Battery_Cyclic(void)
{
#ifdef MEASURE_BATTERY_VOLTAGE
static uint32_t lastVoltageCheckTimestamp = 0;
void Battery_Cyclic(void) {
#ifdef MEASURE_BATTERY_VOLTAGE
static uint32_t lastVoltageCheckTimestamp = 0;
if ((millis() - lastVoltageCheckTimestamp >= voltageCheckInterval * 60000) || (!lastVoltageCheckTimestamp && millis() >= 10000))
{
float voltage = Battery_GetVoltage();
if ((millis() - lastVoltageCheckTimestamp >= voltageCheckInterval * 60000) || (!lastVoltageCheckTimestamp && millis() >= 10000)) {
float voltage = Battery_GetVoltage();
if (voltage <= warningLowVoltage)
{
snprintf(Log_Buffer, Log_BufferLength, "%s: (%.2f V)", (char *)FPSTR(voltageTooLow), voltage);
Log_Println(Log_Buffer, LOGLEVEL_ERROR);
Led_Indicate(LedIndicatorType::VoltageWarning);
}
if (voltage <= warningLowVoltage) {
snprintf(Log_Buffer, Log_BufferLength, "%s: (%.2f V)", (char *) FPSTR(voltageTooLow), voltage);
Log_Println(Log_Buffer, LOGLEVEL_ERROR);
Led_Indicate(LedIndicatorType::VoltageWarning);
}
#ifdef MQTT_ENABLE
char vstr[6];
snprintf(vstr, 6, "%.2f", voltage);
publishMqtt((char *)FPSTR(topicBatteryVoltage), vstr, false);
#endif
snprintf(Log_Buffer, Log_BufferLength, "%s: %.2f V", (char *)FPSTR(currentVoltageMsg), voltage);
Log_Println(Log_Buffer, LOGLEVEL_INFO);
lastVoltageCheckTimestamp = millis();
}
#endif
#ifdef MQTT_ENABLE
char vstr[6];
snprintf(vstr, 6, "%.2f", voltage);
publishMqtt((char *) FPSTR(topicBatteryVoltage), vstr, false);
#endif
snprintf(Log_Buffer, Log_BufferLength, "%s: %.2f V", (char *) FPSTR(currentVoltageMsg), voltage);
Log_Println(Log_Buffer, LOGLEVEL_INFO);
lastVoltageCheckTimestamp = millis();
}
#endif
} }

58
src/Bluetooth.cpp

@ -4,43 +4,37 @@
#include "System.h" #include "System.h"
#ifdef BLUETOOTH_ENABLE #ifdef BLUETOOTH_ENABLE
#include "esp_bt.h"
#include "BluetoothA2DPSink.h"
#include "esp_bt.h"
#include "BluetoothA2DPSink.h"
#endif #endif
#ifdef BLUETOOTH_ENABLE #ifdef BLUETOOTH_ENABLE
BluetoothA2DPSink *a2dp_sink;
BluetoothA2DPSink *a2dp_sink;
#endif #endif
void Bluetooth_Init(void)
{
#ifdef BLUETOOTH_ENABLE
if (System_GetOperationMode() == OPMODE_BLUETOOTH)
{
a2dp_sink = new BluetoothA2DPSink();
i2s_pin_config_t pin_config = {
.bck_io_num = I2S_BCLK,
.ws_io_num = I2S_LRC,
.data_out_num = I2S_DOUT,
.data_in_num = I2S_PIN_NO_CHANGE};
a2dp_sink->set_pin_config(pin_config);
a2dp_sink->start((char *)FPSTR(nameBluetoothDevice));
}
else
{
esp_bt_mem_release(ESP_BT_MODE_BTDM);
}
#endif
void Bluetooth_Init(void) {
#ifdef BLUETOOTH_ENABLE
if (System_GetOperationMode() == OPMODE_BLUETOOTH) {
a2dp_sink = new BluetoothA2DPSink();
i2s_pin_config_t pin_config = {
.bck_io_num = I2S_BCLK,
.ws_io_num = I2S_LRC,
.data_out_num = I2S_DOUT,
.data_in_num = I2S_PIN_NO_CHANGE};
a2dp_sink->set_pin_config(pin_config);
a2dp_sink->start((char *)FPSTR(nameBluetoothDevice));
} else {
esp_bt_mem_release(ESP_BT_MODE_BTDM);
}
#endif
} }
void Bluetooth_Cyclic(void)
{
#ifdef BLUETOOTH_ENABLE
esp_a2d_audio_state_t state = a2dp_sink->get_audio_state();
// Reset Sleep Timer when audio is playing
if (state == ESP_A2D_AUDIO_STATE_STARTED)
{
System_UpdateActivityTimer();
}
#endif
void Bluetooth_Cyclic(void) {
#ifdef BLUETOOTH_ENABLE
esp_a2d_audio_state_t state = a2dp_sink->get_audio_state();
// Reset Sleep Timer when audio is playing
if (state == ESP_A2D_AUDIO_STATE_STARTED) {
System_UpdateActivityTimer();
}
#endif
} }

347
src/Button.cpp

@ -48,71 +48,69 @@ uint8_t gShutdownButton = 99; // Helper used for Neopixel: stores button-number
static volatile SemaphoreHandle_t Button_TimerSemaphore; static volatile SemaphoreHandle_t Button_TimerSemaphore;
#ifndef IR_CONTROL_ENABLE #ifndef IR_CONTROL_ENABLE
hw_timer_t *Button_Timer = NULL;
hw_timer_t *Button_Timer = NULL;
#endif #endif
static void IRAM_ATTR onTimer(); static void IRAM_ATTR onTimer();
static void Button_DoButtonActions(void); static void Button_DoButtonActions(void);
void Button_Init()
{
#if (WAKEUP_BUTTON <= 39)
esp_sleep_enable_ext0_wakeup((gpio_num_t)WAKEUP_BUTTON, 0);
#endif
void Button_Init() {
#if (WAKEUP_BUTTON <= 39)
esp_sleep_enable_ext0_wakeup((gpio_num_t)WAKEUP_BUTTON, 0);
#endif
#ifdef NEOPIXEL_ENABLE // Try to find button that is used for shutdown via longpress-action (only necessary for Neopixel)
#if defined(BUTTON_0_ENABLE) || defined(EXPANDER_0_ENABLE)
#if (BUTTON_0_LONG == CMD_SLEEPMODE)
gShutdownButton = 0;
#endif
#endif
#if defined(BUTTON_1_ENABLE) || defined(EXPANDER_1_ENABLE)
#if (BUTTON_1_LONG == CMD_SLEEPMODE)
gShutdownButton = 1;
#endif
#endif
#if defined(BUTTON_2_ENABLE) || defined(EXPANDER_2_ENABLE)
#if (BUTTON_2_LONG == CMD_SLEEPMODE)
gShutdownButton = 2;
#endif
#endif
#if defined(BUTTON_3_ENABLE) || defined(EXPANDER_3_ENABLE)
#if (BUTTON_3_LONG == CMD_SLEEPMODE)
gShutdownButton = 3;
#endif
#endif
#if defined(BUTTON_4_ENABLE) || defined(EXPANDER_4_ENABLE)
#if (BUTTON_4_LONG == CMD_SLEEPMODE)
gShutdownButton = 4;
#endif
#endif
#if defined(BUTTON_5_ENABLE) || defined(EXPANDER_5_ENABLE)
#if (BUTTON_5_LONG == CMD_SLEEPMODE)
gShutdownButton = 5;
#endif
#endif
#endif
#ifdef NEOPIXEL_ENABLE // Try to find button that is used for shutdown via longpress-action (only necessary for Neopixel)
#if defined(BUTTON_0_ENABLE) || defined(EXPANDER_0_ENABLE)
#if (BUTTON_0_LONG == CMD_SLEEPMODE)
gShutdownButton = 0;
#endif
#endif
#if defined(BUTTON_1_ENABLE) || defined(EXPANDER_1_ENABLE)
#if (BUTTON_1_LONG == CMD_SLEEPMODE)
gShutdownButton = 1;
#endif
#endif
#if defined(BUTTON_2_ENABLE) || defined(EXPANDER_2_ENABLE)
#if (BUTTON_2_LONG == CMD_SLEEPMODE)
gShutdownButton = 2;
#endif
#endif
#if defined(BUTTON_3_ENABLE) || defined(EXPANDER_3_ENABLE)
#if (BUTTON_3_LONG == CMD_SLEEPMODE)
gShutdownButton = 3;
#endif
#endif
#if defined(BUTTON_4_ENABLE) || defined(EXPANDER_4_ENABLE)
#if (BUTTON_4_LONG == CMD_SLEEPMODE)
gShutdownButton = 4;
#endif
#endif
#if defined(BUTTON_5_ENABLE) || defined(EXPANDER_5_ENABLE)
#if (BUTTON_5_LONG == CMD_SLEEPMODE)
gShutdownButton = 5;
#endif
#endif
#endif
// Activate internal pullups for all enabled buttons
#ifdef BUTTON_0_ENABLE
pinMode(NEXT_BUTTON, INPUT_PULLUP);
#endif
#ifdef BUTTON_1_ENABLE
pinMode(PREVIOUS_BUTTON, INPUT_PULLUP);
#endif
#ifdef BUTTON_2_ENABLE
pinMode(PAUSEPLAY_BUTTON, INPUT_PULLUP);
#endif
#ifdef BUTTON_3_ENABLE
pinMode(DREHENCODER_BUTTON, INPUT_PULLUP);
#endif
#ifdef BUTTON_4_ENABLE
pinMode(BUTTON_4, INPUT_PULLUP);
#endif
#ifdef BUTTON_5_ENABLE
pinMode(BUTTON_5, INPUT_PULLUP);
#endif
// Activate internal pullups for all enabled buttons
#ifdef BUTTON_0_ENABLE
pinMode(NEXT_BUTTON, INPUT_PULLUP);
#endif
#ifdef BUTTON_1_ENABLE
pinMode(PREVIOUS_BUTTON, INPUT_PULLUP);
#endif
#ifdef BUTTON_2_ENABLE
pinMode(PAUSEPLAY_BUTTON, INPUT_PULLUP);
#endif
#ifdef BUTTON_3_ENABLE
pinMode(DREHENCODER_BUTTON, INPUT_PULLUP);
#endif
#ifdef BUTTON_4_ENABLE
pinMode(BUTTON_4, INPUT_PULLUP);
#endif
#ifdef BUTTON_5_ENABLE
pinMode(BUTTON_5, INPUT_PULLUP);
#endif
// Create 1000Hz-HW-Timer (currently only used for buttons) // Create 1000Hz-HW-Timer (currently only used for buttons)
Button_TimerSemaphore = xSemaphoreCreateBinary(); Button_TimerSemaphore = xSemaphoreCreateBinary();
@ -123,37 +121,34 @@ void Button_Init()
} }
// If timer-semaphore is set, read buttons (unless controls are locked) // If timer-semaphore is set, read buttons (unless controls are locked)
void Button_Cyclic()
{
if (xSemaphoreTake(Button_TimerSemaphore, 0) == pdTRUE)
{
if (System_AreControlsLocked())
{
void Button_Cyclic() {
if (xSemaphoreTake(Button_TimerSemaphore, 0) == pdTRUE) {
if (System_AreControlsLocked()) {
return; return;
} }
unsigned long currentTimestamp = millis(); unsigned long currentTimestamp = millis();
// Buttons can be mixed between GPIO and port-expander.
// But at the same time only one of them can be for example NEXT_BUTTON
#if defined(BUTTON_0_ENABLE) || defined(EXPANDER_0_ENABLE)
gButtons[0].currentState = Port_Read(NEXT_BUTTON);
#endif
#if defined(BUTTON_1_ENABLE) || defined(EXPANDER_1_ENABLE)
gButtons[1].currentState = Port_Read(PREVIOUS_BUTTON);
#endif
#if defined(BUTTON_2_ENABLE) || defined(EXPANDER_2_ENABLE)
gButtons[2].currentState = Port_Read(PAUSEPLAY_BUTTON);
#endif
#if defined(BUTTON_3_ENABLE) || defined(EXPANDER_3_ENABLE)
gButtons[3].currentState = Port_Read(DREHENCODER_BUTTON);
#endif
#if defined(BUTTON_4_ENABLE) || defined(EXPANDER_4_ENABLE)
gButtons[4].currentState = Port_Read(BUTTON_4);
#endif
#if defined(BUTTON_5_ENABLE) || defined(EXPANDER_5_ENABLE)
gButtons[5].currentState = Port_Read(BUTTON_5);
#endif
// Buttons can be mixed between GPIO and port-expander.
// But at the same time only one of them can be for example NEXT_BUTTON
#if defined(BUTTON_0_ENABLE) || defined(EXPANDER_0_ENABLE)
gButtons[0].currentState = Port_Read(NEXT_BUTTON);
#endif
#if defined(BUTTON_1_ENABLE) || defined(EXPANDER_1_ENABLE)
gButtons[1].currentState = Port_Read(PREVIOUS_BUTTON);
#endif
#if defined(BUTTON_2_ENABLE) || defined(EXPANDER_2_ENABLE)
gButtons[2].currentState = Port_Read(PAUSEPLAY_BUTTON);
#endif
#if defined(BUTTON_3_ENABLE) || defined(EXPANDER_3_ENABLE)
gButtons[3].currentState = Port_Read(DREHENCODER_BUTTON);
#endif
#if defined(BUTTON_4_ENABLE) || defined(EXPANDER_4_ENABLE)
gButtons[4].currentState = Port_Read(BUTTON_4);
#endif
#if defined(BUTTON_5_ENABLE) || defined(EXPANDER_5_ENABLE)
gButtons[5].currentState = Port_Read(BUTTON_5);
#endif
// Iterate over all buttons in struct-array // Iterate over all buttons in struct-array
for (uint8_t i = 0; i < sizeof(gButtons) / sizeof(gButtons[0]); i++) for (uint8_t i = 0; i < sizeof(gButtons) / sizeof(gButtons[0]); i++)
@ -180,172 +175,133 @@ void Button_Cyclic()
// Do corresponding actions for all buttons // Do corresponding actions for all buttons
void Button_DoButtonActions(void) void Button_DoButtonActions(void)
{ {
if (gButtons[0].isPressed && gButtons[1].isPressed)
{
if (gButtons[0].isPressed && gButtons[1].isPressed) {
gButtons[0].isPressed = false; gButtons[0].isPressed = false;
gButtons[1].isPressed = false; gButtons[1].isPressed = false;
Cmd_Action(BUTTON_MULTI_01); Cmd_Action(BUTTON_MULTI_01);
}
else if (gButtons[0].isPressed && gButtons[2].isPressed)
{
} else if (gButtons[0].isPressed && gButtons[2].isPressed) {
gButtons[0].isPressed = false; gButtons[0].isPressed = false;
gButtons[2].isPressed = false; gButtons[2].isPressed = false;
Cmd_Action(BUTTON_MULTI_02); Cmd_Action(BUTTON_MULTI_02);
}
else if (gButtons[0].isPressed && gButtons[3].isPressed)
{
} else if (gButtons[0].isPressed && gButtons[3].isPressed) {
gButtons[0].isPressed = false; gButtons[0].isPressed = false;
gButtons[3].isPressed = false; gButtons[3].isPressed = false;
Cmd_Action(BUTTON_MULTI_03); Cmd_Action(BUTTON_MULTI_03);
}
else if (gButtons[0].isPressed && gButtons[4].isPressed)
{
} else if (gButtons[0].isPressed && gButtons[4].isPressed) {
gButtons[0].isPressed = false; gButtons[0].isPressed = false;
gButtons[4].isPressed = false; gButtons[4].isPressed = false;
Cmd_Action(BUTTON_MULTI_04); Cmd_Action(BUTTON_MULTI_04);
}
else if (gButtons[0].isPressed && gButtons[5].isPressed)
{
} else if (gButtons[0].isPressed && gButtons[5].isPressed) {
gButtons[0].isPressed = false; gButtons[0].isPressed = false;
gButtons[5].isPressed = false; gButtons[5].isPressed = false;
Cmd_Action(BUTTON_MULTI_05); Cmd_Action(BUTTON_MULTI_05);
}
else if (gButtons[1].isPressed && gButtons[2].isPressed)
{
} else if (gButtons[1].isPressed && gButtons[2].isPressed) {
gButtons[1].isPressed = false; gButtons[1].isPressed = false;
gButtons[2].isPressed = false; gButtons[2].isPressed = false;
Cmd_Action(BUTTON_MULTI_12); Cmd_Action(BUTTON_MULTI_12);
}
else if (gButtons[1].isPressed && gButtons[3].isPressed)
{
} else if (gButtons[1].isPressed && gButtons[3].isPressed) {
gButtons[1].isPressed = false; gButtons[1].isPressed = false;
gButtons[3].isPressed = false; gButtons[3].isPressed = false;
Cmd_Action(BUTTON_MULTI_13); Cmd_Action(BUTTON_MULTI_13);
}
else if (gButtons[1].isPressed && gButtons[4].isPressed)
{
} else if (gButtons[1].isPressed && gButtons[4].isPressed) {
gButtons[1].isPressed = false; gButtons[1].isPressed = false;
gButtons[4].isPressed = false; gButtons[4].isPressed = false;
Cmd_Action(BUTTON_MULTI_14); Cmd_Action(BUTTON_MULTI_14);
}
else if (gButtons[1].isPressed && gButtons[5].isPressed)
{
} else if (gButtons[1].isPressed && gButtons[5].isPressed) {
gButtons[1].isPressed = false; gButtons[1].isPressed = false;
gButtons[5].isPressed = false; gButtons[5].isPressed = false;
Cmd_Action(BUTTON_MULTI_15); Cmd_Action(BUTTON_MULTI_15);
}
else if (gButtons[2].isPressed && gButtons[3].isPressed)
{
} else if (gButtons[2].isPressed && gButtons[3].isPressed) {
gButtons[2].isPressed = false; gButtons[2].isPressed = false;
gButtons[3].isPressed = false; gButtons[3].isPressed = false;
Cmd_Action(BUTTON_MULTI_23); Cmd_Action(BUTTON_MULTI_23);
}
else if (gButtons[2].isPressed && gButtons[4].isPressed)
{
} else if (gButtons[2].isPressed && gButtons[4].isPressed) {
gButtons[2].isPressed = false; gButtons[2].isPressed = false;
gButtons[4].isPressed = false; gButtons[4].isPressed = false;
Cmd_Action(BUTTON_MULTI_24); Cmd_Action(BUTTON_MULTI_24);
}
else if (gButtons[2].isPressed && gButtons[5].isPressed)
{
} else if (gButtons[2].isPressed && gButtons[5].isPressed) {
gButtons[2].isPressed = false; gButtons[2].isPressed = false;
gButtons[5].isPressed = false; gButtons[5].isPressed = false;
Cmd_Action(BUTTON_MULTI_25); Cmd_Action(BUTTON_MULTI_25);
}
else if (gButtons[3].isPressed && gButtons[4].isPressed)
{
} else if (gButtons[3].isPressed && gButtons[4].isPressed) {
gButtons[3].isPressed = false; gButtons[3].isPressed = false;
gButtons[4].isPressed = false; gButtons[4].isPressed = false;
Cmd_Action(BUTTON_MULTI_34); Cmd_Action(BUTTON_MULTI_34);
}
else if (gButtons[3].isPressed && gButtons[5].isPressed)
{
} else if (gButtons[3].isPressed && gButtons[5].isPressed) {
gButtons[3].isPressed = false; gButtons[3].isPressed = false;
gButtons[5].isPressed = false; gButtons[5].isPressed = false;
Cmd_Action(BUTTON_MULTI_35); Cmd_Action(BUTTON_MULTI_35);
}
else if (gButtons[4].isPressed && gButtons[5].isPressed)
{
} else if (gButtons[4].isPressed && gButtons[5].isPressed) {
gButtons[4].isPressed = false; gButtons[4].isPressed = false;
gButtons[5].isPressed = false; gButtons[5].isPressed = false;
Cmd_Action(BUTTON_MULTI_45); Cmd_Action(BUTTON_MULTI_45);
}
else
{
for (uint8_t i = 0; i < sizeof(gButtons) / sizeof(gButtons[0]); i++)
{
if (gButtons[i].isPressed)
{
if (gButtons[i].lastReleasedTimestamp > gButtons[i].lastPressedTimestamp)
{
if (gButtons[i].lastReleasedTimestamp - gButtons[i].lastPressedTimestamp >= intervalToLongPress)
{
switch (i) // Long-press-actions
{
case 0:
Cmd_Action(BUTTON_0_LONG);
gButtons[i].isPressed = false;
break;
} else {
for (uint8_t i = 0; i < sizeof(gButtons) / sizeof(gButtons[0]); i++) {
if (gButtons[i].isPressed) {
if (gButtons[i].lastReleasedTimestamp > gButtons[i].lastPressedTimestamp) {
if (gButtons[i].lastReleasedTimestamp - gButtons[i].lastPressedTimestamp >= intervalToLongPress) {
switch (i) { // Long-press-actions
case 0:
Cmd_Action(BUTTON_0_LONG);
gButtons[i].isPressed = false;
break;
case 1:
Cmd_Action(BUTTON_1_LONG);
gButtons[i].isPressed = false;
break;
case 1:
Cmd_Action(BUTTON_1_LONG);
gButtons[i].isPressed = false;
break;
case 2:
Cmd_Action(BUTTON_2_LONG);
gButtons[i].isPressed = false;
break;
case 2:
Cmd_Action(BUTTON_2_LONG);
gButtons[i].isPressed = false;
break;
case 3:
Cmd_Action(BUTTON_3_LONG);
gButtons[i].isPressed = false;
break;
case 3:
Cmd_Action(BUTTON_3_LONG);
gButtons[i].isPressed = false;
break;
case 4:
Cmd_Action(BUTTON_4_LONG);
gButtons[i].isPressed = false;
break;
case 4:
Cmd_Action(BUTTON_4_LONG);
gButtons[i].isPressed = false;
break;
case 5:
Cmd_Action(BUTTON_5_LONG);
gButtons[i].isPressed = false;
break;
case 5:
Cmd_Action(BUTTON_5_LONG);
gButtons[i].isPressed = false;
break;
} }
}
else
{
switch (i) // Short-press-actions
{
case 0:
Cmd_Action(BUTTON_0_SHORT);
gButtons[i].isPressed = false;
break;
} else {
switch (i) { // Short-press-actions
case 0:
Cmd_Action(BUTTON_0_SHORT);
gButtons[i].isPressed = false;
break;
case 1:
Cmd_Action(BUTTON_1_SHORT);
gButtons[i].isPressed = false;
break;
case 1:
Cmd_Action(BUTTON_1_SHORT);
gButtons[i].isPressed = false;
break;
case 2:
Cmd_Action(BUTTON_2_SHORT);
gButtons[i].isPressed = false;
break;
case 2:
Cmd_Action(BUTTON_2_SHORT);
gButtons[i].isPressed = false;
break;
case 3:
Cmd_Action(BUTTON_3_SHORT);
gButtons[i].isPressed = false;
break;
case 3:
Cmd_Action(BUTTON_3_SHORT);
gButtons[i].isPressed = false;
break;
case 4:
Cmd_Action(BUTTON_4_SHORT);
gButtons[i].isPressed = false;
break;
case 4:
Cmd_Action(BUTTON_4_SHORT);
gButtons[i].isPressed = false;
break;
case 5:
Cmd_Action(BUTTON_5_SHORT);
gButtons[i].isPressed = false;
break;
case 5:
Cmd_Action(BUTTON_5_SHORT);
gButtons[i].isPressed = false;
break;
} }
} }
} }
@ -354,7 +310,6 @@ void Button_DoButtonActions(void)
} }
} }
void IRAM_ATTR onTimer()
{
void IRAM_ATTR onTimer() {
xSemaphoreGiveFromISR(Button_TimerSemaphore, NULL); xSemaphoreGiveFromISR(Button_TimerSemaphore, NULL);
} }

618
src/Cmd.cpp

@ -10,372 +10,328 @@
#include "System.h" #include "System.h"
#include "Wlan.h" #include "Wlan.h"
void Cmd_Action(const uint16_t mod)
{
switch (mod)
{
case LOCK_BUTTONS_MOD:
{ // Locks/unlocks all buttons
System_ToggleLockControls();
break;
}
void Cmd_Action(const uint16_t mod) {
switch (mod) {
case LOCK_BUTTONS_MOD: { // Locks/unlocks all buttons
System_ToggleLockControls();
break;
}
case SLEEP_TIMER_MOD_15:
{ // Enables/disables sleep after 15 minutes
System_SetSleepTimer(15u);
case SLEEP_TIMER_MOD_15: { // Enables/disables sleep after 15 minutes
System_SetSleepTimer(15u);
gPlayProperties.sleepAfterCurrentTrack = false; // deactivate/overwrite if already active
gPlayProperties.sleepAfterPlaylist = false; // deactivate/overwrite if already active
gPlayProperties.playUntilTrackNumber = 0;
System_IndicateOk();
break;
}
gPlayProperties.sleepAfterCurrentTrack = false; // deactivate/overwrite if already active
gPlayProperties.sleepAfterPlaylist = false; // deactivate/overwrite if already active
gPlayProperties.playUntilTrackNumber = 0;
System_IndicateOk();
break;
}
case SLEEP_TIMER_MOD_30:
{ // Enables/disables sleep after 30 minutes
System_SetSleepTimer(30u);
case SLEEP_TIMER_MOD_30: { // Enables/disables sleep after 30 minutes
System_SetSleepTimer(30u);
gPlayProperties.sleepAfterCurrentTrack = false; // deactivate/overwrite if already active
gPlayProperties.sleepAfterPlaylist = false; // deactivate/overwrite if already active
gPlayProperties.playUntilTrackNumber = 0;
System_IndicateOk();
break;
}
gPlayProperties.sleepAfterCurrentTrack = false; // deactivate/overwrite if already active
gPlayProperties.sleepAfterPlaylist = false; // deactivate/overwrite if already active
gPlayProperties.playUntilTrackNumber = 0;
System_IndicateOk();
break;
}
case SLEEP_TIMER_MOD_60:
{ // Enables/disables sleep after 60 minutes
System_SetSleepTimer(60u);
case SLEEP_TIMER_MOD_60: { // Enables/disables sleep after 60 minutes
System_SetSleepTimer(60u);
gPlayProperties.sleepAfterCurrentTrack = false; // deactivate/overwrite if already active
gPlayProperties.sleepAfterPlaylist = false; // deactivate/overwrite if already active
gPlayProperties.playUntilTrackNumber = 0;
System_IndicateOk();
break;
}
gPlayProperties.sleepAfterCurrentTrack = false; // deactivate/overwrite if already active
gPlayProperties.sleepAfterPlaylist = false; // deactivate/overwrite if already active
gPlayProperties.playUntilTrackNumber = 0;
System_IndicateOk();
break;
}
case SLEEP_TIMER_MOD_120:
{ // Enables/disables sleep after 2 hrs
System_SetSleepTimer(120u);
case SLEEP_TIMER_MOD_120: { // Enables/disables sleep after 2 hrs
System_SetSleepTimer(120u);
gPlayProperties.sleepAfterCurrentTrack = false; // deactivate/overwrite if already active
gPlayProperties.sleepAfterPlaylist = false; // deactivate/overwrite if already active
gPlayProperties.playUntilTrackNumber = 0;
System_IndicateOk();
break;
}
gPlayProperties.sleepAfterCurrentTrack = false; // deactivate/overwrite if already active
gPlayProperties.sleepAfterPlaylist = false; // deactivate/overwrite if already active
gPlayProperties.playUntilTrackNumber = 0;
System_IndicateOk();
break;
}
case SLEEP_AFTER_END_OF_TRACK:
{ // Puts uC to sleep after end of current track
if (gPlayProperties.playMode == NO_PLAYLIST)
{
Log_Println((char *)FPSTR(modificatorNotallowedWhenIdle), LOGLEVEL_NOTICE);
System_IndicateError();
return;
case SLEEP_AFTER_END_OF_TRACK: { // Puts uC to sleep after end of current track
if (gPlayProperties.playMode == NO_PLAYLIST) {
Log_Println((char *) FPSTR(modificatorNotallowedWhenIdle), LOGLEVEL_NOTICE);
System_IndicateError();
return;
}
if (gPlayProperties.sleepAfterCurrentTrack) {
Log_Println((char *) FPSTR(modificatorSleepAtEOTd), LOGLEVEL_NOTICE);
#ifdef MQTT_ENABLE
publishMqtt((char *) FPSTR(topicSleepTimerState), "0", false);
#endif
#ifdef NEOPIXEL_ENABLE
Led_ResetToInitialBrightness();
#endif
}
else
{
Log_Println((char *) FPSTR(modificatorSleepAtEOT), LOGLEVEL_NOTICE);
#ifdef MQTT_ENABLE
publishMqtt((char *) FPSTR(topicSleepTimerState), "EOT", false);
#endif
#ifdef NEOPIXEL_ENABLE
Led_ResetToNightBrightness();
Log_Println((char *) FPSTR(ledsDimmedToNightmode), LOGLEVEL_INFO);
#endif
}
gPlayProperties.sleepAfterCurrentTrack = !gPlayProperties.sleepAfterCurrentTrack;
gPlayProperties.sleepAfterPlaylist = false;
System_DisableSleepTimer();
gPlayProperties.playUntilTrackNumber = 0;
#ifdef MQTT_ENABLE
publishMqtt((char *) FPSTR(topicLedBrightnessState), Led_GetBrightness(), false);
#endif
System_IndicateOk();
break;
} }
if (gPlayProperties.sleepAfterCurrentTrack)
{
Log_Println((char *)FPSTR(modificatorSleepAtEOTd), LOGLEVEL_NOTICE);
#ifdef MQTT_ENABLE
publishMqtt((char *)FPSTR(topicSleepTimerState), "0", false);
#endif
#ifdef NEOPIXEL_ENABLE
Led_ResetToInitialBrightness();
#endif
case SLEEP_AFTER_END_OF_PLAYLIST: { // Puts uC to sleep after end of whole playlist (can take a while :->)
if (gPlayProperties.playMode == NO_PLAYLIST) {
Log_Println((char *) FPSTR(modificatorNotallowedWhenIdle), LOGLEVEL_NOTICE);
System_IndicateError();
return;
}
if (gPlayProperties.sleepAfterCurrentTrack) {
#ifdef MQTT_ENABLE
publishMqtt((char *) FPSTR(topicSleepTimerState), "0", false);
#endif
#ifdef NEOPIXEL_ENABLE
Led_ResetToInitialBrightness();
#endif
Log_Println((char *) FPSTR(modificatorSleepAtEOPd), LOGLEVEL_NOTICE);
} else {
#ifdef NEOPIXEL_ENABLE
Led_ResetToNightBrightness();
Log_Println((char *) FPSTR(ledsDimmedToNightmode), LOGLEVEL_INFO);
#endif
Log_Println((char *) FPSTR(modificatorSleepAtEOP), LOGLEVEL_NOTICE);
#ifdef MQTT_ENABLE
publishMqtt((char *) FPSTR(topicSleepTimerState), "EOP", false);
#endif
}
gPlayProperties.sleepAfterCurrentTrack = false;
gPlayProperties.sleepAfterPlaylist = !gPlayProperties.sleepAfterPlaylist;
System_DisableSleepTimer();
gPlayProperties.playUntilTrackNumber = 0;
#ifdef MQTT_ENABLE
publishMqtt((char *) FPSTR(topicLedBrightnessState), Led_GetBrightness(), false);
#endif
System_IndicateOk();
break;
} }
else
{
Log_Println((char *)FPSTR(modificatorSleepAtEOT), LOGLEVEL_NOTICE);
#ifdef MQTT_ENABLE
publishMqtt((char *)FPSTR(topicSleepTimerState), "EOT", false);
#endif
#ifdef NEOPIXEL_ENABLE
Led_ResetToNightBrightness();
Log_Println((char *)FPSTR(ledsDimmedToNightmode), LOGLEVEL_INFO);
#endif
case SLEEP_AFTER_5_TRACKS: {
if (gPlayProperties.playMode == NO_PLAYLIST) {
Log_Println((char *) FPSTR(modificatorNotallowedWhenIdle), LOGLEVEL_NOTICE);
System_IndicateError();
return;
}
gPlayProperties.sleepAfterCurrentTrack = false;
gPlayProperties.sleepAfterPlaylist = false;
System_DisableSleepTimer();
if (gPlayProperties.playUntilTrackNumber > 0) {
gPlayProperties.playUntilTrackNumber = 0;
#ifdef MQTT_ENABLE
publishMqtt((char *) FPSTR(topicSleepTimerState), "0", false);
#endif
#ifdef NEOPIXEL_ENABLE
Led_ResetToInitialBrightness();
#endif
Log_Println((char *) FPSTR(modificatorSleepd), LOGLEVEL_NOTICE);
} else {
if (gPlayProperties.currentTrackNumber + 5 > gPlayProperties.numberOfTracks) { // If currentTrack + 5 exceeds number of tracks in playlist, sleep after end of playlist
gPlayProperties.sleepAfterPlaylist = true;
#ifdef MQTT_ENABLE
publishMqtt((char *) FPSTR(topicSleepTimerState), "EOP", false);
#endif
} else {
gPlayProperties.playUntilTrackNumber = gPlayProperties.currentTrackNumber + 5;
#ifdef MQTT_ENABLE
publishMqtt((char *) FPSTR(topicSleepTimerState), "EO5T", false);
#endif
}
#ifdef NEOPIXEL_ENABLE
Led_ResetToNightBrightness();
#endif
Log_Println((char *) FPSTR(sleepTimerEO5), LOGLEVEL_NOTICE);
}
#ifdef MQTT_ENABLE
publishMqtt((char *) FPSTR(topicLedBrightnessState), Led_GetBrightness(), false);
#endif
System_IndicateOk();
break;
} }
gPlayProperties.sleepAfterCurrentTrack = !gPlayProperties.sleepAfterCurrentTrack;
gPlayProperties.sleepAfterPlaylist = false;
System_DisableSleepTimer();
gPlayProperties.playUntilTrackNumber = 0;
#ifdef MQTT_ENABLE
publishMqtt((char *)FPSTR(topicLedBrightnessState), Led_GetBrightness(), false);
#endif
System_IndicateOk();
break;
}
case SLEEP_AFTER_END_OF_PLAYLIST:
{ // Puts uC to sleep after end of whole playlist (can take a while :->)
if (gPlayProperties.playMode == NO_PLAYLIST)
{
Log_Println((char *)FPSTR(modificatorNotallowedWhenIdle), LOGLEVEL_NOTICE);
System_IndicateError();
return;
case REPEAT_PLAYLIST: {
if (gPlayProperties.playMode == NO_PLAYLIST) {
Log_Println((char *) FPSTR(modificatorNotallowedWhenIdle), LOGLEVEL_NOTICE);
System_IndicateError();
} else {
if (gPlayProperties.repeatPlaylist) {
Log_Println((char *) FPSTR(modificatorPlaylistLoopDeactive), LOGLEVEL_NOTICE);
} else {
Log_Println((char *) FPSTR(modificatorPlaylistLoopActive), LOGLEVEL_NOTICE);
}
gPlayProperties.repeatPlaylist = !gPlayProperties.repeatPlaylist;
char rBuf[2];
snprintf(rBuf, 2, "%u", AudioPlayer_GetRepeatMode());
#ifdef MQTT_ENABLE
publishMqtt((char *) FPSTR(topicRepeatModeState), rBuf, false);
#endif
System_IndicateOk();
}
break;
} }
if (gPlayProperties.sleepAfterCurrentTrack)
{
#ifdef MQTT_ENABLE
publishMqtt((char *)FPSTR(topicSleepTimerState), "0", false);
#endif
#ifdef NEOPIXEL_ENABLE
Led_ResetToInitialBrightness();
#endif
Log_Println((char *)FPSTR(modificatorSleepAtEOPd), LOGLEVEL_NOTICE);
case REPEAT_TRACK: { // Introduces looping for track-mode
if (gPlayProperties.playMode == NO_PLAYLIST) {
Log_Println((char *) FPSTR(modificatorNotallowedWhenIdle), LOGLEVEL_NOTICE);
System_IndicateError();
} else {
if (gPlayProperties.repeatCurrentTrack) {
Log_Println((char *) FPSTR(modificatorTrackDeactive), LOGLEVEL_NOTICE);
} else {
Log_Println((char *) FPSTR(modificatorTrackActive), LOGLEVEL_NOTICE);
}
gPlayProperties.repeatCurrentTrack = !gPlayProperties.repeatCurrentTrack;
char rBuf[2];
snprintf(rBuf, 2, "%u", AudioPlayer_GetRepeatMode());
#ifdef MQTT_ENABLE
publishMqtt((char *) FPSTR(topicRepeatModeState), rBuf, false);
#endif
System_IndicateOk();
}
break;
} }
else
{
#ifdef NEOPIXEL_ENABLE
Led_ResetToNightBrightness();
Log_Println((char *)FPSTR(ledsDimmedToNightmode), LOGLEVEL_INFO);
#endif
Log_Println((char *)FPSTR(modificatorSleepAtEOP), LOGLEVEL_NOTICE);
#ifdef MQTT_ENABLE
publishMqtt((char *)FPSTR(topicSleepTimerState), "EOP", false);
#endif
case DIMM_LEDS_NIGHTMODE: {
#ifdef MQTT_ENABLE
publishMqtt((char *) FPSTR(topicLedBrightnessState), Led_GetBrightness(), false);
#endif
Log_Println((char *) FPSTR(ledsDimmedToNightmode), LOGLEVEL_INFO);
#ifdef NEOPIXEL_ENABLE
Led_ResetToNightBrightness();
#endif
System_IndicateOk();
break;
} }
gPlayProperties.sleepAfterCurrentTrack = false;
gPlayProperties.sleepAfterPlaylist = !gPlayProperties.sleepAfterPlaylist;
System_DisableSleepTimer();
gPlayProperties.playUntilTrackNumber = 0;
#ifdef MQTT_ENABLE
publishMqtt((char *)FPSTR(topicLedBrightnessState), Led_GetBrightness(), false);
#endif
System_IndicateOk();
break;
}
case TOGGLE_WIFI_STATUS: {
Wlan_ToggleEnable();
System_IndicateOk();
break;
}
case SLEEP_AFTER_5_TRACKS:
{
if (gPlayProperties.playMode == NO_PLAYLIST)
{
Log_Println((char *)FPSTR(modificatorNotallowedWhenIdle), LOGLEVEL_NOTICE);
System_IndicateError();
return;
#ifdef BLUETOOTH_ENABLE
case TOGGLE_BLUETOOTH_MODE: {
if (System_GetOperationModeFromNvs() == OPMODE_NORMAL) {
System_IndicateOk();
System_SetOperationMode(OPMODE_BLUETOOTH);
} else if (System_GetOperationModeFromNvs() == OPMODE_BLUETOOTH) {
System_IndicateOk();
System_SetOperationMode(OPMODE_NORMAL);
} else {
System_IndicateError();
}
break;
}
#endif
#ifdef FTP_ENABLE
case ENABLE_FTP_SERVER: {
Ftp_EnableServer();
break;
}
#endif
case CMD_PLAYPAUSE: {
AudioPlayer_TrackControlToQueueSender(PAUSEPLAY);
break;
} }
gPlayProperties.sleepAfterCurrentTrack = false;
gPlayProperties.sleepAfterPlaylist = false;
System_DisableSleepTimer();
case CMD_PREVTRACK: {
AudioPlayer_TrackControlToQueueSender(PREVIOUSTRACK);
break;
}
if (gPlayProperties.playUntilTrackNumber > 0)
{
gPlayProperties.playUntilTrackNumber = 0;
#ifdef MQTT_ENABLE
publishMqtt((char *)FPSTR(topicSleepTimerState), "0", false);
#endif
#ifdef NEOPIXEL_ENABLE
Led_ResetToInitialBrightness();
#endif
Log_Println((char *)FPSTR(modificatorSleepd), LOGLEVEL_NOTICE);
case CMD_NEXTTRACK: {
AudioPlayer_TrackControlToQueueSender(NEXTTRACK);
break;
} }
else
{
if (gPlayProperties.currentTrackNumber + 5 > gPlayProperties.numberOfTracks)
{ // If currentTrack + 5 exceeds number of tracks in playlist, sleep after end of playlist
gPlayProperties.sleepAfterPlaylist = true;
#ifdef MQTT_ENABLE
publishMqtt((char *)FPSTR(topicSleepTimerState), "EOP", false);
#endif
}
else
{
gPlayProperties.playUntilTrackNumber = gPlayProperties.currentTrackNumber + 5;
#ifdef MQTT_ENABLE
publishMqtt((char *)FPSTR(topicSleepTimerState), "EO5T", false);
#endif
}
#ifdef NEOPIXEL_ENABLE
Led_ResetToNightBrightness();
#endif
Log_Println((char *)FPSTR(sleepTimerEO5), LOGLEVEL_NOTICE);
case CMD_FIRSTTRACK: {
AudioPlayer_TrackControlToQueueSender(FIRSTTRACK);
break;
} }
#ifdef MQTT_ENABLE
publishMqtt((char *)FPSTR(topicLedBrightnessState), Led_GetBrightness(), false);
#endif
System_IndicateOk();
break;
}
case CMD_LASTTRACK: {
AudioPlayer_TrackControlToQueueSender(LASTTRACK);
break;
}
case REPEAT_PLAYLIST:
{
if (gPlayProperties.playMode == NO_PLAYLIST)
{
Log_Println((char *)FPSTR(modificatorNotallowedWhenIdle), LOGLEVEL_NOTICE);
System_IndicateError();
case CMD_VOLUMEINIT: {
AudioPlayer_VolumeToQueueSender(AudioPlayer_GetInitVolume(), true);
break;
} }
else
{
if (gPlayProperties.repeatPlaylist)
{
Log_Println((char *)FPSTR(modificatorPlaylistLoopDeactive), LOGLEVEL_NOTICE);
}
else
{
Log_Println((char *)FPSTR(modificatorPlaylistLoopActive), LOGLEVEL_NOTICE);
}
gPlayProperties.repeatPlaylist = !gPlayProperties.repeatPlaylist;
char rBuf[2];
snprintf(rBuf, 2, "%u", AudioPlayer_GetRepeatMode());
#ifdef MQTT_ENABLE
publishMqtt((char *)FPSTR(topicRepeatModeState), rBuf, false);
#endif
System_IndicateOk();
case CMD_VOLUMEUP: {
AudioPlayer_VolumeToQueueSender(AudioPlayer_GetCurrentVolume() + 1, true);
break;
} }
break;
}
case REPEAT_TRACK:
{ // Introduces looping for track-mode
if (gPlayProperties.playMode == NO_PLAYLIST)
{
Log_Println((char *)FPSTR(modificatorNotallowedWhenIdle), LOGLEVEL_NOTICE);
System_IndicateError();
case CMD_VOLUMEDOWN:{
AudioPlayer_VolumeToQueueSender(AudioPlayer_GetCurrentVolume() - 1, true);
break;
} }
else
{
if (gPlayProperties.repeatCurrentTrack)
{
Log_Println((char *)FPSTR(modificatorTrackDeactive), LOGLEVEL_NOTICE);
}
else
{
Log_Println((char *)FPSTR(modificatorTrackActive), LOGLEVEL_NOTICE);
}
gPlayProperties.repeatCurrentTrack = !gPlayProperties.repeatCurrentTrack;
char rBuf[2];
snprintf(rBuf, 2, "%u", AudioPlayer_GetRepeatMode());
#ifdef MQTT_ENABLE
publishMqtt((char *)FPSTR(topicRepeatModeState), rBuf, false);
#endif
System_IndicateOk();
case CMD_MEASUREBATTERY: {
#ifdef MEASURE_BATTERY_VOLTAGE
float voltage = Battery_GetVoltage();
snprintf(Log_Buffer, Log_BufferLength, "%s: %.2f V", (char *) FPSTR(currentVoltageMsg), voltage);
Log_Println(Log_Buffer, LOGLEVEL_INFO);
Led_Indicate(LedIndicatorType::Voltage);
#ifdef MQTT_ENABLE
char vstr[6];
snprintf(vstr, 6, "%.2f", voltage);
publishMqtt((char *) FPSTR(topicBatteryVoltage), vstr, false);
#endif
#endif
break;
} }
break;
}
case DIMM_LEDS_NIGHTMODE:
{
#ifdef MQTT_ENABLE
publishMqtt((char *)FPSTR(topicLedBrightnessState), Led_GetBrightness(), false);
#endif
Log_Println((char *)FPSTR(ledsDimmedToNightmode), LOGLEVEL_INFO);
#ifdef NEOPIXEL_ENABLE
Led_ResetToNightBrightness();
#endif
System_IndicateOk();
break;
}
case CMD_SLEEPMODE: {
System_RequestSleep();
break;
}
case TOGGLE_WIFI_STATUS:
{
Wlan_ToggleEnable();
System_IndicateOk();
break;
}
#ifdef BLUETOOTH_ENABLE
case TOGGLE_BLUETOOTH_MODE:
{
if (System_GetOperationModeFromNvs() == OPMODE_NORMAL)
{
System_IndicateOk();
System_SetOperationMode(OPMODE_BLUETOOTH);
case CMD_SEEK_FORWARDS: {
gPlayProperties.seekmode = SEEK_FORWARDS;
break;
} }
else if (System_GetOperationModeFromNvs() == OPMODE_BLUETOOTH)
{
System_IndicateOk();
System_SetOperationMode(OPMODE_NORMAL);
case CMD_SEEK_BACKWARDS: {
gPlayProperties.seekmode = SEEK_BACKWARDS;
break;
} }
else
{
default: {
snprintf(Log_Buffer, Log_BufferLength, "%s %d !", (char *) FPSTR(modificatorDoesNotExist), mod);
Log_Println(Log_Buffer, LOGLEVEL_ERROR);
System_IndicateError(); System_IndicateError();
} }
break;
}
#endif
#ifdef FTP_ENABLE
case ENABLE_FTP_SERVER:
{
Ftp_EnableServer();
break;
}
#endif
case CMD_PLAYPAUSE:
{
AudioPlayer_TrackControlToQueueSender(PAUSEPLAY);
break;
}
case CMD_PREVTRACK:
{
AudioPlayer_TrackControlToQueueSender(PREVIOUSTRACK);
break;
}
case CMD_NEXTTRACK:
{
AudioPlayer_TrackControlToQueueSender(NEXTTRACK);
break;
}
case CMD_FIRSTTRACK:
{
AudioPlayer_TrackControlToQueueSender(FIRSTTRACK);
break;
}
case CMD_LASTTRACK:
{
AudioPlayer_TrackControlToQueueSender(LASTTRACK);
break;
}
case CMD_VOLUMEINIT:
{
AudioPlayer_VolumeToQueueSender(AudioPlayer_GetInitVolume(), true);
break;
}
case CMD_VOLUMEUP:
{
AudioPlayer_VolumeToQueueSender(AudioPlayer_GetCurrentVolume() + 1, true);
break;
}
case CMD_VOLUMEDOWN:
{
AudioPlayer_VolumeToQueueSender(AudioPlayer_GetCurrentVolume() - 1, true);
break;
}
case CMD_MEASUREBATTERY:
{
#ifdef MEASURE_BATTERY_VOLTAGE
float voltage = Battery_GetVoltage();
snprintf(Log_Buffer, Log_BufferLength, "%s: %.2f V", (char *)FPSTR(currentVoltageMsg), voltage);
Log_Println(Log_Buffer, LOGLEVEL_INFO);
Led_Indicate(LedIndicatorType::Voltage);
#ifdef MQTT_ENABLE
char vstr[6];
snprintf(vstr, 6, "%.2f", voltage);
publishMqtt((char *)FPSTR(topicBatteryVoltage), vstr, false);
#endif
#endif
break;
}
case CMD_SLEEPMODE:
{
System_RequestSleep();
break;
}
case CMD_SEEK_FORWARDS:
{
gPlayProperties.seekmode = SEEK_FORWARDS;
break;
}
case CMD_SEEK_BACKWARDS:
{
gPlayProperties.seekmode = SEEK_BACKWARDS;
break;
}
default:
{
snprintf(Log_Buffer, Log_BufferLength, "%s %d !", (char *)FPSTR(modificatorDoesNotExist), mod);
Log_Println(Log_Buffer, LOGLEVEL_ERROR);
System_IndicateError();
}
} }
} }

174
src/Common.h

@ -10,30 +10,23 @@ inline bool isNumber(const char *str)
{ {
byte i = 0; byte i = 0;
while (*(str + i) != '\0')
{
if (!isdigit(*(str + i++)))
{
while (*(str + i) != '\0') {
if (!isdigit(*(str + i++))) {
return false; return false;
} }
} }
if (i > 0)
{
if (i > 0) {
return true; return true;
}
else
{
} else{
return false; return false;
} }
} }
// Checks if string starts with prefix // Checks if string starts with prefix
// Returns true if so // Returns true if so
inline bool startsWith(const char *str, const char *pre)
{
if (strlen(pre) < 1)
{
inline bool startsWith(const char *str, const char *pre) {
if (strlen(pre) < 1) {
return false; return false;
} }
@ -42,68 +35,58 @@ inline bool startsWith(const char *str, const char *pre)
// Checks if string ends with suffix // Checks if string ends with suffix
// Returns true if so // Returns true if so
inline bool endsWith(const char *str, const char *suf)
{
inline bool endsWith(const char *str, const char *suf) {
const char *a = str + strlen(str); const char *a = str + strlen(str);
const char *b = suf + strlen(suf); const char *b = suf + strlen(suf);
while (a != str && b != suf)
{
if (*--a != *--b)
while (a != str && b != suf) {
if (*--a != *--b) {
break; break;
}
} }
return b == suf && *a == *b; return b == suf && *a == *b;
} }
inline void convertUtf8ToAscii(String utf8String, char *asciiString)
{
inline void convertUtf8ToAscii(String utf8String, char *asciiString) {
int k = 0; int k = 0;
bool f_C3_seen = false; bool f_C3_seen = false;
for (int i = 0; i < utf8String.length() && k < MAX_FILEPATH_LENTGH - 1; i++)
{
for (int i = 0; i < utf8String.length() && k < MAX_FILEPATH_LENTGH - 1; i++) {
if (utf8String[i] == 195)
{ // C3
if (utf8String[i] == 195) { // C3
f_C3_seen = true; f_C3_seen = true;
continue; continue;
}
else
{
if (f_C3_seen == true)
{
} else {
if (f_C3_seen == true) {
f_C3_seen = false; f_C3_seen = false;
switch (utf8String[i])
{
case 0x84:
asciiString[k++] = 0x8e;
break; // Ä
case 0xa4:
asciiString[k++] = 0x84;
break; // ä
case 0x9c:
asciiString[k++] = 0x9a;
break; // Ü
case 0xbc:
asciiString[k++] = 0x81;
break; // ü
case 0x96:
asciiString[k++] = 0x99;
break; // Ö
case 0xb6:
asciiString[k++] = 0x94;
break; // ö
case 0x9f:
asciiString[k++] = 0xe1;
break; // ß
default:
asciiString[k++] = 0xdb; // Unknow...
switch (utf8String[i]) {
case 0x84:
asciiString[k++] = 0x8e;
break; // Ä
case 0xa4:
asciiString[k++] = 0x84;
break; // ä
case 0x9c:
asciiString[k++] = 0x9a;
break; // Ü
case 0xbc:
asciiString[k++] = 0x81;
break; // ü
case 0x96:
asciiString[k++] = 0x99;
break; // Ö
case 0xb6:
asciiString[k++] = 0x94;
break; // ö
case 0x9f:
asciiString[k++] = 0xe1;
break; // ß
default:
asciiString[k++] = 0xdb; // Unknown...
} }
}
else
{
} else {
asciiString[k++] = utf8String[i]; asciiString[k++] = utf8String[i];
} }
} }
@ -112,46 +95,43 @@ inline void convertUtf8ToAscii(String utf8String, char *asciiString)
asciiString[k] = 0; asciiString[k] = 0;
} }
inline void convertAsciiToUtf8(String asciiString, char *utf8String)
{
inline void convertAsciiToUtf8(String asciiString, char *utf8String) {
int k = 0; int k = 0;
for (int i = 0; i < asciiString.length() && k < MAX_FILEPATH_LENTGH - 2; i++)
{
switch (asciiString[i])
{
case 0x8e:
utf8String[k++] = 0xc3;
utf8String[k++] = 0x84;
break; // Ä
case 0x84:
utf8String[k++] = 0xc3;
utf8String[k++] = 0xa4;
break; // ä
case 0x9a:
utf8String[k++] = 0xc3;
utf8String[k++] = 0x9c;
break; // Ü
case 0x81:
utf8String[k++] = 0xc3;
utf8String[k++] = 0xbc;
break; // ü
case 0x99:
utf8String[k++] = 0xc3;
utf8String[k++] = 0x96;
break; // Ö
case 0x94:
utf8String[k++] = 0xc3;
utf8String[k++] = 0xb6;
break; // ö
case 0xe1:
utf8String[k++] = 0xc3;
utf8String[k++] = 0x9f;
break; // ß
default:
utf8String[k++] = asciiString[i];
for (int i = 0; i < asciiString.length() && k < MAX_FILEPATH_LENTGH - 2; i++) {
switch (asciiString[i]) {
case 0x8e:
utf8String[k++] = 0xc3;
utf8String[k++] = 0x84;
break; // Ä
case 0x84:
utf8String[k++] = 0xc3;
utf8String[k++] = 0xa4;
break; // ä
case 0x9a:
utf8String[k++] = 0xc3;
utf8String[k++] = 0x9c;
break; // Ü
case 0x81:
utf8String[k++] = 0xc3;
utf8String[k++] = 0xbc;
break; // ü
case 0x99:
utf8String[k++] = 0xc3;
utf8String[k++] = 0x96;
break; // Ö
case 0x94:
utf8String[k++] = 0xc3;
utf8String[k++] = 0xb6;
break; // ö
case 0xe1:
utf8String[k++] = 0xc3;
utf8String[k++] = 0x9f;
break; // ß
default:
utf8String[k++] = asciiString[i];
} }
} }
@ -159,10 +139,8 @@ inline void convertAsciiToUtf8(String asciiString, char *utf8String)
} }
// Release previously allocated memory // Release previously allocated memory
inline void freeMultiCharArray(char **arr, const uint32_t cnt)
{
for (uint32_t i = 0; i <= cnt; i++)
{
inline void freeMultiCharArray(char **arr, const uint32_t cnt) {
for (uint32_t i = 0; i <= cnt; i++) {
/*snprintf(Log_Buffer, Log_BufferLength, "%s: %s", (char *) FPSTR(freePtr), *(arr+i)); /*snprintf(Log_Buffer, Log_BufferLength, "%s: %s", (char *) FPSTR(freePtr), *(arr+i));
Log_Println(Log_Buffer, LOGLEVEL_DEBUG);*/ Log_Println(Log_Buffer, LOGLEVEL_DEBUG);*/
free(*(arr + i)); free(*(arr + i));

108
src/Ftp.cpp

@ -9,12 +9,12 @@
#include "Wlan.h" #include "Wlan.h"
#ifdef FTP_ENABLE #ifdef FTP_ENABLE
#include "ESP32FtpServer.h"
#include "ESP32FtpServer.h"
#endif #endif
// FTP // FTP
char *Ftp_User = x_strndup((char *)"esp32", ftpUserLength); // FTP-user (default; can be changed later via GUI)
char *Ftp_Password = x_strndup((char *)"esp32", ftpPasswordLength); // FTP-password (default; can be changed later via GUI)
char *Ftp_User = x_strndup((char *) "esp32", ftpUserLength); // FTP-user (default; can be changed later via GUI)
char *Ftp_Password = x_strndup((char *) "esp32", ftpPasswordLength); // FTP-password (default; can be changed later via GUI)
// FTP // FTP
#ifdef FTP_ENABLE #ifdef FTP_ENABLE
@ -25,92 +25,74 @@ bool ftpEnableCurrentStatus = false;
void ftpManager(void); void ftpManager(void);
void Ftp_Init(void)
{
void Ftp_Init(void) {
// Get FTP-user from NVS // Get FTP-user from NVS
String nvsFtpUser = gPrefsSettings.getString("ftpuser", "-1"); String nvsFtpUser = gPrefsSettings.getString("ftpuser", "-1");
if (!nvsFtpUser.compareTo("-1"))
{
if (!nvsFtpUser.compareTo("-1")) {
gPrefsSettings.putString("ftpuser", (String)Ftp_User); gPrefsSettings.putString("ftpuser", (String)Ftp_User);
Log_Println((char *)FPSTR(wroteFtpUserToNvs), LOGLEVEL_ERROR);
}
else
{
Log_Println((char *) FPSTR(wroteFtpUserToNvs), LOGLEVEL_ERROR);
} else {
strncpy(Ftp_User, nvsFtpUser.c_str(), ftpUserLength); strncpy(Ftp_User, nvsFtpUser.c_str(), ftpUserLength);
snprintf(Log_Buffer, Log_BufferLength, "%s: %s", (char *)FPSTR(restoredFtpUserFromNvs), nvsFtpUser.c_str());
snprintf(Log_Buffer, Log_BufferLength, "%s: %s", (char *) FPSTR(restoredFtpUserFromNvs), nvsFtpUser.c_str());
Log_Println(Log_Buffer, LOGLEVEL_INFO); Log_Println(Log_Buffer, LOGLEVEL_INFO);
} }
// Get FTP-password from NVS // Get FTP-password from NVS
String nvsFtpPassword = gPrefsSettings.getString("ftppassword", "-1"); String nvsFtpPassword = gPrefsSettings.getString("ftppassword", "-1");
if (!nvsFtpPassword.compareTo("-1"))
{
if (!nvsFtpPassword.compareTo("-1")) {
gPrefsSettings.putString("ftppassword", (String)Ftp_Password); gPrefsSettings.putString("ftppassword", (String)Ftp_Password);
Log_Println((char *)FPSTR(wroteFtpPwdToNvs), LOGLEVEL_ERROR);
}
else
{
Log_Println((char *) FPSTR(wroteFtpPwdToNvs), LOGLEVEL_ERROR);
} else {
strncpy(Ftp_Password, nvsFtpPassword.c_str(), ftpPasswordLength); strncpy(Ftp_Password, nvsFtpPassword.c_str(), ftpPasswordLength);
snprintf(Log_Buffer, Log_BufferLength, "%s: %s", (char *)FPSTR(restoredFtpPwdFromNvs), nvsFtpPassword.c_str());
snprintf(Log_Buffer, Log_BufferLength, "%s: %s", (char *) FPSTR(restoredFtpPwdFromNvs), nvsFtpPassword.c_str());
Log_Println(Log_Buffer, LOGLEVEL_INFO); Log_Println(Log_Buffer, LOGLEVEL_INFO);
} }
} }
void Ftp_Cyclic(void)
{
#ifdef FTP_ENABLE
ftpManager();
void Ftp_Cyclic(void) {
#ifdef FTP_ENABLE
ftpManager();
if (WL_CONNECTED == WiFi.status())
{
if (ftpEnableLastStatus && ftpEnableCurrentStatus)
{
ftpSrv->handleFTP();
if (WL_CONNECTED == WiFi.status()) {
if (ftpEnableLastStatus && ftpEnableCurrentStatus) {
ftpSrv->handleFTP();
}
} }
}
if (ftpEnableLastStatus && ftpEnableCurrentStatus)
{
if (ftpSrv->isConnected())
{
System_UpdateActivityTimer(); // Re-adjust timer while client is connected to avoid ESP falling asleep
if (ftpEnableLastStatus && ftpEnableCurrentStatus) {
if (ftpSrv->isConnected()) {
System_UpdateActivityTimer(); // Re-adjust timer while client is connected to avoid ESP falling asleep
}
} }
}
#endif
#endif
} }
void Ftp_EnableServer(void)
{
if (Wlan_IsConnected() && !ftpEnableLastStatus && !ftpEnableCurrentStatus)
{
void Ftp_EnableServer(void) {
if (Wlan_IsConnected() && !ftpEnableLastStatus && !ftpEnableCurrentStatus) {
ftpEnableLastStatus = true; ftpEnableLastStatus = true;
System_IndicateOk(); System_IndicateOk();
}
else
{
Log_Println((char *)FPSTR(unableToStartFtpServer), LOGLEVEL_ERROR);
} else {
Log_Println((char *) FPSTR(unableToStartFtpServer), LOGLEVEL_ERROR);
System_IndicateError(); System_IndicateError();
} }
} }
// Creates FTP-instance only when requested // Creates FTP-instance only when requested
void ftpManager(void)
{
#ifdef FTP_ENABLE
if (ftpEnableLastStatus && !ftpEnableCurrentStatus)
{
snprintf(Log_Buffer, Log_BufferLength, "%s: %u", (char *)FPSTR(freeHeapWithoutFtp), ESP.getFreeHeap());
Log_Println(Log_Buffer, LOGLEVEL_DEBUG);
ftpEnableCurrentStatus = true;
ftpSrv = new FtpServer();
ftpSrv->begin(gFSystem, Ftp_User, Ftp_Password);
snprintf(Log_Buffer, Log_BufferLength, "%s: %u", (char *)FPSTR(freeHeapWithFtp), ESP.getFreeHeap());
Log_Println(Log_Buffer, LOGLEVEL_DEBUG);
#if (LANGUAGE == 1)
Serial.println(F("FTP-Server gestartet"));
#else
Serial.println(F("FTP-server started"));
#endif
}
#endif
void ftpManager(void) {
#ifdef FTP_ENABLE
if (ftpEnableLastStatus && !ftpEnableCurrentStatus) {
snprintf(Log_Buffer, Log_BufferLength, "%s: %u", (char *) FPSTR(freeHeapWithoutFtp), ESP.getFreeHeap());
Log_Println(Log_Buffer, LOGLEVEL_DEBUG);
ftpEnableCurrentStatus = true;
ftpSrv = new FtpServer();
ftpSrv->begin(gFSystem, Ftp_User, Ftp_Password);
snprintf(Log_Buffer, Log_BufferLength, "%s: %u", (char *) FPSTR(freeHeapWithFtp), ESP.getFreeHeap());
Log_Println(Log_Buffer, LOGLEVEL_DEBUG);
#if (LANGUAGE == 1)
Serial.println(F("FTP-Server gestartet"));
#else
Serial.println(F("FTP-server started"));
#endif
}
#endif
} }

64
src/HTMLaccesspoint.h

@ -0,0 +1,64 @@
static const char accesspoint_HTML[] PROGMEM = "<!DOCTYPE html>\
<html>\
<head>\
<title>WLAN-Einrichtung</title>\
<style>\
input {\
width: 90%%;\
height: 44px;\
border-radius: 4px;\
margin: 10px auto;\
font-size: 15px;\
background: #f1f1f1;\
border: 0;\
padding: 0 15px\
}\
input {\
\
}\
body {\
background: #007bff;\
font-family: sans-serif;\
font-size: 14px;\
color: #777\
}\
.box {\
background: #fff;\
max-width: 258px;\
margin: 75px auto;\
padding: 30px;\
border-radius: 5px;\
text-align: center\
}\
.btn {\
background: #3498db;\
color: #fff;\
cursor: pointer;\
width: 90%%;\
height: 44px;\
border-radius: 4px;\
margin: 10px auto;\
font-size: 15px;\
}\
.rebootmsg {\
display: none;\
}\
</style>\
</head>\
<body>\
<form id=\"settings\" action=\"/init\" class=\"box\" method=\"POST\">\
<h1>WLAN-Einrichtung</h1>\
<label for=\"ssid\">SSID:</label><br>\
<input type=\"text\" id=\"ssid\" name=\"ssid\" placeholder=\"SSID\" required><br>\
<label for=\"pwd\">Passwort:</label><br>\
<input type=\"password\" id=\"pwd\" name=\"pwd\" autocomplete=\"off\" required><br>\
<label for=\"hostname\">ESPuino-Name (Hostname):</label><br>\
<input type=\"text\" id=\"hostname\" name=\"hostname\" placeholder=\"espuino\" required><br><br>\
<input class=\"btn\" type=\"submit\" id=\"save-button\" value=\"Save\">\
</form>\
<form action=\"/restart\" class=\"box\">\
<h1>Fertig?</h1>\
<input class=\"btn\" type=\"submit\" id=\"restart-button\" value=\"Reboot\">\
</form>\
</body>\
</html>";

130
src/HTMLaccesspoint_DE.h

@ -1,68 +1,64 @@
#if (LANGUAGE == 1)
static const char accesspoint_HTML[] PROGMEM = "<!DOCTYPE html>\ static const char accesspoint_HTML[] PROGMEM = "<!DOCTYPE html>\
<html>\
<head>\
<title>WLAN-Einrichtung</title>\
<style>\
input {\
width: 90%%;\
height: 44px;\
border-radius: 4px;\
margin: 10px auto;\
font-size: 15px;\
background: #f1f1f1;\
border: 0;\
padding: 0 15px\
}\
input {\
\
}\
body {\
background: #007bff;\
font-family: sans-serif;\
font-size: 14px;\
color: #777\
}\
.box {\
background: #fff;\
max-width: 258px;\
margin: 75px auto;\
padding: 30px;\
border-radius: 5px;\
text-align: center\
}\
.btn {\
background: #3498db;\
color: #fff;\
cursor: pointer;\
width: 90%%;\
height: 44px;\
border-radius: 4px;\
margin: 10px auto;\
font-size: 15px;\
}\
.rebootmsg {\
display: none;\
}\
</style>\
</head>\
<body>\
<form id=\"settings\" action=\"/init\" class=\"box\" method=\"POST\">\
<h1>WLAN-Einrichtung</h1>\
<label for=\"ssid\">SSID:</label><br>\
<input type=\"text\" id=\"ssid\" name=\"ssid\" placeholder=\"SSID\" required><br>\
<label for=\"pwd\">Passwort:</label><br>\
<input type=\"password\" id=\"pwd\" name=\"pwd\" autocomplete=\"off\" required><br>\
<label for=\"hostname\">ESPuino-Name (Hostname):</label><br>\
<input type=\"text\" id=\"hostname\" name=\"hostname\" placeholder=\"espuino\" required><br><br>\
<input class=\"btn\" type=\"submit\" id=\"save-button\" value=\"Save\">\
</form>\
<form action=\"/restart\" class=\"box\">\
<h1>Fertig?</h1>\
<input class=\"btn\" type=\"submit\" id=\"restart-button\" value=\"Reboot\">\
</form>\
</body>\
</html>";
#endif
<html>\
<head>\
<title>WLAN-Einrichtung</title>\
<style>\
input {\
width: 90%%;\
height: 44px;\
border-radius: 4px;\
margin: 10px auto;\
font-size: 15px;\
background: #f1f1f1;\
border: 0;\
padding: 0 15px\
}\
input {\
\
}\
body {\
background: #007bff;\
font-family: sans-serif;\
font-size: 14px;\
color: #777\
}\
.box {\
background: #fff;\
max-width: 258px;\
margin: 75px auto;\
padding: 30px;\
border-radius: 5px;\
text-align: center\
}\
.btn {\
background: #3498db;\
color: #fff;\
cursor: pointer;\
width: 90%%;\
height: 44px;\
border-radius: 4px;\
margin: 10px auto;\
font-size: 15px;\
}\
.rebootmsg {\
display: none;\
}\
</style>\
</head>\
<body>\
<form id=\"settings\" action=\"/init\" class=\"box\" method=\"POST\">\
<h1>WLAN-Einrichtung</h1>\
<label for=\"ssid\">SSID:</label><br>\
<input type=\"text\" id=\"ssid\" name=\"ssid\" placeholder=\"SSID\" required><br>\
<label for=\"pwd\">Passwort:</label><br>\
<input type=\"password\" id=\"pwd\" name=\"pwd\" autocomplete=\"off\" required><br>\
<label for=\"hostname\">ESPuino-Name (Hostname):</label><br>\
<input type=\"text\" id=\"hostname\" name=\"hostname\" placeholder=\"espuino\" required><br><br>\
<input class=\"btn\" type=\"submit\" id=\"save-button\" value=\"Save\">\
</form>\
<form action=\"/restart\" class=\"box\">\
<h1>Fertig?</h1>\
<input class=\"btn\" type=\"submit\" id=\"restart-button\" value=\"Reboot\">\
</form>\
</body>\
</html>";

4
src/HTMLaccesspoint_EN.h

@ -1,5 +1,3 @@
#if (LANGUAGE == 2)
static const char accesspoint_HTML[] PROGMEM = "<!DOCTYPE html>\ static const char accesspoint_HTML[] PROGMEM = "<!DOCTYPE html>\
<html>\ <html>\
<head>\ <head>\
@ -64,5 +62,3 @@ static const char accesspoint_HTML[] PROGMEM = "<!DOCTYPE html>\
</form>\ </form>\
</body>\ </body>\
</html>"; </html>";
#endif

1111
src/HTMLmanagement.h
File diff suppressed because it is too large
View File

726
src/HTMLmanagement_DE.h

@ -1,5 +1,3 @@
#if (LANGUAGE == 1)
static const char management_HTML[] PROGMEM = "<!DOCTYPE html>\ static const char management_HTML[] PROGMEM = "<!DOCTYPE html>\
<html lang=\"de\">\ <html lang=\"de\">\
<head>\ <head>\
@ -47,7 +45,7 @@ static const char management_HTML[] PROGMEM = "<!DOCTYPE html>\
.icon-pos{\ .icon-pos{\
top: 0.3em;\ top: 0.3em;\
position: relative;\ position: relative;\
}\
}\
.reboot{\ .reboot{\
color:white;\ color:white;\
}\ }\
@ -133,7 +131,7 @@ static const char management_HTML[] PROGMEM = "<!DOCTYPE html>\
<div class=\"col-md-12\">\ <div class=\"col-md-12\">\
<a class=\"float-left navbar-brand\">\ <a class=\"float-left navbar-brand\">\
<img src=\"https://www.espuino.de/espuino/Espuino32.png\"\ <img src=\"https://www.espuino.de/espuino/Espuino32.png\"\
width=\"35\" height=\"35\" class=\"d-inline-block align-top\" alt=\"\"/>\
width=\"35\" height=\"35\" class=\"d-inline-block align-top\" alt=\"\"/>\
ESPuino\ ESPuino\
</a>\ </a>\
<a class=\"reboot float-right nav-link\" href=\"/restart\"><i class=\"fas fa-redo\"></i> Neustart</a>\ <a class=\"reboot float-right nav-link\" href=\"/restart\"><i class=\"fas fa-redo\"></i> Neustart</a>\
@ -169,7 +167,7 @@ static const char management_HTML[] PROGMEM = "<!DOCTYPE html>\
<input type=\"password\" class=\"form-control\" id=\"pwd\" placeholder=\"Passwort\" name=\"pwd\" required>\ <input type=\"password\" class=\"form-control\" id=\"pwd\" placeholder=\"Passwort\" name=\"pwd\" required>\
<label for=\"hostname\">ESPuino-Name (Hostname):</label>\ <label for=\"hostname\">ESPuino-Name (Hostname):</label>\
<input type=\"text\" class=\"form-control\" id=\"hostname\" placeholder=\"espuino\" name=\"hostname\"\ <input type=\"text\" class=\"form-control\" id=\"hostname\" placeholder=\"espuino\" name=\"hostname\"\
value=\"%HOSTNAME%\" pattern=\"^[^-\\.]{2,32}\" required>\
value=\"%HOSTNAME%\" pattern=\"^[^-\\.]{2,32}\" required>\
</div>\ </div>\
<br>\ <br>\
<div class=\"text-center\">\ <div class=\"text-center\">\
@ -214,12 +212,12 @@ static const char management_HTML[] PROGMEM = "<!DOCTYPE html>\
<div class=\"container\" id=\"filetreeContainer\">\ <div class=\"container\" id=\"filetreeContainer\">\
<fieldset>\ <fieldset>\
<legend>Dateien</legend>\ <legend>Dateien</legend>\
<div class=\"filetree-container\">\
<div id=\"filebrowser\">\
<div class=\"filetree demo\" id=\"explorerTree\"></div>\
</div>\
<div>\
<form id=\"explorerUploadForm\" method=\"POST\" enctype=\"multipart/form-data\" action=\"/explorer\">\
<div class=\"filetree-container\">\
<div id=\"filebrowser\">\
<div class=\"filetree demo\" id=\"explorerTree\"></div>\
</div>\
<div>\
<form id=\"explorerUploadForm\" method=\"POST\" enctype=\"multipart/form-data\" action=\"/explorer\">\
<div class=\"input-group\">\ <div class=\"input-group\">\
<span class=\"form-control\" id=\"uploaded_file_text\"></span>\ <span class=\"form-control\" id=\"uploaded_file_text\"></span>\
<span class=\"input-group-btn\">\ <span class=\"input-group-btn\">\
@ -235,7 +233,7 @@ static const char management_HTML[] PROGMEM = "<!DOCTYPE html>\
</div>\ </div>\
</div>\ </div>\
<br>\ <br>\
</div>\
</div>\
</fieldset>\ </fieldset>\
</div>\ </div>\
<div class=\"container\" id=\"rfidMusicTags\">\ <div class=\"container\" id=\"rfidMusicTags\">\
@ -245,7 +243,7 @@ static const char management_HTML[] PROGMEM = "<!DOCTYPE html>\
<div class=\"form-group col-md-12\">\ <div class=\"form-group col-md-12\">\
<label for=\"rfidIdMusic\">RFID-Chip-Nummer (12-stellig)</label>\ <label for=\"rfidIdMusic\">RFID-Chip-Nummer (12-stellig)</label>\
<input type=\"text\" class=\"form-control\" id=\"rfidIdMusic\" maxlength=\"12\" pattern=\"[0-9]{12}\"\ <input type=\"text\" class=\"form-control\" id=\"rfidIdMusic\" maxlength=\"12\" pattern=\"[0-9]{12}\"\
placeholder=\"%RFID_TAG_ID%\" name=\"rfidIdMusic\" required>\
placeholder=\"%RFID_TAG_ID%\" name=\"rfidIdMusic\" required>\
<br>\ <br>\
<ul class=\"nav nav-tabs\" id=\"SubTab\" role=\"tablist\">\ <ul class=\"nav nav-tabs\" id=\"SubTab\" role=\"tablist\">\
<li class=\"nav-item\">\ <li class=\"nav-item\">\
@ -311,7 +309,7 @@ static const char management_HTML[] PROGMEM = "<!DOCTYPE html>\
<div class=\"container\" id=\"mqttConfig\">\ <div class=\"container\" id=\"mqttConfig\">\
\ \
<form class=\"needs-validation\" action=\"#mqttConfig\" method=\"POST\"\ <form class=\"needs-validation\" action=\"#mqttConfig\" method=\"POST\"\
onsubmit=\"mqttSettings('mqttConfig'); return false\">\
onsubmit=\"mqttSettings('mqttConfig'); return false\">\
<div class=\"form-check col-md-12\">\ <div class=\"form-check col-md-12\">\
<legend>MQTT-Einstellungen</legend>\ <legend>MQTT-Einstellungen</legend>\
<input class=\"form-check-input\" type=\"checkbox\" value=\"1\" id=\"mqttEnable\" name=\"mqttEnable\" %MQTT_ENABLE%>\ <input class=\"form-check-input\" type=\"checkbox\" value=\"1\" id=\"mqttEnable\" name=\"mqttEnable\" %MQTT_ENABLE%>\
@ -322,13 +320,13 @@ static const char management_HTML[] PROGMEM = "<!DOCTYPE html>\
<div class=\"form-group my-2 col-md-12\">\ <div class=\"form-group my-2 col-md-12\">\
<label for=\"mqttServer\">MQTT-Server</label>\ <label for=\"mqttServer\">MQTT-Server</label>\
<input type=\"text\" class=\"form-control\" id=\"mqttServer\" minlength=\"7\" maxlength=\"%MQTT_SERVER_LENGTH%\"\ <input type=\"text\" class=\"form-control\" id=\"mqttServer\" minlength=\"7\" maxlength=\"%MQTT_SERVER_LENGTH%\"\
placeholder=\"z.B. 192.168.2.89\" name=\"mqttServer\" value=\"%MQTT_SERVER%\">\
placeholder=\"z.B. 192.168.2.89\" name=\"mqttServer\" value=\"%MQTT_SERVER%\">\
<label for=\"mqttUser\">MQTT-Benutzername (optional):</label>\ <label for=\"mqttUser\">MQTT-Benutzername (optional):</label>\
<input type=\"text\" class=\"form-control\" id=\"mqttUser\" maxlength=\"%MQTT_USER_LENGTH%\"\ <input type=\"text\" class=\"form-control\" id=\"mqttUser\" maxlength=\"%MQTT_USER_LENGTH%\"\
placeholder=\"Benutzername\" name=\"mqttUser\" value=\"%MQTT_USER%\">\
placeholder=\"Benutzername\" name=\"mqttUser\" value=\"%MQTT_USER%\">\
<label for=\"mqttPwd\">MQTT-Passwort (optional):</label>\ <label for=\"mqttPwd\">MQTT-Passwort (optional):</label>\
<input type=\"password\" class=\"form-control\" id=\"mqttPwd\" maxlength=\"%MQTT_PWD_LENGTH%\"\ <input type=\"password\" class=\"form-control\" id=\"mqttPwd\" maxlength=\"%MQTT_PWD_LENGTH%\"\
placeholder=\"Passwort\" name=\"mqttPwd\" value=\"%MQTT_PWD%\">\
placeholder=\"Passwort\" name=\"mqttPwd\" value=\"%MQTT_PWD%\">\
<label for=\"mqttPort\">MQTT-Port:</label>\ <label for=\"mqttPort\">MQTT-Port:</label>\
<input type=\"number\" class=\"form-control\" id=\"mqttPort\" min=\"1\" max=\"65535\"\ <input type=\"number\" class=\"form-control\" id=\"mqttPort\" min=\"1\" max=\"65535\"\
placeholder=\"Port\" name=\"mqttPort\" value=\"%MQTT_PORT%\" required>\ placeholder=\"Port\" name=\"mqttPort\" value=\"%MQTT_PORT%\" required>\
@ -349,10 +347,10 @@ static const char management_HTML[] PROGMEM = "<!DOCTYPE html>\
<legend>FTP-Einstellungen</legend>\ <legend>FTP-Einstellungen</legend>\
<label for=\"ftpUser\">FTP-Benutzername:</label>\ <label for=\"ftpUser\">FTP-Benutzername:</label>\
<input type=\"text\" class=\"form-control\" id=\"ftpUser\" maxlength=\"%FTP_USER_LENGTH%\"\ <input type=\"text\" class=\"form-control\" id=\"ftpUser\" maxlength=\"%FTP_USER_LENGTH%\"\
placeholder=\"Benutzername\" name=\"ftpUser\" value=\"%FTP_USER%\" required>\
placeholder=\"Benutzername\" name=\"ftpUser\" value=\"%FTP_USER%\" required>\
<label for=\"pwd\">FTP-Passwort:</label>\ <label for=\"pwd\">FTP-Passwort:</label>\
<input type=\"password\" class=\"form-control\" id=\"ftpPwd\" maxlength=\"%FTP_PWD_LENGTH%\" placeholder=\"Passwort\"\ <input type=\"password\" class=\"form-control\" id=\"ftpPwd\" maxlength=\"%FTP_PWD_LENGTH%\" placeholder=\"Passwort\"\
name=\"ftpPwd\" value=\"%FTP_PWD%\" required>\
name=\"ftpPwd\" value=\"%FTP_PWD%\" required>\
</div>\ </div>\
<br>\ <br>\
<div class=\"text-center\">\ <div class=\"text-center\">\
@ -377,14 +375,14 @@ static const char management_HTML[] PROGMEM = "<!DOCTYPE html>\
<br>\ <br>\
<label for=\"maxVolumeSpeaker\">Maximal (Lautsprecher)</label>\ <label for=\"maxVolumeSpeaker\">Maximal (Lautsprecher)</label>\
<div class=\"text-center\">\ <div class=\"text-center\">\
<i class=\"fas fa-volume-down fa-2x .icon-pos\"></i> <input data-provide=\"slider\" type=\"number\" data-slider-min=\"1\" data-slider-max=\"21\" min=\"1\" max=\"21\" class=\"form-control\" id=\"maxVolumeSpeaker\" name=\"maxVolumeSpeaker\"\
<i class=\"fas fa-volume-down fa-2x .icon-pos\"></i> <input data-provide=\"slider\" type=\"number\" data-slider-min=\"1\" data-slider-max=\"21\" min=\"1\" max=\"21\" class=\"form-control\" id=\"maxVolumeSpeaker\" name=\"maxVolumeSpeaker\"\
data-slider-value=\"%MAX_VOLUME_SPEAKER%\" value=\"%MAX_VOLUME_SPEAKER%\" required> <i class=\"fas fa-volume-up fa-2x .icon-pos\"></i>\ data-slider-value=\"%MAX_VOLUME_SPEAKER%\" value=\"%MAX_VOLUME_SPEAKER%\" required> <i class=\"fas fa-volume-up fa-2x .icon-pos\"></i>\
</div>\ </div>\
<br>\ <br>\
<label for=\"maxVolumeHeadphone\">Maximal (Kopfhörer)</label>\ <label for=\"maxVolumeHeadphone\">Maximal (Kopfhörer)</label>\
<div class=\"text-center\">\ <div class=\"text-center\">\
<i class=\"fas fa-volume-down fa-2x .icon-pos\"></i> <input data-provide=\"slider\" type=\"number\" data-slider-min=\"1\" data-slider-max=\"21\" min=\"1\" max=\"21\" class=\"form-control\" id=\"maxVolumeHeadphone\" name=\"maxVolumeHeadphone\"\ <i class=\"fas fa-volume-down fa-2x .icon-pos\"></i> <input data-provide=\"slider\" type=\"number\" data-slider-min=\"1\" data-slider-max=\"21\" min=\"1\" max=\"21\" class=\"form-control\" id=\"maxVolumeHeadphone\" name=\"maxVolumeHeadphone\"\
data-slider-value=\"%MAX_VOLUME_HEADPHONE%\" value=\"%MAX_VOLUME_HEADPHONE%\" required> <i class=\"fas fa-volume-up fa-2x .icon-pos\"></i>\
data-slider-value=\"%MAX_VOLUME_HEADPHONE%\" value=\"%MAX_VOLUME_HEADPHONE%\" required> <i class=\"fas fa-volume-up fa-2x .icon-pos\"></i>\
</div>\ </div>\
</fieldset>\ </fieldset>\
</div>\ </div>\
@ -396,7 +394,7 @@ static const char management_HTML[] PROGMEM = "<!DOCTYPE html>\
<div class=\"text-center\">\ <div class=\"text-center\">\
<i class=\"far fa-sun fa-2x .icon-pos\"></i>\ <i class=\"far fa-sun fa-2x .icon-pos\"></i>\
<input data-provide=\"slider\" type=\"number\" data-slider-min=\"0\" data-slider-max=\"255\" min=\"0\" max=\"255\" class=\"form-control\" id=\"initBrightness\" name=\"initBrightness\"\ <input data-provide=\"slider\" type=\"number\" data-slider-min=\"0\" data-slider-max=\"255\" min=\"0\" max=\"255\" class=\"form-control\" id=\"initBrightness\" name=\"initBrightness\"\
data-slider-value=\"%INIT_LED_BRIGHTNESS%\" value=\"%INIT_LED_BRIGHTNESS%\" required><i class=\"fas fa-sun fa-2x .icon-pos\"></i>\
data-slider-value=\"%INIT_LED_BRIGHTNESS%\" value=\"%INIT_LED_BRIGHTNESS%\" required><i class=\"fas fa-sun fa-2x .icon-pos\"></i>\
</div>\ </div>\
\ \
<label for=\"nightBrightness\">Im Nachtmodus</label>\ <label for=\"nightBrightness\">Im Nachtmodus</label>\
@ -412,7 +410,7 @@ static const char management_HTML[] PROGMEM = "<!DOCTYPE html>\
\ \
<label for=\"inactivityTime\">Inaktivität nach (in Minuten)</label>\ <label for=\"inactivityTime\">Inaktivität nach (in Minuten)</label>\
<div class=\"text-center\"><i class=\"fas fa-hourglass-start fa-2x .icon-pos\"></i> <input type=\"number\" data-provide=\"slider\" data-slider-min=\"0\" data-slider-max=\"30\" min=\"1\" max=\"120\" class=\"form-control\" id=\"inactivityTime\" name=\"inactivityTime\"\ <div class=\"text-center\"><i class=\"fas fa-hourglass-start fa-2x .icon-pos\"></i> <input type=\"number\" data-provide=\"slider\" data-slider-min=\"0\" data-slider-max=\"30\" min=\"1\" max=\"120\" class=\"form-control\" id=\"inactivityTime\" name=\"inactivityTime\"\
data-slider-value=\"%MAX_INACTIVITY%\" value=\"%MAX_INACTIVITY%\" required><i class=\"fas fa-hourglass-end fa-2x .icon-pos\"></i></div>\
data-slider-value=\"%MAX_INACTIVITY%\" value=\"%MAX_INACTIVITY%\" required><i class=\"fas fa-hourglass-end fa-2x .icon-pos\"></i></div>\
</fieldset>\ </fieldset>\
</div>\ </div>\
<br>\ <br>\
@ -433,21 +431,21 @@ static const char management_HTML[] PROGMEM = "<!DOCTYPE html>\
</label>\ </label>\
<div class=\"text-center\">\ <div class=\"text-center\">\
<i class=\"fas fa-battery-quarter fa-2x .icon-pos\"></i> <input data-provide=\"slider\" min=\"2.0\" data-slider-step=\"0.1\" data-slider-min=\"2.0\" data-slider-max=\"5.0\" max=\"5.0\" type=\"text\" class=\"form-control\" id=\"voltageIndicatorLow\" name=\"voltageIndicatorLow\"\ <i class=\"fas fa-battery-quarter fa-2x .icon-pos\"></i> <input data-provide=\"slider\" min=\"2.0\" data-slider-step=\"0.1\" data-slider-min=\"2.0\" data-slider-max=\"5.0\" max=\"5.0\" type=\"text\" class=\"form-control\" id=\"voltageIndicatorLow\" name=\"voltageIndicatorLow\"\
data-slider-value=\"%VOLTAGE_INDICATOR_LOW%\" value=\"%VOLTAGE_INDICATOR_LOW%\" pattern=\"^\\d{1,2}(\\.\\d{1,3})?\" required> <i class=\"fas fa-battery-three-quarters fa-2x .icon-pos\" fa-2x .icon-pos></i>\
data-slider-value=\"%VOLTAGE_INDICATOR_LOW%\" value=\"%VOLTAGE_INDICATOR_LOW%\" pattern=\"^\\d{1,2}(\\.\\d{1,3})?\" required> <i class=\"fas fa-battery-three-quarters fa-2x .icon-pos\" fa-2x .icon-pos></i>\
</div>\ </div>\
<br>\ <br>\
<label for=\"voltageIndicatorHigh\">Alle LEDs leuchten bei dieser Spannung</label>\ <label for=\"voltageIndicatorHigh\">Alle LEDs leuchten bei dieser Spannung</label>\
\ \
<div class=\"text-center\">\ <div class=\"text-center\">\
<i class=\"fas fa-battery-quarter fa-2x .icon-pos\"></i><input data-provide=\"slider\" data-slider-step=\"0.1\" data-slider-min=\"2.0\" data-slider-max=\"5.0\" min=\"2.0\" max=\"5.0\" type=\"text\" class=\"form-control\" id=\"voltageIndicatorHigh\" name=\"voltageIndicatorHigh\"\ <i class=\"fas fa-battery-quarter fa-2x .icon-pos\"></i><input data-provide=\"slider\" data-slider-step=\"0.1\" data-slider-min=\"2.0\" data-slider-max=\"5.0\" min=\"2.0\" max=\"5.0\" type=\"text\" class=\"form-control\" id=\"voltageIndicatorHigh\" name=\"voltageIndicatorHigh\"\
data-slider-value=\"%VOLTAGE_INDICATOR_HIGH%\" value=\"%VOLTAGE_INDICATOR_HIGH%\" pattern=\"^\\d{1,2}(\\.\\d{1,3})?\" required> <i class=\"fas fa-battery-three-quarters fa-2x .icon-pos\" fa-2x .icon-pos></i>\
data-slider-value=\"%VOLTAGE_INDICATOR_HIGH%\" value=\"%VOLTAGE_INDICATOR_HIGH%\" pattern=\"^\\d{1,2}(\\.\\d{1,3})?\" required> <i class=\"fas fa-battery-three-quarters fa-2x .icon-pos\" fa-2x .icon-pos></i>\
</div>\ </div>\
\ \
<br>\ <br>\
<label for=\"voltageCheckInterval\">Zeitabstand der Messung (in Minuten)</label>\ <label for=\"voltageCheckInterval\">Zeitabstand der Messung (in Minuten)</label>\
<div class=\"text-center\"><i class=\"fas fa-hourglass-start fa-2x .icon-pos\"></i>\ <div class=\"text-center\"><i class=\"fas fa-hourglass-start fa-2x .icon-pos\"></i>\
<input data-provide=\"slider\" data-slider-min=\"1\" data-slider-max=\"60\" type=\"number\" min=\"1\" max=\"60\" class=\"form-control\" id=\"voltageCheckInterval\"\ <input data-provide=\"slider\" data-slider-min=\"1\" data-slider-max=\"60\" type=\"number\" min=\"1\" max=\"60\" class=\"form-control\" id=\"voltageCheckInterval\"\
data-slider-value=\"%VOLTAGE_CHECK_INTERVAL%\" name=\"voltageCheckInterval\" value=\"%VOLTAGE_CHECK_INTERVAL%\" required><i class=\"fas fa-hourglass-end fa-2x .icon-pos\"></i>\
data-slider-value=\"%VOLTAGE_CHECK_INTERVAL%\" name=\"voltageCheckInterval\" value=\"%VOLTAGE_CHECK_INTERVAL%\" required><i class=\"fas fa-hourglass-end fa-2x .icon-pos\"></i>\
</div>\ </div>\
\ \
</fieldset>\ </fieldset>\
@ -577,353 +575,353 @@ static const char management_HTML[] PROGMEM = "<!DOCTYPE html>\
}\ }\
\ \
}\ }\
lastSelectedNodePath = data.node.data.path;\
lastSelectedNodePath = data.node.data.path;\
}\ }\
\ \
\ \
});\ });\
\ \
function doRest(path, callback, obj) {\
obj.url = path;\
obj.dataType = \"json\";\
obj.contentType= \"application/json;charset=IBM437\",\
function doRest(path, callback, obj) {\
obj.url = path;\
obj.dataType = \"json\";\
obj.contentType= \"application/json;charset=IBM437\",\
obj.scriptCharset= \"IBM437\",\ obj.scriptCharset= \"IBM437\",\
obj.success = function(data, textStatus, jqXHR) {\ obj.success = function(data, textStatus, jqXHR) {\
if (callback) {\
callback(data);\
}\
};\
obj.error = function(jqXHR, textStatus, errorThrown) {\
console.log(\"AJAX error\");\
/*debugger; */\
};\
jQuery.ajax(obj);\
} /* doRest */\
\
function getData(path, callback) {\
doRest(path, callback, {\
method : \"GET\"\
});\
} /* getData */\
\
function deleteData(path, callback, _data) {\
doRest(path, callback, {\
method : \"DELETE\",\
data: _data\
});\
} /* deleteData */\
\
function patchData(path, callback, _data) {\
doRest(path, callback, {\
method : \"PATCH\",\
data: _data\
});\
} /* patchData */\
\
function postData(path, callback, _data) {\
doRest(path, callback, {\
method : \"POST\",\
data: _data\
});\
} /* postData */\
\
\
function putData(path, callback, _data) {\
doRest(path, callback, {\
method : \"PUT\",\
data: _data\
});\
} /* putData */\
\
\
/* File Upload */\
$('#explorerUploadForm').submit(function(e){\
e.preventDefault();\
console.log(\"Upload!\");\
var data = new FormData(this);\
\
var ref = $('#explorerTree').jstree(true),\
sel = ref.get_selected(),\
path = \"/\";\
if (callback) {\
callback(data);\
}\
};\
obj.error = function(jqXHR, textStatus, errorThrown) {\
console.log(\"AJAX error\");\
/*debugger; */\
};\
jQuery.ajax(obj);\
} /* doRest */\
\
function getData(path, callback) {\
doRest(path, callback, {\
method : \"GET\"\
});\
} /* getData */\
\
function deleteData(path, callback, _data) {\
doRest(path, callback, {\
method : \"DELETE\",\
data: _data\
});\
} /* deleteData */\
\
function patchData(path, callback, _data) {\
doRest(path, callback, {\
method : \"PATCH\",\
data: _data\
});\
} /* patchData */\
\
function postData(path, callback, _data) {\
doRest(path, callback, {\
method : \"POST\",\
data: _data\
});\
} /* postData */\
\
\
function putData(path, callback, _data) {\
doRest(path, callback, {\
method : \"PUT\",\
data: _data\
});\
} /* putData */\
\
\
/* File Upload */\
$('#explorerUploadForm').submit(function(e){\
e.preventDefault();\
console.log(\"Upload!\");\
var data = new FormData(this);\
\
var ref = $('#explorerTree').jstree(true),\
sel = ref.get_selected(),\
path = \"/\";\
if(!sel.length) { alert(\"Please select the upload location!\");return false; }\ if(!sel.length) { alert(\"Please select the upload location!\");return false; }\
if(!document.getElementById('uploaded_file').files.length > 0) { alert(\"Please select files to upload!\");return false; }\ if(!document.getElementById('uploaded_file').files.length > 0) { alert(\"Please select files to upload!\");return false; }\
sel = sel[0];\
selectedNode = ref.get_node(sel);\
if(selectedNode.data.directory){\
path = selectedNode.data.path\
} else {\
/* remap sel to parent folder */\
sel = ref.get_node(ref.get_parent(sel));\
path = parentNode.data.path;\
console.log(\"Parent path: \" + path);\
}\
\
$.ajax({\
url: '/explorer?path=' + path,\
sel = sel[0];\
selectedNode = ref.get_node(sel);\
if(selectedNode.data.directory){\
path = selectedNode.data.path\
} else {\
/* remap sel to parent folder */\
sel = ref.get_node(ref.get_parent(sel));\
path = parentNode.data.path;\
console.log(\"Parent path: \" + path);\
}\
\
$.ajax({\
url: '/explorer?path=' + path,\
type: 'POST',\ type: 'POST',\
data: data,\ data: data,\
contentType: false,\ contentType: false,\
processData:false,\ processData:false,\
xhr: function() {\
var xhr = new window.XMLHttpRequest();\
xhr: function() {\
var xhr = new window.XMLHttpRequest();\
\ \
xhr.upload.addEventListener(\"progress\", function(evt) {\
if (evt.lengthComputable) {\
var percentComplete = evt.loaded / evt.total;\
percentComplete = parseInt(percentComplete * 100);\
xhr.upload.addEventListener(\"progress\", function(evt) {\
if (evt.lengthComputable) {\
var percentComplete = evt.loaded / evt.total;\
percentComplete = parseInt(percentComplete * 100);\
console.log(percentComplete);\ console.log(percentComplete);\
var percent = percentComplete + '%';\ var percent = percentComplete + '%';\
$(\"#explorerUploadProgress\").css('width', percent).text(percent);\ $(\"#explorerUploadProgress\").css('width', percent).text(percent);\
}\
}, false);\
}\
}, false);\
\ \
return xhr;\
},\
success: function(data, textStatus, jqXHR) {\
return xhr;\
},\
success: function(data, textStatus, jqXHR) {\
console.log(\"Upload success!\");\ console.log(\"Upload success!\");\
$(\"#explorerUploadProgress\").text(\"Upload success!\");\ $(\"#explorerUploadProgress\").text(\"Upload success!\");\
document.getElementById('uploaded_file').value = '';\ document.getElementById('uploaded_file').value = '';\
document.getElementById('uploaded_file_text').innerHTML = '';\ document.getElementById('uploaded_file_text').innerHTML = '';\
\ \
getData(\"/explorer?path=\" + path, function(data) {\
/* We now have data! */\
deleteChildrenNodes(sel);\
addFileDirectory(sel, data);\
ref.open_node(sel);\
getData(\"/explorer?path=\" + path, function(data) {\
/* We now have data! */\
deleteChildrenNodes(sel);\
addFileDirectory(sel, data);\
ref.open_node(sel);\
\
\
});\
\
}\
});\
});\
\
/* File Delete */\
function handleDeleteData(nodeId) {\
var ref = $('#explorerTree').jstree(true);\
var node = ref.get_node(nodeId);\
console.log(\"call delete request: \" + node.data.path);\
deleteData(\"/explorer?path=\" + node.data.path);\
}\
\
function fileNameSort( a, b ) {\
if ( a.dir && !b.dir ) {\
return -1\
}\
if ( !a.dir && b.dir ) {\
return 1\
}\
if ( a.name < b.name ){\
return -1;\
}\
if ( a.name > b.name ){\
return 1;\
}\
return 0;\
}\
\
function createChild(nodeId, data) {\
var ref = $('#explorerTree').jstree(true);\
var node = ref.get_node(nodeId);\
var parentNodePath = node.data.path;\
/* In case of root node remove leading '/' to avoid '//' */\
if(parentNodePath == \"/\"){\
parentNodePath = \"\";\
}\
var child = {\
text: data.name,\
type: getType(data),\
data: {\
path: parentNodePath + \"/\" + data.name,\
directory: data.dir\
}\
};\
\
return child;\
\
}\
\
function deleteChildrenNodes(nodeId) {\
var ref = $('#explorerTree').jstree(true);\
var children = $(\"#explorerTree\").jstree(\"get_children_dom\",nodeId);\
for(var i=0;i<children.length;i++)\
{\
ref.delete_node(children[i].id);\
}\
\
}\
\ \
function refreshNode(nodeId) {\
\ \
});\
var ref = $('#explorerTree').jstree(true);\
\
var node = ref.get_node(nodeId);\
\
getData(\"/explorer?path=\" + node.data.path, function(data) {\
/* We now have data! */\
\
deleteChildrenNodes(nodeId);\
addFileDirectory(nodeId, data);\
ref.open_node(nodeId);\
\ \
}\
});\ });\
});\
\
/* File Delete */\
function handleDeleteData(nodeId) {\
var ref = $('#explorerTree').jstree(true);\
var node = ref.get_node(nodeId);\
console.log(\"call delete request: \" + node.data.path);\
deleteData(\"/explorer?path=\" + node.data.path);\
}\
\
function fileNameSort( a, b ) {\
if ( a.dir && !b.dir ) {\
return -1\
}\
if ( !a.dir && b.dir ) {\
return 1\
}\
if ( a.name < b.name ){\
return -1;\
}\
if ( a.name > b.name ){\
return 1;\
}\
return 0;\
}\
\
function createChild(nodeId, data) {\
var ref = $('#explorerTree').jstree(true);\
var node = ref.get_node(nodeId);\
var parentNodePath = node.data.path;\
/* In case of root node remove leading '/' to avoid '//' */\
if(parentNodePath == \"/\"){\
parentNodePath = \"\";\
}\
var child = {\
text: data.name,\
type: getType(data),\
data: {\
path: parentNodePath + \"/\" + data.name,\
directory: data.dir\
}\
};\
\
return child;\
\
}\
\
function deleteChildrenNodes(nodeId) {\
var ref = $('#explorerTree').jstree(true);\
var children = $(\"#explorerTree\").jstree(\"get_children_dom\",nodeId);\
for(var i=0;i<children.length;i++)\
{\
ref.delete_node(children[i].id);\
}\
\
}\
\
function refreshNode(nodeId) {\
\
var ref = $('#explorerTree').jstree(true);\
\
var node = ref.get_node(nodeId);\
\
getData(\"/explorer?path=\" + node.data.path, function(data) {\
/* We now have data! */\
\
deleteChildrenNodes(nodeId);\
addFileDirectory(nodeId, data);\
ref.open_node(nodeId);\
\
});\
\
\
}\
\
function getType(data) {\
var type = \"\";\
\
if(data.dir) {\
type = \"folder\";\
} else if ((/\\.(mp3|MP3|ogg|wav|WAV|OGG|wma|WMA|acc|ACC|flac|FLAC)$/i).test(data.name)) {\
type = \"audio\";\
} else {\
type = \"file\";\
}\
\
return type;\
}\
\
\
function addFileDirectory(parent, data) {\
\
data.sort( fileNameSort );\
var ref = $('#explorerTree').jstree(true);\
\
for (var i=0; i<data.length; i++) {\
console.log(\"Create Node\");\
ref.create_node(parent, createChild(parent, data[i]));\
}\
} /* addFileDirectory */\
\
function buildFileSystemTree(path) {\
\
$('#explorerTree').jstree({\
\"core\" : {\
\"check_callback\" : true,\
'force_text' : true,\
\"themes\" : { \"stripes\" : true },\
'data' : { text: '/',\
state: {\
opened: true\
},\
type: 'folder',\
children: [],\
data: {\
path: '/',\
directory: true\
}}\
},\
'types': {\
'folder': {\
'icon': \"fa fa-folder\"\
},\
'file': {\
'icon': \"fa fa-file\"\
},\
'audio': {\
'icon': \"fa fa-file-audio\"\
},\
'default': {\
'icon': \"fa fa-folder\"\
}\
},\
plugins: [\"contextmenu\", \"themes\", \"types\"],\
contextmenu: {\
items: function(nodeId) {\
var ref = $('#explorerTree').jstree(true);\
var node = ref.get_node(nodeId);\
var items = {};\
\
\
if (node.data.directory) {\
items.createDir = {\
label: \"Neuer Ordner\",\
action: function(x) {\
var childNode = ref.create_node(nodeId, {text: \"Neuer Ordner\", type: \"folder\"});\
if(childNode) {\
ref.edit(childNode, null, function(childNode, status){\
putData(\"/explorer?path=\" + node.data.path + \"/\" + childNode.text);\
refreshNode(nodeId);\
});\
}\
}\
};\
}\
\
/* Play */\
items.play = {\
label: \"Abspielen\",\
action: function(x) {\
var playMode = node.data.directory?\"5\":\"1\";\
postData(\"/exploreraudio?path=\" + node.data.path + \"&playmode=\" + playMode);\
}\
};\
\
/* Refresh */\
items.refresh = {\
label: \"Aktualisieren\",\
action: function(x) {\
refreshNode(nodeId);\
}\
};\
\
/* Delete */\
items.delete = {\
label: \"Löschen\",\
action: function(x) {\
handleDeleteData(nodeId);\
refreshNode(ref.get_parent(nodeId));\
}\
};\
\
/* Rename */\
items.rename = {\
label: \"Umbenennen\",\
action: function(x) {\
var srcPath = node.data.path;\
ref.edit(nodeId, null, function(node, status){\
node.data.path = node.data.path.substring(0,node.data.path.lastIndexOf(\"/\")+1) + node.text;\
patchData(\"/explorer?srcpath=\" + srcPath + \"&dstpath=\" + node.data.path);\
refreshNode(ref.get_parent(nodeId));\
});\
}\
};\
\
return items;\
}\
}\
});\
\
if (path.length == 0) {\
return;\
}\
getData(\"/explorer?path=/\", function(data) {\
/* We now have data! */\
$('#explorerTree').jstree(true).settings.core.data.children = [];\
\
data.sort( fileNameSort );\
\
\
for (var i=0; i<data.length; i++) {\
var newChild = {\
text: data[i].name,\
type: getType(data[i]),\
data: {\
path: \"/\" + data[i].name,\
directory: data[i].dir\
},\
children: []\
};\
$('#explorerTree').jstree(true).settings.core.data.children.push(newChild);\
}\
\
$(\"#explorerTree\").jstree(true).refresh();\
\
\
});\
} /* buildFileSystemTree */\
\
\
}\
\
function getType(data) {\
var type = \"\";\
\
if(data.dir) {\
type = \"folder\";\
} else if ((/\\.(mp3|MP3|ogg|wav|WAV|OGG|wma|WMA|acc|ACC|flac|FLAC)$/i).test(data.name)) {\
type = \"audio\";\
} else {\
type = \"file\";\
}\
\
return type;\
}\
\
\
function addFileDirectory(parent, data) {\
\
data.sort( fileNameSort );\
var ref = $('#explorerTree').jstree(true);\
\
for (var i=0; i<data.length; i++) {\
console.log(\"Create Node\");\
ref.create_node(parent, createChild(parent, data[i]));\
}\
} /* addFileDirectory */\
\
function buildFileSystemTree(path) {\
\
$('#explorerTree').jstree({\
\"core\" : {\
\"check_callback\" : true,\
'force_text' : true,\
\"themes\" : { \"stripes\" : true },\
'data' : { text: '/',\
state: {\
opened: true\
},\
type: 'folder',\
children: [],\
data: {\
path: '/',\
directory: true\
}}\
},\
'types': {\
'folder': {\
'icon': \"fa fa-folder\"\
},\
'file': {\
'icon': \"fa fa-file\"\
},\
'audio': {\
'icon': \"fa fa-file-audio\"\
},\
'default': {\
'icon': \"fa fa-folder\"\
}\
},\
plugins: [\"contextmenu\", \"themes\", \"types\"],\
contextmenu: {\
items: function(nodeId) {\
var ref = $('#explorerTree').jstree(true);\
var node = ref.get_node(nodeId);\
var items = {};\
\
\
if (node.data.directory) {\
items.createDir = {\
label: \"Neuer Ordner\",\
action: function(x) {\
var childNode = ref.create_node(nodeId, {text: \"Neuer Ordner\", type: \"folder\"});\
if(childNode) {\
ref.edit(childNode, null, function(childNode, status){\
putData(\"/explorer?path=\" + node.data.path + \"/\" + childNode.text);\
refreshNode(nodeId);\
});\
}\
}\
};\
}\
\
/* Play */\
items.play = {\
label: \"Abspielen\",\
action: function(x) {\
var playMode = node.data.directory?\"5\":\"1\";\
postData(\"/exploreraudio?path=\" + node.data.path + \"&playmode=\" + playMode);\
}\
};\
\
/* Refresh */\
items.refresh = {\
label: \"Aktualisieren\",\
action: function(x) {\
refreshNode(nodeId);\
}\
};\
\
/* Delete */\
items.delete = {\
label: \"Löschen\",\
action: function(x) {\
handleDeleteData(nodeId);\
refreshNode(ref.get_parent(nodeId));\
}\
};\
\
/* Rename */\
items.rename = {\
label: \"Umbenennen\",\
action: function(x) {\
var srcPath = node.data.path;\
ref.edit(nodeId, null, function(node, status){\
node.data.path = node.data.path.substring(0,node.data.path.lastIndexOf(\"/\")+1) + node.text;\
patchData(\"/explorer?srcpath=\" + srcPath + \"&dstpath=\" + node.data.path);\
refreshNode(ref.get_parent(nodeId));\
});\
}\
};\
\
return items;\
}\
}\
});\
\
if (path.length == 0) {\
return;\
}\
getData(\"/explorer?path=/\", function(data) {\
/* We now have data! */\
$('#explorerTree').jstree(true).settings.core.data.children = [];\
\
data.sort( fileNameSort );\
\
\
for (var i=0; i<data.length; i++) {\
var newChild = {\
text: data[i].name,\
type: getType(data[i]),\
data: {\
path: \"/\" + data[i].name,\
directory: data[i].dir\
},\
children: []\
};\
$('#explorerTree').jstree(true).settings.core.data.children.push(newChild);\
}\
\
$(\"#explorerTree\").jstree(true).refresh();\
\
\
});\
} /* buildFileSystemTree */\
\ \
/* File Explorer functions end */\ /* File Explorer functions end */\
\ \
@ -950,22 +948,22 @@ static const char management_HTML[] PROGMEM = "<!DOCTYPE html>\
};\ };\
\ \
socket.onmessage = function(event) {\ socket.onmessage = function(event) {\
console.log(event.data);\
var socketMsg = JSON.parse(event.data);\
if (socketMsg.rfidId != null) {\
document.getElementById('rfidIdMusic').value = socketMsg.rfidId;\
toastr.info(\"RFID Tag mit \"+ socketMsg.rfidId + \" erkannt.\" );\
$(\"#rfidIdMusic\").effect(\"highlight\", {color:\"#abf5af\"}, 3000);\
} if (\"status\" in socketMsg) {\
if (socketMsg.status == \"ok\") {\
toastr.success(\"Aktion erfolgreich ausgeführt.\" );\
}\
} if (\"pong\" in socketMsg) {\
if (socketMsg.pong == 'pong') {\
pong();\
}\
}\
};\
console.log(event.data);\
var socketMsg = JSON.parse(event.data);\
if (socketMsg.rfidId != null) {\
document.getElementById('rfidIdMusic').value = socketMsg.rfidId;\
toastr.info(\"RFID Tag mit \"+ socketMsg.rfidId + \" erkannt.\" );\
$(\"#rfidIdMusic\").effect(\"highlight\", {color:\"#abf5af\"}, 3000);\
} if (\"status\" in socketMsg) {\
if (socketMsg.status == \"ok\") {\
toastr.success(\"Aktion erfolgreich ausgeführt.\" );\
}\
} if (\"pong\" in socketMsg) {\
if (socketMsg.pong == 'pong') {\
pong();\
}\
}\
};\
}\ }\
\ \
function ping() {\ function ping() {\
@ -1100,7 +1098,7 @@ static const char management_HTML[] PROGMEM = "<!DOCTYPE html>\
\ \
$(document).ready(function () {\ $(document).ready(function () {\
connect();\ connect();\
buildFileSystemTree(\"/\");\
buildFileSystemTree(\"/\");\
\ \
console.log(parseInt(document.getElementById('warningLowVoltage').value));\ console.log(parseInt(document.getElementById('warningLowVoltage').value));\
$(function () {\ $(function () {\
@ -1111,5 +1109,3 @@ static const char management_HTML[] PROGMEM = "<!DOCTYPE html>\
</script>\ </script>\
</body>\ </body>\
</html>"; </html>";
#endif

4
src/HTMLmanagement_EN.h

@ -1,5 +1,3 @@
#if (LANGUAGE == 2)
static const char management_HTML[] PROGMEM = "<!DOCTYPE html>\ static const char management_HTML[] PROGMEM = "<!DOCTYPE html>\
<html lang=\"de\">\ <html lang=\"de\">\
<head>\ <head>\
@ -1111,5 +1109,3 @@ static const char management_HTML[] PROGMEM = "<!DOCTYPE html>\
</script>\ </script>\
</body>\ </body>\
</html>"; </html>";
#endif

254
src/IrReceiver.cpp

@ -7,163 +7,131 @@
#include "System.h" #include "System.h"
#ifdef IR_CONTROL_ENABLE #ifdef IR_CONTROL_ENABLE
#include <IRremote.h>
#include <IRremote.h>
#endif #endif
// HW-Timer // HW-Timer
#ifdef IR_CONTROL_ENABLE #ifdef IR_CONTROL_ENABLE
uint32_t IrReceiver_LastRcCmdTimestamp = 0u;
uint32_t IrReceiver_LastRcCmdTimestamp = 0u;
#endif #endif
void IrReceiver_Init()
{
#ifdef IR_CONTROL_ENABLE
IrReceiver.begin(IRLED_PIN);
#endif
void IrReceiver_Init() {
#ifdef IR_CONTROL_ENABLE
IrReceiver.begin(IRLED_PIN);
#endif
} }
void IrReceiver_Cyclic()
{
#ifdef IR_CONTROL_ENABLE
static uint8_t lastVolume = 0;
void IrReceiver_Cyclic() {
#ifdef IR_CONTROL_ENABLE
static uint8_t lastVolume = 0;
if (IrReceiver.decode())
{
// Print a short summary of received data
IrReceiver.printIRResultShort(&Serial);
Serial.println();
IrReceiver.resume(); // Enable receiving of the next value
bool rcActionOk = false;
if (millis() - IrReceiver_LastRcCmdTimestamp >= IR_DEBOUNCE)
{
rcActionOk = true; // not used for volume up/down
IrReceiver_LastRcCmdTimestamp = millis();
}
if (IrReceiver.decode()){
switch (IrReceiver.decodedIRData.command)
{
case RC_PLAY:
{
if (rcActionOk)
{
Cmd_Action(CMD_PLAYPAUSE);
Serial.println(F("RC: Play"));
}
break;
}
case RC_PAUSE:
{
if (rcActionOk)
{
Cmd_Action(CMD_PLAYPAUSE);
Serial.println(F("RC: Pause"));
}
break;
}
case RC_NEXT:
{
if (rcActionOk)
{
Cmd_Action(CMD_NEXTTRACK);
Serial.println(F("RC: Next"));
}
break;
}
case RC_PREVIOUS:
{
if (rcActionOk)
{
Cmd_Action(CMD_PREVTRACK);
Serial.println(F("RC: Previous"));
}
break;
}
case RC_FIRST:
{
if (rcActionOk)
{
Cmd_Action(CMD_FIRSTTRACK);
Serial.println(F("RC: First"));
}
break;
}
case RC_LAST:
{
if (rcActionOk)
{
Cmd_Action(CMD_LASTTRACK);
Serial.println(F("RC: Last"));
// Print a short summary of received data
IrReceiver.printIRResultShort(&Serial);
Serial.println();
IrReceiver.resume(); // Enable receiving of the next value
bool rcActionOk = false;
if (millis() - IrReceiver_LastRcCmdTimestamp >= IR_DEBOUNCE) {
rcActionOk = true; // not used for volume up/down
IrReceiver_LastRcCmdTimestamp = millis();
} }
break;
}
case RC_MUTE:
{
if (rcActionOk)
{
if (AudioPlayer_GetCurrentVolume() > 0)
{
lastVolume = AudioPlayer_GetCurrentVolume();
AudioPlayer_SetCurrentVolume(0u);
switch (IrReceiver.decodedIRData.command) {
case RC_PLAY: {
if (rcActionOk) {
Cmd_Action(CMD_PLAYPAUSE);
Serial.println(F("RC: Play"));
}
break;
}
case RC_PAUSE: {
if (rcActionOk) {
Cmd_Action(CMD_PLAYPAUSE);
Serial.println(F("RC: Pause"));
}
break;
}
case RC_NEXT: {
if (rcActionOk) {
Cmd_Action(CMD_NEXTTRACK);
Serial.println(F("RC: Next"));
}
break;
}
case RC_PREVIOUS: {
if (rcActionOk) {
Cmd_Action(CMD_PREVTRACK);
Serial.println(F("RC: Previous"));
}
break;
} }
else
{
AudioPlayer_SetCurrentVolume(lastVolume); // Remember last volume if mute is pressed again
case RC_FIRST: {
if (rcActionOk) {
Cmd_Action(CMD_FIRSTTRACK);
Serial.println(F("RC: First"));
}
break;
} }
case RC_LAST: {
if (rcActionOk) {
Cmd_Action(CMD_LASTTRACK);
Serial.println(F("RC: Last"));
}
break;
}
case RC_MUTE: {
if (rcActionOk) {
if (AudioPlayer_GetCurrentVolume() > 0) {
lastVolume = AudioPlayer_GetCurrentVolume();
AudioPlayer_SetCurrentVolume(0u);
} else {
AudioPlayer_SetCurrentVolume(lastVolume); // Remember last volume if mute is pressed again
}
uint8_t currentVolume = AudioPlayer_GetCurrentVolume();
xQueueSend(gVolumeQueue, &currentVolume, 0);
Serial.println(F("RC: Mute"));
}
break;
}
case RC_BLUETOOTH:
{
if (rcActionOk)
{
Cmd_Action(TOGGLE_BLUETOOTH_MODE);
Serial.println(F("RC: Bluetooth"));
}
break;
}
case RC_FTP:
{
if (rcActionOk)
{
Cmd_Action(ENABLE_FTP_SERVER);
Serial.println(F("RC: FTP"));
}
break;
}
case RC_SHUTDOWN:
{
if (rcActionOk)
{
System_RequestSleep();
Serial.println(F("RC: Shutdown"));
}
break;
}
case RC_VOL_DOWN:
{
Cmd_Action(CMD_VOLUMEDOWN);
Serial.println(F("RC: Volume down"));
break;
}
case RC_VOL_UP:
{
Cmd_Action(CMD_VOLUMEUP);
Serial.println(F("RC: Volume up"));
break;
}
default:
{
if (rcActionOk)
{
Serial.println(F("RC: unknown"));
uint8_t currentVolume = AudioPlayer_GetCurrentVolume();
xQueueSend(gVolumeQueue, &currentVolume, 0);
Serial.println(F("RC: Mute"));
}
break;
}
case RC_BLUETOOTH: {
if (rcActionOk) {
Cmd_Action(TOGGLE_BLUETOOTH_MODE);
Serial.println(F("RC: Bluetooth"));
}
break;
}
case RC_FTP: {
if (rcActionOk) {
Cmd_Action(ENABLE_FTP_SERVER);
Serial.println(F("RC: FTP"));
}
break;
}
case RC_SHUTDOWN: {
if (rcActionOk) {
System_RequestSleep();
Serial.println(F("RC: Shutdown"));
}
break;
}
case RC_VOL_DOWN: {
Cmd_Action(CMD_VOLUMEDOWN);
Serial.println(F("RC: Volume down"));
break;
}
case RC_VOL_UP: {
Cmd_Action(CMD_VOLUMEUP);
Serial.println(F("RC: Volume up"));
break;
}
default: {
if (rcActionOk) {
Serial.println(F("RC: unknown"));
}
}
} }
} }
}
}
#endif
#endif
} }

876
src/Led.cpp
File diff suppressed because it is too large
View File

22
src/Log.cpp

@ -6,14 +6,13 @@
// Serial-logging buffer // Serial-logging buffer
uint8_t Log_BufferLength = 200; uint8_t Log_BufferLength = 200;
char *Log_Buffer = (char *)calloc(Log_BufferLength, sizeof(char)); // Buffer for all log-messages
char *Log_Buffer = (char *) calloc(Log_BufferLength, sizeof(char)); // Buffer for all log-messages
static LogRingBuffer Log_RingBuffer; static LogRingBuffer Log_RingBuffer;
void Log_Init(void)
{
void Log_Init(void){
Serial.begin(115200); Serial.begin(115200);
Log_Buffer = (char *)x_calloc(Log_BufferLength, sizeof(char)); // Buffer for all log-messages
Log_Buffer = (char *) x_calloc(Log_BufferLength, sizeof(char)); // Buffer for all log-messages
} }
/* Wrapper-function for serial-logging (with newline) /* Wrapper-function for serial-logging (with newline)
@ -21,26 +20,21 @@ void Log_Init(void)
_minLogLevel: loglevel configured for this message. _minLogLevel: loglevel configured for this message.
If (SERIAL_LOGLEVEL <= _minLogLevel) message will be logged If (SERIAL_LOGLEVEL <= _minLogLevel) message will be logged
*/ */
void Log_Println(const char *_logBuffer, const uint8_t _minLogLevel)
{
if (SERIAL_LOGLEVEL >= _minLogLevel)
{
void Log_Println(const char *_logBuffer, const uint8_t _minLogLevel) {
if (SERIAL_LOGLEVEL >= _minLogLevel) {
Serial.println(_logBuffer); Serial.println(_logBuffer);
Log_RingBuffer.println(_logBuffer); Log_RingBuffer.println(_logBuffer);
} }
} }
/* Wrapper-function for serial-logging (without newline) */ /* Wrapper-function for serial-logging (without newline) */
void Log_Print(const char *_logBuffer, const uint8_t _minLogLevel)
{
if (SERIAL_LOGLEVEL >= _minLogLevel)
{
void Log_Print(const char *_logBuffer, const uint8_t _minLogLevel) {
if (SERIAL_LOGLEVEL >= _minLogLevel) {
Serial.print(_logBuffer); Serial.print(_logBuffer);
Log_RingBuffer.print(_logBuffer); Log_RingBuffer.print(_logBuffer);
} }
} }
String Log_GetRingBuffer(void)
{
String Log_GetRingBuffer(void) {
return Log_RingBuffer.get(); return Log_RingBuffer.get();
} }

364
src/LogMessages_DE.cpp

@ -2,188 +2,188 @@
#include "settings.h" #include "settings.h"
#if (LANGUAGE == 1) #if (LANGUAGE == 1)
#include "Log.h"
#include "Log.h"
const char stillOnlineMqtt[] PROGMEM = "MQTT: Bin noch online.";
const char tryConnectMqttS[] PROGMEM = "Versuche Verbindung zu MQTT-Broker aufzubauen";
const char mqttOk[] PROGMEM = "MQTT-Session aufgebaut.";
const char sleepTimerEOP[] PROGMEM = "Sleep-Timer: Nach dem letzten Track der Playlist.";
const char sleepTimerEOT[] PROGMEM = "Sleep-Timer: Nach dem Ende des laufenden Tracks.";
const char sleepTimerStop[] PROGMEM = "Sleep-Timer wurde deaktiviert.";
const char sleepTimerEO5[] PROGMEM = "Sleep Timer: Nach Ende des Titels oder, wenn früher, Ende der Playlist";
const char sleepTimerAlreadyStopped[] PROGMEM = "Sleep-Timer ist bereits deaktiviert.";
const char sleepTimerSetTo[] PROGMEM = "Sleep-Timer gesetzt auf";
const char allowButtons[] PROGMEM = "Alle Tasten werden freigegeben.";
const char lockButtons[] PROGMEM = "Alle Tasten werden gesperrt.";
const char noPlaylistNotAllowedMqtt[] PROGMEM = "Playmode kann nicht auf 'Keine Playlist' gesetzt werden via MQTT.";
const char playmodeChangedMQtt[] PROGMEM = "Playmode per MQTT angepasst.";
const char noPlaymodeChangeIfIdle[] PROGMEM = "Playmode kann nicht verändert werden, wenn keine Playlist aktiv ist.";
const char noValidTopic[] PROGMEM = "Kein gültiges Topic";
const char freePtr[] PROGMEM = "Ptr-Freigabe";
const char freeMemory[] PROGMEM = "Freier Speicher";
const char writeEntryToNvs[] PROGMEM = "Schreibe Eintrag in NVS";
const char freeMemoryAfterFree[] PROGMEM = "Freier Speicher nach Aufräumen";
const char releaseMemoryOfOldPlaylist[] PROGMEM = "Gebe Speicher der alten Playlist frei.";
const char dirOrFileDoesNotExist[] PROGMEM = "Datei oder Verzeichnis existiert nicht ";
const char unableToAllocateMemForPlaylist[] PROGMEM = "Speicher für Playlist konnte nicht allokiert werden!";
const char unableToAllocateMem[] PROGMEM = "Speicher konnte nicht allokiert werden!";
const char fileModeDetected[] PROGMEM = "Dateimodus erkannt.";
const char nameOfFileFound[] PROGMEM = "Gefundenes File";
const char reallocCalled[] PROGMEM = "Speicher reallokiert.";
const char unableToAllocateMemForLinearPlaylist[] PROGMEM = "Speicher für lineare Playlist konnte nicht allokiert werden!";
const char numberOfValidFiles[] PROGMEM = "Anzahl gültiger Files";
const char newLoudnessReceivedQueue[] PROGMEM = "Neue Lautstärke empfangen via Queue";
const char newCntrlReceivedQueue[] PROGMEM = "Kontroll-Kommando empfangen via Queue";
const char newPlaylistReceived[] PROGMEM = "Neue Playlist empfangen";
const char repeatTrackDueToPlaymode[] PROGMEM = "Wiederhole Titel aufgrund von Playmode.";
const char repeatPlaylistDueToPlaymode[] PROGMEM = "Wiederhole Playlist aufgrund von Playmode.";
const char cmndStop[] PROGMEM = "Kommando: Stop";
const char cmndPause[] PROGMEM = "Kommando: Pause";
const char cmndNextTrack[] PROGMEM = "Kommando: Nächster Titel";
const char cmndPrevTrack[] PROGMEM = "Kommando: Vorheriger Titel";
const char cmndFirstTrack[] PROGMEM = "Kommando: Erster Titel von Playlist";
const char cmndLastTrack[] PROGMEM = "Kommando: Letzter Titel von Playlist";
const char cmndDoesNotExist[] PROGMEM = "Dieses Kommando existiert nicht.";
const char lastTrackAlreadyActive[] PROGMEM = "Es wird bereits der letzte Track gespielt.";
const char firstTrackAlreadyActive[] PROGMEM = "Es wird bereits der erste Track gespielt.";
const char trackStartAudiobook[] PROGMEM = "Titel wird im Hörspielmodus von vorne gespielt.";
const char trackStart[] PROGMEM = "Titel wird von vorne gespielt.";
const char trackChangeWebstream[] PROGMEM = "Im Webradio-Modus kann nicht an den Anfang gesprungen werden.";
const char endOfPlaylistReached[] PROGMEM = "Ende der Playlist erreicht.";
const char trackStartatPos[] PROGMEM = "Titel wird abgespielt ab Position";
const char rfidScannerReady[] PROGMEM = "RFID-Tags koennen jetzt gescannt werden...";
const char rfidTagDetected[] PROGMEM = "RFID-Karte erkannt: ";
const char rfid15693TagDetected[] PROGMEM = "RFID-Karte (ISO-15693) erkannt: ";
const char rfidTagReceived[] PROGMEM = "RFID-Karte empfangen";
const char rfidTagUnknownInNvs[] PROGMEM = "RFID-Karte ist im NVS nicht hinterlegt.";
const char goToSleepDueToIdle[] PROGMEM = "Gehe in Deep Sleep wegen Inaktivität...";
const char goToSleepDueToTimer[] PROGMEM = "Gehe in Deep Sleep wegen Sleep Timer...";
const char goToSleepNow[] PROGMEM = "Gehe jetzt in Deep Sleep!";
const char maxLoudnessReached[] PROGMEM = "Maximale Lautstärke bereits erreicht!";
const char minLoudnessReached[] PROGMEM = "Minimale Lautstärke bereits erreicht!";
const char errorOccured[] PROGMEM = "Fehler aufgetreten!";
const char noMp3FilesInDir[] PROGMEM = "Verzeichnis beinhaltet keine mp3-Files.";
const char modeSingleTrack[] PROGMEM = "Modus: Einzelner Track";
const char modeSingleTrackLoop[] PROGMEM = "Modus: Einzelner Track in Endlosschleife";
const char modeSingleAudiobook[] PROGMEM = "Modus: Hoerspiel";
const char modeSingleAudiobookLoop[] PROGMEM = "Modus: Hoerspiel in Endlosschleife";
const char modeAllTrackAlphSorted[] PROGMEM = "Modus: Spiele alle Tracks (alphabetisch sortiert) des Ordners";
const char modeAllTrackRandom[] PROGMEM = "Modus: Alle Tracks eines Ordners zufällig";
const char modeAllTrackAlphSortedLoop[] PROGMEM = "Modus: Alle Tracks eines Ordners sortiert (alphabetisch) in Endlosschleife";
const char modeAllTrackRandomLoop[] PROGMEM = "Modus: Alle Tracks eines Ordners zufällig in Endlosschleife";
const char modeWebstream[] PROGMEM = "Modus: Webstream";
const char webstreamNotAvailable[] PROGMEM = "Aktuell kein Webstream möglich, da keine WLAN-Verbindung vorhanden!";
const char modeDoesNotExist[] PROGMEM = "Abspielmodus existiert nicht!";
const char modeRepeatNone[] PROGMEM = "Repeatmodus: Kein Repeat";
const char modeRepeatTrack[] PROGMEM = "Repeatmodus: Aktueller Titel";
const char modeRepeatPlaylist[] PROGMEM = "Repeatmodus: Gesamte Playlist";
const char modeRepeatTracknPlaylist[] PROGMEM = "Repeatmodus: Track und Playlist";
const char modificatorAllButtonsLocked[] PROGMEM = "Modifikator: Alle Tasten werden per RFID gesperrt.";
const char modificatorAllButtonsUnlocked[] PROGMEM = "Modifikator: Alle Tasten werden per RFID freigegeben.";
const char modificatorSleepd[] PROGMEM = "Modifikator: Sleep-Timer wieder deaktiviert.";
const char modificatorSleepTimer15[] PROGMEM = "Modifikator: Sleep-Timer per RFID aktiviert (15 Minuten).";
const char modificatorSleepTimer30[] PROGMEM = "Modifikator: Sleep-Timer per RFID aktiviert (30 Minuten).";
const char modificatorSleepTimer60[] PROGMEM = "Modifikator: Sleep-Timer per RFID aktiviert (60 Minuten).";
const char modificatorSleepTimer120[] PROGMEM = "Modifikator: Sleep-Timer per RFID aktiviert (2 Stunden).";
const char ledsDimmedToNightmode[] PROGMEM = "LEDs wurden auf Nachtmodus gedimmt.";
const char modificatorNotallowedWhenIdle[] PROGMEM = "Modifikator kann bei nicht aktivierter Playlist nicht angewendet werden.";
const char modificatorSleepAtEOT[] PROGMEM = "Modifikator: Sleep-Timer am Ende des Titels aktiviert.";
const char modificatorSleepAtEOTd[] PROGMEM = "Modifikator: Sleep-Timer am Ende des Titels deaktiviert.";
const char modificatorSleepAtEOP[] PROGMEM = "Modifikator: Sleep-Timer am Ende der Playlist aktiviert.";
const char modificatorSleepAtEOPd[] PROGMEM = "Modifikator: Sleep-Timer am Ende der Playlist deaktiviert.";
const char modificatorAllTrackAlphSortedLoop[] PROGMEM = "Modifikator: Alle Titel (alphabetisch sortiert) in Endlosschleife.";
const char modificatorAllTrackRandomLoop[] PROGMEM = "Modifikator: Alle Titel (zufällige Reihenfolge) in Endlosschleife.";
const char modificatorCurTrackLoop[] PROGMEM = "Modifikator: Aktueller Titel in Endlosschleife.";
const char modificatorCurAudiobookLoop[] PROGMEM = "Modifikator: Aktuelles Hörspiel in Endlosschleife.";
const char modificatorPlaylistLoopActive[] PROGMEM = "Modifikator: Alle Titel in Endlosschleife aktiviert.";
const char modificatorPlaylistLoopDeactive[] PROGMEM = "Modifikator: Alle Titel in Endlosschleife deaktiviert.";
const char modificatorTrackActive[] PROGMEM = "Modifikator: Titel in Endlosschleife aktiviert.";
const char modificatorTrackDeactive[] PROGMEM = "Modifikator: Titel in Endlosschleife deaktiviert.";
const char modificatorNotAllowed[] PROGMEM = "Modifikator konnte nicht angewendet werden.";
const char modificatorLoopRev[] PROGMEM = "Modifikator: Endlosschleife beendet.";
const char modificatorDoesNotExist[] PROGMEM = "Ein Karten-Modifikator existiert nicht vom Typ";
const char errorOccuredNvs[] PROGMEM = "Es ist ein Fehler aufgetreten beim Lesen aus dem NVS!";
const char statementsReceivedByServer[] PROGMEM = "Vom Server wurde Folgendes empfangen";
const char savedSsidInNvs[] PROGMEM = "Speichere SSID in NVS";
const char savedWifiPwdInNvs[] PROGMEM = "Speichere WLAN-Password in NVS";
const char apReady[] PROGMEM = "Access-Point geöffnet";
const char httpReady[] PROGMEM = "HTTP-Server gestartet.";
const char unableToMountSd[] PROGMEM = "SD-Karte konnte nicht gemountet werden.";
const char unableToCreateVolQ[] PROGMEM = "Konnte Volume-Queue nicht anlegen.";
const char unableToCreateRfidQ[] PROGMEM = "Konnte RFID-Queue nicht anlegen.";
const char unableToCreateMgmtQ[] PROGMEM = "Konnte Play-Management-Queue nicht anlegen.";
const char unableToCreatePlayQ[] PROGMEM = "Konnte Track-Queue nicht anlegen..";
const char initialBrightnessfromNvs[] PROGMEM = "Initiale LED-Helligkeit wurde aus NVS geladen";
const char wroteInitialBrightnessToNvs[] PROGMEM = "Initiale LED-Helligkeit wurde ins NVS geschrieben.";
const char restoredInitialBrightnessForNmFromNvs[] PROGMEM = "LED-Helligkeit für Nachtmodus wurde aus NVS geladen";
const char wroteNmBrightnessToNvs[] PROGMEM = "LED-Helligkeit für Nachtmodus wurde ins NVS geschrieben.";
const char wroteFtpUserToNvs[] PROGMEM = "FTP-User wurde ins NVS geschrieben.";
const char restoredFtpUserFromNvs[] PROGMEM = "FTP-User wurde aus NVS geladen";
const char wroteFtpPwdToNvs[] PROGMEM = "FTP-Passwort wurde ins NVS geschrieben.";
const char restoredFtpPwdFromNvs[] PROGMEM = "FTP-Passwort wurde aus NVS geladen";
const char restoredMaxInactivityFromNvs[] PROGMEM = "Maximale Inaktivitätszeit wurde aus NVS geladen";
const char wroteMaxInactivityToNvs[] PROGMEM = "Maximale Inaktivitätszeit wurde ins NVS geschrieben.";
const char restoredInitialLoudnessFromNvs[] PROGMEM = "Initiale Lautstärke wurde aus NVS geladen";
const char wroteInitialLoudnessToNvs[] PROGMEM = "Initiale Lautstärke wurde ins NVS geschrieben.";
const char restoredMaxLoudnessForSpeakerFromNvs[] PROGMEM = "Maximale Lautstärke für Lautsprecher wurde aus NVS geladen";
const char restoredMaxLoudnessForHeadphoneFromNvs[] PROGMEM = "Maximale Lautstärke für Kopfhörer wurde aus NVS geladen";
const char wroteMaxLoudnessForSpeakerToNvs[] PROGMEM = "Maximale Lautstärke für Lautsprecher wurde ins NVS geschrieben.";
const char wroteMaxLoudnessForHeadphoneToNvs[] PROGMEM = "Maximale Lautstärke für Kopfhörer wurde ins NVS geschrieben.";
const char maxVolumeSet[] PROGMEM = "Maximale Lautstärke wurde gesetzt auf";
const char wroteMqttFlagToNvs[] PROGMEM = "MQTT-Flag wurde ins NVS geschrieben.";
const char restoredMqttActiveFromNvs[] PROGMEM = "MQTT-Flag (aktiviert) wurde aus NVS geladen";
const char restoredMqttDeactiveFromNvs[] PROGMEM = "MQTT-Flag (deaktiviert) wurde aus NVS geladen";
const char wroteMqttServerToNvs[] PROGMEM = "MQTT-Server wurde ins NVS geschrieben.";
const char restoredMqttServerFromNvs[] PROGMEM = "MQTT-Server wurde aus NVS geladen";
const char wroteMqttUserToNvs[] PROGMEM = "MQTT-User wurde ins NVS geschrieben.";
const char restoredMqttUserFromNvs[] PROGMEM = "MQTT-User wurde aus NVS geladen";
const char wroteMqttPwdToNvs[] PROGMEM = "MQTT-Passwort wurde ins NVS geschrieben.";
const char restoredMqttPwdFromNvs[] PROGMEM = "MQTT-Passwort wurde aus NVS geladen";
const char restoredMqttPortFromNvs[] PROGMEM = "MQTT-Port wurde aus NVS geladen";
const char mqttWithPwd[] PROGMEM = "Verbinde zu MQTT-Server mit User und Passwort";
const char mqttWithoutPwd[] PROGMEM = "Verbinde zu MQTT-Server ohne User und Passwort";
const char ssidNotFoundInNvs[] PROGMEM = "SSID wurde im NVS nicht gefunden.";
const char wifiPwdNotFoundInNvs[] PROGMEM = "WLAN-Passwort wurde im NVS nicht gefunden.";
const char wifiStaticIpConfigNotFoundInNvs[] PROGMEM = "Statische WLAN-IP-Konfiguration wurde im NVS nicht gefunden.";
const char wifiHostnameNotSet[] PROGMEM = "Keine Hostname-Konfiguration im NVS gefunden.";
const char mqttConnFailed[] PROGMEM = "Verbindung fehlgeschlagen, versuche in Kürze erneut";
const char restoredHostnameFromNvs[] PROGMEM = "Hostname aus NVS geladen";
const char currentVoltageMsg[] PROGMEM = "Aktuelle Batteriespannung";
const char voltageTooLow[] PROGMEM = "Batteriespannung niedrig";
const char sdBootFailedDeepsleep[] PROGMEM = "Bootgang wegen SD fehlgeschlagen. Gehe in Deepsleep...";
const char wifiEnabledAfterRestart[] PROGMEM = "WLAN wird aktiviert.";
const char wifiDisabledAfterRestart[] PROGMEM = "WLAN wird deaktiviert.";
const char voltageIndicatorLowFromNVS[] PROGMEM = "Unterer Spannungslevel (Batterie) fuer Neopixel-Anzeige aus NVS geladen";
const char voltageIndicatorHighFromNVS[] PROGMEM = "Oberer Spannungslevel (Batterie) fuer Neopixel-Anzeige aus NVS geladen";
const char voltageCheckIntervalFromNVS[] PROGMEM = "Zyklus für Spannungsmessung (Batterie) fuer Neopixel-Anzeige aus NVS geladen";
const char warningLowVoltageFromNVS[] PROGMEM = "Spannungslevel (Batterie) fuer Warnung via Neopixel aus NVS geladen";
const char unableToRestoreLastRfidFromNVS[] PROGMEM = "Letzte RFID konnte nicht aus NVS geladen werden";
const char restoredLastRfidFromNVS[] PROGMEM = "Letzte RFID wurde aus NVS geladen";
const char failedOpenFileForWrite[] PROGMEM = "Öffnen der Datei für den Schreibvorgang fehlgeschlagen";
const char fileWritten[] PROGMEM = "Datei geschrieben";
const char writeFailed[] PROGMEM = "Schreibvorgang fehlgeschlagen";
const char writingFile[] PROGMEM = "Schreibe Datei";
const char failedToOpenFileForAppending[] PROGMEM = "Öffnen der Datei zum Schreiben der JSON-Datei fehlgeschlagen";
const char listingDirectory[] PROGMEM = "Verzeichnisinhalt anzeigen";
const char failedToOpenDirectory[] PROGMEM = "Öffnen des Verzeichnisses fehlgeschlagen";
const char notADirectory[] PROGMEM = "Kein Verzeichnis";
const char sdMountedMmc1BitMode[] PROGMEM = "Versuche SD-Karte wird im SD_MMC-Modus (1 Bit) zu mounten...";
const char sdMountedSpiMode[] PROGMEM = "Versuche SD-Karte wird im SPI-Modus zu mounten...";
const char backupRecoveryWebsite[] PROGMEM = "<p>Das Backup-File wird eingespielt...<br />Zur letzten Seite <a href=\"javascript:history.back()\">zur&uuml;ckkehren</a>.</p>";
const char restartWebsite[] PROGMEM = "<p>Der ESPuino wird neu gestartet...<br />Zur letzten Seite <a href=\"javascript:history.back()\">zur&uuml;ckkehren</a>.</p>";
const char shutdownWebsite[] PROGMEM = "<p>Der ESPuino wird ausgeschaltet...</p>";
const char mqttMsgReceived[] PROGMEM = "MQTT-Nachricht empfangen";
const char trackPausedAtPos[] PROGMEM = "Titel pausiert bei Position";
const char freeHeapWithoutFtp[] PROGMEM = "Freier Heap-Speicher vor FTP-Instanzierung";
const char freeHeapWithFtp[] PROGMEM = "Freier Heap-Speicher nach FTP-Instanzierung";
const char freeHeapAfterSetup[] PROGMEM = "Freier Heap-Speicher nach Setup-Routine";
const char tryStaticIpConfig[] PROGMEM = "Statische IP-Konfiguration wird durchgeführt...";
const char staticIPConfigFailed[] PROGMEM = "Statische IP-Konfiguration fehlgeschlagen";
const char wakeUpRfidNoIso14443[] PROGMEM = "ESP32 wurde vom Kartenleser aus dem Deepsleep aufgeweckt. Allerdings wurde keine ISO-14443-Karte gefunden. Gehe zurück in den Deepsleep...";
const char lowPowerCardSuccess[] PROGMEM = "Kartenerkennung via 'low power' erfolgreich durchgeführt";
const char rememberLastVolume[] PROGMEM = "Lautstärke vor dem letzten Shutdown wird wiederhergestellt. Dies überschreibt die Einstellung der initialen Lautstärke aus der GUI.";
const char unableToStartFtpServer[] PROGMEM = "Der FTP-Server konnte nicht gestartet werden. Entweder weil er ist bereits gestartet oder kein WLAN verfügbar ist.";
const char newPlayModeStereo[] PROGMEM = "Neuer Modus: stereo";
const char newPlayModeMono[] PROGMEM = "Neuer Modus: mono";
const char stillOnlineMqtt[] PROGMEM = "MQTT: Bin noch online.";
const char tryConnectMqttS[] PROGMEM = "Versuche Verbindung zu MQTT-Broker aufzubauen";
const char mqttOk[] PROGMEM = "MQTT-Session aufgebaut.";
const char sleepTimerEOP[] PROGMEM = "Sleep-Timer: Nach dem letzten Track der Playlist.";
const char sleepTimerEOT[] PROGMEM = "Sleep-Timer: Nach dem Ende des laufenden Tracks.";
const char sleepTimerStop[] PROGMEM = "Sleep-Timer wurde deaktiviert.";
const char sleepTimerEO5[] PROGMEM = "Sleep Timer: Nach Ende des Titels oder, wenn früher, Ende der Playlist";
const char sleepTimerAlreadyStopped[] PROGMEM = "Sleep-Timer ist bereits deaktiviert.";
const char sleepTimerSetTo[] PROGMEM = "Sleep-Timer gesetzt auf";
const char allowButtons[] PROGMEM = "Alle Tasten werden freigegeben.";
const char lockButtons[] PROGMEM = "Alle Tasten werden gesperrt.";
const char noPlaylistNotAllowedMqtt[] PROGMEM = "Playmode kann nicht auf 'Keine Playlist' gesetzt werden via MQTT.";
const char playmodeChangedMQtt[] PROGMEM = "Playmode per MQTT angepasst.";
const char noPlaymodeChangeIfIdle[] PROGMEM = "Playmode kann nicht verändert werden, wenn keine Playlist aktiv ist.";
const char noValidTopic[] PROGMEM = "Kein gültiges Topic";
const char freePtr[] PROGMEM = "Ptr-Freigabe";
const char freeMemory[] PROGMEM = "Freier Speicher";
const char writeEntryToNvs[] PROGMEM = "Schreibe Eintrag in NVS";
const char freeMemoryAfterFree[] PROGMEM = "Freier Speicher nach Aufräumen";
const char releaseMemoryOfOldPlaylist[] PROGMEM = "Gebe Speicher der alten Playlist frei.";
const char dirOrFileDoesNotExist[] PROGMEM = "Datei oder Verzeichnis existiert nicht ";
const char unableToAllocateMemForPlaylist[] PROGMEM = "Speicher für Playlist konnte nicht allokiert werden!";
const char unableToAllocateMem[] PROGMEM = "Speicher konnte nicht allokiert werden!";
const char fileModeDetected[] PROGMEM = "Dateimodus erkannt.";
const char nameOfFileFound[] PROGMEM = "Gefundenes File";
const char reallocCalled[] PROGMEM = "Speicher reallokiert.";
const char unableToAllocateMemForLinearPlaylist[] PROGMEM = "Speicher für lineare Playlist konnte nicht allokiert werden!";
const char numberOfValidFiles[] PROGMEM = "Anzahl gültiger Files";
const char newLoudnessReceivedQueue[] PROGMEM = "Neue Lautstärke empfangen via Queue";
const char newCntrlReceivedQueue[] PROGMEM = "Kontroll-Kommando empfangen via Queue";
const char newPlaylistReceived[] PROGMEM = "Neue Playlist empfangen";
const char repeatTrackDueToPlaymode[] PROGMEM = "Wiederhole Titel aufgrund von Playmode.";
const char repeatPlaylistDueToPlaymode[] PROGMEM = "Wiederhole Playlist aufgrund von Playmode.";
const char cmndStop[] PROGMEM = "Kommando: Stop";
const char cmndPause[] PROGMEM = "Kommando: Pause";
const char cmndNextTrack[] PROGMEM = "Kommando: Nächster Titel";
const char cmndPrevTrack[] PROGMEM = "Kommando: Vorheriger Titel";
const char cmndFirstTrack[] PROGMEM = "Kommando: Erster Titel von Playlist";
const char cmndLastTrack[] PROGMEM = "Kommando: Letzter Titel von Playlist";
const char cmndDoesNotExist[] PROGMEM = "Dieses Kommando existiert nicht.";
const char lastTrackAlreadyActive[] PROGMEM = "Es wird bereits der letzte Track gespielt.";
const char firstTrackAlreadyActive[] PROGMEM = "Es wird bereits der erste Track gespielt.";
const char trackStartAudiobook[] PROGMEM = "Titel wird im Hörspielmodus von vorne gespielt.";
const char trackStart[] PROGMEM = "Titel wird von vorne gespielt.";
const char trackChangeWebstream[] PROGMEM = "Im Webradio-Modus kann nicht an den Anfang gesprungen werden.";
const char endOfPlaylistReached[] PROGMEM = "Ende der Playlist erreicht.";
const char trackStartatPos[] PROGMEM = "Titel wird abgespielt ab Position";
const char rfidScannerReady[] PROGMEM = "RFID-Tags koennen jetzt gescannt werden...";
const char rfidTagDetected[] PROGMEM = "RFID-Karte erkannt: ";
const char rfid15693TagDetected[] PROGMEM = "RFID-Karte (ISO-15693) erkannt: ";
const char rfidTagReceived[] PROGMEM = "RFID-Karte empfangen";
const char rfidTagUnknownInNvs[] PROGMEM = "RFID-Karte ist im NVS nicht hinterlegt.";
const char goToSleepDueToIdle[] PROGMEM = "Gehe in Deep Sleep wegen Inaktivität...";
const char goToSleepDueToTimer[] PROGMEM = "Gehe in Deep Sleep wegen Sleep Timer...";
const char goToSleepNow[] PROGMEM = "Gehe jetzt in Deep Sleep!";
const char maxLoudnessReached[] PROGMEM = "Maximale Lautstärke bereits erreicht!";
const char minLoudnessReached[] PROGMEM = "Minimale Lautstärke bereits erreicht!";
const char errorOccured[] PROGMEM = "Fehler aufgetreten!";
const char noMp3FilesInDir[] PROGMEM = "Verzeichnis beinhaltet keine mp3-Files.";
const char modeSingleTrack[] PROGMEM = "Modus: Einzelner Track";
const char modeSingleTrackLoop[] PROGMEM = "Modus: Einzelner Track in Endlosschleife";
const char modeSingleAudiobook[] PROGMEM = "Modus: Hoerspiel";
const char modeSingleAudiobookLoop[] PROGMEM = "Modus: Hoerspiel in Endlosschleife";
const char modeAllTrackAlphSorted[] PROGMEM = "Modus: Spiele alle Tracks (alphabetisch sortiert) des Ordners";
const char modeAllTrackRandom[] PROGMEM = "Modus: Alle Tracks eines Ordners zufällig";
const char modeAllTrackAlphSortedLoop[] PROGMEM = "Modus: Alle Tracks eines Ordners sortiert (alphabetisch) in Endlosschleife";
const char modeAllTrackRandomLoop[] PROGMEM = "Modus: Alle Tracks eines Ordners zufällig in Endlosschleife";
const char modeWebstream[] PROGMEM = "Modus: Webstream";
const char webstreamNotAvailable[] PROGMEM = "Aktuell kein Webstream möglich, da keine WLAN-Verbindung vorhanden!";
const char modeDoesNotExist[] PROGMEM = "Abspielmodus existiert nicht!";
const char modeRepeatNone[] PROGMEM = "Repeatmodus: Kein Repeat";
const char modeRepeatTrack[] PROGMEM = "Repeatmodus: Aktueller Titel";
const char modeRepeatPlaylist[] PROGMEM = "Repeatmodus: Gesamte Playlist";
const char modeRepeatTracknPlaylist[] PROGMEM = "Repeatmodus: Track und Playlist";
const char modificatorAllButtonsLocked[] PROGMEM = "Modifikator: Alle Tasten werden per RFID gesperrt.";
const char modificatorAllButtonsUnlocked[] PROGMEM = "Modifikator: Alle Tasten werden per RFID freigegeben.";
const char modificatorSleepd[] PROGMEM = "Modifikator: Sleep-Timer wieder deaktiviert.";
const char modificatorSleepTimer15[] PROGMEM = "Modifikator: Sleep-Timer per RFID aktiviert (15 Minuten).";
const char modificatorSleepTimer30[] PROGMEM = "Modifikator: Sleep-Timer per RFID aktiviert (30 Minuten).";
const char modificatorSleepTimer60[] PROGMEM = "Modifikator: Sleep-Timer per RFID aktiviert (60 Minuten).";
const char modificatorSleepTimer120[] PROGMEM = "Modifikator: Sleep-Timer per RFID aktiviert (2 Stunden).";
const char ledsDimmedToNightmode[] PROGMEM = "LEDs wurden auf Nachtmodus gedimmt.";
const char modificatorNotallowedWhenIdle[] PROGMEM = "Modifikator kann bei nicht aktivierter Playlist nicht angewendet werden.";
const char modificatorSleepAtEOT[] PROGMEM = "Modifikator: Sleep-Timer am Ende des Titels aktiviert.";
const char modificatorSleepAtEOTd[] PROGMEM = "Modifikator: Sleep-Timer am Ende des Titels deaktiviert.";
const char modificatorSleepAtEOP[] PROGMEM = "Modifikator: Sleep-Timer am Ende der Playlist aktiviert.";
const char modificatorSleepAtEOPd[] PROGMEM = "Modifikator: Sleep-Timer am Ende der Playlist deaktiviert.";
const char modificatorAllTrackAlphSortedLoop[] PROGMEM = "Modifikator: Alle Titel (alphabetisch sortiert) in Endlosschleife.";
const char modificatorAllTrackRandomLoop[] PROGMEM = "Modifikator: Alle Titel (zufällige Reihenfolge) in Endlosschleife.";
const char modificatorCurTrackLoop[] PROGMEM = "Modifikator: Aktueller Titel in Endlosschleife.";
const char modificatorCurAudiobookLoop[] PROGMEM = "Modifikator: Aktuelles Hörspiel in Endlosschleife.";
const char modificatorPlaylistLoopActive[] PROGMEM = "Modifikator: Alle Titel in Endlosschleife aktiviert.";
const char modificatorPlaylistLoopDeactive[] PROGMEM = "Modifikator: Alle Titel in Endlosschleife deaktiviert.";
const char modificatorTrackActive[] PROGMEM = "Modifikator: Titel in Endlosschleife aktiviert.";
const char modificatorTrackDeactive[] PROGMEM = "Modifikator: Titel in Endlosschleife deaktiviert.";
const char modificatorNotAllowed[] PROGMEM = "Modifikator konnte nicht angewendet werden.";
const char modificatorLoopRev[] PROGMEM = "Modifikator: Endlosschleife beendet.";
const char modificatorDoesNotExist[] PROGMEM = "Ein Karten-Modifikator existiert nicht vom Typ";
const char errorOccuredNvs[] PROGMEM = "Es ist ein Fehler aufgetreten beim Lesen aus dem NVS!";
const char statementsReceivedByServer[] PROGMEM = "Vom Server wurde Folgendes empfangen";
const char savedSsidInNvs[] PROGMEM = "Speichere SSID in NVS";
const char savedWifiPwdInNvs[] PROGMEM = "Speichere WLAN-Password in NVS";
const char apReady[] PROGMEM = "Access-Point geöffnet";
const char httpReady[] PROGMEM = "HTTP-Server gestartet.";
const char unableToMountSd[] PROGMEM = "SD-Karte konnte nicht gemountet werden.";
const char unableToCreateVolQ[] PROGMEM = "Konnte Volume-Queue nicht anlegen.";
const char unableToCreateRfidQ[] PROGMEM = "Konnte RFID-Queue nicht anlegen.";
const char unableToCreateMgmtQ[] PROGMEM = "Konnte Play-Management-Queue nicht anlegen.";
const char unableToCreatePlayQ[] PROGMEM = "Konnte Track-Queue nicht anlegen..";
const char initialBrightnessfromNvs[] PROGMEM = "Initiale LED-Helligkeit wurde aus NVS geladen";
const char wroteInitialBrightnessToNvs[] PROGMEM = "Initiale LED-Helligkeit wurde ins NVS geschrieben.";
const char restoredInitialBrightnessForNmFromNvs[] PROGMEM = "LED-Helligkeit für Nachtmodus wurde aus NVS geladen";
const char wroteNmBrightnessToNvs[] PROGMEM = "LED-Helligkeit für Nachtmodus wurde ins NVS geschrieben.";
const char wroteFtpUserToNvs[] PROGMEM = "FTP-User wurde ins NVS geschrieben.";
const char restoredFtpUserFromNvs[] PROGMEM = "FTP-User wurde aus NVS geladen";
const char wroteFtpPwdToNvs[] PROGMEM = "FTP-Passwort wurde ins NVS geschrieben.";
const char restoredFtpPwdFromNvs[] PROGMEM = "FTP-Passwort wurde aus NVS geladen";
const char restoredMaxInactivityFromNvs[] PROGMEM = "Maximale Inaktivitätszeit wurde aus NVS geladen";
const char wroteMaxInactivityToNvs[] PROGMEM = "Maximale Inaktivitätszeit wurde ins NVS geschrieben.";
const char restoredInitialLoudnessFromNvs[] PROGMEM = "Initiale Lautstärke wurde aus NVS geladen";
const char wroteInitialLoudnessToNvs[] PROGMEM = "Initiale Lautstärke wurde ins NVS geschrieben.";
const char restoredMaxLoudnessForSpeakerFromNvs[] PROGMEM = "Maximale Lautstärke für Lautsprecher wurde aus NVS geladen";
const char restoredMaxLoudnessForHeadphoneFromNvs[] PROGMEM = "Maximale Lautstärke für Kopfhörer wurde aus NVS geladen";
const char wroteMaxLoudnessForSpeakerToNvs[] PROGMEM = "Maximale Lautstärke für Lautsprecher wurde ins NVS geschrieben.";
const char wroteMaxLoudnessForHeadphoneToNvs[] PROGMEM = "Maximale Lautstärke für Kopfhörer wurde ins NVS geschrieben.";
const char maxVolumeSet[] PROGMEM = "Maximale Lautstärke wurde gesetzt auf";
const char wroteMqttFlagToNvs[] PROGMEM = "MQTT-Flag wurde ins NVS geschrieben.";
const char restoredMqttActiveFromNvs[] PROGMEM = "MQTT-Flag (aktiviert) wurde aus NVS geladen";
const char restoredMqttDeactiveFromNvs[] PROGMEM = "MQTT-Flag (deaktiviert) wurde aus NVS geladen";
const char wroteMqttServerToNvs[] PROGMEM = "MQTT-Server wurde ins NVS geschrieben.";
const char restoredMqttServerFromNvs[] PROGMEM = "MQTT-Server wurde aus NVS geladen";
const char wroteMqttUserToNvs[] PROGMEM = "MQTT-User wurde ins NVS geschrieben.";
const char restoredMqttUserFromNvs[] PROGMEM = "MQTT-User wurde aus NVS geladen";
const char wroteMqttPwdToNvs[] PROGMEM = "MQTT-Passwort wurde ins NVS geschrieben.";
const char restoredMqttPwdFromNvs[] PROGMEM = "MQTT-Passwort wurde aus NVS geladen";
const char restoredMqttPortFromNvs[] PROGMEM = "MQTT-Port wurde aus NVS geladen";
const char mqttWithPwd[] PROGMEM = "Verbinde zu MQTT-Server mit User und Passwort";
const char mqttWithoutPwd[] PROGMEM = "Verbinde zu MQTT-Server ohne User und Passwort";
const char ssidNotFoundInNvs[] PROGMEM = "SSID wurde im NVS nicht gefunden.";
const char wifiPwdNotFoundInNvs[] PROGMEM = "WLAN-Passwort wurde im NVS nicht gefunden.";
const char wifiStaticIpConfigNotFoundInNvs[] PROGMEM = "Statische WLAN-IP-Konfiguration wurde im NVS nicht gefunden.";
const char wifiHostnameNotSet[] PROGMEM = "Keine Hostname-Konfiguration im NVS gefunden.";
const char mqttConnFailed[] PROGMEM = "Verbindung fehlgeschlagen, versuche in Kürze erneut";
const char restoredHostnameFromNvs[] PROGMEM = "Hostname aus NVS geladen";
const char currentVoltageMsg[] PROGMEM = "Aktuelle Batteriespannung";
const char voltageTooLow[] PROGMEM = "Batteriespannung niedrig";
const char sdBootFailedDeepsleep[] PROGMEM = "Bootgang wegen SD fehlgeschlagen. Gehe in Deepsleep...";
const char wifiEnabledAfterRestart[] PROGMEM = "WLAN wird aktiviert.";
const char wifiDisabledAfterRestart[] PROGMEM = "WLAN wird deaktiviert.";
const char voltageIndicatorLowFromNVS[] PROGMEM = "Unterer Spannungslevel (Batterie) fuer Neopixel-Anzeige aus NVS geladen";
const char voltageIndicatorHighFromNVS[] PROGMEM = "Oberer Spannungslevel (Batterie) fuer Neopixel-Anzeige aus NVS geladen";
const char voltageCheckIntervalFromNVS[] PROGMEM = "Zyklus für Spannungsmessung (Batterie) fuer Neopixel-Anzeige aus NVS geladen";
const char warningLowVoltageFromNVS[] PROGMEM = "Spannungslevel (Batterie) fuer Warnung via Neopixel aus NVS geladen";
const char unableToRestoreLastRfidFromNVS[] PROGMEM = "Letzte RFID konnte nicht aus NVS geladen werden";
const char restoredLastRfidFromNVS[] PROGMEM = "Letzte RFID wurde aus NVS geladen";
const char failedOpenFileForWrite[] PROGMEM = "Öffnen der Datei für den Schreibvorgang fehlgeschlagen";
const char fileWritten[] PROGMEM = "Datei geschrieben";
const char writeFailed[] PROGMEM = "Schreibvorgang fehlgeschlagen";
const char writingFile[] PROGMEM = "Schreibe Datei";
const char failedToOpenFileForAppending[] PROGMEM = "Öffnen der Datei zum Schreiben der JSON-Datei fehlgeschlagen";
const char listingDirectory[] PROGMEM = "Verzeichnisinhalt anzeigen";
const char failedToOpenDirectory[] PROGMEM = "Öffnen des Verzeichnisses fehlgeschlagen";
const char notADirectory[] PROGMEM = "Kein Verzeichnis";
const char sdMountedMmc1BitMode[] PROGMEM = "Versuche SD-Karte wird im SD_MMC-Modus (1 Bit) zu mounten...";
const char sdMountedSpiMode[] PROGMEM = "Versuche SD-Karte wird im SPI-Modus zu mounten...";
const char backupRecoveryWebsite[] PROGMEM = "<p>Das Backup-File wird eingespielt...<br />Zur letzten Seite <a href=\"javascript:history.back()\">zur&uuml;ckkehren</a>.</p>";
const char restartWebsite[] PROGMEM = "<p>Der ESPuino wird neu gestartet...<br />Zur letzten Seite <a href=\"javascript:history.back()\">zur&uuml;ckkehren</a>.</p>";
const char shutdownWebsite[] PROGMEM = "<p>Der ESPuino wird ausgeschaltet...</p>";
const char mqttMsgReceived[] PROGMEM = "MQTT-Nachricht empfangen";
const char trackPausedAtPos[] PROGMEM = "Titel pausiert bei Position";
const char freeHeapWithoutFtp[] PROGMEM = "Freier Heap-Speicher vor FTP-Instanzierung";
const char freeHeapWithFtp[] PROGMEM = "Freier Heap-Speicher nach FTP-Instanzierung";
const char freeHeapAfterSetup[] PROGMEM = "Freier Heap-Speicher nach Setup-Routine";
const char tryStaticIpConfig[] PROGMEM = "Statische IP-Konfiguration wird durchgeführt...";
const char staticIPConfigFailed[] PROGMEM = "Statische IP-Konfiguration fehlgeschlagen";
const char wakeUpRfidNoIso14443[] PROGMEM = "ESP32 wurde vom Kartenleser aus dem Deepsleep aufgeweckt. Allerdings wurde keine ISO-14443-Karte gefunden. Gehe zurück in den Deepsleep...";
const char lowPowerCardSuccess[] PROGMEM = "Kartenerkennung via 'low power' erfolgreich durchgeführt";
const char rememberLastVolume[] PROGMEM = "Lautstärke vor dem letzten Shutdown wird wiederhergestellt. Dies überschreibt die Einstellung der initialen Lautstärke aus der GUI.";
const char unableToStartFtpServer[] PROGMEM = "Der FTP-Server konnte nicht gestartet werden. Entweder weil er ist bereits gestartet oder kein WLAN verfügbar ist.";
const char newPlayModeStereo[] PROGMEM = "Neuer Modus: stereo";
const char newPlayModeMono[] PROGMEM = "Neuer Modus: mono";
#endif #endif

364
src/LogMessages_EN.cpp

@ -2,188 +2,188 @@
#include "settings.h" #include "settings.h"
#if (LANGUAGE == 2) #if (LANGUAGE == 2)
#include "Log.h"
#include "Log.h"
const char stillOnlineMqtt[] PROGMEM = "MQTT: still online.";
const char tryConnectMqttS[] PROGMEM = "Trying to connect to MQTT-broker";
const char mqttOk[] PROGMEM = "MQTT-connection established.";
const char sleepTimerEOP[] PROGMEM = "Sleep-timer: after last track of playlist.";
const char sleepTimerEOT[] PROGMEM = "Sleep-timer: after end of current track.";
const char sleepTimerStop[] PROGMEM = "Sleep-timer has been disabled.";
const char sleepTimerEO5[] PROGMEM = "Sleep-timer: after five track or end of playlist - whatever is reached first";
const char sleepTimerAlreadyStopped[] PROGMEM = "sleep-timer is already disabled.";
const char sleepTimerSetTo[] PROGMEM = "sleep-timer adjusted to";
const char allowButtons[] PROGMEM = "Unlocking all keys.";
const char lockButtons[] PROGMEM = "Locking all keys.";
const char noPlaylistNotAllowedMqtt[] PROGMEM = "Playmode cannot be adjusted to 'no playlist' via MQTT.";
const char playmodeChangedMQtt[] PROGMEM = "Playlist adjusted via MQTT.";
const char noPlaymodeChangeIfIdle[] PROGMEM = "Playlist cannot be adjusted while no playlist is active.";
const char noValidTopic[] PROGMEM = "No valid MQTT-topic";
const char freePtr[] PROGMEM = "Releasing Pointer";
const char freeMemory[] PROGMEM = "Free memory";
const char writeEntryToNvs[] PROGMEM = "Storing data to NVS";
const char freeMemoryAfterFree[] PROGMEM = "Free memory after cleaning";
const char releaseMemoryOfOldPlaylist[] PROGMEM = "Releasing memory of old playlist.";
const char dirOrFileDoesNotExist[] PROGMEM = "File of directory does not exist";
const char unableToAllocateMemForPlaylist[] PROGMEM = "Unable to allocate memory for playlist!";
const char unableToAllocateMem[] PROGMEM = "Unable to allocate memory!";
const char fileModeDetected[] PROGMEM = "File-mode detected.";
const char nameOfFileFound[] PROGMEM = "File found";
const char reallocCalled[] PROGMEM = "Reallocated memory.";
const char unableToAllocateMemForLinearPlaylist[] PROGMEM = "Unable to allocate memory for linear playlist!";
const char numberOfValidFiles[] PROGMEM = "Number of valid files";
const char newLoudnessReceivedQueue[] PROGMEM = "New volume received via queue";
const char newCntrlReceivedQueue[] PROGMEM = "Control-command received via queue";
const char newPlaylistReceived[] PROGMEM = "New playlist received";
const char repeatTrackDueToPlaymode[] PROGMEM = "Repeating track due to playmode configured.";
const char repeatPlaylistDueToPlaymode[] PROGMEM = "Repeating playlist due to playmode configured.";
const char cmndStop[] PROGMEM = "Command: stop";
const char cmndPause[] PROGMEM = "Command: pause";
const char cmndNextTrack[] PROGMEM = "Command: next track";
const char cmndPrevTrack[] PROGMEM = "Command: previous track";
const char cmndFirstTrack[] PROGMEM = "Command: first track of playlist";
const char cmndLastTrack[] PROGMEM = "Command: last track of playlist";
const char cmndDoesNotExist[] PROGMEM = "Command requested does not exist.";
const char lastTrackAlreadyActive[] PROGMEM = "Already playing last track.";
const char firstTrackAlreadyActive[] PROGMEM = "Already playing first track.";
const char trackStartAudiobook[] PROGMEM = "Starting track in playmode from the very beginning.";
const char trackStart[] PROGMEM = "Starting track from the very beginning.";
const char trackChangeWebstream[] PROGMEM = "Playing from the very beginning is not possible while webradio-mode is active.";
const char endOfPlaylistReached[] PROGMEM = "Reached end of playlist.";
const char trackStartatPos[] PROGMEM = "Starting track at position";
const char rfidScannerReady[] PROGMEM = "RFID-tags can now be applied...";
const char rfidTagDetected[] PROGMEM = "RFID-tag detected: ";
const char rfid15693TagDetected[] PROGMEM = "RFID-ta (ISO-15693) detected: ";
const char rfidTagReceived[] PROGMEM = "RFID-tag received";
const char rfidTagUnknownInNvs[] PROGMEM = "RFID-tag is unkown to NVS.";
const char goToSleepDueToIdle[] PROGMEM = "Going to deepsleep due to inactivity-timer...";
const char goToSleepDueToTimer[] PROGMEM = "Going to deepsleep due to sleep timer...";
const char goToSleepNow[] PROGMEM = "Going to deepsleep now!";
const char maxLoudnessReached[] PROGMEM = "Already reached max volume!";
const char minLoudnessReached[] PROGMEM = "Already reached min volume!";
const char errorOccured[] PROGMEM = "Error occured!";
const char noMp3FilesInDir[] PROGMEM = "Directory does not contain mp3-files.";
const char modeSingleTrack[] PROGMEM = "Mode: Single track";
const char modeSingleTrackLoop[] PROGMEM = "Mode: single track as infinite loop";
const char modeSingleAudiobook[] PROGMEM = "Mode: audiobook";
const char modeSingleAudiobookLoop[] PROGMEM = "Mode: audiobook as infinite loop";
const char modeAllTrackAlphSorted[] PROGMEM = "Mode: all tracks (in alph. order) of directory";
const char modeAllTrackRandom[] PROGMEM = "Mode: all tracks (in random. order) of directory";
const char modeAllTrackAlphSortedLoop[] PROGMEM = "Mode: all tracks (in alph. order) of directory as infinite loop";
const char modeAllTrackRandomLoop[] PROGMEM = "Mode: all tracks (in random order) of directory as infinite loop";
const char modeWebstream[] PROGMEM = "Mode: webstream";
const char webstreamNotAvailable[] PROGMEM = "Unable to access webstream as no wifi-connection is available!";
const char modeDoesNotExist[] PROGMEM = "Playmode does not exist!";
const char modeRepeatNone[] PROGMEM = "Repeatmode: no repeat";
const char modeRepeatTrack[] PROGMEM = "Repeatmode: current track";
const char modeRepeatPlaylist[] PROGMEM = "Repeatmode: whole playlist";
const char modeRepeatTracknPlaylist[] PROGMEM = "Repeatmode: track and playlist";
const char modificatorAllButtonsLocked[] PROGMEM = "Modificator: locking all keys via RFID-tag.";
const char modificatorAllButtonsUnlocked[] PROGMEM = "Modificator: unlocking all keys via RFID-tag.";
const char modificatorSleepd[] PROGMEM = "Modificator: sleep-Timer deactivated.";
const char modificatorSleepTimer15[] PROGMEM = "Modificator: sleep-Timer enabled via RFID (15 minutes).";
const char modificatorSleepTimer30[] PROGMEM = "Modificator: sleep-Timer enabled via RFID (30 minutes).";
const char modificatorSleepTimer60[] PROGMEM = "Modificator: sleep-Timer enabled via RFID (60 minutes).";
const char modificatorSleepTimer120[] PROGMEM = "Modificator: sleep-Timer enabled via RFID (2 hours).";
const char ledsDimmedToNightmode[] PROGMEM = "Dimmed LEDs to nightmode.";
const char modificatorNotallowedWhenIdle[] PROGMEM = "Modificator cannot be applied while playlist is inactive.";
const char modificatorSleepAtEOT[] PROGMEM = "Modificator: adjusted sleep-timer to after end of current track.";
const char modificatorSleepAtEOTd[] PROGMEM = "Modificator: disabled sleep-timer after end of current track.";
const char modificatorSleepAtEOP[] PROGMEM = "Modificator: adjusted sleep-timer to after end of playlist.";
const char modificatorSleepAtEOPd[] PROGMEM = "Modificator: disabled sleep-timer after end of playlist.";
const char modificatorAllTrackAlphSortedLoop[] PROGMEM = "Modificator: adjusted to all tracks (in alph. order) as infinite loop.";
const char modificatorAllTrackRandomLoop[] PROGMEM = "Modificator: adjusted to all tracks (in random order) as infinite loop.";
const char modificatorCurTrackLoop[] PROGMEM = "Modificator: adjusted to current track as infinite loop.";
const char modificatorCurAudiobookLoop[] PROGMEM = "Modificator: adjusted to current audiobook as infinite loop.";
const char modificatorPlaylistLoopActive[] PROGMEM = "Modificator: adjusted to all tracks as infinite loop.";
const char modificatorPlaylistLoopDeactive[] PROGMEM = "Modificator: disabled all tracks as infinite loop.";
const char modificatorTrackActive[] PROGMEM = "Modificator: adjusted to current track as infinite loop.";
const char modificatorTrackDeactive[] PROGMEM = "Modificator: disabled current track as infinite loop.";
const char modificatorNotAllowed[] PROGMEM = "Unable to apply modificator.";
const char modificatorLoopRev[] PROGMEM = "Modificator: infinite loop ended.";
const char modificatorDoesNotExist[] PROGMEM = "This type of card-modificator does not exist";
const char errorOccuredNvs[] PROGMEM = "Error occured while reading from NVS!";
const char statementsReceivedByServer[] PROGMEM = "Data received from server";
const char savedSsidInNvs[] PROGMEM = "Storing SSID to NVS";
const char savedWifiPwdInNvs[] PROGMEM = "Storing wifi-password to NVS";
const char apReady[] PROGMEM = "Started wifi-access-point";
const char httpReady[] PROGMEM = "Started HTTP-server.";
const char unableToMountSd[] PROGMEM = "Unable to mount sd-card.";
const char unableToCreateVolQ[] PROGMEM = "Unable to create volume-queue.";
const char unableToCreateRfidQ[] PROGMEM = "Unable to create RFID-queue.";
const char unableToCreateMgmtQ[] PROGMEM = "Unable to play-management-queue.";
const char unableToCreatePlayQ[] PROGMEM = "Unable to create track-queue..";
const char initialBrightnessfromNvs[] PROGMEM = "Restoring initial LED-brightness from NVS";
const char wroteInitialBrightnessToNvs[] PROGMEM = "Storing initial LED-brightness to NVS.";
const char restoredInitialBrightnessForNmFromNvs[] PROGMEM = "Restored LED-brightness for nightmode from NVS";
const char wroteNmBrightnessToNvs[] PROGMEM = "Stored LED-brightness for nightmode to NVS.";
const char wroteFtpUserToNvs[] PROGMEM = "Stored FTP-user to NVS.";
const char restoredFtpUserFromNvs[] PROGMEM = "Restored FTP-user from NVS";
const char wroteFtpPwdToNvs[] PROGMEM = "Stored FTP-password to NVS.";
const char restoredFtpPwdFromNvs[] PROGMEM = "Restored FTP-password from NVS";
const char restoredMaxInactivityFromNvs[] PROGMEM = "Restored maximum inactivity-time from NVS.";
const char wroteMaxInactivityToNvs[] PROGMEM = "Stored maximum inactivity-time to NVS.";
const char restoredInitialLoudnessFromNvs[] PROGMEM = "Restored initial volume from NVS";
const char wroteInitialLoudnessToNvs[] PROGMEM = "Stored initial volume to NVS.";
const char restoredMaxLoudnessForSpeakerFromNvs[] PROGMEM = "Restored maximum volume for speaker from NVS";
const char restoredMaxLoudnessForHeadphoneFromNvs[] PROGMEM = "Restored maximum volume for headphone from NVS";
const char wroteMaxLoudnessForSpeakerToNvs[] PROGMEM = "Wrote maximum volume for speaker to NVS.";
const char wroteMaxLoudnessForHeadphoneToNvs[] PROGMEM = "Wrote maximum volume for headphone to NVS.";
const char maxVolumeSet[] PROGMEM = "Maximum volume set to";
const char wroteMqttFlagToNvs[] PROGMEM = "Stored MQTT-flag to NVS.";
const char restoredMqttActiveFromNvs[] PROGMEM = "Restored MQTT-flag (enabled) from NVS";
const char restoredMqttDeactiveFromNvs[] PROGMEM = "Restored MQTT-flag (disabled) from NVS";
const char wroteMqttServerToNvs[] PROGMEM = "Stored MQTT-server to NVS.";
const char restoredMqttServerFromNvs[] PROGMEM = "Restored MQTT-Server from NVS";
const char wroteMqttUserToNvs[] PROGMEM = "Stored MQTT-user to NVS.";
const char restoredMqttUserFromNvs[] PROGMEM = "Restored MQTT-user from NVS";
const char wroteMqttPwdToNvs[] PROGMEM = "Stored MQTT-password to NVS.";
const char restoredMqttPwdFromNvs[] PROGMEM = "Restored MQTT-password from NVS";
const char restoredMqttPortFromNvs[] PROGMEM = "Restored MQTT-port from NVS";
const char mqttWithPwd[] PROGMEM = "Try to connect to MQTT-server with user und password";
const char mqttWithoutPwd[] PROGMEM = "Try to connect to MQTT-server without user und password";
const char ssidNotFoundInNvs[] PROGMEM = "Unable to find SSID to NVS.";
const char wifiPwdNotFoundInNvs[] PROGMEM = "Unable to find wifi-password to NVS.";
const char wifiStaticIpConfigNotFoundInNvs[] PROGMEM = "Unable to find wifi-ip-configuration to NVS.";
const char wifiHostnameNotSet[] PROGMEM = "Unable to find hostname-configuration to NVS.";
const char mqttConnFailed[] PROGMEM = "Unable to establish mqtt-connection, trying again...";
const char restoredHostnameFromNvs[] PROGMEM = "Restored hostname from NVS";
const char currentVoltageMsg[] PROGMEM = "Current battery-voltage";
const char voltageTooLow[] PROGMEM = "Low battery-voltage";
const char sdBootFailedDeepsleep[] PROGMEM = "Failed to boot due to SD. Will go to deepsleep...";
const char wifiEnabledAfterRestart[] PROGMEM = "WiFi will be enabled.";
const char wifiDisabledAfterRestart[] PROGMEM = "WiFi will be disabled .";
const char voltageIndicatorLowFromNVS[] PROGMEM = "Restored lower voltage-level for Neopixel-display from NVS";
const char voltageIndicatorHighFromNVS[] PROGMEM = "Restored upper voltage-level for Neopixel-display from NVS";
const char voltageCheckIntervalFromNVS[] PROGMEM = "Restored interval of battery-measurement or Neopixel-display from NVS";
const char warningLowVoltageFromNVS[] PROGMEM = "Restored battery-voltage-level for warning via Neopixel from NVS";
const char unableToRestoreLastRfidFromNVS[] PROGMEM = "Unable to restore last RFID from NVS";
const char restoredLastRfidFromNVS[] PROGMEM = "Restored last RFID from NVS";
const char failedOpenFileForWrite[] PROGMEM = "Failed to open file for writing";
const char fileWritten[] PROGMEM = "File written";
const char writeFailed[] PROGMEM = "Write failed";
const char writingFile[] PROGMEM = "Writing file";
const char failedToOpenFileForAppending[] PROGMEM = "Failed to open file for appending";
const char listingDirectory[] PROGMEM = "Listing directory";
const char failedToOpenDirectory[] PROGMEM = "Failed to open directory";
const char notADirectory[] PROGMEM = "Not a directory";
const char sdMountedMmc1BitMode[] PROGMEM = "SD card mounted in SPI-mode configured...";
const char sdMountedSpiMode[] PROGMEM = "Mounting SD card in SPI-mode...";
const char backupRecoveryWebsite[] PROGMEM = "<p>Backup-file is being applied...<br />Back to <a href=\"javascript:history.back()\">last page</a>.</p>";
const char restartWebsite[] PROGMEM = "<p>ESPuino is being restarted...<br />Back to <a href=\"javascript:history.back()\">last page</a>.</p>";
const char shutdownWebsite[] PROGMEM = "<p>Der ESPuino is being shutdown...</p>";
const char mqttMsgReceived[] PROGMEM = "MQTT-message received";
const char trackPausedAtPos[] PROGMEM = "Track paused at position";
const char freeHeapWithoutFtp[] PROGMEM = "Free heap before FTP-allocation";
const char freeHeapWithFtp[] PROGMEM = "Free heap after FTP-allocation";
const char freeHeapAfterSetup[] PROGMEM = "Free heap after setup";
const char tryStaticIpConfig[] PROGMEM = "Performing IP-configuration...";
const char staticIPConfigFailed[] PROGMEM = "IP-configuration failed";
const char wakeUpRfidNoIso14443[] PROGMEM = "Wakeup caused by low power card-detection. RF-field changed but no ISO-14443 card on reader was found. So I'll return back to sleep now...";
const char lowPowerCardSuccess[] PROGMEM = "Switch to low power card-detection: success";
const char rememberLastVolume[] PROGMEM = "Restored volume used before last shutdown. This overwrites the initial volume configured via webgui.";
const char unableToStartFtpServer[] PROGMEM = "FTP-server cannot be started. This is because FTP-service is already active of because WiFi is unavailable.";
const char newPlayModeStereo[] PROGMEM = "New mode: stereo";
const char newPlayModeMono[] PROGMEM = "New mode: mono";
const char stillOnlineMqtt[] PROGMEM = "MQTT: still online.";
const char tryConnectMqttS[] PROGMEM = "Trying to connect to MQTT-broker";
const char mqttOk[] PROGMEM = "MQTT-connection established.";
const char sleepTimerEOP[] PROGMEM = "Sleep-timer: after last track of playlist.";
const char sleepTimerEOT[] PROGMEM = "Sleep-timer: after end of current track.";
const char sleepTimerStop[] PROGMEM = "Sleep-timer has been disabled.";
const char sleepTimerEO5[] PROGMEM = "Sleep-timer: after five track or end of playlist - whatever is reached first";
const char sleepTimerAlreadyStopped[] PROGMEM = "sleep-timer is already disabled.";
const char sleepTimerSetTo[] PROGMEM = "sleep-timer adjusted to";
const char allowButtons[] PROGMEM = "Unlocking all keys.";
const char lockButtons[] PROGMEM = "Locking all keys.";
const char noPlaylistNotAllowedMqtt[] PROGMEM = "Playmode cannot be adjusted to 'no playlist' via MQTT.";
const char playmodeChangedMQtt[] PROGMEM = "Playlist adjusted via MQTT.";
const char noPlaymodeChangeIfIdle[] PROGMEM = "Playlist cannot be adjusted while no playlist is active.";
const char noValidTopic[] PROGMEM = "No valid MQTT-topic";
const char freePtr[] PROGMEM = "Releasing Pointer";
const char freeMemory[] PROGMEM = "Free memory";
const char writeEntryToNvs[] PROGMEM = "Storing data to NVS";
const char freeMemoryAfterFree[] PROGMEM = "Free memory after cleaning";
const char releaseMemoryOfOldPlaylist[] PROGMEM = "Releasing memory of old playlist.";
const char dirOrFileDoesNotExist[] PROGMEM = "File of directory does not exist";
const char unableToAllocateMemForPlaylist[] PROGMEM = "Unable to allocate memory for playlist!";
const char unableToAllocateMem[] PROGMEM = "Unable to allocate memory!";
const char fileModeDetected[] PROGMEM = "File-mode detected.";
const char nameOfFileFound[] PROGMEM = "File found";
const char reallocCalled[] PROGMEM = "Reallocated memory.";
const char unableToAllocateMemForLinearPlaylist[] PROGMEM = "Unable to allocate memory for linear playlist!";
const char numberOfValidFiles[] PROGMEM = "Number of valid files";
const char newLoudnessReceivedQueue[] PROGMEM = "New volume received via queue";
const char newCntrlReceivedQueue[] PROGMEM = "Control-command received via queue";
const char newPlaylistReceived[] PROGMEM = "New playlist received";
const char repeatTrackDueToPlaymode[] PROGMEM = "Repeating track due to playmode configured.";
const char repeatPlaylistDueToPlaymode[] PROGMEM = "Repeating playlist due to playmode configured.";
const char cmndStop[] PROGMEM = "Command: stop";
const char cmndPause[] PROGMEM = "Command: pause";
const char cmndNextTrack[] PROGMEM = "Command: next track";
const char cmndPrevTrack[] PROGMEM = "Command: previous track";
const char cmndFirstTrack[] PROGMEM = "Command: first track of playlist";
const char cmndLastTrack[] PROGMEM = "Command: last track of playlist";
const char cmndDoesNotExist[] PROGMEM = "Command requested does not exist.";
const char lastTrackAlreadyActive[] PROGMEM = "Already playing last track.";
const char firstTrackAlreadyActive[] PROGMEM = "Already playing first track.";
const char trackStartAudiobook[] PROGMEM = "Starting track in playmode from the very beginning.";
const char trackStart[] PROGMEM = "Starting track from the very beginning.";
const char trackChangeWebstream[] PROGMEM = "Playing from the very beginning is not possible while webradio-mode is active.";
const char endOfPlaylistReached[] PROGMEM = "Reached end of playlist.";
const char trackStartatPos[] PROGMEM = "Starting track at position";
const char rfidScannerReady[] PROGMEM = "RFID-tags can now be applied...";
const char rfidTagDetected[] PROGMEM = "RFID-tag detected: ";
const char rfid15693TagDetected[] PROGMEM = "RFID-ta (ISO-15693) detected: ";
const char rfidTagReceived[] PROGMEM = "RFID-tag received";
const char rfidTagUnknownInNvs[] PROGMEM = "RFID-tag is unkown to NVS.";
const char goToSleepDueToIdle[] PROGMEM = "Going to deepsleep due to inactivity-timer...";
const char goToSleepDueToTimer[] PROGMEM = "Going to deepsleep due to sleep timer...";
const char goToSleepNow[] PROGMEM = "Going to deepsleep now!";
const char maxLoudnessReached[] PROGMEM = "Already reached max volume!";
const char minLoudnessReached[] PROGMEM = "Already reached min volume!";
const char errorOccured[] PROGMEM = "Error occured!";
const char noMp3FilesInDir[] PROGMEM = "Directory does not contain mp3-files.";
const char modeSingleTrack[] PROGMEM = "Mode: Single track";
const char modeSingleTrackLoop[] PROGMEM = "Mode: single track as infinite loop";
const char modeSingleAudiobook[] PROGMEM = "Mode: audiobook";
const char modeSingleAudiobookLoop[] PROGMEM = "Mode: audiobook as infinite loop";
const char modeAllTrackAlphSorted[] PROGMEM = "Mode: all tracks (in alph. order) of directory";
const char modeAllTrackRandom[] PROGMEM = "Mode: all tracks (in random. order) of directory";
const char modeAllTrackAlphSortedLoop[] PROGMEM = "Mode: all tracks (in alph. order) of directory as infinite loop";
const char modeAllTrackRandomLoop[] PROGMEM = "Mode: all tracks (in random order) of directory as infinite loop";
const char modeWebstream[] PROGMEM = "Mode: webstream";
const char webstreamNotAvailable[] PROGMEM = "Unable to access webstream as no wifi-connection is available!";
const char modeDoesNotExist[] PROGMEM = "Playmode does not exist!";
const char modeRepeatNone[] PROGMEM = "Repeatmode: no repeat";
const char modeRepeatTrack[] PROGMEM = "Repeatmode: current track";
const char modeRepeatPlaylist[] PROGMEM = "Repeatmode: whole playlist";
const char modeRepeatTracknPlaylist[] PROGMEM = "Repeatmode: track and playlist";
const char modificatorAllButtonsLocked[] PROGMEM = "Modificator: locking all keys via RFID-tag.";
const char modificatorAllButtonsUnlocked[] PROGMEM = "Modificator: unlocking all keys via RFID-tag.";
const char modificatorSleepd[] PROGMEM = "Modificator: sleep-Timer deactivated.";
const char modificatorSleepTimer15[] PROGMEM = "Modificator: sleep-Timer enabled via RFID (15 minutes).";
const char modificatorSleepTimer30[] PROGMEM = "Modificator: sleep-Timer enabled via RFID (30 minutes).";
const char modificatorSleepTimer60[] PROGMEM = "Modificator: sleep-Timer enabled via RFID (60 minutes).";
const char modificatorSleepTimer120[] PROGMEM = "Modificator: sleep-Timer enabled via RFID (2 hours).";
const char ledsDimmedToNightmode[] PROGMEM = "Dimmed LEDs to nightmode.";
const char modificatorNotallowedWhenIdle[] PROGMEM = "Modificator cannot be applied while playlist is inactive.";
const char modificatorSleepAtEOT[] PROGMEM = "Modificator: adjusted sleep-timer to after end of current track.";
const char modificatorSleepAtEOTd[] PROGMEM = "Modificator: disabled sleep-timer after end of current track.";
const char modificatorSleepAtEOP[] PROGMEM = "Modificator: adjusted sleep-timer to after end of playlist.";
const char modificatorSleepAtEOPd[] PROGMEM = "Modificator: disabled sleep-timer after end of playlist.";
const char modificatorAllTrackAlphSortedLoop[] PROGMEM = "Modificator: adjusted to all tracks (in alph. order) as infinite loop.";
const char modificatorAllTrackRandomLoop[] PROGMEM = "Modificator: adjusted to all tracks (in random order) as infinite loop.";
const char modificatorCurTrackLoop[] PROGMEM = "Modificator: adjusted to current track as infinite loop.";
const char modificatorCurAudiobookLoop[] PROGMEM = "Modificator: adjusted to current audiobook as infinite loop.";
const char modificatorPlaylistLoopActive[] PROGMEM = "Modificator: adjusted to all tracks as infinite loop.";
const char modificatorPlaylistLoopDeactive[] PROGMEM = "Modificator: disabled all tracks as infinite loop.";
const char modificatorTrackActive[] PROGMEM = "Modificator: adjusted to current track as infinite loop.";
const char modificatorTrackDeactive[] PROGMEM = "Modificator: disabled current track as infinite loop.";
const char modificatorNotAllowed[] PROGMEM = "Unable to apply modificator.";
const char modificatorLoopRev[] PROGMEM = "Modificator: infinite loop ended.";
const char modificatorDoesNotExist[] PROGMEM = "This type of card-modificator does not exist";
const char errorOccuredNvs[] PROGMEM = "Error occured while reading from NVS!";
const char statementsReceivedByServer[] PROGMEM = "Data received from server";
const char savedSsidInNvs[] PROGMEM = "Storing SSID to NVS";
const char savedWifiPwdInNvs[] PROGMEM = "Storing wifi-password to NVS";
const char apReady[] PROGMEM = "Started wifi-access-point";
const char httpReady[] PROGMEM = "Started HTTP-server.";
const char unableToMountSd[] PROGMEM = "Unable to mount sd-card.";
const char unableToCreateVolQ[] PROGMEM = "Unable to create volume-queue.";
const char unableToCreateRfidQ[] PROGMEM = "Unable to create RFID-queue.";
const char unableToCreateMgmtQ[] PROGMEM = "Unable to play-management-queue.";
const char unableToCreatePlayQ[] PROGMEM = "Unable to create track-queue..";
const char initialBrightnessfromNvs[] PROGMEM = "Restoring initial LED-brightness from NVS";
const char wroteInitialBrightnessToNvs[] PROGMEM = "Storing initial LED-brightness to NVS.";
const char restoredInitialBrightnessForNmFromNvs[] PROGMEM = "Restored LED-brightness for nightmode from NVS";
const char wroteNmBrightnessToNvs[] PROGMEM = "Stored LED-brightness for nightmode to NVS.";
const char wroteFtpUserToNvs[] PROGMEM = "Stored FTP-user to NVS.";
const char restoredFtpUserFromNvs[] PROGMEM = "Restored FTP-user from NVS";
const char wroteFtpPwdToNvs[] PROGMEM = "Stored FTP-password to NVS.";
const char restoredFtpPwdFromNvs[] PROGMEM = "Restored FTP-password from NVS";
const char restoredMaxInactivityFromNvs[] PROGMEM = "Restored maximum inactivity-time from NVS.";
const char wroteMaxInactivityToNvs[] PROGMEM = "Stored maximum inactivity-time to NVS.";
const char restoredInitialLoudnessFromNvs[] PROGMEM = "Restored initial volume from NVS";
const char wroteInitialLoudnessToNvs[] PROGMEM = "Stored initial volume to NVS.";
const char restoredMaxLoudnessForSpeakerFromNvs[] PROGMEM = "Restored maximum volume for speaker from NVS";
const char restoredMaxLoudnessForHeadphoneFromNvs[] PROGMEM = "Restored maximum volume for headphone from NVS";
const char wroteMaxLoudnessForSpeakerToNvs[] PROGMEM = "Wrote maximum volume for speaker to NVS.";
const char wroteMaxLoudnessForHeadphoneToNvs[] PROGMEM = "Wrote maximum volume for headphone to NVS.";
const char maxVolumeSet[] PROGMEM = "Maximum volume set to";
const char wroteMqttFlagToNvs[] PROGMEM = "Stored MQTT-flag to NVS.";
const char restoredMqttActiveFromNvs[] PROGMEM = "Restored MQTT-flag (enabled) from NVS";
const char restoredMqttDeactiveFromNvs[] PROGMEM = "Restored MQTT-flag (disabled) from NVS";
const char wroteMqttServerToNvs[] PROGMEM = "Stored MQTT-server to NVS.";
const char restoredMqttServerFromNvs[] PROGMEM = "Restored MQTT-Server from NVS";
const char wroteMqttUserToNvs[] PROGMEM = "Stored MQTT-user to NVS.";
const char restoredMqttUserFromNvs[] PROGMEM = "Restored MQTT-user from NVS";
const char wroteMqttPwdToNvs[] PROGMEM = "Stored MQTT-password to NVS.";
const char restoredMqttPwdFromNvs[] PROGMEM = "Restored MQTT-password from NVS";
const char restoredMqttPortFromNvs[] PROGMEM = "Restored MQTT-port from NVS";
const char mqttWithPwd[] PROGMEM = "Try to connect to MQTT-server with user und password";
const char mqttWithoutPwd[] PROGMEM = "Try to connect to MQTT-server without user und password";
const char ssidNotFoundInNvs[] PROGMEM = "Unable to find SSID to NVS.";
const char wifiPwdNotFoundInNvs[] PROGMEM = "Unable to find wifi-password to NVS.";
const char wifiStaticIpConfigNotFoundInNvs[] PROGMEM = "Unable to find wifi-ip-configuration to NVS.";
const char wifiHostnameNotSet[] PROGMEM = "Unable to find hostname-configuration to NVS.";
const char mqttConnFailed[] PROGMEM = "Unable to establish mqtt-connection, trying again...";
const char restoredHostnameFromNvs[] PROGMEM = "Restored hostname from NVS";
const char currentVoltageMsg[] PROGMEM = "Current battery-voltage";
const char voltageTooLow[] PROGMEM = "Low battery-voltage";
const char sdBootFailedDeepsleep[] PROGMEM = "Failed to boot due to SD. Will go to deepsleep...";
const char wifiEnabledAfterRestart[] PROGMEM = "WiFi will be enabled.";
const char wifiDisabledAfterRestart[] PROGMEM = "WiFi will be disabled .";
const char voltageIndicatorLowFromNVS[] PROGMEM = "Restored lower voltage-level for Neopixel-display from NVS";
const char voltageIndicatorHighFromNVS[] PROGMEM = "Restored upper voltage-level for Neopixel-display from NVS";
const char voltageCheckIntervalFromNVS[] PROGMEM = "Restored interval of battery-measurement or Neopixel-display from NVS";
const char warningLowVoltageFromNVS[] PROGMEM = "Restored battery-voltage-level for warning via Neopixel from NVS";
const char unableToRestoreLastRfidFromNVS[] PROGMEM = "Unable to restore last RFID from NVS";
const char restoredLastRfidFromNVS[] PROGMEM = "Restored last RFID from NVS";
const char failedOpenFileForWrite[] PROGMEM = "Failed to open file for writing";
const char fileWritten[] PROGMEM = "File written";
const char writeFailed[] PROGMEM = "Write failed";
const char writingFile[] PROGMEM = "Writing file";
const char failedToOpenFileForAppending[] PROGMEM = "Failed to open file for appending";
const char listingDirectory[] PROGMEM = "Listing directory";
const char failedToOpenDirectory[] PROGMEM = "Failed to open directory";
const char notADirectory[] PROGMEM = "Not a directory";
const char sdMountedMmc1BitMode[] PROGMEM = "SD card mounted in SPI-mode configured...";
const char sdMountedSpiMode[] PROGMEM = "Mounting SD card in SPI-mode...";
const char backupRecoveryWebsite[] PROGMEM = "<p>Backup-file is being applied...<br />Back to <a href=\"javascript:history.back()\">last page</a>.</p>";
const char restartWebsite[] PROGMEM = "<p>ESPuino is being restarted...<br />Back to <a href=\"javascript:history.back()\">last page</a>.</p>";
const char shutdownWebsite[] PROGMEM = "<p>Der ESPuino is being shutdown...</p>";
const char mqttMsgReceived[] PROGMEM = "MQTT-message received";
const char trackPausedAtPos[] PROGMEM = "Track paused at position";
const char freeHeapWithoutFtp[] PROGMEM = "Free heap before FTP-allocation";
const char freeHeapWithFtp[] PROGMEM = "Free heap after FTP-allocation";
const char freeHeapAfterSetup[] PROGMEM = "Free heap after setup";
const char tryStaticIpConfig[] PROGMEM = "Performing IP-configuration...";
const char staticIPConfigFailed[] PROGMEM = "IP-configuration failed";
const char wakeUpRfidNoIso14443[] PROGMEM = "Wakeup caused by low power card-detection. RF-field changed but no ISO-14443 card on reader was found. So I'll return back to sleep now...";
const char lowPowerCardSuccess[] PROGMEM = "Switch to low power card-detection: success";
const char rememberLastVolume[] PROGMEM = "Restored volume used before last shutdown. This overwrites the initial volume configured via webgui.";
const char unableToStartFtpServer[] PROGMEM = "FTP-server cannot be started. This is because FTP-service is already active of because WiFi is unavailable.";
const char newPlayModeStereo[] PROGMEM = "New mode: stereo";
const char newPlayModeMono[] PROGMEM = "New mode: mono";
#endif #endif

759
src/Mqtt.cpp

@ -19,14 +19,14 @@ constexpr uint8_t stillOnlineInterval = 60u; // Interval 'I'm still alive' is se
// MQTT-helper // MQTT-helper
#ifdef MQTT_ENABLE #ifdef MQTT_ENABLE
static WiFiClient Mqtt_WifiClient;
static PubSubClient Mqtt_PubSubClient(Mqtt_WifiClient);
static WiFiClient Mqtt_WifiClient;
static PubSubClient Mqtt_PubSubClient(Mqtt_WifiClient);
#endif #endif
// Please note: all of them are defaults that can be changed later via GUI // Please note: all of them are defaults that can be changed later via GUI
char *gMqttServer = x_strndup((char *)"192.168.2.43", mqttServerLength); // IP-address of MQTT-server (if not found in NVS this one will be taken)
char *gMqttUser = x_strndup((char *)"mqtt-user", mqttUserLength); // MQTT-user
char *gMqttPassword = x_strndup((char *)"mqtt-password", mqttPasswordLength); // MQTT-password*/
char *gMqttServer = x_strndup((char *) "192.168.2.43", mqttServerLength); // IP-address of MQTT-server (if not found in NVS this one will be taken)
char *gMqttUser = x_strndup((char *) "mqtt-user", mqttUserLength); // MQTT-user
char *gMqttPassword = x_strndup((char *) "mqtt-password", mqttPasswordLength); // MQTT-password*/
uint16_t gMqttPort = 1883; // MQTT-Port uint16_t gMqttPort = 1883; // MQTT-Port
// MQTT // MQTT
@ -36,481 +36,406 @@ static void Mqtt_ClientCallback(const char *topic, const byte *payload, uint32_t
static bool Mqtt_Reconnect(void); static bool Mqtt_Reconnect(void);
static void Mqtt_PostHeartbeatViaMqtt(void); static void Mqtt_PostHeartbeatViaMqtt(void);
void Mqtt_Init()
{
#ifdef MQTT_ENABLE
// Get MQTT-enable from NVS
uint8_t nvsEnableMqtt = gPrefsSettings.getUChar("enableMQTT", 99);
switch (nvsEnableMqtt)
{
case 99:
gPrefsSettings.putUChar("enableMQTT", Mqtt_Enabled);
Log_Println((char *)FPSTR(wroteMqttFlagToNvs), LOGLEVEL_ERROR);
break;
case 1:
Mqtt_Enabled = nvsEnableMqtt;
snprintf(Log_Buffer, Log_BufferLength, "%s: %u", (char *)FPSTR(restoredMqttActiveFromNvs), nvsEnableMqtt);
Log_Println(Log_Buffer, LOGLEVEL_INFO);
break;
case 0:
Mqtt_Enabled = nvsEnableMqtt;
snprintf(Log_Buffer, Log_BufferLength, "%s: %u", (char *)FPSTR(restoredMqttDeactiveFromNvs), nvsEnableMqtt);
Log_Println(Log_Buffer, LOGLEVEL_INFO);
break;
}
// Get MQTT-server from NVS
String nvsMqttServer = gPrefsSettings.getString("mqttServer", "-1");
if (!nvsMqttServer.compareTo("-1"))
{
gPrefsSettings.putString("mqttServer", (String)gMqttServer);
Log_Println((char *)FPSTR(wroteMqttServerToNvs), LOGLEVEL_ERROR);
}
else
{
strncpy(gMqttServer, nvsMqttServer.c_str(), mqttServerLength);
snprintf(Log_Buffer, Log_BufferLength, "%s: %s", (char *)FPSTR(restoredMqttServerFromNvs), nvsMqttServer.c_str());
Log_Println(Log_Buffer, LOGLEVEL_INFO);
}
// Get MQTT-user from NVS
String nvsMqttUser = gPrefsSettings.getString("mqttUser", "-1");
if (!nvsMqttUser.compareTo("-1"))
{
gPrefsSettings.putString("mqttUser", (String)gMqttUser);
Log_Println((char *)FPSTR(wroteMqttUserToNvs), LOGLEVEL_ERROR);
}
else
{
strncpy(gMqttUser, nvsMqttUser.c_str(), mqttUserLength);
snprintf(Log_Buffer, Log_BufferLength, "%s: %s", (char *)FPSTR(restoredMqttUserFromNvs), nvsMqttUser.c_str());
Log_Println(Log_Buffer, LOGLEVEL_INFO);
}
// Get MQTT-password from NVS
String nvsMqttPassword = gPrefsSettings.getString("mqttPassword", "-1");
if (!nvsMqttPassword.compareTo("-1"))
{
gPrefsSettings.putString("mqttPassword", (String)gMqttPassword);
Log_Println((char *)FPSTR(wroteMqttPwdToNvs), LOGLEVEL_ERROR);
}
else
{
strncpy(gMqttPassword, nvsMqttPassword.c_str(), mqttPasswordLength);
snprintf(Log_Buffer, Log_BufferLength, "%s: %s", (char *)FPSTR(restoredMqttPwdFromNvs), nvsMqttPassword.c_str());
Log_Println(Log_Buffer, LOGLEVEL_INFO);
}
// Get MQTT-password from NVS
uint32_t nvsMqttPort = gPrefsSettings.getUInt("mqttPort", 99999);
if (nvsMqttPort == 99999)
{
gPrefsSettings.putUInt("mqttPort", gMqttPort);
}
else
{
gMqttPort = nvsMqttPort;
snprintf(Log_Buffer, Log_BufferLength, "%s: %u", (char *)FPSTR(restoredMqttPortFromNvs), gMqttPort);
Log_Println(Log_Buffer, LOGLEVEL_INFO);
}
// Only enable MQTT if requested
if (Mqtt_Enabled)
{
Mqtt_PubSubClient.setServer(gMqttServer, gMqttPort);
Mqtt_PubSubClient.setCallback(Mqtt_ClientCallback);
}
#endif
void Mqtt_Init() {
#ifdef MQTT_ENABLE
// Get MQTT-enable from NVS
uint8_t nvsEnableMqtt = gPrefsSettings.getUChar("enableMQTT", 99);
switch (nvsEnableMqtt) {
case 99:
gPrefsSettings.putUChar("enableMQTT", Mqtt_Enabled);
Log_Println((char *) FPSTR(wroteMqttFlagToNvs), LOGLEVEL_ERROR);
break;
case 1:
Mqtt_Enabled = nvsEnableMqtt;
snprintf(Log_Buffer, Log_BufferLength, "%s: %u", (char *) FPSTR(restoredMqttActiveFromNvs), nvsEnableMqtt);
Log_Println(Log_Buffer, LOGLEVEL_INFO);
break;
case 0:
Mqtt_Enabled = nvsEnableMqtt;
snprintf(Log_Buffer, Log_BufferLength, "%s: %u", (char *) FPSTR(restoredMqttDeactiveFromNvs), nvsEnableMqtt);
Log_Println(Log_Buffer, LOGLEVEL_INFO);
break;
}
// Get MQTT-server from NVS
String nvsMqttServer = gPrefsSettings.getString("mqttServer", "-1");
if (!nvsMqttServer.compareTo("-1")) {
gPrefsSettings.putString("mqttServer", (String)gMqttServer);
Log_Println((char *) FPSTR(wroteMqttServerToNvs), LOGLEVEL_ERROR);
} else {
strncpy(gMqttServer, nvsMqttServer.c_str(), mqttServerLength);
snprintf(Log_Buffer, Log_BufferLength, "%s: %s", (char *) FPSTR(restoredMqttServerFromNvs), nvsMqttServer.c_str());
Log_Println(Log_Buffer, LOGLEVEL_INFO);
}
// Get MQTT-user from NVS
String nvsMqttUser = gPrefsSettings.getString("mqttUser", "-1");
if (!nvsMqttUser.compareTo("-1")) {
gPrefsSettings.putString("mqttUser", (String)gMqttUser);
Log_Println((char *) FPSTR(wroteMqttUserToNvs), LOGLEVEL_ERROR);
} else {
strncpy(gMqttUser, nvsMqttUser.c_str(), mqttUserLength);
snprintf(Log_Buffer, Log_BufferLength, "%s: %s", (char *) FPSTR(restoredMqttUserFromNvs), nvsMqttUser.c_str());
Log_Println(Log_Buffer, LOGLEVEL_INFO);
}
// Get MQTT-password from NVS
String nvsMqttPassword = gPrefsSettings.getString("mqttPassword", "-1");
if (!nvsMqttPassword.compareTo("-1")) {
gPrefsSettings.putString("mqttPassword", (String)gMqttPassword);
Log_Println((char *) FPSTR(wroteMqttPwdToNvs), LOGLEVEL_ERROR);
} else {
strncpy(gMqttPassword, nvsMqttPassword.c_str(), mqttPasswordLength);
snprintf(Log_Buffer, Log_BufferLength, "%s: %s", (char *) FPSTR(restoredMqttPwdFromNvs), nvsMqttPassword.c_str());
Log_Println(Log_Buffer, LOGLEVEL_INFO);
}
// Get MQTT-password from NVS
uint32_t nvsMqttPort = gPrefsSettings.getUInt("mqttPort", 99999);
if (nvsMqttPort == 99999) {
gPrefsSettings.putUInt("mqttPort", gMqttPort);
} else {
gMqttPort = nvsMqttPort;
snprintf(Log_Buffer, Log_BufferLength, "%s: %u", (char *) FPSTR(restoredMqttPortFromNvs), gMqttPort);
Log_Println(Log_Buffer, LOGLEVEL_INFO);
}
// Only enable MQTT if requested
if (Mqtt_Enabled) {
Mqtt_PubSubClient.setServer(gMqttServer, gMqttPort);
Mqtt_PubSubClient.setCallback(Mqtt_ClientCallback);
}
#endif
} }
void Mqtt_Cyclic(void)
{
#ifdef MQTT_ENABLE
if (Mqtt_Enabled && Wlan_IsConnected())
{
Mqtt_Reconnect();
Mqtt_PubSubClient.loop();
Mqtt_PostHeartbeatViaMqtt();
}
#endif
void Mqtt_Cyclic(void) {
#ifdef MQTT_ENABLE
if (Mqtt_Enabled && Wlan_IsConnected()) {
Mqtt_Reconnect();
Mqtt_PubSubClient.loop();
Mqtt_PostHeartbeatViaMqtt();
}
#endif
} }
void Mqtt_Exit(void)
{
#ifdef MQTT_ENABLE
publishMqtt((char *)FPSTR(topicState), "Offline", false);
publishMqtt((char *)FPSTR(topicTrackState), "---", false);
Mqtt_PubSubClient.disconnect();
#endif
void Mqtt_Exit(void) {
#ifdef MQTT_ENABLE
publishMqtt((char *) FPSTR(topicState), "Offline", false);
publishMqtt((char *) FPSTR(topicTrackState), "---", false);
Mqtt_PubSubClient.disconnect();
#endif
} }
bool Mqtt_IsEnabled(void)
{
bool Mqtt_IsEnabled(void) {
return Mqtt_Enabled; return Mqtt_Enabled;
} }
/* Wrapper-functions for MQTT-publish */ /* Wrapper-functions for MQTT-publish */
bool publishMqtt(const char *topic, const char *payload, bool retained)
{
#ifdef MQTT_ENABLE
if (strcmp(topic, "") != 0)
{
if (Mqtt_PubSubClient.connected())
{
Mqtt_PubSubClient.publish(topic, payload, retained);
delay(100);
return true;
bool publishMqtt(const char *topic, const char *payload, bool retained) {
#ifdef MQTT_ENABLE
if (strcmp(topic, "") != 0) {
if (Mqtt_PubSubClient.connected()) {
Mqtt_PubSubClient.publish(topic, payload, retained);
delay(100);
return true;
}
} }
}
#endif
#endif
return false; return false;
} }
bool publishMqtt(const char *topic, int32_t payload, bool retained)
{
#ifdef MQTT_ENABLE
char buf[11];
snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%d", payload);
return publishMqtt(topic, buf, retained);
#else
return false;
#endif
bool publishMqtt(const char *topic, int32_t payload, bool retained) {
#ifdef MQTT_ENABLE
char buf[11];
snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%d", payload);
return publishMqtt(topic, buf, retained);
#else
return false;
#endif
} }
bool publishMqtt(const char *topic, unsigned long payload, bool retained)
{
#ifdef MQTT_ENABLE
char buf[11];
snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%lu", payload);
return publishMqtt(topic, buf, retained);
#else
return false;
#endif
bool publishMqtt(const char *topic, unsigned long payload, bool retained) {
#ifdef MQTT_ENABLE
char buf[11];
snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%lu", payload);
return publishMqtt(topic, buf, retained);
#else
return false;
#endif
} }
bool publishMqtt(const char *topic, uint32_t payload, bool retained)
{
#ifdef MQTT_ENABLE
char buf[11];
snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%u", payload);
return publishMqtt(topic, buf, retained);
#else
return false;
#endif
bool publishMqtt(const char *topic, uint32_t payload, bool retained) {
#ifdef MQTT_ENABLE
char buf[11];
snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%u", payload);
return publishMqtt(topic, buf, retained);
#else
return false;
#endif
} }
/* Cyclic posting via MQTT that ESP is still alive. Use case: when ESPuino is switched off, it will post via /* Cyclic posting via MQTT that ESP is still alive. Use case: when ESPuino is switched off, it will post via
MQTT it's gonna be offline now. But when unplugging ESPuino e.g. openHAB doesn't know ESPuino is offline. MQTT it's gonna be offline now. But when unplugging ESPuino e.g. openHAB doesn't know ESPuino is offline.
One way to recognize this is to determine, when a topic has been updated for the last time. So by One way to recognize this is to determine, when a topic has been updated for the last time. So by
telling openHAB connection is timed out after 2mins for instance, this is the right topic to check for. */ telling openHAB connection is timed out after 2mins for instance, this is the right topic to check for. */
void Mqtt_PostHeartbeatViaMqtt(void)
{
#ifdef MQTT_ENABLE
static unsigned long lastOnlineTimestamp = 0u;
if (millis() - lastOnlineTimestamp >= stillOnlineInterval * 1000)
{
lastOnlineTimestamp = millis();
if (publishMqtt((char *)FPSTR(topicState), "Online", false))
{
Log_Println((char *)FPSTR(stillOnlineMqtt), LOGLEVEL_DEBUG);
void Mqtt_PostHeartbeatViaMqtt(void) {
#ifdef MQTT_ENABLE
static unsigned long lastOnlineTimestamp = 0u;
if (millis() - lastOnlineTimestamp >= stillOnlineInterval * 1000) {
lastOnlineTimestamp = millis();
if (publishMqtt((char *) FPSTR(topicState), "Online", false)) {
Log_Println((char *) FPSTR(stillOnlineMqtt), LOGLEVEL_DEBUG);
}
} }
}
#endif
#endif
} }
/* Connects/reconnects to MQTT-Broker unless connection is not already available. /* Connects/reconnects to MQTT-Broker unless connection is not already available.
Manages MQTT-subscriptions. Manages MQTT-subscriptions.
*/ */
bool Mqtt_Reconnect()
{
#ifdef MQTT_ENABLE
static uint32_t mqttLastRetryTimestamp = 0u;
uint8_t connect = false;
uint8_t i = 0;
if (!mqttLastRetryTimestamp || millis() - mqttLastRetryTimestamp >= mqttRetryInterval * 1000)
{
mqttLastRetryTimestamp = millis();
}
else
{
return false;
}
while (!Mqtt_PubSubClient.connected() && i < mqttMaxRetriesPerInterval)
{
i++;
snprintf(Log_Buffer, Log_BufferLength, "%s %s", (char *)FPSTR(tryConnectMqttS), gMqttServer);
Log_Println(Log_Buffer, LOGLEVEL_NOTICE);
// Try to connect to MQTT-server. If username AND password are set, they'll be used
if (strlen(gMqttUser) < 1 || strlen(gMqttPassword) < 1)
{
Log_Println((char *)FPSTR(mqttWithoutPwd), LOGLEVEL_NOTICE);
if (Mqtt_PubSubClient.connect(DEVICE_HOSTNAME))
{
connect = true;
}
bool Mqtt_Reconnect() {
#ifdef MQTT_ENABLE
static uint32_t mqttLastRetryTimestamp = 0u;
uint8_t connect = false;
uint8_t i = 0;
if (!mqttLastRetryTimestamp || millis() - mqttLastRetryTimestamp >= mqttRetryInterval * 1000) {
mqttLastRetryTimestamp = millis();
} else {
return false;
} }
else
{
Log_Println((char *)FPSTR(mqttWithPwd), LOGLEVEL_NOTICE);
if (Mqtt_PubSubClient.connect(DEVICE_HOSTNAME, gMqttUser, gMqttPassword))
{
connect = true;
while (!Mqtt_PubSubClient.connected() && i < mqttMaxRetriesPerInterval) {
i++;
snprintf(Log_Buffer, Log_BufferLength, "%s %s", (char *) FPSTR(tryConnectMqttS), gMqttServer);
Log_Println(Log_Buffer, LOGLEVEL_NOTICE);
// Try to connect to MQTT-server. If username AND password are set, they'll be used
if (strlen(gMqttUser) < 1 || strlen(gMqttPassword) < 1) {
Log_Println((char *) FPSTR(mqttWithoutPwd), LOGLEVEL_NOTICE);
if (Mqtt_PubSubClient.connect(DEVICE_HOSTNAME)) {
connect = true;
}
} else {
Log_Println((char *) FPSTR(mqttWithPwd), LOGLEVEL_NOTICE);
if (Mqtt_PubSubClient.connect(DEVICE_HOSTNAME, gMqttUser, gMqttPassword)) {
connect = true;
}
} }
}
if (connect)
{
Log_Println((char *)FPSTR(mqttOk), LOGLEVEL_NOTICE);
if (connect) {
Log_Println((char *) FPSTR(mqttOk), LOGLEVEL_NOTICE);
// Deepsleep-subscription
Mqtt_PubSubClient.subscribe((char *)FPSTR(topicSleepCmnd));
// Deepsleep-subscription
Mqtt_PubSubClient.subscribe((char *) FPSTR(topicSleepCmnd));
// RFID-Tag-ID-subscription
Mqtt_PubSubClient.subscribe((char *)FPSTR(topicRfidCmnd));
// RFID-Tag-ID-subscription
Mqtt_PubSubClient.subscribe((char *) FPSTR(topicRfidCmnd));
// Loudness-subscription
Mqtt_PubSubClient.subscribe((char *)FPSTR(topicLoudnessCmnd));
// Loudness-subscription
Mqtt_PubSubClient.subscribe((char *) FPSTR(topicLoudnessCmnd));
// Sleep-Timer-subscription
Mqtt_PubSubClient.subscribe((char *)FPSTR(topicSleepTimerCmnd));
// Sleep-Timer-subscription
Mqtt_PubSubClient.subscribe((char *) FPSTR(topicSleepTimerCmnd));
// Next/previous/stop/play-track-subscription
Mqtt_PubSubClient.subscribe((char *)FPSTR(topicTrackControlCmnd));
// Next/previous/stop/play-track-subscription
Mqtt_PubSubClient.subscribe((char *) FPSTR(topicTrackControlCmnd));
// Lock controls
Mqtt_PubSubClient.subscribe((char *)FPSTR(topicLockControlsCmnd));
// Lock controls
Mqtt_PubSubClient.subscribe((char *) FPSTR(topicLockControlsCmnd));
// Current repeat-Mode
Mqtt_PubSubClient.subscribe((char *)FPSTR(topicRepeatModeCmnd));
// Current repeat-Mode
Mqtt_PubSubClient.subscribe((char *) FPSTR(topicRepeatModeCmnd));
// LED-brightness
Mqtt_PubSubClient.subscribe((char *)FPSTR(topicLedBrightnessCmnd));
// LED-brightness
Mqtt_PubSubClient.subscribe((char *) FPSTR(topicLedBrightnessCmnd));
// Publish some stuff
publishMqtt((char *)FPSTR(topicState), "Online", false);
publishMqtt((char *)FPSTR(topicTrackState), "---", false);
publishMqtt((char *)FPSTR(topicLoudnessState), AudioPlayer_GetCurrentVolume(), false);
publishMqtt((char *)FPSTR(topicSleepTimerState), System_GetSleepTimerTimeStamp(), false);
publishMqtt((char *)FPSTR(topicLockControlsState), "OFF", false);
publishMqtt((char *)FPSTR(topicPlaymodeState), gPlayProperties.playMode, false);
publishMqtt((char *)FPSTR(topicLedBrightnessState), Led_GetBrightness(), false);
publishMqtt((char *)FPSTR(topicRepeatModeState), 0, false);
publishMqtt((char *)FPSTR(topicCurrentIPv4IP), Wlan_GetIpAddress().c_str(), false);
// Publish some stuff
publishMqtt((char *) FPSTR(topicState), "Online", false);
publishMqtt((char *) FPSTR(topicTrackState), "---", false);
publishMqtt((char *) FPSTR(topicLoudnessState), AudioPlayer_GetCurrentVolume(), false);
publishMqtt((char *) FPSTR(topicSleepTimerState), System_GetSleepTimerTimeStamp(), false);
publishMqtt((char *) FPSTR(topicLockControlsState), "OFF", false);
publishMqtt((char *) FPSTR(topicPlaymodeState), gPlayProperties.playMode, false);
publishMqtt((char *) FPSTR(topicLedBrightnessState), Led_GetBrightness(), false);
publishMqtt((char *) FPSTR(topicRepeatModeState), 0, false);
publishMqtt((char *) FPSTR(topicCurrentIPv4IP), Wlan_GetIpAddress().c_str(), false);
return Mqtt_PubSubClient.connected();
}
else
{
snprintf(Log_Buffer, Log_BufferLength, "%s: rc=%i (%d / %d)", (char *)FPSTR(mqttConnFailed), Mqtt_PubSubClient.state(), i, mqttMaxRetriesPerInterval);
Log_Println(Log_Buffer, LOGLEVEL_ERROR);
return Mqtt_PubSubClient.connected();
} else {
snprintf(Log_Buffer, Log_BufferLength, "%s: rc=%i (%d / %d)", (char *) FPSTR(mqttConnFailed), Mqtt_PubSubClient.state(), i, mqttMaxRetriesPerInterval);
Log_Println(Log_Buffer, LOGLEVEL_ERROR);
}
} }
}
return false;
#endif
return false;
#endif
} }
// Is called if there's a new MQTT-message for us // Is called if there's a new MQTT-message for us
void Mqtt_ClientCallback(const char *topic, const byte *payload, uint32_t length)
{
#ifdef MQTT_ENABLE
char *receivedString = x_strndup((char *)payload, length);
char *mqttTopic = x_strdup(topic);
snprintf(Log_Buffer, Log_BufferLength, "%s: [Topic: %s] [Command: %s]", (char *)FPSTR(mqttMsgReceived), mqttTopic, receivedString);
Log_Println(Log_Buffer, LOGLEVEL_INFO);
// Go to sleep?
if (strcmp_P(topic, topicSleepCmnd) == 0)
{
if ((strcmp(receivedString, "OFF") == 0) || (strcmp(receivedString, "0") == 0))
{
System_RequestSleep();
}
}
// New track to play? Take RFID-ID as input
else if (strcmp_P(topic, topicRfidCmnd) == 0)
{
char *_rfidId = x_strdup(receivedString);
xQueueSend(gRfidCardQueue, &_rfidId, 0);
//free(_rfidId);
}
// Loudness to change?
else if (strcmp_P(topic, topicLoudnessCmnd) == 0)
{
unsigned long vol = strtoul(receivedString, NULL, 10);
AudioPlayer_VolumeToQueueSender(vol, true);
}
// Modify sleep-timer?
else if (strcmp_P(topic, topicSleepTimerCmnd) == 0)
{
if (gPlayProperties.playMode == NO_PLAYLIST)
{ // Don't allow sleep-modications if no playlist is active
Log_Println((char *)FPSTR(modificatorNotallowedWhenIdle), LOGLEVEL_INFO);
publishMqtt((char *)FPSTR(topicSleepState), 0, false);
System_IndicateError();
return;
void Mqtt_ClientCallback(const char *topic, const byte *payload, uint32_t length) {
#ifdef MQTT_ENABLE
char *receivedString = x_strndup((char *) payload, length);
char *mqttTopic = x_strdup(topic);
snprintf(Log_Buffer, Log_BufferLength, "%s: [Topic: %s] [Command: %s]", (char *) FPSTR(mqttMsgReceived), mqttTopic, receivedString);
Log_Println(Log_Buffer, LOGLEVEL_INFO);
// Go to sleep?
if (strcmp_P(topic, topicSleepCmnd) == 0) {
if ((strcmp(receivedString, "OFF") == 0) || (strcmp(receivedString, "0") == 0)) {
System_RequestSleep();
}
} }
if (strcmp(receivedString, "EOP") == 0)
{
gPlayProperties.sleepAfterPlaylist = true;
Log_Println((char *)FPSTR(sleepTimerEOP), LOGLEVEL_NOTICE);
System_IndicateOk();
return;
// New track to play? Take RFID-ID as input
else if (strcmp_P(topic, topicRfidCmnd) == 0) {
char *_rfidId = x_strdup(receivedString);
xQueueSend(gRfidCardQueue, _rfidId, 0);
} }
else if (strcmp(receivedString, "EOT") == 0)
{
gPlayProperties.sleepAfterCurrentTrack = true;
Log_Println((char *)FPSTR(sleepTimerEOT), LOGLEVEL_NOTICE);
System_IndicateOk();
return;
// Loudness to change?
else if (strcmp_P(topic, topicLoudnessCmnd) == 0) {
unsigned long vol = strtoul(receivedString, NULL, 10);
AudioPlayer_VolumeToQueueSender(vol, true);
} }
else if (strcmp(receivedString, "EO5T") == 0)
{
if ((gPlayProperties.numberOfTracks - 1) >= (gPlayProperties.currentTrackNumber + 5))
{
gPlayProperties.playUntilTrackNumber = gPlayProperties.currentTrackNumber + 5;
// Modify sleep-timer?
else if (strcmp_P(topic, topicSleepTimerCmnd) == 0) {
if (gPlayProperties.playMode == NO_PLAYLIST) { // Don't allow sleep-modications if no playlist is active
Log_Println((char *) FPSTR(modificatorNotallowedWhenIdle), LOGLEVEL_INFO);
publishMqtt((char *) FPSTR(topicSleepState), 0, false);
System_IndicateError();
return;
} }
else
{
if (strcmp(receivedString, "EOP") == 0) {
gPlayProperties.sleepAfterPlaylist = true; gPlayProperties.sleepAfterPlaylist = true;
}
Log_Println((char *)FPSTR(sleepTimerEO5), LOGLEVEL_NOTICE);
System_IndicateOk();
return;
}
else if (strcmp(receivedString, "0") == 0)
{
if (System_IsSleepTimerEnabled())
{
System_DisableSleepTimer();
Log_Println((char *)FPSTR(sleepTimerStop), LOGLEVEL_NOTICE);
Log_Println((char *) FPSTR(sleepTimerEOP), LOGLEVEL_NOTICE);
System_IndicateOk(); System_IndicateOk();
publishMqtt((char *)FPSTR(topicSleepState), 0, false);
return; return;
}
else
{
Log_Println((char *)FPSTR(sleepTimerAlreadyStopped), LOGLEVEL_INFO);
System_IndicateError();
} else if (strcmp(receivedString, "EOT") == 0) {
gPlayProperties.sleepAfterCurrentTrack = true;
Log_Println((char *) FPSTR(sleepTimerEOT), LOGLEVEL_NOTICE);
System_IndicateOk();
return; return;
} else if (strcmp(receivedString, "EO5T") == 0) {
if ((gPlayProperties.numberOfTracks - 1) >= (gPlayProperties.currentTrackNumber + 5)) {
gPlayProperties.playUntilTrackNumber = gPlayProperties.currentTrackNumber + 5;
} else {
gPlayProperties.sleepAfterPlaylist = true;
}
Log_Println((char *) FPSTR(sleepTimerEO5), LOGLEVEL_NOTICE);
System_IndicateOk();
return;
} else if (strcmp(receivedString, "0") == 0) {
if (System_IsSleepTimerEnabled()) {
System_DisableSleepTimer();
Log_Println((char *) FPSTR(sleepTimerStop), LOGLEVEL_NOTICE);
System_IndicateOk();
publishMqtt((char *) FPSTR(topicSleepState), 0, false);
return;
} else {
Log_Println((char *) FPSTR(sleepTimerAlreadyStopped), LOGLEVEL_INFO);
System_IndicateError();
return;
}
} }
}
System_SetSleepTimer((uint8_t)strtoul(receivedString, NULL, 10));
snprintf(Log_Buffer, Log_BufferLength, "%s: %u Minute(n)", (char *)FPSTR(sleepTimerSetTo), System_GetSleepTimer());
Log_Println(Log_Buffer, LOGLEVEL_NOTICE);
System_IndicateOk();
gPlayProperties.sleepAfterPlaylist = false;
gPlayProperties.sleepAfterCurrentTrack = false;
}
// Track-control (pause/play, stop, first, last, next, previous)
else if (strcmp_P(topic, topicTrackControlCmnd) == 0)
{
uint8_t controlCommand = strtoul(receivedString, NULL, 10);
AudioPlayer_TrackControlToQueueSender(controlCommand);
}
// Check if controls should be locked
else if (strcmp_P(topic, topicLockControlsCmnd) == 0)
{
if (strcmp(receivedString, "OFF") == 0)
{
System_SetLockControls(false);
Log_Println((char *)FPSTR(allowButtons), LOGLEVEL_NOTICE);
System_SetSleepTimer((uint8_t)strtoul(receivedString, NULL, 10));
snprintf(Log_Buffer, Log_BufferLength, "%s: %u Minute(n)", (char *) FPSTR(sleepTimerSetTo), System_GetSleepTimer());
Log_Println(Log_Buffer, LOGLEVEL_NOTICE);
System_IndicateOk(); System_IndicateOk();
gPlayProperties.sleepAfterPlaylist = false;
gPlayProperties.sleepAfterCurrentTrack = false;
} }
else if (strcmp(receivedString, "ON") == 0)
{
System_SetLockControls(true);
Log_Println((char *)FPSTR(lockButtons), LOGLEVEL_NOTICE);
System_IndicateOk();
// Track-control (pause/play, stop, first, last, next, previous)
else if (strcmp_P(topic, topicTrackControlCmnd) == 0) {
uint8_t controlCommand = strtoul(receivedString, NULL, 10);
AudioPlayer_TrackControlToQueueSender(controlCommand);
} }
}
// Check if playmode should be adjusted
else if (strcmp_P(topic, topicRepeatModeCmnd) == 0)
{
char rBuf[2];
uint8_t repeatMode = strtoul(receivedString, NULL, 10);
Serial.printf("Repeat: %d", repeatMode);
if (gPlayProperties.playMode != NO_PLAYLIST)
{
if (gPlayProperties.playMode == NO_PLAYLIST)
{
snprintf(rBuf, 2, "%u", AudioPlayer_GetRepeatMode());
publishMqtt((char *)FPSTR(topicRepeatModeState), rBuf, false);
Log_Println((char *)FPSTR(noPlaylistNotAllowedMqtt), LOGLEVEL_ERROR);
System_IndicateError();
}
else
{
switch (repeatMode)
{
case NO_REPEAT:
gPlayProperties.repeatCurrentTrack = false;
gPlayProperties.repeatPlaylist = false;
snprintf(rBuf, 2, "%u", AudioPlayer_GetRepeatMode());
publishMqtt((char *)FPSTR(topicRepeatModeState), rBuf, false);
Log_Println((char *)FPSTR(modeRepeatNone), LOGLEVEL_INFO);
System_IndicateOk();
break;
case TRACK:
gPlayProperties.repeatCurrentTrack = true;
gPlayProperties.repeatPlaylist = false;
snprintf(rBuf, 2, "%u", AudioPlayer_GetRepeatMode());
publishMqtt((char *)FPSTR(topicRepeatModeState), rBuf, false);
Log_Println((char *)FPSTR(modeRepeatTrack), LOGLEVEL_INFO);
System_IndicateOk();
break;
case PLAYLIST:
gPlayProperties.repeatCurrentTrack = false;
gPlayProperties.repeatPlaylist = true;
snprintf(rBuf, 2, "%u", AudioPlayer_GetRepeatMode());
publishMqtt((char *)FPSTR(topicRepeatModeState), rBuf, false);
Log_Println((char *)FPSTR(modeRepeatPlaylist), LOGLEVEL_INFO);
System_IndicateOk();
break;
// Check if controls should be locked
else if (strcmp_P(topic, topicLockControlsCmnd) == 0) {
if (strcmp(receivedString, "OFF") == 0) {
System_SetLockControls(false);
Log_Println((char *) FPSTR(allowButtons), LOGLEVEL_NOTICE);
System_IndicateOk();
} else if (strcmp(receivedString, "ON") == 0) {
System_SetLockControls(true);
Log_Println((char *) FPSTR(lockButtons), LOGLEVEL_NOTICE);
System_IndicateOk();
}
}
case TRACK_N_PLAYLIST:
gPlayProperties.repeatCurrentTrack = true;
gPlayProperties.repeatPlaylist = true;
// Check if playmode should be adjusted
else if (strcmp_P(topic, topicRepeatModeCmnd) == 0) {
char rBuf[2];
uint8_t repeatMode = strtoul(receivedString, NULL, 10);
Serial.printf("Repeat: %d", repeatMode);
if (gPlayProperties.playMode != NO_PLAYLIST) {
if (gPlayProperties.playMode == NO_PLAYLIST) {
snprintf(rBuf, 2, "%u", AudioPlayer_GetRepeatMode()); snprintf(rBuf, 2, "%u", AudioPlayer_GetRepeatMode());
publishMqtt((char *)FPSTR(topicRepeatModeState), rBuf, false);
Log_Println((char *)FPSTR(modeRepeatTracknPlaylist), LOGLEVEL_INFO);
System_IndicateOk();
break;
default:
publishMqtt((char *) FPSTR(topicRepeatModeState), rBuf, false);
Log_Println((char *) FPSTR(noPlaylistNotAllowedMqtt), LOGLEVEL_ERROR);
System_IndicateError(); System_IndicateError();
snprintf(rBuf, 2, "%u", AudioPlayer_GetRepeatMode());
publishMqtt((char *)FPSTR(topicRepeatModeState), rBuf, false);
break;
} else {
switch (repeatMode) {
case NO_REPEAT:
gPlayProperties.repeatCurrentTrack = false;
gPlayProperties.repeatPlaylist = false;
snprintf(rBuf, 2, "%u", AudioPlayer_GetRepeatMode());
publishMqtt((char *) FPSTR(topicRepeatModeState), rBuf, false);
Log_Println((char *) FPSTR(modeRepeatNone), LOGLEVEL_INFO);
System_IndicateOk();
break;
case TRACK:
gPlayProperties.repeatCurrentTrack = true;
gPlayProperties.repeatPlaylist = false;
snprintf(rBuf, 2, "%u", AudioPlayer_GetRepeatMode());
publishMqtt((char *) FPSTR(topicRepeatModeState), rBuf, false);
Log_Println((char *) FPSTR(modeRepeatTrack), LOGLEVEL_INFO);
System_IndicateOk();
break;
case PLAYLIST:
gPlayProperties.repeatCurrentTrack = false;
gPlayProperties.repeatPlaylist = true;
snprintf(rBuf, 2, "%u", AudioPlayer_GetRepeatMode());
publishMqtt((char *) FPSTR(topicRepeatModeState), rBuf, false);
Log_Println((char *) FPSTR(modeRepeatPlaylist), LOGLEVEL_INFO);
System_IndicateOk();
break;
case TRACK_N_PLAYLIST:
gPlayProperties.repeatCurrentTrack = true;
gPlayProperties.repeatPlaylist = true;
snprintf(rBuf, 2, "%u", AudioPlayer_GetRepeatMode());
publishMqtt((char *) FPSTR(topicRepeatModeState), rBuf, false);
Log_Println((char *) FPSTR(modeRepeatTracknPlaylist), LOGLEVEL_INFO);
System_IndicateOk();
break;
default:
System_IndicateError();
snprintf(rBuf, 2, "%u", AudioPlayer_GetRepeatMode());
publishMqtt((char *) FPSTR(topicRepeatModeState), rBuf, false);
break;
}
} }
} }
} }
}
// Check if LEDs should be dimmed
else if (strcmp_P(topic, topicLedBrightnessCmnd) == 0)
{
Led_SetBrightness(strtoul(receivedString, NULL, 10));
}
// Requested something that isn't specified?
else
{
snprintf(Log_Buffer, Log_BufferLength, "%s: %s", (char *)FPSTR(noValidTopic), topic);
Log_Println(Log_Buffer, LOGLEVEL_ERROR);
System_IndicateError();
}
free(receivedString);
free(mqttTopic);
#endif
// Check if LEDs should be dimmed
else if (strcmp_P(topic, topicLedBrightnessCmnd) == 0) {
Led_SetBrightness(strtoul(receivedString, NULL, 10));
}
// Requested something that isn't specified?
else {
snprintf(Log_Buffer, Log_BufferLength, "%s: %s", (char *) FPSTR(noValidTopic), topic);
Log_Println(Log_Buffer, LOGLEVEL_ERROR);
System_IndicateError();
}
free(receivedString);
free(mqttTopic);
#endif
} }

89
src/Port.cpp

@ -4,74 +4,61 @@
#include "Port.h" #include "Port.h"
#ifdef PORT_EXPANDER_ENABLE #ifdef PORT_EXPANDER_ENABLE
extern TwoWire i2cBusTwo;
extern TwoWire i2cBusTwo;
uint8_t Port_ExpanderPorts[portsToRead];
bool Port_ExpanderHandler(void);
uint8_t Port_ExpanderPorts[portsToRead];
bool Port_ExpanderHandler(void);
#endif #endif
void Port_Init(void)
{
void Port_Init(void) {
} }
void Port_Cyclic(void)
{
#ifdef PORT_EXPANDER_ENABLE
Port_ExpanderHandler();
#endif
void Port_Cyclic(void) {
#ifdef PORT_EXPANDER_ENABLE
Port_ExpanderHandler();
#endif
} }
// Wrapper: reads from GPIOs (via digitalRead()) or from port-expander (if enabled) // Wrapper: reads from GPIOs (via digitalRead()) or from port-expander (if enabled)
// Behaviour like digitalRead(): returns true if not pressed and false if pressed // Behaviour like digitalRead(): returns true if not pressed and false if pressed
bool Port_Read(const uint8_t _channel)
{
switch (_channel)
{
case 0 ... 39: // GPIO
return digitalRead(_channel);
bool Port_Read(const uint8_t _channel) {
switch (_channel) {
case 0 ... 39: // GPIO
return digitalRead(_channel);
#ifdef PORT_EXPANDER_ENABLE
case 100 ... 107: // Port-expander (port 0)
return (Port_ExpanderPorts[0] & (1 << (_channel - 100))); // Remove offset 100 (return false if pressed)
#ifdef PORT_EXPANDER_ENABLE
case 100 ... 107: // Port-expander (port 0)
return (Port_ExpanderPorts[0] & (1 << (_channel - 100))); // Remove offset 100 (return false if pressed)
case 108 ... 115: // Port-expander (port 1)
if (portsToRead == 2)
{ // Make sure portsToRead != 1 when channel > 107
return (Port_ExpanderPorts[1] & (1 << (_channel - 108))); // Remove offset 100 + 8 (return false if pressed)
}
else
{
return true;
}
case 108 ... 115: // Port-expander (port 1)
if (portsToRead == 2) { // Make sure portsToRead != 1 when channel > 107
return (Port_ExpanderPorts[1] & (1 << (_channel - 108))); // Remove offset 100 + 8 (return false if pressed)
} else {
return true;
}
#endif
#endif
default: // Everything else (doesn't make sense at all) isn't supposed to be pressed
return true;
default: // Everything else (doesn't make sense at all) isn't supposed to be pressed
return true;
} }
} }
#ifdef PORT_EXPANDER_ENABLE #ifdef PORT_EXPANDER_ENABLE
// Reads input from port-expander and writes output into global array
// Datasheet: https://www.nxp.com/docs/en/data-sheet/PCA9555.pdf
bool Port_ExpanderHandler()
{
i2cBusTwo.beginTransmission(expanderI2cAddress);
for (uint8_t i = 0; i < portsToRead; i++)
{
i2cBusTwo.write(0x00 + i); // Go to input-register...
i2cBusTwo.endTransmission();
i2cBusTwo.requestFrom(expanderI2cAddress, 1); // ...and read its byte
// Reads input from port-expander and writes output into global array
// Datasheet: https://www.nxp.com/docs/en/data-sheet/PCA9555.pdf
bool Port_ExpanderHandler() {
i2cBusTwo.beginTransmission(expanderI2cAddress);
for (uint8_t i = 0; i < portsToRead; i++) {
i2cBusTwo.write(0x00 + i); // Go to input-register...
i2cBusTwo.endTransmission();
i2cBusTwo.requestFrom(expanderI2cAddress, 1); // ...and read its byte
if (i2cBusTwo.available())
{
Port_ExpanderPorts[i] = i2cBusTwo.read();
}
else
{
return false;
if (i2cBusTwo.available()) {
Port_ExpanderPorts[i] = i2cBusTwo.read();
} else {
return false;
}
} }
return false;
} }
return false;
}
#endif #endif

23
src/Queues.cpp

@ -8,31 +8,26 @@ QueueHandle_t gTrackQueue;
QueueHandle_t gTrackControlQueue; QueueHandle_t gTrackControlQueue;
QueueHandle_t gRfidCardQueue; QueueHandle_t gRfidCardQueue;
void Queues_Init(void)
{
void Queues_Init(void) {
// Create queues // Create queues
gVolumeQueue = xQueueCreate(1, sizeof(int)); gVolumeQueue = xQueueCreate(1, sizeof(int));
if (gVolumeQueue == NULL)
{
Log_Println((char *)FPSTR(unableToCreateVolQ), LOGLEVEL_ERROR);
if (gVolumeQueue == NULL) {
Log_Println((char *) FPSTR(unableToCreateVolQ), LOGLEVEL_ERROR);
} }
gRfidCardQueue = xQueueCreate(1, cardIdStringSize); gRfidCardQueue = xQueueCreate(1, cardIdStringSize);
if (gRfidCardQueue == NULL)
{
Log_Println((char *)FPSTR(unableToCreateRfidQ), LOGLEVEL_ERROR);
if (gRfidCardQueue == NULL) {
Log_Println((char *) FPSTR(unableToCreateRfidQ), LOGLEVEL_ERROR);
} }
gTrackControlQueue = xQueueCreate(1, sizeof(uint8_t)); gTrackControlQueue = xQueueCreate(1, sizeof(uint8_t));
if (gTrackControlQueue == NULL)
{
Log_Println((char *)FPSTR(unableToCreateMgmtQ), LOGLEVEL_ERROR);
if (gTrackControlQueue == NULL) {
Log_Println((char *) FPSTR(unableToCreateMgmtQ), LOGLEVEL_ERROR);
} }
char **playlistArray; char **playlistArray;
gTrackQueue = xQueueCreate(1, sizeof(playlistArray)); gTrackQueue = xQueueCreate(1, sizeof(playlistArray));
if (gTrackQueue == NULL)
{
Log_Println((char *)FPSTR(unableToCreatePlayQ), LOGLEVEL_ERROR);
if (gTrackQueue == NULL) {
Log_Println((char *) FPSTR(unableToCreatePlayQ), LOGLEVEL_ERROR);
} }
} }

66
src/RfidCommon.cpp

@ -15,8 +15,7 @@ unsigned long Rfid_LastRfidCheckTimestamp = 0;
char *gCurrentRfidTagId = NULL; char *gCurrentRfidTagId = NULL;
// Tries to lookup RFID-tag-string in NVS and extracts parameter from it if found // Tries to lookup RFID-tag-string in NVS and extracts parameter from it if found
void Rfid_PreferenceLookupHandler(void)
{
void Rfid_PreferenceLookupHandler(void) {
BaseType_t rfidStatus; BaseType_t rfidStatus;
char rfidTagId[cardIdStringSize]; char rfidTagId[cardIdStringSize];
char _file[255]; char _file[255];
@ -25,19 +24,17 @@ void Rfid_PreferenceLookupHandler(void)
uint32_t _playMode = 1; uint32_t _playMode = 1;
rfidStatus = xQueueReceive(gRfidCardQueue, &rfidTagId, 0); rfidStatus = xQueueReceive(gRfidCardQueue, &rfidTagId, 0);
if (rfidStatus == pdPASS)
{
if (rfidStatus == pdPASS) {
System_UpdateActivityTimer(); System_UpdateActivityTimer();
free(gCurrentRfidTagId); free(gCurrentRfidTagId);
gCurrentRfidTagId = x_strdup(rfidTagId); gCurrentRfidTagId = x_strdup(rfidTagId);
snprintf(Log_Buffer, Log_BufferLength, "%s: %s", (char *)FPSTR(rfidTagReceived), gCurrentRfidTagId);
snprintf(Log_Buffer, Log_BufferLength, "%s: %s", (char *) FPSTR(rfidTagReceived), gCurrentRfidTagId);
Web_SendWebsocketData(0, 10); // Push new rfidTagId to all websocket-clients Web_SendWebsocketData(0, 10); // Push new rfidTagId to all websocket-clients
Log_Println(Log_Buffer, LOGLEVEL_INFO); Log_Println(Log_Buffer, LOGLEVEL_INFO);
String s = gPrefsRfid.getString(gCurrentRfidTagId, "-1"); // Try to lookup rfidId in NVS String s = gPrefsRfid.getString(gCurrentRfidTagId, "-1"); // Try to lookup rfidId in NVS
if (!s.compareTo("-1"))
{
Log_Println((char *)FPSTR(rfidTagUnknownInNvs), LOGLEVEL_ERROR);
if (!s.compareTo("-1")) {
Log_Println((char *) FPSTR(rfidTagUnknownInNvs), LOGLEVEL_ERROR);
System_IndicateError(); System_IndicateError();
return; return;
} }
@ -45,54 +42,39 @@ void Rfid_PreferenceLookupHandler(void)
char *token; char *token;
uint8_t i = 1; uint8_t i = 1;
token = strtok((char *)s.c_str(), stringDelimiter); token = strtok((char *)s.c_str(), stringDelimiter);
while (token != NULL)
{ // Try to extract data from string after lookup
if (i == 1)
{
while (token != NULL) { // Try to extract data from string after lookup
if (i == 1) {
strncpy(_file, token, sizeof(_file) / sizeof(_file[0])); strncpy(_file, token, sizeof(_file) / sizeof(_file[0]));
}
else if (i == 2)
{
} else if (i == 2) {
_lastPlayPos = strtoul(token, NULL, 10); _lastPlayPos = strtoul(token, NULL, 10);
}
else if (i == 3)
{
} else if (i == 3) {
_playMode = strtoul(token, NULL, 10); _playMode = strtoul(token, NULL, 10);
}
else if (i == 4)
{
} else if (i == 4) {
_trackLastPlayed = strtoul(token, NULL, 10); _trackLastPlayed = strtoul(token, NULL, 10);
} }
i++; i++;
token = strtok(NULL, stringDelimiter); token = strtok(NULL, stringDelimiter);
} }
if (i != 5)
{
Log_Println((char *)FPSTR(errorOccuredNvs), LOGLEVEL_ERROR);
if (i != 5) {
Log_Println((char *) FPSTR(errorOccuredNvs), LOGLEVEL_ERROR);
System_IndicateError(); System_IndicateError();
}
else
{
} else {
// Only pass file to queue if strtok revealed 3 items // Only pass file to queue if strtok revealed 3 items
if (_playMode >= 100)
{
if (_playMode >= 100) {
// Modification-cards can change some settings (e.g. introducing track-looping or sleep after track/playlist). // Modification-cards can change some settings (e.g. introducing track-looping or sleep after track/playlist).
Cmd_Action(_playMode); Cmd_Action(_playMode);
}
else
{
#ifdef MQTT_ENABLE
publishMqtt((char *)FPSTR(topicRfidState), gCurrentRfidTagId, false);
#endif
} else {
#ifdef MQTT_ENABLE
publishMqtt((char *) FPSTR(topicRfidState), gCurrentRfidTagId, false);
#endif
#ifdef BLUETOOTH_ENABLE
// if music rfid was read, go back to normal mode
if (System_GetOperationMode() == OPMODE_BLUETOOTH)
{
System_SetOperationMode(OPMODE_NORMAL);
}
#endif
#ifdef BLUETOOTH_ENABLE
// if music rfid was read, go back to normal mode
if (System_GetOperationMode() == OPMODE_BLUETOOTH) {
System_SetOperationMode(OPMODE_NORMAL);
}
#endif
AudioPlayer_TrackQueueDispatcher(_file, _lastPlayPos, _playMode, _trackLastPlayed); AudioPlayer_TrackQueueDispatcher(_file, _lastPlayPos, _playMode, _trackLastPlayed);
} }

143
src/RfidMfrc522.cpp

@ -7,95 +7,84 @@
#include "System.h" #include "System.h"
#if defined RFID_READER_TYPE_MFRC522_SPI || defined RFID_READER_TYPE_MFRC522_I2C #if defined RFID_READER_TYPE_MFRC522_SPI || defined RFID_READER_TYPE_MFRC522_I2C
#ifdef RFID_READER_TYPE_MFRC522_SPI
#include <MFRC522.h>
#endif
#if defined(RFID_READER_TYPE_MFRC522_I2C) || defined(PORT_EXPANDER_ENABLE)
#include "Wire.h"
#endif
#ifdef RFID_READER_TYPE_MFRC522_I2C
#include <MFRC522_I2C.h>
#endif
extern unsigned long Rfid_LastRfidCheckTimestamp;
#ifdef RFID_READER_TYPE_MFRC522_I2C
extern TwoWire i2cBusTwo;
static MFRC522_I2C mfrc522(MFRC522_ADDR, MFRC522_RST_PIN, &i2cBusTwo);
#endif
#ifdef RFID_READER_TYPE_MFRC522_SPI
static MFRC522 mfrc522(RFID_CS, RST_PIN);
#endif
void Rfid_Init(void) {
#ifdef RFID_READER_TYPE_MFRC522_SPI
SPI.begin(RFID_SCK, RFID_MISO, RFID_MOSI, RFID_CS);
SPI.setFrequency(1000000);
#endif
// Init RC522 Card-Reader
#if defined(RFID_READER_TYPE_MFRC522_I2C) || defined(RFID_READER_TYPE_MFRC522_SPI)
mfrc522.PCD_Init();
mfrc522.PCD_SetAntennaGain(rfidGain);
delay(50);
Log_Println((char *) FPSTR(rfidScannerReady), LOGLEVEL_DEBUG);
#endif
}
#ifdef RFID_READER_TYPE_MFRC522_SPI
#include <MFRC522.h>
#endif
#if defined(RFID_READER_TYPE_MFRC522_I2C) || defined(PORT_EXPANDER_ENABLE)
#include "Wire.h"
#endif
#ifdef RFID_READER_TYPE_MFRC522_I2C
#include <MFRC522_I2C.h>
#endif
extern unsigned long Rfid_LastRfidCheckTimestamp;
#ifdef RFID_READER_TYPE_MFRC522_I2C
extern TwoWire i2cBusTwo;
static MFRC522_I2C mfrc522(MFRC522_ADDR, MFRC522_RST_PIN, &i2cBusTwo);
#endif
#ifdef RFID_READER_TYPE_MFRC522_SPI
static MFRC522 mfrc522(RFID_CS, RST_PIN);
#endif
void Rfid_Init(void)
{
#ifdef RFID_READER_TYPE_MFRC522_SPI
SPI.begin(RFID_SCK, RFID_MISO, RFID_MOSI, RFID_CS);
SPI.setFrequency(1000000);
#endif
// Init RC522 Card-Reader
#if defined(RFID_READER_TYPE_MFRC522_I2C) || defined(RFID_READER_TYPE_MFRC522_SPI)
mfrc522.PCD_Init();
mfrc522.PCD_SetAntennaGain(rfidGain);
delay(50);
Log_Println((char *)FPSTR(rfidScannerReady), LOGLEVEL_DEBUG);
#endif
}
void Rfid_Cyclic(void) {
byte cardId[cardIdSize];
String cardIdString;
void Rfid_Cyclic(void)
{
byte cardId[cardIdSize];
String cardIdString;
if ((millis() - Rfid_LastRfidCheckTimestamp) >= RFID_SCAN_INTERVAL) {
Rfid_LastRfidCheckTimestamp = millis();
// Reset the loop if no new card is present on the sensor/reader. This saves the entire process when idle.
if ((millis() - Rfid_LastRfidCheckTimestamp) >= RFID_SCAN_INTERVAL)
{
Rfid_LastRfidCheckTimestamp = millis();
// Reset the loop if no new card is present on the sensor/reader. This saves the entire process when idle.
if (!mfrc522.PICC_IsNewCardPresent()) {
return;
}
if (!mfrc522.PICC_IsNewCardPresent())
{
return;
}
// Select one of the cards
if (!mfrc522.PICC_ReadCardSerial()) {
return;
}
// Select one of the cards
if (!mfrc522.PICC_ReadCardSerial())
{
return;
}
//mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
mfrc522.PICC_HaltA();
mfrc522.PCD_StopCrypto1();
//mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
mfrc522.PICC_HaltA();
mfrc522.PCD_StopCrypto1();
memcpy(cardId, mfrc522.uid.uidByte, cardIdSize);
memcpy(cardId, mfrc522.uid.uidByte, cardIdSize);
Log_Print((char *) FPSTR(rfidTagDetected), LOGLEVEL_NOTICE);
for (uint8_t i = 0u; i < cardIdSize; i++) {
snprintf(Log_Buffer, Log_BufferLength, "%02x%s", cardId[i], (i < cardIdSize - 1u) ? "-" : "\n");
Log_Print(Log_Buffer, LOGLEVEL_NOTICE);
}
Log_Print((char *)FPSTR(rfidTagDetected), LOGLEVEL_NOTICE);
for (uint8_t i = 0u; i < cardIdSize; i++)
{
snprintf(Log_Buffer, Log_BufferLength, "%02x%s", cardId[i], (i < cardIdSize - 1u) ? "-" : "\n");
Log_Print(Log_Buffer, LOGLEVEL_NOTICE);
}
for (uint8_t i = 0u; i < cardIdSize; i++) {
char num[4];
snprintf(num, sizeof(num), "%03d", cardId[i]);
cardIdString += num;
}
for (uint8_t i = 0u; i < cardIdSize; i++)
{
char num[4];
snprintf(num, sizeof(num), "%03d", cardId[i]);
cardIdString += num;
xQueueSend(gRfidCardQueue, cardIdString.c_str(), 0);
} }
xQueueSend(gRfidCardQueue, cardIdString.c_str(), 0);
} }
}
void Rfid_Exit(void)
{
}
void Rfid_Exit(void) {
}
void Rfid_WakeupCheck(void)
{
}
void Rfid_WakeupCheck(void) {
}
#endif #endif

391
src/RfidPn5180.cpp

@ -9,9 +9,9 @@
#include "System.h" #include "System.h"
#ifdef RFID_READER_TYPE_PN5180 #ifdef RFID_READER_TYPE_PN5180
#include <PN5180.h>
#include <PN5180ISO14443.h>
#include <PN5180ISO15693.h>
#include <PN5180.h>
#include <PN5180ISO14443.h>
#include <PN5180ISO15693.h>
#endif #endif
#define RFID_PN5180_STATE_INIT 0u #define RFID_PN5180_STATE_INIT 0u
@ -28,235 +28,198 @@
extern unsigned long Rfid_LastRfidCheckTimestamp; extern unsigned long Rfid_LastRfidCheckTimestamp;
#ifdef RFID_READER_TYPE_PN5180 #ifdef RFID_READER_TYPE_PN5180
static void Rfid_Task(void *parameter);
static void Rfid_Read(void);
void Rfid_Init(void)
{
#ifdef PN5180_ENABLE_LPCD
// disable pin hold from deep sleep
gpio_deep_sleep_hold_dis();
gpio_hold_dis(gpio_num_t(RFID_CS)); // NSS
gpio_hold_dis(gpio_num_t(RFID_RST)); // RST
#endif
// Create task for rfid
xTaskCreatePinnedToCore(
Rfid_Task, /* Function to implement the task */
"Rfid_Task", /* Name of the task */
1500, /* Stack size in words */
NULL, /* Task input parameter */
1, /* Priority of the task */
NULL, /* Task handle. */
0 /* Core where the task should run */
);
}
void Rfid_Cyclic(void)
{
// Implemented via task
}
void Rfid_Task(void *parameter)
{
for (;;)
{
Rfid_Read();
vTaskDelay(5u);
static void Rfid_Task(void *parameter);
static void Rfid_Read(void);
void Rfid_Init(void) {
#ifdef PN5180_ENABLE_LPCD
// disable pin hold from deep sleep
gpio_deep_sleep_hold_dis();
gpio_hold_dis(gpio_num_t(RFID_CS)); // NSS
gpio_hold_dis(gpio_num_t(RFID_RST)); // RST
#endif
// Create task for rfid
xTaskCreatePinnedToCore(
Rfid_Task, /* Function to implement the task */
"Rfid_Task", /* Name of the task */
1500, /* Stack size in words */
NULL, /* Task input parameter */
1, /* Priority of the task */
NULL, /* Task handle. */
0 /* Core where the task should run */
);
} }
}
void Rfid_Read(void)
{
static PN5180ISO14443 nfc14443(RFID_CS, RFID_BUSY, RFID_RST);
static PN5180ISO15693 nfc15693(RFID_CS, RFID_BUSY, RFID_RST);
static uint8_t stateMachine = RFID_PN5180_STATE_INIT;
byte cardId[cardIdSize], lastCardId[cardIdSize];
uint8_t uid[10];
String cardIdString;
bool cardReceived = false;
if (RFID_PN5180_STATE_INIT == stateMachine)
{
nfc14443.begin();
nfc14443.reset();
// show PN5180 reader version
uint8_t firmwareVersion[2];
nfc14443.readEEprom(FIRMWARE_VERSION, firmwareVersion, sizeof(firmwareVersion));
Serial.print(F("Firmware version="));
Serial.print(firmwareVersion[1]);
Serial.print(".");
Serial.println(firmwareVersion[0]);
// activate RF field
delay(4);
Log_Println((char *)FPSTR(rfidScannerReady), LOGLEVEL_DEBUG);
void Rfid_Cyclic(void) {
// Implemented via task
} }
// 1. check for an ISO-14443 card
else if (RFID_PN5180_NFC14443_STATE_RESET == stateMachine)
{
nfc14443.reset();
}
else if (RFID_PN5180_NFC14443_STATE_SETUPRF == stateMachine)
{
nfc14443.setupRF();
}
else if (RFID_PN5180_NFC14443_STATE_READCARD == stateMachine)
{
if (nfc14443.readCardSerial(uid) >= 4u)
{
cardReceived = true;
}
}
// 2. check for an ISO-15693 card
else if (RFID_PN5180_NFC15693_STATE_RESET == stateMachine)
{
nfc15693.reset();
}
else if (RFID_PN5180_NFC15693_STATE_SETUPRF == stateMachine)
{
nfc15693.setupRF();
}
else if (RFID_PN5180_NFC15693_STATE_DISABLEPRIVACYMODE == stateMachine)
{
// check for ICODE-SLIX2 password protected tag
// put your privacy password here, e.g.:
// https://de.ifixit.com/Antworten/Ansehen/513422/nfc+Chips+f%C3%BCr+tonies+kaufen
uint8_t password[] = {0x01, 0x02, 0x03, 0x04};
ISO15693ErrorCode myrc = nfc15693.disablePrivacyMode(password);
if (ISO15693_EC_OK == myrc)
{
Serial.println(F("disabling privacy-mode successful"));
void Rfid_Task(void *parameter) {
for (;;) {
Rfid_Read();
vTaskDelay(5u);
} }
} }
else if (RFID_PN5180_NFC15693_STATE_GETINVENTORY == stateMachine)
{
// try to read ISO15693 inventory
ISO15693ErrorCode rc = nfc15693.getInventory(uid);
if (rc == ISO15693_EC_OK)
{
cardReceived = true;
void Rfid_Read(void) {
static PN5180ISO14443 nfc14443(RFID_CS, RFID_BUSY, RFID_RST);
static PN5180ISO15693 nfc15693(RFID_CS, RFID_BUSY, RFID_RST);
static uint8_t stateMachine = RFID_PN5180_STATE_INIT;
byte cardId[cardIdSize], lastCardId[cardIdSize];
uint8_t uid[10];
String cardIdString;
bool cardReceived = false;
if (RFID_PN5180_STATE_INIT == stateMachine) {
nfc14443.begin();
nfc14443.reset();
// show PN5180 reader version
uint8_t firmwareVersion[2];
nfc14443.readEEprom(FIRMWARE_VERSION, firmwareVersion, sizeof(firmwareVersion));
Serial.print(F("Firmware version="));
Serial.print(firmwareVersion[1]);
Serial.print(".");
Serial.println(firmwareVersion[0]);
// activate RF field
delay(4);
Log_Println((char *) FPSTR(rfidScannerReady), LOGLEVEL_DEBUG);
// 1. check for an ISO-14443 card
} else if (RFID_PN5180_NFC14443_STATE_RESET == stateMachine) {
nfc14443.reset();
} else if (RFID_PN5180_NFC14443_STATE_SETUPRF == stateMachine) {
nfc14443.setupRF();
} else if (RFID_PN5180_NFC14443_STATE_READCARD == stateMachine) {
if (nfc14443.readCardSerial(uid) >= 4u) {
cardReceived = true;
}
// 2. check for an ISO-15693 card
} else if (RFID_PN5180_NFC15693_STATE_RESET == stateMachine) {
nfc15693.reset();
} else if (RFID_PN5180_NFC15693_STATE_SETUPRF == stateMachine) {
nfc15693.setupRF();
} else if (RFID_PN5180_NFC15693_STATE_DISABLEPRIVACYMODE == stateMachine) {
// check for ICODE-SLIX2 password protected tag
// put your privacy password here, e.g.:
// https://de.ifixit.com/Antworten/Ansehen/513422/nfc+Chips+f%C3%BCr+tonies+kaufen
uint8_t password[] = {0x01, 0x02, 0x03, 0x04};
ISO15693ErrorCode myrc = nfc15693.disablePrivacyMode(password);
if (ISO15693_EC_OK == myrc) {
Serial.println(F("disabling privacy-mode successful"));
}
} else if (RFID_PN5180_NFC15693_STATE_GETINVENTORY == stateMachine) {
// try to read ISO15693 inventory
ISO15693ErrorCode rc = nfc15693.getInventory(uid);
if (rc == ISO15693_EC_OK) {
cardReceived = true;
}
} }
}
// send card to queue
if (cardReceived)
{
memcpy(cardId, uid, cardIdSize);
// send card to queue
if (cardReceived) {
memcpy(cardId, uid, cardIdSize);
// check for different card id
if (memcmp((const void *)cardId, (const void *)lastCardId, sizeof(cardId)) == 0)
{
// reset state machine
stateMachine = RFID_PN5180_NFC14443_STATE_RESET;
return;
}
// check for different card id
if (memcmp((const void *)cardId, (const void *)lastCardId, sizeof(cardId)) == 0) {
// reset state machine
stateMachine = RFID_PN5180_NFC14443_STATE_RESET;
return;
}
memcpy(lastCardId, cardId, cardIdSize);
memcpy(lastCardId, cardId, cardIdSize);
Log_Print((char *)FPSTR(rfidTagDetected), LOGLEVEL_NOTICE);
for (uint8_t i = 0u; i < cardIdSize; i++)
{
snprintf(Log_Buffer, Log_BufferLength, "%02x%s", cardId[i], (i < cardIdSize - 1u) ? "-" : "\n");
Log_Print(Log_Buffer, LOGLEVEL_NOTICE);
}
Log_Print((char *) FPSTR(rfidTagDetected), LOGLEVEL_NOTICE);
for (uint8_t i = 0u; i < cardIdSize; i++) {
snprintf(Log_Buffer, Log_BufferLength, "%02x%s", cardId[i], (i < cardIdSize - 1u) ? "-" : "\n");
Log_Print(Log_Buffer, LOGLEVEL_NOTICE);
}
for (uint8_t i = 0u; i < cardIdSize; i++)
{
char num[4];
snprintf(num, sizeof(num), "%03d", cardId[i]);
cardIdString += num;
}
for (uint8_t i = 0u; i < cardIdSize; i++) {
char num[4];
snprintf(num, sizeof(num), "%03d", cardId[i]);
cardIdString += num;
}
xQueueSend(gRfidCardQueue, cardIdString.c_str(), 0);
}
xQueueSend(gRfidCardQueue, cardIdString.c_str(), 0);
}
stateMachine++;
stateMachine++;
if (stateMachine > RFID_PN5180_NFC15693_STATE_GETINVENTORY)
{
stateMachine = RFID_PN5180_NFC14443_STATE_RESET;
if (stateMachine > RFID_PN5180_NFC15693_STATE_GETINVENTORY) {
stateMachine = RFID_PN5180_NFC14443_STATE_RESET;
}
} }
}
void Rfid_Exit(void)
{
// goto low power card detection mode
#ifdef PN5180_ENABLE_LPCD
static PN5180 nfc(RFID_CS, RFID_BUSY, RFID_RST);
nfc.begin();
// show PN5180 reader version
uint8_t firmwareVersion[2];
nfc.readEEprom(FIRMWARE_VERSION, firmwareVersion, sizeof(firmwareVersion));
Serial.print(F("Firmware version="));
Serial.print(firmwareVersion[1]);
Serial.print(".");
Serial.println(firmwareVersion[0]);
// check firmware version: PN5180 firmware < 4.0 has several bugs preventing the LPCD mode
// you can flash latest firmware with this project: https://github.com/abidxraihan/PN5180_Updater_ESP32
if (firmwareVersion[1] < 4)
{
Serial.println(F("This PN5180 firmware does not work with LPCD! use firmware >= 4.0"));
return;
}
Serial.println(F("prepare low power card detection..."));
nfc.prepareLPCD();
nfc.clearIRQStatus(0xffffffff);
Serial.print(F("PN5180 IRQ PIN: "));
Serial.println(Port_Read(RFID_IRQ));
// turn on LPCD
uint16_t wakeupCounterInMs = 0x3FF; // must be in the range of 0x0 - 0xA82. max wake-up time is 2960 ms.
if (nfc.switchToLPCD(wakeupCounterInMs))
{
Serial.println(F("switch to low power card detection: success"));
// configure wakeup pin for deep-sleep wake-up, use ext1
esp_sleep_enable_ext1_wakeup((1ULL << (RFID_IRQ)), ESP_EXT1_WAKEUP_ANY_HIGH);
// freeze pin states in deep sleep
gpio_hold_en(gpio_num_t(RFID_CS)); // CS/NSS
gpio_hold_en(gpio_num_t(RFID_RST)); // RST
gpio_deep_sleep_hold_en();
void Rfid_Exit(void) {
// goto low power card detection mode
#ifdef PN5180_ENABLE_LPCD
static PN5180 nfc(RFID_CS, RFID_BUSY, RFID_RST);
nfc.begin();
// show PN5180 reader version
uint8_t firmwareVersion[2];
nfc.readEEprom(FIRMWARE_VERSION, firmwareVersion, sizeof(firmwareVersion));
Serial.print(F("Firmware version="));
Serial.print(firmwareVersion[1]);
Serial.print(".");
Serial.println(firmwareVersion[0]);
// check firmware version: PN5180 firmware < 4.0 has several bugs preventing the LPCD mode
// you can flash latest firmware with this project: https://github.com/abidxraihan/PN5180_Updater_ESP32
if (firmwareVersion[1] < 4) {
Serial.println(F("This PN5180 firmware does not work with LPCD! use firmware >= 4.0"));
return;
}
Serial.println(F("prepare low power card detection..."));
nfc.prepareLPCD();
nfc.clearIRQStatus(0xffffffff);
Serial.print(F("PN5180 IRQ PIN: "));
Serial.println(Port_Read(RFID_IRQ));
// turn on LPCD
uint16_t wakeupCounterInMs = 0x3FF; // must be in the range of 0x0 - 0xA82. max wake-up time is 2960 ms.
if (nfc.switchToLPCD(wakeupCounterInMs)) {
Serial.println(F("switch to low power card detection: success"));
// configure wakeup pin for deep-sleep wake-up, use ext1
esp_sleep_enable_ext1_wakeup((1ULL << (RFID_IRQ)), ESP_EXT1_WAKEUP_ANY_HIGH);
// freeze pin states in deep sleep
gpio_hold_en(gpio_num_t(RFID_CS)); // CS/NSS
gpio_hold_en(gpio_num_t(RFID_RST)); // RST
gpio_deep_sleep_hold_en();
} else {
Serial.println(F("switchToLPCD failed"));
}
#endif
} }
else
{
Serial.println(F("switchToLPCD failed"));
}
#endif
}
// wake up from LPCD, check card is present. This works only for ISO-14443 compatible cards
void Rfid_WakeupCheck(void)
{
#ifdef PN5180_ENABLE_LPCD
static PN5180ISO14443 nfc14443(RFID_CS, RFID_BUSY, RFID_RST);
nfc14443.begin();
nfc14443.reset();
nfc14443.setupRF();
if (!nfc14443.isCardPresent())
{
nfc14443.clearIRQStatus(0xffffffff);
Serial.print(F("Logic level at PN5180' IRQ-PIN: "));
Serial.println(Port_Read(RFID_IRQ));
// turn on LPCD
uint16_t wakeupCounterInMs = 0x3FF; // needs to be in the range of 0x0 - 0xA82. max wake-up time is 2960 ms.
if (nfc14443.switchToLPCD(wakeupCounterInMs))
{
Log_Println((char *)FPSTR(lowPowerCardSuccess), LOGLEVEL_INFO);
// configure wakeup pin for deep-sleep wake-up, use ext1
esp_sleep_enable_ext1_wakeup((1ULL << (RFID_IRQ)), ESP_EXT1_WAKEUP_ANY_HIGH);
// freeze pin states in deep sleep
gpio_hold_en(gpio_num_t(RFID_CS)); // CS/NSS
gpio_hold_en(gpio_num_t(RFID_RST)); // RST
gpio_deep_sleep_hold_en();
Log_Println((char *)FPSTR(wakeUpRfidNoIso14443), LOGLEVEL_ERROR);
esp_deep_sleep_start();
}
else
{
Serial.println(F("switchToLPCD failed"));
}
// wake up from LPCD, check card is present. This works only for ISO-14443 compatible cards
void Rfid_WakeupCheck(void) {
#ifdef PN5180_ENABLE_LPCD
static PN5180ISO14443 nfc14443(RFID_CS, RFID_BUSY, RFID_RST);
nfc14443.begin();
nfc14443.reset();
nfc14443.setupRF();
if (!nfc14443.isCardPresent()) {
nfc14443.clearIRQStatus(0xffffffff);
Serial.print(F("Logic level at PN5180' IRQ-PIN: "));
Serial.println(Port_Read(RFID_IRQ));
// turn on LPCD
uint16_t wakeupCounterInMs = 0x3FF; // needs to be in the range of 0x0 - 0xA82. max wake-up time is 2960 ms.
if (nfc14443.switchToLPCD(wakeupCounterInMs)) {
Log_Println((char *) FPSTR(lowPowerCardSuccess), LOGLEVEL_INFO);
// configure wakeup pin for deep-sleep wake-up, use ext1
esp_sleep_enable_ext1_wakeup((1ULL << (RFID_IRQ)), ESP_EXT1_WAKEUP_ANY_HIGH);
// freeze pin states in deep sleep
gpio_hold_en(gpio_num_t(RFID_CS)); // CS/NSS
gpio_hold_en(gpio_num_t(RFID_RST)); // RST
gpio_deep_sleep_hold_en();
Log_Println((char *) FPSTR(wakeUpRfidNoIso14443), LOGLEVEL_ERROR);
esp_deep_sleep_start();
} else {
Serial.println(F("switchToLPCD failed"));
}
}
#endif
} }
#endif
}
#endif #endif

97
src/RotaryEncoder.cpp

@ -11,68 +11,59 @@
// Rotary encoder-configuration // Rotary encoder-configuration
#ifdef USEROTARY_ENABLE #ifdef USEROTARY_ENABLE
ESP32Encoder encoder;
// Rotary encoder-helper
int32_t lastEncoderValue;
int32_t currentEncoderValue;
int32_t lastVolume = -1; // Don't change -1 as initial-value!
ESP32Encoder encoder;
// Rotary encoder-helper
int32_t lastEncoderValue;
int32_t currentEncoderValue;
int32_t lastVolume = -1; // Don't change -1 as initial-value!
#endif #endif
void RotaryEncoder_Init(void)
{
void RotaryEncoder_Init(void) {
// Init rotary encoder // Init rotary encoder
#ifdef USEROTARY_ENABLE
encoder.attachHalfQuad(DREHENCODER_CLK, DREHENCODER_DT);
encoder.clearCount();
encoder.setCount(AudioPlayer_GetInitVolume() * 2); // Ganzes Raster ist immer +2, daher initiale Lautstärke mit 2 multiplizieren
#endif
}
void RotaryEncoder_Readjust(void)
{
#ifdef USEROTARY_ENABLE
encoder.clearCount();
encoder.setCount(AudioPlayer_GetCurrentVolume() * 2);
#endif
#ifdef USEROTARY_ENABLE
encoder.attachHalfQuad(DREHENCODER_CLK, DREHENCODER_DT);
encoder.clearCount();
encoder.setCount(AudioPlayer_GetInitVolume() * 2); // Ganzes Raster ist immer +2, daher initiale Lautstärke mit 2 multiplizieren
#endif
} }
// Handles volume directed by rotary encoder
void RotaryEncoder_Cyclic(void)
{
#ifdef USEROTARY_ENABLE
if (System_AreControlsLocked())
{
void RotaryEncoder_Readjust(void) {
#ifdef USEROTARY_ENABLE
encoder.clearCount(); encoder.clearCount();
encoder.setCount(AudioPlayer_GetCurrentVolume() * 2); encoder.setCount(AudioPlayer_GetCurrentVolume() * 2);
return;
}
#endif
}
currentEncoderValue = encoder.getCount();
// Only if initial run or value has changed. And only after "full step" of rotary encoder
if (((lastEncoderValue != currentEncoderValue) || lastVolume == -1) && (currentEncoderValue % 2 == 0))
{
System_UpdateActivityTimer(); // Set inactive back if rotary encoder was used
if ((AudioPlayer_GetMaxVolume() * 2) < currentEncoderValue)
{
encoder.clearCount();
encoder.setCount(AudioPlayer_GetMaxVolume() * 2);
Log_Println((char *)FPSTR(maxLoudnessReached), LOGLEVEL_INFO);
currentEncoderValue = encoder.getCount();
}
else if (currentEncoderValue < AudioPlayer_GetMinVolume())
{
// Handles volume directed by rotary encoder
void RotaryEncoder_Cyclic(void) {
#ifdef USEROTARY_ENABLE
if (System_AreControlsLocked()) {
encoder.clearCount(); encoder.clearCount();
encoder.setCount(AudioPlayer_GetMinVolume());
Log_Println((char *)FPSTR(minLoudnessReached), LOGLEVEL_INFO);
currentEncoderValue = encoder.getCount();
encoder.setCount(AudioPlayer_GetCurrentVolume() * 2);
return;
} }
lastEncoderValue = currentEncoderValue;
AudioPlayer_SetCurrentVolume(lastEncoderValue / 2u);
if (AudioPlayer_GetCurrentVolume() != lastVolume)
{
lastVolume = AudioPlayer_GetCurrentVolume();
AudioPlayer_VolumeToQueueSender(AudioPlayer_GetCurrentVolume(), false);
currentEncoderValue = encoder.getCount();
// Only if initial run or value has changed. And only after "full step" of rotary encoder
if (((lastEncoderValue != currentEncoderValue) || lastVolume == -1) && (currentEncoderValue % 2 == 0)) {
System_UpdateActivityTimer(); // Set inactive back if rotary encoder was used
if ((AudioPlayer_GetMaxVolume() * 2) < currentEncoderValue) {
encoder.clearCount();
encoder.setCount(AudioPlayer_GetMaxVolume() * 2);
Log_Println((char *) FPSTR(maxLoudnessReached), LOGLEVEL_INFO);
currentEncoderValue = encoder.getCount();
} else if (currentEncoderValue < AudioPlayer_GetMinVolume()) {
encoder.clearCount();
encoder.setCount(AudioPlayer_GetMinVolume());
Log_Println((char *) FPSTR(minLoudnessReached), LOGLEVEL_INFO);
currentEncoderValue = encoder.getCount();
}
lastEncoderValue = currentEncoderValue;
AudioPlayer_SetCurrentVolume(lastEncoderValue / 2u);
if (AudioPlayer_GetCurrentVolume() != lastVolume) {
lastVolume = AudioPlayer_GetCurrentVolume();
AudioPlayer_VolumeToQueueSender(AudioPlayer_GetCurrentVolume(), false);
}
} }
}
#endif
#endif
} }

196
src/SdCard.cpp

@ -8,78 +8,69 @@
#include "System.h" #include "System.h"
#ifdef SD_MMC_1BIT_MODE #ifdef SD_MMC_1BIT_MODE
fs::FS gFSystem = (fs::FS)SD_MMC;
fs::FS gFSystem = (fs::FS)SD_MMC;
#else #else
SPIClass spiSD(HSPI);
fs::FS gFSystem = (fs::FS)SD;
SPIClass spiSD(HSPI);
fs::FS gFSystem = (fs::FS)SD;
#endif #endif
void SdCard_Init(void)
{
#ifndef SINGLE_SPI_ENABLE
#ifdef SD_MMC_1BIT_MODE
pinMode(2, INPUT_PULLUP);
while (!SD_MMC.begin("/sdcard", true))
{
#else
pinMode(SPISD_CS, OUTPUT);
digitalWrite(SPISD_CS, HIGH);
spiSD.begin(SPISD_SCK, SPISD_MISO, SPISD_MOSI, SPISD_CS);
spiSD.setFrequency(1000000);
while (!SD.begin(SPISD_CS, spiSD))
{
#endif
#else
#ifdef SD_MMC_1BIT_MODE
pinMode(2, INPUT_PULLUP);
while (!SD_MMC.begin("/sdcard", true))
{
#else
while (!SD.begin(SPISD_CS))
{
#endif
#endif
Log_Println((char *)FPSTR(unableToMountSd), LOGLEVEL_ERROR);
delay(500);
#ifdef SHUTDOWN_IF_SD_BOOT_FAILS
if (millis() >= deepsleepTimeAfterBootFails * 1000)
{
Log_Println((char *)FPSTR(sdBootFailedDeepsleep), LOGLEVEL_ERROR);
esp_deep_sleep_start();
}
#endif
}
void SdCard_Init(void) {
#ifndef SINGLE_SPI_ENABLE
#ifdef SD_MMC_1BIT_MODE
pinMode(2, INPUT_PULLUP);
while (!SD_MMC.begin("/sdcard", true)) {
#else
pinMode(SPISD_CS, OUTPUT);
digitalWrite(SPISD_CS, HIGH);
spiSD.begin(SPISD_SCK, SPISD_MISO, SPISD_MOSI, SPISD_CS);
spiSD.setFrequency(1000000);
while (!SD.begin(SPISD_CS, spiSD)) {
#endif
#else
#ifdef SD_MMC_1BIT_MODE
pinMode(2, INPUT_PULLUP);
while (!SD_MMC.begin("/sdcard", true)) {
#else
while (!SD.begin(SPISD_CS)) {
#endif
#endif
Log_Println((char *) FPSTR(unableToMountSd), LOGLEVEL_ERROR);
delay(500);
#ifdef SHUTDOWN_IF_SD_BOOT_FAILS
if (millis() >= deepsleepTimeAfterBootFails * 1000) {
Log_Println((char *) FPSTR(sdBootFailedDeepsleep), LOGLEVEL_ERROR);
esp_deep_sleep_start();
}
#endif
}
} }
void SdCard_Exit(void)
{
void SdCard_Exit(void) {
// SD card goto idle mode // SD card goto idle mode
#ifdef SD_MMC_1BIT_MODE
SD_MMC.end();
#endif
#ifdef SD_MMC_1BIT_MODE
SD_MMC.end();
#endif
} }
sdcard_type_t SdCard_GetType(void)
{
sdcard_type_t SdCard_GetType(void) {
sdcard_type_t cardType; sdcard_type_t cardType;
#ifdef SD_MMC_1BIT_MODE
Log_Println((char *)FPSTR(sdMountedMmc1BitMode), LOGLEVEL_NOTICE);
cardType = SD_MMC.cardType();
#else
Log_Println((char *)FPSTR(sdMountedSpiMode), LOGLEVEL_NOTICE);
cardType = SD.cardType();
#endif
return cardType;
#ifdef SD_MMC_1BIT_MODE
Log_Println((char *) FPSTR(sdMountedMmc1BitMode), LOGLEVEL_NOTICE);
cardType = SD_MMC.cardType();
#else
Log_Println((char *) FPSTR(sdMountedSpiMode), LOGLEVEL_NOTICE);
cardType = SD.cardType();
#endif
return cardType;
} }
// Check if file-type is correct // Check if file-type is correct
bool fileValid(const char *_fileItem)
{
bool fileValid(const char *_fileItem) {
const char ch = '/'; const char ch = '/';
char *subst; char *subst;
subst = strrchr(_fileItem, ch); // Don't use files that start with . subst = strrchr(_fileItem, ch); // Don't use files that start with .
return (!startsWith(subst, (char *)"/.")) &&
return (!startsWith(subst, (char *) "/.")) &&
(endsWith(_fileItem, ".mp3") || endsWith(_fileItem, ".MP3") || (endsWith(_fileItem, ".mp3") || endsWith(_fileItem, ".MP3") ||
endsWith(_fileItem, ".aac") || endsWith(_fileItem, ".AAC") || endsWith(_fileItem, ".aac") || endsWith(_fileItem, ".AAC") ||
endsWith(_fileItem, ".m3u") || endsWith(_fileItem, ".M3U") || endsWith(_fileItem, ".m3u") || endsWith(_fileItem, ".M3U") ||
@ -91,46 +82,41 @@ bool fileValid(const char *_fileItem)
/* Puts SD-file(s) or directory into a playlist /* Puts SD-file(s) or directory into a playlist
First element of array always contains the number of payload-items. */ First element of array always contains the number of payload-items. */
char **SdCard_ReturnPlaylist(const char *fileName)
{
char **SdCard_ReturnPlaylist(const char *fileName) {
static char **files; static char **files;
char fileNameBuf[255]; char fileNameBuf[255];
File fileOrDirectory = gFSystem.open(fileName); File fileOrDirectory = gFSystem.open(fileName);
snprintf(Log_Buffer, Log_BufferLength, "%s: %u", (char *)FPSTR(freeMemory), ESP.getFreeHeap());
snprintf(Log_Buffer, Log_BufferLength, "%s: %u", (char *) FPSTR(freeMemory), ESP.getFreeHeap());
Log_Println(Log_Buffer, LOGLEVEL_DEBUG); Log_Println(Log_Buffer, LOGLEVEL_DEBUG);
if (files != NULL)
{ // If **ptr already exists, de-allocate its memory
Log_Println((char *)FPSTR(releaseMemoryOfOldPlaylist), LOGLEVEL_DEBUG);
if (files != NULL) { // If **ptr already exists, de-allocate its memory
Log_Println((char *) FPSTR(releaseMemoryOfOldPlaylist), LOGLEVEL_DEBUG);
--files; --files;
freeMultiCharArray(files, strtoul(*files, NULL, 10)); freeMultiCharArray(files, strtoul(*files, NULL, 10));
snprintf(Log_Buffer, Log_BufferLength, "%s: %u", (char *)FPSTR(freeMemoryAfterFree), ESP.getFreeHeap());
snprintf(Log_Buffer, Log_BufferLength, "%s: %u", (char *) FPSTR(freeMemoryAfterFree), ESP.getFreeHeap());
Log_Println(Log_Buffer, LOGLEVEL_DEBUG); Log_Println(Log_Buffer, LOGLEVEL_DEBUG);
} }
if (!fileOrDirectory)
{
Log_Println((char *)FPSTR(dirOrFileDoesNotExist), LOGLEVEL_ERROR);
if (!fileOrDirectory) {
Log_Println((char *) FPSTR(dirOrFileDoesNotExist), LOGLEVEL_ERROR);
return NULL; return NULL;
} }
// File-mode // File-mode
if (!fileOrDirectory.isDirectory())
{
files = (char **)x_malloc(sizeof(char *) * 2);
if (files == NULL)
{
Log_Println((char *)FPSTR(unableToAllocateMemForPlaylist), LOGLEVEL_ERROR);
if (!fileOrDirectory.isDirectory()) {
files = (char **) x_malloc(sizeof(char *) * 2);
if (files == NULL) {
Log_Println((char *) FPSTR(unableToAllocateMemForPlaylist), LOGLEVEL_ERROR);
System_IndicateError(); System_IndicateError();
return NULL; return NULL;
} }
Log_Println((char *)FPSTR(fileModeDetected), LOGLEVEL_INFO);
strncpy(fileNameBuf, (char *)fileOrDirectory.name(), sizeof(fileNameBuf) / sizeof(fileNameBuf[0]));
Log_Println((char *) FPSTR(fileModeDetected), LOGLEVEL_INFO);
strncpy(fileNameBuf, (char *) fileOrDirectory.name(), sizeof(fileNameBuf) / sizeof(fileNameBuf[0]));
if (fileValid(fileNameBuf)) if (fileValid(fileNameBuf))
{ {
files = (char **)x_malloc(sizeof(char *) * 2);
files = (char **) x_malloc(sizeof(char *) * 2);
files[1] = x_strdup(fileNameBuf); files[1] = x_strdup(fileNameBuf);
} }
files[0] = x_strdup("1"); // Number of files is always 1 in file-mode files[0] = x_strdup("1"); // Number of files is always 1 in file-mode
@ -141,41 +127,32 @@ char **SdCard_ReturnPlaylist(const char *fileName)
// Directory-mode // Directory-mode
uint16_t allocCount = 1; uint16_t allocCount = 1;
uint16_t allocSize = 512; uint16_t allocSize = 512;
if (psramInit())
{
if (psramInit()) {
allocSize = 16384; // There's enough PSRAM. So we don't have to care... allocSize = 16384; // There's enough PSRAM. So we don't have to care...
} }
char *serializedPlaylist; char *serializedPlaylist;
serializedPlaylist = (char *)x_calloc(allocSize, sizeof(char));
serializedPlaylist = (char *) x_calloc(allocSize, sizeof(char));
while (true)
{
while (true) {
File fileItem = fileOrDirectory.openNextFile(); File fileItem = fileOrDirectory.openNextFile();
if (!fileItem)
{
if (!fileItem) {
break; break;
} }
if (fileItem.isDirectory())
{
if (fileItem.isDirectory()) {
continue; continue;
}
else
{
strncpy(fileNameBuf, (char *)fileItem.name(), sizeof(fileNameBuf) / sizeof(fileNameBuf[0]));
} else {
strncpy(fileNameBuf, (char *) fileItem.name(), sizeof(fileNameBuf) / sizeof(fileNameBuf[0]));
// Don't support filenames that start with "." and only allow .mp3 // Don't support filenames that start with "." and only allow .mp3
if (fileValid(fileNameBuf))
{
if (fileValid(fileNameBuf)) {
/*snprintf(Log_Buffer, Log_BufferLength, "%s: %s", (char *) FPSTR(nameOfFileFound), fileNameBuf); /*snprintf(Log_Buffer, Log_BufferLength, "%s: %s", (char *) FPSTR(nameOfFileFound), fileNameBuf);
Log_Println(Log_Buffer, LOGLEVEL_INFO);*/ Log_Println(Log_Buffer, LOGLEVEL_INFO);*/
if ((strlen(serializedPlaylist) + strlen(fileNameBuf) + 2) >= allocCount * allocSize)
{
serializedPlaylist = (char *)realloc(serializedPlaylist, ++allocCount * allocSize);
Log_Println((char *)FPSTR(reallocCalled), LOGLEVEL_DEBUG);
if (serializedPlaylist == NULL)
{
Log_Println((char *)FPSTR(unableToAllocateMemForLinearPlaylist), LOGLEVEL_ERROR);
if ((strlen(serializedPlaylist) + strlen(fileNameBuf) + 2) >= allocCount * allocSize) {
serializedPlaylist = (char *) realloc(serializedPlaylist, ++allocCount * allocSize);
Log_Println((char *) FPSTR(reallocCalled), LOGLEVEL_DEBUG);
if (serializedPlaylist == NULL) {
Log_Println((char *) FPSTR(unableToAllocateMemForLinearPlaylist), LOGLEVEL_ERROR);
System_IndicateError(); System_IndicateError();
return files; return files;
} }
@ -188,20 +165,17 @@ char **SdCard_ReturnPlaylist(const char *fileName)
// Get number of elements out of serialized playlist // Get number of elements out of serialized playlist
uint32_t cnt = 0; uint32_t cnt = 0;
for (uint32_t k = 0; k < (strlen(serializedPlaylist)); k++)
{
if (serializedPlaylist[k] == '#')
{
for (uint32_t k = 0; k < (strlen(serializedPlaylist)); k++) {
if (serializedPlaylist[k] == '#') {
cnt++; cnt++;
} }
} }
// Alloc only necessary number of playlist-pointers // Alloc only necessary number of playlist-pointers
files = (char **)x_malloc(sizeof(char *) * cnt + 1);
files = (char **) x_malloc(sizeof(char *) * cnt + 1);
if (files == NULL)
{
Log_Println((char *)FPSTR(unableToAllocateMemForPlaylist), LOGLEVEL_ERROR);
if (files == NULL) {
Log_Println((char *) FPSTR(unableToAllocateMemForPlaylist), LOGLEVEL_ERROR);
System_IndicateError(); System_IndicateError();
free(serializedPlaylist); free(serializedPlaylist);
return NULL; return NULL;
@ -211,24 +185,22 @@ char **SdCard_ReturnPlaylist(const char *fileName)
char *token; char *token;
token = strtok(serializedPlaylist, stringDelimiter); token = strtok(serializedPlaylist, stringDelimiter);
uint32_t pos = 1; uint32_t pos = 1;
while (token != NULL)
{
while (token != NULL) {
files[pos++] = x_strdup(token); files[pos++] = x_strdup(token);
token = strtok(NULL, stringDelimiter); token = strtok(NULL, stringDelimiter);
} }
free(serializedPlaylist); free(serializedPlaylist);
files[0] = (char *)x_malloc(sizeof(char) * 5);
files[0] = (char *) x_malloc(sizeof(char) * 5);
if (files[0] == NULL)
{
Log_Println((char *)FPSTR(unableToAllocateMemForPlaylist), LOGLEVEL_ERROR);
if (files[0] == NULL) {
Log_Println((char *) FPSTR(unableToAllocateMemForPlaylist), LOGLEVEL_ERROR);
System_IndicateError(); System_IndicateError();
return NULL; return NULL;
} }
sprintf(files[0], "%u", cnt); sprintf(files[0], "%u", cnt);
snprintf(Log_Buffer, Log_BufferLength, "%s: %d", (char *)FPSTR(numberOfValidFiles), cnt);
snprintf(Log_Buffer, Log_BufferLength, "%s: %d", (char *) FPSTR(numberOfValidFiles), cnt);
Log_Println(Log_Buffer, LOGLEVEL_NOTICE); Log_Println(Log_Buffer, LOGLEVEL_NOTICE);
return ++files; // return ptr+1 (starting at 1st payload-item); ptr+0 contains number of items return ++files; // return ptr+1 (starting at 1st payload-item); ptr+0 contains number of items

145
src/System.cpp

@ -28,202 +28,165 @@ volatile uint8_t System_OperationMode;
void System_SleepHandler(void); void System_SleepHandler(void);
void System_DeepSleepManager(void); void System_DeepSleepManager(void);
void System_Init(void)
{
void System_Init(void) {
srand(esp_random()); srand(esp_random());
pinMode(POWER, OUTPUT); pinMode(POWER, OUTPUT);
digitalWrite(POWER, HIGH); digitalWrite(POWER, HIGH);
gPrefsRfid.begin((char *)FPSTR(prefsRfidNamespace));
gPrefsSettings.begin((char *)FPSTR(prefsSettingsNamespace));
gPrefsRfid.begin((char *) FPSTR(prefsRfidNamespace));
gPrefsSettings.begin((char *) FPSTR(prefsSettingsNamespace));
// Get maximum inactivity-time from NVS // Get maximum inactivity-time from NVS
uint32_t nvsMInactivityTime = gPrefsSettings.getUInt("mInactiviyT", 0); uint32_t nvsMInactivityTime = gPrefsSettings.getUInt("mInactiviyT", 0);
if (nvsMInactivityTime)
{
if (nvsMInactivityTime) {
System_MaxInactivityTime = nvsMInactivityTime; System_MaxInactivityTime = nvsMInactivityTime;
snprintf(Log_Buffer, Log_BufferLength, "%s: %u", (char *)FPSTR(restoredMaxInactivityFromNvs), nvsMInactivityTime);
snprintf(Log_Buffer, Log_BufferLength, "%s: %u", (char *) FPSTR(restoredMaxInactivityFromNvs), nvsMInactivityTime);
Log_Println(Log_Buffer, LOGLEVEL_INFO); Log_Println(Log_Buffer, LOGLEVEL_INFO);
}
else
{
} else {
gPrefsSettings.putUInt("mInactiviyT", System_MaxInactivityTime); gPrefsSettings.putUInt("mInactiviyT", System_MaxInactivityTime);
Log_Println((char *)FPSTR(wroteMaxInactivityToNvs), LOGLEVEL_ERROR);
Log_Println((char *) FPSTR(wroteMaxInactivityToNvs), LOGLEVEL_ERROR);
} }
System_OperationMode = gPrefsSettings.getUChar("operationMode", OPMODE_NORMAL); System_OperationMode = gPrefsSettings.getUChar("operationMode", OPMODE_NORMAL);
} }
void System_Cyclic(void)
{
void System_Cyclic(void) {
System_SleepHandler(); System_SleepHandler();
System_DeepSleepManager(); System_DeepSleepManager();
} }
void System_UpdateActivityTimer(void)
{
void System_UpdateActivityTimer(void) {
System_LastTimeActiveTimestamp = millis(); System_LastTimeActiveTimestamp = millis();
} }
void System_RequestSleep(void)
{
void System_RequestSleep(void) {
System_GoToSleep = true; System_GoToSleep = true;
} }
bool System_IsSleepRequested(void)
{
bool System_IsSleepRequested(void) {
return System_GoToSleep; return System_GoToSleep;
} }
bool System_SetSleepTimer(uint8_t minutes)
{
bool System_SetSleepTimer(uint8_t minutes) {
bool sleepTimerEnabled = false; bool sleepTimerEnabled = false;
if (System_SleepTimerStartTimestamp && (System_SleepTimer == minutes))
{
if (System_SleepTimerStartTimestamp && (System_SleepTimer == minutes)) {
System_SleepTimerStartTimestamp = 0u; System_SleepTimerStartTimestamp = 0u;
Led_ResetToInitialBrightness(); Led_ResetToInitialBrightness();
Log_Println((char *)FPSTR(modificatorSleepd), LOGLEVEL_NOTICE);
publishMqtt((char *)FPSTR(topicLedBrightnessState), Led_GetBrightness(), false);
}
else
{
Log_Println((char *) FPSTR(modificatorSleepd), LOGLEVEL_NOTICE);
publishMqtt((char *) FPSTR(topicLedBrightnessState), Led_GetBrightness(), false);
} else {
System_SleepTimer = minutes; System_SleepTimer = minutes;
System_SleepTimerStartTimestamp = millis(); System_SleepTimerStartTimestamp = millis();
sleepTimerEnabled = true; sleepTimerEnabled = true;
Led_ResetToNightBrightness(); Led_ResetToNightBrightness();
Log_Println((char *)FPSTR(modificatorSleepTimer60), LOGLEVEL_NOTICE);
publishMqtt((char *)FPSTR(topicSleepTimerState), System_SleepTimer, false);
publishMqtt((char *)FPSTR(topicLedBrightnessState), Led_GetBrightness(), false);
Log_Println((char *) FPSTR(modificatorSleepTimer60), LOGLEVEL_NOTICE);
publishMqtt((char *) FPSTR(topicSleepTimerState), System_SleepTimer, false);
publishMqtt((char *) FPSTR(topicLedBrightnessState), Led_GetBrightness(), false);
} }
return sleepTimerEnabled; return sleepTimerEnabled;
} }
void System_DisableSleepTimer(void)
{
void System_DisableSleepTimer(void) {
System_SleepTimerStartTimestamp = 0u; System_SleepTimerStartTimestamp = 0u;
} }
bool System_IsSleepTimerEnabled(void)
{
bool System_IsSleepTimerEnabled(void) {
return (System_SleepTimerStartTimestamp > 0u); return (System_SleepTimerStartTimestamp > 0u);
} }
uint32_t System_GetSleepTimerTimeStamp(void)
{
uint32_t System_GetSleepTimerTimeStamp(void) {
return System_SleepTimerStartTimestamp; return System_SleepTimerStartTimestamp;
} }
bool System_IsSleepPending(void)
{
bool System_IsSleepPending(void) {
return System_Sleeping; return System_Sleeping;
} }
uint8_t System_GetSleepTimer(void)
{
uint8_t System_GetSleepTimer(void) {
return System_SleepTimer; return System_SleepTimer;
} }
void System_SetLockControls(bool value)
{
void System_SetLockControls(bool value) {
System_LockControls = value; System_LockControls = value;
} }
void System_ToggleLockControls(void)
{
void System_ToggleLockControls(void) {
System_LockControls = !System_LockControls; System_LockControls = !System_LockControls;
if (System_LockControls)
{
Log_Println((char *)FPSTR(modificatorAllButtonsLocked), LOGLEVEL_NOTICE);
publishMqtt((char *)FPSTR(topicLockControlsState), "ON", false);
if (System_LockControls) {
Log_Println((char *) FPSTR(modificatorAllButtonsLocked), LOGLEVEL_NOTICE);
publishMqtt((char *) FPSTR(topicLockControlsState), "ON", false);
System_IndicateOk(); System_IndicateOk();
}
else
{
Log_Println((char *)FPSTR(modificatorAllButtonsUnlocked), LOGLEVEL_NOTICE);
publishMqtt((char *)FPSTR(topicLockControlsState), "OFF", false);
} else {
Log_Println((char *) FPSTR(modificatorAllButtonsUnlocked), LOGLEVEL_NOTICE);
publishMqtt((char *) FPSTR(topicLockControlsState), "OFF", false);
} }
} }
bool System_AreControlsLocked(void)
{
bool System_AreControlsLocked(void) {
return System_LockControls; return System_LockControls;
} }
void System_IndicateError(void)
{
void System_IndicateError(void) {
Led_Indicate(LedIndicatorType::Error); Led_Indicate(LedIndicatorType::Error);
} }
void System_IndicateOk(void)
{
void System_IndicateOk(void) {
Led_Indicate(LedIndicatorType::Ok); Led_Indicate(LedIndicatorType::Ok);
} }
// Writes to NVS, if bluetooth or "normal" mode is desired // Writes to NVS, if bluetooth or "normal" mode is desired
void System_SetOperationMode(uint8_t opMode)
{
void System_SetOperationMode(uint8_t opMode) {
uint8_t currentOperationMode = gPrefsSettings.getUChar("operationMode", OPMODE_NORMAL); uint8_t currentOperationMode = gPrefsSettings.getUChar("operationMode", OPMODE_NORMAL);
if (currentOperationMode != opMode)
{
if (gPrefsSettings.putUChar("operationMode", opMode))
{
if (currentOperationMode != opMode) {
if (gPrefsSettings.putUChar("operationMode", opMode)) {
ESP.restart(); ESP.restart();
} }
} }
} }
uint8_t System_GetOperationMode(void)
{
uint8_t System_GetOperationMode(void) {
return System_OperationMode; return System_OperationMode;
} }
// Reads from NVS, if bluetooth or "normal" mode is desired // Reads from NVS, if bluetooth or "normal" mode is desired
uint8_t System_GetOperationModeFromNvs(void)
{
uint8_t System_GetOperationModeFromNvs(void) {
return gPrefsSettings.getUChar("operationMode", OPMODE_NORMAL); return gPrefsSettings.getUChar("operationMode", OPMODE_NORMAL);
} }
// Sets deep-sleep-flag if max. inactivity-time is reached // Sets deep-sleep-flag if max. inactivity-time is reached
void System_SleepHandler(void)
{
void System_SleepHandler(void) {
unsigned long m = millis(); unsigned long m = millis();
if (m >= System_LastTimeActiveTimestamp && (m - System_LastTimeActiveTimestamp >= (System_MaxInactivityTime * 1000u * 60u)))
{
Log_Println((char *)FPSTR(goToSleepDueToIdle), LOGLEVEL_INFO);
if (m >= System_LastTimeActiveTimestamp && (m - System_LastTimeActiveTimestamp >= (System_MaxInactivityTime * 1000u * 60u))) {
Log_Println((char *) FPSTR(goToSleepDueToIdle), LOGLEVEL_INFO);
System_RequestSleep(); System_RequestSleep();
}
else if (System_SleepTimerStartTimestamp > 00)
{
if (m - System_SleepTimerStartTimestamp >= (System_SleepTimer * 1000u * 60u))
{
Log_Println((char *)FPSTR(goToSleepDueToTimer), LOGLEVEL_INFO);
} else if (System_SleepTimerStartTimestamp > 00) {
if (m - System_SleepTimerStartTimestamp >= (System_SleepTimer * 1000u * 60u)) {
Log_Println((char *) FPSTR(goToSleepDueToTimer), LOGLEVEL_INFO);
System_RequestSleep(); System_RequestSleep();
} }
} }
} }
// Puts uC to deep-sleep if flag is set // Puts uC to deep-sleep if flag is set
void System_DeepSleepManager(void)
{
if (System_GoToSleep)
{
if (System_Sleeping)
{
void System_DeepSleepManager(void) {
if (System_GoToSleep) {
if (System_Sleeping) {
return; return;
} }
System_Sleeping = true; System_Sleeping = true;
Log_Println((char *)FPSTR(goToSleepNow), LOGLEVEL_NOTICE);
Log_Println((char *) FPSTR(goToSleepNow), LOGLEVEL_NOTICE);
Mqtt_Exit(); Mqtt_Exit();
Led_Exit(); Led_Exit();
#ifdef USE_LAST_VOLUME_AFTER_REBOOT
gPrefsSettings.putUInt("previousVolume", AudioPlayer_GetCurrentVolume());
#endif
#ifdef USE_LAST_VOLUME_AFTER_REBOOT
gPrefsSettings.putUInt("previousVolume", AudioPlayer_GetCurrentVolume());
#endif
SdCard_Exit(); SdCard_Exit();
Serial.flush(); Serial.flush();

566
src/Web.cpp
File diff suppressed because it is too large
View File

133
src/Wlan.cpp

@ -25,122 +25,103 @@ void accessPointStart(const char *SSID, IPAddress ip, IPAddress netmask);
bool getWifiEnableStatusFromNVS(void); bool getWifiEnableStatusFromNVS(void);
void writeWifiStatusToNVS(bool wifiStatus); void writeWifiStatusToNVS(bool wifiStatus);
void Wlan_Init(void)
{
void Wlan_Init(void) {
wifiEnabled = getWifiEnableStatusFromNVS(); wifiEnabled = getWifiEnableStatusFromNVS();
} }
void Wlan_Cyclic(void)
{
void Wlan_Cyclic(void) {
// If wifi whould not be activated, return instantly // If wifi whould not be activated, return instantly
if (!wifiEnabled)
{
if (!wifiEnabled) {
return; return;
} }
if (!wifiCheckLastTimestamp || wifiNeedsRestart)
{
if (!wifiCheckLastTimestamp || wifiNeedsRestart) {
// Get credentials from NVS // Get credentials from NVS
String strSSID = gPrefsSettings.getString("SSID", "-1"); String strSSID = gPrefsSettings.getString("SSID", "-1");
if (!strSSID.compareTo("-1"))
{
Log_Println((char *)FPSTR(ssidNotFoundInNvs), LOGLEVEL_ERROR);
if (!strSSID.compareTo("-1")) {
Log_Println((char *) FPSTR(ssidNotFoundInNvs), LOGLEVEL_ERROR);
} }
String strPassword = gPrefsSettings.getString("Password", "-1"); String strPassword = gPrefsSettings.getString("Password", "-1");
if (!strPassword.compareTo("-1"))
{
Log_Println((char *)FPSTR(wifiPwdNotFoundInNvs), LOGLEVEL_ERROR);
if (!strPassword.compareTo("-1")) {
Log_Println((char *) FPSTR(wifiPwdNotFoundInNvs), LOGLEVEL_ERROR);
} }
const char *_ssid = strSSID.c_str(); const char *_ssid = strSSID.c_str();
const char *_pwd = strPassword.c_str(); const char *_pwd = strPassword.c_str();
// Get (optional) hostname-configration from NVS // Get (optional) hostname-configration from NVS
String hostname = gPrefsSettings.getString("Hostname", "-1"); String hostname = gPrefsSettings.getString("Hostname", "-1");
if (hostname.compareTo("-1"))
{
if (hostname.compareTo("-1")) {
//WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE); //WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE);
WiFi.setHostname(hostname.c_str()); WiFi.setHostname(hostname.c_str());
snprintf(Log_Buffer, Log_BufferLength, "%s: %s", (char *)FPSTR(restoredHostnameFromNvs), hostname.c_str());
snprintf(Log_Buffer, Log_BufferLength, "%s: %s", (char *) FPSTR(restoredHostnameFromNvs), hostname.c_str());
Log_Println(Log_Buffer, LOGLEVEL_INFO); Log_Println(Log_Buffer, LOGLEVEL_INFO);
}
else
{
Log_Println((char *)FPSTR(wifiHostnameNotSet), LOGLEVEL_INFO);
} else {
Log_Println((char *) FPSTR(wifiHostnameNotSet), LOGLEVEL_INFO);
} }
// Add configration of static IP (if requested)
#ifdef STATIC_IP_ENABLE
snprintf(Log_Buffer, Log_BufferLength, "%s", (char *)FPSTR(tryStaticIpConfig));
Log_Println(Log_Buffer, LOGLEVEL_NOTICE);
if (!WiFi.config(IPAddress(LOCAL_IP), IPAddress(GATEWAY_IP), IPAddress(SUBNET_IP), IPAddress(DNS_IP)))
{
snprintf(Log_Buffer, Log_BufferLength, "%s", (char *)FPSTR(staticIPConfigFailed));
Log_Println(Log_Buffer, LOGLEVEL_ERROR);
}
#endif
// Add configration of static IP (if requested)
#ifdef STATIC_IP_ENABLE
snprintf(Log_Buffer, Log_BufferLength, "%s", (char *) FPSTR(tryStaticIpConfig));
Log_Println(Log_Buffer, LOGLEVEL_NOTICE);
if (!WiFi.config(IPAddress(LOCAL_IP), IPAddress(GATEWAY_IP), IPAddress(SUBNET_IP), IPAddress(DNS_IP))) {
snprintf(Log_Buffer, Log_BufferLength, "%s", (char *) FPSTR(staticIPConfigFailed));
Log_Println(Log_Buffer, LOGLEVEL_ERROR);
}
#endif
// Try to join local WiFi. If not successful, an access-point is opened // 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;
while (WiFi.status() != WL_CONNECTED && tryCount <= 4)
{
while (WiFi.status() != WL_CONNECTED && tryCount <= 4) {
delay(500); delay(500);
Serial.print(F(".")); Serial.print(F("."));
tryCount++; tryCount++;
wifiCheckLastTimestamp = millis(); wifiCheckLastTimestamp = millis();
if (tryCount >= 4 && WiFi.status() == WL_CONNECT_FAILED)
{
if (tryCount >= 4 && WiFi.status() == WL_CONNECT_FAILED) {
WiFi.begin(_ssid, _pwd); // ESP32-workaround (otherwise WiFi-connection sometimes fails) WiFi.begin(_ssid, _pwd); // ESP32-workaround (otherwise WiFi-connection sometimes fails)
} }
} }
if (WiFi.status() == WL_CONNECTED)
{
if (WiFi.status() == WL_CONNECTED) {
IPAddress myIP = WiFi.localIP(); IPAddress myIP = WiFi.localIP();
#if (LANGUAGE == 1)
snprintf(Log_Buffer, Log_BufferLength, "Aktuelle IP: %d.%d.%d.%d", myIP[0], myIP[1], myIP[2], myIP[3]);
#else
snprintf(Log_Buffer, Log_BufferLength, "Current IP: %d.%d.%d.%d", myIP[0], myIP[1], myIP[2], myIP[3]);
#endif
#if (LANGUAGE == 1)
snprintf(Log_Buffer, Log_BufferLength, "Aktuelle IP: %d.%d.%d.%d", myIP[0], myIP[1], myIP[2], myIP[3]);
#else
snprintf(Log_Buffer, Log_BufferLength, "Current IP: %d.%d.%d.%d", myIP[0], myIP[1], myIP[2], myIP[3]);
#endif
Log_Println(Log_Buffer, LOGLEVEL_NOTICE); Log_Println(Log_Buffer, LOGLEVEL_NOTICE);
}
else
{ // Starts AP if WiFi-connect wasn't successful
accessPointStart((char *)FPSTR(accessPointNetworkSSID), apIP, apNetmask);
} else { // Starts AP if WiFi-connect wasn't successful
accessPointStart((char *) FPSTR(accessPointNetworkSSID), apIP, apNetmask);
} }
#ifdef MDNS_ENABLE
// zero conf, make device available as <hostname>.local
if (MDNS.begin(hostname.c_str()))
{
MDNS.addService("http", "tcp", 80);
}
#endif
#ifdef MDNS_ENABLE
// zero conf, make device available as <hostname>.local
if (MDNS.begin(hostname.c_str())) {
MDNS.addService("http", "tcp", 80);
}
#endif
wifiNeedsRestart = false; wifiNeedsRestart = false;
} }
} }
void Wlan_ToggleEnable(void)
{
void Wlan_ToggleEnable(void) {
writeWifiStatusToNVS(!getWifiEnableStatusFromNVS()); writeWifiStatusToNVS(!getWifiEnableStatusFromNVS());
} }
String Wlan_GetIpAddress(void)
{
String Wlan_GetIpAddress(void) {
return WiFi.localIP().toString(); return WiFi.localIP().toString();
} }
// Initialize soft access-point // Initialize soft access-point
void accessPointStart(const char *SSID, IPAddress ip, IPAddress netmask)
{
void accessPointStart(const char *SSID, IPAddress ip, IPAddress netmask) {
WiFi.mode(WIFI_AP); WiFi.mode(WIFI_AP);
WiFi.softAPConfig(ip, ip, netmask); WiFi.softAPConfig(ip, ip, netmask);
WiFi.softAP(SSID); WiFi.softAP(SSID);
delay(500); delay(500);
Log_Println((char *)FPSTR(apReady), LOGLEVEL_NOTICE);
Log_Println((char *) FPSTR(apReady), LOGLEVEL_NOTICE);
snprintf(Log_Buffer, Log_BufferLength, "IP-Adresse: %d.%d.%d.%d", apIP[0], apIP[1], apIP[2], apIP[3]); snprintf(Log_Buffer, Log_BufferLength, "IP-Adresse: %d.%d.%d.%d", apIP[0], apIP[1], apIP[2], apIP[3]);
Log_Println(Log_Buffer, LOGLEVEL_NOTICE); Log_Println(Log_Buffer, LOGLEVEL_NOTICE);
@ -150,13 +131,11 @@ void accessPointStart(const char *SSID, IPAddress ip, IPAddress netmask)
} }
// Reads stored WiFi-status from NVS // Reads stored WiFi-status from NVS
bool getWifiEnableStatusFromNVS(void)
{
bool getWifiEnableStatusFromNVS(void) {
uint32_t wifiStatus = gPrefsSettings.getUInt("enableWifi", 99); uint32_t wifiStatus = gPrefsSettings.getUInt("enableWifi", 99);
// if not set so far, preseed with 1 (enable) // if not set so far, preseed with 1 (enable)
if (wifiStatus == 99)
{
if (wifiStatus == 99) {
gPrefsSettings.putUInt("enableWifi", 1); gPrefsSettings.putUInt("enableWifi", 1);
wifiStatus = 1; wifiStatus = 1;
} }
@ -165,34 +144,26 @@ bool getWifiEnableStatusFromNVS(void)
} }
// Writes to NVS whether WiFi should be activated // Writes to NVS whether WiFi should be activated
void writeWifiStatusToNVS(bool wifiStatus)
{
if (!wifiStatus)
{
if (gPrefsSettings.putUInt("enableWifi", 0))
{ // disable
Log_Println((char *)FPSTR(wifiDisabledAfterRestart), LOGLEVEL_NOTICE);
if (gPlayProperties.playMode == WEBSTREAM)
{
void writeWifiStatusToNVS(bool wifiStatus) {
if (!wifiStatus) {
if (gPrefsSettings.putUInt("enableWifi", 0)) { // disable
Log_Println((char *) FPSTR(wifiDisabledAfterRestart), LOGLEVEL_NOTICE);
if (gPlayProperties.playMode == WEBSTREAM) {
AudioPlayer_TrackControlToQueueSender(STOP); AudioPlayer_TrackControlToQueueSender(STOP);
} }
delay(300); delay(300);
WiFi.mode(WIFI_OFF); WiFi.mode(WIFI_OFF);
wifiEnabled = false; wifiEnabled = false;
} }
}
else
{
if (gPrefsSettings.putUInt("enableWifi", 1))
{ // enable
Log_Println((char *)FPSTR(wifiEnabledAfterRestart), LOGLEVEL_NOTICE);
} else {
if (gPrefsSettings.putUInt("enableWifi", 1)) { // enable
Log_Println((char *) FPSTR(wifiEnabledAfterRestart), LOGLEVEL_NOTICE);
wifiNeedsRestart = true; wifiNeedsRestart = true;
wifiEnabled = true; wifiEnabled = true;
} }
} }
} }
bool Wlan_IsConnected(void)
{
bool Wlan_IsConnected(void) {
return (WiFi.status() == WL_CONNECTED); return (WiFi.status() == WL_CONNECTED);
} }

175
src/main.cpp

@ -25,76 +25,68 @@
#include "Wlan.h" #include "Wlan.h"
#ifdef PLAY_LAST_RFID_AFTER_REBOOT #ifdef PLAY_LAST_RFID_AFTER_REBOOT
bool recoverLastRfid = true;
bool recoverLastRfid = true;
#endif #endif
//////////// ////////////
#if (HAL == 2) #if (HAL == 2)
#include "AC101.h"
static TwoWire i2cBusOne = TwoWire(0);
static AC101 ac(&i2cBusOne);
#include "AC101.h"
static TwoWire i2cBusOne = TwoWire(0);
static AC101 ac(&i2cBusOne);
#endif #endif
// I2C // I2C
#if defined(RFID_READER_TYPE_MFRC522_I2C) || defined(PORT_EXPANDER_ENABLE) #if defined(RFID_READER_TYPE_MFRC522_I2C) || defined(PORT_EXPANDER_ENABLE)
TwoWire i2cBusTwo = TwoWire(1);
TwoWire i2cBusTwo = TwoWire(1);
#endif #endif
#ifdef PLAY_LAST_RFID_AFTER_REBOOT #ifdef PLAY_LAST_RFID_AFTER_REBOOT
// Get last RFID-tag applied from NVS
void recoverLastRfidPlayed(void)
{
if (recoverLastRfid)
{
if (System_GetOperationMode() == OPMODE_BLUETOOTH)
{ // Don't recover if BT-mode is desired
// Get last RFID-tag applied from NVS
void recoverLastRfidPlayed(void) {
if (recoverLastRfid) {
if (System_GetOperationMode() == OPMODE_BLUETOOTH) { // Don't recover if BT-mode is desired
recoverLastRfid = false;
return;
}
recoverLastRfid = false; recoverLastRfid = false;
return;
}
recoverLastRfid = false;
String lastRfidPlayed = gPrefsSettings.getString("lastRfid", "-1");
if (!lastRfidPlayed.compareTo("-1"))
{
Log_Println((char *)FPSTR(unableToRestoreLastRfidFromNVS), LOGLEVEL_INFO);
}
else
{
char *lastRfid = x_strdup(lastRfidPlayed.c_str());
xQueueSend(gRfidCardQueue, &lastRfid, 0);
snprintf(Log_Buffer, Log_BufferLength, "%s: %s", (char *)FPSTR(restoredLastRfidFromNVS), lastRfidPlayed.c_str());
Log_Println(Log_Buffer, LOGLEVEL_INFO);
String lastRfidPlayed = gPrefsSettings.getString("lastRfid", "-1");
if (!lastRfidPlayed.compareTo("-1")) {
Log_Println((char *) FPSTR(unableToRestoreLastRfidFromNVS), LOGLEVEL_INFO);
} else {
char *lastRfid = x_strdup(lastRfidPlayed.c_str());
xQueueSend(gRfidCardQueue, lastRfid, 0);
snprintf(Log_Buffer, Log_BufferLength, "%s: %s", (char *) FPSTR(restoredLastRfidFromNVS), lastRfidPlayed.c_str());
Log_Println(Log_Buffer, LOGLEVEL_INFO);
}
} }
} }
}
#endif #endif
// Print the wake-up reason why ESP32 is awake now // Print the wake-up reason why ESP32 is awake now
void printWakeUpReason()
{
void printWakeUpReason() {
esp_sleep_wakeup_cause_t wakeup_reason; esp_sleep_wakeup_cause_t wakeup_reason;
wakeup_reason = esp_sleep_get_wakeup_cause(); wakeup_reason = esp_sleep_get_wakeup_cause();
switch (wakeup_reason)
{
case ESP_SLEEP_WAKEUP_EXT0:
Serial.println(F("Wakeup caused by push button"));
break;
case ESP_SLEEP_WAKEUP_EXT1:
Serial.println(F("Wakeup caused by low power card detection"));
break;
case ESP_SLEEP_WAKEUP_TIMER:
Serial.println(F("Wakeup caused by timer"));
break;
case ESP_SLEEP_WAKEUP_TOUCHPAD:
Serial.println(F("Wakeup caused by touchpad"));
break;
case ESP_SLEEP_WAKEUP_ULP:
Serial.println(F("Wakeup caused by ULP program"));
break;
default:
Serial.printf("Wakeup was not caused by deep sleep: %d\n", wakeup_reason);
break;
switch (wakeup_reason) {
case ESP_SLEEP_WAKEUP_EXT0:
Serial.println(F("Wakeup caused by push button"));
break;
case ESP_SLEEP_WAKEUP_EXT1:
Serial.println(F("Wakeup caused by low power card detection"));
break;
case ESP_SLEEP_WAKEUP_TIMER:
Serial.println(F("Wakeup caused by timer"));
break;
case ESP_SLEEP_WAKEUP_TOUCHPAD:
Serial.println(F("Wakeup caused by touchpad"));
break;
case ESP_SLEEP_WAKEUP_ULP:
Serial.println(F("Wakeup caused by ULP program"));
break;
default:
Serial.printf("Wakeup was not caused by deep sleep: %d\n", wakeup_reason);
break;
} }
} }
@ -107,10 +99,10 @@ void setup()
memset(&gPlayProperties, 0, sizeof(gPlayProperties)); memset(&gPlayProperties, 0, sizeof(gPlayProperties));
gPlayProperties.playlistFinished = true; gPlayProperties.playlistFinished = true;
#ifdef PLAY_MONO_SPEAKER
gPlayProperties.newPlayMono = true;
gPlayProperties.currentPlayMono = true;
#endif
#ifdef PLAY_MONO_SPEAKER
gPlayProperties.newPlayMono = true;
gPlayProperties.currentPlayMono = true;
#endif
// Examples for serialized RFID-actions that are stored in NVS // Examples for serialized RFID-actions that are stored in NVS
// #<file/folder>#<startPlayPositionInBytes>#<playmode>#<trackNumberToStartWith> // #<file/folder>#<startPlayPositionInBytes>#<playmode>#<trackNumberToStartWith>
@ -123,32 +115,31 @@ void setup()
Led_Init(); Led_Init();
#if (HAL == 2)
i2cBusOne.begin(IIC_DATA, IIC_CLK, 40000);
#if (HAL == 2)
i2cBusOne.begin(IIC_DATA, IIC_CLK, 40000);
while (not ac.begin())
{
Serial.println(F("AC101 Failed!"));
delay(1000);
}
Serial.println(F("AC101 via I2C - OK!"));
while (not ac.begin()) {
Serial.println(F("AC101 Failed!"));
delay(1000);
}
Serial.println(F("AC101 via I2C - OK!"));
pinMode(22, OUTPUT);
digitalWrite(22, HIGH);
pinMode(22, OUTPUT);
digitalWrite(22, HIGH);
pinMode(GPIO_PA_EN, OUTPUT);
digitalWrite(GPIO_PA_EN, HIGH);
Serial.println(F("Built-in amplifier enabled\n"));
#endif
pinMode(GPIO_PA_EN, OUTPUT);
digitalWrite(GPIO_PA_EN, HIGH);
Serial.println(F("Built-in amplifier enabled\n"));
#endif
SdCard_Init(); SdCard_Init();
// Init 2nd i2c-bus if RC522 is used with i2c or if port-expander is enabled
#if defined(RFID_READER_TYPE_MFRC522_I2C) || defined(PORT_EXPANDER_ENABLE)
i2cBusTwo.begin(ext_IIC_DATA, ext_IIC_CLK, 40000);
delay(50);
Log_Println((char *)FPSTR(rfidScannerReady), LOGLEVEL_DEBUG);
#endif
// Init 2nd i2c-bus if RC522 is used with i2c or if port-expander is enabled
#if defined(RFID_READER_TYPE_MFRC522_I2C) || defined(PORT_EXPANDER_ENABLE)
i2cBusTwo.begin(ext_IIC_DATA, ext_IIC_CLK, 40000);
delay(50);
Log_Println((char *) FPSTR(rfidScannerReady), LOGLEVEL_DEBUG);
#endif
// welcome message // welcome message
Serial.println(F("")); Serial.println(F(""));
@ -166,20 +157,13 @@ void setup()
// show SD card type // show SD card type
sdcard_type_t cardType = SdCard_GetType(); sdcard_type_t cardType = SdCard_GetType();
Serial.print(F("SD card type: ")); Serial.print(F("SD card type: "));
if (cardType == CARD_MMC)
{
if (cardType == CARD_MMC) {
Serial.println(F("MMC")); Serial.println(F("MMC"));
}
else if (cardType == CARD_SD)
{
} else if (cardType == CARD_SD) {
Serial.println(F("SDSC")); Serial.println(F("SDSC"));
}
else if (cardType == CARD_SDHC)
{
} else if (cardType == CARD_SDHC) {
Serial.println(F("SDHC")); Serial.println(F("SDHC"));
}
else
{
} else {
Serial.println(F("UNKNOWN")); Serial.println(F("UNKNOWN"));
} }
@ -194,32 +178,25 @@ void setup()
Wlan_Init(); Wlan_Init();
Bluetooth_Init(); Bluetooth_Init();
if (OPMODE_NORMAL == System_GetOperationMode())
{
if (OPMODE_NORMAL == System_GetOperationMode()) {
Wlan_Cyclic(); Wlan_Cyclic();
} }
IrReceiver_Init(); IrReceiver_Init();
System_UpdateActivityTimer(); // initial set after boot System_UpdateActivityTimer(); // initial set after boot
Led_Indicate(LedIndicatorType::BootComplete); Led_Indicate(LedIndicatorType::BootComplete);
snprintf(Log_Buffer, Log_BufferLength, "%s: %u", (char *)FPSTR(freeHeapAfterSetup), ESP.getFreeHeap());
snprintf(Log_Buffer, Log_BufferLength, "%s: %u", (char *) FPSTR(freeHeapAfterSetup), ESP.getFreeHeap());
Log_Println(Log_Buffer, LOGLEVEL_DEBUG); Log_Println(Log_Buffer, LOGLEVEL_DEBUG);
Serial.printf("PSRAM: %u bytes\n", ESP.getPsramSize()); Serial.printf("PSRAM: %u bytes\n", ESP.getPsramSize());
} }
void loop()
{
void loop() {
Rfid_Cyclic(); Rfid_Cyclic();
if (OPMODE_BLUETOOTH == System_GetOperationMode())
{
if (OPMODE_BLUETOOTH == System_GetOperationMode()) {
Bluetooth_Cyclic(); Bluetooth_Cyclic();
}
else
{
} else {
Wlan_Cyclic(); Wlan_Cyclic();
Web_Cyclic(); Web_Cyclic();
Ftp_Cyclic(); Ftp_Cyclic();
@ -234,9 +211,9 @@ void loop()
System_Cyclic(); System_Cyclic();
Rfid_PreferenceLookupHandler(); Rfid_PreferenceLookupHandler();
#ifdef PLAY_LAST_RFID_AFTER_REBOOT
recoverLastRfidPlayed();
#endif
#ifdef PLAY_LAST_RFID_AFTER_REBOOT
recoverLastRfidPlayed();
#endif
IrReceiver_Cyclic(); IrReceiver_Cyclic();

Loading…
Cancel
Save