Description
CircuitPython version
Adafruit CircuitPython 9.1.1 on 2024-07-23; FeatherS3 with ESP32S3
Board ID:unexpectedmaker_feathers3
UID:0740D1DA1CCA
Code/REPL
import board
from adafruit_ble import BLERadio
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
from adafruit_ble.services.nordic import UARTService
import neopixel
import time
def monitor():
ble = BLERadio()
#uart = UARTService()
#advertisement = ProvideServicesAdvertisement(uart)
pix = neopixel.NeoPixel(board.NEOPIXEL,10)
tog = True
last_time_tog = time.monotonic()
while True:
try:
#connect to two uart devices.
while ble.connected and any(UARTService in connection for connection in ble.connections) and len(ble.connections) == 2:
try:
if right_paw_uart.in_waiting:
print(right_paw_uart.read(4))
if left_paw_uart.in_waiting:
print(left_paw_uart.read(4))
if time.monotonic()-last_time_tog>=1:
last_time_tog = time.monotonic()
print('here')
if tog:
pix.fill(0xff0000)
tog = not tog
else:
pix.fill(0)
tog = not tog
except ConnectionError:
print('NOT CONNECTED')
break
print("disconnected, scanning", len(ble.connections))
try:
for advertisement in ble.start_scan(ProvideServicesAdvertisement, timeout=1):
if UARTService not in advertisement.services:
continue
#ble.connect(advertisement)
if advertisement.complete_name == "RIGHTPAW":
right_paw = ble.connect(advertisement)
right_paw_uart = right_paw[UARTService]
if advertisement.complete_name == "LEFTPAW":
left_paw = ble.connect(advertisement)
left_paw_uart = left_paw[UARTService]
print(f"connected {advertisement.complete_name}")
break
except ConnectionError:
print('connection error:not connected')
ble.stop_scan()
except ConnectionError as er:
print('IDK its a connection error:',er)
time.sleep(1)
monitor()
Behavior
Board will connect to 2 devices "LEFTPAW" and "RIGHTPAW" normally, and receive messages as expected. Restarting one of the connected devices once is usually OK, code will reconnect normally. After a number of restarts of a connected device (sometimes up to 3 restarts) this board will hang, and then finally crash to safe mode.
Here is the caught error immediately before safe mode:
Connection has been disconnected and can no longer be used. Create a new connection.
And the safe mode message:
You are in safe mode because:
CircuitPython core code crashed hard. Whoops!
Hard fault: memory access or instruction error.
Please file an issue with your program at github.com/adafruit/circuitpython/issues.
Press reset to exit safe mode.
Description
No response
Additional information
I have similar code running without issue on a Feather NRF52840. The connected devices are Circuit Playground Bluefruit boards running CircuitPython.