WinJS and Bluetooth Connection Error RRS feed

  • Question

  • I am trying to write a cordova plugin, using WinJS, that will connect to a custom bluetooth service using RFComm.  I am able to get a list of paired devices but when I try to connect I get an "WinRTError: Element not found." Error

    My code to connect is:

    //RFComm defined as
    var RFComm = Windows.Devices.Bluetooth.Rfcomm;
    var devId = deviceId.toString()
    console.log('Getting device: ' + devId)
    RFComm.RfcommDeviceService.fromIdAsync(devId).done(function (service) {	
         console.log('in function handler')        
         if (service === null) {		
              errorCallback('Service is null')		
    //connection code here

    Output is:

    Getting device: Bluetooth#Bluetoothe8:2a:ea:89:a4:a3-5c:f3:70:66:43:3d
    console-via-logger.js (173,15)
    RFCOMM error getting device: WinRTError: Element not found.
    console-via-logger.js (173,15)

    Since the "in function handler" message is never outputted, the error is coming from the fromIdAsync() method.  

    I am running this on a Windows 10 tablet and have the proper capabilities defined (I have a C# app that works fine with the same capabilities that I am trying to convert to a hybrid app).

    Does anyone have any idea what the "WinRTError: Element not found" error is from the fromIdAsync() method?


    Wednesday, September 7, 2016 7:17 PM


  • I figured out my issue, it was a user error.  I was getting the list of devices from the DeviceWatcher rather than using the DeviceInformation.FindAllAsync() method. 
    • Marked as answer by Jon Hoffman123 Friday, September 9, 2016 4:09 PM
    Thursday, September 8, 2016 6:01 PM