From a2a71aa0f14139d06331301ef0b4efb518c7ae3e Mon Sep 17 00:00:00 2001 From: Mandeep Shetty Date: Wed, 15 Apr 2015 15:25:41 -0700 Subject: [PATCH] Added note in documentation for max payload length. 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 Reviewed-on: https://gerrit.iotivity.org/gerrit/743 Tested-by: jenkins-iotivity Reviewed-by: Doug Hudson Reviewed-by: Erich Keane --- resource/csdk/stack/include/internal/ocresourcehandler.h | 2 ++ resource/csdk/stack/include/ocstackconfig.h | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/resource/csdk/stack/include/internal/ocresourcehandler.h b/resource/csdk/stack/include/internal/ocresourcehandler.h index ab939fd..aecc032 100644 --- a/resource/csdk/stack/include/internal/ocresourcehandler.h +++ b/resource/csdk/stack/include/internal/ocresourcehandler.h @@ -59,6 +59,8 @@ /** * 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) diff --git a/resource/csdk/stack/include/ocstackconfig.h b/resource/csdk/stack/include/ocstackconfig.h index ad7c3da..ea6f90f 100644 --- a/resource/csdk/stack/include/ocstackconfig.h +++ b/resource/csdk/stack/include/ocstackconfig.h @@ -31,11 +31,16 @@ /** * 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 /** -- 2.7.4