There is a beautiful plugin https://github.com/EddyVerbruggen/nativescript-bluetooth-demo which is developed by EddyVerbruggen. However, it doesn't go very well with my Android Device. Here is the Android project link for creating/updating aar file in the project.
This app is built with the NativeScript CLI. Once you have the CLI installed, start by cloning the repo:
$ [email protected]:AshleyCao/nativescript-bluetoothspp.git
$ tns install
$ tns run android
-
Get all connected devices
GetPairDevice()
-
Find target device
findDevice()
-
Build Bluetooth connection
buildConnection()
-
Start reading data in
loopThread()
Recommend to put this in worker( yes, mutiple threads for Javascript) to reduce delay while waiting input If you are not sure about inputStream status, runcheckSocketStream()
-
Close inputSteam and then close bt connection
stopLoop()
andcloseConnection()
Please note Nativescript provide a well-rounded instruction for creating a plugin.
Also, Naticescript Plugin Seed is awesome as well.
However, if you are like me ( not have enough time), just simply clone this project and compress it .tgz file. Put it in app root folder and
in your package.json file, add "nativescript-portscanner": "file:nativescript-portscanner.tgz"