Skip to content

Commit 338ee8c

Browse files
committed
RP2040 OTA: rename Error codes
1 parent ffbfd0d commit 338ee8c

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

Diff for: src/utility/ota/OTA-nano-rp2040.cpp

+21-21
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,17 @@
4444

4545
enum class rp2040OTAError : int
4646
{
47-
None = 0,
48-
ErrorFlashInit = RP2040_OTA_ERROR_BASE - 3,
49-
ErrorParseHttpHeader = RP2040_OTA_ERROR_BASE - 8,
50-
UrlParseError = RP2040_OTA_ERROR_BASE - 9,
51-
ServerConnectError = RP2040_OTA_ERROR_BASE - 10,
52-
HttpHeaderError = RP2040_OTA_ERROR_BASE - 11,
53-
HttpDataError = RP2040_OTA_ERROR_BASE - 12,
54-
ErrorOpenUpdateFile = RP2040_OTA_ERROR_BASE - 19,
55-
ErrorWriteUpdateFile = RP2040_OTA_ERROR_BASE - 20,
56-
ErrorReformat = RP2040_OTA_ERROR_BASE - 21,
57-
ErrorUnmount = RP2040_OTA_ERROR_BASE - 22,
47+
None = 0,
48+
OtaStorageInit = RP2040_OTA_ERROR_BASE - 3,
49+
ParseHttpHeader = RP2040_OTA_ERROR_BASE - 8,
50+
UrlParse = RP2040_OTA_ERROR_BASE - 9,
51+
ServerConnect = RP2040_OTA_ERROR_BASE - 10,
52+
HttpHeader = RP2040_OTA_ERROR_BASE - 11,
53+
HttpData = RP2040_OTA_ERROR_BASE - 12,
54+
OpenUpdateFile = RP2040_OTA_ERROR_BASE - 19,
55+
WriteUpdateFile = RP2040_OTA_ERROR_BASE - 20,
56+
Reformat = RP2040_OTA_ERROR_BASE - 21,
57+
Unmount = RP2040_OTA_ERROR_BASE - 22,
5858
};
5959

6060
/******************************************************************************
@@ -115,7 +115,7 @@ int rp2040_connect_onOTARequest(char const * ota_url)
115115
if ((err = flash.init()) < 0)
116116
{
117117
DEBUG_ERROR("%s: flash.init() failed with %d", __FUNCTION__, err);
118-
return static_cast<int>(rp2040OTAError::ErrorFlashInit);
118+
return static_cast<int>(rp2040OTAError::OtaStorageInit);
119119
}
120120

121121
watchdog_reset();
@@ -128,7 +128,7 @@ int rp2040_connect_onOTARequest(char const * ota_url)
128128
if ((err = fs.reformat(&flash)) != 0)
129129
{
130130
DEBUG_ERROR("%s: fs.reformat() failed with %d", __FUNCTION__, err);
131-
return static_cast<int>(rp2040OTAError::ErrorReformat);
131+
return static_cast<int>(rp2040OTAError::Reformat);
132132
}
133133

134134
watchdog_reset();
@@ -138,7 +138,7 @@ int rp2040_connect_onOTARequest(char const * ota_url)
138138
{
139139
DEBUG_ERROR("%s: fopen() failed", __FUNCTION__);
140140
fclose(file);
141-
return static_cast<int>(rp2040OTAError::ErrorOpenUpdateFile);
141+
return static_cast<int>(rp2040OTAError::OpenUpdateFile);
142142
}
143143

144144
watchdog_reset();
@@ -156,7 +156,7 @@ int rp2040_connect_onOTARequest(char const * ota_url)
156156
} else {
157157
DEBUG_ERROR("%s: Failed to parse OTA URL %s", __FUNCTION__, ota_url);
158158
fclose(file);
159-
return static_cast<int>(rp2040OTAError::UrlParseError);
159+
return static_cast<int>(rp2040OTAError::UrlParse);
160160
}
161161

162162
watchdog_reset();
@@ -165,7 +165,7 @@ int rp2040_connect_onOTARequest(char const * ota_url)
165165
{
166166
DEBUG_ERROR("%s: Connection failure with OTA storage server %s", __FUNCTION__, url.host_.c_str());
167167
fclose(file);
168-
return static_cast<int>(rp2040OTAError::ServerConnectError);
168+
return static_cast<int>(rp2040OTAError::ServerConnect);
169169
}
170170

171171
watchdog_reset();
@@ -202,7 +202,7 @@ int rp2040_connect_onOTARequest(char const * ota_url)
202202
{
203203
DEBUG_ERROR("%s: Error receiving HTTP header %s", __FUNCTION__, is_http_header_timeout ? "(timeout)":"");
204204
fclose(file);
205-
return static_cast<int>(rp2040OTAError::HttpHeaderError);
205+
return static_cast<int>(rp2040OTAError::HttpHeader);
206206
}
207207

208208
/* Extract concent length from HTTP header. A typical entry looks like
@@ -213,7 +213,7 @@ int rp2040_connect_onOTARequest(char const * ota_url)
213213
{
214214
DEBUG_ERROR("%s: Failure to extract content length from http header", __FUNCTION__);
215215
fclose(file);
216-
return static_cast<int>(rp2040OTAError::ErrorParseHttpHeader);
216+
return static_cast<int>(rp2040OTAError::ParseHttpHeader);
217217
}
218218
/* Find start of numerical value. */
219219
char * ptr = const_cast<char *>(content_length_ptr);
@@ -242,7 +242,7 @@ int rp2040_connect_onOTARequest(char const * ota_url)
242242
{
243243
DEBUG_ERROR("%s: Writing of firmware image to flash failed", __FUNCTION__);
244244
fclose(file);
245-
return static_cast<int>(rp2040OTAError::ErrorWriteUpdateFile);
245+
return static_cast<int>(rp2040OTAError::WriteUpdateFile);
246246
}
247247

248248
bytes_received++;
@@ -252,7 +252,7 @@ int rp2040_connect_onOTARequest(char const * ota_url)
252252
if (bytes_received != content_length_val) {
253253
DEBUG_ERROR("%s: Error receiving HTTP data %s (%d bytes received, %d expected)", __FUNCTION__, is_http_data_timeout ? "(timeout)":"", bytes_received, content_length_val);
254254
fclose(file);
255-
return static_cast<int>(rp2040OTAError::HttpDataError);
255+
return static_cast<int>(rp2040OTAError::HttpData);
256256
}
257257

258258
DEBUG_INFO("%s: %d bytes received", __FUNCTION__, ftell(file));
@@ -262,7 +262,7 @@ int rp2040_connect_onOTARequest(char const * ota_url)
262262
if ((err = fs.unmount()) != 0)
263263
{
264264
DEBUG_ERROR("%s: fs.unmount() failed with %d", __FUNCTION__, err);
265-
return static_cast<int>(rp2040OTAError::ErrorUnmount);
265+
return static_cast<int>(rp2040OTAError::Unmount);
266266
}
267267

268268
/* Perform the reset to reboot to SFU. */

0 commit comments

Comments
 (0)