forked from TridentTD/TridentTD_ESP32NVS
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
drkr
committed
Jan 21, 2019
1 parent
01b4696
commit 0210b57
Showing
4 changed files
with
49 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include <Arduino.h> | ||
#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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters