1313#include " OTASTM32H7.h"
1414#include < STM32H747_System.h>
1515
16- const char STM32H7OTACloudProcess::UPDATE_FILE_NAME[] = " /fs/UPDATE.BIN" ;
17-
1816STM32H7OTACloudProcess::STM32H7OTACloudProcess (MessageStream *ms, Client* client)
1917: OTADefaultCloudProcessInterface(ms, client)
2018, decompressed(nullptr )
2119, _bd_raw_qspi(nullptr )
2220, _program_length(0 )
2321, _bd(nullptr )
24- , _fs(nullptr ) {
22+ , _fs(nullptr )
23+ , _filename(" /" + String(STM32H747OTA::FOLDER) + "/" + String(STM32H747OTA::NAME)) {
2524
2625}
2726
@@ -60,9 +59,9 @@ OTACloudProcessInterface::State STM32H7OTACloudProcess::startOTA() {
6059 }
6160
6261 // this could be useless, since we are writing over it
63- remove (UPDATE_FILE_NAME );
62+ remove (_filename. c_str () );
6463
65- decompressed = fopen (UPDATE_FILE_NAME , " wb" );
64+ decompressed = fopen (_filename. c_str () , " wb" );
6665
6766 // start the download if the setup for ota storage is successful
6867 return OTADefaultCloudProcessInterface::startOTA ();
@@ -101,7 +100,7 @@ OTACloudProcessInterface::State STM32H7OTACloudProcess::reboot() {
101100void STM32H7OTACloudProcess::reset () {
102101 OTADefaultCloudProcessInterface::reset ();
103102
104- remove (UPDATE_FILE_NAME );
103+ remove (_filename. c_str () );
105104
106105 storageClean ();
107106}
@@ -152,7 +151,7 @@ bool STM32H7OTACloudProcess::storageInit() {
152151 }
153152
154153 _bd = new mbed::MBRBlockDevice (_bd_raw_qspi, STM32H747OTA::PARTITION);
155- _fs = new mbed::FATFileSystem (" fs " );
154+ _fs = new mbed::FATFileSystem (STM32H747OTA::FOLDER );
156155 err_mount = _fs->mount (_bd);
157156
158157 if (!err_mount) {
@@ -165,16 +164,17 @@ bool STM32H7OTACloudProcess::storageInit() {
165164bool STM32H7OTACloudProcess::findProgramLength (uint32_t & program_length) {
166165 DIR * dir = NULL ;
167166 struct dirent * entry = NULL ;
167+ String dirName = " /" + String (STM32H747OTA::FOLDER);
168168 bool found = false ;
169169
170- if ((dir = opendir (" /fs " )) == NULL ) {
170+ if ((dir = opendir (dirName. c_str () )) == NULL ) {
171171 return false ;
172172 }
173173
174174 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 ) {
176176 struct stat stat_buf;
177- stat (" /fs/UPDATE.BIN " , &stat_buf);
177+ stat (_filename. c_str () , &stat_buf);
178178 program_length = stat_buf.st_size ;
179179 found = true ;
180180 }
0 commit comments