118 noise +=
abs(foo[x]);
139 ast_debug(1,
"%s: Noise: %d, samples: %d, avg: %d\n", who, noise, samples, noise / samples);
140 return (noise / samples);
157 const char *testid=data;
176 ast_debug(1,
"Transmit client version\n");
184 ast_debug(1,
"server version: %s\n", serverver);
196 ast_debug(1,
"send test identifier: %s\n", testid);
203 if ((f = fopen(fn,
"w+"))) {
206 fprintf(f,
"CLIENTTEST ID: %s\n", testid);
207 fprintf(f,
"ANSWER: PASS\n");
212 ast_debug(1,
"TestClient: 2. Wait DTMF 1\n");
214 fprintf(f,
"WAIT DTMF 1: %s\n", (res !=
'1') ?
"FAIL" :
"PASS");
225 ast_debug(1,
"TestClient: 2. Send DTMF 2\n");
227 fprintf(f,
"SEND DTMF 2: %s\n", (res < 0) ?
"FAIL" :
"PASS");
233 ast_debug(1,
"TestClient: 3. Wait one second\n");
235 fprintf(f,
"WAIT 1 SEC: %s\n", (res < 0) ?
"FAIL" :
"PASS");
241 ast_debug(1,
"TestClient: 4. Measure noise\n");
243 fprintf(f,
"MEASURENOISE: %s (%d)\n", (res < 0) ?
"FAIL" :
"PASS", res);
249 ast_debug(1,
"TestClient: 5. Wait DTMF 4\n");
251 fprintf(f,
"WAIT DTMF 4: %s\n", (res !=
'4') ?
"FAIL" :
"PASS");
259 ast_debug(1,
"TestClient: 6. Transmit tone\n");
261 fprintf(f,
"SENDTONE: %s\n", (res < 0) ?
"FAIL" :
"PASS");
263 if (!res || (res ==
'5')) {
265 ast_debug(1,
"TestClient: 7. Wait DTMF 5\n");
268 fprintf(f,
"WAIT DTMF 5: %s\n", (res !=
'5') ?
"FAIL" :
"PASS");
276 ast_debug(1,
"TestClient: 8. Wait one second\n");
278 fprintf(f,
"WAIT 1 SEC: %s\n", (res < 0) ?
"FAIL" :
"PASS");
284 ast_debug(1,
"TestClient: 9. Measure tone\n");
286 fprintf(f,
"MEASURETONE: %s (%d)\n", (res < 0) ?
"FAIL" :
"PASS", res);
292 ast_debug(1,
"TestClient: 10. Send DTMF 7\n");
294 fprintf(f,
"SEND DTMF 7: %s\n", (res < 0) ?
"FAIL" :
"PASS");
300 ast_debug(1,
"TestClient: 11. Wait DTMF 8\n");
302 fprintf(f,
"WAIT DTMF 8: %s\n", (res !=
'8') ?
"FAIL" :
"PASS");
313 ast_debug(1,
"TestClient: 12. Hangup\n");
317 fprintf(f,
"-- END TEST--\n");
343 ast_debug(1,
"client version: %s\n", testid);
344 ast_debug(1,
"Transmit server version\n");
354 ast_debug(1,
"read test identifier: %s\n", testid);
356 if (strchr(testid,
'/'))
366 if ((f = fopen(fn,
"w+"))) {
369 fprintf(f,
"SERVERTEST ID: %s\n", testid);
370 fprintf(f,
"ANSWER: PASS\n");
371 ast_debug(1,
"Processing Test ID '%s'\n", testid);
375 ast_debug(1,
"TestServer: 1. Send DTMF 1\n");
377 fprintf(f,
"SEND DTMF 1: %s\n", (res < 0) ?
"FAIL" :
"PASS");
383 ast_debug(1,
"TestServer: 2. Wait DTMF 2\n");
385 fprintf(f,
"WAIT DTMF 2: %s\n", (res !=
'2') ?
"FAIL" :
"PASS");
393 ast_debug(1,
"TestServer: 3. Measure noise\n");
395 fprintf(f,
"MEASURENOISE: %s (%d)\n", (res < 0) ?
"FAIL" :
"PASS", res);
401 ast_debug(1,
"TestServer: 4. Send DTMF 4\n");
403 fprintf(f,
"SEND DTMF 4: %s\n", (res < 0) ?
"FAIL" :
"PASS");
409 ast_debug(1,
"TestServer: 5. Wait one second\n");
411 fprintf(f,
"WAIT 1 SEC: %s\n", (res < 0) ?
"FAIL" :
"PASS");
417 ast_debug(1,
"TestServer: 6. Measure tone\n");
419 fprintf(f,
"MEASURETONE: %s (%d)\n", (res < 0) ?
"FAIL" :
"PASS", res);
425 ast_debug(1,
"TestServer: 7. Send DTMF 5\n");
427 fprintf(f,
"SEND DTMF 5: %s\n", (res < 0) ?
"FAIL" :
"PASS");
433 ast_debug(1,
"TestServer: 8. Transmit tone\n");
435 fprintf(f,
"SENDTONE: %s\n", (res < 0) ?
"FAIL" :
"PASS");
438 if (!res || (res ==
'7')) {
440 ast_debug(1,
"TestServer: 9. Wait DTMF 7\n");
443 fprintf(f,
"WAIT DTMF 7: %s\n", (res !=
'7') ?
"FAIL" :
"PASS");
454 ast_debug(1,
"TestServer: 10. Send DTMF 8\n");
456 fprintf(f,
"SEND DTMF 8: %s\n", (res < 0) ?
"FAIL" :
"PASS");
462 ast_debug(1,
"TestServer: 11. Waiting for hangup\n");
464 fprintf(f,
"WAIT HANGUP: %s\n", (res < 0) ?
"PASS" :
"FAIL");
468 fprintf(f,
"-- END TEST--\n");
int ast_dtmf_stream(struct ast_channel *chan, struct ast_channel *peer, const char *digits, int between, unsigned int duration)
Send a string of DTMF digits to a channel.
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups.
Main Channel structure associated with a channel.
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
static int testclient_exec(struct ast_channel *chan, const char *data)
ast_channel_state
ast_channel states
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
int ast_unregister_application(const char *app)
Unregister an application.
struct ast_frame_subclass subclass
#define ast_strlen_zero(foo)
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
#define ast_debug(level,...)
Log a DEBUG message.
General Asterisk PBX channel definitions.
Asterisk file paths, configured in asterisk.conf.
int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
Sets read format on channel chan.
#define ao2_ref(o, delta)
Core PBX routines and definitions.
static int testserver_exec(struct ast_channel *chan, const char *data)
const char * ast_config_AST_LOG_DIR
static int load_module(void)
int ast_app_getdata(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout)
Plays a stream and gets DTMF data from a channel.
int ast_waitfordigit(struct ast_channel *c, int ms)
Waits for a digit.
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
void ast_tonepair_stop(struct ast_channel *chan)
const char * ast_channel_name(const struct ast_channel *chan)
int ast_answer(struct ast_channel *chan)
Answer a channel.
Data structure associated with a single frame of data.
static int measurenoise(struct ast_channel *chan, int ms, char *who)
AST_MODULE_INFO_STANDARD_EXTENDED(ASTERISK_GPL_KEY, "Interface Test Application")
int ast_tonepair_start(struct ast_channel *chan, int freq1, int freq2, int duration, int vol)
union ast_frame::@263 data
enum ast_frame_type frametype
struct ast_format * format
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
static int unload_module(void)
static int sendnoise(struct ast_channel *chan, int ms)
int ast_mkdir(const char *path, int mode)
Recursively create directory path.