Asterisk - The Open Source Telephony Project  GIT-master-a24979a
Data Structures | Macros | Typedefs | Functions | Variables
app_alarmreceiver.c File Reference

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"
Include dependency graph for app_alarmreceiver.c:

Go to the source code of this file.

Data Structures

struct  event_node
 

Macros

#define ADEMCO_AUDIO_CALL_NEXT   "606"
 
#define ADEMCO_CONTACT_ID   "ADEMCO_CONTACT_ID"
 
#define ADEMCO_EXPRESS_4_1   "ADEMCO_EXPRESS_4_1"
 
#define ADEMCO_EXPRESS_4_2   "ADEMCO_EXPRESS_4_2"
 
#define ADEMCO_HIGH_SPEED   "ADEMCO_HIGH_SPEED"
 
#define ADEMCO_MSG_TYPE_1   "18"
 
#define ADEMCO_MSG_TYPE_2   "98"
 
#define ADEMCO_MSG_TYPE_3   "17"
 
#define ADEMCO_MSG_TYPE_4   "27"
 
#define ADEMCO_MSG_TYPE_5   "55"
 
#define ADEMCO_MSG_TYPE_6   "56"
 
#define ADEMCO_SUPER_FAST   "ADEMCO_SUPER_FAST"
 
#define ALMRCV_CONFIG   "alarmreceiver.conf"
 
#define UNKNOWN_FORMAT   "UNKNOWN_FORMAT"
 

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_moduleAST_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 = AST_BUILDOPT_SUM, .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_infoast_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
 

Detailed Description

Central Station Alarm receiver for Ademco Contact ID.

Author
Steve Rodgers hwsta.nosp@m.r@ro.nosp@m.dgers.nosp@m..sdc.nosp@m.oxmai.nosp@m.l.co.nosp@m.m

*** 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.

Macro Definition Documentation

◆ ADEMCO_AUDIO_CALL_NEXT

#define ADEMCO_AUDIO_CALL_NEXT   "606"

Definition at line 128 of file app_alarmreceiver.c.

◆ ADEMCO_CONTACT_ID

#define ADEMCO_CONTACT_ID   "ADEMCO_CONTACT_ID"

Definition at line 71 of file app_alarmreceiver.c.

◆ ADEMCO_EXPRESS_4_1

#define ADEMCO_EXPRESS_4_1   "ADEMCO_EXPRESS_4_1"

Definition at line 80 of file app_alarmreceiver.c.

◆ ADEMCO_EXPRESS_4_2

#define ADEMCO_EXPRESS_4_2   "ADEMCO_EXPRESS_4_2"

Definition at line 87 of file app_alarmreceiver.c.

◆ ADEMCO_HIGH_SPEED

#define ADEMCO_HIGH_SPEED   "ADEMCO_HIGH_SPEED"

Definition at line 94 of file app_alarmreceiver.c.

◆ ADEMCO_MSG_TYPE_1

#define ADEMCO_MSG_TYPE_1   "18"

Definition at line 121 of file app_alarmreceiver.c.

◆ ADEMCO_MSG_TYPE_2

#define ADEMCO_MSG_TYPE_2   "98"

Definition at line 122 of file app_alarmreceiver.c.

◆ ADEMCO_MSG_TYPE_3

#define ADEMCO_MSG_TYPE_3   "17"

Definition at line 123 of file app_alarmreceiver.c.

◆ ADEMCO_MSG_TYPE_4

#define ADEMCO_MSG_TYPE_4   "27"

Definition at line 124 of file app_alarmreceiver.c.

◆ ADEMCO_MSG_TYPE_5

#define ADEMCO_MSG_TYPE_5   "55"

Definition at line 125 of file app_alarmreceiver.c.

◆ ADEMCO_MSG_TYPE_6

#define ADEMCO_MSG_TYPE_6   "56"

Definition at line 126 of file app_alarmreceiver.c.

◆ ADEMCO_SUPER_FAST

#define ADEMCO_SUPER_FAST   "ADEMCO_SUPER_FAST"

Definition at line 115 of file app_alarmreceiver.c.

◆ ALMRCV_CONFIG

#define ALMRCV_CONFIG   "alarmreceiver.conf"

Definition at line 68 of file app_alarmreceiver.c.

◆ UNKNOWN_FORMAT

#define UNKNOWN_FORMAT   "UNKNOWN_FORMAT"

Definition at line 69 of file app_alarmreceiver.c.

Typedef Documentation

◆ event_node_t

typedef struct event_node event_node_t

Definition at line 1 of file app_alarmreceiver.c.

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 999 of file app_alarmreceiver.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 999 of file app_alarmreceiver.c.

◆ ademco_check_valid()

static int ademco_check_valid ( char *  signalling_type,
char *  event 
)
static

Check if the message is in known and valid Ademco format.

Parameters
signalling_typeExpected signalling type for the message
eventevent received
Return values
0The event is valid
-1The event is not valid

Definition at line 522 of file app_alarmreceiver.c.

523 {
524  if (!strcmp(signalling_type, UNKNOWN_FORMAT)) {
525  return 1;
526  }
527 
528  if (!strcmp(signalling_type, ADEMCO_CONTACT_ID)
529  && strncmp(event + 4, ADEMCO_MSG_TYPE_1, 2)
530  && strncmp(event + 4, ADEMCO_MSG_TYPE_2, 2)) {
531  return -1;
532  }
533 
534  if (!strcmp(signalling_type, ADEMCO_EXPRESS_4_1) && strncmp(event + 4, ADEMCO_MSG_TYPE_3, 2)) {
535  return -1;
536  }
537 
538  if (!strcmp(signalling_type, ADEMCO_EXPRESS_4_2) && strncmp(event + 4, ADEMCO_MSG_TYPE_4, 2)) {
539  return -1;
540  }
541 
542  if (!strcmp(signalling_type, ADEMCO_HIGH_SPEED) && strncmp(event + 4, ADEMCO_MSG_TYPE_5, 2)) {
543  return -1;
544  }
545 
546  if (!strcmp(signalling_type, ADEMCO_SUPER_FAST) && strncmp(event + 4, ADEMCO_MSG_TYPE_6, 2)) {
547  return -1;
548  }
549 
550  return 0;
551 }
#define ADEMCO_MSG_TYPE_4
#define ADEMCO_EXPRESS_4_2
#define ADEMCO_MSG_TYPE_2
#define ADEMCO_CONTACT_ID
#define ADEMCO_HIGH_SPEED
#define ADEMCO_MSG_TYPE_3
#define ADEMCO_EXPRESS_4_1
#define ADEMCO_MSG_TYPE_6
#define ADEMCO_MSG_TYPE_5
#define UNKNOWN_FORMAT
#define ADEMCO_SUPER_FAST
#define ADEMCO_MSG_TYPE_1
Definition: astman.c:222

References ADEMCO_CONTACT_ID, ADEMCO_EXPRESS_4_1, ADEMCO_EXPRESS_4_2, ADEMCO_HIGH_SPEED, ADEMCO_MSG_TYPE_1, ADEMCO_MSG_TYPE_2, ADEMCO_MSG_TYPE_3, ADEMCO_MSG_TYPE_4, ADEMCO_MSG_TYPE_5, ADEMCO_MSG_TYPE_6, ADEMCO_SUPER_FAST, and UNKNOWN_FORMAT.

Referenced by receive_ademco_event().

◆ ademco_detect_format()

static int ademco_detect_format ( char *  signalling_type,
char *  event,
int *  no_checksum 
)
static

Detect the message format of an event.

Parameters
signalling_typeExpected signalling type for the message
eventevent received
no_checksumShould we calculate checksum for the message
Returns
The expected digits for the detected event type

Definition at line 562 of file app_alarmreceiver.c.

563 {
564  int res = 16;
565 
566  if (!strncmp(event + 4, ADEMCO_MSG_TYPE_1, 2)
567  || !strncmp(event + 4, ADEMCO_MSG_TYPE_2, 2)) {
568  sprintf(signalling_type, "%s", ADEMCO_CONTACT_ID);
569  }
570 
571  if (!strncmp(event + 4, ADEMCO_MSG_TYPE_3, 2)) {
572  sprintf(signalling_type, "%s", ADEMCO_EXPRESS_4_1);
573  res = 8;
574  }
575 
576  if (!strncmp(event + 4, ADEMCO_MSG_TYPE_4, 2)) {
577  sprintf(signalling_type, "%s", ADEMCO_EXPRESS_4_2);
578  res = 9;
579  }
580 
581  if (!strncmp(event + 4, ADEMCO_MSG_TYPE_5, 2)) {
582  sprintf(signalling_type, "%s", ADEMCO_HIGH_SPEED);
583  }
584 
585  if (!strncmp(event + 4, ADEMCO_MSG_TYPE_6, 2)) {
586  sprintf(signalling_type, "%s", ADEMCO_SUPER_FAST);
587  *no_checksum = 1;
588  res = 15;
589  }
590 
591  if (strcmp(signalling_type, UNKNOWN_FORMAT)) {
592  ast_verb(4, "AlarmMonitoring: Detected format %s.\n", signalling_type);
593  ast_debug(1, "AlarmMonitoring: Autodetected format %s.\n", signalling_type);
594  }
595 
596  return res;
597 }
#define ast_debug(level,...)
Log a DEBUG message.
#define ast_verb(level,...)

References ADEMCO_CONTACT_ID, ADEMCO_EXPRESS_4_1, ADEMCO_EXPRESS_4_2, ADEMCO_HIGH_SPEED, ADEMCO_MSG_TYPE_1, ADEMCO_MSG_TYPE_2, ADEMCO_MSG_TYPE_3, ADEMCO_MSG_TYPE_4, ADEMCO_MSG_TYPE_5, ADEMCO_MSG_TYPE_6, ADEMCO_SUPER_FAST, ast_debug, ast_verb, and UNKNOWN_FORMAT.

Referenced by receive_ademco_event().

◆ ademco_verify_checksum()

static int ademco_verify_checksum ( char *  event,
int  expected 
)
static

Verify Ademco checksum.

Since
11.0
Parameters
eventReceived DTMF String
expectedNumber of Digits expected
Return values
0success
-1failure

Definition at line 455 of file app_alarmreceiver.c.

456 {
457  int checksum = 0;
458  int i, j;
459 
460  for (j = 0; j < expected; j++) {
461  for (i = 0; i < ARRAY_LEN(digits_mapping); i++) {
462  if (digits_mapping[i].digit == event[j]) {
463  break;
464  }
465  }
466 
467  if (i >= ARRAY_LEN(digits_mapping)) {
468  ast_verb(2, "AlarmReceiver: Bad DTMF character %c, trying again\n", event[j]);
469  return -1;
470  }
471 
472  checksum += digits_mapping[i].weight;
473  }
474 
475  /* Checksum is mod(15) of the total */
476  if (!(checksum % 15)) {
477  return 0;
478  }
479 
480  return -1;
481 }
struct @6 digits_mapping[]
char digit
#define ARRAY_LEN(a)
Definition: utils.h:661

References ARRAY_LEN, ast_verb, digit, and digits_mapping.

Referenced by receive_ademco_event().

◆ alarmreceiver_exec()

static int alarmreceiver_exec ( struct ast_channel chan,
const char *  data 
)
static

This is the main function called by Asterisk Core whenever the App is invoked in the extension logic.

Parameters
chanAsterisk Channel
dataApplication data
Return values
0success
-1failure

Definition at line 791 of file app_alarmreceiver.c.

792 {
793  int res = 0;
794  int no_checksum = 0;
795  event_node_t *elp, *efree;
796  char signalling_type[64] = "";
797  event_node_t *event_head = NULL;
798 
801  ast_verb(4, "AlarmReceiver: Setting write format to Mu-law\n");
803  ast_log(LOG_WARNING, "AlarmReceiver: Unable to set write format to Mu-law on %s\n",ast_channel_name(chan));
804  return -1;
805  }
806  }
807 
810  ast_verb(4, "AlarmReceiver: Setting read format to Mu-law\n");
812  ast_log(LOG_WARNING, "AlarmReceiver: Unable to set read format to Mu-law on %s\n",ast_channel_name(chan));
813  return -1;
814  }
815  }
816 
817  /* Set default values for this invocation of the application */
818  ast_copy_string(signalling_type, UNKNOWN_FORMAT, sizeof(signalling_type));
820 
821  /* Answer the channel if it is not already */
822  if (ast_channel_state(chan) != AST_STATE_UP) {
823  ast_verb(4, "AlarmReceiver: Answering channel\n");
824  if (ast_answer(chan)) {
825  return -1;
826  }
827  }
828 
829  /* Wait for the connection to settle post-answer */
830  ast_verb(4, "AlarmReceiver: Waiting for connection to stabilize\n");
831  if (ast_safe_sleep(chan, answait)) {
832  return -1;
833  }
834 
835  /* Attempt to receive the events */
836  receive_ademco_event(chan, &event_head, signalling_type, &no_checksum);
837 
838  /* Events queued by receiver, write them all out here if so configured */
839  if (!log_individual_events) {
840  res = log_events(chan, signalling_type, event_head, no_checksum);
841  }
842 
843  /* Do we exec a command line at the end? */
844  if ((!res) && (!ast_strlen_zero(event_app)) && (event_head)) {
845  ast_debug(1,"Alarmreceiver: executing: %s\n", event_app);
847  }
848 
849  /* Free up the data allocated in our linked list */
850  for (elp = event_head; (elp != NULL);) {
851  efree = elp;
852  elp = elp->next;
853  ast_free(efree);
854  }
855 
856  return 0;
857 }
struct timeval call_start_time
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.
static int log_individual_events
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.
static char event_app[128]
static int answait
#define ast_free(a)
Definition: astmm.h:180
#define ast_log
Definition: astobj2.c:42
struct ast_format * ast_channel_writeformat(struct ast_channel *chan)
const char * ast_channel_name(const struct ast_channel *chan)
int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
Sets read format on channel chan.
Definition: channel.c:5839
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
Sets write format on channel chan.
Definition: channel.c:5880
int ast_answer(struct ast_channel *chan)
Answer a channel.
Definition: channel.c:2806
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups.
Definition: channel.c:1568
ast_channel_state
ast_channel states
Definition: channelstate.h:35
@ AST_STATE_UP
Definition: channelstate.h:42
enum ast_format_cmp_res ast_format_cmp(const struct ast_format *format1, const struct ast_format *format2)
Compare two formats.
Definition: format.c:201
@ AST_FORMAT_CMP_NOT_EQUAL
Definition: format.h:38
struct ast_format * ast_format_ulaw
Built-in cached ulaw format.
Definition: format_cache.c:86
struct ast_format * ast_format_alaw
Built-in cached alaw format.
Definition: format_cache.c:91
int ast_safe_system(const char *s)
Safely spawn an OS shell command while closing file descriptors.
Definition: extconf.c:829
#define LOG_WARNING
#define NULL
Definition: resample.c:96
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:406
struct event_node * next
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:157

References answait, ast_answer(), ast_channel_name(), ast_channel_readformat(), ast_channel_writeformat(), ast_copy_string(), ast_debug, ast_format_alaw, ast_format_cmp(), AST_FORMAT_CMP_NOT_EQUAL, ast_format_ulaw, ast_free, ast_log, ast_safe_sleep(), ast_safe_system(), ast_set_read_format(), ast_set_write_format(), AST_STATE_UP, ast_strlen_zero(), ast_tvnow(), ast_verb, call_start_time, event_app, log_events(), log_individual_events, LOG_WARNING, event_node::next, NULL, receive_ademco_event(), and UNKNOWN_FORMAT.

Referenced by load_module().

◆ AST_MODULE_SELF_SYM()

struct ast_module* AST_MODULE_SELF_SYM ( void  )

Definition at line 999 of file app_alarmreceiver.c.

◆ database_increment()

static void database_increment ( char *  key)
static

Attempt to access a database variable and increment it.

Note
Only if the user defined db-family in alarmreceiver.conf

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.

Parameters
keyA database key to increment

Definition at line 207 of file app_alarmreceiver.c.

208 {
209  unsigned v;
210  char value[16];
211 
212  if (ast_strlen_zero(db_family)) {
213  return; /* If not defined, don't do anything */
214  }
215 
216  if (ast_db_get(db_family, key, value, sizeof(value) - 1)) {
217  ast_verb(4, "AlarmReceiver: Creating database entry %s and setting to 1\n", key);
218  /* Guess we have to create it */
219  ast_db_put(db_family, key, "1");
220  return;
221  }
222 
223  sscanf(value, "%30u", &v);
224  v++;
225 
226  ast_verb(4, "AlarmReceiver: New value for %s: %u\n", key, v);
227  snprintf(value, sizeof(value), "%u", v);
228 
229  if (ast_db_put(db_family, key, value)) {
230  ast_verb(4, "AlarmReceiver: database_increment write error\n");
231  }
232 
233  return;
234 }
static char db_family[128]
int ast_db_put(const char *family, const char *key, const char *value)
Store value addressed by family/key.
Definition: main/db.c:327
int ast_db_get(const char *family, const char *key, char *value, int valuelen)
Get key value specified by family/key.
Definition: main/db.c:412
int value
Definition: syslog.c:37

