aboutsummaryrefslogtreecommitdiffstats
path: root/arduino/libraries/FileSystem/examples/External_ReadWrite/External_ReadWrite.ino
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2019-02-28 17:04:22 -0500
committerClyne Sullivan <tullivan99@gmail.com>2019-02-28 17:04:22 -0500
commitd6869d1ec4bd24cd2c3eafa534f0849b25ec5607 (patch)
tree79e54ed27b39c31864895535d11399708d5a45c0 /arduino/libraries/FileSystem/examples/External_ReadWrite/External_ReadWrite.ino
parent614ee97bf3a2270c413527a7f35c54cbecd9e601 (diff)
added basic code
Diffstat (limited to 'arduino/libraries/FileSystem/examples/External_ReadWrite/External_ReadWrite.ino')
-rwxr-xr-xarduino/libraries/FileSystem/examples/External_ReadWrite/External_ReadWrite.ino79
1 files changed, 79 insertions, 0 deletions
diff --git a/arduino/libraries/FileSystem/examples/External_ReadWrite/External_ReadWrite.ino b/arduino/libraries/FileSystem/examples/External_ReadWrite/External_ReadWrite.ino
new file mode 100755
index 0000000..294d58d
--- /dev/null
+++ b/arduino/libraries/FileSystem/examples/External_ReadWrite/External_ReadWrite.ino
@@ -0,0 +1,79 @@
+/*********************************************************************
+ This is an example for our nRF52 based Bluefruit LE modules
+
+ Pick one up today in the adafruit shop!
+
+ Adafruit invests time and resources providing this open source code,
+ please support Adafruit and open-source hardware by purchasing
+ products from Adafruit!
+
+ MIT license, check LICENSE for more information
+ All text above, and the splash screen below must be included in
+ any redistribution
+*********************************************************************/
+
+#include <Bluefruit_FileIO.h>
+
+#define FILENAME "/adafruit.txt"
+
+#define CONTENTS "Bluefruit Feather52's file contents"
+
+File file (ExternalFS);
+
+// the setup function runs once when you press reset or power the board
+void setup()
+{
+ Serial.begin(115200);
+ while ( !Serial ) delay(10); // for nrf52840 with native usb
+
+ Serial.println("External Read Write File Example");
+ Serial.println();
+
+ // Wait for user input to run. Otherwise the code will
+ // always run immediately after flash and create the FILENAME in advance
+ Serial.print("Enter to any keys to continue:");
+ while ( !Serial.available() )
+ {
+ delay(1);
+ }
+ Serial.println();
+ Serial.println();
+
+ // Initialize Internal File System
+ ExternalFS.begin();
+
+ file.open(FILENAME, FILE_READ);
+
+ // file existed
+ if ( file )
+ {
+ Serial.println(FILENAME " file exists");
+
+ uint32_t readlen;
+ char buffer[64] = { 0 };
+ readlen = file.read(buffer, sizeof(buffer));
+
+ buffer[readlen] = 0;
+ Serial.println(buffer);
+ file.close();
+ }else
+ {
+ Serial.print("Open " FILENAME " file to write ... ");
+
+ if( file.open(FILENAME, FILE_WRITE) )
+ {
+ Serial.println("OK");
+ file.write(CONTENTS, strlen(CONTENTS));
+ file.close();
+ }else
+ {
+ Serial.println("Failed!");
+ }
+ }
+}
+
+// the loop function runs over and over again forever
+void loop()
+{
+ // nothing to do
+}