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')
return
}
//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?
Thanks