2016-09-02 21 views
0

メソッド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 
を作品

答えて

0

問題

あなたのセレクタシリアルポートの説明と一致するデバイス/サービスを探しているだけで、 SPP Devやシリアルポートのような名前を取得している理由です。

こんにちは、私はあなたが提案したセレクタを試してみました
// Any extra properties you need 
var requestedProperties = null 

// The magic happens here, "e0cbf06c-cd8b-4647-bb8a-263b43f0f974" is 
// the GUID for any Bluetooth device. 
var selector = "(System.Devices.Aep.ProtocolId:=\"{e0cbf06c-cd8b-4647-bb8a-263b43f0f974}\")" 

// Then run findAllAsync with these new filters 
deviceInfo.findAllAsync(selector, requestedProperties).then(function(devices) { 
    // Your code here 
} 
+0

、それが発見されたデバイスを返さない:

ソリューションは、Bluetoothデバイスは、以下のAQSクエリを使用見つけるために、Windows 10 sample for BluetoothRFcommChatから撮影します。セレクタを更新されたポストに入れました。 – Marek

関連する問題