Commit 78b48524 authored by Spencer Williams's avatar Spencer Williams
Browse files

send data to AWS Kinesis Firehose

parent 802f60fe
......@@ -9,6 +9,8 @@
"author": "",
"license": "ISC",
"dependencies": {
"dateformat": "^2.0.0",
"firehoser": "^1.2.4",
"noble": "^1.8.1",
"noble-device": "^1.4.1"
}
......
'use strict';
const AWS = require('aws-sdk');
const firehoser = require('firehoser');
const dateFormat = require('dateformat');
const ProviderStrategy = require('./providerStrategy.js');
class AWSProvider extends ProviderStrategy {
constructor(config) {
super(config);
this.name = 'AWS';
AWS.config.update({
accessKeyId: config.accessKeyId,
secretAccessKey: config.secretAccessKey,
region: config.region,
});
this.firehose = new firehoser.JSONDeliveryStream(config.deliveryStream)
}
connectGateway() {
......@@ -13,7 +25,15 @@ class AWSProvider extends ProviderStrategy {
}
sendTelemetry(telemetry) {
console.log(`[AWS] sendTelemetry ${JSON.stringify(telemetry)}`);
const now = new Date();
telemetry.timestamp = dateFormat(now, "yyyy-mm-dd hh:mm:ss.l");
this.firehose.putRecord(telemetry)
.then(() => {
console.log('[AWS] sent telemetry');
})
.catch((err) => {
console.log(`[AWS] error sending telemetry: ${JSON.stringify(err)}`);
});
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment