azure-iot-multiplexing-gateway
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

A gateway to Azure IoT Hub that can represent multiple devices over a single connection.

Build Status

To see an implementation of the same pattern in .NET Core, please see this project.

Basic functionality

var gateway = new Gateway();

// The connection string must include a shared access key with the `device connect` permission.
// The value can be copied, for example, from the Azure Portal.
await gateway.open(process.env.IOTHUB_CONNECTION_STRING);

// Setup the message handler.
gateway.on('message', (message) => {
  // Do something when C2D messages arrive.
  // This handler is called to messages targeting any device and includes the target device id.
});

// Add the devices you want to handle with this gateway.
// Note that only device id is enough and there is no need for device-specific keys.
await gateway.addDevice('<some-device-id>');

// Send D2C messages on behalf of any device id.
await gateway.sendMessage('<some-device-id>', <message>);

See the sample server.ts for more details about the usage.

Running sample locally

export IOTHUB_CONNECTION_STRING="HostName=..."
npm install
npm start

Running tests locally

npm install
npm test

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.3
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.3
    0
  • 0.0.2
    0
  • 0.0.1
    0

Package Sidebar

Install

npm i azure-iot-multiplexing-gateway

Weekly Downloads

0

Version

0.0.3

License

MIT

Unpacked Size

30.7 kB

Total Files

18

Last publish

Collaborators

  • vjrantal