public override void Execute(BTConnection conn, BTDriver driver)
            {
                conn.Connected       = false;
                conn.IsMaster        = false;
                conn.ConnectedToAddr = null;

                if (null != this.Address)
                {
                    this.Success = driver.PageScanForAddress(this.Address, Timeout);
                }
                else
                {
                    this.Success = driver.InquiryAndPageScans(Timeout);

                    if (this.Success)
                    {
                        try
                        {
                            this.Address = driver.GetLastConnectedAddress();
                        }
                        catch
                        {
                            this.Address = null;
                        }
                    }
                }

                conn.Connected       = this.Success;
                conn.ConnectedToAddr = this.Address;
            }
Exemple #2
0
        private bool m_disposed;                      // Whether or not this manager has been disposed

        //--//

        /// <summary>
        /// Creates and initializes a new BTManager
        /// </summary>
        protected BTManager(BTDriver driver, IPowerPolicy pp)
        {
            m_driver = null;

            try
            {
                m_driver = driver;
                m_pp     = (null == pp) ? new DefaultPowerPolicy() : pp;

                m_outstandingConnections   = new ArrayList();
                m_connectionsToBeProcessed = new ArrayList();
                m_newCommand = new AutoResetEvent(false);

                m_scheduler = new Thread(new ThreadStart(AggregateAndDispatch));
                m_scheduler.Start();

                m_disposed = false;
            }
            catch
            {
                m_disposed = true;

                throw;
            }

            // Now apply policy for no pending commands
            m_pp.ApplyPolicy(m_driver, null, null);
        }
        private bool m_disposed;                     // Whether or not this manager has been disposed

        //--//

        /// <summary>
        /// Creates and initializes a new BTManager
        /// </summary>
        protected BTManager(BTDriver driver, IPowerPolicy pp)
        {
            m_driver = null;

            try
            {
                m_driver = driver;
                m_pp = (null == pp) ? new DefaultPowerPolicy() : pp;

                m_outstandingConnections = new ArrayList();
                m_connectionsToBeProcessed = new ArrayList();
                m_newCommand = new AutoResetEvent(false);

                m_scheduler = new Thread(new ThreadStart(AggregateAndDispatch));
                m_scheduler.Start();

                m_disposed = false;
            }
            catch
            {
                m_disposed = true;

                throw;
            }

            // Now apply policy for no pending commands
            m_pp.ApplyPolicy(m_driver, null, null);
        }
            public override void Execute(BTConnection conn, BTDriver driver)
            {
                Devices = driver.Inquiry();

                if (null != Devices)
                {
                    Success = true;
                }
            }
            public override void Execute(BTConnection conn, BTDriver driver)
            {
                NumReceived = driver.Receive(ref Data, Timeout);
                Success     = (0 <= NumReceived);

                // Check for disconnect
                if (!Success)
                {
                    conn.Connected = false;
                }
            }
            public override void Execute(BTConnection conn, BTDriver driver)
            {
                if (null != Data)
                {
                    NumSent = driver.Send(Data);
                    Success = (0 <= NumSent);

                    // Check for disconnect
                    if (!Success)
                    {
                        conn.Connected = false;
                    }
                }
            }
            public override void Execute(BTConnection conn, BTDriver driver)
            {
                conn.Connected       = false;
                conn.IsMaster        = true;
                conn.ConnectedToAddr = null;

                if (null != Address)
                {
                    Success = driver.PageAddress(Address, Timeout);

                    conn.Connected       = this.Success;
                    conn.IsMaster        = true;
                    conn.ConnectedToAddr = this.Address;
                }
            }
