Hardware ID
The hardware ID library provides a simple interface to retrieve a unique hardware ID.
You can retrieve the hardware ID by calling the hw_id_get()
function.
The Hardware ID sample uses this library.
Configuration
To enable the library, set the CONFIG_HW_ID_LIBRARY
Kconfig option to y in the project configuration file prj.conf
.
You can configure one of the following Kconfig options to choose the hardware ID:
CONFIG_HW_ID_LIBRARY_SOURCE_IMEI
- This option specifies the International Mobile (Station) Equipment Identity (IMEI) of the modem.CONFIG_HW_ID_LIBRARY_SOURCE_UUID
- This option specifies the UUID of the modem.CONFIG_HW_ID_LIBRARY_SOURCE_BLE_MAC
- This option specifies the default Bluetooth® Low Energy MAC address.CONFIG_HW_ID_LIBRARY_SOURCE_NET_MAC
- This option specifies the MAC address of the default network interface.CONFIG_HW_ID_LIBRARY_SOURCE_DEVICE_ID
- This option specifies a serial number provided by Zephyr’s HW Info API.
API documentation
include/hw_id.h
lib/hw_id/
- group hw_id
Library that provides a unified interface for fetching a unique device ID from hardware.
Functions
-
int hw_id_get(char *buf, size_t buf_len)
Fetch unique device ID.
Note
The buffer should be at least HW_ID_LEN bytes long.
- Parameters
buf – [out] destination buffer
buf_len – [in] length of destination buffer
- Returns
0 If the operation was successful.
- Returns
-EINVAL If the passed in pointer is NULL or buffer is too small.
- Returns
-EIO If requesting platform ID failed.
-
int hw_id_get(char *buf, size_t buf_len)