summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoug Bailey <dbailey@digium.com>2009-08-20 19:20:36 +0000
committerDoug Bailey <dbailey@digium.com>2009-08-20 19:20:36 +0000
commited45d6267c2ead5ca9558d720056b469342c0c6f (patch)
tree19a096454c0a1f5d92f1676800433b65571f6cea
parent73a93c720ac94f92a7877c738a584bd69b0addcf (diff)
Add a capability to send only DTMF tones over an on-hook fxs channel
git-svn-id: http://svn.asterisk.org/svn/dahdi/tools/trunk@7045 a0bf4364-ded3-4de4-8d8a-66a801d63aff
-rw-r--r--fxstest.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/fxstest.c b/fxstest.c
index 8260217..130fad5 100644
--- a/fxstest.c
+++ b/fxstest.c
@@ -117,6 +117,7 @@ int main(int argc, char *argv[])
" vmwi - toggles VMWI LED lamp\n"
" hvdc - toggles VMWI HV lamp\n"
" neon - toggles VMWI NEON lamp\n"
+ " dtmf <sequence> [<duration>]- Send a sequence of dtmf tones (\"-\" denotes no tone)\n"
" dtmfcid - create a dtmf cid spill without polarity reversal\n");
exit(1);
}
@@ -263,6 +264,38 @@ int main(int argc, char *argv[])
else
printf("Success.\n");
}
+ } else if (!strcasecmp(argv[2], "dtmf")) {
+ int duration = 50; /* default to 50 mS duration */
+ char * outstring = "";
+ int dtmftone;
+
+ if(argc < 4) { /* user supplied string */
+ fprintf(stderr, "You must specify a string of dtmf characters to send\n");
+ } else {
+ outstring = argv[3];
+ if(argc >= 5) {
+ sscanf(argv[4], "%30i", &duration);
+ }
+ printf("Going to send a set of DTMF tones >%s<\n", outstring);
+ printf("Using a duration of %d mS per tone\n", duration);
+ /* Flush any left remaining characs in the buffer and place the channel into on-hook transfer mode */
+ x = DAHDI_FLUSH_BOTH;
+ res = ioctl(fd, DAHDI_FLUSH, &x);
+ x = 500 + strlen(outstring) * duration;
+ ioctl(fd, DAHDI_ONHOOKTRANSFER, &x);
+
+ for (x = 0; '\0' != outstring[x]; x++) {
+ dtmftone = digit_to_dtmfindex(outstring[x]);
+ if (0 > dtmftone) {
+ dtmftone = -1;
+ }
+ res = tone_zone_play_tone(fd, dtmftone);
+ if (res) {
+ fprintf(stderr, "Unable to play DTMF tone %d (0x%x)\n", dtmftone, dtmftone);
+ }
+ usleep(duration * 1000);
+ }
+ }
} else if (!strcasecmp(argv[2], "dtmfcid")) {
char * outstring = "A5551212C"; /* Default string using A and C tones to bracket the number */
int dtmftone;