minor fix

This commit is contained in:
Gilles Boccon-Gibod
2025-04-24 17:22:25 -07:00
parent febed8179b
commit ab60b42b85
3 changed files with 18 additions and 2 deletions

View File

@@ -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,

View File

@@ -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,
},
)

View File

@@ -26,6 +26,7 @@ class Advertiser(private val bluetoothAdapter: BluetoothAdapter) : AdvertiseCall
@SuppressLint("MissingPermission")
fun stop() {
Log.info("stopping advertiser")
bluetoothAdapter.bluetoothLeAdvertiser.stopAdvertising(this)
}