Skip to content

Commit 44c9987

Browse files
manchozaentinger
authored andcommitted
Add support for storage via U-201 filsystem
1 parent d589f5b commit 44c9987

File tree

2 files changed

+127
-0
lines changed

2 files changed

+127
-0
lines changed

src/utility/ota/OTAStorage_MKRGSM.cpp

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
This file is part of ArduinoIoTCloud.
3+
4+
Copyright 2020 ARDUINO SA (http://www.arduino.cc/)
5+
6+
This software is released under the GNU General Public License version 3,
7+
which covers the main part of arduino-cli.
8+
The terms of this license can be found at:
9+
https://www.gnu.org/licenses/gpl-3.0.en.html
10+
11+
You can be released from the requirements of the above licenses by purchasing
12+
a commercial license. Buying such a license is mandatory if you want to modify or
13+
otherwise use the software for commercial activities involving the Arduino
14+
software without disclosing the source code of your own applications. To purchase
15+
a commercial license, send an email to [email protected].
16+
*/
17+
18+
/******************************************************************************
19+
INCLUDE
20+
******************************************************************************/
21+
22+
#include "OTAStorage_MKRGSM.h"
23+
24+
#include <Arduino_DebugUtils.h>
25+
26+
/******************************************************************************
27+
CTOR/DTOR
28+
******************************************************************************/
29+
30+
OTAStorage_MKRGSM::OTAStorage_MKRGSM()
31+
{
32+
}
33+
34+
// GSMFileUtils _fileUtils;
35+
// String filename = "UPDATE.BIN";
36+
constexpr char * filename { "UPDATE.BIN" };
37+
/******************************************************************************
38+
PUBLIC MEMBER FUNCTIONS
39+
******************************************************************************/
40+
41+
bool OTAStorage_MKRGSM::init()
42+
{
43+
return _fileUtils.begin();
44+
}
45+
46+
bool OTAStorage_MKRGSM::open()
47+
{
48+
auto size = _fileUtils.listFile(filename);
49+
_fileUtils.deleteFile(filename);
50+
return true;
51+
}
52+
53+
size_t OTAStorage_MKRGSM::write(uint8_t const* const buf, size_t const num_bytes)
54+
{
55+
// Serial.print("size: ");
56+
// Serial.println(num_bytes);
57+
_fileUtils.appendFile(filename, (const char*)buf, num_bytes);
58+
59+
return num_bytes;
60+
}
61+
62+
void OTAStorage_MKRGSM::close()
63+
{
64+
}
65+
66+
void OTAStorage_MKRGSM::remove()
67+
{
68+
_fileUtils.deleteFile(filename);
69+
}
70+
71+
void OTAStorage_MKRGSM::deinit()
72+
{
73+
}

src/utility/ota/OTAStorage_MKRGSM.h

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
This file is part of ArduinoIoTCloud.
3+
4+
Copyright 2020 ARDUINO SA (http://www.arduino.cc/)
5+
6+
This software is released under the GNU General Public License version 3,
7+
which covers the main part of arduino-cli.
8+
The terms of this license can be found at:
9+
https://www.gnu.org/licenses/gpl-3.0.en.html
10+
11+
You can be released from the requirements of the above licenses by purchasing
12+
a commercial license. Buying such a license is mandatory if you want to modify or
13+
otherwise use the software for commercial activities involving the Arduino
14+
software without disclosing the source code of your own applications. To purchase
15+
a commercial license, send an email to [email protected].
16+
*/
17+
18+
#ifndef ARDUINO_OTA_STORAGE_MKRGSM_H_
19+
#define ARDUINO_OTA_STORAGE_MKRGSM_H_
20+
21+
/******************************************************************************
22+
* INCLUDE
23+
******************************************************************************/
24+
25+
#include "OTAStorage.h"
26+
27+
#include <GSMFileUtils.h>
28+
29+
/******************************************************************************
30+
* CLASS DECLARATION
31+
******************************************************************************/
32+
33+
class OTAStorage_MKRGSM : public OTAStorage
34+
{
35+
public:
36+
37+
OTAStorage_MKRGSM();
38+
virtual ~OTAStorage_MKRGSM() { }
39+
40+
41+
virtual Type type () override { return Type::MKRGSMFile; }
42+
virtual bool init () override;
43+
virtual bool open () override;
44+
virtual size_t write (uint8_t const * const buf, size_t const num_bytes) override;
45+
virtual void close () override;
46+
virtual void remove() override;
47+
virtual void deinit() override;
48+
49+
private:
50+
GSMFileUtils _fileUtils;
51+
52+
};
53+
54+
#endif /* ARDUINO_OTA_STORAGE_MKRGSM_H_ */

0 commit comments

Comments
 (0)