Example #1
0
        /// <summary>
        /// Prompts user to pick a paired bluetooth device using built-in UI
        /// </summary>
        /// <returns>MotionDevice user picked</returns>
        public MotionDevice PickDevice()
        {
            var deviceInfo   = btAgent.PickSingleDevice();
            var motionDevice = new MotionDevice(deviceInfo);

            return(motionDevice);
        }
Example #2
0
        /// <summary>
        /// Connect and initialize a MotionDevice
        /// </summary>
        /// <param name="device">The device to connect to, use ListDevices() to get the devices</param>
        /// <returns>Connection result</returns>
        public bool ConnectToDevice(MotionDevice device)
        {
            var connectionResult = btAgent.Connect(device.deviceInfo);

            if (!connectionResult)
            {
                return(false);
            }
            return(true);
        }
Example #3
0
        /// <summary>
        /// <para>Get a list of paired bluetooth device</para>
        /// Use the returned MotionDevice to be the parameter of ConnectToDevice
        /// </summary>
        /// <returns>A list of already paired device</returns>
        public List <MotionDevice> ListDevices()
        {
            var btDevices     = btAgent.GetDevices();
            var motionDevices = new List <MotionDevice>();

            foreach (var btDevice in btDevices)
            {
                var motionDevice = new MotionDevice(btDevice);
                motionDevices.Add(motionDevice);
            }
            return(motionDevices);
        }
Example #4
0
 /// <summary>
 /// Connect and initialize a MotionDevice
 /// </summary>
 /// <param name="device">The device to connect to, use ListDevices() to get the devices</param>
 /// <returns>Connection result</returns>
 public async Task <bool> BeginConnectToDevice(MotionDevice device)
 {
     return(await Task.Run(() => ConnectToDevice(device)));
 }