mirror of
https://github.com/google/bumble.git
synced 2026-05-10 04:18:03 +00:00
Merge/rebase
This commit is contained in:
@@ -17,31 +17,25 @@
|
||||
# -----------------------------------------------------------------------------
|
||||
import logging
|
||||
import asyncio
|
||||
import sys
|
||||
import os
|
||||
|
||||
from bumble.controller import Controller
|
||||
import click
|
||||
|
||||
from bumble.controller import Controller, Options
|
||||
from bumble.link import LocalLink
|
||||
from bumble.transport import open_transport_or_link
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
async def async_main():
|
||||
if len(sys.argv) != 3:
|
||||
print(
|
||||
'Usage: controllers.py <hci-transport-1> <hci-transport-2> '
|
||||
'[<hci-transport-3> ...]'
|
||||
)
|
||||
print('example: python controllers.py pty:ble1 pty:ble2')
|
||||
return
|
||||
|
||||
async def async_main(extended_advertising, transport_names):
|
||||
# Create a local link to attach the controllers to
|
||||
link = LocalLink()
|
||||
|
||||
# Create a transport and controller for all requested names
|
||||
transports = []
|
||||
controllers = []
|
||||
for index, transport_name in enumerate(sys.argv[1:]):
|
||||
options = Options(extended_advertising=extended_advertising)
|
||||
for index, transport_name in enumerate(transport_names):
|
||||
transport = await open_transport_or_link(transport_name)
|
||||
transports.append(transport)
|
||||
controller = Controller(
|
||||
@@ -49,6 +43,7 @@ async def async_main():
|
||||
host_source=transport.source,
|
||||
host_sink=transport.sink,
|
||||
link=link,
|
||||
options=options,
|
||||
)
|
||||
controllers.append(controller)
|
||||
|
||||
@@ -61,9 +56,14 @@ async def async_main():
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
def main():
|
||||
logging.basicConfig(level=os.environ.get('BUMBLE_LOGLEVEL', 'INFO').upper())
|
||||
asyncio.run(async_main())
|
||||
@click.command()
|
||||
@click.option(
|
||||
'--extended-advertising', is_flag=True, help="Enable extended advertising"
|
||||
)
|
||||
@click.argument('transports', nargs=-1, required=True)
|
||||
def main(extended_advertising, transports):
|
||||
logging.basicConfig(level=os.environ.get('BUMBLE_LOGLEVEL', 'WARNING').upper())
|
||||
asyncio.run(async_main(extended_advertising, transports))
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user