From 89d0b8a64570d6d00c06bd5256b269c1223e4dbd Mon Sep 17 00:00:00 2001 From: Gerrit Linnemann Date: Wed, 9 Mar 2016 22:46:41 +0100 Subject: [PATCH] http call --- hobu_doorbell/app.js | 31 +++++++++++++++++++++++++++++-- hobu_doorbell/config.json | 9 ++++++++- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/hobu_doorbell/app.js b/hobu_doorbell/app.js index 97ba566..e731753 100644 --- a/hobu_doorbell/app.js +++ b/hobu_doorbell/app.js @@ -1,5 +1,6 @@ var Tinkerforge = require('../tinkerforge') -, Conf = require('./config.json'); +, Conf = require('./config.json') +, http = require('http'); var HOST = Conf.host; var PORT = Conf.port; @@ -50,7 +51,7 @@ ai.on(Tinkerforge.BrickletAnalogInV2.CALLBACK_VOLTAGE, } if(radicalChange) { - console.log('Hat sich gelohnt!'); + doHoBuDoorBellCall(); } } ); @@ -62,3 +63,29 @@ process.stdin.on('data', process.exit(0); } ); + + +/* private */ +function doHoBuDoorBellCall() { + var options = { + host: Conf.on.ring.host, + port: Conf.on.ring.port, + path: Conf.on.ring.path + }; + + callback = function(response) { + var str = ''; + + //another chunk of data has been recieved, so append it to `str` + response.on('data', function (chunk) { + str += chunk; + }); + + //the whole response has been recieved, so we just print it out here + response.on('end', function () { + console.log(str); + }); + } + + http.request(options, callback).end(); +} \ No newline at end of file diff --git a/hobu_doorbell/config.json b/hobu_doorbell/config.json index ed3b4b5..b5fa4d0 100644 --- a/hobu_doorbell/config.json +++ b/hobu_doorbell/config.json @@ -1,5 +1,12 @@ { "host": "192.168.2.122", "port": 4223, - "uid": "vhb" + "uid": "vhb", + "on": { + "ring": { + "host": "hobu", + "port": "2999", + "path": "/doorbell/ring/haustuer/" + } + } } \ No newline at end of file