Search code examples
ibm-cloudmqttiotnode-red

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. I want to be able to send control commands from my iPhone to the Pi and have the Pi respond with a status update.

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).

The iPhone Swift app is using https://cocoapods.org/pods/MQTTClient (Note - does not specifically list IBM IoT as a tested platform).

From the Swift app, I have successfully connected to IBM IoTF and sent events which the Pi receives. I have also successfully subscribed to command topics in the form "iot-2/cmd/streamStarted/fmt/json", but never receive a message. 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.

The bottom line is that I need to get a status message from the Pi to the iPhone in some way. 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.


Solution

  • 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?