Skip to content

Commit

Permalink
Merge pull request #11 from cloudxsgmbh/feat/addMiromicoInsight
Browse files Browse the repository at this point in the history
Feat/add miromico insight
  • Loading branch information
baartch authored Mar 13, 2023
2 parents 52ec07c + f150fad commit f1eed1e
Show file tree
Hide file tree
Showing 13 changed files with 1,359 additions and 110 deletions.
372 changes: 322 additions & 50 deletions API.md

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
File renamed without changes.
24 changes: 24 additions & 0 deletions lambda/decoderMiromicoInsight/decoder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { decodeUplink } from './decoder/index';

// eslint-disable-next-line @typescript-eslint/no-explicit-any
exports.handler = async function (event: any): Promise<any> {

console.log('Lambda invocation event: ', JSON.stringify(event));

/* Decode sensor payload */
const bytes = Uint8Array.from(Buffer.from(event.PayloadData, 'base64'));
const result = decodeUplink({bytes, fPort: event.WirelessMetadata.LoRaWAN.FPort});

/* Return sensor data in the same format as the Dragino LHT65 */
const decodedPayload = {
BatV: result.data.battery_v,
TempC_DS: 0,
TempC_SHT: result.data.temperature[0],
Hum_SHT: result.data.humidity[0],
ext_sensor: ''
};

console.log('Decoded sensor payload: ', decodedPayload);
return decodedPayload;

};
Loading

0 comments on commit f1eed1e

Please sign in to comment.