bluez_peripheral.gatt.characteristic module¶
- class bluez_peripheral.gatt.characteristic.CharacteristicFlags(value)[source]¶
Bases:
FlagFlags 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_WRITEorCharacteristicFlags.WRITABLE_AUXILIARIESflag 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:
objectOptions 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.
- class bluez_peripheral.gatt.characteristic.CharacteristicWriteOptions(options)[source]¶
Bases:
objectOptions 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 mtu: int¶
The exchanged Maximum Transfer Unit of the connection with the remote device or 0.
- property type: CharacteristicWriteType | None¶
The type of write operation requested or None.
- class bluez_peripheral.gatt.characteristic.CharacteristicWriteType(value)[source]¶
Bases:
EnumPossible 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],HierarchicalServiceInterfaceCreate a new characteristic with a specified UUID and flags. Represents an org.bluez.GattCharacteristic1 instance.
- Parameters:
uuid (str | bytes | UUID | UUID16 | int) – The UUID of the GATT characteristic. A list of standard ids is provided by the Bluetooth SIG
flags (CharacteristicFlags) – Flags defining the possible read/ write behavior of the attribute.
See also
- 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