ble icon indicating copy to clipboard operation
ble copied to clipboard

optimistic connect attempts?

Open bniehuser opened this issue 6 years ago • 3 comments
trafficstars

is it possible to attempt to connect to a peripheral by UUID without first scanning to see if it's in range? the app only needs to connect to a specific peripheral, which has already been identified by UUID (and mac address, service uuids, etc) -- i would like to be able to attempt connection on an interval without having to initiate a scan process each time to test its availability. When i try i get file:///app/tns_modules/nativescript-bluetooth/bluetooth.js:463:18: Error in Bluetooth.connect: TypeError: null is not an object (evaluating 'Bluetooth._state.peripheralArray.count'), presumably because there are no scan results to check against. I'm using the nativescript + angular (typescript) with the current release, 1.3.1 not even sure this is possible, but it was suggested to me as a way to auto-reconnect to a known device and avoid the overhead of 1-2 second device scans on an endless 5-10 second interval, and figured i'd check with the experts ;).

bniehuser avatar Apr 27 '19 01:04 bniehuser

@bniehuser should already be possible in the 2.0 beta. just use connect and your UUID in the params

farfromrefug avatar Apr 30 '19 12:04 farfromrefug

absolutely works, at least for iOS. just throw a connect attempt on app load at whatever device you want connected, and another in the disconnect handler. boom; auto-reconnect.

bniehuser avatar Apr 30 '19 22:04 bniehuser

@bniehuser so it works? could you send a log for the thrown error?

farfromrefug avatar May 01 '19 09:05 farfromrefug