From f7ccd66c231690dda67db7d8b2f28609c6a6c8da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20=C5=9Eiar=20Baysal?= Date: Fri, 3 Jan 2025 12:10:48 +0100 Subject: [PATCH 1/6] do not wait network to be available --- src/config.cpp | 6 ++++++ src/config.h | 2 ++ src/minidexed.cpp | 46 +++++++++++++++++++++++----------------------- 3 files changed, 31 insertions(+), 23 deletions(-) diff --git a/src/config.cpp b/src/config.cpp index cc689f8..a680967 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -208,6 +208,7 @@ void CConfig::Load (void) m_INetworkIPAddress = m_Properties.GetIPAddress("NetworkIPAddress") != 0; m_INetworkSubnetMask = m_Properties.GetIPAddress("NetworkSubnetMask") != 0; m_INetworkDefaultGateway = m_Properties.GetIPAddress("NetworkDefaultGateway") != 0; + m_bSyslogEnabled = m_Properties.GetNumber ("SyslogEnabled", 0) != 0; m_INetworkDNSServer = m_Properties.GetIPAddress("NetworkDNSServer") != 0; const u8 *pSyslogServerIP = m_Properties.GetIPAddress ("NetworkSyslogServerIPAddress"); @@ -774,6 +775,11 @@ CIPAddress CConfig::GetNetworkDNSServer (void) const return m_INetworkDNSServer; } +bool CConfig::GetSyslogEnabled (void) const +{ + return m_bSyslogEnabled; +} + CIPAddress CConfig::GetNetworkSyslogServerIPAddress (void) const { return m_INetworkSyslogServerIPAddress; diff --git a/src/config.h b/src/config.h index 7af0bfc..a30fb7c 100644 --- a/src/config.h +++ b/src/config.h @@ -248,6 +248,7 @@ public: CIPAddress GetNetworkSubnetMask (void) const; CIPAddress GetNetworkDefaultGateway (void) const; CIPAddress GetNetworkDNSServer (void) const; + bool GetSyslogEnabled (void) const; CIPAddress GetNetworkSyslogServerIPAddress (void) const; private: @@ -373,6 +374,7 @@ private: CIPAddress m_INetworkSubnetMask; CIPAddress m_INetworkDefaultGateway; CIPAddress m_INetworkDNSServer; + bool m_bSyslogEnabled; CIPAddress m_INetworkSyslogServerIPAddress; }; diff --git a/src/minidexed.cpp b/src/minidexed.cpp index 57c9c86..135811b 100644 --- a/src/minidexed.cpp +++ b/src/minidexed.cpp @@ -2200,7 +2200,6 @@ void CMiniDexed::UpdateNetwork() //CNetSubSystem* const pNet = CNetSubSystem::Get(); if (!m_pNet) return; - //add wired network check as well //add wired network check as well bool bNetIsRunning = m_pNet->IsRunning(); @@ -2209,7 +2208,7 @@ void CMiniDexed::UpdateNetwork() else if (m_pNetDevice->GetType() == NetDeviceTypeWLAN) bNetIsRunning &= m_WPASupplicant.IsConnected(); - if (!m_bNetworkInit) + if (!m_bNetworkInit && bNetIsRunning) { m_bNetworkInit = true; CString IPString; @@ -2248,7 +2247,21 @@ void CMiniDexed::UpdateNetwork() { LOGPANIC ("Cannot publish mdns service"); } - + // syslog configuration + if (m_pConfig->GetSyslogEnabled()) + { + CIPAddress ServerIP = m_pConfig->GetNetworkSyslogServerIPAddress(); + if (ServerIP.IsSet () && !ServerIP.IsNull ()) + { + static const u16 usServerPort = 8514; // standard port is 514 + CString IPString; + ServerIP.Format (&IPString); + LOGNOTE ("Sending log messages to syslog server %s:%u", + (const char *) IPString, (unsigned) usServerPort); + + new CSysLogDaemon (m_pNet, ServerIP, usServerPort); + } + } m_bNetworkReady = true; } @@ -2290,12 +2303,10 @@ bool CMiniDexed::InitNetwork() if (m_pConfig->GetNetworkEnabled () && (strcmp(m_pConfig->GetNetworkType(), "wifi") == 0)) { LOGNOTE("Initializing WLAN"); - - if (m_WLAN.Initialize() && m_WPASupplicant.Initialize()) + NetDeviceType = NetDeviceTypeWLAN; + if (m_WLAN.Initialize()) { - LOGNOTE("wlan and wpasupplicant initialized"); - NetDeviceType = NetDeviceTypeWLAN; - + LOGNOTE("WLAN initialized"); } else LOGERR("Failed to initialize WLAN"); @@ -2319,29 +2330,18 @@ bool CMiniDexed::InitNetwork() m_pConfig->GetNetworkHostname(), NetDeviceType ); - - if (!m_pNet->Initialize()) + if (!m_pNet->Initialize(false)) { LOGERR("Failed to initialize network subsystem"); delete m_pNet; m_pNet = nullptr; } - m_pNetDevice = CNetDevice::GetNetDevice(NetDeviceType); - - // syslog configuration - CIPAddress ServerIP = m_pConfig->GetNetworkSyslogServerIPAddress(); - if (ServerIP.IsSet () && !ServerIP.IsNull ()) + // WPASupplicant needs to be started after netdevice available + if (m_pConfig->GetNetworkEnabled () && (strcmp(m_pConfig->GetNetworkType(), "wifi") == 0)) { - static const u16 usServerPort = 8514; // standard port is 514 - CString IPString; - ServerIP.Format (&IPString); - LOGNOTE ("Sending log messages to syslog server %s:%u", - (const char *) IPString, (unsigned) usServerPort); - - new CSysLogDaemon (m_pNet, ServerIP, usServerPort); + if (!m_WPASupplicant.Initialize()) LOGERR("Failed to initialize WPASupplicant"); } - } return m_pNet != nullptr; } From 166308435b8fea968f5d4913d35c6643ca52724b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20=C5=9Eiar=20Baysal?= Date: Fri, 3 Jan 2025 12:58:32 +0100 Subject: [PATCH 2/6] do not fail boot if wlan files are missing --- src/minidexed.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/minidexed.cpp b/src/minidexed.cpp index 135811b..9be84c6 100644 --- a/src/minidexed.cpp +++ b/src/minidexed.cpp @@ -359,7 +359,7 @@ bool CMiniDexed::Initialize (void) return false; } #endif - InitNetwork(); + InitNetwork(); // returns bool but we continue even if something goes wrong return true; } @@ -2200,8 +2200,7 @@ void CMiniDexed::UpdateNetwork() //CNetSubSystem* const pNet = CNetSubSystem::Get(); if (!m_pNet) return; - //add wired network check as well - //add wired network check as well + bool bNetIsRunning = m_pNet->IsRunning(); if (m_pNetDevice->GetType() == NetDeviceTypeEthernet) bNetIsRunning &= m_pNetDevice->IsLinkUp(); @@ -2309,7 +2308,8 @@ bool CMiniDexed::InitNetwork() LOGNOTE("WLAN initialized"); } else - LOGERR("Failed to initialize WLAN"); + LOGERR("Failed to initialize WLAN, maybe firmware files are missing?"); + return false; } else if (m_pConfig->GetNetworkEnabled () && (strcmp(m_pConfig->GetNetworkType(), "ethernet") == 0)) { @@ -2338,9 +2338,13 @@ bool CMiniDexed::InitNetwork() } m_pNetDevice = CNetDevice::GetNetDevice(NetDeviceType); // WPASupplicant needs to be started after netdevice available - if (m_pConfig->GetNetworkEnabled () && (strcmp(m_pConfig->GetNetworkType(), "wifi") == 0)) + if (NetDeviceType == NetDeviceTypeWLAN) { - if (!m_WPASupplicant.Initialize()) LOGERR("Failed to initialize WPASupplicant"); + if (!m_WPASupplicant.Initialize()) { + // It seems no way to catch if config is missing unless circle provides it + // or we catch the faults in config file ourselves + LOGERR("Failed to initialize WPASupplicant, maybe wifi config is missing?"); + } } } return m_pNet != nullptr; From 94fceb78a23a889b0d8a2119920c8a27d2db00f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20=C5=9Eiar=20Baysal?= Date: Mon, 27 Jan 2025 23:55:07 +0100 Subject: [PATCH 3/6] use WLAN word --- src/config.cpp | 2 +- src/minidexed.cpp | 4 ++-- src/minidexed.ini | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/config.cpp b/src/config.cpp index a680967..66142a4 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -203,7 +203,7 @@ void CConfig::Load (void) // Network m_bNetworkEnabled = m_Properties.GetNumber ("NetworkEnabled", 0) != 0; m_bNetworkDHCP = m_Properties.GetNumber ("NetworkDHCP", 0) != 0; - m_NetworkType = m_Properties.GetString ("NetworkType", "wifi"); + m_NetworkType = m_Properties.GetString ("NetworkType", "wlan"); m_NetworkHostname = m_Properties.GetString ("NetworkHostname", "MiniDexed"); m_INetworkIPAddress = m_Properties.GetIPAddress("NetworkIPAddress") != 0; m_INetworkSubnetMask = m_Properties.GetIPAddress("NetworkSubnetMask") != 0; diff --git a/src/minidexed.cpp b/src/minidexed.cpp index 9be84c6..3f55863 100644 --- a/src/minidexed.cpp +++ b/src/minidexed.cpp @@ -2299,7 +2299,7 @@ bool CMiniDexed::InitNetwork() TNetDeviceType NetDeviceType = NetDeviceTypeUnknown; - if (m_pConfig->GetNetworkEnabled () && (strcmp(m_pConfig->GetNetworkType(), "wifi") == 0)) + if (m_pConfig->GetNetworkEnabled () && (strcmp(m_pConfig->GetNetworkType(), "wlan") == 0)) { LOGNOTE("Initializing WLAN"); NetDeviceType = NetDeviceTypeWLAN; @@ -2343,7 +2343,7 @@ bool CMiniDexed::InitNetwork() if (!m_WPASupplicant.Initialize()) { // It seems no way to catch if config is missing unless circle provides it // or we catch the faults in config file ourselves - LOGERR("Failed to initialize WPASupplicant, maybe wifi config is missing?"); + LOGERR("Failed to initialize WPASupplicant, maybe wlan config is missing?"); } } } diff --git a/src/minidexed.ini b/src/minidexed.ini index cff0eae..d2233fe 100644 --- a/src/minidexed.ini +++ b/src/minidexed.ini @@ -151,8 +151,8 @@ ProfileEnabled=0 # Network NetworkEnabled=0 NetworkDHCP=1 -# NetworkType ( wifi ; ethernet ) -NetworkType=wifi +# NetworkType ( wlan ; ethernet ) +NetworkType=wlan NetworkHostname=MiniDexed NetworkIPAddress=0 NetworkSubnetMask=0 From 541d17a9f9741cdf09a7799c0aca898ab562de71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20=C5=9Eiar=20Baysal?= Date: Mon, 3 Feb 2025 13:07:49 +0100 Subject: [PATCH 4/6] refactor network initialisation --- src/minidexed.cpp | 49 +++++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/src/minidexed.cpp b/src/minidexed.cpp index 3f55863..1bfc988 100644 --- a/src/minidexed.cpp +++ b/src/minidexed.cpp @@ -2299,25 +2299,34 @@ bool CMiniDexed::InitNetwork() TNetDeviceType NetDeviceType = NetDeviceTypeUnknown; - if (m_pConfig->GetNetworkEnabled () && (strcmp(m_pConfig->GetNetworkType(), "wlan") == 0)) + if (m_pConfig->GetNetworkEnabled()) { - LOGNOTE("Initializing WLAN"); - NetDeviceType = NetDeviceTypeWLAN; - if (m_WLAN.Initialize()) + if (strcmp(m_pConfig->GetNetworkType(), "wlan") == 0) { - LOGNOTE("WLAN initialized"); + LOGNOTE("Initializing WLAN"); + NetDeviceType = NetDeviceTypeWLAN; + if (m_WLAN.Initialize()) + { + LOGNOTE("WLAN initialized"); + } + else + { + LOGERR("Failed to initialize WLAN, maybe firmware files are missing?"); + return false; + } } - else - LOGERR("Failed to initialize WLAN, maybe firmware files are missing?"); - return false; - } - else if (m_pConfig->GetNetworkEnabled () && (strcmp(m_pConfig->GetNetworkType(), "ethernet") == 0)) - { - LOGNOTE("Initializing Ethernet"); - NetDeviceType = NetDeviceTypeEthernet; - } - - if (NetDeviceType != NetDeviceTypeUnknown) + else if (strcmp(m_pConfig->GetNetworkType(), "ethernet") == 0) + { + LOGNOTE("Initializing Ethernet"); + NetDeviceType = NetDeviceTypeEthernet; + } + else + { + LOGERR("Network type is not set, please check your minidexed configuration file."); + NetDeviceType = NetDeviceTypeUnknown; + } + + if (NetDeviceType != NetDeviceTypeUnknown) { if (m_pConfig->GetNetworkDHCP()) m_pNet = new CNetSubSystem(0, 0, 0, 0, m_pConfig->GetNetworkHostname(), NetDeviceType); @@ -2336,16 +2345,18 @@ bool CMiniDexed::InitNetwork() delete m_pNet; m_pNet = nullptr; } - m_pNetDevice = CNetDevice::GetNetDevice(NetDeviceType); // WPASupplicant needs to be started after netdevice available if (NetDeviceType == NetDeviceTypeWLAN) { - if (!m_WPASupplicant.Initialize()) { + if (!m_WPASupplicant.Initialize()) + { // It seems no way to catch if config is missing unless circle provides it // or we catch the faults in config file ourselves LOGERR("Failed to initialize WPASupplicant, maybe wlan config is missing?"); } } } - return m_pNet != nullptr; + return m_pNet != nullptr; + } + } From 76a513b466b1db454be0a7d120c3f5df01ed3403 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20=C5=9Eiar=20Baysal?= Date: Mon, 3 Feb 2025 13:13:14 +0100 Subject: [PATCH 5/6] add missing netdevice pointer --- src/minidexed.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/minidexed.cpp b/src/minidexed.cpp index 1bfc988..8eb522a 100644 --- a/src/minidexed.cpp +++ b/src/minidexed.cpp @@ -2346,7 +2346,7 @@ bool CMiniDexed::InitNetwork() m_pNet = nullptr; } // WPASupplicant needs to be started after netdevice available - if (NetDeviceType == NetDeviceTypeWLAN) + if (NetDeviceType == NetDeviceTypeWLAN) { if (!m_WPASupplicant.Initialize()) { @@ -2355,6 +2355,7 @@ bool CMiniDexed::InitNetwork() LOGERR("Failed to initialize WPASupplicant, maybe wlan config is missing?"); } } + m_pNetDevice = CNetDevice::GetNetDevice(NetDeviceType); } return m_pNet != nullptr; } From 0764ee293d020fa55b420bd2bf1fec677d4c8f0c Mon Sep 17 00:00:00 2001 From: probonopd Date: Wed, 5 Feb 2025 20:37:07 +0100 Subject: [PATCH 6/6] uses: actions/upload-artifact@v4 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 36d42c9..f09908d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -98,7 +98,7 @@ jobs: cd - mkdir -p ./sdcard/hardware/ cp -r ./hwconfig/minidexed_* ./sdcard/minidexed.ini ./sdcard/hardware/ - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: ${{ env.artifactName }} # Exported above path: ./sdcard/*