Get ADSI CPE ID. More...
#include "asterisk.h"
#include "asterisk/lock.h"
#include "asterisk/file.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/adsi.h"
Go to the source code of this file.
Functions | |
AST_MODULE_INFO (ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT,"Get ADSI CPE ID",.load=load_module,.unload=unload_module,.nonoptreq="res_adsi",) | |
static int | cpeid_exec (struct ast_channel *chan, const char *idata) |
static int | cpeid_setstatus (struct ast_channel *chan, char *stuff[], int voice) |
static int | load_module (void) |
static int | unload_module (void) |
Variables | |
static char * | app = "GetCPEID" |
Get ADSI CPE ID.
Definition in file app_getcpeid.c.
AST_MODULE_INFO | ( | ASTERISK_GPL_KEY | , | |
AST_MODFLAG_DEFAULT | , | |||
"Get ADSI CPE ID" | , | |||
. | load = load_module , |
|||
. | unload = unload_module , |
|||
. | nonoptreq = "res_adsi" | |||
) |
static int cpeid_exec | ( | struct ast_channel * | chan, | |
const char * | idata | |||
) | [static] |
Definition at line 68 of file app_getcpeid.c.
References ast_adsi_get_cpeid(), ast_adsi_get_cpeinfo(), ast_adsi_load_session(), ast_adsi_unload_session(), ast_alloca, ast_verb, ast_waitfordigit(), and cpeid_setstatus().
Referenced by load_module().
00069 { 00070 int res=0; 00071 unsigned char cpeid[4]; 00072 int gotgeometry = 0; 00073 int gotcpeid = 0; 00074 int width, height, buttons; 00075 char *data[4]; 00076 unsigned int x; 00077 00078 for (x = 0; x < 4; x++) 00079 data[x] = ast_alloca(80); 00080 00081 strcpy(data[0], "** CPE Info **"); 00082 strcpy(data[1], "Identifying CPE..."); 00083 strcpy(data[2], "Please wait..."); 00084 res = ast_adsi_load_session(chan, NULL, 0, 1); 00085 if (res > 0) { 00086 cpeid_setstatus(chan, data, 0); 00087 res = ast_adsi_get_cpeid(chan, cpeid, 0); 00088 if (res > 0) { 00089 gotcpeid = 1; 00090 ast_verb(3, "Got CPEID of '%02x:%02x:%02x:%02x' on '%s'\n", cpeid[0], cpeid[1], cpeid[2], cpeid[3], chan->name); 00091 } 00092 if (res > -1) { 00093 strcpy(data[1], "Measuring CPE..."); 00094 strcpy(data[2], "Please wait..."); 00095 cpeid_setstatus(chan, data, 0); 00096 res = ast_adsi_get_cpeinfo(chan, &width, &height, &buttons, 0); 00097 if (res > -1) { 00098 ast_verb(3, "CPE has %d lines, %d columns, and %d buttons on '%s'\n", height, width, buttons, chan->name); 00099 gotgeometry = 1; 00100 } 00101 } 00102 if (res > -1) { 00103 if (gotcpeid) 00104 snprintf(data[1], 80, "CPEID: %02x:%02x:%02x:%02x", cpeid[0], cpeid[1], cpeid[2], cpeid[3]); 00105 else 00106 strcpy(data[1], "CPEID Unknown"); 00107 if (gotgeometry) 00108 snprintf(data[2], 80, "Geom: %dx%d, %d buttons", width, height, buttons); 00109 else 00110 strcpy(data[2], "Geometry unknown"); 00111 strcpy(data[3], "Press # to exit"); 00112 cpeid_setstatus(chan, data, 1); 00113 for(;;) { 00114 res = ast_waitfordigit(chan, 1000); 00115 if (res < 0) 00116 break; 00117 if (res == '#') { 00118 res = 0; 00119 break; 00120 } 00121 } 00122 ast_adsi_unload_session(chan); 00123 } 00124 } 00125 00126 return res; 00127 }
static int cpeid_setstatus | ( | struct ast_channel * | chan, | |
char * | stuff[], | |||
int | voice | |||
) | [static] |
Definition at line 57 of file app_getcpeid.c.
References ADSI_JUST_CENT, ADSI_JUST_LEFT, ast_adsi_print(), and justify.
Referenced by cpeid_exec().
00058 { 00059 int justify[5] = { ADSI_JUST_CENT, ADSI_JUST_LEFT, ADSI_JUST_LEFT, ADSI_JUST_LEFT }; 00060 char *tmp[5]; 00061 int x; 00062 for (x=0;x<4;x++) 00063 tmp[x] = stuff[x]; 00064 tmp[4] = NULL; 00065 return ast_adsi_print(chan, tmp, justify, voice); 00066 }
static int load_module | ( | void | ) | [static] |
Definition at line 134 of file app_getcpeid.c.
References ast_register_application_xml, and cpeid_exec().
00135 { 00136 return ast_register_application_xml(app, cpeid_exec); 00137 }
static int unload_module | ( | void | ) | [static] |
Definition at line 129 of file app_getcpeid.c.
References ast_unregister_application().
00130 { 00131 return ast_unregister_application(app); 00132 }
char* app = "GetCPEID" [static] |
Definition at line 55 of file app_getcpeid.c.