Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sys/uniqueid: Fixed compilation dependencies of HWRNG and radio hardware #320

Merged
merged 1 commit into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions firmware/sys/uniqueid/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ menu "Subnet"
config MODE_STATIC
bool "STATIC"

if USEMODULE_AT86RF2XX || USEMODULE_AT86RF215 || USEMODULE_PERIPH_HWRNG
config MODE_RANDOM
bool "RANDOM"
endif

config MODE_MANUAL
bool "MANUAL"
Expand Down
6 changes: 4 additions & 2 deletions firmware/sys/uniqueid/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ USEMODULE += netdev_default
USEMODULE += gnrc_ipv6_default
USEMODULE += auto_init_gnrc_netif

ifneq (,$(filter m4a-24g m4a-mb,$(BOARD)))
ifneq (,$(filter at86rf2xx at86rf215,$(USEMODULE)))
USEMODULE += radio
else
USEMODULE += periph_hwrng
ifneq (,$(filter periph_hwrng,$(HAS_PERIPH_HWRNG)))
USEMODULE += periph_hwrng
endif
endif
2 changes: 1 addition & 1 deletion firmware/sys/uniqueid/uniqueid.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "net/gnrc.h"
#if MODULE_AT86RF2XX || MODULE_AT86RF215
#include "radio.h"
#else
#elif MODULE_PERIPH_HWRNG
#include "periph/hwrng.h"
#endif
void subnet_to_ipv6(ipv6_addr_t *addr) {
Expand Down
12 changes: 8 additions & 4 deletions tests/uniqueid/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,23 @@ void get_unique_from_mac(ipv6_addr_t *output) {
}

void test_get_ipv6Address(void) {
#if CONFIG_MODE_STATIC || CONFIG_MODE_MANUAL
ipv6_addr_t ipv6 = {
.u8 = {0},
};

subnet_to_ipv6(&ipv6);
#ifdef CONFIG_MODE_STATIC
ipv6_addr_t output = {
.u8 = {0},
};
printf("\n");
subnet_to_ipv6(&ipv6);
ipv6_addr_print(&ipv6);
printf("\n");
get_unique_from_mac(&output);
#if CONFIG_MODE_STATIC
TEST_ASSERT_EQUAL_INT(1, ipv6_addr_equal(&ipv6, &output));
#elif CONFIG_MODE_MANUAL
TEST_ASSERT_EQUAL_INT(1, !ipv6_addr_equal(&ipv6, &output));
#endif
#endif

#ifdef CONFIG_MODE_RANDOM
Expand All @@ -63,7 +68,6 @@ void test_get_ipv6Address(void) {
ipv6_addr_t output2 = {
.u8 = {0},
};

subnet_to_ipv6(&output1);
subnet_to_ipv6(&output2);
printf("\nFirst random IPv6\n");
Expand Down