Spayker / rn-miband-connector

React-Native based connector to MiBand 3
MIT License
23 stars 14 forks source link

Not able to connect and get steps and sleep hours with Mi Band 3 #2

Closed naitikpatel1990 closed 5 years ago

naitikpatel1990 commented 5 years ago

Screenshot_2019-10-09-08-14-58-592_com sbp

i took clone for this repo and install with basic react-native ( npm install ) and run in device and i got above screen shot and stuck on this screen ( Scanning process ) not getting steps or Sleep hours, as i can see it's not being connected with MI Band 3.

I am sure about,

i have Mi Fit install in my device and connected with Mi Band 3. Mi Fit Showing connected in notification section.

Can you please help me to resolve it and any specific steps i need to follow that might be missing?

Spayker commented 5 years ago

Hi,

Please remove Mifit from smartphone, make hard reset in miband and re-try. Leaving a demo video below:

https://www.youtube.com/watch?v=Jwz9kGWV8ZQ

More details: I have re-written java code to make solution work in independent way. However BLE scanning sometimes requires too much time. Sometimes it connects to miband at once. In such cases my workaround is to use debug console like it's shown in video.

I understand the issue must be resolved anyway and I have already started fixing it. Hope it will be ready soon.

naitikpatel1990 commented 5 years ago

As per video i tried with 2-3 device at least 5-6 times but didn't get succeed.

Spayker commented 5 years ago

What do you have in logs?

naitikpatel1990 commented 5 years ago

Screenshot 2019-10-09 at 6 56 37 PM here is the logs

Spayker commented 5 years ago

Looks like you have some issue with android Studio setup since you keep receiving: Access denied finding property “vendor.debug.egl.swapinterval”

Perhaps you need to check several related topics like one below: https://stackoverflow.com/questions/52855807/access-denied-finding-property-vendor-debug-egl-swapinterval-i-am-keep-getting

Ideally you must have following records:

I/Configuration: Configuration getConfigurationFromSysProp name= persist.sys.font_scale value=
    Configuration getConfigurationFromSysProp name= persist.sys.font_scale value=
D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=5
D/ViewRootImpl: loadSystemProperties PersistDebugEvent: false RoDebugEvent: false
D/BluetoothLeScanner: onScanResult() - ScanResult{mDevice=E7:4F:83:DE:98:D9, mScanRecord=ScanRecord [mAdvertiseFlags=6, mServiceUuids=[0000fee0-0000-1000-8000-00805f9b34fb], mManufacturerSpecificData={343=[0, -97, -124, 115, -4, 4, -34, 120, -85, 11, -121, -63, -83, -118, 59, -46, -18, 2, -25, 79, -125, -34, -104, -39]}, mServiceData={}, mTxPowerLevel=-2147483648, mDeviceName=Mi Band 3], mRssi=-43, mTimestampNanos=103558647250489}
D/TAG: Device found E7:4F:83:DE:98:D9 Mi Band 3
D/BluetoothGatt: connect() - device: E7:4F:83:DE:98:D9, auto: true
D/BluetoothGatt: registerApp()
    registerApp() - UUID=d3a1e50c-17b1-4b4a-969a-692aa1a75736
D/BluetoothGatt: onClientRegistered() - status=0 clientIf=5
D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=5 device=E7:4F:83:DE:98:D9
D/Info: Connected with device
    Discovering services
D/BluetoothGatt: discoverServices() - device: E7:4F:83:DE:98:D9
D/BluetoothGatt: onSearchComplete() = Device=E7:4F:83:DE:98:D9 Status=0
D/INFO: Enabling Auth Service notifications status...
D/BluetoothGatt: setCharacteristicNotification() - uuid: 00000009-0000-3512-2118-0009af100700 enable: true
D/INFO: Found NOTIFICATION BluetoothGattDescriptor: android.bluetooth.BluetoothGattDescriptor@16b4204a
D/INFO: onCharacteristicWrite uuid: 00000009-0000-3512-2118-0009af100700 value: [1, 0, -11, -46, 41, -121, 101, 10, 29, -126, 5, -85, -126, -66, -71, 56, 89, -49] status: 0
D/INFO: onCharacteristicChanged char uuid: 00000009-0000-3512-2118-0009af100700 value: [16, 1, 1]
D/INFO: onCharacteristicWrite uuid: 00000009-0000-3512-2118-0009af100700 value: [2, 0] status: 0
D/INFO: onCharacteristicChanged char uuid: 00000009-0000-3512-2118-0009af100700 value: [16, 2, 1, 69, 126, -114, -69, -81, -16, 104, -35, 121, 66, -94, -33, -93, 116, 60, -63]
D/INFO: onCharacteristicWrite uuid: 00000009-0000-3512-2118-0009af100700 value: [3, 0, -71, -114, -6, 24, -76, 44, -119, 78, -74, 44, -116, 52, 55, -79, -9, 63] status: 0
D/INFO: onCharacteristicChanged char uuid: 00000009-0000-3512-2118-0009af100700 value: [16, 3, 1]
D/INFO: Authentication has been passed successfully

PS: I am using Lenovo k920 for testing. It uses sdk 21

naitikpatel1990 commented 5 years ago

Its working! we need to add ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION permission in manifest for android api 23 and above. Let me know where can i buy you beer buddy. Thanks

Spayker commented 5 years ago

Great news!

I've already added missed permission rights. Closing the issue...

naitikpatel1990 commented 5 years ago

I able to connect but when i kill the app and re-open it will ask again to link with Miband. its possible to keep connected and get steps even after i kill the app.

Spayker commented 5 years ago

Right now - no. However it should be possible in theory. Basically I was thinking to investigate and make it possible in next solution's update.

naitikpatel1990 commented 5 years ago

Can you guide us to make changes in your lib to keep connected with mi band even after kill the app and re-open. for now we need to reset band and reconnect again when reopen app. we need to just avoid that. thanks for your help.

Spayker commented 5 years ago

Ok, firstly good news: you do not need to reset miBand each time. Video shows only a full scenario of miBand linking with your mobile solution. Next time miBand will act like previously except first begin operation...

not good news: I did not have time to finish auth scenario without device paring for last week. Going to handle it asap cause I need for my project. One more thing is that I am not sure about proper set of commands to pass auth case without preliminary paring. Wireshark sniffing must help me here.

naitikpatel1990 commented 5 years ago

every time when i reopen app its reconnect Miband and reset step and battery count from band. so i got 0 step count from Miband whenever i try to connect with app.

Spayker commented 5 years ago

I am aware of that. Like I said some time is needed to complete non-pairing auth scenario...

naitikpatel1990 commented 4 years ago

Hey, @Spayker ,

I took new update for your code base and try again.

For now i don't need to reset MI band to connect.

It's connect it self when application open. But still we have reset steps to 0 when reconnect to application with band. So do you have any suggestion for this ?

BTW, Great work. Much appreciated.

Spayker commented 4 years ago

Hi, @naitikpatel1990 ,

Zero drop happens since it tries to pair device each time, again and again. Unfortunately you can not set up step counter, only read its data. For now I can suggest only keeping of passed steps right in mobile app. Once you have next connection to miband it will start calculating steps from zero but your app remembers previous results and you can sum them to get updated results.

No doubts written above is a workaround. Ideally pairing must happen only one time and right your app has passed it further connections will happen to pass auth procedure and that's all.

PS: I am about to finish my research work with server side in few days. Finally I will return to this issue and see what can be done...

naitikpatel1990 commented 4 years ago

@Spayker

Please let us know once you fixed every time reconnect and reset issue.

Because suppose user done 10,000 Steps and not open my application single time. Then open application mi band steps are reset to 0 and from then i can get count as per your work around.

SO in work around case my user need to open my application in morning to get counter proper.

Let me know once you have fix those, that will be very helpful for me.

naitikpatel1990 commented 4 years ago

@Spayker

Are you able to get time and fix keep connect part?

naitikpatel1990 commented 4 years ago

@Spayker

Do you get some time to work on above ?