124 noise +=
abs(foo[x]);
145 ast_debug(1,
"%s: Noise: %d, samples: %d, avg: %d\n", who, noise, samples, noise / samples);
146 return (noise / samples);
163 const char *testid=data;
182 ast_debug(1,
"Transmit client version\n");
190 ast_debug(1,
"server version: %s\n", serverver);
202 ast_debug(1,
"send test identifier: %s\n", testid);
209 if ((f = fopen(fn,
"w+"))) {
212 fprintf(f,
"CLIENTTEST ID: %s\n", testid);
213 fprintf(f,
"ANSWER: PASS\n");
218 ast_debug(1,
"TestClient: 2. Wait DTMF 1\n");
220 fprintf(f,
"WAIT DTMF 1: %s\n", (res !=
'1') ?
"FAIL" :
"PASS");
231 ast_debug(1,
"TestClient: 2. Send DTMF 2\n");
233 fprintf(f,
"SEND DTMF 2: %s\n", (res < 0) ?
"FAIL" :
"PASS");
239 ast_debug(1,
"TestClient: 3. Wait one second\n");
241 fprintf(f,
"WAIT 1 SEC: %s\n", (res < 0) ?
"FAIL" :
"PASS");
247 ast_debug(1,
"TestClient: 4. Measure noise\n");
249 fprintf(f,
"MEASURENOISE: %s (%d)\n", (res < 0) ?
"FAIL" :
"PASS", res);
255 ast_debug(1,
"TestClient: 5. Wait DTMF 4\n");
257 fprintf(f,
"WAIT DTMF 4: %s\n", (res !=
'4') ?
"FAIL" :
"PASS");
265 ast_debug(1,
"TestClient: 6. Transmit tone\n");
267 fprintf(f,
"SENDTONE: %s\n", (res < 0) ?
"FAIL" :
"PASS");
269 if (!res || (res ==
'5')) {
271 ast_debug(1,
"TestClient: 7. Wait DTMF 5\n");
274 fprintf(f,
"WAIT DTMF 5: %s\n", (res !=
'5') ?
"FAIL" :
"PASS");
282 ast_debug(1,
"TestClient: 8. Wait one second\n");
284 fprintf(f,
"WAIT 1 SEC: %s\n", (res < 0) ?
"FAIL" :
"PASS");
290 ast_debug(1,
"TestClient: 9. Measure tone\n");
292 fprintf(f,
"MEASURETONE: %s (%d)\n", (res < 0) ?
"FAIL" :
"PASS", res);
298 ast_debug(1,
"TestClient: 10. Send DTMF 7\n");
300 fprintf(f,
"SEND DTMF 7: %s\n", (res < 0) ?
"FAIL" :
"PASS");
306 ast_debug(1,
"TestClient: 11. Wait DTMF 8\n");
308 fprintf(f,
"WAIT DTMF 8: %s\n", (res !=
'8') ?
"FAIL" :
"PASS");
319 ast_debug(1,
"TestClient: 12. Hangup\n");
323 fprintf(f,
"-- END TEST--\n");
349 ast_debug(1,
"client version: %s\n", testid);
350 ast_debug(1,
"Transmit server version\n");
360 ast_debug(1,
"read test identifier: %s\n", testid);
362 if (strchr(testid,
'/'))
372 if ((f = fopen(fn,
"w+"))) {
375 fprintf(f,
"SERVERTEST ID: %s\n", testid);
376 fprintf(f,
"ANSWER: PASS\n");
377 ast_debug(1,
"Processing Test ID '%s'\n", testid);
381 ast_debug(1,
"TestServer: 1. Send DTMF 1\n");
383 fprintf(f,
"SEND DTMF 1: %s\n", (res < 0) ?
"FAIL" :
"PASS");
389 ast_debug(1,
"TestServer: 2. Wait DTMF 2\n");
391 fprintf(f,
"WAIT DTMF 2: %s\n", (res !=
'2') ?
"FAIL" :
"PASS");
399 ast_debug(1,
"TestServer: 3. Measure noise\n");
401 fprintf(f,
"MEASURENOISE: %s (%d)\n", (res < 0) ?
"FAIL" :
"PASS", res);
407 ast_debug(1,
"TestServer: 4. Send DTMF 4\n");
409 fprintf(f,
"SEND DTMF 4: %s\n", (res < 0) ?
"FAIL" :
"PASS");
415 ast_debug(1,
"TestServer: 5. Wait one second\n");
417 fprintf(f,
"WAIT 1 SEC: %s\n", (res < 0) ?
"FAIL" :
"PASS");
423 ast_debug(1,
"TestServer: 6. Measure tone\n");
425 fprintf(f,
"MEASURETONE: %s (%d)\n", (res < 0) ?
"FAIL" :
"PASS", res);
431 ast_debug(1,
"TestServer: 7. Send DTMF 5\n");
433 fprintf(f,
"SEND DTMF 5: %s\n", (res < 0) ?
"FAIL" :
"PASS");
439 ast_debug(1,
"TestServer: 8. Transmit tone\n");
441 fprintf(f,
"SENDTONE: %s\n", (res < 0) ?
"FAIL" :
"PASS");
444 if (!res || (res ==
'7')) {
446 ast_debug(1,
"TestServer: 9. Wait DTMF 7\n");
449 fprintf(f,
"WAIT DTMF 7: %s\n", (res !=
'7') ?
"FAIL" :
"PASS");
460 ast_debug(1,
"TestServer: 10. Send DTMF 8\n");
462 fprintf(f,
"SEND DTMF 8: %s\n", (res < 0) ?
"FAIL" :
"PASS");
468 ast_debug(1,
"TestServer: 11. Waiting for hangup\n");
470 fprintf(f,
"WAIT HANGUP: %s\n", (res < 0) ?
"PASS" :
"FAIL");
474 fprintf(f,
"-- END TEST--\n");
static int testserver_exec(struct ast_channel *chan, const char *data)
AST_MODULE_INFO_STANDARD_EXTENDED(ASTERISK_GPL_KEY, "Interface Test Application")
static int sendnoise(struct ast_channel *chan, int ms)
static int measurenoise(struct ast_channel *chan, int ms, char *who)
static int load_module(void)
static int testclient_exec(struct ast_channel *chan, const char *data)
static int unload_module(void)
Asterisk main include file. File version handling, generic pbx functions.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
General Asterisk PBX channel definitions.
int ast_waitfordigit(struct ast_channel *c, int ms)
Waits for a digit.
const char * ast_channel_name(const struct ast_channel *chan)
int ast_tonepair_start(struct ast_channel *chan, int freq1, int freq2, int duration, int vol)
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
Sets read format on channel chan.
int ast_answer(struct ast_channel *chan)
Answer a channel.
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups.
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
void ast_tonepair_stop(struct ast_channel *chan)
ast_channel_state
ast_channel states
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
enum ast_getdata_result 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_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.
#define ast_debug(level,...)
Log a DEBUG message.
Asterisk locking-related definitions:
Asterisk module definitions.
#define ASTERISK_GPL_KEY
The text the key() function should return.
int ast_unregister_application(const char *app)
Unregister an application.
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Asterisk file paths, configured in asterisk.conf.
const char * ast_config_AST_LOG_DIR
Core PBX routines and definitions.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Main Channel structure associated with a channel.
struct ast_format * format
Data structure associated with a single frame of data.
union ast_frame::@228 data
struct ast_frame_subclass subclass
enum ast_frame_type frametype
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
int ast_mkdir(const char *path, int mode)
Recursively create directory path.