forked from auracaster/bumble_mirror
add workaround for some buggy controllers
This commit is contained in:
@@ -616,22 +616,28 @@ class Host(utils.EventEmitter):
|
|||||||
if self.supports_command(
|
if self.supports_command(
|
||||||
hci.HCI_LE_READ_NUMBER_OF_SUPPORTED_ADVERTISING_SETS_COMMAND
|
hci.HCI_LE_READ_NUMBER_OF_SUPPORTED_ADVERTISING_SETS_COMMAND
|
||||||
):
|
):
|
||||||
response10 = await self.send_sync_command(
|
try:
|
||||||
hci.HCI_LE_Read_Number_Of_Supported_Advertising_Sets_Command()
|
response10 = await self.send_sync_command(
|
||||||
)
|
hci.HCI_LE_Read_Number_Of_Supported_Advertising_Sets_Command()
|
||||||
self.number_of_supported_advertising_sets = (
|
)
|
||||||
response10.num_supported_advertising_sets
|
self.number_of_supported_advertising_sets = (
|
||||||
)
|
response10.num_supported_advertising_sets
|
||||||
|
)
|
||||||
|
except hci.HCI_Error:
|
||||||
|
logger.warning('Failed to read number of supported advertising sets')
|
||||||
|
|
||||||
if self.supports_command(
|
if self.supports_command(
|
||||||
hci.HCI_LE_READ_MAXIMUM_ADVERTISING_DATA_LENGTH_COMMAND
|
hci.HCI_LE_READ_MAXIMUM_ADVERTISING_DATA_LENGTH_COMMAND
|
||||||
):
|
):
|
||||||
response11 = await self.send_sync_command(
|
try:
|
||||||
hci.HCI_LE_Read_Maximum_Advertising_Data_Length_Command()
|
response11 = await self.send_sync_command(
|
||||||
)
|
hci.HCI_LE_Read_Maximum_Advertising_Data_Length_Command()
|
||||||
self.maximum_advertising_data_length = (
|
)
|
||||||
response11.max_advertising_data_length
|
self.maximum_advertising_data_length = (
|
||||||
)
|
response11.max_advertising_data_length
|
||||||
|
)
|
||||||
|
except hci.HCI_Error:
|
||||||
|
logger.warning('Failed to read maximum advertising data length')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def controller(self) -> TransportSink | None:
|
def controller(self) -> TransportSink | None:
|
||||||
@@ -776,6 +782,20 @@ class Host(utils.EventEmitter):
|
|||||||
) -> hci.HCI_Command_Complete_Event[_RP]:
|
) -> hci.HCI_Command_Complete_Event[_RP]:
|
||||||
response = await self._send_command(command, response_timeout)
|
response = await self._send_command(command, response_timeout)
|
||||||
|
|
||||||
|
# Some buggy controllers return Command Status instead of Command Complete...
|
||||||
|
if isinstance(response, hci.HCI_Command_Status_Event):
|
||||||
|
logger.warning(
|
||||||
|
f'expected Command Complete for {command.name}, '
|
||||||
|
'but got Command Status instead'
|
||||||
|
)
|
||||||
|
return hci.HCI_Command_Complete_Event(
|
||||||
|
num_hci_command_packets=response.num_hci_command_packets,
|
||||||
|
command_opcode=command.op_code,
|
||||||
|
return_parameters=hci.HCI_StatusReturnParameters(
|
||||||
|
status=hci.HCI_ErrorCode(response.status)
|
||||||
|
), # type: ignore
|
||||||
|
)
|
||||||
|
|
||||||
# Check that the response is of the expected type
|
# Check that the response is of the expected type
|
||||||
assert isinstance(response, hci.HCI_Command_Complete_Event)
|
assert isinstance(response, hci.HCI_Command_Complete_Event)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user