1 /*
2  * Copyright (c) 2020 Linumiz
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 #include <zephyr/storage/flash_map.h>
7 #include <zephyr/sys/printk.h>
8 
9 #include "hawkbit_firmware.h"
10 
hawkbit_get_firmware_version(char * version,int version_len)11 bool hawkbit_get_firmware_version(char *version, int version_len)
12 {
13 	struct mcuboot_img_header header;
14 
15 	if (boot_read_bank_header(FIXED_PARTITION_ID(slot0_partition), &header,
16 		sizeof(header)) != 0) {
17 		return false;
18 	}
19 
20 	if (header.mcuboot_version != 1) {
21 		return false;
22 	}
23 
24 	snprintk(version, version_len, "%d.%d.%d", header.h.v1.sem_ver.major,
25 		 header.h.v1.sem_ver.minor, header.h.v1.sem_ver.revision);
26 
27 	return true;
28 }
29