From 0210b578f3718e6191ac63a55a7769b211391ba2 Mon Sep 17 00:00:00 2001 From: drkr Date: Mon, 21 Jan 2019 18:05:08 +0200 Subject: [PATCH] Added simple example --- examples/simpleFlashNVS.ino | 41 +++++++++++++++++++ examples/{example.ino => uart-controlled.ino} | 7 +++- library.json | 2 +- library.properties | 2 +- 4 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 examples/simpleFlashNVS.ino rename examples/{example.ino => uart-controlled.ino} (95%) diff --git a/examples/simpleFlashNVS.ino b/examples/simpleFlashNVS.ino new file mode 100644 index 0000000..e2735da --- /dev/null +++ b/examples/simpleFlashNVS.ino @@ -0,0 +1,41 @@ +#include +#include "ArduinoNvs.h" + +/** + * Arduino NVS is a port for a non-volatile storage (NVS, flash) library for ESP32 to the Arduino Platform. + * It wraps main NVS functionality into the Arduino-styled C++ class. + */ + +void setup() { + NVS.begin(); +} + +void loop() { + bool res; + /*** Int ***/ + // write to flash + const uint64_t ui64_set = 0x1122334455667788; + res = NVS.setInt("longInt", ui64_set); + // read from flash + uint64_t uui64 = NVS.getInt("longInt"); + + + /*** String ***/ + // write to flash + const String st_set = "`simple plain string`"; + res = NVS.setString("st", st_set); + // read from flash + String st = NVS.getString("st"); + + + /*** BLOB ***/ + //write to flash + uint8_t blolb_set[] = {1,2,3,99,100, 0xEE, 0xFE, 0xEE}; + res = NVS.setBlob("blob", blolb_set, sizeof(blolb_set)); + // read from flash + size_t blobLength = NVS.getBlobSize("blob"); + uint8_t blob[blobLength]; + res = NVS.getBlob("blob", blob, sizeof(blob)); + + delay(1000); +} diff --git a/examples/example.ino b/examples/uart-controlled.ino similarity index 95% rename from examples/example.ino rename to examples/uart-controlled.ino index 4a61594..b69f542 100644 --- a/examples/example.ino +++ b/examples/uart-controlled.ino @@ -1,6 +1,11 @@ #include #include "ArduinoNvs.h" +/** + * Arduino NVS is a port for a non-volatile storage (NVS, flash) library for ESP32 to the Arduino Platform. + * It wraps main NVS functionality into the Arduino-styled C++ class. + */ + using namespace std; #define PRINT(...) Serial.print(__VA_ARGS__) @@ -64,7 +69,7 @@ void loop() { DEBUG("6. nvss: ui64 %llu", uui64); } break; case '7': { - uint64_t ii64 = nvss.getInt("i64"); + int64_t ii64 = nvss.getInt("i64"); DEBUG("7. nvss: i64 %lli", ii64); } break; case 'w': { diff --git a/library.json b/library.json index 9ce5b44..d420c4a 100644 --- a/library.json +++ b/library.json @@ -7,7 +7,7 @@ "type": "git", "url": "https://github.com/rpolitex/ArduinoNvs" }, - "version": "1.0", + "version": "2.1", "authors": [ { "name": "dRKr", diff --git a/library.properties b/library.properties index 31429b9..cd0fb3f 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=ArduinoNvs -version=1.1 +version=2.1 author=dRKr maintainer=SinaiRnD sentence=Arduino wrapper for ESP32 NVS (Non-volatile storage)