Skip to content

Commit 9e6792e

Browse files
committed
Removing bin2base64 python script since the same functionality can be obtained via base64
1 parent 9d71e95 commit 9e6792e

File tree

3 files changed

+12
-39
lines changed

3 files changed

+12
-39
lines changed

extras/tools/README.md

+1-10
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,11 @@ This tool can be used to extend (actually prefix) a binary generated with e.g. t
2525
0000030 0000 0000 7485 0000 0000 0000 0000 0000
2626
```
2727

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-
3728
`ota-upload.sh`
3829
==============
3930
This tool allows to upload a OTA binary to a device via a Arduino cloud server.
4031

4132
### How-To-Use
4233
```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
4435
```

extras/tools/bin2base64.py

-24
This file was deleted.

extras/tools/ota-upload.sh

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
#!/bin/bash
22

33
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"
55
exit 1
66
fi
77

8+
printf "Converting to base64"
9+
base64 "$4" > base64_binary
10+
echo "OK"
11+
812
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' \
1014
--header 'content-type: application/x-www-form-urlencoded' \
1115
--header 'Content-Type: application/x-www-form-urlencoded' \
1216
--data-urlencode 'grant_type=client_credentials' \
@@ -23,14 +27,16 @@ fi
2327

2428
printf "Uploading to device ... "
2529
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' \
2833
--header 'Content-Type: application/json' \
2934
--header 'Authorization: Bearer '"$access_token_val" \
3035
--header 'Content-Type: text/plain' \
31-
--data-raw '{"binary":"base64encodedbinary"}'
36+
--data-raw '{"binary":"'"$base64_binary_val"'"}'
3237
echo "OK"
3338

3439
printf "Cleaning up ... "
3540
rm access_token
41+
rm base64_binary
3642
echo "OK"

0 commit comments

Comments
 (0)