From b073db4017008ceb638a9c23c8cc93e60a3a7fdb Mon Sep 17 00:00:00 2001 From: xengineering Date: Sun, 23 Mar 2025 17:53:24 +0100 Subject: fw: app: Move application firmware code here This makes the structure of the `fw` folder more clear and separates application-related code from bootloader- or rtos-related code. --- fw/src/network.c | 75 -------------------------------------------------------- 1 file changed, 75 deletions(-) delete mode 100644 fw/src/network.c (limited to 'fw/src/network.c') 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 -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -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); -- cgit v1.2.3-70-g09d2