refactor network initialisation

pull/783/head
Ömer Şiar Baysal 2 weeks ago committed by GitHub
parent 94fceb78a2
commit 541d17a9f9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 19
      src/minidexed.cpp

@ -2299,7 +2299,9 @@ bool CMiniDexed::InitNetwork()
TNetDeviceType NetDeviceType = NetDeviceTypeUnknown; TNetDeviceType NetDeviceType = NetDeviceTypeUnknown;
if (m_pConfig->GetNetworkEnabled () && (strcmp(m_pConfig->GetNetworkType(), "wlan") == 0)) if (m_pConfig->GetNetworkEnabled())
{
if (strcmp(m_pConfig->GetNetworkType(), "wlan") == 0)
{ {
LOGNOTE("Initializing WLAN"); LOGNOTE("Initializing WLAN");
NetDeviceType = NetDeviceTypeWLAN; NetDeviceType = NetDeviceTypeWLAN;
@ -2308,14 +2310,21 @@ bool CMiniDexed::InitNetwork()
LOGNOTE("WLAN initialized"); LOGNOTE("WLAN initialized");
} }
else else
{
LOGERR("Failed to initialize WLAN, maybe firmware files are missing?"); LOGERR("Failed to initialize WLAN, maybe firmware files are missing?");
return false; return false;
} }
else if (m_pConfig->GetNetworkEnabled () && (strcmp(m_pConfig->GetNetworkType(), "ethernet") == 0)) }
else if (strcmp(m_pConfig->GetNetworkType(), "ethernet") == 0)
{ {
LOGNOTE("Initializing Ethernet"); LOGNOTE("Initializing Ethernet");
NetDeviceType = NetDeviceTypeEthernet; NetDeviceType = NetDeviceTypeEthernet;
} }
else
{
LOGERR("Network type is not set, please check your minidexed configuration file.");
NetDeviceType = NetDeviceTypeUnknown;
}
if (NetDeviceType != NetDeviceTypeUnknown) if (NetDeviceType != NetDeviceTypeUnknown)
{ {
@ -2336,11 +2345,11 @@ bool CMiniDexed::InitNetwork()
delete m_pNet; delete m_pNet;
m_pNet = nullptr; m_pNet = nullptr;
} }
m_pNetDevice = CNetDevice::GetNetDevice(NetDeviceType);
// WPASupplicant needs to be started after netdevice available // WPASupplicant needs to be started after netdevice available
if (NetDeviceType == NetDeviceTypeWLAN) 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 // It seems no way to catch if config is missing unless circle provides it
// or we catch the faults in config file ourselves // or we catch the faults in config file ourselves
LOGERR("Failed to initialize WPASupplicant, maybe wlan config is missing?"); LOGERR("Failed to initialize WPASupplicant, maybe wlan config is missing?");
@ -2349,3 +2358,5 @@ bool CMiniDexed::InitNetwork()
} }
return m_pNet != nullptr; return m_pNet != nullptr;
} }
}

Loading…
Cancel
Save