Skip to main content

A class-based wrapper for the peripheral functionalities provided by the library python-bluezero

Project description

Blepy

MIT-shield

A class-based wrapper for the peripheral functionalities provided by the library python-bluezero.

About

The primary goal of this library is to make it easier and more clearer about how to implement Bluetooth low energy Peripherals, including the associated Services, Characteristics and Descriptors. This is done by using a class-based wrapper for the BlueZ based python-bluezero library.

As seen in the figure below, a Service has one to many Characteristics and a Characteristic has (often) one to many Descriptors, which is what this library is built to follow.

BLE overview

Usage

Import blepy

To use blepy in your project, simply import the whole package:

import blepy

Service

Create unique BLE services by inheriting blepy.Service, including associated characteristics:

class ExampleService(blepy.Service):
   def __init__(self, primary):
      super().__init__(self, "UUID", primary)
      self.characteristics = [ExampleCharacteristic()]

Characteristic

Create unique BLE characteristics by inheriting blepy.Characteristic, including associated descriptors:

class ExampleCharacteristic(blepy.Characteristic):
   def __init__(self):
      super().__init__(self, "UUID")
      self.descriptors = [ExampleDescriptor()]     

Descriptor

Create unique BLE descriptors by inheriting blepy.Descriptor:

class ExampleDescriptor(blepy.Descriptor):
   def __init__(self):
      super().__init__(self, "UUID")

Peripheral

Create a new peripheral with included services by either using the blepy.Peripheral as it is:

# Initialize and publish the peripheral
peripheral = blepy.Peripheral([ExampleService(True)], adapter_address, local_name='Peripheral', appearance=0)
peripheral.publish()

... or by inherit from the blepy.Peripheral and create an unique peripheral:

class ExamplePeripheral(blepy.Peripheral):
    def __init__(self, adapter_address):
        services = [ExampleService(True)]
        super().__init__(services, adapter_address, local_name='Peripheral', appearance=0)

# Initialize and publish the peripheral
peripheral = ExamplePeripheral(adapter_address)
peripheral.publish()

Examples

(GATT Server) cpu-temperature.py

This example transmits (randomly generated) temperature values of the CPU over a single characteristic. Values are only updated when notification are switched on.

(UART) ble_uart.py

This example simulates a basic UART connection over two lines, TXD and RXD.

It is based on a proprietary UART service specification by Nordic Semiconductors. Data sent to and from this service can be viewed using the nRF UART apps from Nordic Semiconductors for Android and iOS.

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

blepy-0.3.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

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

blepy-0.3.0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file blepy-0.3.0.tar.gz.

File metadata

  • Download URL: blepy-0.3.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for blepy-0.3.0.tar.gz
Algorithm Hash digest
SHA256 a535fece25fc842dab3d5fa2ea3377e7a950079dbf682c65a3e69c373a34e7f1
MD5 01ae9751f4acd4ce3a7339091b8dc4a3
BLAKE2b-256 9ff9710d1af088b652b07da4c09d14c71f50dd53b8a782a3be6f6300222894ce

See more details on using hashes here.

File details

Details for the file blepy-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: blepy-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for blepy-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 02272aa6c8d31405536c2e905efad01794ae0abf2e1d7401dcc0440fc89857fd
MD5 acc970426545ef06ce643162bf6ed8f4
BLAKE2b-256 df3dedd49377ce30d3196c480480394dfbf3269f0f8327d440d373cb89cb7359

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