简体   繁体   English

一台设备是否可以从IBM IoTF上的另一台设备预订MQTT事件或命令?

[英]Is it possible for one device to subscribe to MQTT events or commands from another device on IBM IoTF?

I am building an iOS app to control my Raspberry Pi over MQTT. 我正在构建一个iOS应用程序以通过MQTT控制我的Raspberry Pi。 I want to be able to send control commands from my iPhone to the Pi and have the Pi respond with a status update. 我希望能够将控制命令从iPhone发送到Pi,并让Pi响应状态更新。

The Pi is running Node-RED and can both send and receive both events and commands to IBM IoT Foundation (verified from a Bluemix Node-RED application). Pi正在运行Node-RED,并且可以将事件和命令发送和接收到IBM IoT Foundation(已从Bluemix Node-RED应用程序进行了验证)。

The iPhone Swift app is using https://cocoapods.org/pods/MQTTClient (Note - does not specifically list IBM IoT as a tested platform). iPhone Swift应用程序正在使用https://cocoapods.org/pods/MQTTClient (注意-未将IBM IoT专门列出为经过测试的平台)。

From the Swift app, I have successfully connected to IBM IoTF and sent events which the Pi receives. 通过Swift应用程序,我已成功连接到IBM IoTF并发送了Pi接收到的事件 I have also successfully subscribed to command topics in the form "iot-2/cmd/streamStarted/fmt/json" , but never receive a message. 我还以"iot-2/cmd/streamStarted/fmt/json"的形式成功订阅了命令主题,但从未收到任何消息。 If I try to publish a command in the form "iot-2/cmd/startStream/fmt/json" or subscribe to events in the form "iot-2/evt/streamStarted/fmt/json" or "iot-2/type/myPi/id/<myPiID>/evt/streamStarted/fmt/json" , the connection immediately closes. 如果我尝试以"iot-2/cmd/startStream/fmt/json"形式发布命令,或者以"iot-2/evt/streamStarted/fmt/json""iot-2/type/myPi/id/<myPiID>/evt/streamStarted/fmt/json"形式订阅事件"iot-2/type/myPi/id/<myPiID>/evt/streamStarted/fmt/json" ,连接立即关闭。

The bottom line is that I need to get a status message from the Pi to the iPhone in some way. 最重要的是,我需要以某种方式从Pi到iPhone收到状态消息。 I don't really care if it is an event, a command or something else. 我真的不在乎它是事件,命令还是其他东西。 I have been successful doing this with test.mosquitto.org , events but not IoT Foundation. 我通过test.mosquitto.org事件(但不是IoT Foundation)成功完成了此test.mosquitto.org

Only applications can send commands to a device. 仅应用程序可以将命令发送到设备。 You can't send a command from one device to another. 您无法将命令从一台设备发送到另一台设备。 Is the iphone swift app connecting to IoT Foundation as an application or trying to connect as a device? iPhone Swift App是作为应用程序连接到IoT Foundation还是作为设备连接?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM