Still not working properly. I replaced {{PARTICLE_EVENT_VALUE}} with {{PARTICLE_DEVICE_ID}} just for a test, and it successfully replaced that variable with my device ID every time.
I then changed if back from DeviceID to EventValue, and it did not work. So, my guess is that the Particle Cloud does not like something I am sending.
For testing purposes, I have updated the code on my device to the following:
// Constants
const size_t READ_BUF_SIZE = 64;
const unsigned long CHAR_TIMEOUT = 10000;
// Global variables
char readBuf[READ_BUF_SIZE];
size_t readBufOffset = 0;
unsigned long lastCharTime = 0;
void setup() {
Serial1.begin(9600);
Serial.begin(9600);
}
void loop() {
// Read data from serial
while(Serial1.available()) {
if (readBufOffset < READ_BUF_SIZE) {
char c = Serial1.read();
if (c != '\n') {
// Add character to buffer
readBuf[readBufOffset++] = c;
lastCharTime = millis();
}
else {
// End of line character found, process line
readBuf[readBufOffset] = 0;
Serial.printlnf("got: %s", readBuf);
Particle.publish("RS232", readBuf);
readBufOffset = 0;
}
}
else {
Serial.println("readBuf overflow, emptying buffer");
readBufOffset = 0;
}
}
if (millis() - lastCharTime >= CHAR_TIMEOUT) {
lastCharTime = millis();
readBuf[readBufOffset] = 0;
Serial.printlnf("got timeout: %s", readBuf);
readBufOffset = 0;
}
}
I am sending sample data to the Serial1 port on the device, and monitoring the results on Serial. Here is the output from my terminal:
got timeout:
got: testing
got: testing
got timeout:
So, I know that the device is receiving my data/payload which is currently set to “testing”.
If I check the Particle console, and look at the log in my Webhook, I see the following:
Event
The source event that triggered the webhook
{
"event": "RS232",
"data": "testing\r",
"published_at": "2017-01-18T15:53:53.108Z",
"coreid": "44004a000d51363034323832"
}
So that tells me that my data/payload is making it to the particle cloud successfully.
But if I check Requestb.in I can see that {{PARTICLE_EVENT_VALUE}} is not being replaced with my value “testing”, and it is literally sending {{PARTICLE_EVENT_VALUE}}.
RAW BODY
{"payload_encoding":"string","payload":"{{PARTICLE_EVENT_VALUE}}","routing_key":"","properties":[]}