Skip to main content

Virtual Bluetooth controller

Project description

RootCanal

Binding to the RootCanal controller implementation. Enables virtual testing of Bluetooth applications directly in Python.

Usage

from rootcanal.controller import Controller
from rootcanal.bluetooth import Address
import hci_packets as hci
import llcp_packets as llcp
import lmp_packets as lmp
import ll_packets as ll

controller = Controller::new(Address("ca:fe:ca:fe:00:00"))

# Send HCI Reset to the controller and wait for the response.
controller.send_cmd(hci.Reset())
_ = await controller.expect_evt(hci.ResetCommplete)

# Enable page scan.
controller.send_cmd(hci.WriteScanEnable(scan_enable=hci.ScanEnable.PAGE_SCAN_ONLY))
_ = await controller.expect_evt(hci.WriteScanEnableComplete)

# Send classic connection request.
controller.send_ll(
    ll.Page(
        class_of_device=0,
        allow_role_switch=0,
        source_address=Address("11:11:11:11:11:11")))
_ = await controller.expect_evt(hci.ConnectionRequest)

# Accept the connection request.
_ = await controller.send_cmd(
    hci.AcceptConnectionRequest(
        bd_addr=Address("11:11:11:11:11:11"),
        role=hci.AcceptConnectionRequestRole.REMAIN_PERIPHERAL))
_ = await controller.expect_evt(hci.AcceptConnectionRequestStatus)
_ = await controller.expect_ll(hci.PageResponse)
_ = await controller.expect_evt(hci.ConnectionComplete)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

rootcanal-1.3.0-py3-none-any.whl (21.3 MB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page