RT-Thread-packages / umqtt

A light weight, powerful, customizable, easy-to-use and embeddable mqtt client for RT-Thread
Apache License 2.0
27 stars 10 forks source link

Keep alive interval 设置会影响到 ping #15

Open majianjia opened 3 years ago

majianjia commented 3 years ago

我设置的数字比较小的话,ping会每秒一次。

[606434] I/umqtt:  connect success!
[606435] I/mqtt:  umqtt start success!
[607445] I/umqtt:  ping resp! broker -> client! now tick: 607445 
[608451] I/umqtt:  ping resp! broker -> client! now tick: 608451 
[609461] I/umqtt:  ping resp! broker -> client! now tick: 609461 
[610473] I/umqtt:  ping resp! broker -> client! now tick: 610473 
[611480] I/umqtt:  ping resp! broker -> client! now tick: 611480 
[612569] I/umqtt:  ping resp! broker -> client! now tick: 612569 
[613577] I/umqtt:  ping resp! broker -> client! now tick: 613577 

以上是设置为60的情况。

详细设置如下

#define PKG_USING_UMQTT
#define PKG_UMQTT_SUBRECV_DEF_LENGTH 4
#define PKG_UMQTT_INFO_DEF_SENDSIZE 1024
#define PKG_UMQTT_INFO_DEF_RECVSIZE 1024
#define PKG_UMQTT_INFO_DEF_RECONNECT_MAX_NUM 5
#define PKG_UMQTT_INFO_DEF_RECONNECT_INTERVAL 60
#define PKG_UMQTT_INFO_DEF_KEEPALIVE_MAX_NUM 5
#define PKG_UMQTT_INFO_DEF_HEARTBEAT_INTERVAL 30
#define PKG_UMQTT_INFO_DEF_CONNECT_TIMEOUT 4
#define PKG_UMQTT_INFO_DEF_RECV_TIMEOUT_MS 100
#define PKG_UMQTT_INFO_DEF_SEND_TIMEOUT 4
#define PKG_UMQTT_INFO_DEF_THREAD_STACK_SIZE 2048
#define PKG_UMQTT_INFO_DEF_THREAD_PRIORITY 5
#define PKG_UMQTT_MSG_QUEUE_ACK_DEF_SIZE 4
#define PKG_UMQTT_CONNECT_KEEPALIVE_DEF_TIME 60
#define PKG_UMQTT_PUBLISH_RECON_MAX 3
#define PKG_UMQTT_QOS2_QUE_MAX 1
#define PKG_USING_UMQTT_LATEST_VERSION
majianjia commented 3 years ago

问题出现在这 https://github.com/RT-Thread-packages/umqtt/blob/6609efdab702a2339dbcb9339b27b68b47336b43/src/umqtt.c#L992 这个地方应该乘以RT_TICK_PER_SECOND.

另外这个地方不是应该用 PKG_UMQTT_INFO_DEF_HEARTBEAT_INTERVAL 么? 这个宏从没使用过。