1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

Merge pull request #14016 from benpicco/luid_get_be

sys/luid: provide luid_get_lb(), fix documentation
This commit is contained in:
benpicco 2020-05-13 21:14:31 +02:00 committed by GitHub
commit 88e4c0ffef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 1 deletions

View File

@ -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
*

View File

@ -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);