예제 #1
0
        static void Main(string[] args)
        {
            if (args.Any(arg => arg.IndexOf("help") > -1 || arg.IndexOf("-h") > -1))
            {
                usage();
            }
            else
            {
                var info = WifiInterface.GetInfo();
                scanargs(args, info);

                Console.WriteLine("EsptouchInfo:");
                Console.WriteLine($"    {info}");
                Console.WriteLine();

                if (info == null || info.IP == null || string.IsNullOrEmpty(info.SSID) || string.IsNullOrEmpty(info.BSSID) || info.Devices == 0)
                {
                    Console.WriteLine("Exception: Argument Incomplete!");
                    Console.WriteLine();
                    usage();
                }
                else
                {
                    try
                    {
                        Console.WriteLine($"ESPTOUCH VERSION: {EsptouchTask.ESPTOUCH_VERSION} \n");
                        /// broadcast = false  组播模式下, 必须跟esp8266 在一个 wifi 路由下 esp8266 才能收到
                        EsptouchTask eh = new EsptouchTask(info.SSID, info.BSSID, info.Password, info.Broadcast);

                        eh.Find += Eh_Find;

                        Console.Write("Search ");

                        var lst = eh.ExecuteForResults(info.Devices, info.IP);

                        Console.WriteLine("\n");

                        if (lst.Count == 0)
                        {
                            Console.WriteLine("No device response");
                        }
                        else
                        {
                            Console.WriteLine($"{lst.Count} devices were configured successfully");
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine($"Exception: {e.Message}");
                    }
                }
            }
        }
예제 #2
0
        public async Task <List <SmartConfigResult> > SetSmartConfigTask(string ssid, string bssid, string passphrase, bool isBroadcast, int mcucount)
        {
            mEsptouchTask = new EsptouchTask(ssid, bssid, passphrase, Application.Context);
            mEsptouchTask.SetPackageBroadcast(isBroadcast);
            var res = new List <SmartConfigResult>();
            await Task.Run(() => {
                var results = mEsptouchTask.ExecuteForResults(mcucount);
                for (int i = 0; i < results.Count; i++)
                {
                    var scr      = new SmartConfigResult();
                    scr.IsSus    = results[i].IsSuc;
                    scr.IsCancel = results[i].IsCancelled;
                    if (results[i].InetAddress != null)
                    {
                        scr.InetAddress = results[i].InetAddress.HostAddress;
                    }
                    res.Add(scr);
                }
                return(res);
            });

            return(res);
        }
 public void SetSmartConfigTask(string ssid, string bssid, string passphrase, bool isHidden, int timeoutMillis)
 {
     _task = new EsptouchTask(ssid, bssid, passphrase, isHidden, timeoutMillis, Application.Context);
 }
 public void SetSmartConfigTask(string ssid, string bssid, string passphrase)
 {
     _task = new EsptouchTask(ssid, bssid, passphrase, Application.Context);
 }