Skip to content

Commit

Permalink
Removed unneeded isConnected local variable.
Browse files Browse the repository at this point in the history
  • Loading branch information
CartBlanche committed Jun 5, 2024
1 parent 0557660 commit 137cd86
Showing 1 changed file with 3 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,29 @@ internal class NetworkController : INetworkController

public event EventHandler? NetworkStatusChanged;

private bool isConnected;

public NetworkController(F7MicroBase device)
{
wifi = device.NetworkAdapters.Primary<IWiFiNetworkAdapter>();

IsConnected = wifi.IsConnected;
wifi.NetworkConnected += OnNetworkConnected;
wifi.NetworkDisconnected += OnNetworkDisconnected;
}

private void OnNetworkDisconnected(INetworkAdapter sender, NetworkDisconnectionEventArgs args)
{
IsConnected = false;
// Handle logic when disconnected.
}

private void OnNetworkConnected(INetworkAdapter sender, NetworkConnectionEventArgs args)
{
IsConnected = true;
// Handle logic when connected.
}

private IWiFiNetworkAdapter? wifi;

public bool IsConnected
{
get => isConnected;
set
{
if (value == IsConnected) return;
isConnected = value;
NetworkStatusChanged?.Invoke(this, EventArgs.Empty);
}
get => wifi.IsConnected;
}

public async Task Connect()
Expand Down

0 comments on commit 137cd86

Please sign in to comment.