Skip to content

Instantly share code, notes, and snippets.

View patridge's full-sized avatar

Adam Patridge patridge

View GitHub Profile
@patridge
patridge / NetworkHelpers.cs
Created October 31, 2022 22:08
Meadow: Network helper methods (NTP, WiFi discovery, requests, etc.)
public static class NetworkHelpers
{
public static async Task GetWebPageViaHttpClient(string uri)
{
Console.WriteLine($"Requesting {uri} - {DateTime.Now}");
using (var client = new HttpClient())
{
try
{
@patridge
patridge / IWiFiNetworkAdapterExtensions.cs
Last active April 24, 2024 01:45
Meadow wifi helper to allow awaiting the wifi connection
using System;
using System.Threading;
using System.Threading.Tasks;
using Meadow.Hardware;
namespace MeadowHelpers {
public static class IWiFiNetworkAdapterExtensions {
public static async Task<NetworkConnectionEventArgs> WaitForNetworkConnection(this IWiFiNetworkAdapter wifiAdapter, string? ssid = null, string? password = null, TimeSpan timeout = default(TimeSpan), CancellationToken cancellationToken = default(CancellationToken))
{
var tcs = new TaskCompletionSource<NetworkConnectionEventArgs>();