Esempio n. 1
0
        /// <summary>
        /// Initiate a service discovery on the device
        /// </summary>
        public void DiscoverServices()
        {
            Action action = () => _gatt.DiscoverServices();

            if (Configuration.DiscoverServicesOnMainThread)
            {
                var handler = new Handler(Looper.MainLooper);
                handler.PostAtFrontOfQueue(action);
            }
            else
            {
                action.Invoke();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Discconnect from a device.
        /// </summary>
        /// <param name="device">The device.</param>
        public void DisconnectDevice(IDevice device)
        {
            if (_gatt == null)
                return;

            Action action = () => PerformDisconnect(device);

            if (Configuration.DisconnectOnMainThread)
            {
                var handler = new Handler(Looper.MainLooper);
                handler.PostAtFrontOfQueue(action);
            }
            else
            {
                action.Invoke();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Connect to a device.
        /// </summary>
        /// <param name="device">The device.</param>
        public void ConnectToDevice(IDevice device)
        {
            Action action = () => PerformConnectToDevice(device);

            if (Configuration.ConnectOnMainThread)
            {
                var handler = new Handler(Looper.MainLooper);
                handler.PostAtFrontOfQueue(action);
            }
            else
            {
                action.Invoke();
            }
        }