Skip to content
This repository has been archived by the owner on Apr 29, 2019. It is now read-only.

Commit

Permalink
Ensure deviceId is lower case
Browse files Browse the repository at this point in the history
  • Loading branch information
sjhx committed Apr 25, 2014
1 parent 6ca9760 commit c7fa4be
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions samples/nodejs/ibm-iot-quickstart.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
//*****************************************************************************
// Copyright (c) 2014 IBM Corporation and other Contributors.
//
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// which accompanies this distribution, and is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// Contributors:
// IBM - Initial Contribution
//*****************************************************************************

// IoT Cloud QuickStart Driver
// A sample IBM Internet of Things Cloud Quickstart Service client for Intel Galileo

var mqtt = require('mqtt');
var fs = require('fs');

Expand All @@ -10,8 +25,8 @@ var client;

require('getmac').getMac(function(err, macAddress) {
if (err) throw err;
deviceId = macAddress.replace(/:/g, '');
console.log("MAC Address: " + macAddress);
deviceId = macAddress.replace(/:/g, '').toLowerCase();
client = mqtt.createClient(port,broker, { "clientId": "quickstart:"+deviceId } );
topic = "iot-1/d/" + deviceId + "/evt/galileo-quickstart/json";
console.log("Topic: " + topic);
Expand All @@ -23,15 +38,12 @@ setInterval(sendMessage,1000);
function sendMessage() {
var message = {};
message.d = {};
//message.d.date = Date.now();
//read the CPU temp from sysfs
fs.readFile('/sys/class/thermal/thermal_zone0/temp','utf8',function (err, data) {
if (err) throw err;
message.d.cputemp = data/1000;
console.log(message);
client.publish(topic,JSON.stringify(message));
});


}

0 comments on commit c7fa4be

Please sign in to comment.