|
23 | 23 | ******************************************************************************/
|
24 | 24 |
|
25 | 25 | #include <Arduino.h>
|
| 26 | +#include "AIoTC_Config.h" |
26 | 27 | #include "CloudWrapperBase.h"
|
27 | 28 |
|
28 | 29 | /******************************************************************************
|
@@ -50,7 +51,32 @@ class CloudWrapperString : public CloudWrapperBase {
|
50 | 51 | _cloud_value = _primitive_value;
|
51 | 52 | }
|
52 | 53 | virtual CborError appendAttributesToCloud(CborEncoder *encoder) {
|
53 |
| - return appendAttribute(_primitive_value, "", encoder); |
| 54 | + // check that the string fits mqtt tx buffer |
| 55 | + if(_name.length() > STRING_PROPERTY_MAX_SIZE) { |
| 56 | + Serial.print(__FILE__); Serial.print(__LINE__); |
| 57 | + Serial.println("[WARNING] String property name exceedes transmit buffer size, unable to send property"); |
| 58 | + |
| 59 | + /* |
| 60 | + * If your reached this line it means that you set a preperty name that exceeded the current maximum capabilities |
| 61 | + * of transmission buffer size. You can either change the buiffer size or the property name can be shortened. |
| 62 | + * Look below for raising the buffer size |
| 63 | + */ |
| 64 | + |
| 65 | + return CborErrorOutOfMemory; |
| 66 | + } else if(_primitive_value.length() + _name.length() > STRING_PROPERTY_MAX_SIZE) { |
| 67 | + Serial.print(__FILE__); Serial.print(__LINE__); |
| 68 | + Serial.println("[WARNING] String property exceedes transmit buffer size"); |
| 69 | + |
| 70 | + /* |
| 71 | + * If your reached this line it means that the value and the property name exceed the current maximum capabilities |
| 72 | + * of transmission buffer size. to fix this you can raise the size of the buffer. |
| 73 | + * you can raise the size of the buffer by setting #define MQTT_TX_BUFFER_SIZE <VALUE> at the beginning of the file |
| 74 | + */ |
| 75 | + |
| 76 | + return appendAttribute("ERROR_PROPERTY_TOO_LONG", "", encoder); |
| 77 | + } else { |
| 78 | + return appendAttribute(_primitive_value, "", encoder); |
| 79 | + } |
54 | 80 | }
|
55 | 81 | virtual void setAttributesFromCloud() {
|
56 | 82 | setAttribute(_cloud_value, "");
|
|
0 commit comments