private static void setupTrackers()
        {
            foreach (var detectedDevice in _xda._DetectedDevices)
            {
                if (!detectedDevice.deviceId().isWirelessMaster())
                {
                    logger.Log($"Not wireless Master ... exiting for device {detectedDevice.deviceId().toInt().ToString()}");
                    break;
                }

                _xda.openPort(detectedDevice);
                var masterInfo = new MasterInfo(detectedDevice.deviceId());
                masterInfo.ComPort  = detectedDevice.portName();
                masterInfo.BaudRate = detectedDevice.baudrate();

                //TODO: Find out what the channel number represents and means
                _xda.getDevice(detectedDevice.deviceId()).enableRadio(11);
                logger.Log($"Radio enabled for device {detectedDevice.deviceId().toInt().ToString()}");
            }
        }
示例#2
0
    private void ScanForStations()
    {
        List <MasterInfo> _stations = new List <MasterInfo>();

        _xda.scanPorts();

        if (_xda._DetectedDevices.Count > 0)
        {
            foreach (XsPortInfo portInfo in _xda._DetectedDevices)
            {
                if (portInfo.deviceId().isWirelessMaster() || portInfo.deviceId().isAwindaStation())
                {
                    UnityEngine.Debug.Log("found wireless connector");
                    _xda.openPort(portInfo);
                    MasterInfo ai = new MasterInfo(portInfo.deviceId());
                    ai.ComPort  = portInfo.portName();
                    ai.BaudRate = portInfo.baudrate();
                    _stations.Add(ai);
                    break;
                }
            }

            if (_stations.Count > 0)
            {
                UnityEngine.Debug.Log("Found station: " + _stations[0].ToString() + " ... creating master device.");
                _masterDevice = _xda.getDevice(_stations[0].DeviceId);

                if (!_masterDevice.gotoConfig())
                {
                    throw new UnityException("could not enter configuration mode of created master device");
                }
                UnityEngine.Debug.Log("master device created successfully, ready to enable radio");
            }
            else
            {
                throw new UnityException("no station could be found, make sure drivers are installed correctly");
            }
        }
    }