satcar77 / miband4 Goto Github PK
View Code? Open in Web Editor NEWAccess Xiaomi MiBand 4 from Linux using Bluetooth LE
License: MIT License
Access Xiaomi MiBand 4 from Linux using Bluetooth LE
License: MIT License
I have problems with the mi band 6, can you add support for the mi band 6 please?
Thanks.
Hi,
I worked on debugging the setAlarm function in Gadgetbridge (see https://codeberg.org/Freeyourgadget/Gadgetbridge/pulls/1747 )
So I though it would be easy to port the function to Python now that I better understand the data.
I wrote this but it doesn't work :
def set_alarm(self, hour=11, minute=15):
print("set_alarm")
char = self.svc_1.getCharacteristics(UUIDS.CHARACTERISTIC_CONFIGURATION)[0]
alarm_id = 0
alarm_tag = 128+alarm_id #Create or update alarm
repetition_mask = 31 #All days
packet = struct.pack("5H",2,alarm_tag,hour,minute,repetition_mask)
print("packet", packet)
val = char.write(packet, True)
print("done")
return val
Any help or hint is welcome
On Fedora 34, with python 3.9, installing requirements break at the moment to install pycrypto.
Searching I found that link
Resume: they recomends replace PyCrypto with PyCryptodome
Here below the activity log retrieved for the last hour for my miband 5 device.
You can see it is not correctly interpreting the odd minute timestamps are totally different from the even minute timestamps.
2021-12-05 23:38:11,165 miband (INFO) > Enabling Fetch Char notifications status...
2021-12-05 23:38:11,321 miband (INFO) > Enabling Activity Char notifications status...
2021-12-05 23:38:11,461 miband (DEBUG) > start_get_previews_data(2021-12-05 23:00:00)...
2021-12-05 23:38:11,541 miband (DEBUG) > _char_fetch.getHandle(): 15 bytes received, processing them ...
2021-12-05 23:38:11,541 miband (DEBUG) > > Fetch data from 2021-12-5 23:0
2021-12-05 23:38:11,581 miband (DEBUG) > _char_activity.getHandle(): 17 bytes received, processing them ...
> 2021-12-05 23:00: category: 243; intensity 5; steps 0; heart rate 255
> 2021-12-05 23:01: category: 4; intensity 59; steps 128; heart rate 0
> 2021-12-05 23:02: category: 243; intensity 0; steps 0; heart rate 255
> 2021-12-05 23:03: category: 4; intensity 60; steps 128; heart rate 0
2021-12-05 23:38:11,582 miband (DEBUG) > _char_activity.getHandle(): 17 bytes received, processing them ...
> 2021-12-05 23:04: category: 243; intensity 0; steps 0; heart rate 255
> 2021-12-05 23:05: category: 4; intensity 61; steps 128; heart rate 0
> 2021-12-05 23:06: category: 243; intensity 0; steps 0; heart rate 255
> 2021-12-05 23:07: category: 4; intensity 61; steps 128; heart rate 0
2021-12-05 23:38:11,600 miband (DEBUG) > _char_activity.getHandle(): 17 bytes received, processing them ...
> 2021-12-05 23:08: category: 243; intensity 0; steps 0; heart rate 255
> 2021-12-05 23:09: category: 4; intensity 61; steps 128; heart rate 0
> 2021-12-05 23:10: category: 243; intensity 0; steps 0; heart rate 255
> 2021-12-05 23:11: category: 4; intensity 61; steps 128; heart rate 0
2021-12-05 23:38:11,601 miband (DEBUG) > _char_activity.getHandle(): 17 bytes received, processing them ...
> 2021-12-05 23:12: category: 243; intensity 0; steps 0; heart rate 255
> 2021-12-05 23:13: category: 4; intensity 61; steps 128; heart rate 0
> 2021-12-05 23:14: category: 243; intensity 0; steps 0; heart rate 255
> 2021-12-05 23:15: category: 4; intensity 62; steps 128; heart rate 0
2021-12-05 23:38:11,602 miband (DEBUG) > _char_activity.getHandle(): 17 bytes received, processing them ...
> 2021-12-05 23:16: category: 243; intensity 0; steps 0; heart rate 255
> 2021-12-05 23:17: category: 4; intensity 61; steps 128; heart rate 0
> 2021-12-05 23:18: category: 243; intensity 3; steps 0; heart rate 255
> 2021-12-05 23:19: category: 4; intensity 61; steps 128; heart rate 0
2021-12-05 23:38:11,603 miband (DEBUG) > _char_activity.getHandle(): 17 bytes received, processing them ...
> 2021-12-05 23:20: category: 243; intensity 1; steps 0; heart rate 255
> 2021-12-05 23:21: category: 4; intensity 61; steps 128; heart rate 0
> 2021-12-05 23:22: category: 243; intensity 0; steps 0; heart rate 255
> 2021-12-05 23:23: category: 4; intensity 61; steps 128; heart rate 0
FYI the info for my miband5:
MiBand
Soft revision: V1.0.2.58
Hardware revision: V0.44.23.2
Serial: 2c1049507e9d
Battery: 51
Time: 2021-12-05T23:43:43
Press a key to continue
Can you share more info on this " I reverse engineered snooped ACL packets to fill in the pieces of the puzzle." what steps did you took to get the packets - something that a contributor can replicate?
Does it support Mi Band 5 or it's 4 only?
Thanks for saving your days...
This code works well to auth Mi Band 3, but in case if any device goes out of ble range, or ble restart it should auto reconnect with existing connection(shouldn't force to re-authenticate), everytime need to re-auth to pair devices. gadgetbridge is great example. Please share if any idea on this.
Thanks a lot...
When I try to use song title function it throws this error
Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner self.run() File "/usr/lib/python3.7/threading.py", line 865, in run self._target(*self._args, **self._kwargs) File "/home/pi/.local/lib/python3.7/site-packages/cursesmenu/curses_menu.py", line 133, in _wrap_start curses.wrapper(self._main_loop) File "/usr/lib/python3.7/curses/__init__.py", line 94, in wrapper return func(stdscr, *args, **kwds) File "/home/pi/.local/lib/python3.7/site-packages/cursesmenu/curses_menu.py", line 193, in _main_loop self.process_user_input() File "/home/pi/.local/lib/python3.7/site-packages/cursesmenu/curses_menu.py", line 289, in process_user_input self.select() File "/home/pi/.local/lib/python3.7/site-packages/cursesmenu/curses_menu.py", line 329, in select self.selected_item.action() File "/home/pi/.local/lib/python3.7/site-packages/cursesmenu/items/function_item.py", line 35, in action self.return_value = self.function(*self.args, **self.kwargs) File "miband4_console.py", line 169, in set_music band.setTrack(fi, MUSICSTATE.PLAYED) File "/home/pi/miband/miband4/miband.py", line 574, in setTrack self.setMusic() File "/home/pi/miband/miband4/miband.py", line 623, in setMusic buf += self.artist.encode('utf-8') + null AttributeError: 'int' object has no attribute 'encode'
I think that this is lib side error but how to fix it?
when we get the infor from miband, if we can collect and deal with the data to transfer into our own cloud, like alibaba cloud. and when some data is unusual we can send the warning to the miband?
also if it is suit for miband5?
thanks
First of all, thank you for putting in all the work to create such a useful lib.
There seems to be an issue with parsing the recorded activity information from the band: data like the heart rate (only 0 or 255) and steps (only 0 or 128) are incorrect. Is the a common problem?
band info:
MiBand
Soft revision: V1.0.2.64
Hardware revision: V0.44.19.2
Serial: 336713969700
Battery: 71
Will it support mac os?
Just installed on Ubuntu16.04 with python3.7.2. Connect fine, but when I swipe to music control on miband4, it just hanged on "Just a sec...". I 've tried opening rhymbox before and after running miband4_console.py, but to no avail.
I want to receive accelerator data from mi band 4, but there is no callback in start_heart_rate_realtime.
Is it possible to get the RAW pulse (not the rate calculated by the band) from the mi band 4?
After this selection is made, the message "Set music track to : " appears, waiting for input. I've tried almost everything as input but the program keeps crashing.
Has anyone made it work or maybe found a way to set the music on the band from their Linux system?
Thank you in advance
Hi!
It can be usefull to implement an internal plot for heartrate data, as the possibility to live write data into a file to use heartrate externally but live.
Thanks!
It is possible to listen for click / navigation events ?
When I connect to my mi band 4 without an auth key all works
However, when I add the auth key (no matter in the terminal or create the file auth_key.txt), it gives the following error:
python3 miband4_console.py -m <MAC> -k <AUTHKEY>
2022-11-11 23:01:54,391 miband (INFO) > Connecting to F8:08:75:B1:A6:3D
2022-11-11 23:01:55,589 miband (INFO) > Connected
2022-11-11 23:02:01,318 miband (INFO) > Enabling Auth Service notifications status...
2022-11-11 23:02:01,448 miband (INFO) > Requesting random number...
2022-11-11 23:02:01,468 miband (INFO) > Sending encrypted random number
Traceback (most recent call last):
File "/home/artem-linux-usb/miband4/miband4_console.py", line 226, in <module>
success = band.initialize()
File "/home/artem-linux-usb/miband4/miband.py", line 242, in initialize
self._req_rdn()
File "/home/artem-linux-usb/miband4/miband.py", line 259, in _req_rdn
self.waitForNotifications(self.timeout)
File "/home/artem-linux-usb/.local/lib/python3.10/site-packages/bluepy/btle.py", line 560, in waitForNotifications
resp = self._getResp(['ntfy','ind'], timeout)
File "/home/artem-linux-usb/.local/lib/python3.10/site-packages/bluepy/btle.py", line 416, in _getResp
self.delegate.handleNotification(hnd, data)
File "/home/artem-linux-usb/miband4/miband.py", line 38, in handleNotification
self.device._send_enc_rdn(random_nr)
File "/home/artem-linux-usb/miband4/miband.py", line 263, in _send_enc_rdn
cmd = self._send_enc_key + self._encrypt(data)
File "/home/artem-linux-usb/miband4/miband.py", line 269, in _encrypt
aes = AES.new(self.auth_key, AES.MODE_ECB)
File "/home/artem-linux-usb/.local/lib/python3.10/site-packages/Crypto/Cipher/AES.py", line 95, in new
return AESCipher(key, *args, **kwargs)
File "/home/artem-linux-usb/.local/lib/python3.10/site-packages/Crypto/Cipher/AES.py", line 59, in __init__
blockalgo.BlockAlgo.__init__(self, _AES, key, *args, **kwargs)
File "/home/artem-linux-usb/.local/lib/python3.10/site-packages/Crypto/Cipher/blockalgo.py", line 141, in __init__
self._cipher = factory.new(key, *args, **kwargs)
SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats
I checked that my phone is disconnected
I did not change anything in the code
How do I fix that?
Thanks
I successfully connected to my miband5 but when I Set the band's music and receive music controls
as below it doesn't work:
Set music track artist to : artist1
Set music track album to: album1
Set music track title to: title1
Set music volume: 80
Set music position: 100
Set music duration: 1000
My miband5 is showing just a sec...
when opening the music menu and all the music controls are disabled.
FYI the info of my miband5:
MiBand
Soft revision: V1.0.2.58
Hardware revision: V0.44.23.2
Serial: 2c1049507e9d
Battery: 51
Time: 2021-12-06T00:04:38
Press a key to continue
I tried the same on my miband4 and it is working as expected (see output here below)
Set music track artist to : artist1
Set music track album to: album1
Set music track title to: title1
Set music volume: 80
Set music position: 100
Set music duration: 1000
Music focus in
Played
Forward
Backward
volume down
volume up
Music focus out
Can we expect a MI Band 5 update/Support for this repo?
Thanks
I came across your GitHub repository for the MiBand 4 Python Library and appreciate the detailed work you've put into it. I have a few questions and concerns:
Mi Band 3 Compatibility:
Mi Fit App Alternatives:
Python Version Compatibility:
-While attempting to use Python 3.11, I encountered an issue with building pycrypto. Could you specify which versions of Python are compatible with your library?
Here is the error I encountered:
Building wheels for collected packages: pycrypto
Building wheel for pycrypto (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [71 lines of output]
Hardware and Software Requirements:
Issue when running the script:
-There is no module named, Crypto.
Traceback (most recent call last):
File "/home/user/miband4/miband4_console.py", line 16, in
from miband import miband
File "/home/user/miband4/miband.py", line 7, in
from Crypto.Cipher import AES
ModuleNotFoundError: No module named 'Crypto'
Please kindly advise.
Reads realtime heart rate well but spoilt by the Miband 4 internal averaging system, would be good if there was a UUID to obtain RAW unaveraged Heart Rate Data (If exists) or be able to Change the averaging. It would seem averaging is done over at least 20 readings. So good for very slow responses, by useless for sudden change / burst activities. Also the Encryption Key is a real pain. Not a fault of this great library. But spoil by MiBand 4 firmware and it's implementation. But I suspect it was not meant to be hacked in python.
Line 8 in 0ac2a74
this does not work for me, unless I add band.initialize()
MiBand
Soft revision: V1.0.7.14
Hardware revision: V0.25.131.21
Serial: bbba6d66d3d7
Battery: 25
Time: 2019-11-30T23:46:54
I can't retrive music state.
I can't send call message.The device has no output.
Is a problem of the version?
Hello !
I'm working with your plugin to detect when I'm sleeping.
To do that, I want to get back my activity data for the last hour, but I receive nothing after 10:30 this morning (17h20 when I write this)
Do you have an idea of where I need to search ?
Thank you for your jobs, it will help me a lot 👍
self._writeCmd("%s %X %s\n" % (cmd, handle, binascii.b2a_hex(val).decode('utf-8')))
TypeError: a bytes-like object is required, not 'str
Is there anyway to extend this repo with spo2 support actually i want to read spo2 data for miband 5
I have a rooted phone.
sqlite3 /data/data/com.xiaomi.hm.health/databases/origin_db_[YOURDBNAMEHERE] "select AUTHKEY from DEVICE"
Is "[YOURDBNAMEHERE]" a value to change? My DB? What is DB?
What is supposed to do that command? Does it create a file?
In data/data/com.xiaomi.hm.health/ there isn' t the folder database. Is this normal?
Can you make something to avoid to use android (initial pairing)?
How can I get the gyro sensor value from the miband 5?
For example, jump rope in the midband operating mode checks the number of wrist rotations. I want to recognize certain movements using gyro sensors.
Hello. Is there a way to zero the number of steps, calories, and distance traveled via code? Can you help me?
Hi. on ubuntu 20.10 and miband4 firmware version v.10.9.66 send messege call/mail/sms not work !
Can we get the sleep data from band or from web server?
Want to have sleep data analysis form third party perspective.
As you can see below it takes 10 seconds to connect to my miband5.
There is a 10 second delay after it got connected and it enabled the authentication service notification status.
2021-12-05 22:32:29,764 miband (INFO) > Connected
2021-12-05 22:32:39,525 miband (INFO) > Enabling Auth Service notifications status...
2021-12-05 22:32:39,665 miband (INFO) > Requesting random number...
2021-12-05 22:32:39,704 miband (INFO) > Sending encrypted random number
2021-12-05 22:32:39,844 miband (INFO) > Initialized
2021-12-05 22:32:39,844 miband (INFO) > Disabling Auth Service notifications status...
2021-12-05 22:32:39,884 miband_api (INFO) > Connected to miband device
2021-12-05 22:32:39,884 miband_api (INFO) > Waiting for notifications:
FYI info for this miband5 gives:
MiBand
Soft revision: V1.0.2.58
Hardware revision: V0.44.23.2
Serial: 2c1049507e9d
Battery: 51
Time: 2021-12-05T23:32:29
Press a key to continue
Same tested for miband4 and as you can see
there is a 7.5 second delay after it got connected and it enabled the authentication service notification status.
2021-12-05 23:02:46,384 miband (INFO) > Connected
2021-12-05 23:02:54,063 miband (INFO) > Enabling Auth Service notifications status...
2021-12-05 23:02:54,203 miband (INFO) > Requesting random number...
2021-12-05 23:02:54,262 miband (INFO) > Sending encrypted random number
2021-12-05 23:02:54,402 miband (INFO) > Initialized
2021-12-05 23:02:54,402 miband (INFO) > Disabling Auth Service notifications status...
2021-12-05 23:02:54,442 miband_api (INFO) > Connected to miband device
2021-12-05 23:02:54,443 miband_api (INFO) > Waiting for notifications:
FYI info for this miband4 gives:
MiBand
Soft revision: V1.0.9.48
Hardware revision: V0.25.19.5
Serial: 79fb17e114e8
Battery: 54
Time: 2021-12-05T23:33:58
Press a key to continue
HI!
I would like to know if anyone had try to connect a Miband 7 with this code.
I got this error from the raspberry pi terminal (I got the same error if I pass the authkey):
raspberry@raspberrypi:~/Documentos/miband4 $ python3 miband4_console.py --mac D7:4F:6F:49:1C:54
Warning:
To use additional features of this script please put your Auth Key to 'auth_key.txt' or pass the --authkey option with your Auth Key
2023-05-03 19:59:02,444 miband (INFO) > Connecting to D7:4F:6F:49:1C:54
Connection to the MIBand failed. Trying out again in 3 seconds
2023-05-03 19:59:42,621 miband (INFO) > Connecting to D7:4F:6F:49:1C:54
Connection to the MIBand failed. Trying out again in 3 seconds
2023-05-03 20:00:22,941 miband (INFO) > Connecting to D7:4F:6F:49:1C:54
I am testing it using the miband4_console.py
program.
When I select @ Get activity logs for a day
at 9 minute past midnight I am getting below output.
So you can see that the minutes 00:00, 00:01, 00:02,
and 00:03
are missing.
2021-11-24 00:09:29,363 miband (INFO) > Enabling Fetch Char notifications status...
2021-11-24 00:09:29,515 miband (INFO) > Enabling Activity Char notifications status...
Trigger activity communication
Fetch data from 2021-11-24 0:0
24.11 - 00:04: category: 80; intensity 21; steps 0; heart rate 255;
24.11 - 00:05: category: 80; intensity 22; steps 0; heart rate 255;
24.11 - 00:06: category: 80; intensity 1; steps 0; heart rate 255;
24.11 - 00:07: category: 80; intensity 14; steps 0; heart rate 255;
24.11 - 00:08: category: 80; intensity 15; steps 0; heart rate 76;
24.11 - 00:09: category: 80; intensity 18; steps 0; heart rate 255;
Hi,
Thanks a lot for this project.
On thing that is missing is the fetching of activity statistics.
Check parseSummary() from https://codeberg.org/Freeyourgadget/Gadgetbridge/src/branch/master/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchSportsSummaryOperation.java
Is it difficult to add?
I successfully connected to my miband 4 using program:
python miband4_console.py -m XXXX -k XXXX
I then navigate on my miband to the music menu
and if I then select the first item Get general info of the device
from the curses menu it is reporting below error:
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/threading.py", line 973, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.9/threading.py", line 910, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.9/site-packages/cursesmenu/curses_menu.py", line 133, in _wrap_start
curses.wrapper(self._main_loop)
File "/usr/local/lib/python3.9/curses/__init__.py", line 94, in wrapper
return func(stdscr, *args, **kwds)
File "/usr/local/lib/python3.9/site-packages/cursesmenu/curses_menu.py", line 193, in _main_loop
self.process_user_input()
File "/usr/local/lib/python3.9/site-packages/cursesmenu/curses_menu.py", line 289, in process_user_input
self.select()
File "/usr/local/lib/python3.9/site-packages/cursesmenu/curses_menu.py", line 329, in select
self.selected_item.action()
File "/usr/local/lib/python3.9/site-packages/cursesmenu/items/function_item.py", line 35, in action
self.return_value = self.function(*self.args, **self.kwargs)
File "/miband4/miband4_console.py", line 91, in general_info
print ('Soft revision:',band.get_revision())
File "/miband4/miband.py", line 380, in get_revision
svc = self.getServiceByUUID(UUIDS.SERVICE_DEVICE_INFO)
File "/usr/local/lib/python3.9/site-packages/bluepy/btle.py", line 488, in getServiceByUUID
rsp = self._getResp('find')
File "/usr/local/lib/python3.9/site-packages/bluepy/btle.py", line 416, in _getResp
self.delegate.handleNotification(hnd, data)
File "/miband4/miband.py", line 111, in handleNotification
self.device.setMusic()
File "/miband4/miband.py", line 666, in setMusic
if self.artist is not None:
AttributeError: 'miband' object has no attribute 'artist'
Exception ignored in: <function Peripheral.__del__ at 0x7679a658>
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/bluepy/btle.py", line 630, in __del__
File "/usr/local/lib/python3.9/site-packages/bluepy/btle.py", line 454, in disconnect
File "/usr/local/lib/python3.9/site-packages/bluepy/btle.py", line 407, in _getResp
File "/usr/local/lib/python3.9/site-packages/bluepy/btle.py", line 375, in _waitResp
bluepy.btle.BTLEInternalError: Unexpected response (find)
root@pi3two:/miband4#
Line 183 in 0ac2a74
I think this should check for the return value of band.waitForNotifications, and run until it is true
how can i read the live heart rate and save it to txt without the menu and the other stuff?
with cron job
thx ^^
It seems like Python 2.7 is now deprecated and used only by a bunch of legacy scripts.
There is an official statement, confirmed by python.org and pip maintainers:
Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
See also pythonclock.org, it has a reference to PEP 373.
Your script is awesome and deserves better future for it!
Hi there 👋
I'm making a JS/TS implementation of the Mi Band 4 protocol using Web Bluetooth API, thanks to this project, it's been working so far! (except some things Chrome doesn't allow due to its "security" :s)
I'm struggling with auth now. I have an iOS phone so it was not possible for me to get auth key with any way mentioned here, but I found this repo which helped me get it. But when I try to authorize, I get an unknown payload on auth characteristic.
What I'm doing is:
0x02 0x00
to Auth Characteristic)0x03 0x00
and send 18 bytes to Char Auth.0x10 0x03 0x08
(notification) from Char Auth.Last byte is confusing me. It's not a Success (last byte would be 0x01
in that case) but any idea why is that?
Band Info:
Firmware V1.0.9.66
Hardware V0.25.131.5
Apparently, there is a way to disable Bluetooth on the Band, and doing so significantly increases battery life in my tests. I have two Bands, and while both are added to the original mobile app, only either one is active in the app. The deactivated Band shows a crossed out Bluetooth icon on its display, and that Band has a much longer running time. However, I can only switch between active Bands in the app, and not deactivate both. If I disconnect them, then the Bands do not even show the time anymore and want to get paired first.
So what I'm looking for is a way for the Band to display the time and work "offline", while having Bluetooth disabled (as indicated via the icon on the display) to safe battery. I just want to use them as plain watches. It would be great if this tool would support putting Bands into this mode.
Any way to obtain the recorded voice command given with a mi band 4 China version?
Hi,
I'm working on project with miband 4 and I have a doubt about the band.disconnect() method, I'm trying to create a loop that connect the band, then make a call (notification type 3), disconnect the band and finally connect again and make que whole process again.
The problem is that disconnect method from bluepy.btle is disconnecting the band, but the call doesn't end at all. So, do you have any way of stop a call?
I' seem to have connection issues.
From the log:
2019-12-31 16:05:05,769 miband (INFO) > Connecting to FC:D1:E0:EF:5D:0D
2019-12-31 16:05:07,210 miband (INFO) > Connected
Connection to the MIBand failed. Trying out again in 3 seconds
2019-12-31 16:05:49,537 miband (INFO) > Connecting to FC:D1:E0:EF:5D:0D
2019-12-31 16:05:56,350 miband (INFO) > Connected
I've added some trace code and it seems to be failing in miband.py at this line:
self.svc_1 = self.getServiceByUUID(UUIDS.SERVICE_MIBAND1)
The weird thing is: I had it working twice:
The first time was the very first time I used the program (without giving the key).
After that I got the above. Reset did not work, reboot did not work.
And then after instrumenting the code I started it again, It ran into this connection cycle. I went away and after some time lo and behold the curses UI was there. As I was busy with somehing else I only tried a few commands> last one was the music one. Then I was AFK for a while again, and when I came back I encounterd a crash. Not sure if that one is related to the connection issue but the backtrace is:
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.6/dist-packages/cursesmenu/curses_menu.py", line 133, in _wrap_start
curses.wrapper(self._main_loop)
File "/usr/lib/python3.6/curses/init.py", line 94, in wrapper
return func(stdscr, *args, **kwds)
File "/usr/local/lib/python3.6/dist-packages/cursesmenu/curses_menu.py", line 193, in _main_loop
self.process_user_input()
File "/usr/local/lib/python3.6/dist-packages/cursesmenu/curses_menu.py", line 289, in process_user_input
self.select()
File "/usr/local/lib/python3.6/dist-packages/cursesmenu/curses_menu.py", line 329, in select
self.selected_item.action()
File "/usr/local/lib/python3.6/dist-packages/cursesmenu/items/function_item.py", line 35, in action
self.return_value = self.function(*self.args, **self.kwargs)
File "miband4_console.py", line 160, in set_music
if band.waitForNotifications(0.5):
File "/usr/local/lib/python3.6/dist-packages/bluepy/btle.py", line 560, in waitForNotifications
resp = self._getResp(['ntfy','ind'], timeout)
File "/usr/local/lib/python3.6/dist-packages/bluepy/btle.py", line 407, in _getResp
resp = self._waitResp(wantType + ['ntfy', 'ind'], timeout)
File "/usr/local/lib/python3.6/dist-packages/bluepy/btle.py", line 362, in _waitResp
raise BTLEDisconnectError("Device disconnected", resp)
bluepy.btle.BTLEDisconnectError: Device disconnected
Restarting the program again brings me into the connect loop mentioned above.
(and this is all on a mi band 4 if that matters, not a 3 or so)
Hi
I am try to read gyroscope and accelerometer data
char_write_req("0x0033", "0100");
char_write_cmd("0x002f", "010119");
char_write_cmd("0x002f", "02"); //start getting sensor data
I am getting sensor data but i am not figure out what is gyroscope and accelerometer Data and how to parse gyroscope and accelerometer can you help me ?
Change pycrypto to cryptography or other library that is currently maintained since many people, like me cannot use this repo since pycrypto does not compile I'm using Android 12 aarch64 Rooted device and have compilers for C, but since this library is not working as it should I suggest that it is changed to a newer one.
You can config Miband 4 to act as Bluetooth Heart rate sensor.
I tested this with nRF Toolbox and it works without authentification key.
Does this work with your app?
I need help to get this work with javascspript. See this issue.
Hints are welcome.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.