Skip to content

Instantly share code, notes, and snippets.

@ThomasPe

ThomasPe/app.js Secret

Created September 8, 2020 08:09
Show Gist options
  • Save ThomasPe/78bd8bf7c15b970dd7d5a7087409ad7c to your computer and use it in GitHub Desktop.
Save ThomasPe/78bd8bf7c15b970dd7d5a7087409ad7c to your computer and use it in GitHub Desktop.
IdentityTranslationModule message pipe
// Act on input messages to the module.
moduleClient.on('inputMessage', function (inputName, msg) {
console.log("new message received", msg);
if (simulatedTemperatureClient) {
// Identity Translation configured, wrap message fro IoT device
const message = msg.getBytes().toString('utf8');
const sensorMsg = new Message(message);
simulatedTemperatureClient.sendEvent(sensorMsg);
} else {
// No Identity Translation configured, send message through module
pipeMessage(moduleClient, inputName, msg);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment