zephyr/subsys/mgmt/hawkbit/hawkbit_device.c
Flavio Ceolin 11ea2766bc mgmt: hawkbit: Fix variable type
hwinfo_get_define_id returns and ssize_t with the size og the copied
id in case of success or negative value otherwise.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-03-26 07:13:13 -04:00

24 lines
475 B
C

/*
* Copyright (c) 2020 Linumiz
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "hawkbit_device.h"
#include <string.h>
bool hawkbit_get_device_identity(char *id, int id_max_len)
{
uint8_t hwinfo_id[DEVICE_ID_BIN_MAX_SIZE];
ssize_t length;
length = hwinfo_get_device_id(hwinfo_id, DEVICE_ID_BIN_MAX_SIZE);
if (length <= 0) {
return false;
}
memset(id, 0, id_max_len);
length = bin2hex(hwinfo_id, (size_t)length, id, id_max_len - 1);
return length > 0;
}