@ -1,12 +1,12 @@
// Define modules to compile:
// Define modules to compile:
# define MQTT
# define FTP
//#define NEOPIXEL
# define MQTT_ENABLE
# define FTP_ENABLE
# define NEOPIXEL_ENABLE
# include <ESP32Encoder.h>
# include <ESP32Encoder.h>
# include "Arduino.h"
# include "Arduino.h"
# include <WiFi.h>
# include <WiFi.h>
# ifdef FTP
# ifdef FTP_ENABLE
# include "ESP32FtpServer.h"
# include "ESP32FtpServer.h"
# endif
# endif
# include "Audio.h"
# include "Audio.h"
@ -16,13 +16,13 @@
# include "esp_task_wdt.h"
# include "esp_task_wdt.h"
# include <MFRC522.h>
# include <MFRC522.h>
# include <Preferences.h>
# include <Preferences.h>
# ifdef MQTT
# ifdef MQTT_ENABLE
# include <PubSubClient.h>
# include <PubSubClient.h>
# endif
# endif
# include <WebServer.h>
# include <WebServer.h>
# ifdef NEOPIXEL
//#ifdef NEOPIXEL_ENABLE
# include <FastLED.h>
# include <FastLED.h>
# endif
//#endif
# include "logmessages.h"
# include "logmessages.h"
# include <ESPAsyncWebServer.h>
# include <ESPAsyncWebServer.h>
# include "website.h"
# include "website.h"
@ -80,11 +80,11 @@ char logBuf[160]; // Buffer for all log-messag
# define LED_PIN 12
# define LED_PIN 12
// Neopixel-configuration
// Neopixel-configuration
# ifdef NEOPIXEL
//#ifdef NEOPIXEL_ENABLE
# define NUM_LEDS 24 // Configure number of LEDs here
# define NUM_LEDS 24 // Configure number of LEDs here
# define CHIPSET WS2811
# define CHIPSET WS2811
# define COLOR_ORDER GRB
# define COLOR_ORDER GRB
# endif
//#endif
// Track-Control
// Track-Control
# define STOP 1 // Stop play
# define STOP 1 // Stop play
@ -153,7 +153,7 @@ uint8_t nightLedBrightness = 2; // Brightness of Neopixe
// MQTT
// MQTT
bool enableMqtt = true ;
bool enableMqtt = true ;
# ifdef MQTT
# ifdef MQTT_ENABLE
uint8_t mqttFailCount = 3 ; // Number of times mqtt-reconnect is allowed to fail. If >= mqttFailCount to further reconnects take place
uint8_t mqttFailCount = 3 ; // Number of times mqtt-reconnect is allowed to fail. If >= mqttFailCount to further reconnects take place
uint8_t const stillOnlineInterval = 60 ; // Interval 'I'm still alive' is sent via MQTT (in seconds)
uint8_t const stillOnlineInterval = 60 ; // Interval 'I'm still alive' is sent via MQTT (in seconds)
# endif
# endif
@ -176,14 +176,14 @@ uint16_t intervalToLongPress = 700; // Interval in ms to dis
// WiFi
// WiFi
unsigned long wifiCheckLastTimestamp = 0 ;
unsigned long wifiCheckLastTimestamp = 0 ;
// Neopixel
// Neopixel
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
bool showLedError = false ;
bool showLedError = false ;
bool showLedOk = false ;
bool showLedOk = false ;
bool showPlaylistProgress = false ;
bool showPlaylistProgress = false ;
bool showRewind = false ;
bool showRewind = false ;
# endif
# endif
// MQTT
// MQTT
# ifdef MQTT
# ifdef MQTT_ENABLE
unsigned long lastOnlineTimestamp = 0 ;
unsigned long lastOnlineTimestamp = 0 ;
# endif
# endif
// RFID
// RFID
@ -213,7 +213,7 @@ char ftpPassword[15] = "esp32"; // FTP-password
// MQTT-configuration
// MQTT-configuration
char mqtt_server [ 16 ] = " 192.168.2.43 " ; // IP-address of MQTT-server
char mqtt_server [ 16 ] = " 192.168.2.43 " ; // IP-address of MQTT-server
# ifdef MQTT
# ifdef MQTT_ENABLE
# define DEVICE_HOSTNAME "ESP32-Tonuino" // Name that that is used for MQTT
# define DEVICE_HOSTNAME "ESP32-Tonuino" // Name that that is used for MQTT
static const char topicSleepCmnd [ ] PROGMEM = " Cmnd/Tonuino/Sleep " ;
static const char topicSleepCmnd [ ] PROGMEM = " Cmnd/Tonuino/Sleep " ;
static const char topicSleepState [ ] PROGMEM = " State/Tonuino/Sleep " ;
static const char topicSleepState [ ] PROGMEM = " State/Tonuino/Sleep " ;
@ -249,7 +249,7 @@ AsyncWebServer wServer(81);
SPIClass spiSD ( HSPI ) ;
SPIClass spiSD ( HSPI ) ;
TaskHandle_t mp3Play ;
TaskHandle_t mp3Play ;
TaskHandle_t rfid ;
TaskHandle_t rfid ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
TaskHandle_t LED ;
TaskHandle_t LED ;
# endif
# endif
@ -257,7 +257,7 @@ TaskHandle_t rfid;
WebServer server ( 80 ) ;
WebServer server ( 80 ) ;
// FTP
// FTP
# ifdef FTP
# ifdef FTP_ENABLE
FtpServer ftpSrv ;
FtpServer ftpSrv ;
# endif
# endif
@ -266,7 +266,7 @@ WiFiClient wifiClient;
IPAddress myIP ;
IPAddress myIP ;
// MQTT-helper
// MQTT-helper
# ifdef MQTT
# ifdef MQTT_ENABLE
PubSubClient MQTTclient ( wifiClient ) ;
PubSubClient MQTTclient ( wifiClient ) ;
# endif
# endif
@ -314,7 +314,7 @@ uint8_t getRepeatMode(void);
void handleWifiSetup ( ) ;
void handleWifiSetup ( ) ;
void loggerNl ( const char * str , const uint8_t logLevel ) ;
void loggerNl ( const char * str , const uint8_t logLevel ) ;
void logger ( const char * str , const uint8_t logLevel ) ;
void logger ( const char * str , const uint8_t logLevel ) ;
# ifdef MQTT
# ifdef MQTT_ENABLE
bool publishMqtt ( const char * topic , const char * payload , bool retained ) ;
bool publishMqtt ( const char * topic , const char * payload , bool retained ) ;
# endif
# endif
void postHeartbeatViaMqtt ( void ) ;
void postHeartbeatViaMqtt ( void ) ;
@ -517,7 +517,7 @@ void doButtonActions(void) {
/* Wrapper-functions for MQTT-publish */
/* Wrapper-functions for MQTT-publish */
# ifdef MQTT
# ifdef MQTT_ENABLE
bool publishMqtt ( const char * topic , const char * payload , bool retained ) {
bool publishMqtt ( const char * topic , const char * payload , bool retained ) {
if ( strcmp ( topic , " " ) ! = 0 ) {
if ( strcmp ( topic , " " ) ! = 0 ) {
if ( MQTTclient . connected ( ) ) {
if ( MQTTclient . connected ( ) ) {
@ -657,14 +657,14 @@ void callback(const char *topic, const byte *payload, uint32_t length) {
if ( strcmp ( receivedString , " EOP " ) = = 0 ) {
if ( strcmp ( receivedString , " EOP " ) = = 0 ) {
playProperties . sleepAfterPlaylist = true ;
playProperties . sleepAfterPlaylist = true ;
loggerNl ( ( char * ) FPSTR ( sleepTimerEOP ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( sleepTimerEOP ) , LOGLEVEL_NOTICE ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedOk = true ;
showLedOk = true ;
# endif
# endif
return ;
return ;
} else if ( strcmp ( receivedString , " EOT " ) = = 0 ) {
} else if ( strcmp ( receivedString , " EOT " ) = = 0 ) {
playProperties . sleepAfterCurrentTrack = true ;
playProperties . sleepAfterCurrentTrack = true ;
loggerNl ( ( char * ) FPSTR ( sleepTimerEOT ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( sleepTimerEOT ) , LOGLEVEL_NOTICE ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedOk = true ;
showLedOk = true ;
# endif
# endif
return ;
return ;
@ -672,14 +672,14 @@ void callback(const char *topic, const byte *payload, uint32_t length) {
if ( sleepTimerStartTimestamp ) {
if ( sleepTimerStartTimestamp ) {
sleepTimerStartTimestamp = 0 ;
sleepTimerStartTimestamp = 0 ;
loggerNl ( ( char * ) FPSTR ( sleepTimerStop ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( sleepTimerStop ) , LOGLEVEL_NOTICE ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedOk = true ;
showLedOk = true ;
# endif
# endif
publishMqtt ( ( char * ) FPSTR ( topicSleepState ) , 0 , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicSleepState ) , 0 , false ) ;
return ;
return ;
} else {
} else {
loggerNl ( ( char * ) FPSTR ( sleepTimerAlreadyStopped ) , LOGLEVEL_INFO ) ;
loggerNl ( ( char * ) FPSTR ( sleepTimerAlreadyStopped ) , LOGLEVEL_INFO ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedError = true ;
showLedError = true ;
# endif
# endif
return ;
return ;
@ -688,7 +688,7 @@ void callback(const char *topic, const byte *payload, uint32_t length) {
sleepTimer = strtoul ( receivedString , NULL , 10 ) ;
sleepTimer = strtoul ( receivedString , NULL , 10 ) ;
snprintf ( logBuf , sizeof ( logBuf ) / sizeof ( logBuf [ 0 ] ) , " %s: %lu Minute(n) " , ( char * ) FPSTR ( sleepTimerSetTo ) , sleepTimer ) ;
snprintf ( logBuf , sizeof ( logBuf ) / sizeof ( logBuf [ 0 ] ) , " %s: %lu Minute(n) " , ( char * ) FPSTR ( sleepTimerSetTo ) , sleepTimer ) ;
loggerNl ( logBuf , LOGLEVEL_NOTICE ) ;
loggerNl ( logBuf , LOGLEVEL_NOTICE ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedOk = true ;
showLedOk = true ;
# endif
# endif
@ -707,14 +707,14 @@ void callback(const char *topic, const byte *payload, uint32_t length) {
if ( strcmp ( receivedString , " OFF " ) = = 0 ) {
if ( strcmp ( receivedString , " OFF " ) = = 0 ) {
lockControls = false ;
lockControls = false ;
loggerNl ( ( char * ) FPSTR ( allowButtons ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( allowButtons ) , LOGLEVEL_NOTICE ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedOk = true ;
showLedOk = true ;
# endif
# endif
} else if ( strcmp ( receivedString , " ON " ) = = 0 ) {
} else if ( strcmp ( receivedString , " ON " ) = = 0 ) {
lockControls = true ;
lockControls = true ;
loggerNl ( ( char * ) FPSTR ( lockButtons ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( lockButtons ) , LOGLEVEL_NOTICE ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedOk = true ;
showLedOk = true ;
# endif
# endif
}
}
@ -730,7 +730,7 @@ void callback(const char *topic, const byte *payload, uint32_t length) {
snprintf ( rBuf , 2 , " %u " , getRepeatMode ( ) ) ;
snprintf ( rBuf , 2 , " %u " , getRepeatMode ( ) ) ;
publishMqtt ( ( char * ) FPSTR ( topicRepeatModeState ) , rBuf , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicRepeatModeState ) , rBuf , false ) ;
loggerNl ( ( char * ) FPSTR ( noPlaylistNotAllowedMqtt ) , LOGLEVEL_ERROR ) ;
loggerNl ( ( char * ) FPSTR ( noPlaylistNotAllowedMqtt ) , LOGLEVEL_ERROR ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedError = true ;
showLedError = true ;
# endif
# endif
} else {
} else {
@ -741,7 +741,7 @@ void callback(const char *topic, const byte *payload, uint32_t length) {
snprintf ( rBuf , 2 , " %u " , getRepeatMode ( ) ) ;
snprintf ( rBuf , 2 , " %u " , getRepeatMode ( ) ) ;
publishMqtt ( ( char * ) FPSTR ( topicRepeatModeState ) , rBuf , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicRepeatModeState ) , rBuf , false ) ;
loggerNl ( ( char * ) FPSTR ( modeRepeatNone ) , LOGLEVEL_INFO ) ;
loggerNl ( ( char * ) FPSTR ( modeRepeatNone ) , LOGLEVEL_INFO ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedOk = true ;
showLedOk = true ;
# endif
# endif
break ;
break ;
@ -752,7 +752,7 @@ void callback(const char *topic, const byte *payload, uint32_t length) {
snprintf ( rBuf , 2 , " %u " , getRepeatMode ( ) ) ;
snprintf ( rBuf , 2 , " %u " , getRepeatMode ( ) ) ;
publishMqtt ( ( char * ) FPSTR ( topicRepeatModeState ) , rBuf , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicRepeatModeState ) , rBuf , false ) ;
loggerNl ( ( char * ) FPSTR ( modeRepeatTrack ) , LOGLEVEL_INFO ) ;
loggerNl ( ( char * ) FPSTR ( modeRepeatTrack ) , LOGLEVEL_INFO ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedOk = true ;
showLedOk = true ;
# endif
# endif
break ;
break ;
@ -763,7 +763,7 @@ void callback(const char *topic, const byte *payload, uint32_t length) {
snprintf ( rBuf , 2 , " %u " , getRepeatMode ( ) ) ;
snprintf ( rBuf , 2 , " %u " , getRepeatMode ( ) ) ;
publishMqtt ( ( char * ) FPSTR ( topicRepeatModeState ) , rBuf , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicRepeatModeState ) , rBuf , false ) ;
loggerNl ( ( char * ) FPSTR ( modeRepeatPlaylist ) , LOGLEVEL_INFO ) ;
loggerNl ( ( char * ) FPSTR ( modeRepeatPlaylist ) , LOGLEVEL_INFO ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedOk = true ;
showLedOk = true ;
# endif
# endif
break ;
break ;
@ -774,13 +774,13 @@ void callback(const char *topic, const byte *payload, uint32_t length) {
snprintf ( rBuf , 2 , " %u " , getRepeatMode ( ) ) ;
snprintf ( rBuf , 2 , " %u " , getRepeatMode ( ) ) ;
publishMqtt ( ( char * ) FPSTR ( topicRepeatModeState ) , rBuf , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicRepeatModeState ) , rBuf , false ) ;
loggerNl ( ( char * ) FPSTR ( modeRepeatTracknPlaylist ) , LOGLEVEL_INFO ) ;
loggerNl ( ( char * ) FPSTR ( modeRepeatTracknPlaylist ) , LOGLEVEL_INFO ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedOk = true ;
showLedOk = true ;
# endif
# endif
break ;
break ;
default :
default :
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedError = true ;
showLedError = true ;
# endif
# endif
snprintf ( rBuf , 2 , " %u " , getRepeatMode ( ) ) ;
snprintf ( rBuf , 2 , " %u " , getRepeatMode ( ) ) ;
@ -800,7 +800,7 @@ void callback(const char *topic, const byte *payload, uint32_t length) {
else {
else {
snprintf ( logBuf , sizeof ( logBuf ) / sizeof ( logBuf [ 0 ] ) , " %s: %s " , ( char * ) FPSTR ( noValidTopic ) , topic ) ;
snprintf ( logBuf , sizeof ( logBuf ) / sizeof ( logBuf [ 0 ] ) , " %s: %s " , ( char * ) FPSTR ( noValidTopic ) , topic ) ;
loggerNl ( logBuf , LOGLEVEL_ERROR ) ;
loggerNl ( logBuf , LOGLEVEL_ERROR ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedError = true ;
showLedError = true ;
# endif
# endif
}
}
@ -953,7 +953,7 @@ char ** returnPlaylistFromSD(File _fileOrDirectory) {
files = ( char * * ) malloc ( sizeof ( char * ) * 2 ) ; // +1 because [0] is used for number of elements; [1] -> [n] is used for payload
files = ( char * * ) malloc ( sizeof ( char * ) * 2 ) ; // +1 because [0] is used for number of elements; [1] -> [n] is used for payload
if ( files = = NULL ) {
if ( files = = NULL ) {
loggerNl ( ( char * ) FPSTR ( unableToAllocateMemForPlaylist ) , LOGLEVEL_ERROR ) ;
loggerNl ( ( char * ) FPSTR ( unableToAllocateMemForPlaylist ) , LOGLEVEL_ERROR ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedError = true ;
showLedError = true ;
# endif
# endif
return NULL ;
return NULL ;
@ -993,7 +993,7 @@ char ** returnPlaylistFromSD(File _fileOrDirectory) {
loggerNl ( ( char * ) FPSTR ( reallocCalled ) , LOGLEVEL_DEBUG ) ;
loggerNl ( ( char * ) FPSTR ( reallocCalled ) , LOGLEVEL_DEBUG ) ;
if ( serializedPlaylist = = NULL ) {
if ( serializedPlaylist = = NULL ) {
loggerNl ( ( char * ) FPSTR ( unableToAllocateMemForLinearPlaylist ) , LOGLEVEL_ERROR ) ;
loggerNl ( ( char * ) FPSTR ( unableToAllocateMemForLinearPlaylist ) , LOGLEVEL_ERROR ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedError = true ;
showLedError = true ;
# endif
# endif
return files ;
return files ;
@ -1017,7 +1017,7 @@ char ** returnPlaylistFromSD(File _fileOrDirectory) {
files = ( char * * ) malloc ( sizeof ( char * ) * cnt + 1 ) ;
files = ( char * * ) malloc ( sizeof ( char * ) * cnt + 1 ) ;
if ( files = = NULL ) {
if ( files = = NULL ) {
loggerNl ( ( char * ) FPSTR ( unableToAllocateMemForPlaylist ) , LOGLEVEL_ERROR ) ;
loggerNl ( ( char * ) FPSTR ( unableToAllocateMemForPlaylist ) , LOGLEVEL_ERROR ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedError = true ;
showLedError = true ;
# endif
# endif
free ( serializedPlaylist ) ;
free ( serializedPlaylist ) ;
@ -1038,7 +1038,7 @@ char ** returnPlaylistFromSD(File _fileOrDirectory) {
files [ 0 ] = ( char * ) malloc ( sizeof ( char ) * 5 ) ;
files [ 0 ] = ( char * ) malloc ( sizeof ( char ) * 5 ) ;
if ( files [ 0 ] = = NULL ) {
if ( files [ 0 ] = = NULL ) {
loggerNl ( ( char * ) FPSTR ( unableToAllocateMemForPlaylist ) , LOGLEVEL_ERROR ) ;
loggerNl ( ( char * ) FPSTR ( unableToAllocateMemForPlaylist ) , LOGLEVEL_ERROR ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedError = true ;
showLedError = true ;
# endif
# endif
return NULL ;
return NULL ;
@ -1094,7 +1094,7 @@ void playAudio(void *parameter) {
snprintf ( logBuf , sizeof ( logBuf ) / sizeof ( logBuf [ 0 ] ) , " %s: %d " , ( char * ) FPSTR ( newLoudnessReceivedQueue ) , currentVolume ) ;
snprintf ( logBuf , sizeof ( logBuf ) / sizeof ( logBuf [ 0 ] ) , " %s: %d " , ( char * ) FPSTR ( newLoudnessReceivedQueue ) , currentVolume ) ;
loggerNl ( logBuf , LOGLEVEL_INFO ) ;
loggerNl ( logBuf , LOGLEVEL_INFO ) ;
audio . setVolume ( currentVolume ) ;
audio . setVolume ( currentVolume ) ;
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicLoudnessState ) , currentVolume , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicLoudnessState ) , currentVolume , false ) ;
# endif
# endif
}
}
@ -1137,7 +1137,7 @@ void playAudio(void *parameter) {
playProperties . currentTrackNumber + + ;
playProperties . currentTrackNumber + + ;
} else {
} else {
loggerNl ( ( char * ) FPSTR ( repeatTrackDueToPlaymode ) , LOGLEVEL_INFO ) ;
loggerNl ( ( char * ) FPSTR ( repeatTrackDueToPlaymode ) , LOGLEVEL_INFO ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showRewind = true ;
showRewind = true ;
# endif
# endif
}
}
@ -1146,7 +1146,7 @@ void playAudio(void *parameter) {
if ( playProperties . playlistFinished & & trackCommand ! = 0 ) {
if ( playProperties . playlistFinished & & trackCommand ! = 0 ) {
loggerNl ( ( char * ) FPSTR ( noPlaymodeChangeIfIdle ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( noPlaymodeChangeIfIdle ) , LOGLEVEL_NOTICE ) ;
trackCommand = 0 ;
trackCommand = 0 ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedError = true ;
showLedError = true ;
# endif
# endif
continue ;
continue ;
@ -1182,7 +1182,7 @@ void playAudio(void *parameter) {
playProperties . repeatCurrentTrack = ! playProperties . repeatCurrentTrack ;
playProperties . repeatCurrentTrack = ! playProperties . repeatCurrentTrack ;
char rBuf [ 2 ] ;
char rBuf [ 2 ] ;
snprintf ( rBuf , 2 , " %u " , getRepeatMode ( ) ) ;
snprintf ( rBuf , 2 , " %u " , getRepeatMode ( ) ) ;
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicRepeatModeState ) , rBuf , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicRepeatModeState ) , rBuf , false ) ;
# endif
# endif
}
}
@ -1199,7 +1199,7 @@ void playAudio(void *parameter) {
} else {
} else {
loggerNl ( ( char * ) FPSTR ( lastTrackAlreadyActive ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( lastTrackAlreadyActive ) , LOGLEVEL_NOTICE ) ;
trackCommand = 0 ;
trackCommand = 0 ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedError = true ;
showLedError = true ;
# endif
# endif
continue ;
continue ;
@ -1216,7 +1216,7 @@ void playAudio(void *parameter) {
playProperties . repeatCurrentTrack = ! playProperties . repeatCurrentTrack ;
playProperties . repeatCurrentTrack = ! playProperties . repeatCurrentTrack ;
char rBuf [ 2 ] ;
char rBuf [ 2 ] ;
snprintf ( rBuf , 2 , " %u " , getRepeatMode ( ) ) ;
snprintf ( rBuf , 2 , " %u " , getRepeatMode ( ) ) ;
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicRepeatModeState ) , rBuf , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicRepeatModeState ) , rBuf , false ) ;
# endif
# endif
}
}
@ -1234,7 +1234,7 @@ void playAudio(void *parameter) {
} else {
} else {
if ( playProperties . playMode = = WEBSTREAM ) {
if ( playProperties . playMode = = WEBSTREAM ) {
loggerNl ( ( char * ) FPSTR ( trackChangeWebstream ) , LOGLEVEL_INFO ) ;
loggerNl ( ( char * ) FPSTR ( trackChangeWebstream ) , LOGLEVEL_INFO ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedError = true ;
showLedError = true ;
# endif
# endif
trackCommand = 0 ;
trackCommand = 0 ;
@ -1244,7 +1244,7 @@ void playAudio(void *parameter) {
nvsRfidWriteWrapper ( playProperties . playRfidTag , * ( playProperties . playlist + playProperties . currentTrackNumber ) , 0 , playProperties . playMode , playProperties . currentTrackNumber , playProperties . numberOfTracks ) ;
nvsRfidWriteWrapper ( playProperties . playRfidTag , * ( playProperties . playlist + playProperties . currentTrackNumber ) , 0 , playProperties . playMode , playProperties . currentTrackNumber , playProperties . numberOfTracks ) ;
}
}
audio . stopSong ( ) ;
audio . stopSong ( ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showRewind = true ;
showRewind = true ;
# endif
# endif
audio . connecttoSD ( * ( playProperties . playlist + playProperties . currentTrackNumber ) ) ;
audio . connecttoSD ( * ( playProperties . playlist + playProperties . currentTrackNumber ) ) ;
@ -1272,7 +1272,7 @@ void playAudio(void *parameter) {
}
}
} else {
} else {
loggerNl ( ( char * ) FPSTR ( firstTrackAlreadyActive ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( firstTrackAlreadyActive ) , LOGLEVEL_NOTICE ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedError = true ;
showLedError = true ;
# endif
# endif
trackCommand = 0 ;
trackCommand = 0 ;
@ -1298,7 +1298,7 @@ void playAudio(void *parameter) {
}
}
} else {
} else {
loggerNl ( ( char * ) FPSTR ( lastTrackAlreadyActive ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( lastTrackAlreadyActive ) , LOGLEVEL_NOTICE ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedError = true ;
showLedError = true ;
# endif
# endif
trackCommand = 0 ;
trackCommand = 0 ;
@ -1313,7 +1313,7 @@ void playAudio(void *parameter) {
default :
default :
trackCommand = 0 ;
trackCommand = 0 ;
loggerNl ( ( char * ) FPSTR ( cmndDoesNotExist ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( cmndDoesNotExist ) , LOGLEVEL_NOTICE ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedError = true ;
showLedError = true ;
# endif
# endif
continue ;
continue ;
@ -1326,12 +1326,12 @@ void playAudio(void *parameter) {
// Set back to first track
// Set back to first track
nvsRfidWriteWrapper ( playProperties . playRfidTag , * ( playProperties . playlist + 0 ) , 0 , playProperties . playMode , 0 , playProperties . numberOfTracks ) ;
nvsRfidWriteWrapper ( playProperties . playRfidTag , * ( playProperties . playlist + 0 ) , 0 , playProperties . playMode , 0 , playProperties . numberOfTracks ) ;
}
}
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicTrackState ) , " <Ende> " , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicTrackState ) , " <Ende> " , false ) ;
# endif
# endif
playProperties . playlistFinished = true ;
playProperties . playlistFinished = true ;
playProperties . playMode = NO_PLAYLIST ;
playProperties . playMode = NO_PLAYLIST ;
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicPlaymodeState ) , playProperties . playMode , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicPlaymodeState ) , playProperties . playMode , false ) ;
# endif
# endif
playProperties . currentTrackNumber = 0 ;
playProperties . currentTrackNumber = 0 ;
@ -1367,7 +1367,7 @@ void playAudio(void *parameter) {
continue ;
continue ;
} else {
} else {
audio . connecttoSD ( * ( playProperties . playlist + playProperties . currentTrackNumber ) ) ;
audio . connecttoSD ( * ( playProperties . playlist + playProperties . currentTrackNumber ) ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showPlaylistProgress = true ;
showPlaylistProgress = true ;
# endif
# endif
if ( playProperties . startAtFilePos > 0 ) {
if ( playProperties . startAtFilePos > 0 ) {
@ -1377,7 +1377,7 @@ void playAudio(void *parameter) {
}
}
char buf [ 255 ] ;
char buf [ 255 ] ;
snprintf ( buf , sizeof ( buf ) / sizeof ( buf [ 0 ] ) , " (%d/%d) %s " , ( playProperties . currentTrackNumber + 1 ) , playProperties . numberOfTracks , ( const char * ) * ( playProperties . playlist + playProperties . currentTrackNumber ) ) ;
snprintf ( buf , sizeof ( buf ) / sizeof ( buf [ 0 ] ) , " (%d/%d) %s " , ( playProperties . currentTrackNumber + 1 ) , playProperties . numberOfTracks , ( const char * ) * ( playProperties . playlist + playProperties . currentTrackNumber ) ) ;
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicTrackState ) , buf , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicTrackState ) , buf , false ) ;
# endif
# endif
snprintf ( logBuf , sizeof ( logBuf ) / sizeof ( logBuf [ 0 ] ) , " '%s' wird abgespielt (%d von %d) " , * ( playProperties . playlist + playProperties . currentTrackNumber ) , ( playProperties . currentTrackNumber + 1 ) , playProperties . numberOfTracks ) ;
snprintf ( logBuf , sizeof ( logBuf ) / sizeof ( logBuf [ 0 ] ) , " '%s' wird abgespielt (%d von %d) " , * ( playProperties . playlist + playProperties . currentTrackNumber ) , ( playProperties . currentTrackNumber + 1 ) , playProperties . numberOfTracks ) ;
@ -1388,7 +1388,7 @@ void playAudio(void *parameter) {
}
}
// Calculate relative position in file (for neopixel) for SD-card-mode
// Calculate relative position in file (for neopixel) for SD-card-mode
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
if ( ! playProperties . playlistFinished & & playProperties . playMode ! = WEBSTREAM ) {
if ( ! playProperties . playlistFinished & & playProperties . playMode ! = WEBSTREAM ) {
double fp = ( double ) audio . getFilePos ( ) / ( double ) audio . getFileSize ( ) ;
double fp = ( double ) audio . getFilePos ( ) / ( double ) audio . getFileSize ( ) ;
if ( millis ( ) % 100 = = 0 ) {
if ( millis ( ) % 100 = = 0 ) {
@ -1445,7 +1445,7 @@ void rfidScanner(void *parameter) {
cardIdString = ( char * ) malloc ( cardIdSize * 3 + 1 ) ;
cardIdString = ( char * ) malloc ( cardIdSize * 3 + 1 ) ;
if ( cardIdString = = NULL ) {
if ( cardIdString = = NULL ) {
logger ( ( char * ) FPSTR ( unableToAllocateMem ) , LOGLEVEL_ERROR ) ;
logger ( ( char * ) FPSTR ( unableToAllocateMem ) , LOGLEVEL_ERROR ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedError = true ;
showLedError = true ;
# endif
# endif
continue ;
continue ;
@ -1475,7 +1475,7 @@ void rfidScanner(void *parameter) {
// This task handles everything for Neopixel-visualisation
// This task handles everything for Neopixel-visualisation
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
void showLed ( void * parameter ) {
void showLed ( void * parameter ) {
static uint8_t hlastVolume = currentVolume ;
static uint8_t hlastVolume = currentVolume ;
static uint8_t lastPos = playProperties . currentRelPos ;
static uint8_t lastPos = playProperties . currentRelPos ;
@ -1754,12 +1754,12 @@ void deepSleepManager(void) {
if ( gotoSleep ) {
if ( gotoSleep ) {
loggerNl ( ( char * ) FPSTR ( goToSleepNow ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( goToSleepNow ) , LOGLEVEL_NOTICE ) ;
Serial . flush ( ) ;
Serial . flush ( ) ;
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicState ) , " Offline " , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicState ) , " Offline " , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicTrackState ) , " --- " , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicTrackState ) , " --- " , false ) ;
MQTTclient . disconnect ( ) ;
MQTTclient . disconnect ( ) ;
# endif
# endif
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
FastLED . clear ( ) ;
FastLED . clear ( ) ;
FastLED . show ( ) ;
FastLED . show ( ) ;
# endif
# endif
@ -1834,7 +1834,7 @@ void trackQueueDispatcher(const char *_itemToPlay, const uint32_t _lastPlayPos,
char * * musicFiles ;
char * * musicFiles ;
playProperties . playMode = BUSY ; // Show @Neopixel, if uC is busy with creating playlist
playProperties . playMode = BUSY ; // Show @Neopixel, if uC is busy with creating playlist
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicLedBrightnessState ) , 0 , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicLedBrightnessState ) , 0 , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicPlaymodeState ) , playProperties . playMode , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicPlaymodeState ) , playProperties . playMode , false ) ;
# endif
# endif
@ -1843,20 +1843,20 @@ void trackQueueDispatcher(const char *_itemToPlay, const uint32_t _lastPlayPos,
} else {
} else {
musicFiles = returnPlaylistFromWebstream ( filename ) ;
musicFiles = returnPlaylistFromWebstream ( filename ) ;
}
}
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicLedBrightnessState ) , ledBrightness , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicLedBrightnessState ) , ledBrightness , false ) ;
# endif
# endif
if ( musicFiles = = NULL ) {
if ( musicFiles = = NULL ) {
loggerNl ( ( char * ) FPSTR ( errorOccured ) , LOGLEVEL_ERROR ) ;
loggerNl ( ( char * ) FPSTR ( errorOccured ) , LOGLEVEL_ERROR ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedError = true ;
showLedError = true ;
# endif
# endif
playProperties . playMode = NO_PLAYLIST ;
playProperties . playMode = NO_PLAYLIST ;
return ;
return ;
} else if ( ! strcmp ( * ( musicFiles - 1 ) , " 0 " ) ) {
} else if ( ! strcmp ( * ( musicFiles - 1 ) , " 0 " ) ) {
loggerNl ( ( char * ) FPSTR ( noMp3FilesInDir ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( noMp3FilesInDir ) , LOGLEVEL_NOTICE ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedError = true ;
showLedError = true ;
# endif
# endif
playProperties . playMode = NO_PLAYLIST ;
playProperties . playMode = NO_PLAYLIST ;
@ -1876,7 +1876,7 @@ void trackQueueDispatcher(const char *_itemToPlay, const uint32_t _lastPlayPos,
switch ( playProperties . playMode ) {
switch ( playProperties . playMode ) {
case SINGLE_TRACK : {
case SINGLE_TRACK : {
loggerNl ( ( char * ) FPSTR ( modeSingleTrack ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( modeSingleTrack ) , LOGLEVEL_NOTICE ) ;
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicPlaymodeState ) , playProperties . playMode , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicPlaymodeState ) , playProperties . playMode , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicRepeatModeState ) , NO_REPEAT , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicRepeatModeState ) , NO_REPEAT , false ) ;
# endif
# endif
@ -1887,7 +1887,7 @@ void trackQueueDispatcher(const char *_itemToPlay, const uint32_t _lastPlayPos,
case SINGLE_TRACK_LOOP : {
case SINGLE_TRACK_LOOP : {
playProperties . repeatCurrentTrack = true ;
playProperties . repeatCurrentTrack = true ;
loggerNl ( ( char * ) FPSTR ( modeSingleTrackLoop ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( modeSingleTrackLoop ) , LOGLEVEL_NOTICE ) ;
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicPlaymodeState ) , playProperties . playMode , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicPlaymodeState ) , playProperties . playMode , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicRepeatModeState ) , TRACK , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicRepeatModeState ) , TRACK , false ) ;
# endif
# endif
@ -1898,7 +1898,7 @@ void trackQueueDispatcher(const char *_itemToPlay, const uint32_t _lastPlayPos,
case AUDIOBOOK : { // Tracks need to be alph. sorted!
case AUDIOBOOK : { // Tracks need to be alph. sorted!
playProperties . saveLastPlayPosition = true ;
playProperties . saveLastPlayPosition = true ;
loggerNl ( ( char * ) FPSTR ( modeSingleAudiobook ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( modeSingleAudiobook ) , LOGLEVEL_NOTICE ) ;
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicPlaymodeState ) , playProperties . playMode , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicPlaymodeState ) , playProperties . playMode , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicRepeatModeState ) , NO_REPEAT , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicRepeatModeState ) , NO_REPEAT , false ) ;
# endif
# endif
@ -1911,7 +1911,7 @@ void trackQueueDispatcher(const char *_itemToPlay, const uint32_t _lastPlayPos,
playProperties . repeatPlaylist = true ;
playProperties . repeatPlaylist = true ;
playProperties . saveLastPlayPosition = true ;
playProperties . saveLastPlayPosition = true ;
loggerNl ( ( char * ) FPSTR ( modeSingleAudiobookLoop ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( modeSingleAudiobookLoop ) , LOGLEVEL_NOTICE ) ;
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicPlaymodeState ) , playProperties . playMode , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicPlaymodeState ) , playProperties . playMode , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicRepeatModeState ) , PLAYLIST , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicRepeatModeState ) , PLAYLIST , false ) ;
# endif
# endif
@ -1924,7 +1924,7 @@ void trackQueueDispatcher(const char *_itemToPlay, const uint32_t _lastPlayPos,
snprintf ( logBuf , sizeof ( logBuf ) / sizeof ( logBuf [ 0 ] ) , " %s '%s' " , ( char * ) FPSTR ( modeAllTrackAlphSorted ) , filename ) ;
snprintf ( logBuf , sizeof ( logBuf ) / sizeof ( logBuf [ 0 ] ) , " %s '%s' " , ( char * ) FPSTR ( modeAllTrackAlphSorted ) , filename ) ;
loggerNl ( logBuf , LOGLEVEL_NOTICE ) ;
loggerNl ( logBuf , LOGLEVEL_NOTICE ) ;
sortPlaylist ( ( const char * * ) musicFiles , strtoul ( * ( musicFiles - 1 ) , NULL , 10 ) ) ;
sortPlaylist ( ( const char * * ) musicFiles , strtoul ( * ( musicFiles - 1 ) , NULL , 10 ) ) ;
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicPlaymodeState ) , playProperties . playMode , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicPlaymodeState ) , playProperties . playMode , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicRepeatModeState ) , NO_REPEAT , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicRepeatModeState ) , NO_REPEAT , false ) ;
# endif
# endif
@ -1935,7 +1935,7 @@ void trackQueueDispatcher(const char *_itemToPlay, const uint32_t _lastPlayPos,
case ALL_TRACKS_OF_DIR_RANDOM : {
case ALL_TRACKS_OF_DIR_RANDOM : {
loggerNl ( ( char * ) FPSTR ( modeAllTrackRandom ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( modeAllTrackRandom ) , LOGLEVEL_NOTICE ) ;
randomizePlaylist ( musicFiles , strtoul ( * ( musicFiles - 1 ) , NULL , 10 ) ) ;
randomizePlaylist ( musicFiles , strtoul ( * ( musicFiles - 1 ) , NULL , 10 ) ) ;
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicPlaymodeState ) , playProperties . playMode , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicPlaymodeState ) , playProperties . playMode , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicRepeatModeState ) , NO_REPEAT , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicRepeatModeState ) , NO_REPEAT , false ) ;
# endif
# endif
@ -1947,7 +1947,7 @@ void trackQueueDispatcher(const char *_itemToPlay, const uint32_t _lastPlayPos,
playProperties . repeatPlaylist = true ;
playProperties . repeatPlaylist = true ;
loggerNl ( ( char * ) FPSTR ( modeAllTrackAlphSortedLoop ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( modeAllTrackAlphSortedLoop ) , LOGLEVEL_NOTICE ) ;
sortPlaylist ( ( const char * * ) musicFiles , strtoul ( * ( musicFiles - 1 ) , NULL , 10 ) ) ;
sortPlaylist ( ( const char * * ) musicFiles , strtoul ( * ( musicFiles - 1 ) , NULL , 10 ) ) ;
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicPlaymodeState ) , playProperties . playMode , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicPlaymodeState ) , playProperties . playMode , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicRepeatModeState ) , PLAYLIST , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicRepeatModeState ) , PLAYLIST , false ) ;
# endif
# endif
@ -1959,7 +1959,7 @@ void trackQueueDispatcher(const char *_itemToPlay, const uint32_t _lastPlayPos,
playProperties . repeatPlaylist = true ;
playProperties . repeatPlaylist = true ;
loggerNl ( ( char * ) FPSTR ( modeAllTrackRandomLoop ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( modeAllTrackRandomLoop ) , LOGLEVEL_NOTICE ) ;
randomizePlaylist ( musicFiles , strtoul ( * ( musicFiles - 1 ) , NULL , 10 ) ) ;
randomizePlaylist ( musicFiles , strtoul ( * ( musicFiles - 1 ) , NULL , 10 ) ) ;
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicPlaymodeState ) , playProperties . playMode , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicPlaymodeState ) , playProperties . playMode , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicRepeatModeState ) , PLAYLIST , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicRepeatModeState ) , PLAYLIST , false ) ;
# endif
# endif
@ -1971,7 +1971,7 @@ void trackQueueDispatcher(const char *_itemToPlay, const uint32_t _lastPlayPos,
loggerNl ( ( char * ) FPSTR ( modeWebstream ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( modeWebstream ) , LOGLEVEL_NOTICE ) ;
if ( wifiManager ( ) = = WL_CONNECTED ) {
if ( wifiManager ( ) = = WL_CONNECTED ) {
xQueueSend ( trackQueue , & ( musicFiles ) , 0 ) ;
xQueueSend ( trackQueue , & ( musicFiles ) , 0 ) ;
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicPlaymodeState ) , playProperties . playMode , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicPlaymodeState ) , playProperties . playMode , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicRepeatModeState ) , NO_REPEAT , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicRepeatModeState ) , NO_REPEAT , false ) ;
# endif
# endif
@ -1983,7 +1983,7 @@ void trackQueueDispatcher(const char *_itemToPlay, const uint32_t _lastPlayPos,
default :
default :
loggerNl ( ( char * ) FPSTR ( modeDoesNotExist ) , LOGLEVEL_ERROR ) ;
loggerNl ( ( char * ) FPSTR ( modeDoesNotExist ) , LOGLEVEL_ERROR ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedError = true ;
showLedError = true ;
# endif
# endif
}
}
@ -1999,18 +1999,18 @@ void doRfidCardModifications(const uint32_t mod) {
lockControls = ! lockControls ;
lockControls = ! lockControls ;
if ( lockControls ) {
if ( lockControls ) {
loggerNl ( ( char * ) FPSTR ( modificatorAllButtonsLocked ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( modificatorAllButtonsLocked ) , LOGLEVEL_NOTICE ) ;
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicLockControlsState ) , " ON " , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicLockControlsState ) , " ON " , false ) ;
# endif
# endif
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedOk = true ;
showLedOk = true ;
# endif
# endif
} else {
} else {
loggerNl ( ( char * ) FPSTR ( modificatorAllButtonsUnlocked ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( modificatorAllButtonsUnlocked ) , LOGLEVEL_NOTICE ) ;
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicLockControlsState ) , " OFF " , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicLockControlsState ) , " OFF " , false ) ;
# endif
# endif
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedOk = true ;
showLedOk = true ;
# endif
# endif
}
}
@ -2019,23 +2019,23 @@ void doRfidCardModifications(const uint32_t mod) {
case SLEEP_TIMER_MOD_15 : // Puts/undo uC to sleep after 15 minutes
case SLEEP_TIMER_MOD_15 : // Puts/undo uC to sleep after 15 minutes
if ( sleepTimer = = 15 ) {
if ( sleepTimer = = 15 ) {
sleepTimerStartTimestamp = 0 ;
sleepTimerStartTimestamp = 0 ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
ledBrightness = initialLedBrightness ;
ledBrightness = initialLedBrightness ;
# endif
# endif
loggerNl ( ( char * ) FPSTR ( modificatorSleepd ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( modificatorSleepd ) , LOGLEVEL_NOTICE ) ;
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicLedBrightnessState ) , ledBrightness , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicLedBrightnessState ) , ledBrightness , false ) ;
# endif
# endif
} else {
} else {
sleepTimer = 15 ;
sleepTimer = 15 ;
sleepTimerStartTimestamp = millis ( ) ;
sleepTimerStartTimestamp = millis ( ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
ledBrightness = nightLedBrightness ;
ledBrightness = nightLedBrightness ;
# endif
# endif
loggerNl ( ( char * ) FPSTR ( modificatorSleepTimer15 ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( modificatorSleepTimer15 ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( ledsDimmedToNightmode ) , LOGLEVEL_INFO ) ;
loggerNl ( ( char * ) FPSTR ( ledsDimmedToNightmode ) , LOGLEVEL_INFO ) ;
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicSleepTimerState ) , sleepTimer , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicSleepTimerState ) , sleepTimer , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicLedBrightnessState ) , nightLedBrightness , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicLedBrightnessState ) , nightLedBrightness , false ) ;
# endif
# endif
@ -2043,7 +2043,7 @@ void doRfidCardModifications(const uint32_t mod) {
playProperties . sleepAfterCurrentTrack = false ; // deactivate/overwrite if already active
playProperties . sleepAfterCurrentTrack = false ; // deactivate/overwrite if already active
playProperties . sleepAfterPlaylist = false ; // deactivate/overwrite if already active
playProperties . sleepAfterPlaylist = false ; // deactivate/overwrite if already active
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedOk = true ;
showLedOk = true ;
# endif
# endif
break ;
break ;
@ -2051,23 +2051,23 @@ void doRfidCardModifications(const uint32_t mod) {
case SLEEP_TIMER_MOD_30 : // Puts/undo uC to sleep after 30 minutes
case SLEEP_TIMER_MOD_30 : // Puts/undo uC to sleep after 30 minutes
if ( sleepTimer = = 30 ) {
if ( sleepTimer = = 30 ) {
sleepTimerStartTimestamp = 0 ;
sleepTimerStartTimestamp = 0 ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
ledBrightness = initialLedBrightness ;
ledBrightness = initialLedBrightness ;
# endif
# endif
loggerNl ( ( char * ) FPSTR ( modificatorSleepd ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( modificatorSleepd ) , LOGLEVEL_NOTICE ) ;
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicLedBrightnessState ) , ledBrightness , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicLedBrightnessState ) , ledBrightness , false ) ;
# endif
# endif
} else {
} else {
sleepTimer = 30 ;
sleepTimer = 30 ;
sleepTimerStartTimestamp = millis ( ) ;
sleepTimerStartTimestamp = millis ( ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
ledBrightness = nightLedBrightness ;
ledBrightness = nightLedBrightness ;
# endif
# endif
loggerNl ( ( char * ) FPSTR ( modificatorSleepTimer30 ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( modificatorSleepTimer30 ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( ledsDimmedToNightmode ) , LOGLEVEL_INFO ) ;
loggerNl ( ( char * ) FPSTR ( ledsDimmedToNightmode ) , LOGLEVEL_INFO ) ;
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicSleepTimerState ) , sleepTimer , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicSleepTimerState ) , sleepTimer , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicLedBrightnessState ) , nightLedBrightness , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicLedBrightnessState ) , nightLedBrightness , false ) ;
# endif
# endif
@ -2075,7 +2075,7 @@ void doRfidCardModifications(const uint32_t mod) {
playProperties . sleepAfterCurrentTrack = false ; // deactivate/overwrite if already active
playProperties . sleepAfterCurrentTrack = false ; // deactivate/overwrite if already active
playProperties . sleepAfterPlaylist = false ; // deactivate/overwrite if already active
playProperties . sleepAfterPlaylist = false ; // deactivate/overwrite if already active
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedOk = true ;
showLedOk = true ;
# endif
# endif
break ;
break ;
@ -2083,23 +2083,23 @@ void doRfidCardModifications(const uint32_t mod) {
case SLEEP_TIMER_MOD_60 : // Puts/undo uC to sleep after 60 minutes
case SLEEP_TIMER_MOD_60 : // Puts/undo uC to sleep after 60 minutes
if ( sleepTimer = = 60 ) {
if ( sleepTimer = = 60 ) {
sleepTimerStartTimestamp = 0 ;
sleepTimerStartTimestamp = 0 ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
ledBrightness = initialLedBrightness ;
ledBrightness = initialLedBrightness ;
# endif
# endif
loggerNl ( ( char * ) FPSTR ( modificatorSleepd ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( modificatorSleepd ) , LOGLEVEL_NOTICE ) ;
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicLedBrightnessState ) , ledBrightness , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicLedBrightnessState ) , ledBrightness , false ) ;
# endif
# endif
} else {
} else {
sleepTimer = 60 ;
sleepTimer = 60 ;
sleepTimerStartTimestamp = millis ( ) ;
sleepTimerStartTimestamp = millis ( ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
ledBrightness = nightLedBrightness ;
ledBrightness = nightLedBrightness ;
# endif
# endif
loggerNl ( ( char * ) FPSTR ( modificatorSleepTimer60 ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( modificatorSleepTimer60 ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( ledsDimmedToNightmode ) , LOGLEVEL_INFO ) ;
loggerNl ( ( char * ) FPSTR ( ledsDimmedToNightmode ) , LOGLEVEL_INFO ) ;
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicSleepTimerState ) , sleepTimer , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicSleepTimerState ) , sleepTimer , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicLedBrightnessState ) , nightLedBrightness , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicLedBrightnessState ) , nightLedBrightness , false ) ;
# endif
# endif
@ -2107,7 +2107,7 @@ void doRfidCardModifications(const uint32_t mod) {
playProperties . sleepAfterCurrentTrack = false ; // deactivate/overwrite if already active
playProperties . sleepAfterCurrentTrack = false ; // deactivate/overwrite if already active
playProperties . sleepAfterPlaylist = false ; // deactivate/overwrite if already active
playProperties . sleepAfterPlaylist = false ; // deactivate/overwrite if already active
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedOk = true ;
showLedOk = true ;
# endif
# endif
break ;
break ;
@ -2115,23 +2115,23 @@ void doRfidCardModifications(const uint32_t mod) {
case SLEEP_TIMER_MOD_120 : // Puts/undo uC to sleep after 2 hrs
case SLEEP_TIMER_MOD_120 : // Puts/undo uC to sleep after 2 hrs
if ( sleepTimer = = 120 ) {
if ( sleepTimer = = 120 ) {
sleepTimerStartTimestamp = 0 ;
sleepTimerStartTimestamp = 0 ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
ledBrightness = initialLedBrightness ;
ledBrightness = initialLedBrightness ;
# endif
# endif
loggerNl ( ( char * ) FPSTR ( modificatorSleepd ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( modificatorSleepd ) , LOGLEVEL_NOTICE ) ;
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicLedBrightnessState ) , ledBrightness , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicLedBrightnessState ) , ledBrightness , false ) ;
# endif
# endif
} else {
} else {
sleepTimer = 120 ;
sleepTimer = 120 ;
sleepTimerStartTimestamp = millis ( ) ;
sleepTimerStartTimestamp = millis ( ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
ledBrightness = nightLedBrightness ;
ledBrightness = nightLedBrightness ;
# endif
# endif
loggerNl ( ( char * ) FPSTR ( modificatorSleepTimer120 ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( modificatorSleepTimer120 ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( ledsDimmedToNightmode ) , LOGLEVEL_INFO ) ;
loggerNl ( ( char * ) FPSTR ( ledsDimmedToNightmode ) , LOGLEVEL_INFO ) ;
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicSleepTimerState ) , sleepTimer , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicSleepTimerState ) , sleepTimer , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicLedBrightnessState ) , nightLedBrightness , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicLedBrightnessState ) , nightLedBrightness , false ) ;
# endif
# endif
@ -2139,7 +2139,7 @@ void doRfidCardModifications(const uint32_t mod) {
playProperties . sleepAfterCurrentTrack = false ; // deactivate/overwrite if already active
playProperties . sleepAfterCurrentTrack = false ; // deactivate/overwrite if already active
playProperties . sleepAfterPlaylist = false ; // deactivate/overwrite if already active
playProperties . sleepAfterPlaylist = false ; // deactivate/overwrite if already active
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedOk = true ;
showLedOk = true ;
# endif
# endif
break ;
break ;
@ -2147,25 +2147,25 @@ void doRfidCardModifications(const uint32_t mod) {
case SLEEP_AFTER_END_OF_TRACK : // Puts uC to sleep after end of current track
case SLEEP_AFTER_END_OF_TRACK : // Puts uC to sleep after end of current track
if ( playProperties . playMode = = NO_PLAYLIST ) {
if ( playProperties . playMode = = NO_PLAYLIST ) {
loggerNl ( ( char * ) FPSTR ( modificatorNotallowedWhenIdle ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( modificatorNotallowedWhenIdle ) , LOGLEVEL_NOTICE ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedError = true ;
showLedError = true ;
# endif
# endif
return ;
return ;
}
}
if ( playProperties . sleepAfterCurrentTrack ) {
if ( playProperties . sleepAfterCurrentTrack ) {
loggerNl ( ( char * ) FPSTR ( modificatorSleepAtEOTd ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( modificatorSleepAtEOTd ) , LOGLEVEL_NOTICE ) ;
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicSleepTimerState ) , " 0 " , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicSleepTimerState ) , " 0 " , false ) ;
# endif
# endif
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
ledBrightness = initialLedBrightness ;
ledBrightness = initialLedBrightness ;
# endif
# endif
} else {
} else {
loggerNl ( ( char * ) FPSTR ( modificatorSleepAtEOT ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( modificatorSleepAtEOT ) , LOGLEVEL_NOTICE ) ;
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicSleepTimerState ) , " EOT " , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicSleepTimerState ) , " EOT " , false ) ;
# endif
# endif
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
ledBrightness = nightLedBrightness ;
ledBrightness = nightLedBrightness ;
# endif
# endif
loggerNl ( ( char * ) FPSTR ( ledsDimmedToNightmode ) , LOGLEVEL_INFO ) ;
loggerNl ( ( char * ) FPSTR ( ledsDimmedToNightmode ) , LOGLEVEL_INFO ) ;
@ -2174,10 +2174,10 @@ void doRfidCardModifications(const uint32_t mod) {
playProperties . sleepAfterPlaylist = false ;
playProperties . sleepAfterPlaylist = false ;
sleepTimerStartTimestamp = 0 ;
sleepTimerStartTimestamp = 0 ;
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicLedBrightnessState ) , ledBrightness , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicLedBrightnessState ) , ledBrightness , false ) ;
# endif
# endif
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedOk = true ;
showLedOk = true ;
# endif
# endif
break ;
break ;
@ -2185,26 +2185,26 @@ void doRfidCardModifications(const uint32_t mod) {
case SLEEP_AFTER_END_OF_PLAYLIST : // Puts uC to sleep after end of whole playlist (can take a while :->)
case SLEEP_AFTER_END_OF_PLAYLIST : // Puts uC to sleep after end of whole playlist (can take a while :->)
if ( playProperties . playMode = = NO_PLAYLIST ) {
if ( playProperties . playMode = = NO_PLAYLIST ) {
loggerNl ( ( char * ) FPSTR ( modificatorNotallowedWhenIdle ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( modificatorNotallowedWhenIdle ) , LOGLEVEL_NOTICE ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedError = true ;
showLedError = true ;
# endif
# endif
return ;
return ;
}
}
if ( playProperties . sleepAfterCurrentTrack ) {
if ( playProperties . sleepAfterCurrentTrack ) {
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicSleepTimerState ) , " 0 " , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicSleepTimerState ) , " 0 " , false ) ;
# endif
# endif
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
ledBrightness = initialLedBrightness ;
ledBrightness = initialLedBrightness ;
# endif
# endif
loggerNl ( ( char * ) FPSTR ( modificatorSleepAtEOPd ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( modificatorSleepAtEOPd ) , LOGLEVEL_NOTICE ) ;
} else {
} else {
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
ledBrightness = nightLedBrightness ;
ledBrightness = nightLedBrightness ;
# endif
# endif
loggerNl ( ( char * ) FPSTR ( ledsDimmedToNightmode ) , LOGLEVEL_INFO ) ;
loggerNl ( ( char * ) FPSTR ( ledsDimmedToNightmode ) , LOGLEVEL_INFO ) ;
loggerNl ( ( char * ) FPSTR ( modificatorSleepAtEOP ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( modificatorSleepAtEOP ) , LOGLEVEL_NOTICE ) ;
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicSleepTimerState ) , " EOP " , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicSleepTimerState ) , " EOP " , false ) ;
# endif
# endif
}
}
@ -2212,10 +2212,10 @@ void doRfidCardModifications(const uint32_t mod) {
playProperties . sleepAfterCurrentTrack = false ;
playProperties . sleepAfterCurrentTrack = false ;
playProperties . sleepAfterPlaylist = ! playProperties . sleepAfterPlaylist ;
playProperties . sleepAfterPlaylist = ! playProperties . sleepAfterPlaylist ;
sleepTimerStartTimestamp = 0 ;
sleepTimerStartTimestamp = 0 ;
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicLedBrightnessState ) , ledBrightness , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicLedBrightnessState ) , ledBrightness , false ) ;
# endif
# endif
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedOk = true ;
showLedOk = true ;
# endif
# endif
break ;
break ;
@ -2223,7 +2223,7 @@ void doRfidCardModifications(const uint32_t mod) {
case REPEAT_PLAYLIST :
case REPEAT_PLAYLIST :
if ( playProperties . playMode = = NO_PLAYLIST ) {
if ( playProperties . playMode = = NO_PLAYLIST ) {
loggerNl ( ( char * ) FPSTR ( modificatorNotallowedWhenIdle ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( modificatorNotallowedWhenIdle ) , LOGLEVEL_NOTICE ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedError = true ;
showLedError = true ;
# endif
# endif
} else {
} else {
@ -2235,10 +2235,10 @@ void doRfidCardModifications(const uint32_t mod) {
playProperties . repeatPlaylist = ! playProperties . repeatPlaylist ;
playProperties . repeatPlaylist = ! playProperties . repeatPlaylist ;
char rBuf [ 2 ] ;
char rBuf [ 2 ] ;
snprintf ( rBuf , 2 , " %u " , getRepeatMode ( ) ) ;
snprintf ( rBuf , 2 , " %u " , getRepeatMode ( ) ) ;
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicRepeatModeState ) , rBuf , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicRepeatModeState ) , rBuf , false ) ;
# endif
# endif
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedOk = true ;
showLedOk = true ;
# endif
# endif
}
}
@ -2247,7 +2247,7 @@ void doRfidCardModifications(const uint32_t mod) {
case REPEAT_TRACK : // Introduces looping for track-mode
case REPEAT_TRACK : // Introduces looping for track-mode
if ( playProperties . playMode = = NO_PLAYLIST ) {
if ( playProperties . playMode = = NO_PLAYLIST ) {
loggerNl ( ( char * ) FPSTR ( modificatorNotallowedWhenIdle ) , LOGLEVEL_NOTICE ) ;
loggerNl ( ( char * ) FPSTR ( modificatorNotallowedWhenIdle ) , LOGLEVEL_NOTICE ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedError = true ;
showLedError = true ;
# endif
# endif
} else {
} else {
@ -2259,21 +2259,21 @@ void doRfidCardModifications(const uint32_t mod) {
playProperties . repeatCurrentTrack = ! playProperties . repeatCurrentTrack ;
playProperties . repeatCurrentTrack = ! playProperties . repeatCurrentTrack ;
char rBuf [ 2 ] ;
char rBuf [ 2 ] ;
snprintf ( rBuf , 2 , " %u " , getRepeatMode ( ) ) ;
snprintf ( rBuf , 2 , " %u " , getRepeatMode ( ) ) ;
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicRepeatModeState ) , rBuf , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicRepeatModeState ) , rBuf , false ) ;
# endif
# endif
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedOk = true ;
showLedOk = true ;
# endif
# endif
}
}
break ;
break ;
case DIMM_LEDS_NIGHTMODE :
case DIMM_LEDS_NIGHTMODE :
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicLedBrightnessState ) , ledBrightness , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicLedBrightnessState ) , ledBrightness , false ) ;
# endif
# endif
loggerNl ( ( char * ) FPSTR ( ledsDimmedToNightmode ) , LOGLEVEL_INFO ) ;
loggerNl ( ( char * ) FPSTR ( ledsDimmedToNightmode ) , LOGLEVEL_INFO ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
ledBrightness = nightLedBrightness ;
ledBrightness = nightLedBrightness ;
showLedOk = true ;
showLedOk = true ;
# endif
# endif
@ -2282,7 +2282,7 @@ void doRfidCardModifications(const uint32_t mod) {
default :
default :
snprintf ( logBuf , sizeof ( logBuf ) / sizeof ( logBuf [ 0 ] ) , " %s %d ! " , ( char * ) FPSTR ( modificatorDoesNotExist ) , mod ) ;
snprintf ( logBuf , sizeof ( logBuf ) / sizeof ( logBuf [ 0 ] ) , " %s %d ! " , ( char * ) FPSTR ( modificatorDoesNotExist ) , mod ) ;
loggerNl ( logBuf , LOGLEVEL_ERROR ) ;
loggerNl ( logBuf , LOGLEVEL_ERROR ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedError = true ;
showLedError = true ;
# endif
# endif
}
}
@ -2308,7 +2308,7 @@ void rfidPreferenceLookupHandler (void) {
String s = prefsRfid . getString ( rfidTagId , " -1 " ) ; // Try to lookup rfidId in NVS
String s = prefsRfid . getString ( rfidTagId , " -1 " ) ; // Try to lookup rfidId in NVS
if ( ! s . compareTo ( " -1 " ) ) {
if ( ! s . compareTo ( " -1 " ) ) {
loggerNl ( ( char * ) FPSTR ( rfidTagUnknownInNvs ) , LOGLEVEL_ERROR ) ;
loggerNl ( ( char * ) FPSTR ( rfidTagUnknownInNvs ) , LOGLEVEL_ERROR ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedError = true ;
showLedError = true ;
# endif
# endif
return ;
return ;
@ -2333,7 +2333,7 @@ void rfidPreferenceLookupHandler (void) {
if ( i ! = 5 ) {
if ( i ! = 5 ) {
loggerNl ( ( char * ) FPSTR ( errorOccuredNvs ) , LOGLEVEL_ERROR ) ;
loggerNl ( ( char * ) FPSTR ( errorOccuredNvs ) , LOGLEVEL_ERROR ) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
showLedError = true ;
showLedError = true ;
# endif
# endif
} else {
} else {
@ -2447,7 +2447,7 @@ wl_status_t wifiManager(void) {
myIP = WiFi . localIP ( ) ;
myIP = WiFi . localIP ( ) ;
snprintf ( logBuf , sizeof ( logBuf ) / sizeof ( logBuf [ 0 ] ) , " Aktuelle IP: %d.%d.%d.%d " , myIP [ 0 ] , myIP [ 1 ] , myIP [ 2 ] , myIP [ 3 ] ) ;
snprintf ( logBuf , sizeof ( logBuf ) / sizeof ( logBuf [ 0 ] ) , " Aktuelle IP: %d.%d.%d.%d " , myIP [ 0 ] , myIP [ 1 ] , myIP [ 2 ] , myIP [ 3 ] ) ;
loggerNl ( logBuf , LOGLEVEL_NOTICE ) ;
loggerNl ( logBuf , LOGLEVEL_NOTICE ) ;
# ifdef FTP
# ifdef FTP_ENABLE
ftpSrv . begin ( ftpUser , ftpPassword ) ;
ftpSrv . begin ( ftpUser , ftpPassword ) ;
# endif
# endif
} else { // Starts AP if WiFi-connect wasn't successful
} else { // Starts AP if WiFi-connect wasn't successful
@ -2676,7 +2676,7 @@ void setup() {
& mp3Play , /* Task handle. */
& mp3Play , /* Task handle. */
1 /* Core where the task should run */
1 /* Core where the task should run */
) ;
) ;
# ifdef NEOPIXEL
# ifdef NEOPIXEL_ENABLE
xTaskCreatePinnedToCore (
xTaskCreatePinnedToCore (
showLed , /* Function to implement the task */
showLed , /* Function to implement the task */
" LED " , /* Name of the task */
" LED " , /* Name of the task */
@ -2703,7 +2703,7 @@ void setup() {
// Only enable MQTT if requested
// Only enable MQTT if requested
# ifdef MQTT
# ifdef MQTT_ENABLE
if ( enableMqtt ) {
if ( enableMqtt ) {
MQTTclient . setServer ( mqtt_server , 1883 ) ;
MQTTclient . setServer ( mqtt_server , 1883 ) ;
MQTTclient . setCallback ( callback ) ;
MQTTclient . setCallback ( callback ) ;
@ -2764,18 +2764,18 @@ void loop() {
deepSleepManager ( ) ;
deepSleepManager ( ) ;
rfidPreferenceLookupHandler ( ) ;
rfidPreferenceLookupHandler ( ) ;
if ( wifiManager ( ) = = WL_CONNECTED ) {
if ( wifiManager ( ) = = WL_CONNECTED ) {
# ifdef MQTT
# ifdef MQTT_ENABLE
if ( enableMqtt ) {
if ( enableMqtt ) {
reconnect ( ) ;
reconnect ( ) ;
MQTTclient . loop ( ) ;
MQTTclient . loop ( ) ;
postHeartbeatViaMqtt ( ) ;
postHeartbeatViaMqtt ( ) ;
}
}
# endif
# endif
# ifdef FTP
# ifdef FTP_ENABLE
ftpSrv . handleFTP ( ) ;
ftpSrv . handleFTP ( ) ;
# endif
# endif
}
}
# ifdef FTP
# ifdef FTP_ENABLE
if ( ftpSrv . isConnected ( ) ) {
if ( ftpSrv . isConnected ( ) ) {
lastTimeActiveTimestamp = millis ( ) ; // Re-adjust timer while client is connected to avoid ESP falling asleep
lastTimeActiveTimestamp = millis ( ) ; // Re-adjust timer while client is connected to avoid ESP falling asleep
}
}
@ -2803,7 +2803,7 @@ void audio_showstation(const char *info) {
loggerNl ( logBuf , LOGLEVEL_NOTICE ) ;
loggerNl ( logBuf , LOGLEVEL_NOTICE ) ;
char buf [ 255 ] ;
char buf [ 255 ] ;
snprintf ( buf , sizeof ( buf ) / sizeof ( buf [ 0 ] ) , " Webradio: %s " , info ) ;
snprintf ( buf , sizeof ( buf ) / sizeof ( buf [ 0 ] ) , " Webradio: %s " , info ) ;
# ifdef MQTT
# ifdef MQTT_ENABLE
publishMqtt ( ( char * ) FPSTR ( topicTrackState ) , buf , false ) ;
publishMqtt ( ( char * ) FPSTR ( topicTrackState ) , buf , false ) ;
# endif
# endif
}
}