Skip to content

Commit dd491d0

Browse files
SeppoTakalorlubos
authored andcommitted
net: fota_download: Always deliver sec_tag to downloader
Downloader library parses the protocol to detect if it needs to set a sec_tag for given URI, so set sec_tag always to allow HTTP to HTTPS fallback to work. Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
1 parent e304e18 commit dd491d0

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

subsys/net/lib/fota_download/src/util/fota_download_util.c

+3-16
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ struct fota_download_url_data {
4646
const char *file;
4747
/** File name length */
4848
size_t file_len;
49-
/** HTTPs or CoAPs */
50-
bool sec_tag_needed;
5149
};
5250

5351
static void start_fota_download(struct k_work *work);
@@ -146,13 +144,11 @@ static int fota_download_url_parse(const char *uri,
146144
parsed_uri->host_len = e - uri;
147145
parsed_uri->file = e + 1;
148146
parsed_uri->file_len = strlen(uri) - parsed_uri->host_len;
149-
parsed_uri->sec_tag_needed =
150-
strncmp(uri, "https://", 8) == 0 || strncmp(uri, "coaps://", 8) == 0;
151147

152148
return 0;
153149
}
154150

155-
static int download_url_parse(const char *uri, int sec_tag)
151+
static int download_url_parse(const char *uri)
156152
{
157153
int ret;
158154
struct fota_download_url_data parsed_uri;
@@ -172,16 +168,6 @@ static int download_url_parse(const char *uri, int sec_tag)
172168
return -ENOMEM;
173169
}
174170

175-
if (parsed_uri.sec_tag_needed) {
176-
if (sec_tag == -1) {
177-
LOG_ERR("FOTA SMP sec tag not configured");
178-
return -EINVAL;
179-
}
180-
fota_sec_tag = sec_tag;
181-
} else {
182-
fota_sec_tag = -1;
183-
}
184-
185171
strncpy(fota_host, parsed_uri.host, parsed_uri.host_len);
186172
fota_host[parsed_uri.host_len] = 0;
187173

@@ -238,14 +224,15 @@ int fota_download_util_download_start(const char *download_uri,
238224
return -EBUSY;
239225
}
240226

241-
ret = download_url_parse(download_uri, sec_tag);
227+
ret = download_url_parse(download_uri);
242228
if (ret) {
243229
return ret;
244230
}
245231

246232
LOG_INF("Download Path %s host %s", fota_path, fota_host);
247233

248234
active_dfu_type = dfu_target_type;
235+
fota_sec_tag = sec_tag;
249236

250237
/* Register Callback */
251238
ret = fota_download_util_client_init(

0 commit comments

Comments
 (0)