internal WidcommBluetoothRadio(WidcommBluetoothFactoryBase factory) { System.Threading.ThreadStart handleError = delegate { }; #if !NETCF // On my old iPAQ the radio info functions fail sometimes even though // the stack is working fine so we ignored the errors in the first // release. On Win32 this is a problem when the stack is installed // but no radio is attached, so fail in that case. handleError = delegate { throw new PlatformNotSupportedException( "Widcomm Bluetooth stack not supported (Radio)."); }; #endif // Debug.Assert(factory != null); _factory = factory; var tmp = BtIf; bool ret; ret = BtIf.GetLocalDeviceVersionInfo(ref m_dvi); Debug.Assert(ret, "GetLocalDeviceVersionInfo failed"); if (!ret) { handleError(); // Call handleError first so that one Win32 we don't get the Assert if there's no stack present. Debug.Assert(ret, "GetLocalDeviceVersionInfo failed"); m_dvi = new DEV_VER_INFO(HciVersion.Unknown); // Reset to overwrite any garbage returned by GetLocalDeviceVersionInfo. } byte[] bdName = new byte[WidcommStructs.BD_NAME_LEN]; ret = BtIf.GetLocalDeviceName(bdName); Debug.Assert(ret, "GetLocalDeviceName failed"); if (ret) { m_name = WidcommUtils.BdNameToString(bdName); } else { bdName = null; handleError(); } // // Did GetLocalDeviceVersionInfo get the address? It doesn't work on // my iPAQ, but then again this way doesn't work either! if (LocalAddress == null || LocalAddress.ToInt64() == 0) { Utils.MiscUtils.Trace_WriteLine("GetLocalDeviceVersionInfo's bd_addr is empty, trying GetLocalDeviceInfoBdAddr..."); if (m_dvi.bd_addr == null) { m_dvi.bd_addr = new byte[WidcommStructs.BD_ADDR_LEN]; } ret = BtIf.GetLocalDeviceInfoBdAddr(m_dvi.bd_addr); Debug.Assert(ret, "GetLocalDeviceInfoBdAddr failed"); if (!ret) { m_dvi.bd_addr = new byte[WidcommStructs.BD_ADDR_LEN]; handleError(); } } }
//---- protected override void BeginInquiry(int maxDevices, AsyncCallback callback, object state, BluetoothClient.LiveDiscoveryCallback liveDiscoHandler, object liveDiscoState, DiscoDevsParams args) { IAsyncResult ar = BtIf.BeginInquiry(maxDevices, InquiryLength, callback, state, liveDiscoHandler, liveDiscoState, args); }
protected override List_IBluetoothDeviceInfo GetKnownRemoteDeviceEntries() { List_IBluetoothDeviceInfo knownDevices; if (s_useRegistryForGetKnownRemoteDevice) { knownDevices = BtIf.ReadKnownDevicesFromRegistry(); } else { knownDevices = BtIf.GetKnownRemoteDeviceEntries(); } return(knownDevices); }
public void SetMode(bool?connectable, bool?discoverable) { bool conno, disco; if (connectable.HasValue && discoverable.HasValue) { // Will set both bits so do NOT need to know their current value. conno = disco = false; } else { // This returns true/true on Win32. BtIf.IsDeviceConnectableDiscoverable(out conno, out disco); } if (connectable.HasValue) { conno = connectable.Value; } if (discoverable.HasValue) { disco = discoverable.Value; } BtIf.SetDeviceConnectableDiscoverable(conno, AllowPairedOnly, disco); }
protected override List_IBluetoothDeviceInfo EndInquiry(IAsyncResult ar) { List_IBluetoothDeviceInfo discoverableDevices = BtIf.EndInquiry(ar); return(discoverableDevices); }