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
+
1
23
#include " utility/wifi_drv.h"
2
24
3
25
class WiFiStorageFile ;
@@ -11,21 +33,21 @@ class WiFiStorageClass
11
33
static WiFiStorageFile open (String filename);
12
34
13
35
static bool exists (const char *filename) {
14
- size_t len;
36
+ uint32_t len;
15
37
return (WiFiDrv::existsFile (filename, strlen (filename), &len) > 0 );
16
38
}
17
- static bool exists (const char *filename, size_t * len) {
39
+ static bool exists (const char *filename, uint32_t * len) {
18
40
return (WiFiDrv::existsFile (filename, strlen (filename), len) > 0 );
19
41
}
20
42
static bool remove (const char *filename) {
21
43
WiFiDrv::deleteFile (filename, strlen (filename));
22
44
return true ;
23
45
}
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) {
25
47
WiFiDrv::readFile (filename, strlen (filename), offset, buffer, buffer_len);
26
48
return true ;
27
49
}
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) {
29
51
WiFiDrv::writeFile (filename, strlen (filename), offset, buffer, buffer_len);
30
52
return true ;
31
53
}
@@ -37,10 +59,10 @@ class WiFiStorageClass
37
59
static bool remove (String filename) {
38
60
return remove (filename.c_str ());
39
61
}
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) {
41
63
return read (filename.c_str (), offset, buffer, buffer_len);
42
64
}
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) {
44
66
return write (filename.c_str (), offset, buffer, buffer_len);
45
67
}
46
68
static bool download (String url, String filename) {
@@ -55,6 +77,7 @@ class WiFiStorageFile
55
77
{
56
78
public:
57
79
constexpr WiFiStorageFile (const char * _filename) : filename(_filename) { }
80
+
58
81
operator bool () {
59
82
return WiFiStorage.exists (filename, &length);
60
83
}
@@ -96,7 +119,9 @@ class WiFiStorageFile
96
119
}
97
120
protected:
98
121
friend class WiFiStorageClass ;
99
- size_t offset = 0 ;
100
- size_t length = 0 ;
122
+ uint32_t offset = 0 ;
123
+ uint32_t length = 0 ;
101
124
const char * filename;
102
125
};
126
+
127
+ #endif
0 commit comments