How to use the azure-iot-device-amqp.Amqp 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.

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

github Azure-Samples / iot-hub-node-intel-edison-getstartedkit / command_center / command_center.js View on Github external
var board = new five.Board({
  io: new Edison()
});

var hostName = '';
var deviceId = '';
var sharedAccessKey = '';

// String containing Hostname, Device Id & Device Key in the following formats:
//  "HostName=;DeviceId=;SharedAccessKey="
var connectionString = 'HostName=' + hostName + ';DeviceId=' + deviceId + ';SharedAccessKey=' + sharedAccessKey;

var deviceId = ConnectionString.parse(connectionString)["DeviceId"];

// fromConnectionString must specify a transport constructor, coming from any transport package.
var client = Client.fromConnectionString(connectionString, Protocol);

// Helper function to print results in the console
function printResultFor(op) {
  return function printResult(err, res) {
    if (err) console.log(op + ' error: ' + err.toString());
    if (res) console.log(op + ' status: ' + res.constructor.name);
  };
}

board.on("ready", function() {
  var temp = new five.Temperature({
    pin: "A0",
    controller: "GROVE"
  });

  var led = new five.Led(8);
github Azure / iot-edge-v1 / samples / nodejs_simple_sample / nodejs_modules / iothub_writer.js View on Github external
create(broker, configuration) {
        this.broker = broker;
        this.configuration = configuration;

        if(this.configuration && this.configuration.connection_string) {
            // open a connection to the IoT Hub
            this.iothub_client = Client.fromConnectionString(this.configuration.connection_string, Protocol);
            this.iothub_client.open(this.on_connect.bind(this));

            return true;
        }
        else {
            console.error('This module requires the connection string to be passed in via configuration.');
            return false;
        }
    }
github ThingLabsIo / IoTLabs / Edison / azure-iot / simple_sample_device.js View on Github external
'use strict';

var Protocol = require('azure-iot-device-amqp').Amqp;
// Uncomment one of these transports and then change it in fromConnectionString to test other transports
// var Protocol = require('azure-iot-device-amqp-ws').AmqpWs;
// var Protocol = require('azure-iot-device-http').Http;
// var Protocol = require('azure-iot-device-mqtt').Mqtt;
var Client = require('azure-iot-device').Client;
var Message = require('azure-iot-device').Message;

// String containing Hostname, Device Id & Device Key in the following formats:
//  "HostName=;DeviceId=;SharedAccessKey="
var connectionString = process.env.IOTHUB_DEVICE_CONN || 'YOUR IOT HUB DEVICE-SPECIFIC CONNECTION STRING HERE';

// fromConnectionString must specify a transport constructor, coming from any transport package.
var client = Client.fromConnectionString(connectionString, Protocol);

var connectCallback = function (err) {
  if (err) {
    console.error('Could not connect: ' + err.message);
  } else {
    console.log('Client connected');
    client.on('message', function (msg) {
      console.log('Id: ' + msg.messageId + ' Body: ' + msg.data);
      client.complete(msg, printResultFor('completed'));
      // reject and abandon follow the same pattern.
      // /!\ reject and abandon are not available with MQTT
    });

    // Create a message and send it to the IoT Hub every second
    var sendInterval = setInterval(function () {
      var windSpeed = 10 + (Math.random() * 4); // range: [10, 14]
github ThingLabsIo / IoTLabs / Edison / azure-iot / iot-starter-kit.js View on Github external
// Define the protocol that will be used to send messages to Azure IoT Hub
// For this lab we will use AMQP over Web Sockets.
// If you want to use a different protocol, comment out the protocol you want to replace, 
// and uncomment one of the other transports.
// var Protocol = require('azure-iot-device-amqp-ws').AmqpWs;
var Protocol = require('azure-iot-device-amqp').Amqp;
// var Protocol = require('azure-iot-device-http').Http;
// var Protocol = require('azure-iot-device-mqtt').Mqtt;

// The device-specific connection string to your Azure IoT Hub
var connectionString = process.env.IOTHUB_DEVICE_CONN || 'YOUR IOT HUB DEVICE-SPECIFIC CONNECTION STRING HERE';

// Create the client instanxe that will manage the connection to your IoT Hub
// The client is created in the context of an Azure IoT device.
var client = Client.fromConnectionString(connectionString, Protocol);

// Extract the Azure IoT Hub device ID from the connection string
var deviceId = device.ConnectionString.parse(connectionString).DeviceId;

// location is simply a string that you can filter on later
var location = process.env.DEVICE_LOCATION || 'GIVE A NAME TO THE LOCATION OF THE THING';

// Define the sensors you will use
var th02, lcd, led, button;

// Define some variable for holding sensor values
var tempC, tempF, humidity, r, g, b = 0;

// Define the board, which is an abstraction of the Intel Edison
var board = new five.Board({
  io: new Edison()

azure-iot-device-amqp

AMQP transport for Azure IoT device SDK

MIT
Latest version published 10 months ago

Package Health Score

64 / 100
Full package analysis

Similar packages