bluez_peripheral.gatt.characteristic module
- class bluez_peripheral.gatt.characteristic.CharacteristicFlags(value)
Flags to use when specifying the read/ write routines that can be used when accessing the characteristic. These are converted to bluez flags some of which are not clearly documented.
- 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 advertisments.
- 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_WRITEorCharacteristicFlags.WRITABLE_AUXILIARIESflag is used.
- INDICATE = 32
Characteristic may be subscribed to in order to provide indication when its value changes. Indication requires acknowledgement.
- NOTIFY = 16
Characteristic may be subscribed to in order to provide notification when its value changes. Notification does not require acknowledgement.
- 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)
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.
- property device
The path of the remote device on the system dbus or None.
- property mtu: Optional[int]
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)
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.
- property device
The path of the remote device on the system dbus or None.
- property link
The link type.
- property mtu
The exchanged Maximum Transfer Unit of the connection with the remote device or 0.
- property offset
A byte offset to use when writing to this characteristic.
- property prepare_authorize
True if prepare authorization request. False otherwise.
- property type
The type of write operation requested or None.
- class bluez_peripheral.gatt.characteristic.CharacteristicWriteType(value)
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: Union[BTUUID, str], flags: CharacteristicFlags = CharacteristicFlags.READ)
Create a new characteristic with a specified UUID and flags.
- Parameters
uuid (Union[BTUUID, str]) – The UUID of the GATT characteristic. A list of standard ids is provided by the Bluetooth SIG
flags (CharacteristicFlags, optional) – Flags defining the possible read/ write behaviour of the attribute.
- __call__(getter_func: Callable[[Service, CharacteristicReadOptions], bytes] = None, setter_func: Callable[[Service, bytes, CharacteristicWriteOptions], None] = None) characteristic
A decorator for characteristic value getters.
- Parameters
get (Callable[[Service, CharacteristicReadOptions], bytes], optional) – The getter function for this characteristic.
set (Callable[[Service, bytes, CharacteristicWriteOptions], optional) – The setter function for this characteristic.
- Returns
This characteristic.
- Return type
- add_descriptor(desc: descriptor)
Associate the specified descriptor with this characteristic.
- Parameters
desc (descriptor) – The descriptor to associate.
- Raises
ValueError – Raised when the containing service is currently registered and thus cannot be modified.
- changed(new_value: bytes)
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.
- descriptor(uuid: Union[BTUUID, str], flags: DescriptorFlags = DescriptorFlags.READ) descriptor
Create a new descriptor with the specified UUID and Flags.
- Parameters
uuid (Union[BTUUID, str]) – The UUID of the descriptor.
flags (DescriptorFlags, optional) – Any descriptor access flags to use.
- remove_descriptor(desc: descriptor)
Remove the specified descriptor from this characteristic.
- Parameters
desc (descriptor) – The descriptor to remove.
- Raises
ValueError – Raised when the containing service is currently registered and thus cannot be modified.
- setter(setter_func: Callable[[Service, bytes, CharacteristicWriteOptions], None]) characteristic
A decorator for characteristic value setters.