Skip to content

Commit cdadeff

Browse files
committed
Cleaning up.
1 parent 48afe74 commit cdadeff

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

src/utility/ota/OTA-nano-rp2040.cpp

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,7 @@ int rp2040_connect_onOTARequest(char const * ota_url)
8282
{
8383
SFU::begin();
8484

85-
mbed_watchdog_reset();
86-
87-
#if 0
88-
/* Just to be safe delete any remains from previous updates. */
89-
struct stat st;
90-
int err = stat("/ota/UPDATE.BIN", &st);
91-
if (err == 0) {
92-
remove("/ota/UPDATE.BIN");
93-
}
94-
#endif
85+
mbed_watchdog_reset();
9586

9687
URI url(ota_url);
9788
Client * client = nullptr;
@@ -136,7 +127,6 @@ int rp2040_connect_onOTARequest(char const * ota_url)
136127

137128
/* Receive HTTP header. */
138129
String http_header;
139-
140130
for (bool is_header_complete = false; client->connected() && !is_header_complete; )
141131
{
142132
if (client->available())
@@ -168,6 +158,7 @@ int rp2040_connect_onOTARequest(char const * ota_url)
168158
else
169159
{
170160
DEBUG_ERROR("%s: Failure to extract content length from http header", __FUNCTION__);
161+
fclose(file);
171162
return static_cast<int>(OTAError::RP2040_ErrorParseHttpHeader);
172163
}
173164

@@ -183,19 +174,18 @@ int rp2040_connect_onOTARequest(char const * ota_url)
183174
if (fwrite(&c, 1, sizeof(c), file) != sizeof(c))
184175
{
185176
DEBUG_ERROR("%s: Writing of firmware image to flash failed", __FUNCTION__);
177+
fclose(file);
186178
return static_cast<int>(OTAError::RP2040_ErrorWriteUpdateFile);
187179
}
188180

189181
bytes_received++;
190182
}
191183
}
192184

185+
/* Determine length. */
193186
int const file_len = ftell(file);
194-
DEBUG_DEBUG("%s: %d bytes received", __FUNCTION__, file_len);
195-
196-
mbed_watchdog_reset();
197-
198187
fclose(file);
188+
DEBUG_DEBUG("%s: %d bytes received", __FUNCTION__, file_len);
199189

200190
/* Perform the reset to reboot to SxU. */
201191
NVIC_SystemReset();

0 commit comments

Comments
 (0)