1+ /*
2+ WiFiStorage.h - Library for Arduino boards based on NINA wifi module.
3+ Copyright (c) 2018 Arduino SA. All rights reserved.
4+
5+ This library is free software; you can redistribute it and/or
6+ modify it under the terms of the GNU Lesser General Public
7+ License as published by the Free Software Foundation; either
8+ version 2.1 of the License, or (at your option) any later version.
9+
10+ This library is distributed in the hope that it will be useful,
11+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+ Lesser General Public License for more details.
14+
15+ You should have received a copy of the GNU Lesser General Public
16+ License along with this library; if not, write to the Free Software
17+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18+ */
19+
20+ #ifndef wifistorage_h
21+ #define wifistorage_h
22+
123#include " utility/wifi_drv.h"
224
325class WiFiStorageFile ;
@@ -11,21 +33,21 @@ class WiFiStorageClass
1133 static WiFiStorageFile open (String filename);
1234
1335 static bool exists (const char *filename) {
14- size_t len;
36+ uint32_t len;
1537 return (WiFiDrv::existsFile (filename, strlen (filename), &len) > 0 );
1638 }
17- static bool exists (const char *filename, size_t * len) {
39+ static bool exists (const char *filename, uint32_t * len) {
1840 return (WiFiDrv::existsFile (filename, strlen (filename), len) > 0 );
1941 }
2042 static bool remove (const char *filename) {
2143 WiFiDrv::deleteFile (filename, strlen (filename));
2244 return true ;
2345 }
24- static bool read (const char *filename, size_t offset, uint8_t * buffer, size_t buffer_len) {
46+ static bool read (const char *filename, uint32_t offset, uint8_t * buffer, uint32_t buffer_len) {
2547 WiFiDrv::readFile (filename, strlen (filename), offset, buffer, buffer_len);
2648 return true ;
2749 }
28- static bool write (const char *filename, size_t offset, uint8_t * buffer, size_t buffer_len) {
50+ static bool write (const char *filename, uint32_t offset, uint8_t * buffer, uint32_t buffer_len) {
2951 WiFiDrv::writeFile (filename, strlen (filename), offset, buffer, buffer_len);
3052 return true ;
3153 }
@@ -37,10 +59,10 @@ class WiFiStorageClass
3759 static bool remove (String filename) {
3860 return remove (filename.c_str ());
3961 }
40- static bool read (String filename, size_t offset, uint8_t * buffer, size_t buffer_len) {
62+ static bool read (String filename, uint32_t offset, uint8_t * buffer, uint32_t buffer_len) {
4163 return read (filename.c_str (), offset, buffer, buffer_len);
4264 }
43- static bool write (String filename, size_t offset, uint8_t * buffer, size_t buffer_len) {
65+ static bool write (String filename, uint32_t offset, uint8_t * buffer, uint32_t buffer_len) {
4466 return write (filename.c_str (), offset, buffer, buffer_len);
4567 }
4668 static bool download (String url, String filename) {
@@ -55,6 +77,7 @@ class WiFiStorageFile
5577{
5678public:
5779 constexpr WiFiStorageFile (const char * _filename) : filename(_filename) { }
80+
5881 operator bool () {
5982 return WiFiStorage.exists (filename, &length);
6083 }
@@ -96,7 +119,9 @@ class WiFiStorageFile
96119 }
97120protected:
98121 friend class WiFiStorageClass ;
99- size_t offset = 0 ;
100- size_t length = 0 ;
122+ uint32_t offset = 0 ;
123+ uint32_t length = 0 ;
101124 const char * filename;
102125};
126+
127+ #endif
0 commit comments