当前位置:网站首页>paho.mqtt.c使用的总结
paho.mqtt.c使用的总结
2022-04-22 21:22:00 【霍宏鹏】
1 MQTTAsync_connectOptions中的onSuccess和onFailure
1.1 onSuccess
只有在新建连接成功的时候在会执行这个函数,重连过程不管是否成功都不会执行这个函数。但是通过MQTTAsync_setConnected();接口设置的回调函数,无论是由于什么情况进行了连接,都会执行这个函数。
1.2 onFailure
无论是新建连接,还是重连,只要要连接失败,都会调用调用这个函数
MQTTAsync_connectOptions connect_options = MQTTAsync_connectOptions_initializer;
connect_options.cleansession = 1;
connect_options.keepAliveInterval = 10;
connect_options.connectTimeout = 10;
connect_options.automaticReconnect = 1;
connect_options.minRetryInterval = 1;
connect_options.maxRetryInterval = 30;
/*
* 只有新建连接才会执行这个函数,重连不会执行
*/
connect_options.onSuccess = connect_options_success;
/*
* 如果无论是重连,还是连接失败都会调用这个函数
*/
connect_options.onFailure = connect_options_failure;
connect_options.context = handle;
ret = MQTTAsync_connect(handle, &connect_options);
LOG_I(async, 0, "MQTTAsync_connect: %d\n", ret);
版权声明
本文为[霍宏鹏]所创,转载请带上原文链接,感谢
https://huohongpeng.blog.csdn.net/article/details/118414707
边栏推荐
- SH file content startup file
- Introduction and hardware implementation of sereds deserialization module
- 2022-4-22 Leetcode 91.解码方法
- cuda10.2安装torch1.9
- Openvx's immediate mode and graph mode and examples
- swagger2 注解说明
- 毕业五年,如何从月薪5K涨到年薪50W+,需要掌握哪些核心技能?
- Adobe series error code solutions summary
- 2022 G3 boiler water treatment national question bank and online simulation examination
- Solution Sudoku [pre DS hash structure + component DFS | pre-hash-1-9 feature -- binary state compression + DFS]
猜你喜欢

SEREDS解串模块简介以及硬件实现

What important accessories are included in the M5 enhanced dual system package and how to choose?

shell脚本中解决SCP命令免密登录

kubernetes_ How to solve the problem that namespace cannot be deleted

Huawei interview question: "how can an 800kg cow cross a 700kg bridge?" You can live your life as you think

leetcode-470. Rand10() is implemented with rand7()

News Express I mobtech passed the "special safety evaluation" of China Academy of information and communications

Force buckle - 64 Minimum path sum

Expérience 3

Function and principle of join in thread
随机推荐
Section de configuration des outils générée par le concepteur dans Visual Studio. Solution au problème de la mise à jour tardive des fichiers UI
What is the current situation of domestic computer hardware?
Count the number of characters C
解决Chrome跨域问题 - 跨域系列
不稳定排序(选择,快速)
新闻速递 I MobTech通过中国信通院“安全专项评测”
[tool configuration] generated by designer in visual studio Solution to the problem of UI file not being updated in time
Freemodbus Quick Start Guide
OpenVX-将Image文件[pgm格式]读写为vx_image对象,以及写操作
kubernetes_ How to solve the problem that namespace cannot be deleted
K8s deploy MySQL
Mapping configuration files to classes in. Net core
MySQL is still suitable for Silicon Valley courses (I)
[play Lighthouse] build WooCommerce store, enable Alipay to pay in person.
Hdlbits (XI) learning notes - finite state machine (FSM onehot - FSM serialdp)
如何用laragon框架运行php文件
swagger2 注解说明
Brief introduction to common database engines
Solving chrome cross domain problems - cross domain series
Thread communication mechanism: shared memory VS message passing