References ast_db_get(), ast_db_put(), ast_strlen_zero(), ast_verb, db_family, and value.

Referenced by receive_ademco_event().

◆ load_config()

static int load_config ( int  reload)
static

Load the configuration from the configuration file.

Parameters
reloadTrue on reload
Return values
1success
0failure

Definition at line 867 of file app_alarmreceiver.c.

868 {
869  struct ast_config *cfg;
870  const char *value;
871  struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
872 
873  /* Read in the config file */
874  cfg = ast_config_load(ALMRCV_CONFIG, config_flags);
875 
876  if (!cfg) {
877  ast_verb(4, "AlarmReceiver: No config file\n");
878  return 0;
879  } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
880  return 1;
881  } else if (cfg == CONFIG_STATUS_FILEINVALID) {
882  ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n",
883  ALMRCV_CONFIG);
884  return 0;
885  }
886 
887  if ((value = ast_variable_retrieve(cfg, "general", "eventcmd")) != NULL) {
889  }
890 
891  if ((value = ast_variable_retrieve(cfg, "general", "loudness")) != NULL) {
892  toneloudness = atoi(value);
893  if (toneloudness < 100) {
894  toneloudness = 100;
895  } else if (toneloudness > 8192) {
896  toneloudness = 8192;
897  }
898  }
899 
900  if ((value = ast_variable_retrieve(cfg, "general", "fdtimeout")) != NULL) {
901  fdtimeout = atoi(value);
902  if (fdtimeout < 1000) {
903  fdtimeout = 1000;
904  } else if (fdtimeout > 10000) {
905  fdtimeout = 10000;
906  }
907  }
908 
909  if ((value = ast_variable_retrieve(cfg, "general", "sdtimeout")) != NULL) {
910  sdtimeout = atoi(value);
911  if (sdtimeout < 110) {
912  sdtimeout = 110;
913  } else if (sdtimeout > 4000) {
914  sdtimeout = 4000;
915  }
916  }
917 
918  if ((value = ast_variable_retrieve(cfg, "general", "answait")) != NULL) {
919  answait = atoi(value);
920  if (answait < 500) {
921  answait = 500;
922  } else if (answait > 10000) {
923  answait = 10000;
924  }
925  }
926 
927  if ((value = ast_variable_retrieve(cfg, "general", "no_group_meta")) != NULL) {
929  }
930 
931  if ((value = ast_variable_retrieve(cfg, "general", "logindividualevents")) != NULL) {
933  }
934 
935  if ((value = ast_variable_retrieve(cfg, "general", "eventspooldir")) != NULL) {
937  }
938 
939  if ((value = ast_variable_retrieve(cfg, "general", "timestampformat")) != NULL) {
941  }
942 
943  if ((value = ast_variable_retrieve(cfg, "general", "db-family")) != NULL) {
945  }
946 
947  ast_config_destroy(cfg);
948 
949  return 1;
950 }
static char time_stamp_format[128]
#define ALMRCV_CONFIG
static int fdtimeout
static int toneloudness
static int sdtimeout
static char event_spool_dir[128]
static int no_group_meta
static int reload(void)
#define ast_config_load(filename, flags)
Load a config file.
@ CONFIG_FLAG_FILEUNCHANGED
#define CONFIG_STATUS_FILEUNCHANGED
#define CONFIG_STATUS_FILEINVALID
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
Definition: extconf.c:1289
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
Definition: main/config.c:768
#define LOG_ERROR
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
Definition: main/utils.c:2097
Structure used to handle boolean flags.
Definition: utils.h:199

References ALMRCV_CONFIG, answait, ast_config_destroy(), ast_config_load, ast_copy_string(), ast_log, ast_true(), ast_variable_retrieve(), ast_verb, CONFIG_FLAG_FILEUNCHANGED, CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEUNCHANGED, db_family, event_app, event_spool_dir, fdtimeout, LOG_ERROR, log_individual_events, no_group_meta, NULL, reload(), sdtimeout, time_stamp_format, toneloudness, and value.

Referenced by load_module().

◆ load_module()

static int load_module ( void  )
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.

974 {
975  if (load_config(0)) {
978  }
980  }
981 
983 }
static const char app[]
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.
static int load_config(int reload)
Load the configuration from the configuration file.
@ AST_MODULE_LOAD_SUCCESS
Definition: module.h:70
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
Definition: module.h:78
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:626

References alarmreceiver_exec(), app, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_register_application_xml, and load_config().

◆ log_events()

static int log_events ( struct ast_channel chan,
char *  signalling_type,
event_node_t event,
int  no_checksum 
)
static

Log events if configuration key logindividualevents is enabled or on exit.

Parameters
chanAsterisk Channel
signalling_typeSignaling Type
eventEvent Structure
no_checksumExpecting messages without checksum
Return values
0success
-1failure

Definition at line 401 of file app_alarmreceiver.c.

402 {
403  char workstring[sizeof(event_spool_dir) + sizeof(event_file)] = "";
404  int fd;
405  FILE *logfile;
406  event_node_t *elp = event;
407 
409 
410  /* Make a template */
411  ast_copy_string(workstring, event_spool_dir, sizeof(workstring));
412  strncat(workstring, event_file, sizeof(workstring) - strlen(workstring) - 1);
413 
414  /* Make the temporary file */
415  fd = mkstemp(workstring);
416 
417  if (fd == -1) {
418  ast_verb(3, "AlarmReceiver: can't make temporary file\n");
419  ast_debug(1, "AlarmReceiver: can't make temporary file\n");
420  return -1;
421  }
422 
423  if ((logfile = fdopen(fd, "w")) == NULL) {
424  return -1;
425  }
426 
427  /* Write the file */
428  if (write_metadata(logfile, signalling_type, chan, no_checksum)) {
429  fflush(logfile);
430  fclose(logfile);
431  return -1;
432  }
433 
434  while ((elp != NULL) && (write_event(logfile, elp) == 0)) {
435  elp = elp->next;
436  }
437 
438  fflush(logfile);
439  fclose(logfile);
440  }
441 
442  return 0;
443 }
static int write_metadata(FILE *logfile, char *signalling_type, struct ast_channel *chan, int no_checksum)
Write metadata to log file.
static char event_file[14]
static int write_event(FILE *logfile, event_node_t *event)
Log a single event.

