Merge pull request #676 from google/gbg/bt-bench-fixes

fix numeric entries and phy request
This commit is contained in:
Gilles Boccon-Gibod
2025-04-24 17:27:55 -07:00
committed by GitHub
6 changed files with 28 additions and 9 deletions

View File

@@ -1291,8 +1291,10 @@ class Central(Connection.Listener):
logging.info(color('### Connected', 'cyan'))
self.connection.listener = self
print_connection(self.connection)
phy = await self.connection.get_phy()
print_connection_phy(phy)
if not self.classic:
phy = await self.connection.get_phy()
print_connection_phy(phy)
# Switch roles if needed.
if self.role_switch:

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

View File

@@ -381,7 +381,7 @@ fun MainView(
label = {
Text(text = "Packet Interval (ms)")
},
value = appViewModel.senderPacketInterval.toString(),
value = (if (appViewModel.senderPacketInterval != 0) appViewModel.senderPacketInterval else "").toString(),
modifier = Modifier
.fillMaxWidth()
.focusRequester(focusRequester),
@@ -389,7 +389,9 @@ fun MainView(
keyboardType = KeyboardType.Number, imeAction = ImeAction.Done
),
onValueChange = {
if (it.isNotEmpty()) {
if (it.isEmpty()) {
appViewModel.updateSenderPacketInterval(0)
} else {
val interval = it.toIntOrNull()
if (interval != null) {
appViewModel.updateSenderPacketInterval(interval)

View File

@@ -27,8 +27,8 @@ val DEFAULT_RFCOMM_UUID: UUID = UUID.fromString("E6D55659-C8B4-4B85-96BB-B1143AF
const val DEFAULT_PEER_BLUETOOTH_ADDRESS = "AA:BB:CC:DD:EE:FF"
const val DEFAULT_STARTUP_DELAY = 3000
const val DEFAULT_SENDER_PACKET_COUNT = 100
const val DEFAULT_SENDER_PACKET_SIZE = 1024
const val DEFAULT_SENDER_PACKET_INTERVAL = 100
const val DEFAULT_SENDER_PACKET_SIZE = 970 // 970 is a value that works well on Android.
const val DEFAULT_SENDER_PACKET_INTERVAL = 0
const val DEFAULT_PSM = 128
const val L2CAP_CLIENT_MODE = "L2CAP Client"
@@ -192,7 +192,6 @@ class AppViewModel : ViewModel() {
} else if (senderPacketSizeSlider < 0.5F) {
512
} else if (senderPacketSizeSlider < 0.7F) {
// 970 is a value that works well on Android.
970
} else if (senderPacketSizeSlider < 0.9F) {
2048