diff --git a/docs/API_reference/en/networklib/umqtt.md b/docs/API_reference/en/networklib/umqtt.md index 40e42e56b6450f9133e0343275e661d92ffd9da0..9439f30185aafffeeefa2eb29d7d5861debcb379 100644 --- a/docs/API_reference/en/networklib/umqtt.md +++ b/docs/API_reference/en/networklib/umqtt.md @@ -251,6 +251,8 @@ MQTTClient.wait_msg() Blocks waiting for a message response from the MQTT server. +>If this method is called in a thread, it is necessary to ensure that the thread stack created is >= 16K. For details, please refer to the mqtt reconnection sample code. + * Parameter None @@ -381,6 +383,7 @@ import net import _thread import checkNet import dataCall +import uos from umqtt import MQTTClient PROJECT_NAME = "QuecPython_MQTT_example" @@ -552,7 +555,18 @@ class MqttClient(): return -1 def loop_forever(self): + task_stacksize =_thread.stack_size() + name,platform = uos.uname()[1].split("=",1) + if platform == "EC600E" or platform == "EC800E": + _thread.stack_size(8 * 1024) + elif platform == "FCM362K": + _thread.stack_size(3 * 1024) + else: + _thread.stack_size(16 * 1024) + # Before creating a thread, modify the thread stack space according to the platform. _thread.start_new_thread(self.__listen, ()) + # After the thread is created successfully, the platform thread stack default size is restored. + _thread.stack_size(task_stacksize) if __name__ == '__main__': ''' diff --git a/docs/API_reference/zh/networklib/umqtt.md b/docs/API_reference/zh/networklib/umqtt.md index 5358e766c9e8c588510a704b1de2813b5668d183..00a6b029470667edcbf8fb99078a175ec92517d2 100644 --- a/docs/API_reference/zh/networklib/umqtt.md +++ b/docs/API_reference/zh/networklib/umqtt.md @@ -222,6 +222,7 @@ MQTTClient.wait_msg() 阻塞等待服务器消息响应。 +>该方法如果在线程中调用时,需保证创建线程栈空间>=16K,具体请参照mqtt重连示例代码. ### `MQTTClient.get_mqttsta` @@ -339,6 +340,7 @@ import net import _thread import checkNet import dataCall +import uos from umqtt import MQTTClient PROJECT_NAME = "QuecPython_MQTT_example" @@ -510,7 +512,18 @@ class MqttClient(): return -1 def loop_forever(self): + task_stacksize =_thread.stack_size() + name,platform = uos.uname()[1].split("=",1) + if platform == "EC600E" or platform == "EC800E": + _thread.stack_size(8 * 1024) + elif platform == "FCM362K": + _thread.stack_size(3 * 1024) + else: + _thread.stack_size(16 * 1024) + # 创建线程之前,按照平台,修改线程栈空间。 _thread.start_new_thread(self.__listen, ()) + # 线程创建成功后,恢复平台线程栈默认大小。 + _thread.stack_size(task_stacksize) if __name__ == '__main__': '''