refactor network initialisation

pull/783/head
Ömer Şiar Baysal 1 week 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;
if (m_pConfig->GetNetworkEnabled () && (strcmp(m_pConfig->GetNetworkType(), "wlan") == 0))
if (m_pConfig->GetNetworkEnabled())
{
if (strcmp(m_pConfig->GetNetworkType(), "wlan") == 0)
{
LOGNOTE("Initializing WLAN");
NetDeviceType = NetDeviceTypeWLAN;
@ -2308,14 +2310,21 @@ bool CMiniDexed::InitNetwork()
LOGNOTE("WLAN initialized");
}
else
{
LOGERR("Failed to initialize WLAN, maybe firmware files are missing?");
return false;
}
else if (m_pConfig->GetNetworkEnabled () && (strcmp(m_pConfig->GetNetworkType(), "ethernet") == 0))
}
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)
{
@ -2336,11 +2345,11 @@ 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?");
@ -2348,4 +2357,6 @@ bool CMiniDexed::InitNetwork()
}
}
return m_pNet != nullptr;
}
}

Loading…
Cancel
Save