I wonder if there is an opportunity to update the PublishQueueAsyncRK library to add members to a JSON element with each call of PublishQueue.Publish().
For example: If a device takes readings every 5 minutes, calls PublishQueue.Publish() to store the data in a buffer and falls asleep (does not connect to the cloud to publish data) and then every 1 hour it wakes up, takes readings and then connects to the cloud to publish all the readings taken over the last 1 hour (i.e. 12 individual publish events spaced 1 second part as defined by PublishQueue. The PublishQueue library written by @rickkas7 works great for this use case and makes it very easy to store the data and publish at a later date. The complexity is abstracted away making it simple to use.
Prior to the price structure change, I think the amount of data used would be about the same weather it was 12 individual publish events vs 1 publish event containing the data from the 12 sensor readings in a single publish event. Since the billing used to be in MB/Month having PublishQueue send 12 individual publish events was not a big deal. However, now that Particle is metering data operations/month and is not focused much on MB/month, the ideal operation in the example above would be to transmit the 12 packets of data as a single Publish Event rather than 12 individual ones. This would reduce both data operations as well as improve backend throughput as it would make a single web hook with more data rather than 12 individual web hooks. I’d just update the backend to parse out the data from the array of JSON members accordingly.
Has anyone in the Particle Community investigated this or implemented this yet? I was just about to start looking at this so figured I’d ask.
I.e. Instead of publishing something like this 12 times using PublishQueue.publish()
{ "Sensor1": 1234, "Sensor2": 5678, DateTime:1623000246}
{ "Sensor1": 1234, "Sensor2": 5678, DateTime:1623000546}
{ "Sensor1": 1234, "Sensor2": 5678, DateTime:1623000846}
…
I would publish this once using either Particle JSONWriter - JSON
or GitHub - rickkas7/JsonParserGeneratorRK: JSON parser and generator for Particle devices
[ {"Sensor1": 1234, "Sensor2": 5678, DateTime:1623000246}, {"Sensor1": 1234, "Sensor2": 5678, DateTime:1623000546}, {"Sensor1": 1234, "Sensor2": 5678, DateTime:1623000846}...]
The effect would be 1 data operation vs 12.
Any thoughts or guidance is always appreciated!
-Jeff