Esempio n. 1
0
        /// <summary>
        /// Connect Myo
        /// </summary>
        /// <param name="myo"></param>
        /// <returns></returns>
        private async Task ConnectDevice(MyoHw myo)
        {
            try
            {
                //Continue to Connect to other service once connect success to ControlService
                myo.DeviceConnectionUpdated += ContinueConnect;

                myo.m_ControlService.service = await GattDeviceService.FromIdAsync(myo.Device.Id);

                if (myo.m_ControlService.service != null)
                {
                    myo.m_ControlService.isInitialize = true;

                    //await ConfigureServiceForNotificationsAsync();
                }
                else
                {
                    throw new Exception("Access to the device is denied, because the application was not granted access, " +
                                        "or the device is currently in use by another application.");
                }
            }
            catch (Exception e)
            {
                throw new Exception("Connect fail" + myo.Device.Id + "\n" + e.Message);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Update Connect List
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="isConnect"></param>
 private void ConnectUpdate(MyoHw sender, bool isConnect)
 {
     if (isConnect)
     {
         connectedMyos.Add(sender);
     }
     else
     {
         connectedMyos.Remove(sender);
     }
 }
Esempio n. 3
0
        private async void ContinueConnect(MyoHw myo, bool isConnect)
        {
            devicesCollection = await DeviceInformation.FindAllAsync(
                GattDeviceService.GetDeviceSelectorFromUuid(MYO_EMG_UUID),
                new string[] { "System.Devices.ContainerId" });

            devicesCollection = await DeviceInformation.FindAllAsync(
                GattDeviceService.GetDeviceSelectorFromUuid(MYO_IMU_UUID),
                new string[] { "System.Devices.ContainerId" });

            devicesCollection = await DeviceInformation.FindAllAsync(
                GattDeviceService.GetDeviceSelectorFromUuid(MYO_BATTERY_UUID),
                new string[] { "System.Devices.ContainerId" });

            devicesCollection = await DeviceInformation.FindAllAsync(
                GattDeviceService.GetDeviceSelectorFromUuid(MYO_CLASSIFIER_UUID),
                new string[] { "System.Devices.ContainerId" });

            if (devicesCollection.Count > 0)
            {
            }
        }