I am working on a project where I will need to publish approx 200 bytes of data.
If I encode this 200 bytes of data using hex characters, It will be take a minimum of 400 characters.
That means it will take 2 Particle.publishes in order to send my data, since each Particle.publish()
is limited to a maximum size payload of 255 characters.
Alternatively, I was wondering if it would be feasible to use a base-255 encoding scheme (is there a name for this?) instead of a base 16 encoding scheme (i.e. hex) to encode the data. That would mean that I could represent each byte by a single character, though I would be using “weird” characters to accomplish this.
Characters such as ±◘╚♪♀♂◙○◘•♠♣♦♥☻☺
Would this work? Would there be anything in the OSI comm layers preventing this from working (i.e. special characters being scrubbed/altered/deleted as they pass from my app to my server via the Particle Cloud)?
@jaza_tom , “base 255” would be pure 8-bit binary! The publish restricts the payload to pure ASCII so an efficient conversion is Base64 which would make your payload about 267 bytes long. You can find the Base64RK library in the Web IDE to make things easy.
2 Likes
Moors7
October 22, 2018, 3:57pm
3
Are you aware that limits have been increased for most of the cloud thingies, in the 0.8.x versions?
May 4th 2018: Firmware v0.8.0-rc.4
A new pre-release firmware v0.8.0-rc.4 is available now on https://build.particle.io for Core/Photon/P1/Electron.
The changelog is short, so here it is!
0.8.0-rc.4
ENHANCEMENTS
[Electron/Photon/P1] Increase Device OS API argument lengths. More data in Functions, Variables, Publish, Subscribe… oh my! #1537
BUGFIXES
[Electron] Particle.keepAlive() API was broken since v0.6.2-rc.2 firmware on Electron where the System would override an early set Use…
4 Likes
Hmm, I was not aware.
I searched through the Particle Tools Changelog
that you link to and could find no mention of the word “publish” in any release after 0.6.x
Any idea if publishing limits have been updated and now differ from what is shown in the reference documentation?
1 Like
Moors7
October 22, 2018, 4:04pm
5
[Electron/Photon/P1] Increase Device OS API argument lengths. More data in Functions, Variables, Publish, Subscribe… oh my! #1537
It's in that very post I linked to
particle-iot:develop
← particle-iot:feature/increase-limits
opened 12:02AM - 04 May 18 UTC
### Problem
Device OS API arguments have limitations that can be increased.
…
### Solution
| API Field | Prior to 0.8.0 | Since 0.8.0 | Comment |
|--:|--:|--:|:--|
| Variable Key | 12 | 64 | |
| Variable Data | 622 | 622 | |
| Function Key | 12 | 64 | |
| Function Argument | 63 | 622 | |
| Publish/Subscribe Event Name | 64 | 64 | |
| Publish/Subscribe Event Data | 255 | 622 | ~Cloud API currently still limits to 255, but Device OS can publish 622. Will change Cloud API to accept 622.~ Done. |
| Number of registered Functions or Variables | limited by memory available | limited by memory available | |
An additional feature has been added that will return `false` when attempting to register a `Particle.variable()` or `Particle.function()` that exceeds the memory limits of the describe message (about 800 bytes for the Photon/P1/Electron). This message is a JSON object that describes or lists the "keys" needed. When an error occurs, that Variable or Function will be removed from the list available.
### Steps to Test
Included test app.
### Example App
```c
#include "Particle.h"
#define PUB_70 "123456789012345678901234567890123456789012345678901234567890ABCDEFGHIJ"
#define SUB_70 "123456789012345678901234567890123456789012345678901234567890ABCDEFGHIJ"
#define VAR_70 "123456789012345678901234567890123456789012345678901234567890ABCDEFGHIJ"
#define VAR_64 "123456789012345678901234567890123456789012345678901234567890ABCD"
#define VAR_63 "123456789012345678901234567890123456789012345678901234567890ABC"
#define VAR_62 "123456789012345678901234567890123456789012345678901234567890AB"
#define VAR_61 "123456789012345678901234567890123456789012345678901234567890A"
#define VAR_60 "123456789012345678901234567890123456789012345678901234567890"
#define VAR_13 "1234567890123"
#define VAR_12 "123456789012"
#define VAR_OVF "12345678901234567890123456789012345678901234567890"
#define FUN_70 "123456789012345678901234567890123456789012345678901234567890ABCDEFGHIJ"
#define FUN_64 "123456789012345678901234567890123456789012345678901234567890ABCD"
#define FUN_63 "123456789012345678901234567890123456789012345678901234567890ABC"
#define FUN_62 "123456789012345678901234567890123456789012345678901234567890AB"
#define FUN_61 "123456789012345678901234567890123456789012345678901234567890A"
#define FUN_60 "123456789012345678901234567890123456789012345678901234567890"
#define FUN_13 "1234567890123"
#define FUN_12 "123456789012"
#define CHAR_700 "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890ABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJ"
#define CHAR_622 "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890AB"
String my_variable_ovf = CHAR_622;
String my_variable_12 = CHAR_622;
String my_variable_13 = CHAR_622;
String my_variable_60 = CHAR_622;
String my_variable_61 = CHAR_622;
String my_variable_62 = CHAR_622;
String my_variable_63 = CHAR_622;
String my_variable_64 = CHAR_622;
String my_variable_70 = CHAR_700;
Serial1LogHandler logHandler(115200, LOG_LEVEL_ALL);
void handler(const char *event, const char *data)
{
String my_event(event);
String my_data(data);
Serial.printlnf("Event Length: %d, Data Length: %d", my_event.length(), my_data.length() );
Serial.printlnf("Event Name: %s, Event Data: %s", my_event.c_str(), my_data.c_str() );
}
void printInfo(String& string) {
Serial.printlnf("Function Argument Length: %d", string.length() );
Serial.printlnf("Function Argument: %s", string.c_str() );
}
int my_function_70(String arg) {
printInfo(arg);
return 0;
}
int my_function_64(String arg) {
printInfo(arg);
return 0;
}
int my_function_63(String arg) {
printInfo(arg);
return 0;
}
int my_function_62(String arg) {
printInfo(arg);
return 0;
}
int my_function_61(String arg) {
printInfo(arg);
return 0;
}
int my_function_60(String arg) {
printInfo(arg);
return 0;
}
int my_function_50(String arg) {
printInfo(arg);
return 0;
}
int my_function_13(String arg) {
printInfo(arg);
return 0;
}
int my_function_12(String arg) {
printInfo(arg);
return 0;
}
int my_function_ovf(String arg) {
printInfo(arg);
return 0;
}
void setup() {
Serial.begin();
// Particle.function(FUN_70, my_function_70); // error on compile (error shows 64 limit)
Particle.function(FUN_12, my_function_12); // can receive 622 bytes as an argument
Particle.function(FUN_13, my_function_13); // can receive 622 bytes as an argument
Particle.function(FUN_60, my_function_60); // can receive 622 bytes as an argument
Particle.function(FUN_61, my_function_61); // can receive 622 bytes as an argument
Particle.function(FUN_62, my_function_62); // can receive 622 bytes as an argument
Particle.function(FUN_63, my_function_63); // can receive 622 bytes as an argument
Particle.function(FUN_64, my_function_64); // can receive 622 bytes as an argument
// Particle.variable(VAR_70, &my_variable_70, STRING); // error on compile (error shows 64 limit)
Particle.variable(VAR_12, &my_variable_12, STRING); // returns CHAR_622
Particle.variable(VAR_13, &my_variable_13, STRING); // returns CHAR_622
Particle.variable(VAR_60, &my_variable_60, STRING); // returns CHAR_622
Particle.variable(VAR_61, &my_variable_61, STRING); // returns CHAR_622
Particle.variable(VAR_62, &my_variable_62, STRING); // returns CHAR_622
Particle.variable(VAR_63, &my_variable_63, STRING); // returns CHAR_622
Particle.variable(VAR_64, &my_variable_64, STRING); // returns CHAR_622
// Particle.variable(VAR_OVF, &my_variable_ovf, STRING); // add to increase describe message over the limit
Particle.subscribe(SUB_70, handler, MY_DEVICES); // event 64 and data 255 (limited by Cloud API)
waitUntil(Particle.connected);
Particle.publish(PUB_70, CHAR_700, PRIVATE, WITH_ACK); // event 64 and data 622
}
void loop() {
}
```
### References
Closes #1467
---
### Completeness
- [x] User is totes amazing for contributing!
- [x] Contributor has signed CLA ([Info here](https://github.com/spark/firmware/blob/develop/CONTRIBUTING.md))
- [x] Problem and Solution clearly stated
- [x] Run unit/integration/application tests on device
- [x] Added documentation
- [x] Added to CHANGELOG.md after merging (add links to docs and issues)
4 Likes
Ah of course. I’m such an infant.
2 Likes