Particle.publish() max length is 256 not 622

Hi, I’m using the Argon to publish a message, however, I’m running into the problem that the max data message size is 256 characters and not the 622 as mentioned in the documentation.

Is this a known issue?

What device OS version are you running?

2.0.0 rc3 but i had the same issue with 1.5.2

Nope, I cannot confirm that.
With this test code (on 2.0.0-rc.3) I can clearly see that 622 bytes get transferred.

void setup() {
  Particle.function("test", test);
  Particle.subscribe("test", pubLen);
}

int test(const char* command) {
  char msg[623];
  for (int i = 0; i < sizeof(msg)-1; i++)
    msg[i] = (i % 74) + 0x31;
  msg[sizeof(msg)-1] = '\0';
  
  Particle.publish("test", msg); 
  return strlen(msg);
}

void pubLen(const char* event, const char* data) {
  char msg[16];
  snprintf(msg, sizeof(msg), "%d", strlen(data));
  Serial.println(data);
  Particle.publish("len", msg);
}

What kind of data are you trying to send?
Can you provide a sample code that exhibits the issue?

1 Like

image

Here you see I receive exactly 265 characters:
{“a”:4.35,“b”:22.05,“c”:52.87,“d”:19.64,“e”:59.17,“f”:802,“g”:22.29,“h”:50.76,“i”:502,“j”:16,“k”:24.12,“l”:78.48,“m”:364.98,“n”:3.27,“o”:56.85,“p”:3.68,“q”:2.41,“r”:1.87,“s”:1.05,“t”:1.17,“u”:0.86,“v”:0.29,“w”:0.22,“x”:0.13,“y”:0.03,“z”:0.06,“aa”:0.00,"ab

I’m using a JSON writer as follows:

JsonWriterStatic<256> writer;
writer.setFloatPlaces(2);
JsonWriterAutoObject obj(&writer);

writer.insertKeyValue("a",value_1);
....................
writer.insertKeyValue("ac",value_x);

writer.finishObjectOrArray();
Particle.publish("IAQ", writer.getBuffer(), PRIVATE);

Where values 0 to x would be readings from my sensors.

That’s sooo dumb… I see already. My json writer is only 256 long

4 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.