References ast_copy_string(), ast_debug, ast_strlen_zero(), ast_verb, event_file, event_spool_dir, event_node::next, NULL, write_event(), and write_metadata().

Referenced by alarmreceiver_exec(), and receive_ademco_event().

◆ receive_ademco_event()

static int receive_ademco_event ( struct ast_channel chan,
event_node_t **  ehead,
char *  signalling_type,
int *  no_checksum 
)
static

Receive Ademco ContactID or other format Data String.

Parameters
chanAsterisk Channel
eheadPointer to events list
signalling_typeExpected signalling type for the message
no_checksumShould we calculate checksum for the message
Return values
0success
-1failure

Definition at line 610 of file app_alarmreceiver.c.

611 {
612  int res = 0;
613  const char *limit;
614  char event[17];
615  event_node_t *enew, *elp;
616  int got_some_digits = 0;
617  int events_received = 0;
618  int ack_retries = 0;
619  int limit_retries = 0;
620  int expected_length = sizeof(event) - 1;
621 
622  database_increment("calls-received");
623 
624  /* Wait for first event */
625  ast_verb(4, "AlarmReceiver: Waiting for first event from panel...\n");
626 
627  while (res >= 0) {
628  int digits_received = 0;
629 
630  res = 0;
631 
632  if (log_individual_events) {
633  sprintf(signalling_type, "%s", UNKNOWN_FORMAT);
634  expected_length = 16;
635  *no_checksum = 0;
636  }
637 
638  if (got_some_digits == 0) {
639  /* Send ACK tone sequence */
640  ast_verb(4, "AlarmReceiver: Sending 1400Hz 100ms burst (ACK)\n");
641  res = send_tone_burst(chan, "1400", 100, 0);
642  if (!res) {
643  ast_verb(4, "AlarmReceiver: Sending 2300Hz 100ms burst (ACK)\n");
644  res = send_tone_burst(chan, "2300", 100, 100);
645  }
646  }
647  if (res) {
648  return -1;
649  }
650 
651  res = receive_dtmf_digits(chan, event, sizeof(event), expected_length, &digits_received);
652  if (res < 0) {
653  if (events_received == 0) {
654  /* Hangup with no events received should be logged in the DB */
655  database_increment("no-events-received");
656  ast_verb(4, "AlarmReceiver: No events received!\n");
657  } else {
658  if (ack_retries) {
659  database_increment("ack-retries");
660  ast_verb(4, "AlarmReceiver: ACK retries during this call: %d\n", ack_retries);
661  }
662  }
663  ast_verb(4, "AlarmReceiver: App exiting...\n");
664  break;
665  }
666 
667  if (!strcmp(signalling_type, UNKNOWN_FORMAT) && digits_received > 5) {
668  expected_length = ademco_detect_format(signalling_type, event, no_checksum);
669 
670  if (res > 0) {
671  if (digits_received == expected_length) {
672  res = limit_retries = 0;
673  } else if (digits_received == expected_length - 1
674  && (!strcmp(signalling_type, ADEMCO_EXPRESS_4_2)
675  || !strcmp(signalling_type, ADEMCO_EXPRESS_4_1))) {
676  /* ADEMCO EXPRESS without checksum */
677  res = limit_retries = 0;
678  expected_length--;
679  *no_checksum = 1;
680  ast_verb(4, "AlarmMonitoring: Skipping checksum for format %s.\n", signalling_type);
681  ast_debug(1, "AlarmMonitoring: Skipping checksum for format %s.\n", signalling_type);
682  }
683  }
684  }
685 
686  ast_channel_lock(chan);
687  limit = pbx_builtin_getvar_helper(chan, "ALARMRECEIVER_CALL_LIMIT");
688  if (!ast_strlen_zero(limit)) {
689  if (ast_tvdiff_ms(ast_tvnow(), call_start_time) > atoi(limit)) {
690  ast_channel_unlock(chan);
691  return -1;
692  }
693  }
694  limit = pbx_builtin_getvar_helper(chan, "ALARMRECEIVER_RETRIES_LIMIT");
695  ast_channel_unlock(chan);
696  if (!ast_strlen_zero(limit)) {
697  if (limit_retries + 1 >= atoi(limit)) {
698  return -1;
699  }
700  }
701 
702  if (res) {
703  /* Didn't get all of the digits */
704  ast_verb(2, "AlarmReceiver: Incomplete string: %s, trying again...\n", event);
705  limit_retries++;
706 
707  if (!events_received && strcmp(signalling_type, UNKNOWN_FORMAT))
708  {
709  sprintf(signalling_type, "%s", UNKNOWN_FORMAT);
710  expected_length = sizeof(event) - 1;
711  }
712 
713  if (!got_some_digits) {
714  got_some_digits = (!ast_strlen_zero(event)) ? 1 : 0;
715  ack_retries++;
716  }
717  continue;
718  }
719 
720  got_some_digits = 1;
721 
722  ast_verb(2, "AlarmReceiver: Received Event %s\n", event);
723  ast_debug(1, "AlarmReceiver: Received event: %s\n", event);
724 
725  /* Calculate checksum */
726  if (!(*no_checksum) && ademco_verify_checksum(event, expected_length)) {
727  database_increment("checksum-errors");
728  ast_verb(2, "AlarmReceiver: Nonzero checksum\n");
729  ast_debug(1, "AlarmReceiver: Nonzero checksum\n");
730  continue;
731  }
732 
733  /* Check the message type for correctness */
734  if (ademco_check_valid(signalling_type, event)) {
735  database_increment("format-errors");
736  ast_verb(2, "AlarmReceiver: Wrong message type\n");
737  ast_debug(1, "AlarmReceiver: Wrong message type\n");
738  continue;
739  }
740 
741  events_received++;
742 
743  /* Queue the Event */
744  if (!(enew = ast_calloc(1, sizeof(*enew)))) {
745  return -1;
746  }
747 
748  enew->next = NULL;
749  ast_copy_string(enew->data, event, sizeof(enew->data));
750 
751  /* Insert event onto end of list */
752  if (*ehead == NULL) {
753  *ehead = enew;
754  } else {
755  for (elp = *ehead; elp->next != NULL; elp = elp->next) {
756  ;
757  }
758  elp->next = enew;
759  }
760 
761  /* Let the user have the option of logging the single event before sending the kissoff tone */
762  if (log_individual_events && log_events(chan, signalling_type, enew, *no_checksum)) {
763  return -1;
764  }
765 
766  /* Send the kissoff tone (1400 Hz, 900 ms, after 200ms delay) */
767  if (send_tone_burst(chan, "1400", 900, 200)) {
768  return -1;
769  }
770 
771  /* If audio call follows, exit alarm receiver app */
772  if (!strcmp(signalling_type, ADEMCO_CONTACT_ID)
773  && !strncmp(event + 7, ADEMCO_AUDIO_CALL_NEXT, 3)) {
774  ast_verb(4, "AlarmReceiver: App exiting... Audio call next!\n");
775  return 0;
776  }
777  }
778 
779  return res;
780 }
static int ademco_verify_checksum(char *event, int expected)
Verify Ademco checksum.
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.
#define ADEMCO_AUDIO_CALL_NEXT
static int ademco_detect_format(char *signalling_type, char *event, int *no_checksum)
Detect the message format of an event.
static int ademco_check_valid(char *signalling_type, char *event)
Check if the message is in known and valid Ademco format.
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.
static void database_increment(char *key)
Attempt to access a database variable and increment it.
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:202
#define ast_channel_lock(chan)
Definition: channel.h:2922
#define ast_channel_unlock(chan)
Definition: channel.h:2923
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Definition: time.h:105

