我正在尝试将arduino连接到Watson IoT。 使用以下命令:
mqtt.connect(0, "d6acq3.messaging.internetofthings.ibmcloud.com",1883,"d:d6acq3:Arduino_Helligkeit:1234567890","use-token-auth","<as it was provided>");
这是我用于MQTT的lib 并且connect命令的指定位置如下:
bool connect (int id, String brooker, unsigned int port, String deviceId);
bool connect ([s.o], String userName , String password);
在Watson平台上,我在设备的连接日志中看到以下消息:
Closed connection from 93.231.145.115.
The topic is not valid: use-token-auth
The topic does not match an allowed rule 07.02.2017 11:58:16
Closed connection from 93.231.145.115.
The topic is not valid: use-token-auth
The topic does not match an allowed rule 2 times in the last 5 minutes 07.02.2017 11:58:16
Closed connection from 93.231.145.115.
The topic is not valid: use-token-auth
The topic does not match an allowed rule 07.02.2017 11:56:03
Closed connection from 93.231.145.115.
The topic is not valid: use-token-auth
The topic does not match an allowed rule 07.02.2017 11:45:36
提前感谢任何有助于实现这一目标的帮助。
答案 0 :(得分:1)
正如Dan所说,Watson IoT平台只允许使用某些主题字符串,因此您应确认使用的是正确的主题字符串。
对于应用程序,事件主题: iot-2 / type / {device type} / id / {device id} / evt / {event type} / fmt / {format type}
对于应用程序,命令主题: iot-2 / type / {device type} / id / {device id} / cmd / {command type} / fmt / {format type}
对于设备,活动主题: iot-2 / evt / {event type} / fmt / {format type}
对于设备,命令主题: iot-2 / cmd / {命令类型} / fmt / {格式类型}
但是,我在日志中看到的内容表明您尝试使用比您在帖子中指定的客户端ID更长的客户端ID。我看到了这个错误:
令牌验证失败(设备不存在):ClientID =&#39; d:d6acq3:Arduino_Helligkeit:12345678901486464057428&#39;,
因此,您需要检查以确保您的连接使用您已注册的正确设备ID。