Skip to main content

Communicate with the EmBody device over BLE (bluetooth)

Project description

Embody BLE

PyPI Status Python Version License

Tests

pre-commit Black

Features

  • Connects to an EmBody device over BLE (Bluetooth) using Bleak
  • Uses the EmBody protocol to communicate with the device
  • Integrates with the EmBody Protocol Codec project
  • Asynchronous send without having to wait for response
  • Synchronous send where response message is returned
  • Provides callback interfaces for incoming messages, response messages and connect/disconnect
  • Facade method to send/receive BLE messages directly
  • All methods and callbacks are threadsafe
  • Separate threads for send, receive and callback processing
  • Type safe code using ty for type checking
  • High level callback interface for attribute reporting

Requirements

  • Python 3.11-3.13
  • Access to private Aidee Health repositories on Github

Installation

You can install Embody BLE via pip:

$ pip install embody-ble

This adds embody-ble as a library, but also provides the CLI application with the same name.

Usage

A very basic example where you send a message request and get a response:

from embodyble.embodyble import EmbodyBle
from embodyserial.helpers import EmbodySendHelper

embody_ble = EmbodyBle()
send_helper = EmbodySendHelper(sender=embody_ble)
embody_ble.connect()
print(f"Serial no: {send_helper.get_serial_no()}")
embody_ble.shutdown()

If you want to see more of what happens under the hood, activate debug logging before setting up EmbodyBle:

import logging

logging.basicConfig(level=logging.DEBUG)

Using the application from the command line

The application also provides a CLI application that is automatically added to the path when installing via pip.

Once installed with pip, type:

embody-ble --help

To see which options are available.

Note The serial port is automatically detected, but can be overridden by using the --device option.

Example - Attribute reporting

To see how attribute reporting can be configured, have a look at the example in examples/ble_reporting_example.py

You can also test attribute reporting using the cli:

embody-ble --log-level INFO --report-attribute battery_level --report-interval 1
embody-ble --log-level INFO --report-attribute heart_rate --report-interval 1000

Example - List all available EmBody devices

embody-ble --list-devices

Example - List all attribute values

embody-ble --get-all

Example - Get serial no of device

embody-ble --get serialno

Example - List files over serial port

embody-ble --list-files

Example - Set time current time (UTC)

embody-ble --set-time

Logging

This library uses Python's standard logging module and follows best practices for libraries:

For Library Users

The library is silent by default - it won't produce any output unless you configure logging. To enable logging from the library:

import logging

# Enable INFO level logging for embodyble
logging.getLogger('embodyble').setLevel(logging.INFO)
logging.getLogger('embodyble').addHandler(logging.StreamHandler())

# Or configure specific modules
logging.getLogger('embodyble.embodyble').setLevel(logging.DEBUG)

For CLI Users

The CLI configures logging automatically. Use --log-level to control verbosity:

embody-ble --log-level DEBUG --list-devices

Available levels: CRITICAL, WARNING, INFO, DEBUG

Troubleshooting

No known issues registered.

Contributing

Contributions are very welcome. To learn more, see the Contributor Guide.

Issues

If you encounter any problems, please file an issue along with a detailed description.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

embody_ble-1.1.27.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

embody_ble-1.1.27-py3-none-any.whl (19.9 kB view details)

Uploaded Python 3

File details

Details for the file embody_ble-1.1.27.tar.gz.

File metadata

  • Download URL: embody_ble-1.1.27.tar.gz
  • Upload date:
  • Size: 17.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for embody_ble-1.1.27.tar.gz
Algorithm Hash digest
SHA256 e8ea5f0a04103be4d03178f37b234a0c5e08a533090b2fe2e3032c726c41e68d
MD5 09f95ae9a08fdeb3418415ef1eafa01f
BLAKE2b-256 e051fa2ce23e6274ed4d6b3d130e4d53698020870dbb7eb2efd4f61cf5cea57a

See more details on using hashes here.

File details

Details for the file embody_ble-1.1.27-py3-none-any.whl.

File metadata

  • Download URL: embody_ble-1.1.27-py3-none-any.whl
  • Upload date:
  • Size: 19.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for embody_ble-1.1.27-py3-none-any.whl
Algorithm Hash digest
SHA256 4a9326b124ea6d09c7057cf0c096555dada5d05382d762d8f0802219c34396fa
MD5 83d4f6f2d396d62c26d828ace03cc354
BLAKE2b-256 c66024c73e1e9195f3cbe6176bf5dd43c1984eda0ca385510778a3f92ddafd2e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page