Skip to content

Commit 844a00e

Browse files
committed
Add WiFiStorage example
1 parent f0543a2 commit 844a00e

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

examples/WiFiStorage/WiFiStorage.ino

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
This example shows how to interact with NiNa internal memory partition
3+
APIs are modeled on SerialFlash library (not on SD) to speedup operations and avoid buffers.
4+
*/
5+
6+
#include <WiFi1010.h>
7+
8+
void setup() {
9+
10+
Serial.begin(115200);
11+
while (!Serial);
12+
13+
// check for the presence of the shield:
14+
if (WiFi.status() == WL_NO_SHIELD) {
15+
Serial.println("WiFi shield not present");
16+
// don't continue:
17+
while (true);
18+
}
19+
20+
WiFiStorageFile file = WiFiStorage.open("/storage/testfile");
21+
22+
if (file) {
23+
file.erase();
24+
}
25+
26+
String test = "Cantami o Diva del pelide Achille";
27+
file.write(test.c_str(), test.length());
28+
29+
if (file) {
30+
file.seek(0);
31+
while (file.available()) {
32+
uint8_t buf[128];
33+
int ret = file.read(buf, 128);
34+
Serial.write(buf, ret);
35+
}
36+
}
37+
}
38+
39+
void loop() {
40+
// put your main code here, to run repeatedly:
41+
42+
}

0 commit comments

Comments
 (0)