Exemplo n.º 1
0
        static int RunCode(CodeOptions opts)
        {
            _logger.Info("Code Device");
            Commander.Device     = opts.Device;
            Commander.WorkingDir = opts.WorkingDir;
            Commander.IP         = opts.Client_Host;
            Commander.SetDgbMode("OUT");
            Commander.Flash(opts.InputFiles.ToArray(), opts.MFGString, opts.MassErase);

            while (true)
            {
                _logger.Info("\r\nRange Test Start");
                IRangeTester rangeTester = new EFR32xRT();
                rangeTester.Server_Host = opts.Server_Host;
                rangeTester.Server_Port = opts.Server_Port;
                rangeTester.Client_Host = opts.Client_Host;
                rangeTester.Client_Port = opts.Client_Port;
                rangeTester.Channel     = opts.Channel;

                rangeTester.Server_Init();
                Thread.Sleep(500);
                RtPingResults ping = rangeTester.Ping(Properties.Settings.Default.PingCount);

                string msg = "";
                msg += $"TxLqi:{ping.TxLqi} ({Properties.Settings.Default.TxLqi})\r\n";
                msg += $"TxSsi:{ping.TxRssi} ({Properties.Settings.Default.TxRssi})\r\n";
                msg += $"RxLqi:{ping.RxLqi} ({Properties.Settings.Default.RxLqi})\r\n";
                msg += $"RxRssi:{ping.RxRssi} ({Properties.Settings.Default.RxRssi})";

                if (ping.TxLqi >= Properties.Settings.Default.TxLqi && ping.TxRssi >= Properties.Settings.Default.TxRssi &&
                    ping.RxLqi >= Properties.Settings.Default.RxLqi && ping.RxRssi >= Properties.Settings.Default.RxRssi)
                {
                    _logger.Info($"Range Test Passed:\r\n{msg}");
                    break;
                }
                else
                {
                    _logger.Error($"Range Test Failed:\r\n{msg}");

                    if (Properties.Settings.Default.OfferRangeTestRetry)
                    {
                        Console.Write("(R)etry or (A)bort?");
                        ConsoleKeyInfo ki = Console.ReadKey();


                        if (ki.Key == ConsoleKey.A)
                        {
                            return(-1);
                        }
                    }
                    else
                    {
                        return(-1);
                    }
                }
            }

            _logger.Info("GetEUI");
            long eui = Commander.GetEUI();

            _logger.Info($"EUI = {eui.ToString("X16")}");

            _logger.Info("Insert EUI");
            int euiid = DatabaseUtils.InsertEUI(eui);

            _logger.Info($"EUI id = {euiid}");

            // Dummy insert needed for barscan
            int tdid = DatabaseUtils.AddTargetDevice(euiid);

            return(0);
        }
Exemplo n.º 2
0
        int Code()
        {
            setRunStatus("Code Device");

            Commander.Device = Properties.Settings.Default.Device;
            Commander.IP     = Properties.Settings.Default.DBA_ip;
            Commander.SetDgbMode("OUT");

            string[] files = new string[Properties.Settings.Default.Files.Count];
            Properties.Settings.Default.Files.CopyTo(files, 0);
            Commander.Flash(files, mfgStr_textBox.Text, false);

            while (true)
            {
                setRunStatus("Range Test Start");

                IRangeTester rangeTester = new EFR32xRT();
                rangeTester.Server_Host = Properties.Settings.Default.RTM_ip;
                rangeTester.Server_Port = Properties.Settings.Default.RTM_port;
                rangeTester.Client_Host = Properties.Settings.Default.DBA_ip;
                rangeTester.Client_Port = Properties.Settings.Default.RTC_port;
                rangeTester.Channel     = Properties.Settings.Default.Channel;

                rangeTester.Server_Init();
                Thread.Sleep(500);

                try
                {
                    RtPingResults ping = rangeTester.Ping(Properties.Settings.Default.PingCount);

                    string msg = "";
                    msg += $"TxLqi:{ping.TxLqi} ({Properties.Settings.Default.TxLqi})\r\n";
                    msg += $"TxRssi:{ping.TxRssi} ({Properties.Settings.Default.TxRssi})\r\n";
                    msg += $"RxLqi:{ping.RxLqi} ({Properties.Settings.Default.RxLqi})\r\n";
                    msg += $"RxRssi:{ping.RxRssi} ({Properties.Settings.Default.RxRssi})";

                    if (ping.TxLqi >= Properties.Settings.Default.TxLqi && ping.TxRssi >= Properties.Settings.Default.TxRssi &&
                        ping.RxLqi >= Properties.Settings.Default.RxLqi && ping.RxRssi >= Properties.Settings.Default.RxRssi)
                    {
                        setOutputStatus($"Range Test Passed:\r\n{msg}");
                        break;
                    }
                    else
                    {
                        setOutputStatus($"Range Test Failed:\r\n{msg}");
                        if (MessageBoxEx.Show(msg, "Range Test Failed", MessageBoxButtons.RetryCancel) == DialogResult.Cancel)
                        {
                            return(-1);
                        }
                    }
                }
                catch (Exception ex)
                {
                    setOutputStatus($"Range Test Failed:\r\n{ex.Message}\r\n{ex.StackTrace}");
                    if (MessageBoxEx.Show(ex.Message, "Range Test Failed", MessageBoxButtons.RetryCancel) == DialogResult.Cancel)
                    {
                        return(-1);
                    }
                }
            }

            setRunStatus("GetEUI");
            long eui = Commander.GetEUI();

            setRunStatus($"EUI = {eui.ToString("X16")}");

            setRunStatus("Insert EUI");
            int euiid = DatabaseUtils.InsertEUI(eui);

            setRunStatus($"EUI id = {euiid}");

            // Dummy insert needed for barscan
            int tdid = DatabaseUtils.AddTargetDevice(euiid);

            return(0);
        }