环境如下:
在AP板子端操作:(注:允许有多个AP同时在线)
下列配置实现AP和PC之间的双向桥接,AP端发布的消息如果前缀为local/sensor/,该消息将转发到PC端前缀为remote/sensor/的topic;
同理,PC端发布的消息如果前缀为remote/sensor/,则该消息将转发到AP端前缀为local/sensor/的topic;
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/# |
在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`" |