forked from auracaster/bumble_mirror
Compare commits
1 Commits
v0.0.160
...
gbg/defaul
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2c76bec7dc |
@@ -58,7 +58,7 @@ from .hci import (
|
||||
HCI_MITM_REQUIRED_GENERAL_BONDING_AUTHENTICATION_REQUIREMENTS,
|
||||
HCI_MITM_REQUIRED_NO_BONDING_AUTHENTICATION_REQUIREMENTS,
|
||||
HCI_NO_INPUT_NO_OUTPUT_IO_CAPABILITY,
|
||||
HCI_R2_PAGE_SCAN_REPETITION_MODE,
|
||||
HCI_R0_PAGE_SCAN_REPETITION_MODE,
|
||||
HCI_REMOTE_USER_TERMINATED_CONNECTION_ERROR,
|
||||
HCI_SUCCESS,
|
||||
HCI_WRITE_LE_HOST_SUPPORT_COMMAND,
|
||||
@@ -1842,7 +1842,7 @@ class Device(CompositeEventEmitter):
|
||||
HCI_Create_Connection_Command(
|
||||
bd_addr=peer_address,
|
||||
packet_type=0xCC18, # FIXME: change
|
||||
page_scan_repetition_mode=HCI_R2_PAGE_SCAN_REPETITION_MODE,
|
||||
page_scan_repetition_mode=HCI_R0_PAGE_SCAN_REPETITION_MODE,
|
||||
clock_offset=0x0000,
|
||||
allow_role_switch=0x01,
|
||||
reserved=0,
|
||||
@@ -2851,22 +2851,18 @@ class Device(CompositeEventEmitter):
|
||||
method = methods[peer_io_capability][io_capability]
|
||||
|
||||
async def reply() -> None:
|
||||
try:
|
||||
if await connection.abort_on('disconnection', method()):
|
||||
await self.host.send_command(
|
||||
HCI_User_Confirmation_Request_Reply_Command( # type: ignore[call-arg]
|
||||
bd_addr=connection.peer_address
|
||||
)
|
||||
if await connection.abort_on('disconnection', method()):
|
||||
await self.host.send_command(
|
||||
HCI_User_Confirmation_Request_Reply_Command( # type: ignore[call-arg]
|
||||
bd_addr=connection.peer_address
|
||||
)
|
||||
)
|
||||
else:
|
||||
await self.host.send_command(
|
||||
HCI_User_Confirmation_Request_Negative_Reply_Command( # type: ignore[call-arg]
|
||||
bd_addr=connection.peer_address
|
||||
)
|
||||
return
|
||||
except Exception as error:
|
||||
logger.warning(f'exception while confirming: {error}')
|
||||
|
||||
await self.host.send_command(
|
||||
HCI_User_Confirmation_Request_Negative_Reply_Command( # type: ignore[call-arg]
|
||||
bd_addr=connection.peer_address
|
||||
)
|
||||
)
|
||||
|
||||
AsyncRunner.spawn(reply())
|
||||
|
||||
@@ -2878,25 +2874,21 @@ class Device(CompositeEventEmitter):
|
||||
pairing_config = self.pairing_config_factory(connection)
|
||||
|
||||
async def reply() -> None:
|
||||
try:
|
||||
number = await connection.abort_on(
|
||||
'disconnection', pairing_config.delegate.get_number()
|
||||
)
|
||||
if number is not None:
|
||||
await self.host.send_command(
|
||||
HCI_User_Passkey_Request_Reply_Command( # type: ignore[call-arg]
|
||||
bd_addr=connection.peer_address, numeric_value=number
|
||||
)
|
||||
)
|
||||
return
|
||||
except Exception as error:
|
||||
logger.warning(f'exception while asking for pass-key: {error}')
|
||||
|
||||
await self.host.send_command(
|
||||
HCI_User_Passkey_Request_Negative_Reply_Command( # type: ignore[call-arg]
|
||||
bd_addr=connection.peer_address
|
||||
)
|
||||
number = await connection.abort_on(
|
||||
'disconnection', pairing_config.delegate.get_number()
|
||||
)
|
||||
if number is not None:
|
||||
await self.host.send_command(
|
||||
HCI_User_Passkey_Request_Reply_Command( # type: ignore[call-arg]
|
||||
bd_addr=connection.peer_address, numeric_value=number
|
||||
)
|
||||
)
|
||||
else:
|
||||
await self.host.send_command(
|
||||
HCI_User_Passkey_Request_Negative_Reply_Command( # type: ignore[call-arg]
|
||||
bd_addr=connection.peer_address
|
||||
)
|
||||
)
|
||||
|
||||
AsyncRunner.spawn(reply())
|
||||
|
||||
|
||||
@@ -858,13 +858,10 @@ class Session:
|
||||
self.tk = self.passkey.to_bytes(16, byteorder='little')
|
||||
logger.debug(f'TK from passkey = {self.tk.hex()}')
|
||||
|
||||
try:
|
||||
self.connection.abort_on(
|
||||
'disconnection',
|
||||
self.pairing_config.delegate.display_number(self.passkey, digits=6),
|
||||
)
|
||||
except Exception as error:
|
||||
logger.warning(f'exception while displaying number: {error}')
|
||||
self.connection.abort_on(
|
||||
'disconnection',
|
||||
self.pairing_config.delegate.display_number(self.passkey, digits=6),
|
||||
)
|
||||
|
||||
def input_passkey(self, next_steps: Optional[Callable[[], None]] = None) -> None:
|
||||
# Prompt the user for the passkey displayed on the peer
|
||||
@@ -1303,11 +1300,7 @@ class Session:
|
||||
self, command: SMP_Pairing_Request_Command
|
||||
) -> None:
|
||||
# Check if the request should proceed
|
||||
try:
|
||||
accepted = await self.pairing_config.delegate.accept()
|
||||
except Exception as error:
|
||||
logger.warning(f'exception while accepting: {error}')
|
||||
accepted = False
|
||||
accepted = await self.pairing_config.delegate.accept()
|
||||
if not accepted:
|
||||
logger.debug('pairing rejected by delegate')
|
||||
self.send_pairing_failed(SMP_PAIRING_NOT_SUPPORTED_ERROR)
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
WEBSOCKET CLIENT TRANSPORT
|
||||
==========================
|
||||
UDP TRANSPORT
|
||||
=============
|
||||
|
||||
The WebSocket Client transport is WebSocket connection to a WebSocket server over which HCI packets
|
||||
are sent and received.
|
||||
The UDP transport is a UDP socket, receiving packets on a specified port number, and sending packets to a specified host and port number.
|
||||
|
||||
## Moniker
|
||||
The moniker syntax for a WebSocket Client transport is: `ws-client:<ws-url>`
|
||||
The moniker syntax for a UDP transport is: `udp:<local-host>:<local-port>,<remote-host>:<remote-port>`.
|
||||
|
||||
!!! example
|
||||
`ws-client:ws://localhost:1234/some/path`
|
||||
`udp:0.0.0.0:9000,127.0.0.1:9001`
|
||||
UDP transport where packets are received on port `9000` and sent to `127.0.0.1` on port `9001`
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
WEBSOCKET SERVER TRANSPORT
|
||||
==========================
|
||||
UDP TRANSPORT
|
||||
=============
|
||||
|
||||
The WebSocket Server transport is WebSocket server that accepts connections from a WebSocket
|
||||
client. HCI packets are sent and received over the connection.
|
||||
The UDP transport is a UDP socket, receiving packets on a specified port number, and sending packets to a specified host and port number.
|
||||
|
||||
## Moniker
|
||||
The moniker syntax for a WebSocket Server transport is: `ws-server:<host>:<port>`,
|
||||
where `<host>` may be the address of a local network interface, or `_`to accept connections on all local network interfaces. `<port>` is the TCP port number on which to accept connections.
|
||||
|
||||
The moniker syntax for a UDP transport is: `udp:<local-host>:<local-port>,<remote-host>:<remote-port>`.
|
||||
|
||||
!!! example
|
||||
`ws-server:_:9001`
|
||||
`udp:0.0.0.0:9000,127.0.0.1:9001`
|
||||
UDP transport where packets are received on port `9000` and sent to `127.0.0.1` on port `9001`
|
||||
|
||||
@@ -62,7 +62,7 @@ async def main():
|
||||
print(
|
||||
f'>>> {color(advertisement.address, address_color)} '
|
||||
f'[{color(address_type_string, type_color)}]'
|
||||
f'{address_qualifier}:{separator}RSSI: {advertisement.rssi}'
|
||||
f'{address_qualifier}:{separator}RSSI:{advertisement.rssi}'
|
||||
f'{separator}'
|
||||
f'{advertisement.data.to_string(separator)}'
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user