| 51 | } |
| 52 | |
| 53 | bool Preferences::optString(const std::string& key, std::string& out) const { |
| 54 | nvs_handle_t handle; |
| 55 | if (nvs_open(namespace_, NVS_READWRITE, &handle) != ESP_OK) { |
| 56 | LOGGER.error("Failed to open namespace {}", namespace_); |
| 57 | return false; |
| 58 | } else { |
| 59 | size_t out_size = 256; |
| 60 | char* out_data = static_cast<char*>(malloc(out_size)); |
| 61 | bool success = nvs_get_str(handle, key.c_str(), out_data, &out_size) == ESP_OK; |
| 62 | nvs_close(handle); |
| 63 | out = out_data; |
| 64 | free(out_data); |
| 65 | return success; |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | bool Preferences::hasBool(const std::string& key) const { |
| 70 | bool temp; |
no test coverage detected