Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLE/UART - Nordic dongle stops working - probably entering safe mode #9198

Open
gkecskes78 opened this issue Apr 23, 2024 · 5 comments
Open

Comments

@gkecskes78
Copy link

gkecskes78 commented Apr 23, 2024

CircuitPython version

Adafruit CircuitPython 9.0.4 on 2024-04-16; PCA10059 nRF52840 Dongle with nRF52840
Board ID:pca10059
UID:44AF58CE0AE80785

Code/REPL

import time, board, _bleio, pwmio
from adafruit_ble import BLERadio
from adafruit_ble.services.nordic import UARTService
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement

ble=BLERadio()
uart=UARTService()
advert=ProvideServicesAdvertisement(uart)
_bleio.adapter.enabled=True

time.sleep(2)
print('\n------------------- Start')
print('BLE addr: {}'.format(_bleio.adapter.address))
print('Device name: {}'.format(_bleio.adapter.name))
LED1=pwmio.PWMOut(board.LED1)

connected=False
counter=0
while True:
    if not ble.connected:
        if ble.advertising==False:
            ble.start_advertising(advert)
        if connected==True:
            LED1.duty_cycle=65535
            print("Connection lost")
        connected=False
    if ble.connected:
        if connected==False:
            counter+=1
            LED1.duty_cycle=60000
            print("\nConnection Nr. "+str(counter)+" established")
        for b in ble.connections:
            if connected==False:
                print("ble.connections: "+str(ble.connections))
        connected=True

Behavior

I am periodically setting up a BLE connection between 2 nordic dongles, both having the same CPO version 9.0.4.
Recently a bug relating setting up a BLE connection and activating UART service was fixed - this is working now perfect.
adafruit/Adafruit_CircuitPython_BLE#192

The current issue now is related to the dongle, which gets connected.
The dongle which gets connected, suddenly stops working after a short time. When it stops working, is random, it could happen after 20 loops, but also after 120. This is a resulting screenshot:
REPL

Description

might be related to 192

Additional information

@gkecskes78 gkecskes78 added the bug label Apr 23, 2024
@gkecskes78
Copy link
Author

The following code I am using on the other dongle to connect and activate UART:
main.zip

@tannewt tannewt added this to the 9.x.x milestone Apr 23, 2024
@dhalbert
Copy link
Collaborator

If you remove the PWMOut use, does it make any difference?
Do you only have nRF52840 dongles to try, or do you also have, say, a Feather nRF52840? The latter uses external flash for CIRCUITPY.

Style note:
if x: in this context can be used instead of if x == True:. It is idiomatic in Python. Similarly, one would say if not x: instead of if x==False:.

@gkecskes78
Copy link
Author

Thanks for the style note hint, I updated my code accordingly.
Unfortunately no difference without PWMOut.
We are working with nordic dongles(PCA10059) only but we have some nordic DK (PCA10056) as well. Could it be helpful to check on them ?

@dhalbert
Copy link
Collaborator

We are working with nordic dongles(PCA10059) only but we have some nordic DK (PCA10056) as well. Could it be helpful to check on them ?

Yes, please try. The CircuitPython build for PCA10059 uses on-board external flash chips for CIRCUITPY. If there is some issue with the chip-internal-flash CIRCUITPY code, then that would be a clue and differentiator.

@gkecskes78
Copy link
Author

I can confirm the same behaviour on PCA10056, CP version 9.0.4 (pca10056_bootloader-0.8.3_s140_6.1.1) and without PWMOut :(
Let me know if I can help further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants