Пример #1
0
        private void Central_PeripheralsChanged(object sender, PeripheralsEventArgs e)
        {
            foreach (var peripheral in e.Inserted)
            {
                try
                {
                    Debug.Log("Trying to connect peripheral");
                    Debug.Log("- ID: " + peripheral.Id);
                    Debug.Log("- Name: " + peripheral.Name);
                    peripheral.Start();

                    if (peripheral.Name == "CaptoGlove1502")
                    {
                        rPeripheral = peripheral as IBoardPeripheral;
                        rPeripheral.StreamTimeslotsWrite(new StreamTimeslots()
                        {
                            SensorsState = 6
                        });
                        rPeripheral.StreamReceived += Peripheral_StreamReceived;

                        Debug.Log(peripheral.Name + " - Status: " + rPeripheral.Status.ToString());
                    }
                    else if (peripheral.Name == "CaptoGlove1401")
                    {
                        lPeripheral = peripheral as IBoardPeripheral;
                        lPeripheral.StreamTimeslotsWrite(new StreamTimeslots()
                        {
                            SensorsState = 6
                        });
                        lPeripheral.StreamReceived += Peripheral_StreamReceived;

                        Debug.Log(peripheral.Name + " - Status: " + lPeripheral.Status.ToString());
                    }
                }
                catch
                {
                    Debug.Log(peripheral.Name + " - Status: " + peripheral.Status.ToString());
                }
            }
        }