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