-2

I am looking for some advice on an easy way to convert Syslog data into JSON. Currently using a program written in Rust to transmit IoT sensor data over IOTA Tangle but would like to see if it is possible to send Syslog data too. I can manually transmit a data payload but it must be in JSON format. It will most likely need to be broken down into 32Kb payloads. Any ideas would be much appreciated.

Currently using this command to send random sensor data but would like to call Syslog data and have it like this in JSON;

curl --location \
  --request POST '127.0.0.1:8080/sensor_data' \
  --header 'Content-Type: application/json' \
  --data-raw '{ "iot2tangle": [ { "sensor": "Gyroscope", "data": [ { "x": "4514" }, { "y": "244" }, { "z": "-1830" } ] }, { "sensor": "Acoustic", "data": [ { "mp": "1" } ] } ], "device": "DEVICE_ID_1", "timestamp": 1558511111 }' 
keeno563
  • 1
  • 1

1 Answers1

0

Use the crate serde.

Serialize the payload that you want first, by making a data model as a struct for your sensors.

Then, for partitioning your request, implement in the sender some logic that just sends as many packages you want, in the size you want.

Looking your serialization, outer element it's a list of sensors. So, group them in lists that aren't larger of 32kb.

Alex Vergara
  • 1,766
  • 1
  • 10
  • 29