Closed c835722 closed 8 years ago
Hi @c835722,
The iot-nodejs internally uses MQTT to connect and publish messages. It supports sending the message in Buffer and String. So this library also supports sending only in Buffer and String.
Please let us know if you have any questions.
Thanks!!
Hi @jeffdare, Thanks for the response. So by extension those docs need updating then to reflect an example in Buffer and String type.
Hi, Using the "Publishing commands to devices" code snippet from here https://docs.internetofthings.ibmcloud.com/nodejs/node-js_applications.html That is : var Client = require("ibmiotf").IotfApplication; var config = Client.parseConfigFile(configFilePath); var appClient = new Client(config); appClient.connect(); appClient.on("connect", function () { var myData={'DelaySeconds' : 10} appClient.publishDeviceCommand("myDeviceType","device01", "reboot", "json", myData); }); I get the following exception. How do I pass an Object (msg.payload) to a Device?
Publish: iot-2/type/myDeviceType/id/device01/cmd/reboot/fmt/json, [object Object] Connection Error :: TypeError: Argument must be a string events.js:142 throw er; // Unhandled 'error' event ^
TypeError: Argument must be a string at TypeError (native) at Buffer.write (buffer.js:591:21) at writeStringNoPos (/Users/c835722/.usr/local/projects/blinds/blindcommand/node_modules/mqtt-packet/generate.js:547:10) at publish (/Users/c835722/.usr/local/projects/blinds/blindcommand/node_modules/mqtt-packet/generate.js:273:5) at Object.generate (/Users/c835722/.usr/local/projects/blinds/blindcommand/node_modules/mqtt-packet/generate.js:15:14) at sendPacket (/Users/c835722/.usr/local/projects/blinds/blindcommand/node_modules/mqtt/lib/client.js:31:26) at MqttClient._sendPacket (/Users/c835722/.usr/local/projects/blinds/blindcommand/node_modules/mqtt/lib/client.js:603:7) at MqttClient.publish (/Users/c835722/.usr/local/projects/blinds/blindcommand/node_modules/mqtt/lib/client.js:354:12) at ApplicationClient.publish (/Users/c835722/.usr/local/projects/blinds/blindcommand/node_modules/ibmiotf/dist/clients/ApplicationClient.js:181:21) at ApplicationClient.publishDeviceCommand (/Users/c835722/.usr/local/projects/blinds/blindcommand/node_modules/ibmiotf/dist/clients/ApplicationClient.js:241:14) at ApplicationClient. (/Users/c835722/.usr/local/projects/blinds/blindcommand/lib/application-compiled.js:25:13)
at emitNone (events.js:68:13)
at ApplicationClient.emit (events.js:167:7)
at MqttClient. (/Users/c835722/.usr/local/projects/blinds/blindcommand/node_modules/ibmiotf/dist/clients/ApplicationClient.js:112:17)
at emitOne (events.js:83:20)
at MqttClient.emit (events.js:170:7)