How to use the azure-iot-device-amqp.clientFromConnectionString function in azure-iot-device-amqp

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

github ThingLabsIo / IoTLabs / Azure / weather.js View on Github external
/* 
// PARTICLE PHOTON USERS
// Add the following definition for the Particle plugin for Johnny-Five
var Particle = require("particle-io");

var token = 'YOUR PARTICLE ACCESS TOKEN HERE';
*/

var location = process.env.DEVICE_LOCATION || 'GIVE A NAME TO THE LOCATION OF THE THING';
var connectionString = process.env.IOTHUB_CONN || 'YOUR IOT HUB DEVICE-SPECIFIC CONNECTION STRING HERE';

// Create an Azure IoT client that will manage the connection to your IoT Hub
// The client is created in the context of an Azure IoT device, which is why
// you use a device-specific connection string.
var client = clientFromConnectionString(connectionString);
var deviceId = device.ConnectionString.parse(connectionString).DeviceId;

// Create a Johnny-Five board instance to represent your Particle Photon
// Board is simply an abstraction of the physical hardware, whether is is a 
// Photon, Arduino, Raspberry Pi or other boards.
var board = new five.Board();
/* 
// PARTICLE PHOTON USERS
// When creating a Board instance for the Photon you must specify the token and device ID
// for your Photon using the Particle-IO Plugin for Johnny-five.
// Replace the Board instantiation with the following:
var board = new five.Board({
  io: new Particle({
    token: token,
    deviceId: 'YOUR PARTICLE PHOTON DEVICE IS OR ALIAS'
  })
github TheThingsNetwork / workshops / integrations / azure / index.js View on Github external
}).then(deviceInfo => {
      const key = deviceInfo.authentication.SymmetricKey.primaryKey;
      const connectionString = util.format(this.deviceConnectionString, devEUI, key);
      const client = amqp.clientFromConnectionString(connectionString);
      return new Promise((resolve, reject) => {
        client.open(err => {
          if (err) {
            reject(err);
          } else {
            this.devices[devEUI] = client;
            resolve(client);
          }
        });
      });
    });
  }
github codefoster / iot-workshop / device / index.js View on Github external
return new Promise((resolve, reject) => {
        let deviceAmqp = require('azure-iot-device-amqp');
        let client = deviceAmqp.clientFromConnectionString(process.env.DEVICE_CONN_STRING);

        client.open(err => {
            if (err) reject(err);
            resolve(client);
        });
    })
}
github TheThingsNetwork / integration-azure / index.js View on Github external
}).then(deviceInfo => {
      const key = deviceInfo.authentication.symmetricKey.primaryKey
      const connectionString = util.format(this.deviceConnectionString, deviceId, key)
      const client = amqp.clientFromConnectionString(connectionString)
      return new Promise((resolve, reject) => {
        client.open(err => {
          if (err) {
            reject(err)
          } else {
            this.devices[deviceId] = client
            resolve(client)
          }
        })
      })
    })
  }
github codefoster / iot-workshop / device / index.ts View on Github external
import * as five from 'johnny-five';
import * as raspi from 'raspi-io';
import * as Camera from 'camerapi';
import * as oxford from 'project-oxford';
import * as fs from 'fs';
import * as device from 'azure-iot-device';
import * as deviceAmqp from 'azure-iot-device-amqp';

let cogClient = new oxford.Client('d7889254b9244ec1ba54e8cf154ff359');
let connectionString = 'HostName=iot-workshop-hub.azure-devices.net;DeviceId=device1;SharedAccessKey=zyislRKCFj5k916xvNRyB0JPihQpad/56tzTMZMWpdk=';
let hubClient = deviceAmqp.clientFromConnectionString(connectionString);

//establishing connection to gpio
log('establishing connection to gpio...');
let board = new five.Board({ io: new raspi() });
board.on('ready', () => {
    let led = new five.Led('GPIO26');
    let button = new five.Button('GPIO20');
    led.stop().off();

    //open connection to iot hub
    log('connecting to iot hub...');
    hubClient.open(err => {
        if (err)
            log(err.message)
        else {
            log('READY');

azure-iot-device-amqp

AMQP transport for Azure IoT device SDK

MIT
Latest version published 6 months ago

Package Health Score

84 / 100
Full package analysis

Similar packages