Windows Store Bluetooth

痞子三分冷 提交于 2019-12-10 21:35:13

问题


I have been looking through the MSDN docs for Windows Store apps and the only thing I found that was close to Bluetooth was the Windows.Networking.Proximity. This appears to be a class whose use is only for close proximity ie within 3-4 centimeters. The app I am developing is on a HTML5/WinJS platform.

Is there a BluetoothSocket class like there is for android? For those store developers who are not familiar with Bluetooth on android essentially you create a Bluetooth Device member variable and populate that member with the device information, which is a native java call.

That will give you a list of paired devices, and you just open a Bluetooth socket to that device and then its the standard socket operations on a in/outstream for read/write.

Do I need to do the same thing and write a C++/CX version of this and add it as a Windows Component? The key thing here is that the device I'm connecting to treats the Bluetooth as a COM port, so all I need is a stable, reliable way to read/write to this device as if I were connected to a COM port.


回答1:


Per this MSDN Forum article, there isn't a generalized Bluetooth stack available for Windows Store applications.

As the thread indicates, there is only a Bluetooth Call Control sample and

If a device manufacturer needs to use Bluetooth as part of their device, they can provide a driver and metadata for a Store app to use it.

Information here:

 http://msdn.microsoft.com/en-us/library/windows/apps/hh464909.aspx



回答2:


Looks like @JimONeil's answer predates Windows 8.1 and was indeed correct for Windows 8, when the only way to have custom communication with BT device would be to create so called "Device App".

As of Windows 8.1 there is a simplified API which allows for easier (as OP describes "Android style") communication with BT devices.

Here's the quote from MSDN docs for "New Windows 8.1 APIs":

For Windows 8.1, Windows Store apps can use the new RFCOMM and GATT (Generic Attribute Profile) Windows Runtime APIs to access Bluetooth devices. These APIs provide access to the Bluetooth BR/EDR and Bluetooth LE transports.

There're also few good sample projects:

  • Heart Rate Device (C++/ C# and JavaScript)
  • Bluetooth Chat (C++/ C# and JavaScript)


来源:https://stackoverflow.com/questions/14360787/windows-store-bluetooth

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!