예제 #1
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);
        }