📄 cst_exts.c
字号:
<cmd> : remaining unparsed command string.
<cmdLen> : length of command string. This value must be
incremented by the amount of parsed characters
by this function.
<out> : this parameter can be used to display some
strings at the AT command interface.
The first char of one string must contain
the length of the following string. The
special length 0xff must be used to define
the end of the string list.
<outLen> : maximum length of output buffer referenced
by parameter <out>.
*/
GLOBAL T_ACI_RETURN rAT_EXT (
CHAR* cmd,
USHORT* cmdLen,
CHAR* out,
USHORT outLen
)
{
/*
* store command string in case it will be needed later on, when
* result code of this function is equal to AT_EXCT
*/
extCmd = cmd;
extCmdLen = *cmdLen;
/*
* example how to send an unsolicited result code via the AT interface
*/
//glowing,2004-06-17, comment
//ext_CreatePString ( extBuffer, EXT_ENTER );
//sAT_URC ( extBuffer );
/*
* example how to process the command AT%H
*/
if (*cmd == '%')
{
cmd++;
switch (*cmd)
{
case 'A':
/*
* Display AD conversions results
*/
*cmdLen -= 2;
show_adc_conversion(out);
return( AT_CMPL );
case 'C':
case 'c':
case 'D':
case 'd':
{
CHAR* nextCmd;
*cmdLen -= 2;
switch ( *cmd )
{
case 'C':
case 'c':
/* dynamic configuration via AT command interface */
nextCmd = percentCFG ( ++cmd );
break;
case 'D':
case 'd':
/* set debug pin for reset purposes */
nextCmd = percentDBG ( ++cmd );
break;
}
*out = ( CHAR ) 0xFF;
if ( nextCmd EQ NULL )
{
return ( AT_FAIL );
}
else
{
*cmdLen -= ( nextCmd - cmd );
return ( AT_CMPL );
}
}
case 'N':
/*
* Enables the AEC by sending a primitive to L1A
*/
*cmdLen -= 6;
AEC_Enable(cmd, out);
return( AT_CMPL );
case 'S':
case 's':
{
cmd++;
switch (*cmd) {
/* glowing,2004-06-17,import from M188 */
case 'N':
case 'n':
{
/* at%snum */
cmd += 4;
if (*cmd == '?' )
{
char value[20];
char str[10];
int ret;
*cmdLen -= 7;
ret = read_SerialNumber(value);
if ( ret == FALSE)
return AT_FAIL;
else
{
ext_CreatePString(out, value);
return AT_CMPL;
}
}
else
{
char str[20];
unsigned char table[8] = {0, 0, 0, 0, 0, 0, 0, 0};
int i;
for(i = 0; i < MINIMUM(*cmdLen - 6, 8); i++)
table[i] = *cmd++;
write_SerialNumber(&table[0]);
*cmdLen = 0;
return AT_CMPL;
}
}
/*glowing,2004-06-17,end of import */
case 'e':
case 'E':
/* 's''e' already detected => assume the command is at%ser. */
{
cmd += 2; /* Discard the following characters */
/* Warning! '=' has already been discarded by the ACI */
*cmdLen -= 9;
if (SER_WriteConfig (cmd, (BOOL) (*(cmd + 3) - '0')))
return( AT_CMPL );
else
return( AT_FAIL );
}
case 'w':
case 'W':
/* 's''w' already detected => assume the command is at%switch. */
{
*cmdLen -= 7;
if (SER_ImmediateSwitch())
return( AT_CMPL );
else
return( AT_FAIL );
}
case 'l':
case 'L':
/* 's''l' already detected => assume the command is at%sleep. */
{
cmd += 4; /* Discard the following characters */
/* Warning! '=' has already been discarded by the ACI */
*cmdLen -= 8;
/*
* Checks if the parameter is valid:
* 0 -> NO_SLEEP
* 1 -> SMALL_SLEEP
* 2 -> BIG_SLEEP
* 3 -> DEEP_SLEEP
* 4 -> ALL_SLEEP
*/
if (((*cmd - '0') >= 0) && ((*cmd - '0') <= 4))
{
power_down_config ((UBYTE) (*cmd - '0'), UWIRE_CLK_CUT);
return( AT_CMPL );
}
else
return( AT_FAIL );
}
default:
*cmdLen -= 2;
return ( AT_FAIL );
}
}
case 'H':
cmd++;
switch (*cmd)
{
case '0':
{
T_AUDIO_MODE_LOAD audio_mode_load_parameter;
T_RV_RETURN return_path;
return_path.callback_func = nothing;
strcpy(audio_mode_load_parameter.audio_mode_filename,"tty_q90");
audio_mode_load(&audio_mode_load_parameter, return_path);
}
break;
case '1':
{
T_AUDIO_MODE_SAVE audio_mode_save_parameter;
T_RV_RETURN return_path;
return_path.callback_func = nothing;
strcpy(audio_mode_save_parameter.audio_mode_filename,"saved");
audio_mode_save(&audio_mode_save_parameter, return_path);
}
break;
}
#if 0
*cmdLen -= 2;
/*
* here you can perform some actions with drivers etc.
*/
/*
* and create some additional output at the AT interface
* The strings:
*"Hello"
*""
*"World"
* will be displayed at the terminal.
*
* first string Hello
*/
out[0] = strlen ("Hello");
memcpy (&out[1], "Hello", 5);
/*
* add a spare line with an empty string
*/
out [6] = 0;
/*
* second string World
*/
out [7] = strlen ("World");
memcpy (&out[8], "World", 5);
/*
* end of string list
*/
out [13] = (CHAR) 0xff;
#endif
return( AT_CMPL );
#ifndef WIN32
case 'R':
case 'r':
*cmdLen -= 2;
l1dmacro_init_hw();
out[0] = 0;
out[1] = (CHAR) 0xFF;
return( AT_CMPL );
#endif
#ifndef WIN32
case 'V':
case 'v':
*cmdLen -= 2;
/*
* Display version numbers
*/
cmh_show_version (cmd, cmdLen, out);
return( AT_CMPL );
#endif
#if defined (ALR)
/*glowing,2004-06-17,import from M188 */
case 'T':
case 't':
{
/*
* Enables RTC or AUDIO tests
*/
cmd++;
switch (*cmd)
{
case 'N':
case 'n':
{
/* at%tnum */
cmd += 4;
if (*cmd == '?' )
{
short value;
char str[10];
int ret;
*cmdLen -= 7;
ret = read_TestNumber(&value);
if ( ret < 0 )
return AT_FAIL;
else
{
sprintf(str, "%d", value);
ext_CreatePString(out, str);
return AT_CMPL;
}
}
else
{
char str[20];
unsigned short value;
value = atoi(cmd);
write_TestNumber(value);
*cmdLen = 0;
return AT_CMPL;
}
}
break;
/*glowing,2004-06-17,end of import */
default:
{
*cmdLen -= 3;
if (!strncmp(cmd, "A", 1) || !strncmp(cmd, "a", 1))
{
//audio_test_misc();
out[0] = 22;
memcpy (&out[1], "Performing Audio Tests", 22);
out [23] = (CHAR) 0xff;
}
else
{
if (!strncmp(cmd, "R", 1) || !strncmp(cmd, "r", 1))
{
//rtc_test_misc();
out[0] = 20;
memcpy (&out[1], "Performing RTC Tests", 20);
out [21] = (CHAR) 0xff;
}
else
return( AT_FAIL );
}
return( AT_CMPL );
}
}
}
#endif
default:
*cmdLen -= 2;
return ( AT_FAIL );
}
}
else if ( *cmd EQ 'D' )
{
T_ACI_RETURN rslt;
/*
* this is only a test implementation. As soon as a "ATD" command
* string is detected in the AT interpreter and the mobile is not
* yet registered (neither limited nor full service is availbale)
* this function is called. Then instead of dialling immediately
* an activation of the mobile is performed in advance.
*/
strncpy ( extDialNum, cmd + 1, MINIMUM ( MAX_PHB_NUM_LEN - 1,
*cmdLen - 1 ) );
extDialNum[MINIMUM ( MAX_PHB_NUM_LEN - 1, *cmdLen - 1 )] = '\0';
extCmdLen = 0;
*cmdLen = 0;
rslt = sAT_PlusCFUN ( CMD_SRC_LCL,
CFUN_FUN_Full,
CFUN_RST_NotPresent );
if ( rslt EQ AT_EXCT )
{
/*
* generate some output at the AT interface
*/
ext_CreatePString ( out, EXT_ATCFUN );
/*
* indicating that an extended AT command is still in progress
*/
currExtCmd = AT_CMD_CFUN;
}
else
{
ext_LeaveEXT ( TRUE );
rCI_PlusCME ( AT_CMD_EXT, CME_ERR_Unknown );
}
return ( rslt );
}
else /* Robert.Chen extended this branch, 2004-06-07 */
{
return(rAT_EXT_MI(cmd, cmdLen, out, outLen));
}
/*
return( AT_FAIL );
*/
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147) MODULE : CST_EXTS |
| STATE : code ROUTINE : percentCFG |
+--------------------------------------------------------------------+
PURPOSE : %CFG command (enables dynamic configuration of the
protocol stack using the AT command interface)
*/
EXTERN char *parse (char *b, char *f, ...);
GLOBAL SHORT cc_pei_config (char * inString,
char * outString);
GLOBAL SHORT cst_pei_config (char * inString,
char * outString);
GLOBAL SHORT dl_pei_config (char * inString,
char * outString);
GLOBAL SHORT mm_pei_config (char * inString,
char * outString);
GLOBAL SHORT rr_pei_config (char * inString,
char * outString);
GLOBAL SHORT sim_pei_config (char * inString,
char * outString);
GLOBAL SHORT sms_pei_config (char * inString,
char * outString);
GLOBAL SHORT ss_pei_config (char * inString,
char * outString);
GLOBAL SHORT pl_pei_config (char * inString,
char * outString);
#ifdef FAX_AND_DATA
GLOBAL SHORT fad_pei_config (char * inString,
char * outString);
GLOBAL SHORT l2r_pei_config (char * inString,
char * outString);
GLOBAL SHORT ra_pei_config (char * inString,
char * outString);
GLOBAL SHORT rlp_pei_config (char * inString,
char * outString);
GLOBAL SHORT t30_pei_config (char * inString,
char * outString);
#endif
GLOBAL CHAR* percentCFG ( CHAR* cl )
{
CHAR entity[5];
CHAR config[40];
CHAR dummy;
TRACE_FUNCTION ( "percentCFG()" );
switch ( *cl )
{
case('='):
{
cl++;
cl = parse ( cl, "ss", ( LONG )sizeof(entity), entity,
( LONG )sizeof(config), config );
if( !cl OR
*entity EQ '\0' OR
*config EQ '\0' )
{
return ( NULL );
}
break;
}
default:
{
return ( NULL );
}
}
if ( strcmp ( entity, CC_NAME ) EQ 0 )
{
cc_pei_config ( config, &dummy );
}
else if ( strcmp ( entity, CST_NAME ) EQ 0 )
{
cst_pei_config ( config, &dummy );
}
else if ( strcmp ( entity, DL_NAME ) EQ 0 )
{
dl_pei_config ( config, &dummy );
}
else if ( strcmp ( entity, MM_NAME ) EQ 0 )
{
mm_pei_config ( config, &dummy );
}
else if ( strcmp ( entity, RR_NAME ) EQ 0 )
{
rr_pei_config ( config, &dummy );
}
else if ( strcmp ( entity, SIM_NAME ) EQ 0 )
{
sim_pei_config ( config, &dummy );
}
else if ( strcmp ( entity, SMS_NAME ) EQ 0 )
{
sms_pei_config ( config, &dummy );
}
else if ( strcmp ( entity, SS_NAME ) EQ 0 )
{
ss_pei_config ( config, &dummy );
}
else if ( strcmp ( entity, PL_NAME ) EQ 0 )
{
pl_pei_config ( config, &dummy );
}
#ifdef FAX_AND_DATA
else if ( strcmp ( entity, FAD_NAME ) EQ 0 )
{
fad_pei_config ( config, &dummy );
}
else if ( strcmp ( entity, L2R_NAME ) EQ 0 )
{
l2r_pei_config ( config, &dummy );
}
else if ( strcmp ( entity, RA_NAME ) EQ 0 )
{
ra_pei_config ( config, &dummy );
}
else if ( strcmp ( entity, RLP_NAME ) EQ 0 )
{
rlp_pei_config ( config, &dummy );
}
else if ( strcmp ( entity, T30_NAME ) EQ 0 )
{
t30_pei_config ( config, &dummy );
}
#endif
else
{
return ( NULL );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -