2018-04-23 22:50:01 +08:00
|
|
|
/*
|
2023-01-02 18:55:42 +08:00
|
|
|
* Copyright (c) 2018-2023 O.S.Systems
|
2018-04-23 22:50:01 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
2020-05-16 10:34:58 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
2023-01-02 18:55:42 +08:00
|
|
|
#include <zephyr/drivers/hwinfo.h>
|
|
|
|
|
|
|
|
#include "updatehub_device.h"
|
|
|
|
|
2018-04-23 22:50:01 +08:00
|
|
|
bool updatehub_get_device_identity(char *id, int id_max_len)
|
|
|
|
{
|
2020-05-28 00:26:57 +08:00
|
|
|
uint8_t hwinfo_id[DEVICE_ID_BIN_MAX_SIZE];
|
2021-03-25 13:03:38 +08:00
|
|
|
ssize_t length;
|
2018-04-23 22:50:01 +08:00
|
|
|
|
2020-04-05 08:10:30 +08:00
|
|
|
length = hwinfo_get_device_id(hwinfo_id, DEVICE_ID_BIN_MAX_SIZE);
|
2018-04-23 22:50:01 +08:00
|
|
|
if (length <= 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(id, 0, id_max_len);
|
2022-05-16 16:13:49 +08:00
|
|
|
length = bin2hex(hwinfo_id, (size_t)length, id, id_max_len);
|
2018-04-23 22:50:01 +08:00
|
|
|
|
2020-04-05 08:10:30 +08:00
|
|
|
return length > 0;
|
2018-04-23 22:50:01 +08:00
|
|
|
}
|