This addresses IOT-427.
We were not accounting for json suffixes and prefixes when constructing
in the stack. The C sample apps construct json repsonses too.
After discussions, changed the constants in ocstackconfig.h and
added a note in the documentation to inform api users of the affixes.
Change-Id: I790a6d837a3dabc0d1984cfeb5fb49ef881031e4
Signed-off-by: Mandeep Shetty <mandeep.shetty@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/743
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Doug Hudson <douglas.hudson@intel.com>
Reviewed-by: Erich Keane <erich.keane@intel.com>
/**
* Common JSON string components used by the stack to build JSON strings.
+ * These details are exposed in ocstackconfig.h file in the form of documentation.
+ * Remember to update the documentation there if these are changed.
*/
#define OC_JSON_PREFIX "{\"oc\":["
#define OC_JSON_PREFIX_LEN (sizeof(OC_JSON_PREFIX) - 1)
/**
* Maximum length of the response supported by Server for any REST request.
+ * The actual repsonse length is 256 for Arduino and 1024 for other platforms.
+ * Note that the stack will add a prefix and suffix to the payload.
+ * Prefix : {"oc":[
+ * Suffix : ]}
+ * They have a combined size of 9 bytes.
*/
#ifdef WITH_ARDUINO
-#define MAX_RESPONSE_LENGTH (256)
+#define MAX_RESPONSE_LENGTH (247)
#else
-#define MAX_RESPONSE_LENGTH (1024)
+#define MAX_RESPONSE_LENGTH (1015)
#endif
/**