Skip to content

Commit

Permalink
remove debug
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco committed Oct 8, 2024
1 parent 51a3054 commit a1e22cd
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
3 changes: 3 additions & 0 deletions src/habluetooth/base_scanner.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ cdef class BaseHaRemoteScanner(BaseHaScanner):
@cython.locals(
prev_name=str,
prev_details=dict,
num_service_uuids=Py_ssize_t,
num_service_data=Py_ssize_t,
num_manufacturer_data=Py_ssize_t,
service_info=BluetoothServiceInfoBleak,
prev_service_info=BluetoothServiceInfoBleak
)
Expand Down
36 changes: 27 additions & 9 deletions src/habluetooth/base_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,28 +412,46 @@ def _async_on_advertisement(
new_service_uuids.append(service_uuid)
service_info.service_uuids = new_service_uuids

if (
not service_data
or service_data.items() in prev_service_info.service_data.items()
):
num_service_data = len(service_data)
if not num_service_data:
service_info.service_data = prev_service_info.service_data
elif num_service_data == 1:
service_data_key = next(iter(service_data))
if service_data[service_data_key] == prev_service_info.service_data.get(
service_data_key
):
service_info.service_data = prev_service_info.service_data

Check warning on line 423 in src/habluetooth/base_scanner.py

View check run for this annotation

Codecov / codecov/patch

src/habluetooth/base_scanner.py#L423

Added line #L423 was not covered by tests
else:
service_info.service_data = {
**prev_service_info.service_data,
**service_data,
}
else:
service_info.service_data = {

Check warning on line 430 in src/habluetooth/base_scanner.py

View check run for this annotation

Codecov / codecov/patch

src/habluetooth/base_scanner.py#L430

Added line #L430 was not covered by tests
**prev_service_info.service_data,
**service_data,
}

if (
not manufacturer_data
or manufacturer_data.items()
in prev_service_info.manufacturer_data.items()
):
num_service_data = len(manufacturer_data)
if not num_service_data:
service_info.manufacturer_data = prev_service_info.manufacturer_data
elif num_service_data == 1:
manufacturer_data_key = next(iter(manufacturer_data))
if manufacturer_data[
manufacturer_data_key
] == prev_service_info.manufacturer_data.get(manufacturer_data_key):
service_info.manufacturer_data = prev_service_info.manufacturer_data

Check warning on line 443 in src/habluetooth/base_scanner.py

View check run for this annotation

Codecov / codecov/patch

src/habluetooth/base_scanner.py#L443

Added line #L443 was not covered by tests
else:
service_info.manufacturer_data = {
**prev_service_info.manufacturer_data,
**manufacturer_data,
}
else:
service_info.manufacturer_data = {

Check warning on line 450 in src/habluetooth/base_scanner.py

View check run for this annotation

Codecov / codecov/patch

src/habluetooth/base_scanner.py#L450

Added line #L450 was not covered by tests
**prev_service_info.manufacturer_data,
**manufacturer_data,
}

#
# Bleak updates the BLEDevice via create_or_update_device.
# We need to do the same to ensure integrations that already
Expand Down

0 comments on commit a1e22cd

Please sign in to comment.