Skip to main content

bleak compatible pythonista.cb backend

Project description

Bleak compatible backend for Pythonista iOS app

license pypi py-versions Made in Ukraine

Pytest Mypy Ruff

This module uses bleak backend API to implement a compatible solution for Pythonista iOS app. It uses Pythonista built-in _cb module, that is wrapper to iOS CoreBluetooth.

[!CAUTION] This project is in early beta use with caution

  • This backend refers to Pythonista.cb docs
  • This backend refers to existing macOS CoreBluetooth bleak backend was used as a reference
  • It also provides stub files for pythonista built-in modules as _cb and pythonista.cb, and fake _cb.py implementation for testing on unsupported platforms
  • Use Bleak docs to explore how to use Bleak

Table of Contents

Installation

pip install bleak-pythonista

Usage

Direct import

import asyncio
from bleak_pythonista import BleakScanner, BleakClient

async def main():
    devices = await BleakScanner.discover(
        service_uuids=["<some-service-uuid>"]  # optional
    )
    for d in devices:
        print(d)        
        client = BleakClient(d)
        await client.connect()
        print(client.services)
    
asyncio.run(main())

With bleak itself

import asyncio
from bleak import BleakScanner, BleakClient
from bleak_pythonista import BleakScannerPythonistaCB, BleakClientPythonistaCB

async def main():
    devices = await BleakScanner.discover(
        service_uuids=["<some-service-uuid>"],  # optional
        backend=BleakScannerPythonistaCB,
    )
    for d in devices:
        print(d)        
        client = BleakClient(d, backend=BleakClientPythonistaCB)
        await client.connect()
        print(client.services)
    
asyncio.run(main())

[!WARNING] DO NOT NAME YOUR SCRIPT bleak.py or bleak_pythonista! It will cause a circular import error.

What's done?

  • CentralManagerDelegate (for now for scanning purpose only)
  • client.BleakClientPythonistaCB
  • scanner.BleakScannerPythonistaCB
  • _cb and pythonista.cb stubs
  • fake cb.py for testing with backend simulation on unsupported platforms

[!TIP] THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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

bleak_pythonista-0.1.0b3.tar.gz (23.4 kB view details)

Uploaded Source

Built Distribution

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

bleak_pythonista-0.1.0b3-py3-none-any.whl (23.9 kB view details)

Uploaded Python 3

File details

Details for the file bleak_pythonista-0.1.0b3.tar.gz.

File metadata

  • Download URL: bleak_pythonista-0.1.0b3.tar.gz
  • Upload date:
  • Size: 23.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.3

File hashes

Hashes for bleak_pythonista-0.1.0b3.tar.gz
Algorithm Hash digest
SHA256 51f059ef4468b02b435beb10e7b27de0ef6b4d01c59a90ef35ba0510a3b850c0
MD5 ed2c3e7ae8b21b0369579843f64d3a33
BLAKE2b-256 d147e6ac492b47b939a0701f317826b26c4706c67a2d97f292725e4adfe3593c

See more details on using hashes here.

File details

Details for the file bleak_pythonista-0.1.0b3-py3-none-any.whl.

File metadata

File hashes

Hashes for bleak_pythonista-0.1.0b3-py3-none-any.whl
Algorithm Hash digest
SHA256 c18f6d77923201cad23da4194b25b763368365fce52758f36b4537f0b404488e
MD5 d7fcda6079ea3f508471f3adb0f47f12
BLAKE2b-256 70a31978e531b32a387a1ebbeb03b8f9e79da3b0743e09c8408032b1aaf74e3a

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