Skip to content

Commit

Permalink
feat: refactor to be able to use __Pyx_PyObject_FastCall (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Dec 3, 2023
1 parent fd97d07 commit e15074b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
4 changes: 3 additions & 1 deletion src/habluetooth/base_scanner.pxd
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@


cdef object NO_RSSI_VALUE

cdef class BaseHaScanner:

cdef public str adapter
cdef public bint connectable
cdef public object connectable
cdef public str source
cdef public object connector
cdef public unsigned int _connecting
Expand Down
44 changes: 22 additions & 22 deletions src/habluetooth/base_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,10 @@ def _async_on_advertisement(
# near zero cost try on success, and we can avoid .get()
# which is slower than [] we use the try/except pattern.
device = BLEDevice(
address=address,
name=local_name,
details=self._details | details,
rssi=rssi, # deprecated, will be removed in newer bleak
address,
local_name,
self._details | details,
rssi, # deprecated, will be removed in newer bleak
)
else:
# Merge the new data with the old data
Expand Down Expand Up @@ -333,13 +333,13 @@ def _async_on_advertisement(
device._rssi = rssi # deprecated, will be removed in newer bleak

advertisement_data = AdvertisementData(
local_name=None if local_name == "" else local_name,
manufacturer_data=manufacturer_data,
service_data=service_data,
service_uuids=service_uuids,
tx_power=NO_RSSI_VALUE if tx_power is None else tx_power,
rssi=rssi,
platform_data=(),
None if local_name == "" else local_name,
manufacturer_data,
service_data,
service_uuids,
NO_RSSI_VALUE if tx_power is None else tx_power,
rssi,
(),
)
self._discovered_device_advertisement_datas[address] = (
device,
Expand All @@ -348,17 +348,17 @@ def _async_on_advertisement(
self._discovered_device_timestamps[address] = advertisement_monotonic_time
self._new_info_callback(
BluetoothServiceInfoBleak(
name=local_name or address,
address=address,
rssi=rssi,
manufacturer_data=manufacturer_data,
service_data=service_data,
service_uuids=service_uuids,
source=self.source,
device=device,
advertisement=advertisement_data,
connectable=self.connectable,
time=advertisement_monotonic_time,
local_name or address,
address,
rssi,
manufacturer_data,
service_data,
service_uuids,
self.source,
device,
advertisement_data,
self.connectable,
advertisement_monotonic_time,
)
)

Expand Down

0 comments on commit e15074b

Please sign in to comment.