2021-03-11 17:01:25 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
URL="https://http.bosch-iot-hub.com/telemetry"
|
|
|
|
TTD="10"
|
|
|
|
KEY="ZGVmaW5tYUB0MzhiYmNjZDE2MjE3NDViODgxMTk5ZGI2ZWQzZGFiNmE6RGVGaW5NYWNoZW4yMDIwIQ=="
|
|
|
|
|
|
|
|
# Build name
|
2021-03-12 14:37:36 +01:00
|
|
|
# Basename of file with the last dot replaced by a slash and .DPT extension
|
|
|
|
NAME=$(basename $1)
|
|
|
|
NAME="${NAME%.*}_${NAME##*.}.DPT"
|
2021-03-11 17:01:25 +01:00
|
|
|
|
|
|
|
# Build body
|
2021-03-12 14:37:36 +01:00
|
|
|
JSON="{\"filename\":\"$NAME\",\"dpt\":["
|
2021-03-11 17:01:25 +01:00
|
|
|
while read LINE
|
|
|
|
do
|
2021-03-12 14:37:36 +01:00
|
|
|
JSON+="[\"${LINE%,*}\",\"${LINE#*,}\"], "
|
2021-03-11 17:01:25 +01:00
|
|
|
done < $1
|
|
|
|
JSON=${JSON::-2}
|
|
|
|
JSON+=']}'
|
|
|
|
|
|
|
|
# Dispatch curl
|
|
|
|
curl -X POST $URL -H "accept: */*" -H "hono-ttd: $TTD" -H "Authorization: Basic $KEY" -H "Content-Type: application/json" -d "$JSON"
|