Skip to content

Commit

Permalink
doc: fix nvs example case sensitivity (#240)
Browse files Browse the repository at this point in the history
  • Loading branch information
finger563 authored May 17, 2024
1 parent b3f96a0 commit ceb3090
Showing 1 changed file with 30 additions and 29 deletions.
59 changes: 30 additions & 29 deletions components/nvs/example/main/nvs_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,36 @@
using namespace std::chrono_literals;

extern "C" void app_main(void) {
std::this_thread::sleep_for(200ms);
fmt::print("Starting NVS example!\n");
//! [NVS example]
std::error_code ec;
uint8_t counter = 0;
espp::Nvs nvs;
std::this_thread::sleep_for(200ms);
fmt::print("Starting NVS example!\n");

//! [nvs example]
std::error_code ec;
uint8_t counter = 0;
espp::Nvs nvs;
nvs.init(ec);
ec.clear();
// note that the namespace and key strings must be <= 15 characters
nvs.get_or_set_var("system", "reset_counter", counter, counter, ec);
ec.clear();
fmt::print("Reset Counter = {}\n", counter);

counter++;

if (counter > 10) {
nvs.erase(ec);
nvs.init(ec);
counter = 0;
fmt::print("NVS erased, Reset Counter set to 0\n");
ec.clear();
//note that the namespace and key strings must be <= 15 characters
nvs.get_or_set_var("system", "reset_counter", counter, counter, ec);
ec.clear();
fmt::print("Reset Counter = {}\n", counter);

counter ++;

if(counter > 10) {
nvs.erase(ec);
nvs.init(ec);
counter = 0;
fmt::print("NVS erased, Reset Counter set to 0\n");
ec.clear();
}

nvs.set_var("system", "reset_counter", counter, ec);
fmt::print("Next Reset Counter will be = {}\n", counter);
fmt::print("NVS example complete!\n");
//! [NVS example]

while (true) {
std::this_thread::sleep_for(1s);
}
}

nvs.set_var("system", "reset_counter", counter, ec);
fmt::print("Next Reset Counter will be = {}\n", counter);
fmt::print("NVS example complete!\n");
//! [nvs example]

while (true) {
std::this_thread::sleep_for(1s);
}
}

0 comments on commit ceb3090

Please sign in to comment.