This is a porting of EsptouchForIOS and EsptouchForAndroid
Please use NuGet to installa the library in your Xamarin.iOS, Xamarin.Droid or Xamarin.Forms project. This Library does not support Windows Phone yet.
Install-Package EspTouchSmartConfigXamarin
You need to use Dependency Service to get a Platform specific implementation of the SmartConfigTask
Define the Interface
public interface ISmartConfigHelper
{
ISmartConfigTask CreatePlatformTask();
}
using System;
using EspTouchBindingExample_Forms;
using EspTouchMultiPlatformLIbrary;
using Xamarin.Forms;
[assembly: Dependency(typeof(EspTouchBindingExample_Forms.iOS.SmartConfig_iOS))]
namespace EspTouchBindingExample_Forms.iOS
{
public class SmartConfig_iOS : ISmartConfigHelper
{
public SmartConfig_iOS()
{
}
public ISmartConfigTask CreatePlatformTask()
{
return new SmartConfigTask_iOS();
}
}
}
using System;
using EspTouchMultiPlatformLIbrary;
using Xamarin.Forms;
[assembly: Dependency(typeof(EspTouchBindingExample_Forms.Droid.SmartConfig_Droid))]
namespace EspTouchBindingExample_Forms.Droid
{
public class SmartConfig_Droid:ISmartConfigHelper
{
public SmartConfig_Droid()
{
}
public ISmartConfigTask CreatePlatformTask()
{
return new SmartConfigTask_Droid();
}
}
}
You can now instantiate the class in your code (code behind or viewmodel)
String Ssid = "network ssid";
String Bssid = "network bssid";
String Passphrase = "network passphrase"
ISmartConfigTask smartconfig;
smartconfig = DependencyService.Get<ISmartConfigHelper>().CreatePlatformTask();
smartconfig.SetSmartConfigTask(Ssid, Bssid, Passphrase);
await Task.Run(() =>
{
var result = smartconfig.executeForResult();
//handle your result
});
ESPTouchTask ett = new ESPTouchTask("<SSID>", "<BSSID>", "<PASSPHRASE>");
var result = ett.ExecuteForResult;
EsptouchTask mEsptouchTask = new EsptouchTask("<SSID>", "<BSSID>", "<PASSPHRASE>", true, Application.Context);
IEsptouchResult result = mEsptouchTask.ExecuteForResult();