|
|
@ -378,6 +378,8 @@ QueueHandle_t explorerFileUploadStatusQueue; |
|
|
|
|
|
|
|
// Prototypes
|
|
|
|
void accessPointStart(const char *SSID, IPAddress ip, IPAddress netmask); |
|
|
|
void actionError(void); |
|
|
|
void actionOk(void); |
|
|
|
static int arrSortHelper(const void* a, const void* b); |
|
|
|
void batteryVoltageTester(void); |
|
|
|
void buttonHandler(); |
|
|
@ -468,6 +470,22 @@ void logger(const uint8_t _currentLogLevel, const char *_logBuffer, const uint8_ |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Indicate if error occured
|
|
|
|
void actionError(void) { |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
#endif
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Indicate if action was ok
|
|
|
|
void actionOk(void) { |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedOk = true; |
|
|
|
#endif
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void IRAM_ATTR onTimer() { |
|
|
|
xSemaphoreGiveFromISR(timerSemaphore, NULL); |
|
|
|
} |
|
|
@ -948,24 +966,18 @@ void callback(const char *topic, const byte *payload, uint32_t length) { |
|
|
|
if (playProperties.playMode == NO_PLAYLIST) { // Don't allow sleep-modications if no playlist is active
|
|
|
|
loggerNl(serialDebug, (char *) FPSTR(modificatorNotallowedWhenIdle), LOGLEVEL_INFO); |
|
|
|
publishMqtt((char *) FPSTR(topicSleepState), 0, false); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
#endif
|
|
|
|
actionError(); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (strcmp(receivedString, "EOP") == 0) { |
|
|
|
playProperties.sleepAfterPlaylist = true; |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(sleepTimerEOP), LOGLEVEL_NOTICE); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedOk = true; |
|
|
|
#endif
|
|
|
|
actionOk(); |
|
|
|
return; |
|
|
|
} else if (strcmp(receivedString, "EOT") == 0) { |
|
|
|
playProperties.sleepAfterCurrentTrack = true; |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(sleepTimerEOT), LOGLEVEL_NOTICE); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedOk = true; |
|
|
|
#endif
|
|
|
|
actionOk(); |
|
|
|
return; |
|
|
|
} else if (strcmp(receivedString, "EO5T") == 0) { |
|
|
|
if ((playProperties.numberOfTracks - 1) >= (playProperties.currentTrackNumber + 5)) { |
|
|
@ -974,33 +986,25 @@ void callback(const char *topic, const byte *payload, uint32_t length) { |
|
|
|
playProperties.sleepAfterPlaylist = true; |
|
|
|
} |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(sleepTimerEO5), LOGLEVEL_NOTICE); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedOk = true; |
|
|
|
#endif
|
|
|
|
actionOk(); |
|
|
|
return; |
|
|
|
} else if (strcmp(receivedString, "0") == 0) { |
|
|
|
if (sleepTimerStartTimestamp) { |
|
|
|
sleepTimerStartTimestamp = 0; |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(sleepTimerStop), LOGLEVEL_NOTICE); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedOk = true; |
|
|
|
#endif
|
|
|
|
actionOk(); |
|
|
|
publishMqtt((char *) FPSTR(topicSleepState), 0, false); |
|
|
|
return; |
|
|
|
} else { |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(sleepTimerAlreadyStopped), LOGLEVEL_INFO); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
#endif
|
|
|
|
actionError(); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
sleepTimer = strtoul(receivedString, NULL, 10); |
|
|
|
snprintf(logBuf, serialLoglength, "%s: %u Minute(n)", (char *) FPSTR(sleepTimerSetTo), sleepTimer); |
|
|
|
loggerNl(serialDebug, logBuf, LOGLEVEL_NOTICE); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedOk = true; |
|
|
|
#endif
|
|
|
|
actionOk(); |
|
|
|
|
|
|
|
sleepTimerStartTimestamp = millis(); // Activate timer
|
|
|
|
playProperties.sleepAfterPlaylist = false; |
|
|
@ -1017,16 +1021,12 @@ void callback(const char *topic, const byte *payload, uint32_t length) { |
|
|
|
if (strcmp(receivedString, "OFF") == 0) { |
|
|
|
lockControls = false; |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(allowButtons), LOGLEVEL_NOTICE); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedOk = true; |
|
|
|
#endif
|
|
|
|
actionOk(); |
|
|
|
|
|
|
|
} else if (strcmp(receivedString, "ON") == 0) { |
|
|
|
lockControls = true; |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(lockButtons), LOGLEVEL_NOTICE); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedOk = true; |
|
|
|
#endif
|
|
|
|
actionOk(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -1040,9 +1040,7 @@ void callback(const char *topic, const byte *payload, uint32_t length) { |
|
|
|
snprintf(rBuf, 2, "%u", getRepeatMode()); |
|
|
|
publishMqtt((char *) FPSTR(topicRepeatModeState), rBuf, false); |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(noPlaylistNotAllowedMqtt), LOGLEVEL_ERROR); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
#endif
|
|
|
|
actionError(); |
|
|
|
} else { |
|
|
|
switch (repeatMode) { |
|
|
|
case NO_REPEAT: |
|
|
@ -1051,9 +1049,7 @@ void callback(const char *topic, const byte *payload, uint32_t length) { |
|
|
|
snprintf(rBuf, 2, "%u", getRepeatMode()); |
|
|
|
publishMqtt((char *) FPSTR(topicRepeatModeState), rBuf, false); |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(modeRepeatNone), LOGLEVEL_INFO); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedOk = true; |
|
|
|
#endif
|
|
|
|
actionOk(); |
|
|
|
break; |
|
|
|
|
|
|
|
case TRACK: |
|
|
@ -1062,9 +1058,7 @@ void callback(const char *topic, const byte *payload, uint32_t length) { |
|
|
|
snprintf(rBuf, 2, "%u", getRepeatMode()); |
|
|
|
publishMqtt((char *) FPSTR(topicRepeatModeState), rBuf, false); |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(modeRepeatTrack), LOGLEVEL_INFO); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedOk = true; |
|
|
|
#endif
|
|
|
|
actionOk(); |
|
|
|
break; |
|
|
|
|
|
|
|
case PLAYLIST: |
|
|
@ -1073,9 +1067,7 @@ void callback(const char *topic, const byte *payload, uint32_t length) { |
|
|
|
snprintf(rBuf, 2, "%u", getRepeatMode()); |
|
|
|
publishMqtt((char *) FPSTR(topicRepeatModeState), rBuf, false); |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(modeRepeatPlaylist), LOGLEVEL_INFO); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedOk = true; |
|
|
|
#endif
|
|
|
|
actionOk(); |
|
|
|
break; |
|
|
|
|
|
|
|
case TRACK_N_PLAYLIST: |
|
|
@ -1084,15 +1076,11 @@ void callback(const char *topic, const byte *payload, uint32_t length) { |
|
|
|
snprintf(rBuf, 2, "%u", getRepeatMode()); |
|
|
|
publishMqtt((char *) FPSTR(topicRepeatModeState), rBuf, false); |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(modeRepeatTracknPlaylist), LOGLEVEL_INFO); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedOk = true; |
|
|
|
#endif
|
|
|
|
actionOk(); |
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
#endif
|
|
|
|
actionError(); |
|
|
|
snprintf(rBuf, 2, "%u", getRepeatMode()); |
|
|
|
publishMqtt((char *) FPSTR(topicRepeatModeState), rBuf, false); |
|
|
|
break; |
|
|
@ -1110,9 +1098,7 @@ void callback(const char *topic, const byte *payload, uint32_t length) { |
|
|
|
else { |
|
|
|
snprintf(logBuf, serialLoglength, "%s: %s", (char *) FPSTR(noValidTopic), topic); |
|
|
|
loggerNl(serialDebug, logBuf, LOGLEVEL_ERROR); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
#endif
|
|
|
|
actionError(); |
|
|
|
} |
|
|
|
|
|
|
|
free(receivedString); |
|
|
@ -1278,9 +1264,7 @@ char ** returnPlaylistFromSD(File _fileOrDirectory) { |
|
|
|
} |
|
|
|
if (files == NULL) { |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(unableToAllocateMemForPlaylist), LOGLEVEL_ERROR); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
#endif
|
|
|
|
actionError(); |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(fileModeDetected), LOGLEVEL_INFO); |
|
|
@ -1330,9 +1314,7 @@ char ** returnPlaylistFromSD(File _fileOrDirectory) { |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(reallocCalled), LOGLEVEL_DEBUG); |
|
|
|
if (serializedPlaylist == NULL) { |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(unableToAllocateMemForLinearPlaylist), LOGLEVEL_ERROR); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
#endif
|
|
|
|
actionError(); |
|
|
|
return files; |
|
|
|
} |
|
|
|
} |
|
|
@ -1359,9 +1341,7 @@ char ** returnPlaylistFromSD(File _fileOrDirectory) { |
|
|
|
|
|
|
|
if (files == NULL) { |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(unableToAllocateMemForPlaylist), LOGLEVEL_ERROR); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
#endif
|
|
|
|
actionError(); |
|
|
|
free(serializedPlaylist); |
|
|
|
return NULL; |
|
|
|
} |
|
|
@ -1385,9 +1365,7 @@ char ** returnPlaylistFromSD(File _fileOrDirectory) { |
|
|
|
|
|
|
|
if (files[0] == NULL) { |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(unableToAllocateMemForPlaylist), LOGLEVEL_ERROR); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
#endif
|
|
|
|
actionError(); |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
sprintf(files[0], "%u", cnt); |
|
|
@ -1520,9 +1498,7 @@ void playAudio(void *parameter) { |
|
|
|
if (playProperties.playlistFinished && trackCommand != 0) { |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(noPlaymodeChangeIfIdle), LOGLEVEL_NOTICE); |
|
|
|
trackCommand = 0; |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
#endif
|
|
|
|
actionError(); |
|
|
|
continue; |
|
|
|
} |
|
|
|
/* Check if track-control was called
|
|
|
@ -1575,9 +1551,7 @@ void playAudio(void *parameter) { |
|
|
|
} else { |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(lastTrackAlreadyActive), LOGLEVEL_NOTICE); |
|
|
|
trackCommand = 0; |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
#endif
|
|
|
|
actionError(); |
|
|
|
continue; |
|
|
|
} |
|
|
|
trackCommand = 0; |
|
|
@ -1613,9 +1587,7 @@ void playAudio(void *parameter) { |
|
|
|
} else { |
|
|
|
if (playProperties.playMode == WEBSTREAM) { |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(trackChangeWebstream), LOGLEVEL_INFO); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
#endif
|
|
|
|
actionError(); |
|
|
|
trackCommand = 0; |
|
|
|
continue; |
|
|
|
} |
|
|
@ -1629,9 +1601,7 @@ void playAudio(void *parameter) { |
|
|
|
audioReturnCode = audio.connecttoFS(FSystem, *(playProperties.playlist + playProperties.currentTrackNumber)); |
|
|
|
// consider track as finished, when audio lib call was not successful
|
|
|
|
if (!audioReturnCode) { |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
#endif
|
|
|
|
actionError(); |
|
|
|
playProperties.trackFinished = true; |
|
|
|
continue; |
|
|
|
} |
|
|
@ -1659,9 +1629,7 @@ void playAudio(void *parameter) { |
|
|
|
} |
|
|
|
} else { |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(firstTrackAlreadyActive), LOGLEVEL_NOTICE); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
#endif
|
|
|
|
actionError(); |
|
|
|
trackCommand = 0; |
|
|
|
continue; |
|
|
|
} |
|
|
@ -1685,9 +1653,7 @@ void playAudio(void *parameter) { |
|
|
|
} |
|
|
|
} else { |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(lastTrackAlreadyActive), LOGLEVEL_NOTICE); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
#endif
|
|
|
|
actionError(); |
|
|
|
trackCommand = 0; |
|
|
|
continue; |
|
|
|
} |
|
|
@ -1700,9 +1666,7 @@ void playAudio(void *parameter) { |
|
|
|
default: |
|
|
|
trackCommand = 0; |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(cmndDoesNotExist), LOGLEVEL_NOTICE); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
#endif
|
|
|
|
actionError(); |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
@ -1770,9 +1734,7 @@ void playAudio(void *parameter) { |
|
|
|
audioReturnCode = audio.connecttoFS(FSystem, *(playProperties.playlist + playProperties.currentTrackNumber)); |
|
|
|
// consider track as finished, when audio lib call was not successful
|
|
|
|
if(!audioReturnCode) { |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
#endif
|
|
|
|
actionError(); |
|
|
|
playProperties.trackFinished = true; |
|
|
|
continue; |
|
|
|
} |
|
|
@ -1810,9 +1772,7 @@ void playAudio(void *parameter) { |
|
|
|
Serial.printf("Jumped %d seconds forwards\n", jumpOffset); |
|
|
|
#endif
|
|
|
|
} else { |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
#endif
|
|
|
|
actionError(); |
|
|
|
} |
|
|
|
} else if (playProperties.seekmode == SEEK_BACKWARDS) { |
|
|
|
if (audio.setTimeOffset(-(jumpOffset))) { |
|
|
@ -1822,9 +1782,7 @@ void playAudio(void *parameter) { |
|
|
|
Serial.printf("Jumped %d seconds backwards\n", jumpOffset); |
|
|
|
#endif
|
|
|
|
} else { |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
#endif
|
|
|
|
actionError(); |
|
|
|
} |
|
|
|
} |
|
|
|
playProperties.seekmode = SEEK_NORMAL; |
|
|
@ -1912,9 +1870,7 @@ void rfidScanner(void) { |
|
|
|
|
|
|
|
if (cardIdString == NULL) { |
|
|
|
logger(serialDebug, (char *) FPSTR(unableToAllocateMem), LOGLEVEL_ERROR); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
#endif
|
|
|
|
actionError(); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
@ -1982,9 +1938,7 @@ void rfidScanner(void *parameter) { |
|
|
|
|
|
|
|
if (cardIdString == NULL) { |
|
|
|
logger(serialDebug, (char *) FPSTR(unableToAllocateMem), LOGLEVEL_ERROR); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
#endif
|
|
|
|
actionError(); |
|
|
|
continue; |
|
|
|
} |
|
|
|
for (uint8_t i=0; i<cardIdSize; i++) |
|
|
@ -2031,9 +1985,7 @@ void rfidScanner(void *parameter) { |
|
|
|
|
|
|
|
if (cardIdString == NULL) { |
|
|
|
logger(serialDebug, (char *) FPSTR(unableToAllocateMem), LOGLEVEL_ERROR); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
#endif
|
|
|
|
actionError(); |
|
|
|
continue; |
|
|
|
} |
|
|
|
for (uint8_t i=0; i<cardIdSize; i++) |
|
|
@ -2664,16 +2616,12 @@ void trackQueueDispatcher(const char *_itemToPlay, const uint32_t _lastPlayPos, |
|
|
|
|
|
|
|
if (musicFiles == NULL) { |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(errorOccured), LOGLEVEL_ERROR); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
#endif
|
|
|
|
actionError(); |
|
|
|
playProperties.playMode = NO_PLAYLIST; |
|
|
|
return; |
|
|
|
} else if (!strcmp(*(musicFiles-1), "0")) { |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(noMp3FilesInDir), LOGLEVEL_NOTICE); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
#endif
|
|
|
|
actionError(); |
|
|
|
playProperties.playMode = NO_PLAYLIST; |
|
|
|
free (filename); |
|
|
|
return; |
|
|
@ -2797,9 +2745,7 @@ void trackQueueDispatcher(const char *_itemToPlay, const uint32_t _lastPlayPos, |
|
|
|
#endif
|
|
|
|
} else { |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(webstreamNotAvailable), LOGLEVEL_ERROR); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
#endif
|
|
|
|
actionError(); |
|
|
|
playProperties.playMode = NO_PLAYLIST; |
|
|
|
} |
|
|
|
break; |
|
|
@ -2808,9 +2754,7 @@ void trackQueueDispatcher(const char *_itemToPlay, const uint32_t _lastPlayPos, |
|
|
|
default: |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(modeDoesNotExist), LOGLEVEL_ERROR); |
|
|
|
playProperties.playMode = NO_PLAYLIST; |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
#endif
|
|
|
|
actionError(); |
|
|
|
} |
|
|
|
free (filename); |
|
|
|
} |
|
|
@ -2831,9 +2775,7 @@ void doCmdAction(const uint16_t mod) { |
|
|
|
#ifdef MQTT_ENABLE
|
|
|
|
publishMqtt((char *) FPSTR(topicLockControlsState), "ON", false); |
|
|
|
#endif
|
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedOk = true; |
|
|
|
#endif
|
|
|
|
actionOk(); |
|
|
|
} else { |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(modificatorAllButtonsUnlocked), LOGLEVEL_NOTICE); |
|
|
|
#ifdef MQTT_ENABLE
|
|
|
@ -2871,9 +2813,7 @@ void doCmdAction(const uint16_t mod) { |
|
|
|
playProperties.sleepAfterCurrentTrack = false; // deactivate/overwrite if already active
|
|
|
|
playProperties.sleepAfterPlaylist = false; // deactivate/overwrite if already active
|
|
|
|
playProperties.playUntilTrackNumber = 0; |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedOk = true; |
|
|
|
#endif
|
|
|
|
actionOk(); |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
@ -2905,9 +2845,7 @@ void doCmdAction(const uint16_t mod) { |
|
|
|
playProperties.sleepAfterCurrentTrack = false; // deactivate/overwrite if already active
|
|
|
|
playProperties.sleepAfterPlaylist = false; // deactivate/overwrite if already active
|
|
|
|
playProperties.playUntilTrackNumber = 0; |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedOk = true; |
|
|
|
#endif
|
|
|
|
actionOk(); |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
@ -2939,9 +2877,7 @@ void doCmdAction(const uint16_t mod) { |
|
|
|
playProperties.sleepAfterCurrentTrack = false; // deactivate/overwrite if already active
|
|
|
|
playProperties.sleepAfterPlaylist = false; // deactivate/overwrite if already active
|
|
|
|
playProperties.playUntilTrackNumber = 0; |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedOk = true; |
|
|
|
#endif
|
|
|
|
actionOk(); |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
@ -2973,18 +2909,14 @@ void doCmdAction(const uint16_t mod) { |
|
|
|
playProperties.sleepAfterCurrentTrack = false; // deactivate/overwrite if already active
|
|
|
|
playProperties.sleepAfterPlaylist = false; // deactivate/overwrite if already active
|
|
|
|
playProperties.playUntilTrackNumber = 0; |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedOk = true; |
|
|
|
#endif
|
|
|
|
actionOk(); |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
case SLEEP_AFTER_END_OF_TRACK: { // Puts uC to sleep after end of current track
|
|
|
|
if (playProperties.playMode == NO_PLAYLIST) { |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(modificatorNotallowedWhenIdle), LOGLEVEL_NOTICE); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
#endif
|
|
|
|
actionError(); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (playProperties.sleepAfterCurrentTrack) { |
|
|
@ -3013,18 +2945,14 @@ void doCmdAction(const uint16_t mod) { |
|
|
|
#ifdef MQTT_ENABLE
|
|
|
|
publishMqtt((char *) FPSTR(topicLedBrightnessState), ledBrightness, false); |
|
|
|
#endif
|
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedOk = true; |
|
|
|
#endif
|
|
|
|
actionOk(); |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
case SLEEP_AFTER_END_OF_PLAYLIST: { // Puts uC to sleep after end of whole playlist (can take a while :->)
|
|
|
|
if (playProperties.playMode == NO_PLAYLIST) { |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(modificatorNotallowedWhenIdle), LOGLEVEL_NOTICE); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
#endif
|
|
|
|
actionError(); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (playProperties.sleepAfterCurrentTrack) { |
|
|
@ -3053,18 +2981,14 @@ void doCmdAction(const uint16_t mod) { |
|
|
|
#ifdef MQTT_ENABLE
|
|
|
|
publishMqtt((char *) FPSTR(topicLedBrightnessState), ledBrightness, false); |
|
|
|
#endif
|
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedOk = true; |
|
|
|
#endif
|
|
|
|
actionOk(); |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
case SLEEP_AFTER_5_TRACKS:{ |
|
|
|
if (playProperties.playMode == NO_PLAYLIST) { |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(modificatorNotallowedWhenIdle), LOGLEVEL_NOTICE); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
#endif
|
|
|
|
actionError(); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
@ -3102,18 +3026,14 @@ void doCmdAction(const uint16_t mod) { |
|
|
|
#ifdef MQTT_ENABLE
|
|
|
|
publishMqtt((char *) FPSTR(topicLedBrightnessState), ledBrightness, false); |
|
|
|
#endif
|
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedOk = true; |
|
|
|
#endif
|
|
|
|
actionOk(); |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
case REPEAT_PLAYLIST: { |
|
|
|
if (playProperties.playMode == NO_PLAYLIST) { |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(modificatorNotallowedWhenIdle), LOGLEVEL_NOTICE); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
#endif
|
|
|
|
actionError(); |
|
|
|
} else { |
|
|
|
if (playProperties.repeatPlaylist) { |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(modificatorPlaylistLoopDeactive), LOGLEVEL_NOTICE); |
|
|
@ -3126,9 +3046,7 @@ void doCmdAction(const uint16_t mod) { |
|
|
|
#ifdef MQTT_ENABLE
|
|
|
|
publishMqtt((char *) FPSTR(topicRepeatModeState), rBuf, false); |
|
|
|
#endif
|
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedOk = true; |
|
|
|
#endif
|
|
|
|
actionOk(); |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
@ -3136,9 +3054,7 @@ void doCmdAction(const uint16_t mod) { |
|
|
|
case REPEAT_TRACK: { // Introduces looping for track-mode
|
|
|
|
if (playProperties.playMode == NO_PLAYLIST) { |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(modificatorNotallowedWhenIdle), LOGLEVEL_NOTICE); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
#endif
|
|
|
|
actionError(); |
|
|
|
} else { |
|
|
|
if (playProperties.repeatCurrentTrack) { |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(modificatorTrackDeactive), LOGLEVEL_NOTICE); |
|
|
@ -3151,9 +3067,7 @@ void doCmdAction(const uint16_t mod) { |
|
|
|
#ifdef MQTT_ENABLE
|
|
|
|
publishMqtt((char *) FPSTR(topicRepeatModeState), rBuf, false); |
|
|
|
#endif
|
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedOk = true; |
|
|
|
#endif
|
|
|
|
actionOk(); |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
@ -3165,39 +3079,29 @@ void doCmdAction(const uint16_t mod) { |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(ledsDimmedToNightmode), LOGLEVEL_INFO); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
ledBrightness = nightLedBrightness; |
|
|
|
showLedOk = true; |
|
|
|
#endif
|
|
|
|
actionOk(); |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
case TOGGLE_WIFI_STATUS: { |
|
|
|
if (writeWifiStatusToNVS(!getWifiEnableStatusFromNVS())) { |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedOk = true; |
|
|
|
#endif
|
|
|
|
actionOk(); |
|
|
|
} else { |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
#endif
|
|
|
|
actionError(); |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|
#ifdef BLUETOOTH_ENABLE
|
|
|
|
case TOGGLE_BLUETOOTH_MODE: { |
|
|
|
if (readOperationModeFromNVS() == OPMODE_NORMAL) { |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedOk = true; |
|
|
|
#endif
|
|
|
|
actionOk(); |
|
|
|
setOperationMode(OPMODE_BLUETOOTH); |
|
|
|
} else if (readOperationModeFromNVS() == OPMODE_BLUETOOTH) { |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedOk = true; |
|
|
|
#endif
|
|
|
|
actionOk(); |
|
|
|
setOperationMode(OPMODE_NORMAL); |
|
|
|
} else { |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
#endif
|
|
|
|
actionError(); |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
@ -3206,14 +3110,10 @@ void doCmdAction(const uint16_t mod) { |
|
|
|
case ENABLE_FTP_SERVER: { |
|
|
|
if (wifiManager() == WL_CONNECTED && !ftpEnableLastStatus && !ftpEnableCurrentStatus) { |
|
|
|
ftpEnableLastStatus = true; |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedOk = true; |
|
|
|
#endif
|
|
|
|
actionOk(); |
|
|
|
} else { |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(unableToStartFtpServer), LOGLEVEL_ERROR); |
|
|
|
#endif
|
|
|
|
loggerNl(serialDebug, (char *) FPSTR(unableToStartFtpServer), LOGLEVEL_ERROR); |
|
|
|
actionError(); |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
@ -3281,9 +3181,7 @@ void doCmdAction(const uint16_t mod) { |
|
|
|
default: { |
|
|
|
snprintf(logBuf, serialLoglength, "%s %d !", (char *) FPSTR(modificatorDoesNotExist), mod); |
|
|
|
loggerNl(serialDebug, logBuf, LOGLEVEL_ERROR); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
#endif
|
|
|
|
actionError(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -3311,9 +3209,7 @@ void rfidPreferenceLookupHandler (void) { |
|
|
|
String s = prefsRfid.getString(currentRfidTagId, "-1"); // Try to lookup rfidId in NVS
|
|
|
|
if (!s.compareTo("-1")) { |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(rfidTagUnknownInNvs), LOGLEVEL_ERROR); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
#endif
|
|
|
|
actionError(); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
@ -3336,9 +3232,7 @@ void rfidPreferenceLookupHandler (void) { |
|
|
|
|
|
|
|
if (i != 5) { |
|
|
|
loggerNl(serialDebug, (char *) FPSTR(errorOccuredNvs), LOGLEVEL_ERROR); |
|
|
|
#ifdef NEOPIXEL_ENABLE
|
|
|
|
showLedError = true; |
|
|
|
#endif
|
|
|
|
actionError(); |
|
|
|
} else { |
|
|
|
// Only pass file to queue if strtok revealed 3 items
|
|
|
|
if (_playMode >= 100) { |
|
|
@ -4807,7 +4701,7 @@ void setup() { |
|
|
|
Serial.println(F(" | |___ ___) | | __/ | |_| | | | | | | | | (_) |")); |
|
|
|
Serial.println(F(" |_____| |____/ |_| \\__,_| |_| |_| |_| \\___/ ")); |
|
|
|
Serial.println(F(" Rfid-controlled musicplayer\n")); |
|
|
|
Serial.println(F(" Rev 20210402-1\n")); |
|
|
|
Serial.println(F(" Rev 20210402-2\n")); |
|
|
|
// print wake-up reason
|
|
|
|
printWakeUpReason(); |
|
|
|
#ifdef PN5180_ENABLE_LPCD
|
|
|
|