我正在设置我的 MQTT 设备。我从 ESP8266 + NodeMCU v2 发送的代码是这样的:
client.publish(ANSWER_TEMPERATURE_TOPIC, buffer);
“answer/node_1 / temperature”在哪里ANSWER_TEMPERATURE_TOPIC
,例如22.10。我在连接到时设置了我的设备buffer
const char* CLIENT_ID = "node_1";
client.connect(CLIENT_ID, MQTT_USERNAME, MQTT_PASSWORD)
是否有可能在接收消息期间检查此 ID CLIENT?我在我的树莓派中运行这个命令:
mosquitto_sub -d -u pi -P channel -t answer/node_1/temperature
答案是
Client mosqsub/1021-raspberryp sending CONNECT
Client mosqsub/1021-raspberryp received CONNACK
Client mosqsub/1021-raspberryp sending SUBSCRIBE (Mid: 1, Topic:
answer/node_1/temperature, QoS: 0)
Client mosqsub/1021-raspberryp received SUBACK
Subscribed (mid: 1): 0
Client mosqsub/1021-raspberryp received PUBLISH (d0, q0, r0, m0,
'answer/node_1/temperature', ... (5 bytes))
21.8
有没有可能看到这个 CLIENT_ID?将来,我想创建 PHP 文件来接收此消息。