Ejemplo n.º 1
0
 public CommDevice(CommDevice device)
 {
     name = device.name;
     address = device.address;
     for (int i = 0; i < device.args.Count; i++)
         args.Add(device.args[i]);
 }
Ejemplo n.º 2
0
        public bool Equals(CommDevice device)
        {
            if (!name.Equals(device.name))
                return false;

            if (!address.Equals(device.address))
                return false;

            if (args.Count != device.args.Count)
                return false;

            for (int i = 0; i < args.Count; i++)
            {
                if (!args[i].Equals(device.args[i]))
                    return false;
            }

            return true;
        }
Ejemplo n.º 3
0
        public override void StartSearch()
        {
            foundDevices.Clear();

            _searchTimeout = searchTimeout;
            OnStartSearch.Invoke();

            #if UNITY_ANDROID
            if (_android != null)
            {
                string[] devInfos = _android.Call<string[]>("GetBondedDevices");
                for (int i = 0; i < devInfos.Length; i++)
                {
                    string[] tokens = devInfos[i].Split(new char[] { ',' });
                    CommDevice foundDevice = new CommDevice();
                    foundDevice.name = tokens[0];
                    foundDevice.address = tokens[1];
                    foundDevices.Add(foundDevice);
                }
                if (devInfos.Length > 0)
                    OnFoundDevice.Invoke();

                _android.Call("StartSearch");
            }
            #endif
        }
Ejemplo n.º 4
0
        private void AndroidMessageFoundDevice(string message)
        {
            Debug.Log(message);

            string[] tokens = message.Split(new char[] { ',' });
            CommDevice foundDevice = new CommDevice();
            if (tokens[0].Length == 0)
                foundDevice.name = tokens[1];
            else
                foundDevice.name = tokens[0];
            foundDevice.address = tokens[1];

            for (int i = 0; i < foundDevices.Count; i++)
            {
                if (foundDevices[i].Equals(foundDevice))
                    return;
            }

            foundDevices.Add(foundDevice);
            OnFoundDevice.Invoke();
        }