Skip to content

Commit e1d7771

Browse files
rluboskartben
authored andcommitted
net: mqtt-sn: Correct the allowed Keep Alive value range
Keep Alive timeout is represented by 2-byte unsigned integer, however the corresponding Kconfig option was limited to UINT8_MAX only. Also, similarly to regular MQTT, allow to disable the Keep Alive functionality by specifying the Keep Alive value to 0. Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
1 parent 5b6a865 commit e1d7771

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

subsys/net/lib/mqtt_sn/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ config MQTT_SN_LIB_MAX_PUBLISH
5858
config MQTT_SN_KEEPALIVE
5959
int "Maximum number of clients Keep alive time for MQTT-SN (in seconds)"
6060
default 60
61-
range 1 $(UINT8_MAX)
61+
range 0 $(UINT16_MAX)
6262
help
6363
Keep alive time for MQTT-SN (in seconds). Sending of Ping Requests to
6464
keep the connection alive are governed by this value.

subsys/net/lib/mqtt_sn/mqtt_sn.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,11 @@ static int process_ping(struct mqtt_sn_client *client, int64_t *next_cycle)
842842
struct mqtt_sn_gateway *gw = NULL;
843843
int64_t next_ping;
844844

845+
if (CONFIG_MQTT_SN_KEEPALIVE == 0) {
846+
/* Keep Alive disabled. */
847+
return 0;
848+
}
849+
845850
if (client->ping_retries == N_RETRY) {
846851
/* Last ping was acked */
847852
next_ping = client->last_ping + T_KEEPALIVE_MSEC;

0 commit comments

Comments
 (0)