mosquitto 桥接环境

环境如下:

 

在AP板子端操作:(注:允许有多个AP同时在线)

下列配置实现AP和PC之间的双向桥接,AP端发布的消息如果前缀为local/sensor/,该消息将转发到PC端前缀为remote/sensor/的topic;

同理,PC端发布的消息如果前缀为remote/sensor/,则该消息将转发到AP端前缀为local/sensor/的topic;

/etc/mosquitto/mosquitto-1.conf

log_type all

user root

connection server-PC

address 192.168.1.102:1883

topic # both 0 local/sensor/ remote/sensor/

clientid 1_4

cleansession true

执行服务器程序: mosquitto -c mosquitto-1.conf

执行订阅者程序: mosquitto_sub -t local/sensor/#

执行发布者程序: mosquitto_pub -t local/sensor/room -m "`date`"

 

在PC端操作:(注意:当在AP端配置了both方向的bridge后,在PC端不需要再进行bridge配置)

执行服务器程序: ~/mosquitto-1.4.4/mosquitto

执行订阅者程序: ~/mosquitto-1.4.4/client/mosquitto_sub -t remote/sensor/#

执行发布者程序: ~/mosquitto-1.4.4/client/mosquitto_pub -t remote/sensor/room -m "`date`"

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值