116 noise += abs(foo[x]);
135 ast_debug(1,
"%s: Noise: %d, samples: %d, avg: %d\n", who, noise, samples, noise / samples);
136 return (noise / samples);
153 const char *testid=
data;
172 ast_debug(1,
"Transmit client version\n");
177 res =
ast_app_getdata(chan, NULL, serverver,
sizeof(serverver) - 1, 0);
180 ast_debug(1,
"server version: %s\n", serverver);
192 ast_debug(1,
"send test identifier: %s\n", testid);
199 if ((f = fopen(fn,
"w+"))) {
201 fprintf(f,
"CLIENTCHAN: %s\n", chan->
name);
202 fprintf(f,
"CLIENTTEST ID: %s\n", testid);
203 fprintf(f,
"ANSWER: PASS\n");
208 ast_debug(1,
"TestClient: 2. Wait DTMF 1\n");
210 fprintf(f,
"WAIT DTMF 1: %s\n", (res !=
'1') ?
"FAIL" :
"PASS");
221 ast_debug(1,
"TestClient: 2. Send DTMF 2\n");
223 fprintf(f,
"SEND DTMF 2: %s\n", (res < 0) ?
"FAIL" :
"PASS");
229 ast_debug(1,
"TestClient: 3. Wait one second\n");
231 fprintf(f,
"WAIT 1 SEC: %s\n", (res < 0) ?
"FAIL" :
"PASS");
237 ast_debug(1,
"TestClient: 4. Measure noise\n");
239 fprintf(f,
"MEASURENOISE: %s (%d)\n", (res < 0) ?
"FAIL" :
"PASS", res);
245 ast_debug(1,
"TestClient: 5. Wait DTMF 4\n");
247 fprintf(f,
"WAIT DTMF 4: %s\n", (res !=
'4') ?
"FAIL" :
"PASS");
255 ast_debug(1,
"TestClient: 6. Transmit tone\n");
257 fprintf(f,
"SENDTONE: %s\n", (res < 0) ?
"FAIL" :
"PASS");
259 if (!res || (res ==
'5')) {
261 ast_debug(1,
"TestClient: 7. Wait DTMF 5\n");
264 fprintf(f,
"WAIT DTMF 5: %s\n", (res !=
'5') ?
"FAIL" :
"PASS");
272 ast_debug(1,
"TestClient: 8. Wait one second\n");
274 fprintf(f,
"WAIT 1 SEC: %s\n", (res < 0) ?
"FAIL" :
"PASS");
280 ast_debug(1,
"TestClient: 9. Measure tone\n");
282 fprintf(f,
"MEASURETONE: %s (%d)\n", (res < 0) ?
"FAIL" :
"PASS", res);
288 ast_debug(1,
"TestClient: 10. Send DTMF 7\n");
290 fprintf(f,
"SEND DTMF 7: %s\n", (res < 0) ?
"FAIL" :
"PASS");
296 ast_debug(1,
"TestClient: 11. Wait DTMF 8\n");
298 fprintf(f,
"WAIT DTMF 8: %s\n", (res !=
'8') ?
"FAIL" :
"PASS");
309 ast_debug(1,
"TestClient: 12. Hangup\n");
313 fprintf(f,
"-- END TEST--\n");
340 ast_debug(1,
"client version: %s\n", testid);
341 ast_debug(1,
"Transmit server version\n");
351 ast_debug(1,
"read test identifier: %s\n", testid);
353 if (strchr(testid,
'/'))
361 if ((f = fopen(fn,
"w+"))) {
363 fprintf(f,
"SERVERCHAN: %s\n", chan->
name);
364 fprintf(f,
"SERVERTEST ID: %s\n", testid);
365 fprintf(f,
"ANSWER: PASS\n");
366 ast_debug(1,
"Processing Test ID '%s'\n", testid);
370 ast_debug(1,
"TestServer: 1. Send DTMF 1\n");
372 fprintf(f,
"SEND DTMF 1: %s\n", (res < 0) ?
"FAIL" :
"PASS");
378 ast_debug(1,
"TestServer: 2. Wait DTMF 2\n");
380 fprintf(f,
"WAIT DTMF 2: %s\n", (res !=
'2') ?
"FAIL" :
"PASS");
388 ast_debug(1,
"TestServer: 3. Measure noise\n");
390 fprintf(f,
"MEASURENOISE: %s (%d)\n", (res < 0) ?
"FAIL" :
"PASS", res);
396 ast_debug(1,
"TestServer: 4. Send DTMF 4\n");
398 fprintf(f,
"SEND DTMF 4: %s\n", (res < 0) ?
"FAIL" :
"PASS");
404 ast_debug(1,
"TestServer: 5. Wait one second\n");
406 fprintf(f,
"WAIT 1 SEC: %s\n", (res < 0) ?
"FAIL" :
"PASS");
412 ast_debug(1,
"TestServer: 6. Measure tone\n");
414 fprintf(f,
"MEASURETONE: %s (%d)\n", (res < 0) ?
"FAIL" :
"PASS", res);
420 ast_debug(1,
"TestServer: 7. Send DTMF 5\n");
422 fprintf(f,
"SEND DTMF 5: %s\n", (res < 0) ?
"FAIL" :
"PASS");
428 ast_debug(1,
"TestServer: 8. Transmit tone\n");
430 fprintf(f,
"SENDTONE: %s\n", (res < 0) ?
"FAIL" :
"PASS");
433 if (!res || (res ==
'7')) {
435 ast_debug(1,
"TestServer: 9. Wait DTMF 7\n");
438 fprintf(f,
"WAIT DTMF 7: %s\n", (res !=
'7') ?
"FAIL" :
"PASS");
449 ast_debug(1,
"TestServer: 10. Send DTMF 8\n");
451 fprintf(f,
"SEND DTMF 8: %s\n", (res < 0) ?
"FAIL" :
"PASS");
457 ast_debug(1,
"TestServer: 11. Waiting for hangup\n");
459 fprintf(f,
"WAIT HANGUP: %s\n", (res < 0) ?
"PASS" :
"FAIL");
463 fprintf(f,
"-- END TEST--\n");
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups.
union ast_frame_subclass subclass
Main Channel structure associated with a channel.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
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.
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
static int testclient_exec(struct ast_channel *chan, const char *data)
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.
int ast_set_read_format(struct ast_channel *chan, format_t format)
Sets read format on channel chan Set read format for channel to whichever component of "format" is be...
#define ast_debug(level,...)
Log a DEBUG message.
General Asterisk PBX channel definitions.
Asterisk file paths, configured in asterisk.conf.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Core PBX routines and definitions.
static int testserver_exec(struct ast_channel *chan, const char *data)
enum ast_channel_state _state
const ast_string_field name
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
const char * ast_config_AST_LOG_DIR
static int load_module(void)
int ast_waitfordigit(struct ast_channel *c, int ms)
Waits for a digit.
#define AST_FORMAT_SLINEAR
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
void ast_tonepair_stop(struct ast_channel *chan)
int ast_answer(struct ast_channel *chan)
Answer a channel.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
Data structure associated with a single frame of data.
static int measurenoise(struct ast_channel *chan, int ms, char *who)
int ast_tonepair_start(struct ast_channel *chan, int freq1, int freq2, int duration, int vol)
enum ast_frame_type frametype
int ast_dtmf_stream(struct ast_channel *chan, struct ast_channel *peer, const char *digits, int between, unsigned int duration)
Send DTMF to a channel.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
union ast_frame::@172 data
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
static int unload_module(void)
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
static int sendnoise(struct ast_channel *chan, int ms)
int ast_mkdir(const char *path, int mode)
Recursively create directory path.