Skip to content

Commit ea6ca0e

Browse files
committed
make mqtt thread stack size runtime configurable
Signed-off-by: Ajay Bhargav <[email protected]>
1 parent 7682f34 commit ea6ca0e

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

mqttclient/mqttclient.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,7 @@ static int mqtt_connect_with_results(mqtt_client_t* c)
10371037
if(NULL == c->mqtt_thread) {
10381038
mqtt_set_client_state(c, CLIENT_STATE_CONNECTED);
10391039
/* connect success, and need init mqtt thread */
1040-
c->mqtt_thread= platform_thread_init("mqtt_yield_thread", mqtt_yield_thread, c, MQTT_THREAD_STACK_SIZE, MQTT_THREAD_PRIO, MQTT_THREAD_TICK);
1040+
c->mqtt_thread= platform_thread_init("mqtt_yield_thread", mqtt_yield_thread, c, c->mqtt_thread_stack_size, MQTT_THREAD_PRIO, MQTT_THREAD_TICK);
10411041

10421042
if (NULL != c->mqtt_thread) {
10431043
platform_thread_startup(c->mqtt_thread);
@@ -1133,6 +1133,7 @@ static int mqtt_init(mqtt_client_t* c)
11331133
c->mqtt_keep_alive_interval = MQTT_KEEP_ALIVE_INTERVAL;
11341134
c->mqtt_version = MQTT_VERSION;
11351135
c->mqtt_reconnect_try_duration = MQTT_RECONNECT_DEFAULT_DURATION;
1136+
c->mqtt_thread_stack_size = MQTT_THREAD_STACK_SIZE;
11361137

11371138
c->mqtt_will_options = NULL;
11381139
c->mqtt_reconnect_data = NULL;
@@ -1169,6 +1170,7 @@ MQTT_CLIENT_SET_DEFINE(clean_session, uint32_t, 0)
11691170
MQTT_CLIENT_SET_DEFINE(version, uint32_t, 0)
11701171
MQTT_CLIENT_SET_DEFINE(cmd_timeout, uint32_t, 0)
11711172
MQTT_CLIENT_SET_DEFINE(reconnect_try_duration, uint32_t, 0)
1173+
MQTT_CLIENT_SET_DEFINE(thread_stack_size, uint32_t, 0)
11721174
MQTT_CLIENT_SET_DEFINE(reconnect_handler, reconnect_handler_t, NULL)
11731175
MQTT_CLIENT_SET_DEFINE(interceptor_handler, interceptor_handler_t, NULL)
11741176

mqttclient/mqttclient.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ typedef struct mqtt_client {
112112
uint32_t mqtt_read_buf_size;
113113
uint32_t mqtt_write_buf_size;
114114
uint32_t mqtt_reconnect_try_duration;
115+
uint32_t mqtt_thread_stack_size;
115116
size_t mqtt_client_id_len;
116117
size_t mqtt_user_name_len;
117118
size_t mqtt_password_len;
@@ -159,6 +160,7 @@ MQTT_CLIENT_SET_STATEMENT(cmd_timeout, uint32_t)
159160
MQTT_CLIENT_SET_STATEMENT(read_buf_size, uint32_t)
160161
MQTT_CLIENT_SET_STATEMENT(write_buf_size, uint32_t)
161162
MQTT_CLIENT_SET_STATEMENT(reconnect_try_duration, uint32_t)
163+
MQTT_CLIENT_SET_STATEMENT(thread_stack_size, uint32_t)
162164
MQTT_CLIENT_SET_STATEMENT(reconnect_handler, reconnect_handler_t)
163165
MQTT_CLIENT_SET_STATEMENT(interceptor_handler, interceptor_handler_t)
164166

0 commit comments

Comments
 (0)