2018-04-23 22:50:01 +08:00
|
|
|
/*
|
2020-03-28 10:42:29 +08:00
|
|
|
* Copyright (c) 2018-2020 O.S.Systems
|
2018-04-23 22:50:01 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
#include "updatehub_device.h"
|
|
|
|
|
2020-05-16 10:34:58 +08:00
|
|
|
#include <string.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];
|
2018-04-23 22:50:01 +08:00
|
|
|
size_t length;
|
|
|
|
|
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);
|
2020-04-05 08:10:30 +08:00
|
|
|
length = bin2hex(hwinfo_id, length, id, id_max_len - 1);
|
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
|
|
|
}
|