1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

net/asymcute : Move 'ASYMCUTE_BUFSIZE' to 'CONFIG_'

Move ASYMCUTE_BUFSIZE to CONFIG_ namespace, update entry in Kconfig
This commit is contained in:
Akshai M 2020-11-10 15:45:26 +01:00 committed by Akshai M
parent 8f36c817eb
commit 1559aa1dc6
3 changed files with 16 additions and 21 deletions

View File

@ -80,10 +80,17 @@ extern "C" {
#define CONFIG_ASYMCUTE_BUFSIZE_EXP (7U) #define CONFIG_ASYMCUTE_BUFSIZE_EXP (7U)
#endif #endif
/**
* @brief Default buffer size used for receive and request buffers
*/
#ifndef CONFIG_ASYMCUTE_BUFSIZE
#define CONFIG_ASYMCUTE_BUFSIZE (128U)
#endif
/** /**
* @brief Maximum topic length * @brief Maximum topic length
* *
* @note Must be less than (256 - 8) AND less than ( @ref ASYMCUTE_BUFSIZE - 8). * @note Must be less than (256 - 8) AND less than ( @ref CONFIG_ASYMCUTE_BUFSIZE - 8).
*/ */
#ifndef CONFIG_ASYMCUTE_TOPIC_MAXLEN #ifndef CONFIG_ASYMCUTE_TOPIC_MAXLEN
#define CONFIG_ASYMCUTE_TOPIC_MAXLEN (32U) #define CONFIG_ASYMCUTE_TOPIC_MAXLEN (32U)
@ -140,13 +147,6 @@ extern "C" {
#endif #endif
/** @} */ /** @} */
#ifndef ASYMCUTE_BUFSIZE
/**
* @brief Default buffer size used for receive and request buffers
*/
#define ASYMCUTE_BUFSIZE (1 << CONFIG_ASYMCUTE_BUFSIZE_EXP)
#endif
#ifndef ASYMCUTE_HANDLER_PRIO #ifndef ASYMCUTE_HANDLER_PRIO
/** /**
* @brief Default priority for Asymcute's handler thread * @brief Default priority for Asymcute's handler thread
@ -275,7 +275,7 @@ struct asymcute_req {
void *arg; /**< internally used additional state */ void *arg; /**< internally used additional state */
event_callback_t to_evt; /**< timeout event */ event_callback_t to_evt; /**< timeout event */
event_timeout_t to_timer; /**< timeout timer */ event_timeout_t to_timer; /**< timeout timer */
uint8_t data[ASYMCUTE_BUFSIZE]; /**< buffer holding the request's data */ uint8_t data[CONFIG_ASYMCUTE_BUFSIZE]; /**< buffer holding the request's data */
size_t data_len; /**< length of the request packet in byte */ size_t data_len; /**< length of the request packet in byte */
uint16_t msg_id; /**< used message id for this request */ uint16_t msg_id; /**< used message id for this request */
uint8_t retry_cnt; /**< retransmission counter */ uint8_t retry_cnt; /**< retransmission counter */
@ -297,7 +297,7 @@ struct asymcute_con {
* connection */ * connection */
uint8_t keepalive_retry_cnt; /**< keep alive transmission counter */ uint8_t keepalive_retry_cnt; /**< keep alive transmission counter */
uint8_t state; /**< connection state */ uint8_t state; /**< connection state */
uint8_t rxbuf[ASYMCUTE_BUFSIZE]; /**< connection specific receive buf */ uint8_t rxbuf[CONFIG_ASYMCUTE_BUFSIZE]; /**< connection specific receive buf */
char cli_id[MQTTSN_CLI_ID_MAXLEN + 1]; /**< buffer to store client ID */ char cli_id[MQTTSN_CLI_ID_MAXLEN + 1]; /**< buffer to store client ID */
}; };

View File

@ -24,21 +24,16 @@ config ASYMCUTE_DEFAULT_PORT
to macro 'CONFIG_ASYMCUTE_DEFAULT_PORT'. Usage can be found in to macro 'CONFIG_ASYMCUTE_DEFAULT_PORT'. Usage can be found in
examples/asymcute_mqttsn examples/asymcute_mqttsn
config ASYMCUTE_BUFSIZE_EXP config ASYMCUTE_BUFSIZE
int "Exponent for the buffer size (resulting in the buffer size 2^n)" int "Size of buffer used for receive and request buffers"
default 7 default 128
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 config ASYMCUTE_TOPIC_MAXLEN
int "Maximum topic length" int "Maximum topic length"
default 32 default 32
help help
Configure maximum length for client's topic. The value must be less than Configure maximum length for client's topic. The value must be less than
(256 - 8) and less than ('ASYMCUTE_BUFSIZE' - 8). (256 - 8) and less than ('CONFIG_ASYMCUTE_BUFSIZE' - 8).
config ASYMCUTE_KEEPALIVE config ASYMCUTE_KEEPALIVE
int "Keep alive interval in seconds" int "Keep alive interval in seconds"

View File

@ -597,7 +597,7 @@ void *_listener(void *arg)
while (1) { while (1) {
sock_udp_ep_t remote; sock_udp_ep_t remote;
int n = sock_udp_recv(&con->sock, con->rxbuf, ASYMCUTE_BUFSIZE, int n = sock_udp_recv(&con->sock, con->rxbuf, CONFIG_ASYMCUTE_BUFSIZE,
SOCK_NO_TIMEOUT, &remote); SOCK_NO_TIMEOUT, &remote);
if (n > 0) { if (n > 0) {
_on_data(con, (size_t)n, &remote); _on_data(con, (size_t)n, &remote);
@ -860,7 +860,7 @@ int asymcute_publish(asymcute_con_t *con, asymcute_req_t *req,
return ASYMCUTE_NOTSUP; return ASYMCUTE_NOTSUP;
} }
/* check for message size */ /* check for message size */
if ((data_len + 9) > ASYMCUTE_BUFSIZE) { if ((data_len + 9) > CONFIG_ASYMCUTE_BUFSIZE) {
return ASYMCUTE_OVERFLOW; return ASYMCUTE_OVERFLOW;
} }
/* make sure topic is registered */ /* make sure topic is registered */