Anyone knows get connected bluetooth device uuid?

plugins

#1

Hi all.

Anyone use nativescript-bluetooth plugin?

I get one connected device ( in setting->bluetooth saying device connected).

In my app, i tried to get this connected device by running:

  bluetooth.startScanning({
    serviceUUIDs: [],
    seconds: 1 ,
    onDiscovered: (peripheral) => {
      console.log(peripheral.state);
    }
  }).then(() => {
    console.log("scanning complete");
  }, (err) => {
    console.log("error while scanning: " + err);
  });
    }

But only display disconnected device, such as, no matter how I changed seconds:

 result: {"type":"scanResult","UUID":"30:38:5A:74:B1:F8","name":null,"RSSI":-98,"state":"disconnected","advertisement":"Hv8GAAEJIALeQ3Bc9jQBMtXxtyza4mIDrf3KSrNYlwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=","manufacturerId":6,"manufacturerData":{}}
disconnected
---- Lollipop+ scanCallback result: {"type":"scanResult","UUID":"AC:23:3F:A0:3A:B8","name":null,"RSSI":-95,"state":"disconnected","advertisement":"AgEGAwPh/xAW4f+hCGS4OqA/I6xQTFVTAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="}

Any one knows how to get connected device via this plugin?

Thanks in advance


#2

Please read the plugin docs carefully. You are just scanning for device, not connecting to one. Try the connect method and pass in the UUID as in the example.


#3

@manojdcoder thanks for your reply.
I know scan is searching for all available devices. My question is if this plugin can find connected ones.
I had a connected scanner but I don’t know its uuid.