I have a function to publish periodic data, for testing I am calling it every second.
I cycle through the channels 0 - 15
When I recieve the data, I see a few extra characters padded on: [�1]
event: inputs
data: {"data":"{\"input\":\"I2\",\"state\":false,\"channel\":1,\"module_name\":\"OE_IOT_1016A\"�1","ttl":60,"published_at":"2018-12-02T15:05:54.624Z","coreid":"2c003f000c47363339343638"}
FUNCTION:
char * module_name = "OE_IOT_1016A";
void publish(String channel, bool status, int i){
// This creates a buffer to hold up to 256 bytes of JSON data (good for Particle.publish)
JsonWriterStatic<256> jw;
//JsonWriter jw;
// Creating a scope like this in {} with a JsonWriterAutoObject in it creates an object,
// and automatically closes the object when leaving the scope. This is necessary because
// all JSON values must be in either an object or an array to be valid, and JsonWriter
// requires all startObject to be balanced with a finishObjectOrArray and JsonWriterAutoObject
// takes care of doing that automatically.
{
JsonWriterAutoObject obj(&jw);
// Add various types of data
jw.insertKeyValue("input",channel);
jw.insertKeyValue("state", status);
jw.insertKeyValue("channel", i);
jw.insertKeyValue("module_name", module_name);
Particle.publish("inputs", jw.getBuffer(),60,PRIVATE);
}
}
SAMPLE OUTPUT:
event: inputs
data: {"data":"{\"input\":\"I12\",\"state\":false,\"channel\":11,\"module_name\":\"OE_IOT_1016A\"","ttl":60,"published_at":"2018-12-02T15:05:47.621Z","coreid":"2c003f000c47363339343638"}
event: inputs
data: {"data":"{\"input\":\"I13\",\"state\":false,\"channel\":12,\"module_name\":\"OE_IOT_1016A\"","ttl":60,"published_at":"2018-12-02T15:05:48.621Z","coreid":"2c003f000c47363339343638"}
event: inputs
data: {"data":"{\"input\":\"I14\",\"state\":false,\"channel\":13,\"module_name\":\"OE_IOT_1016A\"","ttl":60,"published_at":"2018-12-02T15:05:49.622Z","coreid":"2c003f000c47363339343638"}
event: inputs
data: {"data":"{\"input\":\"I15\",\"state\":false,\"channel\":14,\"module_name\":\"OE_IOT_1016A\"","ttl":60,"published_at":"2018-12-02T15:05:50.624Z","coreid":"2c003f000c47363339343638"}
event: inputs
data: {"data":"{\"input\":\"I1\",\"state\":false,\"channel\":0,\"module_name\":\"OE_IOT_1016A\"�1","ttl":60,"published_at":"2018-12-02T15:05:53.623Z","coreid":"2c003f000c47363339343638"}
event: inputs
data: {"data":"{\"input\":\"I2\",\"state\":false,\"channel\":1,\"module_name\":\"OE_IOT_1016A\"�1","ttl":60,"published_at":"2018-12-02T15:05:54.624Z","coreid":"2c003f000c47363339343638"}
event: inputs
data: {"data":"{\"input\":\"I3\",\"state\":false,\"channel\":2,\"module_name\":\"OE_IOT_1016A\"�1","ttl":60,"published_at":"2018-12-02T15:05:55.624Z","coreid":"2c003f000c47363339343638"}
event: inputs
data: {"data":"{\"input\":\"I4\",\"state\":false,\"channel\":3,\"module_name\":\"OE_IOT_1016A\"�1","ttl":60,"published_at":"2018-12-02T15:05:56.625Z","coreid":"2c003f000c47363339343638"}
event: inputs
data: {"data":"{\"input\":\"I5\",\"state\":false,\"channel\":4,\"module_name\":\"OE_IOT_1016A\"�1","ttl":60,"published_at":"2018-12-02T15:05:57.626Z","coreid":"2c003f000c47363339343638"}
event: inputs
data: {"data":"{\"input\":\"I6\",\"state\":false,\"channel\":5,\"module_name\":\"OE_IOT_1016A\"�1","ttl":60,"published_at":"2018-12-02T15:05:58.625Z","coreid":"2c003f000c47363339343638"}
event: inputs
data: {"data":"{\"input\":\"I7\",\"state\":false,\"channel\":6,\"module_name\":\"OE_IOT_1016A\"�1","ttl":60,"published_at":"2018-12-02T15:05:59.627Z","coreid":"2c003f000c47363339343638"}
event: inputs
data: {"data":"{\"input\":\"I8\",\"state\":false,\"channel\":7,\"module_name\":\"OE_IOT_1016A\"\u0010","ttl":60,"published_at":"2018-12-02T15:06:00.626Z","coreid":"2c003f000c47363339343638"}
event: inputs
data: {"data":"{\"input\":\"I9\",\"state\":false,\"channel\":8,\"module_name\":\"OE_IOT_1016A\"�1","ttl":60,"published_at":"2018-12-02T15:06:01.626Z","coreid":"2c003f000c47363339343638"}
event: inputs
data: {"data":"{\"input\":\"I10\",\"state\":false,\"channel\":9,\"module_name\":\"OE_IOT_1016A\"1","ttl":60,"published_at":"2018-12-02T15:06:02.627Z","coreid":"2c003f000c47363339343638"}
event: inputs
data: {"data":"{\"input\":\"I11\",\"state\":false,\"channel\":10,\"module_name\":\"OE_IOT_1016A\"","ttl":60,"published_at":"2018-12-02T15:06:03.627Z","coreid":"2c003f000c47363339343638"}