Example #1
0
        //----
        public SDK_RETURN_CODE IsRemoteDevicePresent(byte[] bd_addr)
        {
            int             ret0 = NativeMethods.BtIf_IsRemoteDevicePresent(m_pBtIf, bd_addr);
            SDK_RETURN_CODE ret  = (SDK_RETURN_CODE)ret0;

            return(ret);
        }
Example #2
0
        public RemoteDeviceState FindIfPresentOrConnected(byte[] bda)
        {
            WidcommBtInterface iface = m_factory.GetWidcommBtInterface();
            int start;

            start = Environment.TickCount;
            Utils.MiscUtils.Trace_WriteLine("FiPoC: gonna IsRemoteDeviceConnected");
            bool connected = iface.IsRemoteDeviceConnected(bda);
            int  tc        = Environment.TickCount - start;

            //
            start = Environment.TickCount;
            //TO-DO If this chap is slow, when connected==true we could exit before calling it.
            //(...But it should be quick in that case!)
            Utils.MiscUtils.Trace_WriteLine("FiPoC: gonna IsRemoteDevicePresent");
            SDK_RETURN_CODE present0 = iface.IsRemoteDevicePresent(bda);
            bool            present  = (present0 == SDK_RETURN_CODE.Success);
            int             tp       = Environment.TickCount - start;

            //--
#if NETCF
#else
            Debug.Assert(present0 == SDK_RETURN_CODE.NotSupported);
            Debug.Assert(connected == false);
            const int ExpectedMilliseconds = 100;
            Debug.Assert(tp < ExpectedMilliseconds, "slow Is-Present: " + tp);
            Debug.Assert(tc < ExpectedMilliseconds, "slow Is-Connected: " + tc);
#endif
            //--
            RemoteDeviceState state;
            if (connected)
            {
                state = RemoteDeviceState.Connected;
#if NETCF
                Debug.Assert(present0 == SDK_RETURN_CODE.Success, "present0: " + present0);
#else
                // On BTW IsConnected was implemented before IsPresent.
                Debug.Assert(present0 == SDK_RETURN_CODE.NotSupported ||
                             present0 == SDK_RETURN_CODE.Success, "present0: " + present0);
#endif
            }
            else if (present0 == SDK_RETURN_CODE.NotSupported)
            {
                state = RemoteDeviceState.Unknown;
            }
            else if (present0 == SDK_RETURN_CODE.Success)
            {
                state = RemoteDeviceState.Present;
            }
            else
            {
                Debug.Assert(present0 == SDK_RETURN_CODE.Timeout, "present0: " + present0);
                state = RemoteDeviceState.NotPresent;
            }
            Utils.MiscUtils.Trace_WriteLine("FindIfPresentOrConnected: c={0} + p={1} => {2}",
                                            connected, present0, state);
            return(state);
        }