Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieving activity logs missed the first 4 minutes of activity. #55

Open
janvda opened this issue Nov 23, 2021 · 2 comments
Open

Retrieving activity logs missed the first 4 minutes of activity. #55

janvda opened this issue Nov 23, 2021 · 2 comments

Comments

@janvda
Copy link

janvda commented Nov 23, 2021

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;
@janvda
Copy link
Author

janvda commented Nov 24, 2021

I have added some log statements.
I also adapted it so that it is not logging the activity for the complete day but only for the current hour:

2021-11-24 09:25:24,047 miband (INFO) > Enabling Fetch Char notifications status...
2021-11-24 09:25:24,067 miband (INFO) > Enabling Activity Char notifications status...
Trigger activity communication
_char_fetch.getHandle(): 15 bytes received, processing them ...
  > Fetch data from 2021-11-24 9:0
_char_activity.getHandle(): 9 bytes received, processing them ...
  > 2021-11-24 09:04: category: 80; intensity 110; steps 0; heart rate 255
  > 2021-11-24 09:05: category: 17; intensity 83; steps 43; heart rate 255
_char_fetch.getHandle(): 3 bytes received, processing them ...
  > Trigger more communication
Trigger activity communication
_char_fetch.getHandle(): 15 bytes received, processing them ...
  > Fetch data from 2021-11-24 9:6
_char_activity.getHandle(): 17 bytes received, processing them ...
  > 2021-11-24 09:10: category: 96; intensity 14; steps 0; heart rate 255
  > 2021-11-24 09:11: category: 96; intensity 20; steps 0; heart rate 255
  > 2021-11-24 09:12: category: 96; intensity 28; steps 0; heart rate 255
  > 2021-11-24 09:13: category: 96; intensity 17; steps 0; heart rate 255
_char_activity.getHandle(): 17 bytes received, processing them ...
  > 2021-11-24 09:14: category: 96; intensity 23; steps 0; heart rate 255
  > 2021-11-24 09:15: category: 96; intensity 14; steps 0; heart rate 255
  > 2021-11-24 09:16: category: 96; intensity 15; steps 0; heart rate 255
  > 2021-11-24 09:17: category: 96; intensity 22; steps 0; heart rate 255
_char_activity.getHandle(): 17 bytes received, processing them ...
  > 2021-11-24 09:18: category: 96; intensity 26; steps 0; heart rate 255
  > 2021-11-24 09:19: category: 96; intensity 9; steps 0; heart rate 255
  > 2021-11-24 09:20: category: 96; intensity 25; steps 0; heart rate 255
  > 2021-11-24 09:21: category: 96; intensity 3; steps 0; heart rate 255
_char_activity.getHandle(): 17 bytes received, processing them ...
  > 2021-11-24 09:22: category: 96; intensity 1; steps 0; heart rate 255
  > 2021-11-24 09:23: category: 106; intensity 0; steps 0; heart rate 255
  > 2021-11-24 09:24: category: 96; intensity 16; steps 0; heart rate 255
  > 2021-11-24 09:25: category: 96; intensity 21; steps 0; heart rate 255
_char_activity.getHandle(): 13 bytes received, processing them ...
  1. So it looks like that the problem is not in this python repository but on the miband.
    The first 4 minutes are not returned by my miband4.

  2. To make it worse in the midst it is rerequesting activity information for the remaining part (> Fetch data from 2021-11-24 9:6 and it is again skipping the first 4 minutes.

@janvda
Copy link
Author

janvda commented Nov 24, 2021

I have found the root cause.
There is little bug in following line:

To fix this you need to change

index = int(self.pkg) * 4 + (i - 1) / 4

into:

index = ( int(self.pkg) -1 ) * 4 + (i - 1) / 4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant