我正在尝试使用IBM Bluemix平台构建物联网小应用程序。我发现了一个Ryan J Baxter的视频,将传感器标签连接到物联网云基础上,并带有Beagle-bone骨架。现在,我正在尝试使用Raspberry Pi设备而不是Beagle-Bone执行相同的过程,在sensor-tag.js
文件面临一些问题时,我们无法从config.properties
文件中获取像cfg type
,cfg org
,cfg id
这样的cfg参数值。物联网Raspberry Pi传感器标签
我得到了我在注册设备时给予的mac地址,我给了我的Raspberry Pi mac地址,因为它连接到我的以太网eth0
。
if(cfg.id != deviceId) {
console.warn('The device MAC address does not match the ID in the configuration file.');
}
//------------- This is where I'm facing a problem --------
var clientId = ['d', cfg.org, cfg.type, cfg.id].join(':');
var client = mqtt.connect("mqtts://" + cfg.org +
'.messaging.internetofthings.ibmcloud.com:8883',
{
"clientId" : clientId,
"keepalive" : 30,
"username" : "use-token-auth",
"password" : cfg['auth-token']
});
client.on('connect', function() {
console.log('MQTT client connected to IBM IoT Cloud.');
});
client.on('error', function(err) {
console.log('client error' + err);
process.exit(1);
});
client.on('close', function() {
console.log('client closed');
process.exit(1);
});
monitorSensorTag(client);
});
});
function monitorSensorTag(client) {
console.log('Make sure the Sensor Tag is on!');
请确保您的代码中的括号相符。 – Ram