Skip to content

Commit 7be73b6

Browse files
committed
Use Zephyr UUID
Signed-off-by: Simone Orru <simone.orru@secomind.com>
1 parent 82cd3e8 commit 7be73b6

7 files changed

Lines changed: 33 additions & 167 deletions

File tree

e2e/prj.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,9 @@ CONFIG_THREAD_NAME=y
187187
# Enable File System and LittleFS
188188
CONFIG_FILE_SYSTEM=y
189189
CONFIG_FILE_SYSTEM_LITTLEFS=y
190+
191+
# Enable UUID
192+
CONFIG_UUID=y
193+
CONFIG_UUID_V4=y
194+
CONFIG_UUID_V5=y
195+
CONFIG_UUID_BASE64=y

lib/edgehog_device/device.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
#include "storage_usage.h"
2323
#include "system_info.h"
2424
#include "system_status.h"
25-
#include "uuid.h"
2625
#include "wifi_scan.h"
2726

2827
#include <stdlib.h>
2928

3029
#include <zephyr/kernel.h>
3130
#include <zephyr/sys/util.h>
31+
#include <zephyr/sys/uuid.h>
3232

3333
#include <astarte_device_sdk/device.h>
3434
#include <astarte_device_sdk/interface.h>
@@ -292,10 +292,16 @@ edgehog_result_t edgehog_device_new(
292292
}
293293

294294
// Step 5: Initialize the Edgehog device boot ID
295-
char boot_id[UUID_STR_LEN + 1] = { 0 };
296-
eres = uuid_generate_v4_string(boot_id);
297-
if (eres != EDGEHOG_RESULT_OK) {
298-
EDGEHOG_LOG_ERR("Unable to generate edgehog boot id");
295+
struct uuid boot_id = { 0 };
296+
char boot_id_str[UUID_STR_LEN] = { 0 };
297+
int res = uuid_generate_v4(&boot_id);
298+
if (res != 0) {
299+
EDGEHOG_LOG_ERR("Unable to generate Edgehog boot ID");
300+
goto failure;
301+
}
302+
res = uuid_to_string(&boot_id, boot_id_str);
303+
if (res != 0) {
304+
EDGEHOG_LOG_ERR("Unable to generate Edgehog boot ID");
299305
goto failure;
300306
}
301307

@@ -338,7 +344,7 @@ edgehog_result_t edgehog_device_new(
338344

339345
k_sem_init(&edgehog_device->sync_ota_ft_sem, 1, 1);
340346

341-
memcpy(edgehog_device->boot_id, boot_id, UUID_STR_LEN + 1);
347+
memcpy(edgehog_device->boot_id, boot_id_str, UUID_STR_LEN);
342348
*edgehog_handle = edgehog_device;
343349

344350
// Step 8: Initialize the WiFi scan driver

lib/edgehog_device/include/edgehog_private.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@
1616
#include "led.h"
1717
#include "ota.h"
1818
#include "telemetry_private.h"
19-
#include "uuid.h"
2019

2120
#ifdef CONFIG_WIFI
2221
#include "wifi_scan.h"
2322
#endif
2423

2524
#include <astarte_device_sdk/device.h>
2625

26+
#include <zephyr/sys/uuid.h>
27+
2728
/** @brief Possible states for the Edgehog device. */
2829
enum device_states
2930
{
@@ -65,7 +66,7 @@ struct edgehog_device
6566
/** @brief Original user data for the callbacks provided by the user, might be NULL. */
6667
void *user_cbk_user_data;
6768
/** @brief UUID representing the Boot Id. */
68-
char boot_id[UUID_STR_LEN + 1];
69+
char boot_id[UUID_STR_LEN];
6970
/** @brief OTA thread data used during the OTA Update operation. */
7071
ota_thread_t ota_thread;
7172
/** @brief LED thread data used during the LED blink. */

lib/edgehog_device/include/uuid.h

Lines changed: 0 additions & 47 deletions
This file was deleted.

lib/edgehog_device/uuid.c

Lines changed: 0 additions & 112 deletions
This file was deleted.

samples/edgehog_app/prj.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,9 @@ CONFIG_THREAD_NAME=y
174174
# Zephyr Kernel & Filesystem Additions
175175
CONFIG_EVENTS=y
176176
CONFIG_FILE_SYSTEM=y
177+
178+
# Enable UUID
179+
CONFIG_UUID=y
180+
CONFIG_UUID_V4=y
181+
CONFIG_UUID_V5=y
182+
CONFIG_UUID_BASE64=y

tests/lib/edgehog_device/integration/prj.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,9 @@ CONFIG_SETTINGS=y
156156

157157
# Activate Zbus
158158
CONFIG_ZBUS=y
159+
160+
# Enable UUID
161+
CONFIG_UUID=y
162+
CONFIG_UUID_V4=y
163+
CONFIG_UUID_V5=y
164+
CONFIG_UUID_BASE64=y

0 commit comments

Comments
 (0)