logging
This commit is contained in:
parent
1e304979c5
commit
c81ca008cf
@ -12,10 +12,10 @@ AsyncWebSocket ws("/ws");
|
|||||||
|
|
||||||
void onWebSocketEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, const AwsEventType type, void *arg, const uint8_t *data, const size_t len) {
|
void onWebSocketEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, const AwsEventType type, void *arg, const uint8_t *data, const size_t len) {
|
||||||
if (type == WS_EVT_CONNECT) {
|
if (type == WS_EVT_CONNECT) {
|
||||||
Serial.printf("[%-8s] Connected: %s\n", "WEBSOCKET", client->remoteIP().toString().c_str());
|
Serial.printf("[%-9s] Connected: %s\n", "WEBSOCKET", client->remoteIP().toString().c_str());
|
||||||
client->text(stateBuffer);
|
client->text(stateBuffer);
|
||||||
} else if (type == WS_EVT_DISCONNECT) {
|
} else if (type == WS_EVT_DISCONNECT) {
|
||||||
Serial.printf("[%-8s] Disconnected: %s\n", "WEBSOCKET", client->remoteIP().toString().c_str());
|
Serial.printf("[%-9s] Disconnected: %s\n", "WEBSOCKET", client->remoteIP().toString().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,7 +20,7 @@ size_t playlistIndex = 0;
|
|||||||
std::vector<Entry> playlistEntries;
|
std::vector<Entry> playlistEntries;
|
||||||
|
|
||||||
void playlistClear() {
|
void playlistClear() {
|
||||||
Serial.println("[PLAYLIST] clear");
|
Serial.println("[PLAYLIST ] clear");
|
||||||
playlistTitle = "";
|
playlistTitle = "";
|
||||||
playlistIndex = 0;
|
playlistIndex = 0;
|
||||||
playlistEntries.clear();
|
playlistEntries.clear();
|
||||||
@ -29,17 +29,17 @@ void playlistClear() {
|
|||||||
|
|
||||||
void playlistAdd(String entry) {
|
void playlistAdd(String entry) {
|
||||||
entry.trim();
|
entry.trim();
|
||||||
Serial.println("[PLAYLIST] [ADD] " + entry);
|
Serial.println("[PLAYLIST ] [ADD] " + entry);
|
||||||
|
|
||||||
const auto index_type_url = entry.indexOf('|');
|
const auto index_type_url = entry.indexOf('|');
|
||||||
if (index_type_url < 0) {
|
if (index_type_url < 0) {
|
||||||
Serial.println("[PLAYLIST] type/url-delimiter not found: " + entry);
|
Serial.println("[PLAYLIST ] type/url-delimiter not found: " + entry);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto type = entry.substring(0, index_type_url);
|
auto type = entry.substring(0, index_type_url);
|
||||||
type.trim();
|
type.trim();
|
||||||
if (type != "TITLE" && type != "ICY" && type != "SD" && type != "SNAP") {
|
if (type != "TITLE" && type != "ICY" && type != "SD" && type != "SNAP") {
|
||||||
Serial.println("[PLAYLIST] Unknown type: " + type);
|
Serial.println("[PLAYLIST ] Unknown type: " + type);
|
||||||
}
|
}
|
||||||
|
|
||||||
entry = entry.substring(index_type_url + 1);
|
entry = entry.substring(index_type_url + 1);
|
||||||
@ -52,13 +52,13 @@ void playlistAdd(String entry) {
|
|||||||
|
|
||||||
const auto index_url_title = entry.indexOf('|');
|
const auto index_url_title = entry.indexOf('|');
|
||||||
if (index_url_title < 0) {
|
if (index_url_title < 0) {
|
||||||
Serial.println("[PLAYLIST] url/title-delimiter not found: " + entry);
|
Serial.println("[PLAYLIST ] url/title-delimiter not found: " + entry);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto url = entry.substring(0, index_url_title);
|
auto url = entry.substring(0, index_url_title);
|
||||||
url.trim();
|
url.trim();
|
||||||
if (url.isEmpty()) {
|
if (url.isEmpty()) {
|
||||||
Serial.println("[PLAYLIST] url is empty.");
|
Serial.println("[PLAYLIST ] url is empty.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,18 +70,18 @@ void playlistAdd(String entry) {
|
|||||||
|
|
||||||
void playlistLoad(const String &path) {
|
void playlistLoad(const String &path) {
|
||||||
playlistClear();
|
playlistClear();
|
||||||
Serial.println("[PLAYLIST] Loading playlist: " + path);
|
Serial.println("[PLAYLIST ] Loading playlist: " + path);
|
||||||
if (!SD.begin(PIN_AUDIO_KIT_SD_CARD_CS)) {
|
if (!SD.begin(PIN_AUDIO_KIT_SD_CARD_CS)) {
|
||||||
Serial.println("[PLAYLIST] Failed to initialize SD card.");
|
Serial.println("[PLAYLIST ] Failed to initialize SD card.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!SD.exists(path)) {
|
if (!SD.exists(path)) {
|
||||||
Serial.println("[PLAYLIST] File not found.");
|
Serial.println("[PLAYLIST ] File not found.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto file = SD.open(path, FILE_READ);
|
auto file = SD.open(path, FILE_READ);
|
||||||
if (!file) {
|
if (!file) {
|
||||||
Serial.println("[PLAYLIST] Failed to open file.");
|
Serial.println("[PLAYLIST ] Failed to open file.");
|
||||||
}
|
}
|
||||||
|
|
||||||
while (file.available() > 0) {
|
while (file.available() > 0) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user