bluez_peripheral.gatt.characteristic module

class bluez_peripheral.gatt.characteristic.CharacteristicFlags(value)[source]

Bases: Flag

Flags to use when specifying the read/ write routines that can be used when accessing the characteristic. These are converted to bluez flags.

AUTHENTICATED_SIGNED_WRITES = 64

Characteristic requires secure bonding. Values are authenticated using a client signature.

AUTHORIZE = 65536
BROADCAST = 1

Characteristic value may be broadcast as a part of advertisements.

ENCRYPT_AUTHENTICATED_READ = 4096
ENCRYPT_AUTHENTICATED_WRITE = 8192
ENCRYPT_READ = 1024

The communicating devices have to be paired for the client to be able to read the characteristic. After pairing the devices share a bond and the communication is encrypted.

ENCRYPT_WRITE = 2048

The communicating devices have to be paired for the client to be able to write the characteristic. After pairing the devices share a bond and the communication is encrypted.

EXTENDED_PROPERTIES = 128

The Characteristic Extended Properties Descriptor exists and contains the values of any extended properties. Do not manually set this flag or attempt to define the Characteristic Extended Properties Descriptor. These are automatically handled when a CharacteristicFlags.RELIABLE_WRITE or CharacteristicFlags.WRITABLE_AUXILIARIES flag is used.

INDICATE = 32

Characteristic may be subscribed to in order to provide indication when its value changes. Indication requires acknowledgment.

INVALID = 0
NOTIFY = 16

Characteristic may be subscribed to in order to provide notification when its value changes. Notification does not require acknowledgment.

READ = 2

Characteristic value may be read.

RELIABLE_WRITE = 256

The value to be written to the characteristic is verified by transmission back to the client before writing occurs.

SECURE_READ = 16384
SECURE_WRITE = 32768
WRITABLE_AUXILIARIES = 512

The Characteristic User Description Descriptor exists and is writable by the client.

WRITE = 8

Characteristic value may be written to and confirmation is required.

WRITE_WITHOUT_RESPONSE = 4

Characteristic value may be written to with no confirmation required.

class bluez_peripheral.gatt.characteristic.CharacteristicReadOptions(options)[source]

Bases: object

Options supplied to characteristic read functions. Generally you can ignore these unless you have a long characteristic (eg > 48 bytes) or you have some specific authorization requirements.

Parameters:

options (Dict[str, Variant])

property device: str | None

The path of the remote device on the system dbus or None.

property mtu: int | None

The exchanged Maximum Transfer Unit of the connection with the remote device or 0.

property offset: int

A byte offset to read the characteristic from until the end.

class bluez_peripheral.gatt.characteristic.CharacteristicWriteOptions(options)[source]

Bases: object

Options supplied to characteristic write functions. Generally you can ignore these unless you have a long characteristic (eg > 48 bytes) or you have some specific authorization requirements.

Parameters:

options (Dict[str, Variant])

property device: str

The path of the remote device on the system dbus or None.

The link type.

property mtu: int

The exchanged Maximum Transfer Unit of the connection with the remote device or 0.

property offset: int

A byte offset to use when writing to this characteristic.

property prepare_authorize: bool

True if prepare authorization request. False otherwise.

property type: CharacteristicWriteType | None

The type of write operation requested or None.

class bluez_peripheral.gatt.characteristic.CharacteristicWriteType(value)[source]

Bases: Enum

Possible value of the CharacteristicWriteOptions.type field

COMMAND = 0

Write without response

RELIABLE = 2

Reliable Write

REQUEST = 1

Write with response

class bluez_peripheral.gatt.characteristic.characteristic(uuid, flags=<CharacteristicFlags.READ: 2>)[source]

Bases: ServiceAttribute[CharacteristicReadOptions, CharacteristicWriteOptions], HierarchicalServiceInterface

Create a new characteristic with a specified UUID and flags. Represents an org.bluez.GattCharacteristic1 instance.

Parameters:
add_child(child)[source]

Adds a child service interface.

Parameters:

child (HierarchicalServiceInterface)

Return type:

None

add_descriptor(desc)[source]

Associated a descriptor with this characteristic.

Parameters:

desc (descriptor)

Return type:

None

changed(new_value)[source]

Call this function when the value of a notifiable or indicatable property changes to alert any subscribers.

Parameters:

new_value (bytes) – The new value of the property to send to any subscribers.

Return type:

None

descriptor(uuid, flags=<DescriptorFlags.READ: 1>)[source]

Create a new descriptor with the specified UUID and Flags.

Parameters:
Return type:

descriptor

property service: Service | None

Gets the service that this attribute is a child of.