References ADEMCO_AUDIO_CALL_NEXT, ademco_check_valid(), ADEMCO_CONTACT_ID, ademco_detect_format(), ADEMCO_EXPRESS_4_1, ADEMCO_EXPRESS_4_2, ademco_verify_checksum(), ast_calloc, ast_channel_lock, ast_channel_unlock, ast_copy_string(), ast_debug, ast_strlen_zero(), ast_tvdiff_ms(), ast_tvnow(), ast_verb, call_start_time, event_node::data, database_increment(), log_events(), log_individual_events, event_node::next, NULL, pbx_builtin_getvar_helper(), receive_dtmf_digits(), send_tone_burst(), and UNKNOWN_FORMAT.

Referenced by alarmreceiver_exec().

◆ receive_dtmf_digits()

static int receive_dtmf_digits ( struct ast_channel chan,
char *  digit_string,
int  buf_size,
int  expected,
int *  received 
)
static

Receive a fixed length DTMF string.

Note
Doesn't give preferential treatment to any digit,
allow different timeout values for the first and all subsequent digits
Parameters
chanAsterisk Channel
digit_stringDigits String
buf_sizeThe size of the Digits String buffer
expectedDigits expected for this message type
receivedPointer to number of digits received so far
Return values
0if all digits were successfully received
1if a timeout occurred
-1if the caller hung up or on channel errors

Definition at line 252 of file app_alarmreceiver.c.

253 {
254  int rtn = 0;
255  int r;
256  struct ast_frame *f;
257  struct timeval lastdigittime;
258 
259  lastdigittime = ast_tvnow();
260  while (*received < expected && *received < buf_size - 1) {
261  /* If timed out, leave */
262  if (ast_tvdiff_ms(ast_tvnow(), lastdigittime) > ((*received > 0) ? sdtimeout : fdtimeout)) {
263  ast_verb(4, "AlarmReceiver: DTMF Digit Timeout on %s\n", ast_channel_name(chan));
264  ast_debug(1, "AlarmReceiver: DTMF timeout on chan %s\n", ast_channel_name(chan));
265  rtn = 1;
266  break;
267  }
268 
269  if ((r = ast_waitfor(chan, -1)) < 0) {
270  ast_debug(1, "Waitfor returned %d\n", r);
271  continue;
272  }
273 
274  if ((f = ast_read(chan)) == NULL) {
275  rtn = -1;
276  break;
277  }
278 
279  /* If they hung up, leave */
280  if ((f->frametype == AST_FRAME_CONTROL)
281  && (f->subclass.integer == AST_CONTROL_HANGUP)) {
282  if (f->data.uint32) {
284  }
285  ast_frfree(f);
286  rtn = -1;
287  break;
288  }
289 
290  /* If not DTMF, just do it again */
291  if (f->frametype != AST_FRAME_DTMF) {
292  ast_frfree(f);
293  continue;
294  }
295 
296  /* Save digit */
297  digit_string[(*received)++] = f->subclass.integer;
298  ast_frfree(f);
299 
300  lastdigittime = ast_tvnow();
301  }
302 
303  /* Null terminate the end of the digit_string */
304  digit_string[*received] = '\0';
305 
306  return rtn;
307 }
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
Definition: channel.c:3163
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4292
void ast_channel_hangupcause_set(struct ast_channel *chan, int value)
#define AST_FRAME_DTMF
#define ast_frfree(fr)
@ AST_FRAME_CONTROL
@ AST_CONTROL_HANGUP
Data structure associated with a single frame of data.
struct ast_frame_subclass subclass
union ast_frame::@254 data
enum ast_frame_type frametype

