diff --git a/player/src/SDCard.cpp b/player/src/SDCard.cpp index 151066f..f08c394 100644 --- a/player/src/SDCard.cpp +++ b/player/src/SDCard.cpp @@ -64,6 +64,7 @@ SDCard::SDCard(gpio_num_t clk, gpio_num_t cmd, gpio_num_t d0, gpio_num_t d1, gpi Serial.printf("SDCard mounted at: %s\n", MOUNT_POINT); // Card has been initialized, print its properties sdmmc_card_print_info(stdout, m_card); + sd_card_init_success = true; #endif } @@ -123,6 +124,7 @@ SDCard::SDCard(gpio_num_t miso, gpio_num_t mosi, gpio_num_t clk, gpio_num_t cs) Serial.printf("SDCard mounted at: %s\n", MOUNT_POINT); // Card has been initialized, print its properties sdmmc_card_print_info(stdout, m_card); + sd_card_init_success = true; } SDCard::~SDCard() @@ -135,7 +137,10 @@ SDCard::~SDCard() bool SDCard::isMounted() { - return sdmmc_get_status(m_card) == ESP_OK; + if (sd_card_init_success) { + return sdmmc_get_status(m_card) == ESP_OK; + } + return false; } std::vector SDCard::listFiles(const char *folder, const char *extension) diff --git a/player/src/SDCard.h b/player/src/SDCard.h index 6c66cbf..a258199 100644 --- a/player/src/SDCard.h +++ b/player/src/SDCard.h @@ -17,6 +17,7 @@ class SDCard #else sdmmc_host_t m_host = SDSPI_HOST_DEFAULT(); #endif + bool sd_card_init_success = false; public: SDCard(gpio_num_t miso, gpio_num_t mosi, gpio_num_t clk, gpio_num_t cs); SDCard(gpio_num_t clk, gpio_num_t cmd, gpio_num_t d0, gpio_num_t d1, gpio_num_t d2, gpio_num_t d3);