mirror of
https://github.com/google/bumble.git
synced 2026-05-09 04:08:02 +00:00
Add definition of Client Characteristic Configuration bit
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
# Imports
|
# Imports
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import enum
|
||||||
import types
|
import types
|
||||||
import logging
|
import logging
|
||||||
from colors import color
|
from colors import color
|
||||||
@@ -473,3 +474,12 @@ class Descriptor(Attribute):
|
|||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f'Descriptor(handle=0x{self.handle:04X}, type={self.type}, value={self.read_value(None).hex()})'
|
return f'Descriptor(handle=0x{self.handle:04X}, type={self.type}, value={self.read_value(None).hex()})'
|
||||||
|
|
||||||
|
|
||||||
|
class ClientCharacteristicConfigurationBits(enum.IntFlag):
|
||||||
|
'''
|
||||||
|
See Vol 3, Part G - 3.3.3.3 - Table 3.11 Client Characteristic Configuration bit field definition
|
||||||
|
'''
|
||||||
|
DEFAULT = 0x0000
|
||||||
|
NOTIFICATION = 0x0001
|
||||||
|
INDICATION = 0x0002
|
||||||
|
|||||||
@@ -37,7 +37,8 @@ from .gatt import (
|
|||||||
GATT_PRIMARY_SERVICE_ATTRIBUTE_TYPE,
|
GATT_PRIMARY_SERVICE_ATTRIBUTE_TYPE,
|
||||||
GATT_SECONDARY_SERVICE_ATTRIBUTE_TYPE,
|
GATT_SECONDARY_SERVICE_ATTRIBUTE_TYPE,
|
||||||
GATT_CHARACTERISTIC_ATTRIBUTE_TYPE,
|
GATT_CHARACTERISTIC_ATTRIBUTE_TYPE,
|
||||||
Characteristic
|
Characteristic,
|
||||||
|
ClientCharacteristicConfigurationBits
|
||||||
)
|
)
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
@@ -558,13 +559,13 @@ class Client:
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Set the subscription bits and select the subscriber set
|
# Set the subscription bits and select the subscriber set
|
||||||
bits = 0
|
bits = ClientCharacteristicConfigurationBits.DEFAULT
|
||||||
subscriber_sets = []
|
subscriber_sets = []
|
||||||
if characteristic.properties & Characteristic.NOTIFY:
|
if characteristic.properties & Characteristic.NOTIFY:
|
||||||
bits |= 0x0001
|
bits |= ClientCharacteristicConfigurationBits.NOTIFICATION
|
||||||
subscriber_sets.append(self.notification_subscribers.setdefault(characteristic.handle, set()))
|
subscriber_sets.append(self.notification_subscribers.setdefault(characteristic.handle, set()))
|
||||||
if characteristic.properties & Characteristic.INDICATE:
|
if characteristic.properties & Characteristic.INDICATE:
|
||||||
bits |= 0x0002
|
bits |= ClientCharacteristicConfigurationBits.INDICATION
|
||||||
subscriber_sets.append(self.indication_subscribers.setdefault(characteristic.handle, set()))
|
subscriber_sets.append(self.indication_subscribers.setdefault(characteristic.handle, set()))
|
||||||
|
|
||||||
# Add subscribers to the sets
|
# Add subscribers to the sets
|
||||||
|
|||||||
Reference in New Issue
Block a user