diff --git a/sys/include/luid.h b/sys/include/luid.h index b647958b44..b87ef0407f 100644 --- a/sys/include/luid.h +++ b/sys/include/luid.h @@ -74,7 +74,7 @@ extern "C" { * @brief Get a unique ID * * The resulting ID is built from the base ID generated with luid_base(), which - * isXORed with an 8-bit incrementing counter value into the most significant + * isXORed with an 8-bit incrementing counter value into the first (lowest index) * byte. * * @note The resulting LUID will repeat after 255 calls. @@ -85,6 +85,21 @@ extern "C" { */ void luid_get(void *buf, size_t len); +/** + * @brief Get a unique ID with change in the last byte + * + * The resulting ID is built from the base ID generated with luid_base(), which + * isXORed with an 8-bit incrementing counter value into the last (highest index) + * byte. + * + * @note The resulting LUID will repeat after 255 calls. + * + * @param[out] buf memory location to copy the LUID into. MUST be able to + * hold at least @p len bytes + * @param[in] len length of the LUID in bytes + */ +void luid_get_lb(void *buf, size_t len); + /** * @brief Get a unique short unicast address * diff --git a/sys/luid/luid.c b/sys/luid/luid.c index 544eeb1c3f..bdaff93ff4 100644 --- a/sys/luid/luid.c +++ b/sys/luid/luid.c @@ -54,6 +54,13 @@ void luid_get(void *buf, size_t len) ((uint8_t *)buf)[0] ^= lastused++; } +void luid_get_lb(void *buf, size_t len) +{ + luid_base(buf, len); + + ((uint8_t *)buf)[len - 1] ^= lastused++; +} + void luid_custom(void *buf, size_t len, int gen) { luid_base(buf, len);