forked from auracaster/bumble_mirror
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6e1baf0344 | |||
| cea1905ffb | |||
| af8e0d4dc7 | |||
| 875195aebb | |||
| 5aee37aeab | |||
| d4228e3b5b |
+1
-1
@@ -902,7 +902,7 @@ class LogHandler(logging.Handler):
|
||||
def __init__(self, app):
|
||||
super().__init__()
|
||||
self.app = app
|
||||
self.setFormatter("[%(asctime)s][%(pathname)s:%(lineno)d][%(levelname)s] %(message)s")
|
||||
self.setFormatter(logging.Formatter('[%(asctime)s][%(levelname)s] %(message)s'))
|
||||
|
||||
def emit(self, record):
|
||||
message = self.format(record)
|
||||
|
||||
+5
-2
@@ -1181,6 +1181,7 @@ class Device(CompositeEventEmitter):
|
||||
peer_address,
|
||||
transport=BT_LE_TRANSPORT,
|
||||
connection_parameters_preferences=None,
|
||||
own_address_type=Address.RANDOM_DEVICE_ADDRESS,
|
||||
timeout=DEVICE_DEFAULT_CONNECT_TIMEOUT
|
||||
):
|
||||
'''
|
||||
@@ -1190,6 +1191,8 @@ class Device(CompositeEventEmitter):
|
||||
connection_parameters_preferences: (BLE only, ignored for BR/EDR)
|
||||
* None: use all PHYs with default parameters
|
||||
* map: each entry has a PHY as key and a ConnectionParametersPreferences object as value
|
||||
|
||||
own_address_type: (BLE only)
|
||||
'''
|
||||
|
||||
# Check parameters
|
||||
@@ -1274,7 +1277,7 @@ class Device(CompositeEventEmitter):
|
||||
|
||||
result = await self.send_command(HCI_LE_Extended_Create_Connection_Command(
|
||||
initiator_filter_policy = 0,
|
||||
own_address_type = Address.RANDOM_DEVICE_ADDRESS,
|
||||
own_address_type = own_address_type,
|
||||
peer_address_type = peer_address.address_type,
|
||||
peer_address = peer_address,
|
||||
initiating_phys = initiating_phys,
|
||||
@@ -1298,7 +1301,7 @@ class Device(CompositeEventEmitter):
|
||||
initiator_filter_policy = 0,
|
||||
peer_address_type = peer_address.address_type,
|
||||
peer_address = peer_address,
|
||||
own_address_type = Address.RANDOM_DEVICE_ADDRESS,
|
||||
own_address_type = own_address_type,
|
||||
connection_interval_min = int(prefs.connection_interval_min / 1.25),
|
||||
connection_interval_max = int(prefs.connection_interval_max / 1.25),
|
||||
max_latency = prefs.max_latency,
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
# Imports
|
||||
# -----------------------------------------------------------------------------
|
||||
import asyncio
|
||||
import enum
|
||||
import types
|
||||
import logging
|
||||
from pyee import EventEmitter
|
||||
@@ -474,3 +475,12 @@ class Descriptor(Attribute):
|
||||
|
||||
def __str__(self):
|
||||
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_SECONDARY_SERVICE_ATTRIBUTE_TYPE,
|
||||
GATT_CHARACTERISTIC_ATTRIBUTE_TYPE,
|
||||
Characteristic
|
||||
Characteristic,
|
||||
ClientCharacteristicConfigurationBits
|
||||
)
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
@@ -558,13 +559,13 @@ class Client:
|
||||
return
|
||||
|
||||
# Set the subscription bits and select the subscriber set
|
||||
bits = 0
|
||||
bits = ClientCharacteristicConfigurationBits.DEFAULT
|
||||
subscriber_sets = []
|
||||
if characteristic.properties & Characteristic.NOTIFY:
|
||||
bits |= 0x0001
|
||||
bits |= ClientCharacteristicConfigurationBits.NOTIFICATION
|
||||
subscriber_sets.append(self.notification_subscribers.setdefault(characteristic.handle, set()))
|
||||
if characteristic.properties & Characteristic.INDICATE:
|
||||
bits |= 0x0002
|
||||
bits |= ClientCharacteristicConfigurationBits.INDICATION
|
||||
subscriber_sets.append(self.indication_subscribers.setdefault(characteristic.handle, set()))
|
||||
|
||||
# Add subscribers to the sets
|
||||
|
||||
Reference in New Issue
Block a user