Asterisk - The Open Source Telephony Project
21.4.1
|
Central Station Alarm receiver for Ademco Contact ID. More...
#include "asterisk.h"
#include <math.h>
#include <sys/wait.h>
#include <sys/time.h>
#include "asterisk/lock.h"
#include "asterisk/file.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/translate.h"
#include "asterisk/app.h"
#include "asterisk/dsp.h"
#include "asterisk/config.h"
#include "asterisk/localtime.h"
#include "asterisk/callerid.h"
#include "asterisk/astdb.h"
#include "asterisk/utils.h"
#include "asterisk/indications.h"
#include "asterisk/format_cache.h"
Go to the source code of this file.
Data Structures | |
struct | event_node |
Typedefs | |
typedef struct event_node | event_node_t |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
static int | ademco_check_valid (char *signalling_type, char *event) |
Check if the message is in known and valid Ademco format. More... | |
static int | ademco_detect_format (char *signalling_type, char *event, int *no_checksum) |
Detect the message format of an event. More... | |
static int | ademco_verify_checksum (char *event, int expected) |
Verify Ademco checksum. More... | |
static int | alarmreceiver_exec (struct ast_channel *chan, const char *data) |
This is the main function called by Asterisk Core whenever the App is invoked in the extension logic. More... | |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
static void | database_increment (char *key) |
Attempt to access a database variable and increment it. More... | |
static int | load_config (int reload) |
Load the configuration from the configuration file. More... | |
static int | load_module (void) |
Load the module. More... | |
static int | log_events (struct ast_channel *chan, char *signalling_type, event_node_t *event, int no_checksum) |
Log events if configuration key logindividualevents is enabled or on exit. More... | |
static int | receive_ademco_event (struct ast_channel *chan, event_node_t **ehead, char *signalling_type, int *no_checksum) |
Receive Ademco ContactID or other format Data String. More... | |
static int | receive_dtmf_digits (struct ast_channel *chan, char *digit_string, int buf_size, int expected, int *received) |
Receive a fixed length DTMF string. More... | |
static int | reload (void) |
static int | send_tone_burst (struct ast_channel *chan, const char *tone_freq, int tone_duration, int delay) |
Send a single tone burst for a specified duration and frequency. More... | |
static int | unload_module (void) |
Unregister Alarm Receiver App. More... | |
static int | write_event (FILE *logfile, event_node_t *event) |
Log a single event. More... | |
static int | write_metadata (FILE *logfile, char *signalling_type, struct ast_channel *chan, int no_checksum) |
Write metadata to log file. More... | |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Alarm Receiver for Asterisk" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "da6642af068ee5e6490c5b1d2cc1d238" , .support_level = AST_MODULE_SUPPORT_EXTENDED, .load = load_module, .unload = unload_module, .reload = reload, } |
static int | answait = 1250 |
static const char | app [] = "AlarmReceiver" |
static const struct ast_module_info * | ast_module_info = &__mod_info |
struct timeval | call_start_time |
static char | db_family [128] = {'\0'} |
struct { | |
char digit | |
char weight | |
} | digits_mapping [] |
static char | event_app [128] = {'\0'} |
static char | event_file [14] = "/event-XXXXXX" |
static char | event_spool_dir [128] = {'\0'} |
static int | fdtimeout = 2000 |
static int | log_individual_events = 0 |
static int | no_group_meta = 0 |
static int | sdtimeout = 200 |
static char | time_stamp_format [128] = {"%a %b %d, %Y @ %H:%M:%S %Z"} |
static int | toneloudness = 4096 |
Central Station Alarm receiver for Ademco Contact ID.
*** WARNING *** WARNING *** WARNING *** WARNING *** WARNING *** WARNING *** WARNING *** WARNING ***
Use at your own risk. Please consult the GNU GPL license document included with Asterisk. *
*** WARNING *** WARNING *** WARNING *** WARNING *** WARNING *** WARNING *** WARNING *** WARNING ***
Definition in file app_alarmreceiver.c.
|
static |
Check if the message is in known and valid Ademco format.
signalling_type | Expected signalling type for the message |
event | event received |
0 | The event is valid |
-1 | The event is not valid |
Definition at line 522 of file app_alarmreceiver.c.
Referenced by receive_ademco_event().
|
static |
Detect the message format of an event.
signalling_type | Expected signalling type for the message |
event | event received |
no_checksum | Should we calculate checksum for the message |
Definition at line 562 of file app_alarmreceiver.c.
References ast_debug.
Referenced by receive_ademco_event().
|
static |
Verify Ademco checksum.
event | Received DTMF String |
expected | Number of Digits expected |
0 | success |
-1 | failure |
Definition at line 455 of file app_alarmreceiver.c.
Referenced by receive_ademco_event().
|
static |
This is the main function called by Asterisk Core whenever the App is invoked in the extension logic.
chan | Asterisk Channel |
data | Application data |
0 | success |
-1 | failure |
Definition at line 791 of file app_alarmreceiver.c.
References ast_answer(), ast_copy_string(), ast_debug, ast_format_alaw, ast_format_cmp(), AST_FORMAT_CMP_NOT_EQUAL, ast_format_ulaw, ast_safe_sleep(), ast_safe_system(), ast_set_read_format(), ast_set_write_format(), AST_STATE_UP, ast_tvnow(), log_events(), and receive_ademco_event().
Referenced by load_module().
|
static |
Attempt to access a database variable and increment it.
The alarmreceiver app will write statistics to a few variables in this family if it is defined. If the new key doesn't exist in the family, then create it and set its value to 1.
key | A database key to increment |
Definition at line 207 of file app_alarmreceiver.c.
References ast_db_get(), and ast_db_put().
Referenced by receive_ademco_event().
|
static |
Load the configuration from the configuration file.
reload | True on reload |
1 | success |
0 | failure |
Definition at line 867 of file app_alarmreceiver.c.
References ast_config_destroy(), ast_config_load, ast_copy_string(), ast_true(), and CONFIG_FLAG_FILEUNCHANGED.
Referenced by load_module().
|
static |
Load the module.
Module loading including tests for configuration or dependencies. This function can return AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_DECLINE, or AST_MODULE_LOAD_SUCCESS. If a dependency or environment variable fails tests return AST_MODULE_LOAD_FAILURE. If the module can not load the configuration file or other non-critical problem return AST_MODULE_LOAD_DECLINE. On success return AST_MODULE_LOAD_SUCCESS.
Definition at line 973 of file app_alarmreceiver.c.
References alarmreceiver_exec(), AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_register_application_xml, and load_config().
|
static |
Log events if configuration key logindividualevents is enabled or on exit.
chan | Asterisk Channel |
signalling_type | Signaling Type |
event | Event Structure |
no_checksum | Expecting messages without checksum |
0 | success |
-1 | failure |
Definition at line 401 of file app_alarmreceiver.c.
References ast_copy_string(), ast_debug, write_event(), and write_metadata().
Referenced by alarmreceiver_exec(), and receive_ademco_event().
|
static |
Receive Ademco ContactID or other format Data String.
chan | Asterisk Channel |
ehead | Pointer to events list |
signalling_type | Expected signalling type for the message |
no_checksum | Should we calculate checksum for the message |
0 | success |
-1 | failure |
Definition at line 610 of file app_alarmreceiver.c.
References ademco_check_valid(), ademco_detect_format(), ademco_verify_checksum(), ast_calloc, ast_copy_string(), ast_debug, ast_tvdiff_ms(), ast_tvnow(), database_increment(), log_events(), pbx_builtin_getvar_helper(), receive_dtmf_digits(), and send_tone_burst().
Referenced by alarmreceiver_exec().
|
static |
Receive a fixed length DTMF string.
chan | Asterisk Channel |
digit_string | Digits String |
buf_size | The size of the Digits String buffer |
expected | Digits expected for this message type |
received | Pointer to number of digits received so far |
0 | if all digits were successfully received |
1 | if a timeout occurred |
-1 | if the caller hung up or on channel errors |
Definition at line 252 of file app_alarmreceiver.c.
References AST_CONTROL_HANGUP, ast_debug, AST_FRAME_CONTROL, ast_read(), ast_tvdiff_ms(), ast_tvnow(), ast_waitfor(), ast_frame::data, ast_frame::frametype, ast_frame_subclass::integer, and ast_frame::subclass.
Referenced by receive_ademco_event().
|
static |
Send a single tone burst for a specified duration and frequency.
chan | Asterisk Channel |
tone_freq | Frequency of the tone to send |
tone_duration | Tone duration in ms |
delay | Delay before sending the tone |
0 | success |
-1 | failure |
Definition at line 495 of file app_alarmreceiver.c.
References ast_playtones_start(), ast_playtones_stop(), and ast_safe_sleep().
Referenced by receive_ademco_event().
|
static |
Unregister Alarm Receiver App.
0 | success |
-1 | failure |
Definition at line 958 of file app_alarmreceiver.c.
References ast_unregister_application().
|
static |
Log a single event.
logfile | Log File Pointer |
event | Event Structure |
0 | success |
-1 | failure |
Definition at line 381 of file app_alarmreceiver.c.
Referenced by log_events().
|
static |
Write metadata to log file.
logfile | Log File Pointer |
signalling_type | Signaling Type |
chan | Asterisk Channel |
no_checksum | Expecting messages without checksum |
0 | success |
-1 | failure |
Definition at line 320 of file app_alarmreceiver.c.
References ast_copy_string(), ast_debug, ast_localtime(), ast_shrink_phone_number(), ast_strftime(), ast_tvnow(), and S_COR.
Referenced by log_events().
struct { ... } digits_mapping[] |