Repository navigation
bledev.filetransfer: CircuitPython's BLE file-transfer protocol on MicroPython - #86
Merged
Merged
Conversation
…d and client The board serves it beside the REPL (bledev.repl.start(files=True)), locked by the REPL's password through one extra characteristic. File work runs on the main thread: in the BLE task's few-KB stack a recursive delete crashed the T-Embed.
This was referenced Sep 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A MicroPython board can now serve files over Bluetooth using CircuitPython's own BLE file-transfer protocol, so one client reaches files on either interpreter. Stacked on #85 (bledev-midi); the diff is the three commits on top.
What's in it
bledev.filetransfer: read (with an offset), write (at an offset), delete (recursive), mkdir (with parents), listdir, move, and the free-space pacing on every write.FileServeris the protocol with no radio. The board serves it as a second service onbledev.repl's server (repl.start(files=True)). There's also a client built on the bledev contract, so it runs on bleak or on a board.ADAF0300-…, which CircuitPython doesn't have). One attempt per connection, and a wrong password gets hung up on. Until the password arrives, every command is answered with status0x80. Logging in to the REPL on the same connection unlocks files too.micropython.scheduleplus the REPL's 5 ms timer do the file work.Checks
tests/bledev_filetransfer.pypasses 104 of 104 on CPython and on unix MicroPython. It runs at MTUs 23, 185 and 247 with windows from 512 to 4096 bytes.test_bledev_filetransfer.pyalso plants a flipped bit and a dropped packet, and both fail the run.tests/bledev_board/files_client.pypassed: no password and a wrong password were refused, 20 KB went up and down byte for byte, and read-at-offset, listdir, move and recursive delete all worked. A bit flip planted on the client side and one planted on the board side both failed the run.FileTransferClientalso worked againstFileServerin-process. That was a one-off check; the details are in the internals doc.Measured. This is what decides whether mpftp needs this. A 20 KB file, laptop to T-Embed, with throughput connection parameters:
mpftp's
ble://transport uses file transfer, and falls back to the REPL when a board doesn't serve it: PyDevices/mpftp#47.Not done