forked from sborsay/AWS-IoT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAWSCLI_Payload_Tester
42 lines (27 loc) · 1.71 KB
/
AWSCLI_Payload_Tester
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//check your current AWS IoT Core Region
//By default, the AWS CLI version 2 now passes all binary input and binary output parameters as base64-encoded strings. A parameter that requires binary
//input has its type specified as blob (binary large object) in the documentation.
aws2 --region us-west-2 iot-data publish --topic "myTopic" --cli-binary-format raw-in-base64-out --payload "{\"uptime\": 123,\"temp\": 44,\"humidity\": 33}"
//If you want to encode your payload in base64 here is the equivalent payload from above encoded (using encoding online at https://www.base64encode.org/ )
aws2 --region us-west-2 iot-data publish --topic "myTopic" --payload IntcInVwdGltZVwiOiAxMjMsXCJ0ZW1wXCI6IDQ0LFwiaHVtaWRpdHlcIjogMzN9Ig==
//To upload a whole JSON file of sensor readings (your json file will be the path from your current working directory)
aws2 --region us-west-2 iot-data publish --topic "myTopic" --cli-binary-format raw-in-base64-out --payload file://sample-json-file.json
//To upload a whole JSON file of base64 encoded sensor readings (your json file will be the path from your current working directory)
aws2 --region us-west-2 iot-data publish --topic "myTopic" --output json --payload file://base64.json
//A test payload for the AWS IoT Core console
{
"Temperature": 77,
"Humidity": 88,
"Time": 12349876,
"Device_ID": "device_4"
}
//test JSON sample.json (copy and save as a .json file from your working directory)
[
{ "id": "5001", "type": "None" },
{ "id": "5002", "type": "Glazed" },
{ "id": "5005", "type": "Sugar" },
{ "id": "5007", "type": "Powdered Sugar" },
{ "id": "5006", "type": "Chocolate with Sprinkles" },
{ "id": "5003", "type": "Chocolate" },
{ "id": "5004", "type": "Maple" }
]