Flashing a device with source code that includes public libraries using the Cloud API

Does anyone know if there is a way to flash a device with source code that includes public libraries without also uploading all the necessary libraries? i.e. the docs provide a method:

PUT /v1/devices/:deviceId?access_token=yourtokenhere

My use case involves using an app to program a device selected by the user. The device can one of a few possible platform_ids. Clearly I can precompile first for each platform and then program using the appropriate binary (after identifying the device platform) but I am hoping there is a more elegant way to simply send one .ino file and somehow include the necessary public libraries using the Cloud API.

For example take the source:

#include <ArduinoJson.h>

void setup() {

}

void loop() {

}

Is there a way to Flash with source code using the Cloud API without uploading ArduinoJson.h ?

This endpoint works great when there are no other libraries to upload but with a decent size program uploading all the dependent libraries is not practical in my case.

Thanks for the help.

Yes, in addition to your source code file (.ino) send up a project.properties file in your cloud API build request.

The project.properties file list the library name and version number to use. One way to build it is to create an empty project.properties file and then use the Particle CLI:

particle library add ArduinoJson

The format is simple, however. You can just generate it on the fly if you prefer.

4 Likes

Thanks so much for the quick response! I uploaded the following project.properties file along with the source

dependencies.ArduinoJson=5.13.4

and it did the trick.

btw - thank you for all your excellent tutorials and posts. I have found many of them very useful!

1 Like