adafruit / Adafruit_CircuitPython_BLE_File_Transfer

Simple (not fast) File Transfer service for BLE
MIT License
28 stars 5 forks source link

Infinite Loop Trying to run listdir Example #28

Closed FoamyGuy closed 4 months ago

FoamyGuy commented 5 months ago

When attempting to run the listdir example https://github.com/adafruit/Adafruit_CircuitPython_BLE_File_Transfer/blob/main/examples/ble_file_transfer_listdirs.py it's resulting in getting stuck in an infinite loop inside of here: https://github.com/adafruit/Adafruit_CircuitPython_BLE_File_Transfer/blob/main/adafruit_ble_file_transfer.py#L147 I added print statements and can see that the value of read is always 0. I also printed buffer and it was filled with \x00s

It's unclear to me if this worked in the past and perhaps the workflow API was changed, but the library was not, or perhaps this functionality was not ever working.

I tested with a Feather Sense with BLE Workflow enabled and an Itsy Bitsy nrf52840 as the client running the listdir script. I did originally notice this behavior first on the PC using Blinka_Bleio, but then moved off the PC to using two MCUs and confirmed seeing the same infinite looping behavior.

tannewt commented 4 months ago

Did you figure this out?

FoamyGuy commented 4 months ago

I think I understand it a bit better, but wouldn't say I figured it out completely.

When everything is working as expected this library does run successfully on the micro-controller and does not infinitely loop.

It does still have an infinite loop when run on a PC under blinka_bleio. So this could be closed and if there is a desire to support that environment then an issue could be created over in that repo. For now I've moved to just using bleak module directly without blinka and blinka_bleio and I'm making progress that way.

The times that I did see this library infinite loop on the MCU (mentioned in the original comment), I believe it was due to the "server device" (the one running BLE workflow) had gotten into a "bad state" ultimately caused by partially broken implementations while working on the PC / blinka_bleio version. I did not document specific examples that led to the bad state, but I did experience it a few times. I found that using ctrl+C / ctrl+D to restart the code.py or REPL would typically get it back into a good state. I think maybe once I ended up having to unplug / replug to let it fully reboot.

I'll close this one.