Skip to content

Commit 6c51ec1

Browse files
committed
res_alarmsystem: Add self-contained alarm system module.
res_alarmsystem is a module that can be used to implement an alarm system within Asterisk. The basic functionality is split into "client" and "server" roles, although the "server" role is technically optional. This allows the average home user with an Asterisk server at home and off-site to have a professional-grade alarm system with custom monitoring and reporting, all for the cost of any sensors required. WARNING: This module comes with ABSOLUTELY NO WARRANTY. Use of it is solely at your own risk. PHREAKSCRIPT-32 #close
1 parent 2fc006f commit 6c51ec1

File tree

4 files changed

+2760
-0
lines changed

4 files changed

+2760
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ PhreakScript installs:
7070
- ``PhreakNetDial``
7171
- ``SIPAddParameter``
7272
- ``IRCSendMessage``
73+
- ``AlarmSensor``
74+
- ``AlarmKeypad``
75+
- ``AlarmEventReceiver`` (not to be confused with ``AlarmReceiver``)
7376
- ``Softmodem`` (third-party, with compiler fixes and enhancements, including TDD modem)
7477
- ``TddRx``, ``TddTx`` (third-party)
7578
- Adds the following functions:

configs/samples/res_alarmsystem.conf

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
; res_alarmsystem.conf
2+
3+
; This configuration allows configuring an alarm system using Asterisk. There are two roles
4+
; that exist, client and server. Clients receive input from one or more sensors and
5+
; report alarm events to a server. Typically, these will be different Asterisk servers,
6+
; with clients at individual sites and a single, centralized server receiving events from them,
7+
; but they could also both run on the same server if desired.
8+
; However, it is RECOMMENDED that the server role not be at a location with sensors.
9+
; This way, if someone were to sabotage the alarm system at the client side prior to
10+
; the breach event, the alarm server will still be aware that something has gone wrong.
11+
12+
; WARNING WARNING WARNING This alarm system implementation comes with absolutely no warranty,
13+
; use it at your own risk!
14+
15+
; *** Server configuration
16+
17+
[general]
18+
bindport=4589 ; UDP port to which alarm server will bind, if any servers are enabled.
19+
;bindaddr=0.0.0.0
20+
21+
[myserver] ; Defines an alarm server to which alarm clients can report.
22+
type = server
23+
ip_loss_tolerance = 60 ; Number of seconds the server will tolerate not receiving pings from clients before considering
24+
; IP connectivity to a client to have been lost (which will trigger the internet_lost alarm).
25+
contexts = myserver-contexts ; A config section which defines dialplan contexts to execute for each alarm event
26+
logfile = /var/log/asterisk/alarm_server.log ; Log file for this server
27+
28+
[clients] ; Special section defining clients authorized to report to this server
29+
;A101 = 1D7B ; one entry for each client, with client ID as the key and client PIN as the value
30+
31+
; *** Client configuration
32+
33+
[myclient] ; Each alarm client is defined in its own section
34+
type = client
35+
client_id = A101 ; Unique, telenumeric ID (0-9,A-D) for this client. Should be unique across all clients that report to a server.
36+
; Note that there is no security mechanism to restrict reporting aside from the client ID.
37+
; Therefore, if the alarm server is exposed to the Internet, you may wish to use long, hard-to-guess client IDs
38+
; to prevent spoofed reports, or lock down your firewall accordingly.
39+
;client_pin=1D794B61 ; PIN, if required by server for authentication
40+
server_ip = 127.0.0.1:4589 ; IP/port to reach alarm server over IP
41+
server_dialstr = DAHDI/g1/*70w18005551212 ; A dial string for "POTS phone failover" to reach alarm server if unable to by IP. If you need to use dial options, use a Local channel to encapsulate the Dial() call.
42+
; The server should call AlarmEventReceiver() (NOT AlarmReceiver() !!!) when receiving such a call.
43+
; NOTE: When reporting an alarm trigger, the line will stay open until disarm_delay has been reached, to avoid making multiple calls in succession
44+
phone_hangup_delay = 45 ; Number of seconds to keep phone failover line open upon reporting event for reporting further events in that time.
45+
; It is recommended this setting be at least 10-15 seconds, so that if phone failover is being used,
46+
; a single phone call is sufficient to report sensor trigger and alarm disarm events, rather than dialing up a second time to report this event.
47+
; You may want to tweak this based on the cost of each call, cost per minute, and the acceptable amount of delay in setting up a call. Default is 45.
48+
ping_interval = 4 ; How often to ping the server
49+
egress_delay = 15 ; number of seconds grace period to exit without re-triggering alarm
50+
contexts = myclient-contexts ; A config section which defines dialplan contexts to execute for each alarm event
51+
logfile = /var/log/asterisk/alarm_myclient.log ; Log file to which to log alarm events.
52+
53+
[myclient-contexts]
54+
type = contexts
55+
; In this section, the key is the name of the alarm event for which the specified dialplan will be executed,
56+
; and the value is the dialplan [exten@]context to execute. If exten is omitted, s will be used. The priority will always be 1.
57+
;
58+
; okay = okay@myclientalarm ; Normal initialization
59+
; triggered = triggered@myclientalarm ; Sensor has triggered alarm
60+
; restored = restored@myclientalarm ; Sensor restored to normal (will not auto-disarm pending alarm)
61+
; disarmed = disarmed@myclientalarm ; Alarm disarmed by user
62+
; tempdisarmed = tempdisarmed@myclientalarm ; Alarm temporarily disarmed by user
63+
; breach = breach@myclientalarm ; Breach (failure to disarm active alarm) has occured
64+
; internet_lost = iplost@myclientalarm ; Internet connectivity to alarm peer lost
65+
; internet_restored = iprestored@myclientalarm ; Internet connectivity to alarm peer restored
66+
67+
[door] ; Section defining a door sensor
68+
type = sensor
69+
sensor_id = 1 ; Unique, numeric ID for this sensor. Should be unique across all sensors belongng to all clients that report to a server.
70+
client = myclient ; Client associated with this sensor
71+
device = DAHDI/23 ; if specified, then arg2 to AlarmSensor is optional since we can use the channel to determine which sensor was activated
72+
; (This way, the same context can be specified for all sensors, using immediate=yes in chan_dahdi.conf)
73+
disarm_delay = 45 ; Number of seconds grace period permitted to disarm an active alarm after this sensor triggers before it is considered a breach.
74+
; Default is 60.
75+
76+
[keypad] ; Section defining alarm keypad settings. An alarm keypad can be instantiated by using AlarmKeypad()
77+
type = keypad
78+
client = myclient ; Client associated with these keypad settings
79+
keypad_device = PJSIP/Polycom ; dial string for alarm keypad endpoints to autodial when alarm is triggered. Use a Local channel for predial options to autoanswer.
80+
pin = 1234 ; Hardcoded PIN which must be entered to disarm the alarm. Multiple PINs can be permitted by providing multiple comma-separated PINs.
81+
audio = custom/siren ; An optional audio file to play while waiting for the alarm to be disarmed. By default, a tone is played.
82+
cid_num = DISARM SYSTEM NOW ; Caller ID number to use for outgoing calls to the keypad device
83+
cid_name = ALARM PANEL ; Caller ID name to use for outgoing calls to the keypad device

phreaknet.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1856,6 +1856,7 @@ phreak_patches() { # $1 = $PATCH_DIR, $2 = $AST_SRC_DIR
18561856

18571857
phreak_tree_module "configs/samples/verify.conf.sample" "1" # will fail for obsolete versions of Asterisk b/c of different directory structure, okay.
18581858
phreak_tree_module "configs/samples/irc.conf.sample" "1" # will fail for obsolete versions of Asterisk b/c of different directory structure, okay.
1859+
phreak_tree_module "configs/samples/res_alarmsystem.conf.sample" "1"
18591860

18601861
phreak_tree_module "funcs/func_dbchan.c"
18611862
phreak_tree_module "funcs/func_dtmf_flash.c"
@@ -1873,6 +1874,7 @@ phreak_patches() { # $1 = $PATCH_DIR, $2 = $AST_SRC_DIR
18731874
phreak_tree_module "res/res_deadlock.c" # this is not possibly useful to non-developers
18741875
fi
18751876

1877+
phreak_tree_module "res/res_alarmsystem.c"
18761878
phreak_tree_module "res/res_digitmap.c"
18771879
phreak_tree_module "res/res_irc.c"
18781880
phreak_tree_module "res/res_msp.c"

0 commit comments

Comments
 (0)