Merge pull request #14444 from akshaim/Kconfig_asymcute
net/asymcute : Expose configurations to Kconfig
This commit is contained in:
commit
fe7700c7de
@ -58,11 +58,86 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup net_asymcute_conf Asymcute (MQTT-SN Client) compile configurations
|
||||
* @ingroup config
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Default buffer size for Asymcute client (as exponent of 2^n)
|
||||
*
|
||||
* As the buffer size ALWAYS needs to be power of two, this option represents
|
||||
* the exponent of 2^n, which will be used as the size of the buffer.
|
||||
*/
|
||||
#ifndef CONFIG_ASYMCUTE_BUFSIZE_EXP
|
||||
#define CONFIG_ASYMCUTE_BUFSIZE_EXP (7U)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Maximum topic length
|
||||
*
|
||||
* @note Must be less than (256 - 8) AND less than ( @ref ASYMCUTE_BUFSIZE - 8).
|
||||
*/
|
||||
#ifndef CONFIG_ASYMCUTE_TOPIC_MAXLEN
|
||||
#define CONFIG_ASYMCUTE_TOPIC_MAXLEN (32U)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Keep alive interval [in s] communicated to the gateway
|
||||
*
|
||||
* keep alive interval in seconds which is communicated to the gateway in the
|
||||
* CONNECT message. For more information, see MQTT-SN Spec v1.2, section 5.4.4.
|
||||
* For default values,see section 7.2 -> TWAIT: > 5 min.
|
||||
*/
|
||||
#ifndef CONFIG_ASYMCUTE_KEEPALIVE
|
||||
#define CONFIG_ASYMCUTE_KEEPALIVE (360)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Interval to use for sending periodic ping messages
|
||||
*
|
||||
* The default behavior of this implementation is to send ping messages as soon
|
||||
* as three quarters of the keep alive interval have passed.
|
||||
*
|
||||
* @note Must be less than @ref CONFIG_ASYMCUTE_KEEPALIVE
|
||||
*/
|
||||
#ifndef CONFIG_ASYMCUTE_KEEPALIVE_PING
|
||||
#define CONFIG_ASYMCUTE_KEEPALIVE_PING ((CONFIG_ASYMCUTE_KEEPALIVE / 4) * 3)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Resend interval [in seconds]
|
||||
*
|
||||
* Interval used for timing the retry messages which are sent when the expected
|
||||
* reply from GW is not received. The retry timer is started by the client when
|
||||
* the message is sent and stopped when the expected reply from GW is received.
|
||||
* If the timer times out and the expected GW’s reply is not received, the
|
||||
* client retransmits the message. For more information, see MQTT-SN Spec v1.2,
|
||||
* section 6.13. For default values, see section 7.2 -> Tretry: 10 to 15 sec.
|
||||
*/
|
||||
#ifndef CONFIG_ASYMCUTE_T_RETRY
|
||||
#define CONFIG_ASYMCUTE_T_RETRY (10U)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Number of retransmissions until requests time out
|
||||
*
|
||||
* Maximum number of retransmissions in the event that the retry timer times
|
||||
* out. After 'CONFIG_ASYMCUTE_N_RETRY' number of retransmissions, the client
|
||||
* aborts the procedure and assumes that its MQTT-SN connection to the gateway
|
||||
* is disconnected. For more information, see MQTT-SN Spec v1.2, section 6.13.
|
||||
* For default values, see section 7.2 -> Nretry: 3-5.
|
||||
*/
|
||||
#ifndef CONFIG_ASYMCUTE_N_RETRY
|
||||
#define CONFIG_ASYMCUTE_N_RETRY (3U)
|
||||
#endif
|
||||
/** @} */
|
||||
|
||||
#ifndef ASYMCUTE_BUFSIZE
|
||||
/**
|
||||
* @brief Default buffer size used for receive and request buffers
|
||||
*/
|
||||
#define ASYMCUTE_BUFSIZE (128U)
|
||||
#define ASYMCUTE_BUFSIZE (1 << CONFIG_ASYMCUTE_BUFSIZE_EXP)
|
||||
#endif
|
||||
|
||||
#ifndef ASYMCUTE_HANDLER_PRIO
|
||||
@ -95,54 +170,6 @@ extern "C" {
|
||||
#define ASYMCUTE_LISTENER_STACKSIZE (THREAD_STACKSIZE_DEFAULT)
|
||||
#endif
|
||||
|
||||
#ifndef ASYMCUTE_TOPIC_MAXLEN
|
||||
/**
|
||||
* @brief Maximum topic length
|
||||
*
|
||||
* @note Must be less than (256 - 8) AND less than (ASYMCUTE_BUFSIZE - 8).
|
||||
*/
|
||||
#define ASYMCUTE_TOPIC_MAXLEN (32U)
|
||||
#endif
|
||||
|
||||
#ifndef ASYMCUTE_KEEPALIVE
|
||||
/**
|
||||
* @brief Keep alive interval [in s] communicated to the gateway
|
||||
*
|
||||
* For the default value, see spec v1.2, section 7.2 -> T_WAIT: > 5 min
|
||||
*/
|
||||
#define ASYMCUTE_KEEPALIVE (360) /* -> 6 min*/
|
||||
#endif
|
||||
|
||||
#ifndef ASYMCUTE_KEEPALIVE_PING
|
||||
/**
|
||||
* @brief Interval to use for sending periodic ping messages
|
||||
*
|
||||
* The default behavior of this implementation is to send ping messages as soon
|
||||
* as three quarters of the keep alive interval have passed.
|
||||
*
|
||||
* @note Must be less than ASYMCUTE_KEEPALIVE
|
||||
*/
|
||||
#define ASYMCUTE_KEEPALIVE_PING ((ASYMCUTE_KEEPALIVE / 4) * 3)
|
||||
#endif
|
||||
|
||||
#ifndef ASYMCUTE_T_RETRY
|
||||
/**
|
||||
* @brief Resend interval [in seconds]
|
||||
*
|
||||
* For the default value, see spec v1.2, section 7.2 -> T_RETRY: 10 to 15 sec
|
||||
*/
|
||||
#define ASYMCUTE_T_RETRY (10U) /* -> 10 sec */
|
||||
#endif
|
||||
|
||||
#ifndef ASYMCUTE_N_RETRY
|
||||
/**
|
||||
* @brief Number of retransmissions until requests time out
|
||||
*
|
||||
* For the default value, see spec v1.2, section 7.2 -> N_RETRY: 3-5
|
||||
*/
|
||||
#define ASYMCUTE_N_RETRY (3U)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Return values used by public Asymcute functions
|
||||
*/
|
||||
@ -272,7 +299,7 @@ struct asymcute_con {
|
||||
*/
|
||||
struct asymcute_topic {
|
||||
asymcute_con_t *con; /**< connection used for registration */
|
||||
char name[ASYMCUTE_TOPIC_MAXLEN + 1]; /**< topic string (ACSII only) */
|
||||
char name[CONFIG_ASYMCUTE_TOPIC_MAXLEN + 1]; /**< topic string (ACSII only) */
|
||||
uint8_t flags; /**< normal, short, or pre-defined */
|
||||
uint16_t id; /**< topic id */
|
||||
};
|
||||
|
||||
@ -4,6 +4,8 @@
|
||||
# General Public License v2.1. See the file LICENSE in the top level
|
||||
# directory for more details.
|
||||
#
|
||||
rsource "asymcute/Kconfig"
|
||||
|
||||
menu "CoAP"
|
||||
|
||||
rsource "Kconfig.coap"
|
||||
|
||||
88
sys/net/application_layer/asymcute/Kconfig
Normal file
88
sys/net/application_layer/asymcute/Kconfig
Normal file
@ -0,0 +1,88 @@
|
||||
# Copyright (c) 2020 Freie Universitaet Berlin
|
||||
#
|
||||
# This file is subject to the terms and conditions of the GNU Lesser
|
||||
# General Public License v2.1. See the file LICENSE in the top level
|
||||
# directory for more details.
|
||||
#
|
||||
menuconfig KCONFIG_MODULE_ASYMCUTE
|
||||
bool "Configure Asymcute"
|
||||
depends on MODULE_ASYMCUTE
|
||||
help
|
||||
Configure Asymcute using Kconfig.`Asymcute` is a asynchronous MQTT-SN
|
||||
client implementation, aiming at providing the user a high degree of
|
||||
flexibility. It provides a flexible interface that allows users to issue
|
||||
any number of concurrent requests to one or more different gateways
|
||||
simultaneously.
|
||||
|
||||
if KCONFIG_MODULE_ASYMCUTE
|
||||
|
||||
config ASYMCUTE_BUFSIZE_EXP
|
||||
int "Exponent for the buffer size (resulting in the buffer size 2^n)"
|
||||
default 7
|
||||
help
|
||||
As the buffer size ALWAYS needs to be power of two, this option
|
||||
represents the exponent of 2^n, which will be used as the size of the
|
||||
buffer ('ASYMCUTE_BUFSIZE'). Default value is 7 which corresponds to a
|
||||
buffer size of 128.
|
||||
|
||||
config ASYMCUTE_TOPIC_MAXLEN
|
||||
int "Maximum topic length"
|
||||
default 32
|
||||
help
|
||||
Configure maximum length for client's topic. The value must be less than
|
||||
(256 - 8) and less than ('ASYMCUTE_BUFSIZE' - 8).
|
||||
|
||||
config ASYMCUTE_KEEPALIVE
|
||||
int "Keep alive interval in seconds"
|
||||
range 300 $(UINT32_MAX)
|
||||
default 360
|
||||
help
|
||||
Configure 'CONFIG_ASYMCUTE_KEEPALIVE', keep alive interval in seconds
|
||||
which is communicated to the gateway in the CONNECT message. For more
|
||||
information, see MQTT-SN Spec v1.2, section 5.4.4. For default values,
|
||||
see section 7.2 -> TWAIT: > 5 min. Default value is 360 seconds which
|
||||
corresponds to 6 minutes.
|
||||
|
||||
config ASYMCUTE_KEEPALIVE_PING_EN
|
||||
bool "Enable configuration of keep alive ping"
|
||||
help
|
||||
Enable configuration of 'CONFIG_ASYMCUTE_KEEPALIVE_PING', keep alive
|
||||
ping interval. If not enabled, 'CONFIG_ASYMCUTE_KEEPALIVE_PING' will
|
||||
default to three quarters of 'CONFIG_ASYMCUTE_KEEPALIVE', keep alive
|
||||
interval.
|
||||
|
||||
config ASYMCUTE_KEEPALIVE_PING
|
||||
int "Keep alive ping interval in seconds"
|
||||
default 270
|
||||
depends on ASYMCUTE_KEEPALIVE_PING_EN
|
||||
help
|
||||
Configure 'CONFIG_ASYMCUTE_KEEPALIVE_PING', interval used by client for
|
||||
sending periodic keep alive ping messages to the gateway. The value must
|
||||
be less than 'CONFIG_ASYMCUTE_KEEPALIVE'.
|
||||
|
||||
config ASYMCUTE_T_RETRY
|
||||
int "Retry timer in seconds"
|
||||
range 10 15
|
||||
default 10
|
||||
help
|
||||
Configure 'CONFIG_ASYMCUTE_T_RETRY', interval used for timing the retry
|
||||
messages which are sent when the expected reply from GW is not received.
|
||||
The retry timer is started by the client when the message is sent and
|
||||
stopped when the expected reply from GW is received. If the timer times
|
||||
out and the expected GW’s reply is not received, the client retransmits
|
||||
the message. For more information, see MQTT-SN Spec v1.2, section 6.13.
|
||||
For default values, see section 7.2 -> Tretry: 10 to 15 sec.
|
||||
|
||||
config ASYMCUTE_N_RETRY
|
||||
int "Maximum number of retransmissions"
|
||||
range 3 5
|
||||
default 3
|
||||
help
|
||||
Configure 'CONFIG_ASYMCUTE_N_RETRY',the maximum number of retransmissions
|
||||
in the event that the retry timer times out. After 'CONFIG_ASYMCUTE_N_RETRY'
|
||||
number of retransmissions, the client aborts the procedure and assumes
|
||||
that its MQTT-SN connection to the gateway is disconnected. For more
|
||||
information, see MQTT-SN Spec v1.2, section 6.13. For default values,
|
||||
see section 7.2 -> Nretry: 3-5.
|
||||
|
||||
endif # KCONFIG_MODULE_ASYMCUTE
|
||||
@ -31,8 +31,8 @@
|
||||
|
||||
#define PROTOCOL_VERSION (0x01)
|
||||
|
||||
#define RETRY_TO (ASYMCUTE_T_RETRY * US_PER_SEC)
|
||||
#define KEEPALIVE_TO (ASYMCUTE_KEEPALIVE_PING * US_PER_SEC)
|
||||
#define RETRY_TO (CONFIG_ASYMCUTE_T_RETRY * US_PER_SEC)
|
||||
#define KEEPALIVE_TO (CONFIG_ASYMCUTE_KEEPALIVE_PING * US_PER_SEC)
|
||||
|
||||
#define VALID_PUBLISH_FLAGS (MQTTSN_QOS_1 | MQTTSN_DUP | MQTTSN_RETAIN)
|
||||
#define VALID_SUBSCRIBE_FLAGS (MQTTSN_QOS_1 | MQTTSN_DUP)
|
||||
@ -181,7 +181,7 @@ static void _req_send(asymcute_req_t *req, asymcute_con_t *con,
|
||||
/* initialize request */
|
||||
req->con = con;
|
||||
req->cb = cb;
|
||||
req->retry_cnt = ASYMCUTE_N_RETRY;
|
||||
req->retry_cnt = CONFIG_ASYMCUTE_N_RETRY;
|
||||
event_callback_init(&req->to_evt, _on_req_timeout, (void *)req);
|
||||
event_timeout_init(&req->to_timer, &_queue, &req->to_evt.super);
|
||||
/* add request to the pending queue (if non-con request) */
|
||||
@ -328,7 +328,7 @@ static void _on_connack(asymcute_con_t *con, const uint8_t *data, size_t len)
|
||||
if (data[2] == MQTTSN_ACCEPTED) {
|
||||
con->state = CONNECTED;
|
||||
/* start keep alive timer */
|
||||
con->keepalive_retry_cnt = ASYMCUTE_N_RETRY;
|
||||
con->keepalive_retry_cnt = CONFIG_ASYMCUTE_N_RETRY;
|
||||
event_timeout_set(&con->keepalive_timer, KEEPALIVE_TO);
|
||||
ret = ASYMCUTE_CONNECTED;
|
||||
}
|
||||
@ -369,9 +369,9 @@ static void _on_pingresp(asymcute_con_t *con)
|
||||
{
|
||||
mutex_lock(&con->lock);
|
||||
/* only handle ping resp message if we are actually waiting for a reply */
|
||||
if (con->keepalive_retry_cnt < ASYMCUTE_N_RETRY) {
|
||||
if (con->keepalive_retry_cnt < CONFIG_ASYMCUTE_N_RETRY) {
|
||||
event_timeout_clear(&con->keepalive_timer);
|
||||
con->keepalive_retry_cnt = ASYMCUTE_N_RETRY;
|
||||
con->keepalive_retry_cnt = CONFIG_ASYMCUTE_N_RETRY;
|
||||
event_timeout_set(&con->keepalive_timer, KEEPALIVE_TO);
|
||||
}
|
||||
mutex_unlock(&con->lock);
|
||||
@ -637,7 +637,7 @@ int asymcute_listener_run(asymcute_con_t *con, char *stack, size_t stacksize,
|
||||
random_bytes((uint8_t *)&con->last_id, 2);
|
||||
event_callback_init(&con->keepalive_evt, _on_keepalive_evt, con);
|
||||
event_timeout_init(&con->keepalive_timer, &_queue, &con->keepalive_evt.super);
|
||||
con->keepalive_retry_cnt = ASYMCUTE_N_RETRY;
|
||||
con->keepalive_retry_cnt = CONFIG_ASYMCUTE_N_RETRY;
|
||||
con->state = NOTCON;
|
||||
con->user_cb = callback;
|
||||
|
||||
@ -679,7 +679,7 @@ int asymcute_topic_init(asymcute_topic_t *topic, const char *topic_name,
|
||||
}
|
||||
else {
|
||||
len = strlen(topic_name);
|
||||
if ((len == 0) || (len > ASYMCUTE_TOPIC_MAXLEN)) {
|
||||
if ((len == 0) || (len > CONFIG_ASYMCUTE_TOPIC_MAXLEN)) {
|
||||
return ASYMCUTE_OVERFLOW;
|
||||
}
|
||||
}
|
||||
@ -752,7 +752,7 @@ int asymcute_connect(asymcute_con_t *con, asymcute_req_t *req,
|
||||
req->data[1] = MQTTSN_CONNECT;
|
||||
req->data[2] = ((clean) ? MQTTSN_CS : 0);
|
||||
req->data[3] = PROTOCOL_VERSION;
|
||||
byteorder_htobebufs(&req->data[4], ASYMCUTE_KEEPALIVE);
|
||||
byteorder_htobebufs(&req->data[4], CONFIG_ASYMCUTE_KEEPALIVE);
|
||||
memcpy(&req->data[6], cli_id, id_len);
|
||||
req->data_len = (size_t)req->data[0];
|
||||
_req_send(req, con, _on_con_timeout);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user