How to use the bitbox02.BitBox02 function in bitbox02

To help you get started, we’ve selected a few bitbox02 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github digitalbitbox / bitbox02-firmware / py / send_message.py View on Github external
else:

        def show_pairing(code: str) -> bool:
            print("Please compare and confirm the pairing code on your BitBox02:")
            print(code)
            return True

        def attestation_check(result: bool) -> None:
            if result:
                print("Device attestation PASSED")
            else:
                print("Device attestation FAILED")

        hid_device = hid.device()
        hid_device.open_path(bitbox["path"])
        bitbox_connection = bitbox02.BitBox02(
            transport=u2fhid.U2FHid(hid_device),
            device_info=bitbox,
            show_pairing_callback=show_pairing,
            attestation_check_callback=attestation_check,
        )

        if debug:
            print("Device Info:")
            pprint.pprint(bitbox)
        return SendMessage(bitbox_connection, debug).run()
github digitalbitbox / bitbox02-firmware / py / load_firmware.py View on Github external
def _get_bitbox_and_reboot() -> devices.DeviceInfo:
    """Search for a bitbox and then reboot it into bootloader"""
    device = devices.get_any_bitbox02()

    # bitbox02 detected -> send command to reboot into bootloader to upgrade.
    def _show_pairing(code: str) -> None:
        print("Please compare and confirm the pairing code on your BitBox02:")
        print(code)

    hid_device = hid.device()
    hid_device.open_path(device["path"])
    bitbox = BitBox02(
        transport=u2fhid.U2FHid(hid_device), device_info=device, show_pairing_callback=_show_pairing
    )
    bitbox.reboot()

    # wait for it to reboot
    while True:
        try:
            bootloader_device = devices.get_any_bitbox02_bootloader()
        except NoneFoundException:
            sys.stdout.write(".")
            sys.stdout.flush()
            sleep(1)
            continue
        return bootloader_device