Skip to content

Commit

Permalink
Show free heap before & after creating new playlist
Browse files Browse the repository at this point in the history
Avoid log message "NVS entry not found"
  • Loading branch information
tueddy committed Oct 21, 2023
1 parent 3529915 commit efd1ea6
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/LogMessages_DE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
const char noPlaymodeChangeIfIdle[] = "Playmode kann nicht verändert werden, wenn keine Playlist aktiv ist.";
const char noValidTopic[] = "Kein gültiges Topic: %s";
const char freePtr[] = "Ptr-Freigabe: %s (0x%04x)";
const char freeMemory[] = "Freier Speicher: %u";
const char freeMemory[] = "Freier Speicher: %u Bytes";
const char writeEntryToNvs[] = "[%u] Schreibe Eintrag in NVS: %s => %s";
const char freeMemoryAfterFree[] = "Freier Speicher nach Aufräumen: %u";
const char releaseMemoryOfOldPlaylist[] = "Gebe Speicher der alten Playlist frei.";
const char freeMemoryAfterFree[] = "Freier Speicher nach Aufräumen: %u Bytes";
const char releaseMemoryOfOldPlaylist[] = "Gebe Speicher der alten Playlist frei (Freier Speicher: %u Bytes)";
const char dirOrFileDoesNotExist[] = "Datei oder Verzeichnis existiert nicht: %s";
const char unableToAllocateMemForPlaylist[] = "Speicher für Playlist konnte nicht allokiert werden!";
const char unableToAllocateMem[] = "Speicher konnte nicht allokiert werden!";
Expand Down
7 changes: 3 additions & 4 deletions src/LogMessages_EN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
const char noPlaymodeChangeIfIdle[] = "Playlist cannot be adjusted while no playlist is active.";
const char noValidTopic[] = "No valid MQTT-topic: %s";
const char freePtr[] = "Releasing Pointer: %s (0x%04x)";
const char freeMemory[] = "Free memory: %u";
const char freeMemory[] = "Free memory: %u Bytes";
const char writeEntryToNvs[] = "[%u] Storing data to NVS: %s => %s";
const char freeMemoryAfterFree[] = "Free memory after cleaning: %u";
const char releaseMemoryOfOldPlaylist[] = "Releasing memory of old playlist.";
const char freeMemoryAfterFree[] = "Free memory after cleaning: %u Bytes";
const char releaseMemoryOfOldPlaylist[] = "Releasing memory of old playlist (Free memory: %u Bytes).";
const char dirOrFileDoesNotExist[] = "File of directory does not exist: %s";
const char unableToAllocateMemForPlaylist[] = "Unable to allocate memory for playlist!";
const char unableToAllocateMem[] = "Unable to allocate memory!";
Expand Down Expand Up @@ -76,7 +76,6 @@
const char modeWebstream[] = "Mode: webstream";
const char modeWebstreamM3u[] = "Mode: Webstream (local .m3u-file)";
const char webstreamNotAvailable[] = "Unable to access webstream as no wifi-connection is available!";
const char modeInvalid[] = "Invalid play mode %d!";
const char modeDoesNotExist[] = "Playmode does not exist!";
const char modeRepeatNone[] = "Repeatmode: no repeat";
const char modeRepeatTrack[] = "Repeatmode: current track";
Expand Down
6 changes: 4 additions & 2 deletions src/RfidCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ void Rfid_PreferenceLookupHandler(void) {
strncpy(gCurrentRfidTagId, rfidTagId, cardIdStringSize-1);
Log_Printf(LOGLEVEL_INFO, "%s: %s", rfidTagReceived, gCurrentRfidTagId);
Web_SendWebsocketData(0, 10); // Push new rfidTagId to all websocket-clients

String s = gPrefsRfid.getString(gCurrentRfidTagId, "-1"); // Try to lookup rfidId in NVS
String s = "-1";
if (gPrefsRfid.isKey(gCurrentRfidTagId)) {
s = gPrefsRfid.getString(gCurrentRfidTagId, "-1"); // Try to lookup rfidId in NVS
}
if (!s.compareTo("-1")) {
Log_Println(rfidTagUnknownInNvs, LOGLEVEL_ERROR);
System_IndicateError();
Expand Down
6 changes: 3 additions & 3 deletions src/SdCard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,10 @@ char **SdCard_ReturnPlaylist(const char *fileName, const uint32_t _playMode) {
char *serializedPlaylist = NULL;
char fileNameBuf[255];
bool enablePlaylistFromM3u = false;
uint32_t listStartTimestamp = millis();
//uint32_t listStartTimestamp = millis();

if (files != NULL) { // If **ptr already exists, de-allocate its memory
Log_Println(releaseMemoryOfOldPlaylist, LOGLEVEL_DEBUG);
Log_Printf(LOGLEVEL_DEBUG, releaseMemoryOfOldPlaylist, ESP.getFreeHeap());
freeMultiCharArray(files, strtoul(files[0], NULL, 10) + 1);
Log_Printf(LOGLEVEL_DEBUG, freeMemoryAfterFree, ESP.getFreeHeap());
}
Expand Down Expand Up @@ -416,7 +416,7 @@ char **SdCard_ReturnPlaylist(const char *fileName, const uint32_t _playMode) {
}
snprintf(files[0], 5, "%u", cnt);
Log_Printf(LOGLEVEL_NOTICE, numberOfValidFiles, cnt);
Log_Printf(LOGLEVEL_DEBUG, "build playlist from SD-card finished: %lu ms", (millis() - listStartTimestamp));
// Log_Printf(LOGLEVEL_DEBUG, "build playlist from SD-card finished: %lu ms", (millis() - listStartTimestamp));

return &(files[1]); // return ptr+1 (starting at 1st payload-item); ptr+0 contains number of items
}
2 changes: 1 addition & 1 deletion src/revision.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once

#include "gitrevision.h"
constexpr const char softwareRevision[] = "Software-revision: 20231014-1";
constexpr const char softwareRevision[] = "Software-revision: 20231021-1";

0 comments on commit efd1ea6

Please sign in to comment.