Hey there, for some reason I cannot forward a string from my photon to firebase. In the particle online console, you can see that particle is receiving the string fine but then it doesn’t get sent to firebase. My webhook variables are working fine as I tried sending an integer instead and that gets forwarded perfectly fine. Any help would be much-appreciated.
Cheers
#include "Particle.h"
// Constants
const unsigned long SEND_INTERVAL_MS = 10000;
const size_t READ_BUF_SIZE = 64;
const char *PUBLISH_EVENT_NAME = "photonData";
// Forward declarations
void processBuffer();
// Global variables
int counter = 0;
unsigned long lastSend = 0;
char readBuf[READ_BUF_SIZE];
size_t readBufOffset = 0;
void setup() {
Serial.begin(115200);
}
void loop() {
if (millis() - lastSend >= SEND_INTERVAL_MS) {
lastSend = millis();
Serial.printlnf("Sent to other Photon: %d", counter);
}
// Read data from serial
while(Serial.available()) {
if (readBufOffset < READ_BUF_SIZE) {
char c = Serial.read();
if (c != '\n') {
// Add character to buffer
readBuf[readBufOffset++] = c;
}
else {
// End of line character found, process line
readBuf[readBufOffset] = 0;
processBuffer();
readBufOffset = 0;
}
}
else {
Serial.println("readBuf overflow, emptying buffer");
readBufOffset = 0;
}
}
}
void processBuffer() {
Serial.printlnf("Received from Computer: %s", readBuf);
char buf[256];
snprintf(buf, sizeof(buf), "{\"barcode\":%s}", readBuf);
}