From 7447a3875ea64b1fd45aaae850085b0cac5c8e50 Mon Sep 17 00:00:00 2001 From: xengineering Date: Fri, 21 Mar 2025 22:40:53 +0100 Subject: fw: network: Rename from mac The scope of the mac.{c,h} files was very small. Furthermore more network related logic needs a place. Thus making the name more general makes sense. --- fw/src/mac.c | 56 -------------------------------------------------------- 1 file changed, 56 deletions(-) delete mode 100644 fw/src/mac.c (limited to 'fw/src/mac.c') diff --git a/fw/src/mac.c b/fw/src/mac.c deleted file mode 100644 index e34fa0d..0000000 --- a/fw/src/mac.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at https://mozilla.org/MPL/2.0/. - */ - - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - - -LOG_MODULE_REGISTER(mac); - - -/* will be read from an EEPROM chip in the future */ -static const uint8_t mac_address[NET_ETH_ADDR_LEN] = {0x00, 0x00, 0x5e, 0x00, 0x53, 0x01}; - -int init_mac_address(void) -{ - LOG_DBG("Setting custom MAC address"); - - struct net_if *interface = net_if_get_default(); - - int ret = net_if_down(interface); - if (ret < 0) { - LOG_ERR("Failed to set interface down to set MAC address (%d)", ret); - return ret; - } - - struct ethernet_req_params params = {0}; - memcpy(params.mac_address.addr, mac_address, 6); - ret = net_mgmt(NET_REQUEST_ETHERNET_SET_MAC_ADDRESS, interface, ¶ms, sizeof(params)); - if (ret < 0) { - LOG_ERR("Failed to set MAC address (%d)", ret); - return ret; - } - - ret = net_if_up(interface); - if (ret < 0) { - LOG_ERR("Failed to set interface up after setting MAC address (%d)", ret); - return ret; - } - - LOG_INF("Successfully set MAC address"); - return 0; -} -SYS_INIT(init_mac_address, APPLICATION, 0); -- cgit v1.2.3-70-g09d2