Update code on a remote monitoring station

I am about to install a monitoring and control station in a very remote cabin 7 hours away. I am technically capable enough to design and build the mechanics, some electronics, the software and convert communications to the Notecard (but just barely).

I would like to be able to update my software remotely but have spent may hours trying with no success and am running out of time. I am not using a common platform like Arduino or Python. I am using an interpretive language. If I can somehow transfer a text file to the Notecard, I will be able to read it and handle a software update. I THINK that doing this one line at a time with note request would be very inefficient in data usage.

Any suggestions?

  1. Can I use the DFU process to get a text file to the Notecard and then let my software handle the installation?
  2. Could I do this with web requests? My efforts have failed - not enough background in this area. Am I correct that with Notecard this would entail this?
    a. convert text file to binary file,
    b. break binary file into sized chunks,
    c. convert chunks back to text and
    d. assemble the text files back into one?
  3. By chance, has anybody used Blues Wireless with a Raspberry Pico with “Picomite” installed (Geoff's Projects - BASIC Interpreter for the Raspberry Pi Pico) and have figured out remote updates?
    Thanks for any input.

Hey @gghh, and welcome to the Blues community!

Can I use the DFU process to get a text file to the Notecard and then let my software handle the installation?

You can definitely transfer text and binary files to the Notecard. The DFU part of this will be considerably harder (more on that in a minute).

Could I do this with web requests? My efforts have failed - not enough background in this area.

The latest firmware release of the Notecard (v5.3.1) has a new feature for sending and receiving large files, and it’s our recommended approach for these sorts of situations.

Here is the documentation on that: Sending and Receiving Large Binary Objects - Blues Developers.

By chance, has anybody used Blues Wireless with a Raspberry Pico with “Picomite” installed (Geoff’s Projects - BASIC Interpreter for the Raspberry Pi Pico) and have figured out remote updates?

I have not unfortunately, and I think this is going to easily be the hardest part of what you’re trying to do here.

Any suggestions?

If you’re open to trying other platforms we designed Notecard Outboard Firmware Update to solve this exact problem. You’ll need to run on an ESP32 or an STM32-based board like the Blues Swan, but if you do, you can upload your firmware updates to Notehub and send updates to your host by clicking a few buttons.

Just an idea. If you do stick with the Pico route the Notecard can help you get the updated binary or text to your device, but not sure how you’ll get the remote updates working. Somebody else in the forum might have tried or have ideas though.

TJ

TJ,

Thank you for the quick response.

I want to make every effort to use my current system before switching to another board and firmware. I think it is possible. I should clarify that I will not be trying to update the system firmware remotely, just the application program. I am fairly confident that if a text file “appeared” on my Notecard, I can handle it so that the next restart is running the code in that file.

I had followed the links you recommended and the links that they contained. I am in a field a bit beyond my grasp. But this is how I learn. The nature of your product and approach to documentation and support makes it within reach and I really appreciate that.

I believe then that my solution is to concentrate on how to use “web.post” and “web.get” as follows:

  • Convert a text file to a properly formatted binary file.
  • Send that to the Notehub. (If I understand correctly Notehub and Notecard will break into chunks and reassemble.)
  • Create the code in my host to convert the binary file back to the text file.

Does that sound right?

a) Am I correct that converting the text file to a binary file and back are not functions available in Blues.io?

b) Sending a text file, even of a small enough size, is not possible? It must be binary.

c) Finally, is there a specific binary format I should convert to? (Again, a neophyte.)

Thanks so much for your help.

Greg

Hey Greg,

Sorry for the late response here but I wanted to do a bit of checking. At a high level you have two options for getting your file to a Notecard.

  1. The web.get request allows you to download an asset from an external endpoint. If you go this route, you would put your file on some server, and then the Notecard would download that file as part of a web.get request.

  2. Alternatively, you could POST your binary to Notehub using the note.add request (see Using the Notehub API - Blues Developers), and then retrieve the binary use a hub.sync request on the Notecard to pull down the Note that contains the file.

If your file is small (< ~8k, which I’m guessing yours will be since it’s text) you don’t have to worry about chunking, as both the Notecard and Notehub can handle that in one go.

And regardless of the approach you take you shouldn’t have to worry about specific binary formats. You should be able to just be able to treat binary as a file. If you run into problems with that let us know.

TJ

Thanks TJ. That will get me going. No worries about the timing. I figured you would be with yesterday’s presentation.

I will just send several small text files if the program is too large and reassemble them by the MCU. Once I get this figured out, I’ll leave a record for others trying to do something similar.

Thanks again.

Greg

TJ,
Did I understand you correctly that a moderate sized text file or text payload (ie. 2 KB) could be sent to my Notehub and then synced without converting to binary?

Could it be that this capability is new enough that it has not been documented yet?

Regardless of how it’s done, I’m sure it’s an easy process. It appears simple in your documentation but I’ve had no success. If you are aware of specific instructions or examples, could you please point me to them? If a user like me has a suggestion I welcome your input. Thanks.

Over the weekend I resorted to trial and error. I was pleasantly surprised when requesting a large text with web.get (not encoded to binary) it was automatically encoded to base-64 and sent successfully. Hopefully this helps others.

Two questions:

  1. Does the API have the capability converting back to the original text? (If not I can do it on my MCU.)

  2. On the “Web Transactions” page of the documentation there is mention of caching:

" Note that you may optionally enable caching so that web.get requests return cached results to reduce latency and provide you with more control over Consumption Credit usage (i.e. cached responses do not cost CCs). When handling a web.get request with caching enabled, Notehub honors the Cache-Control response header as per RFC7234 with a minimum cache TTL of 5 minutes."

My searches could not find further documentation explaining this. If it exists can you point me in that direction? Thank you.

1 Like