《
树莓派 IoT 学习2 shell搭建mqtt环境》中,脚本的编写是针对Ubuntu的,后来把脚本修改放在centos6.4中,并不能行的通。问题如下:
1.
mosquitto_internal.h:40:20: 错误:ares.h:没有那个文件或目录
2.
read_handle_server.c:31:25: 错误:uuid/uuid.h:没有那个文件或目录
解决办法是在config.mk中把WITH_SRV:=yes 和
WITH_UUID:=yes屏蔽掉,因为这个是与平台有点关系,原内容是这样的:
# Build with SRV lookup support.
WITH_SRV:=yes
# Build using libuuid for clientid generation (Linux only - please report if
# supported on your platform).
WITH_UUID:=yes
WITH_SRV:=yes
# Build using libuuid for clientid generation (Linux only - please report if
# supported on your platform).
WITH_UUID:=yes
<-----------------------------------------------------------------------------分割线---------------------------------------------------------------------------------------------------->
进入学习正题,mosquito中需要设置的东西还没有细看,比如加密,监听等等。基于初步的应用倒是很容易。环境及配置是这样的:
1.树莓派中,运行mosquito_pub和mosquito_sub负责数据的上传,接收
2.惠普ubuntu系统,运行mosquito代理
3.虚拟机centos6.4,运行mosquito_pub和mosquito_sub负责数据的上传,接收
3个系统里都装了mosquitto软件,然后就可以用图片中的指令简单测试了,关于指令说明,用 mosquito_pub --help等查看吧,当然,项目中是要码代码的。
这张是树莓派发布,centos端接收的情况:
这张图是,树莓派及centos端都订阅同一个主题,实现消息双向通讯: