GithubHelp home page GithubHelp logo

nikeee / fritz-callmonitor Goto Github PK

View Code? Open in Web Editor NEW
4.0 4.0 1.0 1.02 MB

Provides a Node.js wrapper for the call monitor api of the AVM Fritz!Box.

Home Page: https://nikeee.github.io/fritz-callmonitor

License: GNU Lesser General Public License v3.0

TypeScript 100.00%
typescript fritz-callmonitor node avm-fritz fritz-box

fritz-callmonitor's Introduction

fritz-callmonitor Build Status npm version Dependency Status License

Provides a Node.js wrapper for the call monitor api of the AVM Fritz!Box. Written in TypeScript.

Installation

npm install fritz-callmonitor

TypeScript Usage

You need TypeScript 2. Just install the NPM package and you're ready to go!

Enabling the API

The network API is disabled by default. To use this, call #96*5* on a phone which is managed by the FRITZ!Box.

Sample

"use strict";

import { CallMonitor, EventKind } from "fritz-callmonitor";

const cm = new CallMonitor("192.168.178.1", 1012);

cm.on("ring", rr => {
	console.dir(rr);
	console.log(`${rr.caller} calling...`);
});

cm.on("call", rr => console.dir(rr));
cm.on("pickup", rr => console.dir(rr));
cm.on("hangup", rr => console.dir(rr));

cm.on("phone", evt => {
    // gets called on every phone event
    switch(evt.kind) {
        case EventKind.Ring:
        case EventKind.Call:
            console.log(`${evt.caller} -> ${evt.callee}`);
            break;
    }
});

cm.on("close", () => console.log("Connection closed."));
cm.on("connect", () => console.log("Connected to device."));
cm.on("error", err => console.dir(err));

cm.connect();

fritz-callmonitor's People

Contributors

dependabot[bot] avatar nikeee avatar weeklyn8 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

weeklyn8

fritz-callmonitor's Issues

Changed event.kind ?!

This error is thrown for Model 7490:

case _fritzCallmonitor.EventKind.Ring:
^

TypeError: Cannot read property 'Ring' of undefined
at CallMonitor. (/home/suther/scripte/fritz_callMonitor/index.js:19:14)
at emitOne (events.js:96:13)
at CallMonitor.emit (events.js:188:7)
at CallMonitor.processLine (/home/suther/scripte/fritz_callMonitor/node_modules/fritz-callmonitor/dist/fritz-callmonitor.js:34:14)
at LineStream.reader.on (/home/suther/scripte/fritz_callMonitor/node_modules/fritz-callmonitor/dist/fritz-callmonitor.js:18:43)
at emitOne (events.js:96:13)
at LineStream.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at LineStream.Readable.push (_stream_readable.js:134:10)
at LineStream.Transform.push (_stream_transform.js:128:32)

The event seems to changed. The response of FritzBox-Callmonitor looks now like this:

Connected to device.
{ rawData: '09.12.16 09:24:43;RING;0;017678011111;002275911111;SIP1;',
date: 2016-12-09T08:24:43.000Z,
connectionId: 0,
kind: 1,
caller: '017678011111',
callee: '002275911111' }
{ rawData: '09.12.16 09:24:43;RING;0;017678011111;002275911111;SIP1;',
date: 2016-12-09T08:24:43.000Z,
connectionId: 0,
kind: 1,
caller: '017678011111',
callee: '002275911111' }
017678013804 calling...
{ rawData: '09.12.16 09:24:45;DISCONNECT;0;0;',
date: 2016-12-09T08:24:45.000Z,
connectionId: 0,
kind: 4,
callDuration: 0 }
{ rawData: '09.12.16 09:24:45;DISCONNECT;0;0;',
date: 2016-12-09T08:24:45.000Z,
connectionId: 0,
kind: 4,
callDuration: 0 }

So:
kind 1 = incomming call
kind 4 = hangup by client
don't find any description what the other kind-states could be.

Error on startup : Unexpected token import

Node: v7.2.0

If I start the example-Script you post at npm-page, I got this error:

import { CallMonitor, EventKind } from "fritz-callmonitor";
^^^^^^
SyntaxError: Unexpected token import
at Object.exports.runInThisContext (vm.js:78:16)
at Module._compile (module.js:543:28)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:420:7)
at startup (bootstrap_node.js:139:9)
at bootstrap_node.js:535:3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.