
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
polar-python is a Python library for connecting to Polar devices via Bluetooth Low Energy (BLE) using Bleak. It allows querying device capabilities (e.g., ECG, ACC, PPG), exploring configurable options, and streaming parsed data through callback functions.
polar-python
is a Python library designed for seamless integration with Polar devices using Bluetooth Low Energy (BLE) through the Bleak library. With polar-python
, you can easily connect to Polar devices, query supported functionalities such as ECG, ACC, and PPG, explore configurable options and their possible values, and start data streaming to receive parsed binary data through callback functions.
You can install polar-python
from PyPI using pip:
pip install polar-python
Below is an example of how to use polar-python
to connect to a Polar device, query its features, set measurement settings, and start data streaming.
import asyncio
from bleak import BleakScanner
from polar_python import PolarDevice, MeasurementSettings, SettingType, ECGData, ACCData
def data_callback(data: Union[ECGData, ACCData]):
"""
Callback function to handle incoming data from the Polar device.
Args:
data (Union[ECGData, ACCData]): The data received from the Polar device.
"""
async def main():
"""
Main function to connect to a Polar device, query its features,
set measurement settings, and start data streaming.
"""
# Find the Polar H10 device
device = await BleakScanner.find_device_by_filter(
lambda bd, ad: bd.name and "Polar H10" in bd.name, timeout=5
)
if device is None:
return
# Establish connection to the Polar device
async with PolarDevice(device, data_callback) as polar_device:
# Query available features
available_features = await polar_device.available_features()
# Query and print stream settings for each feature
for feature in available_features:
settings = await polar_device.request_stream_settings(feature)
# Define ECG measurement settings
ecg_settings = MeasurementSettings(
measurement_type="ECG",
settings=[
SettingType(type="SAMPLE_RATE", array_length=1, values=[130]),
SettingType(type="RESOLUTION", array_length=1, values=[14]),
],
)
# Define ACC measurement settings
acc_settings = MeasurementSettings(
measurement_type="ACC",
settings=[
SettingType(type="SAMPLE_RATE", array_length=1, values=[25]),
SettingType(type="RESOLUTION", array_length=1, values=[16]),
SettingType(type="RANGE", array_length=1, values=[2]),
],
)
# Start data streams for ECG and ACC
await polar_device.start_stream(ecg_settings)
await polar_device.start_stream(acc_settings)
# Keep the stream running for 120 seconds
await asyncio.sleep(120)
if __name__ == "__main__":
asyncio.run(main())
This project is licensed under the MIT License. See the LICENSE file for details.
FAQs
polar-python is a Python library for connecting to Polar devices via Bluetooth Low Energy (BLE) using Bleak. It allows querying device capabilities (e.g., ECG, ACC, PPG), exploring configurable options, and streaming parsed data through callback functions.
We found that polar-python demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.