13
13
#include " OTASTM32H7.h"
14
14
#include < STM32H747_System.h>
15
15
16
- const char STM32H7OTACloudProcess::UPDATE_FILE_NAME[] = " /fs/UPDATE.BIN" ;
17
-
18
16
STM32H7OTACloudProcess::STM32H7OTACloudProcess (MessageStream *ms, Client* client)
19
17
: OTADefaultCloudProcessInterface(ms, client)
20
18
, decompressed(nullptr )
21
19
, _bd_raw_qspi(nullptr )
22
20
, _program_length(0 )
23
21
, _bd(nullptr )
24
- , _fs(nullptr ) {
22
+ , _fs(nullptr )
23
+ , _filename(" /" + String(STM32H747OTA::FOLDER) + "/" + String(STM32H747OTA::NAME)) {
25
24
26
25
}
27
26
@@ -60,9 +59,9 @@ OTACloudProcessInterface::State STM32H7OTACloudProcess::startOTA() {
60
59
}
61
60
62
61
// this could be useless, since we are writing over it
63
- remove (UPDATE_FILE_NAME );
62
+ remove (_filename. c_str () );
64
63
65
- decompressed = fopen (UPDATE_FILE_NAME , " wb" );
64
+ decompressed = fopen (_filename. c_str () , " wb" );
66
65
67
66
// start the download if the setup for ota storage is successful
68
67
return OTADefaultCloudProcessInterface::startOTA ();
@@ -101,7 +100,7 @@ OTACloudProcessInterface::State STM32H7OTACloudProcess::reboot() {
101
100
void STM32H7OTACloudProcess::reset () {
102
101
OTADefaultCloudProcessInterface::reset ();
103
102
104
- remove (UPDATE_FILE_NAME );
103
+ remove (_filename. c_str () );
105
104
106
105
storageClean ();
107
106
}
@@ -152,7 +151,7 @@ bool STM32H7OTACloudProcess::storageInit() {
152
151
}
153
152
154
153
_bd = new mbed::MBRBlockDevice (_bd_raw_qspi, STM32H747OTA::PARTITION);
155
- _fs = new mbed::FATFileSystem (" fs " );
154
+ _fs = new mbed::FATFileSystem (STM32H747OTA::FOLDER );
156
155
err_mount = _fs->mount (_bd);
157
156
158
157
if (!err_mount) {
@@ -165,16 +164,17 @@ bool STM32H7OTACloudProcess::storageInit() {
165
164
bool STM32H7OTACloudProcess::findProgramLength (uint32_t & program_length) {
166
165
DIR * dir = NULL ;
167
166
struct dirent * entry = NULL ;
167
+ String dirName = " /" + String (STM32H747OTA::FOLDER);
168
168
bool found = false ;
169
169
170
- if ((dir = opendir (" /fs " )) == NULL ) {
170
+ if ((dir = opendir (dirName. c_str () )) == NULL ) {
171
171
return false ;
172
172
}
173
173
174
174
while ((entry = readdir (dir)) != NULL ) {
175
- if (strcmp (entry->d_name , " UPDATE.BIN " ) == 0 ) { // FIXME use constants
175
+ if (strcmp (entry->d_name , STM32H747OTA::NAME ) == 0 ) {
176
176
struct stat stat_buf;
177
- stat (" /fs/UPDATE.BIN " , &stat_buf);
177
+ stat (_filename. c_str () , &stat_buf);
178
178
program_length = stat_buf.st_size ;
179
179
found = true ;
180
180
}
0 commit comments