Skip to content

Add motion service#754

Merged
JF002 merged 5 commits intodevelopfrom
add-motion-service
Oct 24, 2021
Merged

Add motion service#754
JF002 merged 5 commits intodevelopfrom
add-motion-service

Conversation

@JF002
Copy link
Collaborator

@JF002 JF002 commented Oct 17, 2021

This PR adds a new Motion service, which exposes the "live" step count and raw motion values (X/Y/Z).

API definition:

  • Service : 00020000-78fc-48fe-8e23-433b3a1942d0
    • Characteristics
      • Step count (1 * uint32_t) : 00020001-78fc-48fe-8e23-433b3a1942d0 00030001-78fc-48fe-8e23-433b3a1942d0 (READ/NOTIFY)
      • Motion values (3 * int16_t) : 00020002-78fc-48fe-8e23-433b3a1942d0 00030002-78fc-48fe-8e23-433b3a1942d0 (READ/NOTIFY)

I also improved notifications so that they are processed and send only if the companion app registered to them (and applied to change to the heart rate service).

motionService

@JF002 JF002 added documentation Improvements or additions to documentation feature request labels Oct 17, 2021
@JF002 JF002 added this to the 1.7.0 milestone Oct 17, 2021
@JF002 JF002 mentioned this pull request Oct 17, 2021
@Elara6331
Copy link
Contributor

The BLE characteristic UUID for step count is identical to the one used to get responses from call notifications. One of them needs to be changed.

@JF002
Copy link
Collaborator Author

JF002 commented Oct 18, 2021

@Arsen6331 Good catch! I totally forgot about that custom "service"! And it's unfortunately not mentioned in the doc page...
The Motion service will move to 0003xxxx-..., then!

@JF002 JF002 added the needs more work This PR needs more work label Oct 18, 2021
… change the UUID of the new Motion service from 00020000-* to 00030000-*.
@ajack2001my
Copy link

ajack2001my commented Oct 21, 2021

How much is the battery affected by this service? Can it be switched off?

@JF002
Copy link
Collaborator Author

JF002 commented Oct 22, 2021

@ajack2001my This is BLE service, meaning that it exposes some values to the companion app, but it won't consume any power/cpu time unless the companion app actually read those values (or subscribe to notification).

@Elara6331
Copy link
Contributor

I've implemented this in itd. The issue description should be edited in case someone tries to look for the UUIDs and gets confused by there being two differing sources.

@JF002
Copy link
Collaborator Author

JF002 commented Oct 23, 2021

I've implemented this in itd.

Awesome!

The issue description should be edited in case someone tries to look for the UUIDs and gets confused by there being two differing sources.

Indeed, I've just edited, thanks!

@JF002 JF002 removed the needs more work This PR needs more work label Oct 23, 2021
@JF002 JF002 merged commit 82ca526 into develop Oct 24, 2021
@JF002 JF002 deleted the add-motion-service branch October 24, 2021 18:06
@Elara6331
Copy link
Contributor

Notify on the step count characteristic seems to only populate one byte of data. Once the step count goes above 255, it resets to 0. Reading from the characteristic instead of using notify yields the full, 4-byte value.

@JF002
Copy link
Collaborator Author

JF002 commented Oct 25, 2021

Notify on the step count characteristic seems to only populate one byte of data. Once the step count goes above 255, it resets to 0. Reading from the characteristic instead of using notify yields the full, 4-byte value.

Woops ! You are right : https://github.com/InfiniTimeOrg/InfiniTime/blob/develop/src/components/ble/MotionService.cpp#L83
The step count is passed as a single byte in this function, while the original variable is a uint32_t... The joy of C++ and implicit casting...
I'll fix this asap!

@JF002
Copy link
Collaborator Author

JF002 commented Oct 26, 2021

Fixed in 71ce13d

In this screenshot, the number of steps is 0x12345678 :

Screenshot_20211026-203025

@xan-m
Copy link
Contributor

xan-m commented Oct 26, 2021

Step count implemented in InfiniLink on iOS. This was one of my most frequently requested features, thanks for adding it @JF002!

@Elara6331
Copy link
Contributor

Elara6331 commented Oct 26, 2021

Fixed in 71ce13d

Just tried it, it now works. Thank you.

@JF002
Copy link
Collaborator Author

JF002 commented Oct 27, 2021

Step count implemented in InfiniLink on iOS. This was one of my most frequently requested features, thanks for adding it @JF002!

Thanks for integrating it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation feature request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants