-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
I have been using a Feather Sense in a project and noticed that about once a day it would go into safe mode. After some testing I have narrowed it down to specific values for the timeout of start_scan()
. Large values (for example 0.1) seem fine and the code runs for several days. Very small values (for example 0.01) are simply ignored so that start_scan()
never times out. Values in between (for example 0.05) run fine for a few hours or sometimes even a day but eventually cause the Feather to go into safe mode.
My setup for testing was the following:
One ItsyBitsy nRF52840 running the unmodified ble_adafruit_simpletest.py example code.
One Feather nRF52840 Sense running a modified version of the ble_adafruit_simpletest_client.py example (below).
import time
import adafruit_ble
from adafruit_ble_adafruit.adafruit_service import AdafruitServerAdvertisement
import supervisor
ble = adafruit_ble.BLERadio()
connection = None
print("Scanning for an Adafruit Server advertisement...")
for adv in ble.start_scan(AdafruitServerAdvertisement, timeout=0.05):
print("about to connect")
connection = ble.connect(adv)
print("connected")
break
ble.stop_scan()
supervisor.reload()
The last line printed to the REPL is "about to connect".
The safe mode message I get is the following:
Auto-reload is off.
Running in safe mode! Not running saved code.
You are in safe mode: something unanticipated happened.
CircuitPython core code crashed hard. Whoops!
Nordic Soft Device failure assertion.
Please file an issue with the contents of your CIRCUITPY drive at
https://github.com/adafruit/circuitpython/issues
Press any key to enter the REPL. Use CTRL-D to reload.
For my project I will just increase the timeout to 0.1 but since it took me a while to identify the issue I thought I would share. I did most of the testing running beta versions of 6.0.0 but after updating CircuitPython to the final 6.0.0 and updating the libraries the behavior is still the same.