Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated Ethernet_Basics sample #47

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions Source/Meadow F7/Network/Ethernet_Basics/MeadowApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,37 @@ public override async Task Run()
}
else
{
// connected event test.
ethernet.NetworkConnected += EthernetAdapterNetworkConnected;
ethernet.NetworkConnected += EthernetAdapterConnected;
ethernet.NetworkDisconnected += EthernetAdapterDisconnected;

if (ethernet.IsConnected)
{
DisplayNetworkInformation();

while (true)
{
await GetWebPageViaHttpClient("https://postman-echo.com/get?foo1=bar1&foo2=bar2");
try
{
await GetWebPageViaHttpClient("https://postman-echo.com/get?foo1=bar1&foo2=bar2");
}
catch (Exception ex)
{
Resolver.Log.Error($"{ex.Message}");
await Task.Delay(3000);
}
}
}
}
}

void EthernetAdapterNetworkConnected(INetworkAdapter networkAdapter, NetworkConnectionEventArgs e)
private void EthernetAdapterDisconnected(INetworkAdapter sender, NetworkDisconnectionEventArgs args)
{
Resolver.Log.Info("Network cable disconnected");
}

private void EthernetAdapterConnected(INetworkAdapter networkAdapter, NetworkConnectionEventArgs e)
{
Resolver.Log.Info("Connection request completed");
Resolver.Log.Info("Network cable connected");
}

public void DisplayNetworkInformation()
Expand Down
14 changes: 0 additions & 14 deletions Source/Meadow F7/Network/Ethernet_Basics/meadow.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,6 @@ Device:
# (e.g., Core-Compute module with SD add-on)? Optional; default value is `false`.
# SdStorageSupported: true

# Control how the ESP coprocessor will start and operate.
Coprocessor:

# Should the ESP32 automatically attempt to connect to an access point at startup?
# If set to true, wifi.yaml credentials must be stored in the device.
# AutomaticallyStartNetwork: true

# Should the ESP32 automatically reconnect to the configured access point?
# AutomaticallyReconnect: true

# Maximum number of retry attempts for connections etc. before an error code is returned.
# MaximumRetryCount: 7

# Network configuration.
Network:

# Network Interface (Default value is WiFi with DHCP)
Expand Down
Loading