forked from auracaster/bumble_mirror
Merge pull request #164 from AlanRosenthal/alan/local-write
Add `local-write` to bumble-console
This commit is contained in:
@@ -750,10 +750,10 @@ class Attribute(EventEmitter):
|
||||
permissions_str.split(","),
|
||||
0,
|
||||
)
|
||||
except TypeError:
|
||||
except TypeError as exc:
|
||||
raise TypeError(
|
||||
f"Attribute::permissions error:\nExpected a string containing any of the keys, seperated by commas: {','.join(Attribute.PERMISSION_NAMES.values())}\nGot: {permissions_str}"
|
||||
)
|
||||
f"Attribute::permissions error:\nExpected a string containing any of the keys, separated by commas: {','.join(Attribute.PERMISSION_NAMES.values())}\nGot: {permissions_str}"
|
||||
) from exc
|
||||
|
||||
def __init__(self, attribute_type, permissions, value=b''):
|
||||
EventEmitter.__init__(self)
|
||||
|
||||
@@ -28,7 +28,7 @@ import enum
|
||||
import functools
|
||||
import logging
|
||||
import struct
|
||||
from typing import Optional, Sequence
|
||||
from typing import Optional, Sequence, List, Any, Iterable
|
||||
|
||||
from .colors import color
|
||||
from .core import UUID, get_dict_key_by_value
|
||||
@@ -259,6 +259,8 @@ class Characteristic(Attribute):
|
||||
See Vol 3, Part G - 3.3 CHARACTERISTIC DEFINITION
|
||||
'''
|
||||
|
||||
uuid: UUID
|
||||
|
||||
# Property flags
|
||||
BROADCAST = 0x01
|
||||
READ = 0x02
|
||||
@@ -325,6 +327,12 @@ class Characteristic(Attribute):
|
||||
|
||||
return None
|
||||
|
||||
def has_properties(self, properties: Iterable[int]):
|
||||
for prop in properties:
|
||||
if self.properties & prop == 0:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __str__(self):
|
||||
return (
|
||||
f'Characteristic(handle=0x{self.handle:04X}, '
|
||||
@@ -340,6 +348,8 @@ class CharacteristicDeclaration(Attribute):
|
||||
See Vol 3, Part G - 3.3.1 CHARACTERISTIC DECLARATION
|
||||
'''
|
||||
|
||||
characteristic: Characteristic
|
||||
|
||||
def __init__(self, characteristic, value_handle):
|
||||
declaration_bytes = (
|
||||
struct.pack('<BH', characteristic.properties, value_handle)
|
||||
|
||||
@@ -62,7 +62,6 @@ from .gatt import (
|
||||
GATT_PRIMARY_SERVICE_ATTRIBUTE_TYPE,
|
||||
GATT_REQUEST_TIMEOUT,
|
||||
GATT_SECONDARY_SERVICE_ATTRIBUTE_TYPE,
|
||||
Service,
|
||||
Characteristic,
|
||||
ClientCharacteristicConfigurationBits,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user