Ejemplo n.º 1
0
        public DISCOVERY_RESULT GetLastDiscoveryResult(out BluetoothAddress address, out UInt16 p_num_recs)
        {
            byte[]           bdaddr = WidcommUtils.FromBluetoothAddress(BluetoothAddress.None);
            DISCOVERY_RESULT ret    = NativeMethods.BtIf_GetLastDiscoveryResult(m_pBtIf, bdaddr, out p_num_recs);

            address = WidcommUtils.ToBluetoothAddress(bdaddr);
            return(ret);
        }
Ejemplo n.º 2
0
        internal void HandleDiscoveryComplete()
        {
            Utils.MiscUtils.Trace_WriteLine("HandleDiscoveryComplete");
            AsyncResult <ISdpDiscoveryRecordsBuffer, ServiceDiscoveryParams> sacAr = null;
            ISdpDiscoveryRecordsBuffer recBuf = null;
            Exception sacEx = null;

            try {
                lock (lockServiceDiscovery) {
                    Debug.Assert(m_arServiceDiscovery != null, "NOT m_arServiceDiscovery != null");
                    if (m_arServiceDiscovery == null)
                    {
                        return;
                    }                                             // Nothing we can do then!
                    sacAr = m_arServiceDiscovery;
                    m_arServiceDiscovery = null;
                    BluetoothAddress addr;
                    ushort           numRecords0;
                    DISCOVERY_RESULT result = m_btIf.GetLastDiscoveryResult(out addr, out numRecords0);
                    if (result != DISCOVERY_RESULT.SUCCESS)
                    {
                        sacEx = WidcommSocketExceptions.Create(result, "ServiceRecordsGetResult");
                        return;
                    }
                    if (!addr.Equals(sacAr.BeginParameters.address))
                    {
                        sacEx = new InvalidOperationException("Internal error -- different DiscoveryComplete address.");
                        return;
                    }
                    // Get the records
                    recBuf = m_btIf.ReadDiscoveryRecords(addr, MaxNumberSdpRecords,
                                                         sacAr.BeginParameters);
                }//lock
            } catch (Exception ex) {
                sacEx = ex;
            } finally {
                Debug.Assert(sacAr != null, "out: NOT sacAr != null");
                Debug.Assert(m_arServiceDiscovery == null, "out: NOT m_arServiceDiscovery == null");
                WaitCallback dlgt = delegate {
                    RaiseDiscoveryComplete(sacAr, recBuf, sacEx);
                };
                ThreadPool.QueueUserWorkItem(dlgt);
            }
        }
Ejemplo n.º 3
0
 internal static SocketException Create(DISCOVERY_RESULT result, string location)
 {
     return(new DISCOVERY_RESULT_WidcommSocketException(CommonSocketExceptions.SocketError_StartDiscovery_Failed, result, location));
 }