References ast_channel_hangupcause_set(), ast_channel_name(), AST_CONTROL_HANGUP, ast_debug, AST_FRAME_CONTROL, AST_FRAME_DTMF, ast_frfree, ast_read(), ast_tvdiff_ms(), ast_tvnow(), ast_verb, ast_waitfor(), ast_frame::data, fdtimeout, ast_frame::frametype, ast_frame_subclass::integer, NULL, sdtimeout, ast_frame::subclass, and ast_frame::uint32.

Referenced by receive_ademco_event().

◆ reload()

static int reload ( void  )
static

Definition at line 985 of file app_alarmreceiver.c.

986 {
987  if (load_config(1)) {
989  }
990 
992 }

Referenced by load_config().

◆ send_tone_burst()

static int send_tone_burst ( struct ast_channel chan,
const char *  tone_freq,
int  tone_duration,
int  delay 
)
static

Send a single tone burst for a specified duration and frequency.

Since
11.0
Parameters
chanAsterisk Channel
tone_freqFrequency of the tone to send
tone_durationTone duration in ms
delayDelay before sending the tone
Return values
0success
-1failure

Definition at line 495 of file app_alarmreceiver.c.

496 {
497  if (delay && ast_safe_sleep(chan, delay)) {
498  return -1;
499  }
500 
501  if (ast_playtones_start(chan, toneloudness, tone_freq, 0)) {
502  return -1;
503  }
504 
505  if (ast_safe_sleep(chan, tone_duration)) {
506  return -1;
507  }
508 
509  ast_playtones_stop(chan);
510  return 0;
511 }
int ast_playtones_start(struct ast_channel *chan, int vol, const char *tonelist, int interruptible)
Start playing a list of tones on a channel.
Definition: indications.c:302
void ast_playtones_stop(struct ast_channel *chan)
Stop playing tones on a channel.
Definition: indications.c:393

References ast_playtones_start(), ast_playtones_stop(), ast_safe_sleep(), and toneloudness.

Referenced by receive_ademco_event().

◆ unload_module()

static int unload_module ( void  )
static

Unregister Alarm Receiver App.

Return values
0success
-1failure

Definition at line 958 of file app_alarmreceiver.c.

959 {
961 }
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx_app.c:392

References app, and ast_unregister_application().

◆ write_event()

static int write_event ( FILE *  logfile,
event_node_t event 
)
static

Log a single event.

Parameters
logfileLog File Pointer
eventEvent Structure
Return values
0success
-1failure

Definition at line 381 of file app_alarmreceiver.c.

382 {
383  if (fprintf(logfile, "%s%s\n", no_group_meta ? "event=" : "", event->data) < 0) {
384  return -1;
385  }
386 
387  return 0;
388 }

References no_group_meta.

Referenced by log_events().

◆ write_metadata()

static int write_metadata ( FILE *  logfile,
char *  signalling_type,
struct ast_channel chan,
int  no_checksum 
)
static

Write metadata to log file.

Parameters
logfileLog File Pointer
signalling_typeSignaling Type
chanAsterisk Channel
no_checksumExpecting messages without checksum
Return values
0success
-1failure

Definition at line 320 of file app_alarmreceiver.c.

321 {
322  struct timeval t;
323  struct ast_tm now;
324  char *cl;
325  char *cn;
326  char workstring[80];
327  char timestamp[80];
328 
329  /* Extract the caller ID location */
330  ast_copy_string(workstring,
331  S_COR(ast_channel_caller(chan)->id.number.valid,
332  ast_channel_caller(chan)->id.number.str, ""), sizeof(workstring));
333  ast_shrink_phone_number(workstring);
334  if (ast_strlen_zero(workstring)) {
335  cl = "<unknown>";
336  } else {
337  cl = workstring;
338  }
339  cn = S_COR(ast_channel_caller(chan)->id.name.valid,
340  ast_channel_caller(chan)->id.name.str, "<unknown>");
341 
342  /* Get the current time */
343  t = ast_tvnow();
344  ast_localtime(&t, &now, NULL);
345 
346  /* Format the time */
347  ast_strftime(timestamp, sizeof(timestamp), time_stamp_format, &now);
348 
349  if (no_group_meta && fprintf(logfile, "PROTOCOL=%s\n"
350  "CHECKSUM=%s\n"
351  "CALLINGFROM=%s\n"
352  "CALLERNAME=%s\n"
353  "TIMESTAMP=%s\n\n",
354  signalling_type, (!no_checksum) ? "yes" : "no", cl, cn, timestamp) > -1) {
355  return 0;
356  } else if (fprintf(logfile, "\n\n[metadata]\n\n"
357  "PROTOCOL=%s\n"
358  "CHECKSUM=%s\n"
359  "CALLINGFROM=%s\n"
360  "CALLERNAME=%s\n"
361  "TIMESTAMP=%s\n\n"
362  "[events]\n\n",
363  signalling_type, (!no_checksum) ? "yes" : "no", cl, cn, timestamp) > -1) {
364  return 0;
365  }
366 
367  ast_verb(3, "AlarmReceiver: can't write metadata\n");
368  ast_debug(1, "AlarmReceiver: can't write metadata\n");
369  return -1;
370 }
void ast_shrink_phone_number(char *n)
Shrink a phone number in place to just digits (more accurately it just removes ()'s,...
Definition: callerid.c:947
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
static const char name[]
Definition: format_mp3.c:68
int ast_strftime(char *buf, size_t len, const char *format, const struct ast_tm *tm)
Special version of strftime(3) that handles fractions of a second. Takes the same arguments as strfti...
Definition: localtime.c:2524
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
Definition: localtime.c:1739
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
Definition: strings.h:87
Number structure.
Definition: app_followme.c:154

References ast_channel_caller(), ast_copy_string(), ast_debug, ast_localtime(), ast_shrink_phone_number(), ast_strftime(), ast_strlen_zero(), ast_tvnow(), ast_verb, name, no_group_meta, NULL, S_COR, and time_stamp_format.

Referenced by log_events().

Variable Documentation

◆ __mod_info

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 = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_EXTENDED, .load = load_module, .unload = unload_module, .reload = reload, }
static

