1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-05-28 03:38:46 +00:00

refactor(core): ignore BLE exceptions on boot

[no changelog]
This commit is contained in:
Martin Milata 2025-04-16 21:20:40 +02:00
parent 927ad3944b
commit 5b2e660f14
4 changed files with 25 additions and 10 deletions

View File

@ -590,7 +590,11 @@ env.Ignore(hdr_moduledefs, qstr_generated)
if FROZEN:
SOURCE_PY_DIR = 'src/'
SOURCE_PY = Glob(SOURCE_PY_DIR + '*.py')
SOURCE_PY = Glob(SOURCE_PY_DIR + '*.py',
exclude=[
SOURCE_PY_DIR + 'ble.py',
] if "ble" not in FEATURES_AVAILABLE else []
)
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/*.py',
exclude=[
SOURCE_PY_DIR + 'trezor/sdcard.py',

View File

@ -645,7 +645,11 @@ env.Ignore(micropy_defines, qstr_generated)
if FROZEN:
SOURCE_PY_DIR = 'src/'
SOURCE_PY = Glob(SOURCE_PY_DIR + '*.py')
SOURCE_PY = Glob(SOURCE_PY_DIR + '*.py',
exclude=[
SOURCE_PY_DIR + 'ble.py',
] if "ble" not in FEATURES_AVAILABLE else []
)
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/*.py',
exclude=[
SOURCE_PY_DIR + 'trezor/sdcard.py',

12
core/src/ble.py Normal file
View File

@ -0,0 +1,12 @@
import storage.device
import trezorble as ble
from trezor import log
try:
ble.start_comm()
# allow connections from bonded peers if any
if ble.peer_count() > 0:
ble.start_advertising(True, storage.device.get_label())
except Exception as e:
log.exception(__name__, e)

View File

@ -49,14 +49,9 @@ usb.bus.open(storage.device.get_device_id())
# enable BLE, allow connections
if utils.USE_BLE:
import trezorble as ble
ble.start_comm()
# allow connections from bonded peers if any
if ble.peer_count() > 0:
ble.start_advertising(True, storage.device.get_label())
del ble
with utils.unimport():
import ble # noqa: F401
del ble
# run the endless loop