GithubHelp home page GithubHelp logo

miband4's Introduction

Requirements Commit License

MIBAND 4 - Python Library

Library to interact with Xiaomi MiBand4. Only works on linux. demo

Updates(3/1/2021)

  • Alarm functionality.

Updates(10/27/2020)

  • (New Feature) Custom watchface files(.bin) support.
  • Firmware restore/update fixes.

Contributors

MiBand 4 provides superset of services provided by MiBand 2/3. For the services that were similar for both devices, the bluetooth characteristics, UUIDs and request/response byte sequence were the same. Therefore, I utilized some of the informations already uncovered by Freeyourgadget team and made use of the code by Andrey Nikishaev for MiBand2. I reverse engineered snooped ACL packets to fill in the pieces of the puzzle.

AuthKey

MiBand 4 with updated firmware requires 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 this library. Only some of the features of this library work without AuthKey of the band. Read Server based pairing for further details.

There are several ways to obtain the key.

Obtaining unique Authkey

On rooted phone you may grab the key from MiFit database which means that you must:

  • install MiFit
  • create an account
  • pair the band/watch
  • Then, execute the following command in a root shell terminal:
sqlite3 /data/data/com.xiaomi.hm.health/databases/origin_db_[YOURDBNAMEHERE] "select AUTHKEY from DEVICE"

On a non rooted phone you may consider using https://www.freemyband.com/

NOTICE: Every time you hard reset the band/watch, the Bluetooth MAC Address will be changed and you must grab a new key! Also, anytime you unpair your band/watch from MiFit, the pairing key will be invalidated and you must make new pairing in MiFit app.

Features that work without authkey

  • Sending Calls
  • Sending alerts
  • Sending Missed call notifications
  • Retrieving device info
  • Sending music title and music state(Playing/Paused)
  • Recieve music control events (Play/Pause/Forward/Backward/Volume Up/Volume Down/Enter Music app/ Exit Music app) through callbacks

Features that needs authkey

  • Updating watchface of the band
  • Retrieving heart rate (Realtime and Single time)
  • Firmware update/restore (This feature has the potential to brick your Mi Band 4. Do it at your own risk)
  • Retrieving steps count, calories count and fat burnt
  • Setting date and time
  • Fetching fitness data within certain past intervals.

Setup and demo

  • Clone this repo to your local machine using https://github.com/satcar77/miband4.git
  1. Install the dependencies. Libglib2 is required for bluepy.

    sudo apt-get install libglib2.0-dev
    pip3 install -r requirements.txt
    
  2. (Optional) Find AuthKey for your device and put it to auth_key.txt file in the current directory with the script.

  3. Turn off your Bluetooth on your mobile device paired with MIBand 4

  4. Find out your MiBand4 MAC address using hcitool

    sudo hcitool lescan
    // if you are having trouble
    sudo hciconfig hci0 reset 
    
  5. Run the miband4_console

    python3 miband4_console.py -m MAC_ADDRESS 
    

Contributing

Step 1

  • Option 1

    • 🍴 Fork this repo!
  • Option 2

    • 👯 Clone this repo to your local machine

Step 2

  • HACK AWAY! 🔨🔨🔨

Step 3

  • 🔃 Create a new pull request

License

This project is licensed under the MIT License - see the LICENSE.md file for details

miband4's People

Contributors

d34d633f avatar justkowal avatar mikewent avatar satcar77 avatar shahart avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

miband4's Issues

Error when trying to set song title in demo

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?

Can't read recent activity data

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 👍

Mi band 6 support

I have problems with the mi band 6, can you add support for the mi band 6 please?

Thanks.

Spo2 support

Is there anyway to extend this repo with spo2 support actually i want to read spo2 data for miband 5

Activity Log data incorrect

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

SetAlarm

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

miband authentication takes long (10 sec for miband5 and 7.5 sec for miband 4 )

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

Voice commands

Any way to obtain the recorded voice command given with a mi band 4 China version?

How to auto reconnect already authenticated Mi Band?

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...

Plot live heartrate

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!

connection issue

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)

Need some help with Auth

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:

  • Request Random Number once I connect to GATT. (Write 0x02 0x00 to Auth Characteristic)
  • When I get random number (16 bytes), I encrypt it with AES ECB with Auth Key and prepend 0x03 0x00 and send 18 bytes to Char Auth.
  • After that I receive 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

Heart Rate accuracy and response

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.

Bluetooth Heart rate sensor

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.

"Set the band's music and receive music controls" is not working on miband5.

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

send messege NOT WORK !

Hi. on ubuntu 20.10 and miband4 firmware version v.10.9.66 send messege call/mail/sms not work !

Read gyroscope and accelerometer Data

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 ?

is this suit xiaomi 5?

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

Upgrade to Python 3

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!

Add a way to disable Bluetooth on the band

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.

Oops...some functions have some bugs on my device.

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?

Miband 7 connection

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

miband5 activity log is not correct

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

Error while connecting with AuthKey

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

Question-Request

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)?

pycrypto to cryptography

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.

Retrieving activity logs missed the first 4 minutes of activity.

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;

Stop call notification

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?

AttributeError: 'miband' object has no attribute 'artist'

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# 

More info on ACL packet debugging

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?

Can not control rhymbox in ubuntu 16.04

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.