Update code.py over UART/BLE

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
frednikgohar
 
Posts: 14
Joined: Wed Aug 11, 2021 2:33 pm

Update code.py over UART/BLE

Post by frednikgohar »

I’ve been working on a product that uses the ItsyBitsy nRF board… there will be approximately 500 units shipped to various users.

Here’s the question tho: from time to time I’d like to update the firmware. The ideal scenario would be enabling the users to use thr companion iOS app to simply upload a new code.py to the board. Short of that, the next idea would be to update a companion py module that I have already imported into code.py.

I have successfully been able to append companion modules but not completely replace them. This is good but not quiet sufficient as functions may need to be re-written differently etc…

I’m aware I can always ask the user to plug in via usb and do it that way but I’d really like to avoid that if possible.

So in conclusion:

Has anyone been able to upload/update either code.py or companion modules/libraries over BLE?

If so, can you please share some code or point me to some resource where I can implement something like that?

Thank you so much in advance

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: Update code.py over UART/BLE

Post by mikeysklar »

I've not seen a code.py updated yet, but you might be able to use:

https://github.com/adafruit/Adafruit_Ci ... e_Transfer
Simple BLE Service for reading and writing files over BLE. This BLE service is geared towards file transfer to and from a device running the service. A core part of the protocol is free space responses so that the server can be a memory limited device. The free space responses allow for small buffer sizes that won't be overwhelmed by the client.
Maybe you could pull down a fresh code.py with a different name let's say update.py and have your normally running code look for that file and overwrite the current code.py when found. Kind of a long shot compared to a working solution, but this seems like the path for getting dynamc code updates over BLE.

User avatar
tannewt
 
Posts: 3304
Joined: Thu Oct 06, 2016 8:48 pm

Re: Update code.py over UART/BLE

Post by tannewt »

Check out File Glider. https://adafru.it/file-glider This is our app for generic file transfer over BLE and will work with CircuitPython 7.0.0.

If you are creating your own app, then you can transfer the files directly or use the file api to access the glider files. The Glider source is here for reference: https://github.com/adafruit/Glider-for-iOS

The protocol is documented here: https://github.com/adafruit/Adafruit_Ci ... README.rst

Locked
Please be positive and constructive with your questions and comments.

Return to “Itsy Bitsy Boards”