Exemple #8
0
        /// <summary>
        /// Creates a new instance of BTManager.  Locks the BTManager type so that only one
        /// manager can be created.
        /// </summary>
        /// <param name="driver">
        /// The BTDriver to be used to communicate with the underlying Bluetooth chip.
        /// </param>
        /// <param name="pp">
        /// The power policy to be used while managing connections.
        /// </param>
        /// <returns>
        /// The singleton instance of BTManager
        /// </returns>
        public static BTManager GetManager(BTDriver driver, IPowerPolicy pp)
        {
            if (null == s_manager)
            {
                lock (typeof(BTManager))
                {
                    if (null == s_manager)
                    {
                        s_manager = new BTManager(driver, pp);
                    }
                }
            }

            return(s_manager);
        }
 public override void Execute(BTConnection conn, BTDriver driver)
 {
     Success = driver.InquiryScan(Timeout);
 }
 public override void Execute(BTConnection conn, BTDriver driver)
 {
     Success = driver.CheckDevicePresent();
 }
            public override void Execute(BTConnection conn, BTDriver driver)
            {
                Devices = driver.Inquiry();

                if (null != Devices) Success = true;
            }
 public override void Execute(BTConnection conn, BTDriver driver)
 {
     Success = driver.SetPassKey(PassKey);
 }
 public abstract void Execute(BTConnection conn, BTDriver driver);
 public override void Execute(BTConnection conn, BTDriver driver)
 {
     Success = driver.SetPassKey(PassKey);
 }
 public override void Execute(BTConnection conn, BTDriver driver)
 {
     Success = driver.SetFriendlyDeviceName(Name);
 }
            public override void Execute(BTConnection conn, BTDriver driver)
            {
                this.Success = driver.Disconnect();

                conn.Connected = !this.Success;
            }
            public override void Execute(BTConnection conn, BTDriver driver)
            {
                NumReceived = driver.Receive(ref Data, Timeout);
                Success = (0 <= NumReceived);

                // Check for disconnect
                if (!Success) conn.Connected = false;
            }
 public override void Execute(BTConnection conn, BTDriver driver)
 {
     Success = driver.InquiryScan(Timeout);
 }
            public override void Execute(BTConnection conn, BTDriver driver)
            {
                conn.Connected = false;
                conn.IsMaster = true;
                conn.ConnectedToAddr = null;

                if (null != Address)
                {
                    Success = driver.PageAddress(Address, Timeout);

                    conn.Connected = this.Success;
                    conn.IsMaster = true;
                    conn.ConnectedToAddr = this.Address;
                }
            }
            public override void Execute(BTConnection conn, BTDriver driver)
            {
                this.Success = driver.Disconnect();

                conn.Connected = !this.Success;
            }
 public override void Execute(BTConnection conn, BTDriver driver)
 {
     Success = driver.CheckDevicePresent();
 }
 public abstract void Execute(BTConnection conn, BTDriver driver);
        /// <summary>
        /// Creates a new instance of BTManager.  Locks the BTManager type so that only one
        /// manager can be created.
        /// </summary>
        /// <param name="driver">
        /// The BTDriver to be used to communicate with the underlying Bluetooth chip.
        /// </param>
        /// <param name="pp">
        /// The power policy to be used while managing connections.
        /// </param>
        /// <returns>
        /// The singleton instance of BTManager
        /// </returns>
        public static BTManager GetManager(BTDriver driver, IPowerPolicy pp)
        {
            if (null == s_manager)
            {
                lock (typeof(BTManager))
                {
                    if (null == s_manager)
                    {
                        s_manager = new BTManager(driver, pp);
                    }
                }
            }

            return s_manager;
        }
            public override void Execute(BTConnection conn, BTDriver driver)
            {
                if (null != Data)
                {
                    NumSent = driver.Send(Data);
                    Success = (0 <= NumSent);

                    // Check for disconnect
                    if (!Success) conn.Connected = false;
                }
            }
            public override void Execute(BTConnection conn, BTDriver driver)
            {
                conn.Connected = false;
                conn.IsMaster = false;
                conn.ConnectedToAddr = null;

                if (null != this.Address)
                {
                    this.Success = driver.PageScanForAddress(this.Address, Timeout);
                }
                else
                {
                    this.Success = driver.InquiryAndPageScans(Timeout);

                    if (this.Success)
                    {
                        try
                        {
                            this.Address = driver.GetLastConnectedAddress();
                        }
                        catch
                        {
                            this.Address = null;
                        }
                    }
                }

                conn.Connected = this.Success;
                conn.ConnectedToAddr = this.Address;
            }
 public override void Execute(BTConnection conn, BTDriver driver)
 {
     Success = driver.SetFriendlyDeviceName(Name);
 }