Skip to content

Commit f7ac49e

Browse files
nandojvejhedberg
authored andcommitted
lib: updatehub: Fix buffer sizes
The MAX_PAYLOAD_SIZE must reflect the size of COAP_BLOCK_x. This is necessary becase BLOCK size represents max payload size. The current value create inconsistencies for coap lib. The same way, MAX_DOWNLOAD_DATA must allocate sufficient space for MAX_PAYLOAD_SIZE plus all space for coap header etc. Signed-off-by: Gerson Fernando Budke <[email protected]> Signed-off-by: Otavio Salvador <[email protected]> (cherry picked from commit 5f5919a)
1 parent fce4c9e commit f7ac49e

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

lib/updatehub/updatehub.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,13 @@ LOG_MODULE_REGISTER(updatehub);
3535
#define NETWORK_TIMEOUT K_SECONDS(2)
3636
#define UPDATEHUB_POLL_INTERVAL K_MINUTES(CONFIG_UPDATEHUB_POLL_INTERVAL)
3737
#define MAX_PATH_SIZE 255
38-
#define MAX_PAYLOAD_SIZE 500
39-
#define MAX_DOWNLOAD_DATA 1100
38+
/* MAX_PAYLOAD_SIZE must reflect size COAP_BLOCK_x option */
39+
#define MAX_PAYLOAD_SIZE 1024
40+
/* MAX_DOWNLOAD_DATA must be equal or bigger than:
41+
* MAX_PAYLOAD_SIZE + (len + header + options)
42+
* otherwise download size will be less than real size.
43+
*/
44+
#define MAX_DOWNLOAD_DATA (MAX_PAYLOAD_SIZE + 32)
4045
#define COAP_MAX_RETRY 3
4146
#define MAX_IP_SIZE 30
4247

samples/net/updatehub/prj.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
CONFIG_UPDATEHUB=y
33

44
#Minimal Heap mem pool size for the updatehub working
5-
CONFIG_HEAP_MEM_POOL_SIZE=2048
5+
CONFIG_HEAP_MEM_POOL_SIZE=8192
66
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
77

88
CONFIG_NET_IPV4=y

0 commit comments

Comments
 (0)