51 /* |
51 /* |
52 * Note1: This file uses AT command parsing based on heuristics. |
52 * Note1: This file uses AT command parsing based on heuristics. |
53 * Refer to test specification if planning to change the heuristic. |
53 * Refer to test specification if planning to change the heuristic. |
54 * Note2: Input buffer management (ExtractLineFromInputBuffer()) can be tested |
54 * Note2: Input buffer management (ExtractLineFromInputBuffer()) can be tested |
55 * with non-line based terminals such as HyperTerminal or Realterm. |
55 * with non-line based terminals such as HyperTerminal or Realterm. |
|
56 * Note3: If there is a need to handle commands with random data, the extended |
|
57 * command checking can interfere with the character set of this random data. |
|
58 * Best way to handle this random data is to create a handler for these commands |
|
59 * which skips the valid "not to be parsed" data or use quotes. For these cases |
|
60 * the CDunAtSpecialCmdHandler could be extended. |
56 */ |
61 */ |
57 |
62 |
58 #include "DunAtCmdHandler.h" |
63 #include "DunAtCmdHandler.h" |
59 #include "DunAtUrcHandler.h" |
64 #include "DunAtUrcHandler.h" |
60 #include "DunDownstream.h" |
65 #include "DunDownstream.h" |
1160 if ( !aPeek ) |
1165 if ( !aPeek ) |
1161 { |
1166 { |
1162 iDecodeInfo.iCmdsHandled++; |
1167 iDecodeInfo.iCmdsHandled++; |
1163 FTRACE(FPrint( _L("CDunAtCmdHandler::ExtractNextSubCommand() (handled=%d)"), iDecodeInfo.iCmdsHandled )); |
1168 FTRACE(FPrint( _L("CDunAtCmdHandler::ExtractNextSubCommand() (handled=%d)"), iDecodeInfo.iCmdsHandled )); |
1164 } |
1169 } |
|
1170 FTRACE(FPrint( _L("CDunAtCmdPusher::ExtractNextSubCommand() extracted:") )); |
|
1171 FTRACE(FPrintRaw(iParseInfo.iSendBuffer) ); |
1165 FTRACE(FPrint( _L("CDunAtCmdHandler::ExtractNextSubCommand() complete") )); |
1172 FTRACE(FPrint( _L("CDunAtCmdHandler::ExtractNextSubCommand() complete") )); |
1166 return ETrue; |
1173 return ETrue; |
1167 } |
1174 } |
1168 |
1175 |
1169 // --------------------------------------------------------------------------- |
1176 // --------------------------------------------------------------------------- |
1243 // --------------------------------------------------------------------------- |
1250 // --------------------------------------------------------------------------- |
1244 // |
1251 // |
1245 TBool CDunAtCmdHandler::IsExtendedCharacter( TChar aCharacter ) |
1252 TBool CDunAtCmdHandler::IsExtendedCharacter( TChar aCharacter ) |
1246 { |
1253 { |
1247 FTRACE(FPrint( _L("CDunAtCmdHandler::IsExtendedCharacter()") )); |
1254 FTRACE(FPrint( _L("CDunAtCmdHandler::IsExtendedCharacter()") )); |
|
1255 // Extended characters supported by this function (parser understands these) |
|
1256 // '+': Universal; mentioned in 3GPP TS 27.007, 3GPP TS 27.005, ITU-T V.250 |
|
1257 // '&': Mentioned in ITU-T V.250 and in some "de facto" commands |
|
1258 // '%': Used by some old Hayes modems, left just in case |
|
1259 // '\': Used by some old Hayes modems, left just in case |
|
1260 // '*': Used by some old Hayes modems, AT&T and others |
|
1261 // '#': Used by some old Hayes modems, left just in case |
|
1262 // '$': Used by AT&T and Qualcomm |
|
1263 // '^': Used by China Mobile |
|
1264 // [please maintain this list here for quick reference] |
1248 if ( aCharacter=='+' || aCharacter=='&' || aCharacter=='%' || |
1265 if ( aCharacter=='+' || aCharacter=='&' || aCharacter=='%' || |
1249 aCharacter=='\\' || aCharacter=='*' || aCharacter=='#' || |
1266 aCharacter=='\\' || aCharacter=='*' || aCharacter=='#' || |
1250 aCharacter=='$' || aCharacter=='^' ) |
1267 aCharacter=='$' || aCharacter=='^' ) |
1251 { |
1268 { |
1252 FTRACE(FPrint( _L("CDunAtCmdHandler::IsExtendedCharacter() complete") )); |
1269 FTRACE(FPrint( _L("CDunAtCmdHandler::IsExtendedCharacter() complete") )); |
1397 } |
1414 } |
1398 if ( extendedIndex == expectedIndex ) |
1415 if ( extendedIndex == expectedIndex ) |
1399 { |
1416 { |
1400 iDecodeInfo.iExtendedIndex = aEndIndex; |
1417 iDecodeInfo.iExtendedIndex = aEndIndex; |
1401 SaveFoundCharDecodeState( aCharacter ); |
1418 SaveFoundCharDecodeState( aCharacter ); |
1402 FTRACE(FPrint( _L("CDunAtCmdHandler::IsExtendedBorder() (no border normal) complete") )); |
1419 FTRACE(FPrint( _L("CDunAtCmdHandler::IsExtendedBorder() (no border) complete") )); |
1403 return EFalse; |
1420 return EFalse; |
1404 } |
|
1405 // Now suspect border found so peek the next character after the suspected |
|
1406 // extended character. If it is not alphabetical character, return with EFalse. |
|
1407 // This case is to detect the cases such as "AT+VTS={*,3000}", where '*' would |
|
1408 // be the start of the next command in normal cases. |
|
1409 TInt peekIndex = aEndIndex + 1; |
|
1410 TInt lineLength = iLineBuffer.Length(); |
|
1411 if ( peekIndex < lineLength ) |
|
1412 { |
|
1413 TChar nextCharacter = iLineBuffer[peekIndex]; |
|
1414 if ( !nextCharacter.IsAlpha() ) |
|
1415 { |
|
1416 SaveFoundCharDecodeState( aCharacter ); |
|
1417 FTRACE(FPrint( _L("CDunAtCmdHandler::IsExtendedBorder() (no border special) complete") )); |
|
1418 return EFalse; |
|
1419 } |
|
1420 } |
1421 } |
1421 aEndIndex--; |
1422 aEndIndex--; |
1422 FTRACE(FPrint( _L("CDunAtCmdHandler::IsExtendedBorder() (border) complete") )); |
1423 FTRACE(FPrint( _L("CDunAtCmdHandler::IsExtendedBorder() (border) complete") )); |
1423 return ETrue; |
1424 return ETrue; |
1424 } |
1425 } |
1434 if ( iDecodeInfo.iAssignFound && !iDecodeInfo.iInQuotes ) |
1435 if ( iDecodeInfo.iAssignFound && !iDecodeInfo.iInQuotes ) |
1435 { |
1436 { |
1436 // Check the special case when assigning a number with "basic" command |
1437 // Check the special case when assigning a number with "basic" command |
1437 // and there is no delimiter after it. In this case <Numeric>|<Alpha> |
1438 // and there is no delimiter after it. In this case <Numeric>|<Alpha> |
1438 // border must be detected but only for a "basic" command, not for |
1439 // border must be detected but only for a "basic" command, not for |
1439 // extended. |
1440 // extended. This type of case is in active use in initialization |
|
1441 // strings where "ATS7=60L1M1X3" is one example |
1440 if ( iDecodeInfo.iExtendedIndex<0 && iDecodeInfo.iPrevExists && |
1442 if ( iDecodeInfo.iExtendedIndex<0 && iDecodeInfo.iPrevExists && |
1441 iDecodeInfo.iPrevChar.IsDigit() && aCharacter.IsAlpha() ) |
1443 iDecodeInfo.iPrevChar.IsDigit() && aCharacter.IsAlpha() ) |
1442 { |
1444 { |
1443 aEndIndex--; |
1445 aEndIndex--; |
1444 FTRACE(FPrint( _L("CDunAtCmdHandler::FindSubCommandAlphaBorder() (N|A) complete") )); |
1446 FTRACE(FPrint( _L("CDunAtCmdHandler::FindSubCommandAlphaBorder() (N|A) complete") )); |