or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/bleak@1.1.x
tile.json

tessl/pypi-bleak

tessl install tessl/pypi-bleak@1.1.0

Cross-platform Bluetooth Low Energy GATT client library for asynchronous BLE communication

Agent Success

Agent success rate when using this tile

97%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.07x

Baseline

Agent success rate without this tile

91%

task.mdevals/scenario-2/

BLE Heart Rate Monitor Scanner

Build a BLE scanner that discovers heart rate monitoring devices in the vicinity.

Objective

Create a Python script that scans for BLE devices advertising heart rate services and displays information about discovered devices.

Requirements

1. Device Discovery

Implement a scanner that:

  • Scans for BLE devices that advertise the Heart Rate Service (UUID: 0x180D)
  • Runs the scan for 10 seconds
  • Only discovers devices that specifically advertise heart rate services

2. Display Results

For each discovered device, display:

  • The device name (or "Unknown" if no name is available)
  • The device address
  • The RSSI (signal strength) value

3. Output Format

Print results in the following format:

Scanning for heart rate monitors...
Found: <device_name> (<address>) - RSSI: <rssi> dBm

If no devices are found, print:

No heart rate monitors found

Implementation Details

  • Use asynchronous programming patterns
  • The scanner should filter devices during the scan, not after
  • Handle cases where devices might not have a name

Test Cases { .test }

The following test cases should pass:

Test Case 1: Scanner with Heart Rate Filter @test

File: test_hr_scanner.py { .test-file }

Test:

import pytest
from hr_scanner import scan_heart_rate_devices

@pytest.mark.asyncio
async def test_scanner_filters_by_service():
    """Test that scanner uses service UUID filter"""
    # This test verifies the scanner is configured with service UUID filter
    devices = await scan_heart_rate_devices(timeout=1.0)
    # If devices are found, they should have been filtered during scan
    assert isinstance(devices, list)

Test Case 2: Device Information Format @test

File: test_hr_scanner.py { .test-file }

Test:

import pytest
from hr_scanner import format_device_info

def test_format_device_info():
    """Test device information formatting"""
    # Mock BLEDevice and AdvertisementData
    class MockDevice:
        def __init__(self):
            self.name = "HR Monitor"
            self.address = "AA:BB:CC:DD:EE:FF"

    class MockAdData:
        def __init__(self):
            self.rssi = -65

    device = MockDevice()
    ad_data = MockAdData()
    result = format_device_info(device, ad_data)

    assert "HR Monitor" in result
    assert "AA:BB:CC:DD:EE:FF" in result
    assert "-65" in result

Dependencies { .dependencies }

bleak { .dependency }

Provides cross-platform Bluetooth Low Energy support for device scanning and GATT operations.