Skip to content

Commit

Permalink
Changed EUI seed to use task PID for native POSIX
Browse files Browse the repository at this point in the history
  • Loading branch information
SGilbert-bp committed Jun 17, 2024
1 parent b3382df commit a824eec
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/sdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
#include <thingset.h>
#include <thingset/sdk.h>

#ifdef CONFIG_BOARD_NATIVE_POSIX
#include <unistd.h>
#endif /* CONFIG_BOARD_NATIVE_POSIX */

LOG_MODULE_REGISTER(thingset_sdk, CONFIG_THINGSET_SDK_LOG_LEVEL);

/*
Expand Down Expand Up @@ -119,10 +123,10 @@ static void generate_device_eui()
#ifndef CONFIG_BOARD_NATIVE_POSIX
hwinfo_get_device_id(buf, sizeof(buf));
#else
/* hwinfo is not available in native_posix, so we use random data instead */
for (int i = 0; i < sizeof(buf); i++) {
buf[i] = sys_rand32_get() & 0xFF;
}
/* hwinfo is not available in native_posix, so we take task PID instead */
int pid = getpid();

snprintk(buf, sizeof(buf), "%X", pid);
#endif

crc = crc32_ieee(buf, 8);
Expand Down

0 comments on commit a824eec

Please sign in to comment.