diff --git a/bumble/device.py b/bumble/device.py index 97a32f3c..b1b423a9 100644 --- a/bumble/device.py +++ b/bumble/device.py @@ -3953,6 +3953,9 @@ class Device(utils.CompositeEventEmitter): return result.return_parameters.rssi async def get_connection_phy(self, connection: Connection) -> ConnectionPHY: + if not self.host.supports_command(hci.HCI_LE_READ_PHY_COMMAND): + return ConnectionPHY(hci.Phy.LE_1M, hci.Phy.LE_1M) + result = await self.send_command( hci.HCI_LE_Read_PHY_Command(connection_handle=connection.handle), check_result=True, diff --git a/bumble/hci.py b/bumble/hci.py index 1fa56bcd..4c9259ff 100644 --- a/bumble/hci.py +++ b/bumble/hci.py @@ -5825,12 +5825,18 @@ class HCI_LE_Advertising_Report_Event(HCI_LE_Meta_Event): return HCI_LE_Advertising_Report_Event.event_type_name(self.event_type) def to_string(self, indentation='', _=None): + def data_to_str(data): + try: + return data.hex() + ': ' + str(AdvertisingData.from_bytes(data)) + except Exception: + return data.hex() + return super().to_string( indentation, { 'event_type': HCI_LE_Advertising_Report_Event.event_type_name, 'address_type': Address.address_type_name, - 'data': lambda x: str(AdvertisingData.from_bytes(x)), + 'data': data_to_str, }, ) @@ -6055,12 +6061,18 @@ class HCI_LE_Extended_Advertising_Report_Event(HCI_LE_Meta_Event): def to_string(self, indentation='', _=None): # pylint: disable=line-too-long + def data_to_str(data): + try: + return data.hex() + ': ' + str(AdvertisingData.from_bytes(data)) + except Exception: + return data.hex() + return super().to_string( indentation, { 'event_type': HCI_LE_Extended_Advertising_Report_Event.event_type_string, 'address_type': Address.address_type_name, - 'data': lambda x: str(AdvertisingData.from_bytes(x)), + 'data': data_to_str, }, ) diff --git a/extras/android/BtBench/app/src/main/java/com/github/google/bumble/btbench/Advertiser.kt b/extras/android/BtBench/app/src/main/java/com/github/google/bumble/btbench/Advertiser.kt index b7370a80..17d1adea 100644 --- a/extras/android/BtBench/app/src/main/java/com/github/google/bumble/btbench/Advertiser.kt +++ b/extras/android/BtBench/app/src/main/java/com/github/google/bumble/btbench/Advertiser.kt @@ -26,6 +26,7 @@ class Advertiser(private val bluetoothAdapter: BluetoothAdapter) : AdvertiseCall @SuppressLint("MissingPermission") fun stop() { + Log.info("stopping advertiser") bluetoothAdapter.bluetoothLeAdvertiser.stopAdvertising(this) }