# @josefransaenz/hypergate-aws-mqtt

> hypergate-aws-mqtt is built on top of [aws-iot-device-sdk](https://www.npmjs.com/package/aws-iot-device-sdk) and can be used to connect a hypergate instance to the AWS IoT Platform via MQTT or MQTT over the Secure WebSocket Protocol.

Latest version **1.0.4** (published 2020-07-23) · GPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install @josefransaenz/hypergate-aws-mqtt
pnpm add @josefransaenz/hypergate-aws-mqtt
yarn add @josefransaenz/hypergate-aws-mqtt
bun add @josefransaenz/hypergate-aws-mqtt
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2020-07-23 |
| First published | 2020-07-23 |
| Weekly downloads | 0 |
| License | GPL-3.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 51.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jose F. Saenz-Cogollo |
| Maintainers | josefransaenz |

## Links

- npm: https://www.npmjs.com/package/@josefransaenz/hypergate-aws-mqtt
- npm.io page: https://npm.io/package/@josefransaenz/hypergate-aws-mqtt

## Dependencies (2)

- [mocha](https://npm.io/package/mocha.md) 5.0.0
- [aws-iot-device-sdk](https://npm.io/package/aws-iot-device-sdk.md) 2.2.0

## Recent versions

- 1.0.4 (latest) — 2020-07-23
- 1.0.3 — 2020-07-23
- 1.0.2 — 2020-07-23

## README

# hypergate-aws-mqtt
hypergate-aws-mqtt is built on top of [aws-iot-device-sdk](https://www.npmjs.com/package/aws-iot-device-sdk)
and can be used to connect a hypergate instance to the AWS IoT Platform via MQTT or MQTT over the Secure WebSocket Protocol.

# API Reference

<a name="HypergateAWSMqtt"></a>

## HypergateAWSMqtt
**Kind**: global class  
<a name="new_HypergateAWSMqtt_new"></a>

### new HypergateAWSMqtt(hypergate, baseTopic, AWSMqttOptions)
An instance of the HypergateAWSMqtt class is a [mqtt.js Client instance](https://www.npmjs.com/package/mqtt#client) created by using the [aws-iot-device-sdk](https://www.npmjs.com/package/aws-iot-device-sdk) library.


| Param | Type | Description |
| --- | --- | --- |
| hypergate | <code>object</code> | The instance of the Hypergate class to use |
| baseTopic | <code>string</code> | string that will be appended to the topics related to the hypergate instance. The instance of the HypergateAWSMqtt class will be subscribed to topic '_baseTopic_/command/#' and will redirect the related messages to the hypergate.command method. All hypergate events will be automatically published as '_baseTopic_/event/{original_hypergate_event}'. |
| AWSMqttOptions | <code>object</code> | AWSIoT-specific arguments as specified in the [aws-iot-device-sdk documentation](https://www.npmjs.com/package/aws-iot-device-sdk#device) |

**Example**  
```js
const Hypergate = require('@josefransaenz/hypergate-core'); 
const HypergateAWSMqtt = require('@josefransaenz/hypergate-aws-mqtt');

const hypergate = new Hypergate(<YourPluginsSpecification>);

const AWSMqttOptions = {
  keyPath: <YourPrivateKeyPath>,
  certPath: <YourCertificatePath>,
  caPath: <YourRootCACertificatePath>,
  clientId: <YourUniqueClientIdentifier>,
  host: <YourCustomEndpoint>
};
const baseTopic = <YourBaseTopicString>;

const mqttClient = new HypergateAWSMqtt(hypergate, baseTopic, AWSMqttOptions); 

mqttClient.on('message', function (topic, message) {
  console.log(`*** Topic: '${topic}',  Payload: ${message.toString()}`);
});

mqttClient.on('connect', function () {
  console.log('*** Connect');
});

mqttClient.on('close', () => {
  console.log('** Disconect');
});
```

---
_Source: https://npm.io/package/@josefransaenz/hypergate-aws-mqtt · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
