Modifications

Sauter à la navigation Sauter à la recherche
aucun résumé de modification
Ligne 2 : Ligne 2 :     
{{traduction}}
 
{{traduction}}
 +
 +
== Vérifier et flasher un nouveau Firmware ==
 +
 +
{{bloc-etroit|text=All your Spark firmware coding can happen entirely in the build section of the website. However, if you prefer to use your own text editor or IDE, you can! It just means that instead of hitting the "Flash" or "Verify" buttons, you'll make API calls that reference a file.}}
 +
 +
== Flasher un Core avec du Code Source ==
 +
{{bloc-etroit|text=If you have written a source code file that defines setup() and loop() functions, you can flash it to your Spark Core with an HTTP PUT request.}}
 +
 +
<nowiki># HTTP REQUEST DEFINITION
 +
PUT /v1/devices/{DEVICE_ID}
 +
Content-Type: multipart/form-data
 +
 +
Send the source code file as "file" in request body.</nowiki>
 +
 +
The API request should be encoded as multipart/form-data with a file field populated. Your filename does not matter. In particular, the extension can be .c, .cpp, .ino, or anything else your prefer.
 +
 +
This API request will submit your firmware to be compiled into a Spark binary, after which, if compilation was successful, the binary will be flashed to your Core wirelessly.
 +
 +
<nowiki># EXAMPLE REQUEST IN TERMINAL
 +
# Flash a Core with a file called "my-firmware-app.cpp"
 +
curl -X PUT -F file=@my-firmware-app.cpp \
 +
  "https://api.spark.io/v1/devices/0123456789abcdef01234567?access_token=1234123412341234123412341234123412341234"</nowiki>
 +
 +
There are three possible response formats:
 +
* A successful response, in which both compilation and flashing succeed.
 +
** Note that the LED on your Core will blink magenta while updating.
 +
* A failure due to compilation errors.
 +
* A failure due to inability to transmit the binary to the core.
 +
 +
<nowiki>// EXAMPLE SUCCESSFUL RESPONSE
 +
{
 +
  "ok": true,
 +
  "firmware_binary_id": "12345"
 +
}
 +
 +
// EXAMPLE COMPILE FAILURE RESPONSE
 +
{
 +
  "ok": false,
 +
  "errors": ["Compile error"],
 +
  "output": ".... lots of debug output from the compiler..."
 +
}
 +
 +
// EXAMPLE FLASH FAILURE RESPONSE
 +
{
 +
  "ok": false,
 +
  "firmware_binary_id": "1234567",
 +
  "errors": ["Device is not connected."]
 +
}</nowiki>
 +
 +
== Flasher un Core avec un binaire pre-compilé ==
 +
If you want to compile the firmware yourself and send a binary instead of a source file, you can do that too! Just add file_type=binary to the request body, and we will skip the compilation stage altogether. The response format will look like those shown above.
 +
 +
<nowiki># EXAMPLE REQUEST IN TERMINAL TO FLASH A BINARY
 +
curl -X PUT -F file=@my-firmware-app.bin -F file_type=binary \
 +
  "https://api.spark.io/v1/devices/0123456789abcdef01234567?access_token=1234123412341234123412341234123412341234"</nowiki>
    
{{Spark.IO-Could-API-TRAILER}}
 
{{Spark.IO-Could-API-TRAILER}}
29 917

modifications

Menu de navigation