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;
            }
Example #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);
        }
Example #3
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);
        }
            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;
                }
            }
Example #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);
        }
Example #9
0
 public override void Execute(BTConnection conn, BTDriver driver)
 {
     Success = driver.InquiryScan(Timeout);
 }
Example #10
0
 public override void Execute(BTConnection conn, BTDriver driver)
 {
     Success = driver.CheckDevicePresent();
 }
Example #11
0
            public override void Execute(BTConnection conn, BTDriver driver)
            {
                Devices = driver.Inquiry();

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

                conn.Connected = !this.Success;
            }
Example #17
0
            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);
 }
Example #19
0
            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);
Example #23
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;
        }
Example #24
0
            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;
                }
            }
Example #25
0
            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);
 }