diff options
Diffstat (limited to 'fw/src/network.c')
-rw-r--r-- | fw/src/network.c | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/fw/src/network.c b/fw/src/network.c deleted file mode 100644 index 6e6eb17..0000000 --- a/fw/src/network.c +++ /dev/null @@ -1,75 +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 <stdint.h> -#include <string.h> - -#include <zephyr/init.h> -#include <zephyr/logging/log.h> -#include <zephyr/net/hostname.h> -#include <zephyr/net/net_if.h> -#include <zephyr/net/net_linkaddr.h> -#include <zephyr/net/net_mgmt.h> -#include <zephyr/net/ethernet.h> -#include <zephyr/net/ethernet_mgmt.h> -#include <zephyr/sys/util.h> - - -LOG_MODULE_REGISTER(network); - - -#define HOSTNAME "iot-contact" - - -/* 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); - -int init_hostname(void) -{ - LOG_DBG("Setting hostname"); - - int ret = net_hostname_set(HOSTNAME, sizeof(HOSTNAME)); - if (ret < 0) { - LOG_ERR("Failed to set hostname to '%s' (%d)", HOSTNAME, ret); - return ret; - } - - LOG_INF("Successfully set hostname to '%s'", HOSTNAME); - return 0; -} -SYS_INIT(init_hostname, APPLICATION, 1); |