diff --git a/drivers/ieee802154/Kconfig b/drivers/ieee802154/Kconfig index b5356ec4392..2cdb1528bb7 100644 --- a/drivers/ieee802154/Kconfig +++ b/drivers/ieee802154/Kconfig @@ -39,6 +39,24 @@ config IEEE802154_RDEV help PHY is a ranging-capable device (RDEV) +config IEEE802154_VENDOR_OUI_ENABLE + bool "Enables setting Vendor Organizationally Unique Identifier" + help + This option enables setting custom vendor + OUI using IEEE802154_VENDOR_OUI. After enabling, + user is obliged to set IEEE802154_VENDOR_OUI value, + as this option has no default value. + +if IEEE802154_VENDOR_OUI_ENABLE + +config IEEE802154_VENDOR_OUI + int "Vendor Organizationally Unique Identifier" + help + Custom vendor OUI, which makes 24 most-significant + bits of MAC address + +endif # IEEE802154_VENDOR_OUI_ENABLE + source "drivers/ieee802154/Kconfig.cc2520" source "drivers/ieee802154/Kconfig.kw41z" diff --git a/drivers/ieee802154/ieee802154_nrf5.c b/drivers/ieee802154/ieee802154_nrf5.c index 127b64d9314..102dc5127bb 100644 --- a/drivers/ieee802154/ieee802154_nrf5.c +++ b/drivers/ieee802154/ieee802154_nrf5.c @@ -60,9 +60,26 @@ static struct nrf5_802154_data nrf5_data; #define NRF5_802154_CFG(dev) \ ((const struct nrf5_802154_config * const)(dev)->config_info) +#if CONFIG_IEEE802154_VENDOR_OUI_ENABLE +#define IEEE802154_NRF5_VENDOR_OUI CONFIG_IEEE802154_VENDOR_OUI +#else +#define IEEE802154_NRF5_VENDOR_OUI (uint32_t)0xF4CE36 +#endif + static void nrf5_get_eui64(uint8_t *mac) { - memcpy(mac, (const uint32_t *)&NRF_FICR->DEVICEID, 8); + uint64_t factoryAddress; + uint32_t index = 0; + + /* Set the MAC Address Block Larger (MA-L) formerly called OUI. */ + mac[index++] = (IEEE802154_NRF5_VENDOR_OUI >> 16) & 0xff; + mac[index++] = (IEEE802154_NRF5_VENDOR_OUI >> 8) & 0xff; + mac[index++] = IEEE802154_NRF5_VENDOR_OUI & 0xff; + + /* Use device identifier assigned during the production. */ + factoryAddress = (uint64_t)NRF_FICR->DEVICEID[0] << 32; + factoryAddress |= NRF_FICR->DEVICEID[1]; + memcpy(mac + index, &factoryAddress, sizeof(factoryAddress) - index); } static void nrf5_rx_thread(void *arg1, void *arg2, void *arg3)