From 2135e7eccbbc2aabc4476d3c8db4a9367dc90547 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Devran=20=C3=9Cnal?= Date: Thu, 17 Sep 2015 17:00:52 +0200 Subject: [PATCH] Print scannable setup code to terminal on startup --- app.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app.js b/app.js index 8a92123..692fc1a 100644 --- a/app.js +++ b/app.js @@ -191,6 +191,16 @@ function createAccessory(accessoryInstance, displayName) { } } +// Returns the setup code in a scannable format. +function printPin(pin) { + console.log("Scan this code with your HomeKit App on your iOS device:"); + console.log("\x1b[30;47m%s\x1b[0m", " "); + console.log("\x1b[30;47m%s\x1b[0m", " ┌────────────┐ "); + console.log("\x1b[30;47m%s\x1b[0m", " │ " + pin + " │ "); + console.log("\x1b[30;47m%s\x1b[0m", " └────────────┘ "); + console.log("\x1b[30;47m%s\x1b[0m", " "); +} + // Returns a logging function that prepends messages with the given name in [brackets]. function createLog(name) { return function(message) { @@ -210,3 +220,5 @@ function publish() { } startup(); + +printPin(bridgeConfig.pin);