blatann.gatt.gattc_attribute module

class blatann.gatt.gattc_attribute.GattcAttribute(uuid, handle, read_write_manager, initial_value=b'', string_encoding='utf8')

Bases: Attribute

Represents a client-side interface to a single attribute which lives inside a Characteristic

property on_read_complete: Event[GattcAttribute, ReadCompleteEventArgs]

Event that is triggered when a read from the attribute is completed

property on_write_complete: Event[GattcAttribute, WriteCompleteEventArgs]

Event that is triggered when a write to the attribute is completed

read()

Performs a read of the attribute and returns a Waitable that executes when the read finishes with the data read.

Return type

IdBasedEventWaitable[GattcAttribute, ReadCompleteEventArgs]

Returns

A waitable that will trigger when the read finishes

write(data, with_response=True)

Initiates a write of the data provided to the attribute and returns a Waitable that executes when the write completes and the confirmation response is received from the other device.

Parameters
  • data (str or bytes or bytearray) – The data to write. Can be a string, bytes, or anything that can be converted to bytes

  • with_response – Used internally for characteristics that support write without responses. Should always be true for any other case (descriptors, etc.).

Return type

IdBasedEventWaitable[GattcAttribute, WriteCompleteEventArgs]

Returns

A waitable that returns when the write finishes

update(value)

Used internally to update the value after data is received from another means, i.e. Indication/notification. Should not be called by the user.