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

Communicate battery level over bluetooth #88

Open
valeriyvan opened this issue Feb 9, 2023 · 4 comments
Open

Communicate battery level over bluetooth #88

valeriyvan opened this issue Feb 9, 2023 · 4 comments

Comments

@valeriyvan
Copy link
Contributor

valeriyvan commented Feb 9, 2023

I'd like to add to iOS app displaying battery level / warning user about low battery level.
What's missing in this firmware to make possible sending battery level over bluetooth?
Any help is appreciated.

@ataffanel
Copy link
Member

There is currently no good ways to transfer battery level over Bluetooth. The main problem is that this information is available using the Crazyflie's Log subsystem but this subsystem requires to fetch the log's Table of Content (TOC) and this is a pretty heavy operation that would take a lot of time with the current bluetooth speed. The reason the TOC is needed is that the log variables cannot be fetched by name, but by ID, and this ID needs to be discovered.

I see two ways to go forward:

  1. Implement a lighter way to get log variables, either by having an API that returns the ID by name of a variable or by being able to add variable names in a log block. Similar things have already been done in the param subsystem to be able to set/get variable by name to allow the Android client to control decks over bluetooth.
  2. We could implement the official BLE battery service.

The former would allow to add more functionalities like getting pitch/roll/yaw and other logs. The later might allow to get the battery level to be visible from the OS as well which can be useful, for example, to monitor the charge.

If you are thinking of logging more data in the mobile clients later, we should update the log subsystem. Otherwise both way would look good to me.

@valeriyvan
Copy link
Contributor Author

There is currently no good ways to transfer battery level over Bluetooth. The main problem is that this information is available using the Crazyflie's Log subsystem but this subsystem requires to fetch the log's Table of Content (TOC) and this is a pretty heavy operation that would take a lot of time with the current bluetooth speed. The reason the TOC is needed is that the log variables cannot be fetched by name, but by ID, and this ID needs to be discovered.

I see two ways to go forward:

  1. Implement a lighter way to get log variables, either by having an API that returns the ID by name of a variable or by being able to add variable names in a log block. Similar things have already been done in the param subsystem to be able to set/get variable by name to allow the Android client to control decks over bluetooth.
  2. We could implement the official BLE battery service.

The former would allow to add more functionalities like getting pitch/roll/yaw and other logs. The later might allow to get the battery level to be visible from the OS as well which can be useful, for example, to monitor the charge.

If you are thinking of logging more data in the mobile clients later, we should update the log subsystem. Otherwise both way would look good to me.

I would prefer variant 2 - implementing BLE battery service.

@ataffanel
Copy link
Member

Adding a battery BLE service would work fine for us. If you are interested in looking into it we will gladly accept a pull request, otherwise we will eventually get to it and implement it.

@valeriyvan
Copy link
Contributor Author

Adding a battery BLE service would work fine for us. If you are interested in looking into it we will gladly accept a pull request, otherwise we will eventually get to it and implement it.

I would like to implement this as soon as I have time. If you implement this sooner than me - that's fine.

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

No branches or pull requests

3 participants