pull/783/merge
Ömer Şiar Baysal 2 months ago committed by GitHub
commit e79318d975
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      .github/workflows/build.yml
  2. 8
      src/config.cpp
  3. 2
      src/config.h
  4. 92
      src/minidexed.cpp
  5. 4
      src/minidexed.ini

@ -98,7 +98,7 @@ jobs:
cd - cd -
mkdir -p ./sdcard/hardware/ mkdir -p ./sdcard/hardware/
cp -r ./hwconfig/minidexed_* ./sdcard/minidexed.ini ./sdcard/hardware/ cp -r ./hwconfig/minidexed_* ./sdcard/minidexed.ini ./sdcard/hardware/
- uses: actions/upload-artifact@v3 - uses: actions/upload-artifact@v4
with: with:
name: ${{ env.artifactName }} # Exported above name: ${{ env.artifactName }} # Exported above
path: ./sdcard/* path: ./sdcard/*

@ -203,11 +203,12 @@ void CConfig::Load (void)
// Network // Network
m_bNetworkEnabled = m_Properties.GetNumber ("NetworkEnabled", 0) != 0; m_bNetworkEnabled = m_Properties.GetNumber ("NetworkEnabled", 0) != 0;
m_bNetworkDHCP = m_Properties.GetNumber ("NetworkDHCP", 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_NetworkHostname = m_Properties.GetString ("NetworkHostname", "MiniDexed");
m_INetworkIPAddress = m_Properties.GetIPAddress("NetworkIPAddress") != 0; m_INetworkIPAddress = m_Properties.GetIPAddress("NetworkIPAddress") != 0;
m_INetworkSubnetMask = m_Properties.GetIPAddress("NetworkSubnetMask") != 0; m_INetworkSubnetMask = m_Properties.GetIPAddress("NetworkSubnetMask") != 0;
m_INetworkDefaultGateway = m_Properties.GetIPAddress("NetworkDefaultGateway") != 0; m_INetworkDefaultGateway = m_Properties.GetIPAddress("NetworkDefaultGateway") != 0;
m_bSyslogEnabled = m_Properties.GetNumber ("SyslogEnabled", 0) != 0;
m_INetworkDNSServer = m_Properties.GetIPAddress("NetworkDNSServer") != 0; m_INetworkDNSServer = m_Properties.GetIPAddress("NetworkDNSServer") != 0;
const u8 *pSyslogServerIP = m_Properties.GetIPAddress ("NetworkSyslogServerIPAddress"); const u8 *pSyslogServerIP = m_Properties.GetIPAddress ("NetworkSyslogServerIPAddress");
@ -774,6 +775,11 @@ CIPAddress CConfig::GetNetworkDNSServer (void) const
return m_INetworkDNSServer; return m_INetworkDNSServer;
} }
bool CConfig::GetSyslogEnabled (void) const
{
return m_bSyslogEnabled;
}
CIPAddress CConfig::GetNetworkSyslogServerIPAddress (void) const CIPAddress CConfig::GetNetworkSyslogServerIPAddress (void) const
{ {
return m_INetworkSyslogServerIPAddress; return m_INetworkSyslogServerIPAddress;

@ -248,6 +248,7 @@ public:
CIPAddress GetNetworkSubnetMask (void) const; CIPAddress GetNetworkSubnetMask (void) const;
CIPAddress GetNetworkDefaultGateway (void) const; CIPAddress GetNetworkDefaultGateway (void) const;
CIPAddress GetNetworkDNSServer (void) const; CIPAddress GetNetworkDNSServer (void) const;
bool GetSyslogEnabled (void) const;
CIPAddress GetNetworkSyslogServerIPAddress (void) const; CIPAddress GetNetworkSyslogServerIPAddress (void) const;
private: private:
@ -373,6 +374,7 @@ private:
CIPAddress m_INetworkSubnetMask; CIPAddress m_INetworkSubnetMask;
CIPAddress m_INetworkDefaultGateway; CIPAddress m_INetworkDefaultGateway;
CIPAddress m_INetworkDNSServer; CIPAddress m_INetworkDNSServer;
bool m_bSyslogEnabled;
CIPAddress m_INetworkSyslogServerIPAddress; CIPAddress m_INetworkSyslogServerIPAddress;
}; };

@ -359,7 +359,7 @@ bool CMiniDexed::Initialize (void)
return false; return false;
} }
#endif #endif
InitNetwork(); InitNetwork(); // returns bool but we continue even if something goes wrong
return true; return true;
} }
@ -2201,15 +2201,13 @@ void CMiniDexed::UpdateNetwork()
if (!m_pNet) if (!m_pNet)
return; return;
//add wired network check as well
//add wired network check as well
bool bNetIsRunning = m_pNet->IsRunning(); bool bNetIsRunning = m_pNet->IsRunning();
if (m_pNetDevice->GetType() == NetDeviceTypeEthernet) if (m_pNetDevice->GetType() == NetDeviceTypeEthernet)
bNetIsRunning &= m_pNetDevice->IsLinkUp(); bNetIsRunning &= m_pNetDevice->IsLinkUp();
else if (m_pNetDevice->GetType() == NetDeviceTypeWLAN) else if (m_pNetDevice->GetType() == NetDeviceTypeWLAN)
bNetIsRunning &= m_WPASupplicant.IsConnected(); bNetIsRunning &= m_WPASupplicant.IsConnected();
if (!m_bNetworkInit) if (!m_bNetworkInit && bNetIsRunning)
{ {
m_bNetworkInit = true; m_bNetworkInit = true;
CString IPString; CString IPString;
@ -2248,7 +2246,21 @@ void CMiniDexed::UpdateNetwork()
{ {
LOGPANIC ("Cannot publish mdns service"); 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; m_bNetworkReady = true;
} }
@ -2287,26 +2299,34 @@ bool CMiniDexed::InitNetwork()
TNetDeviceType NetDeviceType = NetDeviceTypeUnknown; TNetDeviceType NetDeviceType = NetDeviceTypeUnknown;
if (m_pConfig->GetNetworkEnabled () && (strcmp(m_pConfig->GetNetworkType(), "wifi") == 0)) if (m_pConfig->GetNetworkEnabled())
{ {
LOGNOTE("Initializing WLAN"); if (strcmp(m_pConfig->GetNetworkType(), "wlan") == 0)
if (m_WLAN.Initialize() && m_WPASupplicant.Initialize())
{ {
LOGNOTE("wlan and wpasupplicant initialized"); LOGNOTE("Initializing WLAN");
NetDeviceType = NetDeviceTypeWLAN; NetDeviceType = NetDeviceTypeWLAN;
if (m_WLAN.Initialize())
{
LOGNOTE("WLAN initialized");
}
else
{
LOGERR("Failed to initialize WLAN, maybe firmware files are missing?");
return false;
}
} }
else else if (strcmp(m_pConfig->GetNetworkType(), "ethernet") == 0)
LOGERR("Failed to initialize WLAN"); {
} LOGNOTE("Initializing Ethernet");
else if (m_pConfig->GetNetworkEnabled () && (strcmp(m_pConfig->GetNetworkType(), "ethernet") == 0)) NetDeviceType = NetDeviceTypeEthernet;
{ }
LOGNOTE("Initializing Ethernet"); else
NetDeviceType = NetDeviceTypeEthernet; {
} LOGERR("Network type is not set, please check your minidexed configuration file.");
NetDeviceType = NetDeviceTypeUnknown;
if (NetDeviceType != NetDeviceTypeUnknown) }
if (NetDeviceType != NetDeviceTypeUnknown)
{ {
if (m_pConfig->GetNetworkDHCP()) if (m_pConfig->GetNetworkDHCP())
m_pNet = new CNetSubSystem(0, 0, 0, 0, m_pConfig->GetNetworkHostname(), NetDeviceType); m_pNet = new CNetSubSystem(0, 0, 0, 0, m_pConfig->GetNetworkHostname(), NetDeviceType);
@ -2319,29 +2339,25 @@ bool CMiniDexed::InitNetwork()
m_pConfig->GetNetworkHostname(), m_pConfig->GetNetworkHostname(),
NetDeviceType NetDeviceType
); );
if (!m_pNet->Initialize(false))
if (!m_pNet->Initialize())
{ {
LOGERR("Failed to initialize network subsystem"); LOGERR("Failed to initialize network subsystem");
delete m_pNet; delete m_pNet;
m_pNet = nullptr; m_pNet = nullptr;
} }
// WPASupplicant needs to be started after netdevice available
m_pNetDevice = CNetDevice::GetNetDevice(NetDeviceType); if (NetDeviceType == NetDeviceTypeWLAN)
// syslog configuration
CIPAddress ServerIP = m_pConfig->GetNetworkSyslogServerIPAddress();
if (ServerIP.IsSet () && !ServerIP.IsNull ())
{ {
static const u16 usServerPort = 8514; // standard port is 514 if (!m_WPASupplicant.Initialize())
CString IPString; {
ServerIP.Format (&IPString); // It seems no way to catch if config is missing unless circle provides it
LOGNOTE ("Sending log messages to syslog server %s:%u", // or we catch the faults in config file ourselves
(const char *) IPString, (unsigned) usServerPort); LOGERR("Failed to initialize WPASupplicant, maybe wlan config is missing?");
}
new CSysLogDaemon (m_pNet, ServerIP, usServerPort);
} }
m_pNetDevice = CNetDevice::GetNetDevice(NetDeviceType);
} }
return m_pNet != nullptr; return m_pNet != nullptr;
}
} }

@ -151,8 +151,8 @@ ProfileEnabled=0
# Network # Network
NetworkEnabled=0 NetworkEnabled=0
NetworkDHCP=1 NetworkDHCP=1
# NetworkType ( wifi ; ethernet ) # NetworkType ( wlan ; ethernet )
NetworkType=wifi NetworkType=wlan
NetworkHostname=MiniDexed NetworkHostname=MiniDexed
NetworkIPAddress=0 NetworkIPAddress=0
NetworkSubnetMask=0 NetworkSubnetMask=0

Loading…
Cancel
Save