20
20
******************************************************************************/
21
21
22
22
#include < SFU.h>
23
+ #include < BlockDevice.h>
24
+ #include < MBRBlockDevice.h>
25
+ #include < FATFileSystem.h>
23
26
#include < WiFiC3.h>
24
27
#include < Arduino_DebugUtils.h>
25
28
#include " arduino_secrets.h"
@@ -38,6 +41,10 @@ static char const OTA_FILE_LOCATION[] = "http://downloads.arduino.cc/ota/OTAUsag
38
41
#error "Board not supported"
39
42
#endif
40
43
44
+ BlockDevice* block_device = BlockDevice::get_default_instance();
45
+ MBRBlockDevice mbr (block_device, 1 );
46
+ FATFileSystem fs (" ota" );
47
+
41
48
/* *****************************************************************************
42
49
* SETUP/LOOP
43
50
******************************************************************************/
@@ -68,9 +75,24 @@ void setup()
68
75
Serial.print (WiFi.SSID ());
69
76
Serial.println (" '" );
70
77
78
+ int err = -1 ;
79
+ /* Mount the filesystem. */
80
+ if (err = fs.mount (&mbr) != 0 )
81
+ {
82
+ DEBUG_ERROR (" %s: fs.mount() failed with %d" , __FUNCTION__, err);
83
+ return ;
84
+ }
85
+
71
86
SFU::begin ();
72
87
73
- SFU::download (OTA_FILE_LOCATION);
88
+ SFU::download (" /ota/UPDATE.BIN.OTA" , OTA_FILE_LOCATION);
89
+
90
+ /* Unmount the filesystem. */
91
+ if ((err = fs.unmount ()) != 0 )
92
+ {
93
+ DEBUG_ERROR (" %s: fs.unmount() failed with %d" , __FUNCTION__, err);
94
+ return ;
95
+ }
74
96
75
97
SFU::apply ();
76
98
}
0 commit comments