Skip to content

Commit eca98e3

Browse files
rlubosnashif
authored andcommitted
samples: net: coap_server: Finetune sample parameters
Finetune coap_server sample parameters for better user experience. Reduce the maximum retransmission count to release resources earilier in case client is unreachable and no longer responds. Increase the maximum number of pending retransmissions, along with the heap size (the buffers for messages are allocated on a heap), to improve sample responsiveness, in case multiple unreplied messages are pending retransmission. Signed-off-by: Robert Lubos <[email protected]>
1 parent 15ba020 commit eca98e3

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

samples/net/sockets/coap_server/prj.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ CONFIG_NET_LOG=y
2424
CONFIG_NET_SHELL=y
2525

2626
CONFIG_MAIN_STACK_SIZE=2048
27-
CONFIG_HEAP_MEM_POOL_SIZE=2048
27+
CONFIG_HEAP_MEM_POOL_SIZE=4096
2828

2929
# Configuration
3030
CONFIG_NET_CONFIG_SETTINGS=y

samples/net/sockets/coap_server/src/coap-server.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ LOG_MODULE_REGISTER(net_coap_server_sample, LOG_LEVEL_DBG);
2424
#include "ipv6.h"
2525
#endif
2626

27+
#define MAX_RETRANSMIT_COUNT 2
28+
2729
#define MAX_COAP_MSG_LEN 256
2830

2931
#define MY_COAP_PORT 5683
@@ -44,7 +46,7 @@ LOG_MODULE_REGISTER(net_coap_server_sample, LOG_LEVEL_DBG);
4446

4547
#define NUM_OBSERVERS 3
4648

47-
#define NUM_PENDINGS 3
49+
#define NUM_PENDINGS 10
4850

4951
/* CoAP socket fd */
5052
static int sock;
@@ -1020,8 +1022,7 @@ static int create_pending_request(struct coap_packet *response,
10201022
return -ENOMEM;
10211023
}
10221024

1023-
r = coap_pending_init(pending, response, addr,
1024-
COAP_DEFAULT_MAX_RETRANSMIT);
1025+
r = coap_pending_init(pending, response, addr, MAX_RETRANSMIT_COUNT);
10251026
if (r < 0) {
10261027
return -EINVAL;
10271028
}

0 commit comments

Comments
 (0)