Definition at line 985 of file app_alarmreceiver.c.

◆ answait

int answait = 1250
static

Definition at line 184 of file app_alarmreceiver.c.

Referenced by alarmreceiver_exec(), and load_config().

◆ app

const char app[] = "AlarmReceiver"
static

Definition at line 146 of file app_alarmreceiver.c.

Referenced by load_module(), and unload_module().

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 999 of file app_alarmreceiver.c.

◆ call_start_time

struct timeval call_start_time

Definition at line 1 of file app_alarmreceiver.c.

Referenced by alarmreceiver_exec(), and receive_ademco_event().

◆ db_family

char db_family[128] = {'\0'}
static

Definition at line 190 of file app_alarmreceiver.c.

Referenced by database_increment(), and load_config().

◆ digit

char digit

Definition at line 131 of file app_alarmreceiver.c.

Referenced by __ast_pbx_run(), __ast_read(), action_atxfer(), action_cancel_atxfer(), action_playback_and_continue(), add_digit(), ademco_verify_checksum(), agent_alert(), alsa_digit(), ast_bridge_channel_feature_digit(), ast_bridge_channel_feature_digit_add(), ast_channel_end_dtmf(), ast_dsp_process(), ast_rtp_dtmf_begin(), ast_rtp_dtmf_end(), ast_rtp_dtmf_end_with_duration(), ast_rtp_instance_dtmf_begin(), ast_rtp_instance_dtmf_end(), ast_rtp_instance_dtmf_end_with_duration(), ast_senddigit(), ast_senddigit_begin(), ast_senddigit_end(), ast_senddigit_external(), ast_senddigit_mf(), ast_senddigit_mf_begin(), ast_translate_number_ka(), ast_unreal_digit_begin(), ast_unreal_digit_end(), attended_transfer_exec(), bridge_channel_feature_digit_add(), chan_pjsip_digit_begin(), chan_pjsip_digit_end(), chan_pjsip_indicate(), change_spy_mode(), channel_dtmf_begin_cb(), channel_dtmf_end_cb(), compare(), console_digit_begin(), console_digit_end(), controlplayback_exec(), dahdi_digit_begin(), dahdi_digit_end(), dial_exec_full(), dictate_exec(), digit_to_dtmfindex(), directory_exec(), do_directory(), dtmf_end_to_json(), dtmf_stream(), get_mohbydigit(), handle_incoming_request(), handle_keypad_button_message(), hfp_send_dtmf(), iax2_digit_begin(), iax2_digit_end(), info_dtmf_data_alloc(), jingle_digit_begin(), jingle_digit_end(), manager_play_dtmf(), manager_play_mf(), mbl_digit_end(), mgcp_senddigit_begin(), mgcp_senddigit_end(), moh_digit_match(), morsecode_exec(), ooh323_digit_begin(), ooh323_digit_end(), ooh323_onReceivedDigit(), play_file(), send_dtmf_begin_event(), send_dtmf_end_event(), send_dtmf_tone(), sip_senddigit_begin(), sip_senddigit_end(), skinny_senddigit_end(), store_digit(), transmit_info_with_digit(), try_calling(), unistim_do_senddigit(), unistim_senddigit_begin(), unistim_senddigit_end(), valid_exit(), and wait_for_answer().

◆ 

struct { ... } digits_mapping[]
Initial value:
= { {'0', 10}, {'1', 1} , {'2', 2}, {'3', 3}, {'4', 4}, {'5', 5},
{'6', 6}, {'7', 7}, {'8', 8}, {'9', 9}, {'*', 11}, {'#', 12},
{'A', 13}, {'B', 14}, {'C', 15} }

Referenced by ademco_verify_checksum().

◆ event_app

char event_app[128] = {'\0'}
static

Definition at line 189 of file app_alarmreceiver.c.

Referenced by alarmreceiver_exec(), and load_config().

◆ event_file

char event_file[14] = "/event-XXXXXX"
static

Definition at line 194 of file app_alarmreceiver.c.

Referenced by log_events().

◆ event_spool_dir

char event_spool_dir[128] = {'\0'}
static

Definition at line 188 of file app_alarmreceiver.c.

Referenced by load_config(), and log_events().

◆ fdtimeout

int fdtimeout = 2000
static

Definition at line 182 of file app_alarmreceiver.c.

Referenced by load_config(), and receive_dtmf_digits().

◆ log_individual_events

int log_individual_events = 0
static

Definition at line 186 of file app_alarmreceiver.c.

Referenced by alarmreceiver_exec(), load_config(), and receive_ademco_event().

◆ no_group_meta

int no_group_meta = 0
static

Definition at line 187 of file app_alarmreceiver.c.

Referenced by load_config(), write_event(), and write_metadata().

◆ sdtimeout

int sdtimeout = 200
static

Definition at line 183 of file app_alarmreceiver.c.

Referenced by load_config(), and receive_dtmf_digits().

◆ time_stamp_format

char time_stamp_format[128] = {"%a %b %d, %Y @ %H:%M:%S %Z"}
static

Definition at line 191 of file app_alarmreceiver.c.

Referenced by load_config(), and write_metadata().

◆ toneloudness

int toneloudness = 4096
static

Definition at line 185 of file app_alarmreceiver.c.

Referenced by load_config(), and send_tone_burst().

◆ weight

char weight