nativescript-community / ble

Connect to and interact with Bluetooth LE peripherals.
https://nativescript-community.github.io/ble/
MIT License
194 stars 77 forks source link

Questions Regarding Connecting to Peripherals (Mine is MiSmartBand4) #164

Closed RahhalM closed 4 years ago

RahhalM commented 4 years ago

Hello, I am trying to connect to my Miband4,

the Miband4 has these Services: 1-1800: Generic Access 2-1801: Generic Attribute 3-180a: Device Information 4-00001530-0000-3512-2118-0009af100700 5-1811: Alert Notification Service 6-1802: Immediate Alert 7-180d: Heart Rate 8-fee0: 9-fee1:
10-3802:

The problem is that when I click on any Service and it Navigates to the Characteristics page and I can't read/write anything, here is an example from the 180d service (Heart Rate) Screenshot_20191205-200639

Is this normal? now I know that Miband4 is a server Based peripheral, and I'm not sure if this is the problem here is a direct explanation of Server-based pairing taken from gadgetbridge: "Server based pairing New devices and older devices with updated firmware require server based pairing. This means, that you absolutely must use MiFit app to make the initial pairing, retrieve the pairing key and then use this key to pair with Gadgetbridge. Currently, Mi Band 4, Amzfit Bip Lite and Amzfit GTR are known to be the first device with this enabled from the beggining."

And I have a problem with the call back function "doScanForHeartrateMontitor" there are these two variables : var heartrateService = '180d'; var omegaService = '12345678-9012-3456-7890-1234567890ee'; Shouldn't the omegaService hold the UUID of the desired service ? for example if I want to find all peripherals that support heart rate scanning, shouldn't var omegaService = '180d';? even if I put it that way I get :

JS: NativeScript-Bluetooth: INFO [app context com.tns.NativeScriptApplication@d6776dc] JS: NativeScript-Bluetooth: INFO [Bluetooth.coarseLocationPermissionGranted ---- ACCESS_COARSE_LOCATION permission granted?, true] JS: p undefined

And I was able to get the Authentication key of my Miband4, How can I implement it in this code and where should I ?

Any suggestions would be much-appreciated since I am working on a big project :)

Note: I am new to NativeScript and still learning

farfromrefug commented 4 years ago

please use stack for questions