-
Notifications
You must be signed in to change notification settings - Fork 1.3k
after finish write file via ftp service device prefom RunReason.AUTO_RELOAD ( on battery only ) #10272
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
Comments
Hi, Auto reloading when a file is changed via BLE/USB/Web workflow is the expected behavior, this allows rerunning when you make a change to the code, imported modules or files used by the code. You can disable autoreload in code via the import supervisor
supervisor.runtime.autoreload = False From the issue you opened in the adafruit_ble_file_transfer library (which is not required to use the BLE workflow), it seems that you want to use the file transfer library directly. I believe that for this to happen you need to implement the server side in your code. This example seems to have the basics but would need many changes to actually read and write to the filesystem (without causing a reload), also allowing you to restrict it to a subfolder for example. Then you would disable the BLE workflow with the supervisor module. |
Thanks for the fast and detailed response! I'd like to add some additional details to help clarify and fully explain the issue. Our product is an IoT device, and we make extensive use of the BLE-based FTP service. Because of this, automatic reloads (auto-reload) after file transfers are problematic for our use case. We have a dedicated folder where we store new recipes sent by the client. While we’re not currently using FTP as part of our OTA (Over-The-Air) update mechanism, it's still a critical part of how we interact with the device. Here's an overview of our current device tree: graphql my basic code without using mpy and server example only usage ftp buildin circuitpython fw When I began testing FTP functionality, I discovered the Adafruit_CircuitPython_BLE_File_Transfer library and its examples. I tested the ble_file_transfer_stub_server.py example using the Glider app, and it worked as expected. However, I wasn’t aware that the CircuitPython UF2 firmware includes a built-in FTP service by default. For about a month, our code.py included the full example-based FTP implementation from that library. Later, I noticed that BLE clients like nRF Connect were discovering two FTP services (see the image below). After realizing this, I removed the .mpy module and stopped using the stub server entirely — and surprisingly, FTP functionality continued to work. That’s when I understood that the FTP server is already implemented natively in CircuitPython 9.2.7. This led to confusion: how can BLE clients distinguish between the two services when both are active (custom + built-in)? And more importantly, I confirmed that the auto-reload behavior is tied to the built-in FTP implementation, not my custom server in code.py. ❓ Follow-up Question: Do you know why this behavior differs between USB and battery operation? |
Follow-up Question: Do you know why this behavior differs between USB and battery operation? |
That example is a "stub", it doesn't actually do anything and uses a fake file list (starting empty), there is no use of For now though, as I mentioned above, you can disable auto-reload.
I assume the board just uses the builtin one and it takes precedence over the code.py one.
I don't see that. When trying to change files via BLE while the board is connected to USB the file operations fail as expected (since the drive is only writable via USB) but it still triggers an auto-reload. |
CircuitPython version and board name
Code/REPL
Behavior
Your code.py uses BLE only for advertising
The Glider app connects, and you can:
Create folders
Write files
After each file/folder operation (when running on battery, not USB), the device:
Performs: Run reason: supervisor.RunReason.AUTO_RELOAD
On reconnect (reopen app), the written data appears and is correct
Description
Your code.py uses BLE only for advertising
The Glider app connects, and you can:
Create folders
Write files
After each file/folder operation (when running on battery, not USB), the device:
Performs: Run reason: supervisor.RunReason.AUTO_RELOAD
On reconnect (reopen app), the written data appears and is correct
Additional information
No response
The text was updated successfully, but these errors were encountered: