Skip to content

Commit 349983a

Browse files
committed
py/bitbox02: add boolean to get_info tuple resp.
The device now returns an additional byte from REQ_INFO: 0x00 if the device is not initialized and 0x01 if it is. Read this byte in get_info from the REQ_INFO response in case the firmware version supports it, and add it to the tuple that is returned, None if the firmware does not support it yet.
1 parent c7783a7 commit 349983a

File tree

4 files changed

+21
-10
lines changed

4 files changed

+21
-10
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ endif()
9696
#
9797
# Versions MUST contain three parts and start with lowercase 'v'.
9898
# Example 'v1.0.0'. They MUST not contain a pre-release label such as '-beta'.
99-
set(FIRMWARE_VERSION "v9.19.0")
100-
set(FIRMWARE_BTC_ONLY_VERSION "v9.19.0")
99+
set(FIRMWARE_VERSION "v9.20.0")
100+
set(FIRMWARE_BTC_ONLY_VERSION "v9.20.0")
101101
set(BOOTLOADER_VERSION "v1.0.6")
102102

103103
find_package(PythonInterp 3.6 REQUIRED)

py/bitbox02/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## [Unreleased]
44

5+
# 7.0.0
6+
- get_info: add optional device initialized boolean to returned tuple
7+
58
# 6.3.0
69
- Allow infering product and version via API call instead of via USB descriptor
710
- Accept EIP1559 transactions in `eth_sign()` - requires BitBox02 firmware v9.16.0

py/bitbox02/bitbox02/bitbox02/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from __future__ import print_function
1717
import sys
1818

19-
__version__ = "6.3.0"
19+
__version__ = "7.0.0"
2020

2121
if sys.version_info.major != 3 or sys.version_info.minor < 6:
2222
print(

py/bitbox02/bitbox02/communication/bitbox_api_protocol.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ def __init__(
546546
elif device_info["product_string"] == BITBOX02BTC:
547547
edition = BitBox02Edition.BTCONLY
548548
else:
549-
version, _, edition, _ = self.get_info(transport)
549+
version, _, edition, _, _ = self.get_info(transport)
550550

551551
self.edition = edition
552552
try:
@@ -680,11 +680,14 @@ def reboot(
680680
return True
681681

682682
@staticmethod
683-
def get_info(transport: TransportLayer) -> Tuple[str, Platform, Union[BitBox02Edition], bool]:
683+
def get_info(
684+
transport: TransportLayer,
685+
) -> Tuple[str, Platform, Union[BitBox02Edition], bool, Optional[bool]]:
684686
"""
685-
Returns (version, platform, edition, unlocked).
686-
This is useful to get the version of the firmware when a usb descriptor is not available
687-
(via BitBoxBridge, etc.).
687+
Returns (version, platform, edition, unlocked, initialized).
688+
This is useful to get the version of the firmware or the device unlocked/initialized status
689+
when a usb descriptor is not available (via BitBoxBridge, etc.). The initialized status is
690+
supported from firmware v9.20.0 (it is None if not supported).
688691
This call does not use a versioned BitBoxProtocol for communication, as the version is not
689692
available (this call is used to get the version), so it must work for all firmware versions.
690693
"""
@@ -704,9 +707,14 @@ def get_info(transport: TransportLayer) -> Tuple[str, Platform, Union[BitBox02Ed
704707
else:
705708
raise Exception("Unknown platform: {}".format(platform))
706709

707-
unlocked_byte = response[0]
710+
unlocked_byte, response = response[0], response[1:]
708711
unlocked = {0x00: False, 0x01: True}[unlocked_byte]
709-
return (version_str, platform, edition, unlocked)
712+
713+
initialized = None
714+
if parse_device_version(version_str) >= semver.VersionInfo(9, 20, 0):
715+
initialized_byte = response[0]
716+
initialized = {0x00: False, 0x01: True}[initialized_byte]
717+
return (version_str, platform, edition, unlocked, initialized)
710718

711719
def check_min_version(self) -> None:
712720
"""

0 commit comments

Comments
 (0)