static async Task <int> Main(string[] args) { Console.WriteLine("******** ESPTouch SmartConfig Demo/Utility ********"); if (args.Length != 3) { ShowUsage(); return(-1); } var wifiInterface = FindFirstWifiInterfaceOrDefault(); if (wifiInterface == null) { Console.WriteLine("Cannot find any available WiFi adapter."); return(-1); } Console.WriteLine("WiFi interface: {0}", wifiInterface.Name); var localAddress = GetIPv4AddressOrDefault(wifiInterface); if (localAddress == null) { Console.WriteLine("Cannot find IPv4 address for WiFi interface: {0}", wifiInterface.Name); return(-1); } Console.WriteLine("Local address: {0}", localAddress); var provider = new EspSmartConfigProvider(); var ctx = provider.CreateContext(); ctx.DeviceDiscoveredEvent += (s, e) => { Console.WriteLine("Found device: IP={0} MAC={1}", e.Device.IPAddress, e.Device.MacAddress); }; var scArgs = new SmartConfigArguments() { Ssid = args[0], Bssid = PhysicalAddress.Parse(args[1].ToUpperInvariant().Replace(':', '-')), Password = args[2], LocalAddress = localAddress }; // Do the SmartConfig job using (var job = new SmartConfigJob(TimeSpan.FromSeconds(20))) // Set the timeout to 20 seconds { job.Elapsed += Job_Elapsed; await job.ExecuteAsync(ctx, scArgs); } Console.WriteLine("SmartConfig finished."); return(0); }
private SmartConfigContext CreateContext() { var provider = new EspSmartConfigProvider(); return(provider.CreateContext()); }