Node-RED IOT Foundation Out Node Not Sending Commands

0 votes

I have a Node-RED application that is bound to an IOT Foundation (iotf) service. I can receive events from devices and handle them appropriately.

However, I am now interested in sending commands back to my devices and am having some problems. Nothing is showing up at the device, but by creating an IOTF in node, I can confirm that the command is passing through iotf.

I can definitely get commands to pass through iotf using pure python, as the follow code works well:

Client code:

#!/usr/bin/python

import ibmiotf.device
from time import sleep

options = {
  "org": "cgmncc",
  "type": "table",
  "id": "b827eb764b7a",
  "auth-method": "token",
  "auth-token": "redacted"
}

def myCommandCallback(cmd):
  print('inside command callback')
  print cmd

def main():
  client = ibmiotf.device.Client(options)
  client.connect()
  client.commandCallback = myCommandCallback
  while True:
    sleep(1)

if __name__ == "__main__":
  main()

Application code:

#!/usr/bin/python

import ibmiotf.application

options = {
  "org": "redacted",
  "id": "python app",
  "auth-method": "apikey",
  "auth-key": "redacted",
  "auth-token": "redacted"
}

try:
  client = ibmiotf.application.Client(options)
  client.connect()
  client.publishCommand('table', 'b827eb764b7a', 'test')
  client.disconnect()
except ibmiotf.ConnectionException as e:
  print e

Whenever I run the application code, I see the following output:

root@raspberrypi ~ # ./app.py 
inside command callback
<ibmiotf.device.Command instance at 0x14e8490>

I have a Node-RED iotf output node configured as shown below, but when I trigger the flow, the command callback function doesn't trigger!

enter image description here enter image description here

I'm thinking there maybe something wrong either with trying to use a timestamp trigger to fire the command, or with the way I've configured the output node itself -- any suggestions or advice would be appreciated!

Jul 18, 2018 in IoT (Internet of Things) by Matt
• 2,270 points
733 views

1 answer to this question.

0 votes

A simple test to check if the commands are reaching IBM IoT Foundation is - developing another flow having an IoT App In node which subscribes to the commands. I am attaching the Node-RED flow for the same here:

[
{
    "id": "40560f8b.30693",
    "type": "ibmiot in",
    "authentication": "boundService",
    "apiKey": "",
    "inputType": "cmd",
    "deviceId": "b827eb764b7a",
    "applicationId": "",
    "deviceType": "table",
    "eventType": "",
    "commandType": "test",
    "format": "string",
    "name": "IBM IoT App In",
    "service": "registered",
    "allDevices": false,
    "allApplications": "",
    "allDeviceTypes": false,
    "allEvents": "",
    "allCommands": false,
    "allFormats": false,
    "x": 268,
    "y": 171,
    "z": "6bd610b9.7b40a",
    "wires": [
        [
            "2f9b9c00.8b7ba4"
        ]
    ]
},
{
    "id": "2f9b9c00.8b7ba4",
    "type": "debug",
    "name": "",
    "active": true,
    "console": "false",
    "complete": "false",
    "x": 493,
    "y": 195,
    "z": "6bd610b9.7b40a",
    "wires": []
}
]

answered Jul 19, 2018 by TejaswiniUL
• 140 points

Related Questions In IoT (Internet of Things)

0 votes
1 answer

Issue with connection on Watson IoT Out node on Raspberry Pi

The frequent disconnects could be due to ...READ MORE

answered Dec 20, 2018 in IoT (Internet of Things) by Shubham
• 13,490 points
720 views
0 votes
1 answer

AWS IoT login from android MQTT client using IAM is not working

Seeing your comments and questions. I had ...READ MORE

answered Jul 24, 2018 in IoT (Internet of Things) by anonymous2
• 4,280 points
2,067 views
0 votes
1 answer

Publishing commands to device in IBM IoT using MQTT in Java

If you are publishing from an application, ...READ MORE

answered Jul 27, 2018 in IoT (Internet of Things) by anonymous2
• 4,280 points
1,306 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

MQTT protocol connection error

Ok so you need two libraries to ...READ MORE

answered Jul 6, 2018 in IoT (Internet of Things) by anonymous2
• 4,280 points

reshown Jul 6, 2018 by Vardhan 2,786 views
0 votes
1 answer

Mosquitto 1.4.2 Websocket support

down vote In the dir mosquitto-1.4.X edit the ...READ MORE

answered Jul 9, 2018 in IoT (Internet of Things) by anonymous2
• 4,280 points
1,192 views
0 votes
1 answer

IoT request response protocol

Based on your requirement of a light ...READ MORE

answered Jul 13, 2018 in IoT (Internet of Things) by anonymous2
• 4,280 points
1,618 views
0 votes
1 answer

What is the maximum message length for a MQTT broker?

It's not entirely clear what you're asking ...READ MORE

answered Jul 17, 2018 in IoT (Internet of Things) by anonymous2
• 4,280 points
9,052 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP