How to use the aws-iot-device-sdk.thingShadow function in aws-iot-device-sdk

To help you get started, we’ve selected a few aws-iot-device-sdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github phodal / designiot-code / chapter6 / aws-example / aws.js View on Github external
var awsIot = require('aws-iot-device-sdk');

var thingName = 'Led';
var thingShadows = awsIot.thingShadow({
    keyPath: 'certs/fa635d3140-private.pem.key',
    certPath: 'certs/fa635d3140-certificate.pem.crt',
    caPath: 'certs/root-CA.crt',
    clientId: thingName,
    region: 'us-west-2'
});

thingShadows.on('connect', function () {
    console.log("Connected...");
    thingShadows.register(thingName);

    // An update right away causes a timeout error, so we wait about 2 seconds
    setTimeout(function () {
        console.log("Updating Led Status...");
        var led = thingShadows.update(thingName, {
            "state": {
github aws / aws-iot-device-sdk-js / examples / browser / temperature-monitor / index.js View on Github external
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
   IdentityPoolId: AWSConfiguration.poolId
});

//
// Keep track of whether or not we've registered the shadows used by this
// example.
//
var shadowsRegistered = false;

//
// Create the AWS IoT shadows object.  Note that the credentials must be 
// initialized with empty strings; when we successfully authenticate to
// the Cognito Identity Pool, the credentials will be dynamically updated.
//
const shadows = AWSIoTData.thingShadow({
   //
   // Set the AWS region we will operate in.
   //
   region: AWS.config.region,
   //
   //Set the AWS IoT Host Endpoint
   //     
   host:AWSConfiguration.host,
   //
   // Use a random client ID.
   //
   clientId: 'temperature-control-browser-' + (Math.floor((Math.random() * 100000) + 1)),
   //
   // Connect via secure WebSocket
   //
   protocol: 'wss',
github daaru00 / aws-iot-example / lib / thing.js View on Github external
connect(callback){
    this.thingShadows = awsIot.thingShadow({
      keyPath: this.keyPath,
      certPath: this.certPath,
      caPath: this.caPath,
      clientId: this.thingName,
      host: this.host
    });
    let self = this;

    this.thingShadows.on('connect', function() {
        self.thingShadows.register(self.thingName, {
          enableVersioning: false
        }, function() {
            self.logger.info('connection with '+self.thingName+' opened');
            self.thingShadows.get(self.thingName);
            callback(null)
        });
github cuongquay / node-red-contrib-aws-iot / aws-iot.js View on Github external
this.connect = function(clientId, reconnect, callback) {
			clientId = clientId || n.clientId;
			clientId = clientId.trim();
			var awsCerts = n.awscerts || ".";
			if (!self.device || reconnect) {
				self.log("Attempt to connect to " + n.mode + " with " + clientId + " from: " + awsCerts);
				var keyPath = path.join(awsCerts, '/' + clientId + '.private.key');
				var certPath = path.join(awsCerts, '/' + clientId + '.cert.pem');
				var caPath = path.join(awsCerts, '/root-CA.crt');
				self.log("Using the certificates that are presented as follows:");
				self.log(" - keyPath   : " + keyPath);
				self.log(" - certPath  : " + certPath);
				self.log(" - caPath    : " + caPath);
				if (n.mode == "shadow") {
					self.device = require('aws-iot-device-sdk').thingShadow({
						keyPath : keyPath,
						certPath : certPath,
						caPath : caPath,
						clientId : clientId,
						host : self.endpoint,
						protocol: 'mqtts'
					});
				} else {
					self.device = require('aws-iot-device-sdk').device({
						keyPath : keyPath,
						certPath : certPath,
						caPath : caPath,
						clientId : clientId,
						host : self.endpoint,
						protocol: 'mqtts'
					});
github sreid / aws-iot-raspberry-pi-how-to / pi.js View on Github external
var awsIot = require('aws-iot-device-sdk');

var myThingName = 'pi_2';

var thingShadows = awsIot.thingShadow({
   keyPath: './certs/-private.pem.key',
  certPath: './certs/-certificate.pem.crt',
    caPath: './certs/rootCA.pem',
  clientId: myThingName,
    region: 'us-east-1'
});

mythingstate = {
  "state": {
    "reported": {
      "ip": "unknown"
    }
  }
}

var networkInterfaces = require( 'os' ).networkInterfaces( );
github h3smith / aws-iot-alexa / pi / iot.js View on Github external
gpio.open(pin_location, "input", function(err) { if (err) throw err; });










var _changeStatusTopic = "toggle-garage-door-topic";
var myThingName = 'pi-garage';


var thingShadows = awsIot.thingShadow({
    keyPath: '{local-private-key-name}',
    certPath: '{local-cert-name}',
    caPath: '{local-root-ca-name}',
    clientId: myThingName,
    region: '{aws-region}'
});

mythingstate = {
    "state": {
        "reported": {
            "ip": "unknown"
        }
    }
}

thingShadows.register(myThingName, {
github awslabs / simplebeerservice / device / sbs.js View on Github external
var board = new five.Board({
    io: new Edison()
  });
} else {
  var board = new five.Board({
    io: new Edison(),
    repl: false,
    debug: false
  });
}

var PUBLISH_INTERVAL = config.intervals.publish;
var ROTATE_MESSAGE_INTERVAL = config.intervals.rotateMessages;

var unitID = options.unitid;
var device = awsIot.thingShadow({
    keyPath: config.certs.privateKey,
    certPath: config.certs.certificate,
    caPath: config.certs.caCert,
    clientId: options.unitid,
    region: options.region
});

var logs = [];
var data = [];

var topic = config.topic+"/"+unitID;
var logtopic = config.logTopic+"/"+unitID;
var colors = {
  "green": [ 0, 255, 0 ],
  "red": [ 255, 0, 0 ],
  "orange": [ 150, 150, 0 ],

aws-iot-device-sdk

AWS IoT Node.js SDK for Embedded Devices

Apache-2.0
Latest version published 6 months ago

Package Health Score

73 / 100
Full package analysis

Popular aws-iot-device-sdk functions