File tree 3 files changed +12
-39
lines changed
3 files changed +12
-39
lines changed Original file line number Diff line number Diff line change @@ -25,20 +25,11 @@ This tool can be used to extend (actually prefix) a binary generated with e.g. t
25
25
0000030 0000 0000 7485 0000 0000 0000 0000 0000
26
26
```
27
27
28
- ` bin2base64.py `
29
- ===============
30
- This tool converts the binary file into base64 encoding which is necessary for feeding it to the server.
31
-
32
- ### How-To-Use
33
- ``` bash
34
- ./bin2base64.py sketch-ota.bin sketch-ota.base64
35
- ```
36
-
37
28
` ota-upload.sh `
38
29
==============
39
30
This tool allows to upload a OTA binary to a device via a Arduino cloud server.
40
31
41
32
### How-To-Use
42
33
``` bash
43
- ./ota-upload.sh CLIENT_ID CLIENT_SECRET DEVICE_ID sketch-ota.base64
34
+ ./ota-upload.sh CLIENT_ID CLIENT_SECRET DEVICE_ID sketch-ota.bin
44
35
```
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
2
3
3
if [ " $# " -ne 4 ]; then
4
- echo " Usage: ota-upload.sh CLIENT_ID CLIENT_SECRET DEVICE_ID sketch-ota.base64 "
4
+ echo " Usage: ota-upload.sh CLIENT_ID CLIENT_SECRET DEVICE_ID sketch-ota.bin "
5
5
exit 1
6
6
fi
7
7
8
+ printf " Converting to base64"
9
+ base64 " $4 " > base64_binary
10
+ echo " OK"
11
+
8
12
printf " Obtaining JSON Web Token (JWT) ... "
9
- curl --silent -- location --request POST ' http://api-dev.arduino.cc/iot/v1/clients/token' \
13
+ curl --location --request POST ' http://api-dev.arduino.cc/iot/v1/clients/token' \
10
14
--header ' content-type: application/x-www-form-urlencoded' \
11
15
--header ' Content-Type: application/x-www-form-urlencoded' \
12
16
--data-urlencode ' grant_type=client_credentials' \
23
27
24
28
printf " Uploading to device ... "
25
29
access_token_val=$( < access_token)
26
- base64_binary=$( < " $4 " )
27
- curl --silent --location --request PUT ' https://api-dev.arduino.cc/iot/v2/devices/' " $3 " ' /ota' \
30
+ base64_binary_val=$( < base64_binary)
31
+ echo " $base64_binary_val "
32
+ curl -v --location --request PUT ' https://api-dev.arduino.cc/iot/v2/devices/' " $3 " ' /ota' \
28
33
--header ' Content-Type: application/json' \
29
34
--header ' Authorization: Bearer ' " $access_token_val " \
30
35
--header ' Content-Type: text/plain' \
31
- --data-raw ' {"binary":"base64encodedbinary "}'
36
+ --data-raw ' {"binary":"' " $base64_binary_val " ' "}'
32
37
echo " OK"
33
38
34
39
printf " Cleaning up ... "
35
40
rm access_token
41
+ rm base64_binary
36
42
echo " OK"
You can’t perform that action at this time.
0 commit comments