メソッドWindows.Devices.Enumeration.DeviceInformation.findAllAsyncは、DeviceInformationのコレクションを返します。このオブジェクトは、デバイスBluetooth名として割り当てられたプロパティーnameを持っています。しかし代わりに、HM-12、SPP Dev、またはSerialPortのような値が含まれています。これはBluetoothプロトコルの名前です。DeviceInformation.nameは、名前の代わりにBluetoothバージョンを表示します。
以下はその例です。このコードは、モバイルのWindows 10 10.0.14393.67
のWindows 10のデスクトップ出力正しい結果に取り組んで適切に前のWindows(これが不明の原因版)アップグレード
を働いていたことに注意してください。
var rfcomm = Windows.Devices.Bluetooth.Rfcomm;
var sockets = Windows.Networking.Sockets;
var streams = Windows.Storage.Streams;
var deviceInfo = Windows.Devices.Enumeration.DeviceInformation;
var cordova = require('cordova');
module.exports = {
connService: null,
connSocket: null,
connWriter: null,
connReader: null,
connDevice: null,
list: function(successCallback, errorCallback) {
setTimeout(function() {
try {
var selector =
rfcomm.RfcommDeviceService.getDeviceSelector(
rfcomm.RfcommServiceId.serialPort);
var parsedDevices = [];
deviceInfo.findAllAsync(selector, null).then(function(devices) {
if (devices.length > 0) {
for (var i = 0; i < devices.length; i++) {
parsedDevices.push({
id: devices[i].id,
name: devices[i].name
})
successCallback(parsedDevices);
}
} else {
errorCallback("No devices found.");
}
}, function(error) {
errorCallback({
error: "list",
message: error.message
});
});
} catch (ex) {
errorCallback(ex);
}
}, 0);
}
}
セレクタの値(Windowsの10モバイル):セレクタの
System.Devices.DevObjectType:=10 AND System.Devices.AepService.ProtocolId:="{E0CBF06C-CD8B-4647-BB8A-263B43F0F974}" AND System.Devices.AepService.ServiceClassId:="{B142FC3E-FA4E-460B-8ABC-072B628B3C70}" AND System.Devices.AepService.Bluetooth.ServiceGuid:="{00001101-0000-1000-8000-00805F9B34FB}" AND System.Devices.AepService.ParentAepIsPaired:=System.StructuredQueryType.Boolean#True
値(Windowsの10 PC) - OK
System.Devices.InterfaceClassGuid:=\"{B142FC3E-FA4E-460B-8ABC-072B628B3C70}\" AND System.DeviceInterface.Bluetooth.ServiceGuid:=\"{00001101-0000-1000-8000-00805F9B34FB}\" AND System.Devices.InterfaceEnabled:=System.StructuredQueryType.Boolean#True
を作品
、それが発見されたデバイスを返さない:
ソリューションは、Bluetoothデバイスは、以下のAQSクエリを使用見つけるために、Windows 10 sample for BluetoothRFcommChatから撮影します。セレクタを更新されたポストに入れました。 – Marek