comparison src/cs/services/atp/atp_cmd.c @ 0:945cf7f506b2

src/cs: chipsetsw import from tcs211-fcmodem binary blobs and LCD demo files have been excluded, all line endings are LF only
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 25 Sep 2016 22:50:11 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:945cf7f506b2
1 /********************************************************************************
2 *
3 * File Name : atp_cmd.c
4 *
5 * Functions handling the command translation between txt and command
6 * (and vice-versa)
7 *
8 * (C) Texas Instruments, all rights reserved
9 *
10 * Version number : 0.1 - 03-03-2000
11 *
12 * History : 0.1 - Created by E. Baissus
13 * 0.2 - Reviewed : More generic AT commands handling and
14 * copy optimization (especially on L2CAP
15 * buffers)
16 * 0.3 - '+CME ERROR' and '+CMS ERROR' support
17 *
18 * Author : Eric Baissus : e-baissus@ti.com
19 *
20 * (C) Copyright 2000 by Texas Instruments Incorporated, All Rights Reserved
21 *
22 ********************************************************************************/
23 #include "rv/rv_general.h"
24 #include "rvf/rvf_api.h"
25 #include "atp/atp_api.h"
26 #include "atp/atp_i.h"
27 #include "atp/atp_config.h"
28 #include "atp/atp_cmd.h"
29 #include "rvm/rvm_use_id_list.h"
30 #include <string.h>
31
32 #ifdef BLUETOOTH
33 #include "l2cap_data_hdlr.h" /* For L2CAP data handling. */
34 #endif
35
36 /********************************************************************************
37 * Function name : dtoa
38 *
39 * Description : Convert the digits of the given decimal value to a character
40 * string
41 *
42 * Parameters : decimal = decimal value to be converted
43 * ascii_p = string result
44 *
45 * Return : Digit number
46 *
47 * Note : digit and remainder declared as volatile to avoid bugs due to
48 * optimization.
49 *
50 * History : 0.1 (25-August-2000) - Created
51 *
52 *********************************************************************************/
53 UINT8 dtoa (UINT16 decimal,
54 T_ATP_TXT_CMD ascii_p)
55 {
56 /* Declare local variables. */
57 T_ATP_TXT_CMD str_p = ascii_p;
58 volatile UINT8 digit = 0x00;
59 volatile UINT16 remainder = decimal;
60
61 /***************************** dtoa function begins *****************************/
62
63 /* Check to see if the string result is non-null. */
64 if (str_p == NULL)
65 {
66 return (0x00);
67 }
68
69 /* Convert the fifth digit: remainder = [65535,9999[. */
70 for (digit = 0x00;
71 remainder > 9999;
72 remainder -= 10000,
73 digit++)
74 {
75 }
76 if (digit > 0x00)
77 {
78 *str_p++ = (INT8) ('0' + digit);
79 }
80
81 /* Convert the fourth digit: remainder = [9xxx,999[. */
82 for (digit = 0x00;
83 remainder > 999;
84 remainder -= 1000,
85 digit++)
86 {
87 }
88 if ((digit > 0x00) || (str_p != ascii_p))
89 {
90 *str_p++ = (INT8) ('0' + digit);
91 }
92
93 /* Convert the third digit: remainder = [9xx,99[. */
94 for (digit = 0x00;
95 remainder > 99;
96 remainder -= 100,
97 digit++)
98 {
99 }
100 if ((digit > 0x00) || (str_p != ascii_p))
101 {
102 *str_p++ = (INT8) ('0' + digit);
103 }
104
105 /* Convert the second digit: remainder = [9x,9[. */
106 for (digit = 0x00;
107 remainder > 9;
108 remainder -= 10,
109 digit++)
110 {
111 }
112 if ((digit > 0x00) || (str_p != ascii_p))
113 {
114 *str_p++ = (INT8) ('0' + digit);
115 }
116
117 /* Convert the last digit: remainder = [9,0]. */
118 *str_p++ = (INT8) ('0' + remainder);
119
120 /* Return the length of the string. */
121 return ((UINT8) (str_p - ascii_p));
122
123 } /**************************** End of dtoa function ****************************/
124
125
126 /********************************************************************************
127 * Function name : atp_cmd_init_dce_info
128 *
129 * Description : Initialize the whole of the information stored in the 'DCE
130 * information' structure
131 *
132 * Parameter : dce_info_p = pointer on the DCE information
133 *
134 * Return : RV_OK
135 *
136 * History : 0.1 (28-August-2000) - Created
137 *
138 *********************************************************************************/
139 T_ATP_RET atp_cmd_init_dce_info (T_ATP_DCE_INFO *dce_info_p)
140 {
141 /* Declare a local variable. */
142 UINT8 count = 0;
143
144 /********************* atp_cmd_init_dce_info function begins ********************/
145
146 rvf_send_trace ("ATP : DCE information initialized ",
147 34,
148 NULL_PARAM,
149 RV_TRACE_LEVEL_DEBUG_LOW,
150 ATP_USE_ID);
151
152 /* Define the default command line termination character (See ITU-T */
153 /* Recommendation V.250 ter page 21). */
154 dce_info_p->cr_character = ATP_CR_CHARACTER;
155
156 /* Define the default response formatting character (See ITU-T */
157 /* Recommendation V.250 ter page 22). */
158 dce_info_p->lf_character = ATP_LF_CHARACTER;
159
160 /* Define the default command line editing character (See ITU-T */
161 /* Recommendation V.250 ter page 22). */
162 dce_info_p->bs_character = ATP_BS_CHARACTER;
163
164 /* Define the escape sequence (See ITU-T Recommendation V.250 ter page 24). */
165 memcpy ((void *) (dce_info_p->escape_sequence),
166 ATP_ESCAPE_SEQUENCE,
167 MAX_NB_OF_CHARACTER_FOR_END_SEQUENCE);
168
169 /* Define the command echo (See ITU-T Recommendation V.250 ter page 23). */
170 dce_info_p->echo_mode = ECHO_OFF;
171
172 /* Define the result code suppression (See ITU-T Recommendation V.250 ter */
173 /* page 23). */
174 dce_info_p->result_code_mode = RESULT_CODE_ON;
175
176 /* Define the DCE response format (See ITU-T Recommendation V.250 ter page */
177 /* 24). */
178 dce_info_p->verbose_mode = ATP_VERBOSE_1;
179
180 /* Initialize the masks associated with the commands executed by the ATP. */
181 memset ((void *) (dce_info_p->dce_mask),
182 0x00,
183 sizeof (T_ATP_DCE_MASK));
184
185 /* Initialize pointers on temporary buffers containing the escape sequence. */
186 for (count = 0;
187 count < MAX_NB_OF_CHARACTER_FOR_END_SEQUENCE;
188 count++)
189 {
190
191 /* Initialize the pointer on a temporary data buffer containing part of */
192 /* the assumed escape sequence. */
193 dce_info_p->escape_sequence_tmp_buffer_p[count] = NULL;
194
195 /* Initialize the number of data included in buffer hereinabove. */
196 dce_info_p->length_of_escape_sequence_tmp_buffer_p[count] = 0;
197 }
198 dce_info_p->nb_plus_received = 0;
199 return (RV_OK);
200
201 } /******************** End of atp_cmd_init_dce_info function *******************/
202
203
204 /********************************************************************************
205 * Function name : atp_get_custom_info_from_txt
206 *
207 * Description : Etract custom information from a text string
208 *
209 * Parameters : text_pp = string containing the command (0-terminated)
210 * cmd_format = related structure
211 * mb_id = memory bank used to get the custom command information
212 * buffer
213 * termination_char = termination character ('\x00' or <CR>)
214 *
215 * Return : cmd_info_pp and RV_OK if the command is found,
216 * RV_NOT_SUPPORTED
217 *
218 * Note : Space characters are ignored and may be used freely for formatting
219 * purposes, unless they are embedded in numeric or string constants
220 * (See ITU-T Recommendation V.250 ter sections 5.4.2.1 or 5.4.2.2 on
221 * pages 6 and 7). The DCE shall be capable of accepting at least 40
222 * characters in the body.
223 *
224 * History : 0.1 (29-August-2000) - Created
225 *
226 *********************************************************************************/
227 T_ATP_RET atp_get_custom_info_from_txt (T_ATP_TXT_CMD *text_pp,
228 T_ATP_CMD_FORMAT cmd_format,
229 T_RVF_MB_ID mb_id,
230 T_ATP_CMD **cmd_info_pp,
231 const char termination_char)
232 {
233
234 /***************** atp_get_custom_info_from_txt function begins *****************/
235
236 switch (cmd_format)
237 {
238
239 /* Basic syntax command does not expect any <number>. */
240 case ATP_NO_PARAM:
241 {
242 *cmd_info_pp = NULL;
243 return (RV_OK);
244 }
245
246 /* Basic syntax command. */
247 case ATP_BASIC_PARAM:
248 {
249
250 /* Allocate memory in order to store the <number> associated */
251 /* with basic syntax commands. If insufficient resources */
252 /* available, then report an internal memory error and abort. */
253 if (rvf_get_buf (mb_id, \
254 sizeof (T_ATP_BASIC_CMD), \
255 (void **) cmd_info_pp) == RVF_RED)
256 {
257 atp_error (ATP_ERROR_TX_MB_RED);
258 return (RV_MEMORY_ERR);
259 }
260
261 /* Get the <number> of the basic syntax command (See ITU-T */
262 /* Recommendation V.250 ter page 5). */
263 memset ((void *) (*cmd_info_pp),
264 0x00,
265 sizeof (T_ATP_BASIC_CMD));
266 ATP_GET_NUMBER (*text_pp,
267 &((*((T_ATP_BASIC_CMD **) cmd_info_pp))->number),
268 '0');
269 return (RV_OK);
270 }
271
272 /* Dial. */
273 case ATP_DIAL_PARAM:
274 {
275
276 /* Allocate memory in order to store the <dial_string> */
277 /* associated with the dial. If insufficient resources */
278 /* available, then report an internal memory error and abort. */
279 if (rvf_get_buf (mb_id, \
280 sizeof (T_ATP_DIAL), \
281 (void **) cmd_info_pp) == RVF_RED)
282 {
283 atp_error (ATP_ERROR_TX_MB_RED);
284 return (RV_MEMORY_ERR);
285 }
286
287 /* Get the <dial_string> of the dial (See ITU-T Recommendation */
288 /* V.250 ter page 31). All characters appearing on the same */
289 /* command line after D are considered part of the call */
290 /* addressing information to be signalled to the network, or */
291 /* modifiers used to control the signalling process, up to a */
292 /* semicolon character or the end of the command line. If the */
293 /* <dial_string> is terminated by a semicolon, the DCE does not */
294 /* start the call origination procedure, but instead returns to */
295 /* command state after completion of the signalling of call */
296 /* addressing information to the network. */
297 memset ((void *) (*cmd_info_pp),
298 0x00,
299 sizeof (T_ATP_DIAL));
300 ATP_GET_DIAL_STRING (*text_pp,
301 (*((T_ATP_DIAL **) cmd_info_pp))->dial_string_p,
302 &((*((T_ATP_DIAL **) cmd_info_pp))->dial_string_length),
303 &((*((T_ATP_DIAL **) cmd_info_pp))->call_type),
304 termination_char);
305 return (RV_OK);
306 }
307
308 /* S-parameter. */
309 case ATP_S_PARAM:
310 {
311
312 /* Allocate memory in order to store the <value> associated */
313 /* with S-parameters. If insufficient resources available, then */
314 /* report an internal memory error and abort. */
315 if (rvf_get_buf (mb_id, \
316 sizeof (T_ATP_S_PARAM), \
317 (void **) cmd_info_pp) == RVF_RED)
318 {
319 atp_error (ATP_ERROR_TX_MB_RED);
320 return (RV_MEMORY_ERR);
321 }
322
323 /* Get the characters that immediately follow */
324 /* <parameter_number>. "=" is used to set the indicated */
325 /* S-parameter to a new value (See ITU-T Recommendation V.250 */
326 /* ter page 5). Note that if no value is given, the S-parameter */
327 /* specified may be set to 0, or an ERROR result code issued */
328 /* and the stored value left unchanged. "?" is used to read the */
329 /* current value of the indicated S-parameter (See ITU-T */
330 /* Recommendation V.250 ter page 5). */
331 memset ((void *) (*cmd_info_pp),
332 0x00,
333 sizeof (T_ATP_S_PARAM));
334 ATP_GET_PARAMETER_VALUE (*text_pp,
335 &((*((T_ATP_S_PARAM **) cmd_info_pp))->s_operator),
336 &((*((T_ATP_S_PARAM **) cmd_info_pp))->value));
337 return (RV_OK);
338 }
339
340 /* Extended syntax command does not expect any <value>. */
341 case ATP_NO_EXTENDED_PARAM:
342 {
343
344 /* Allocate memory in order to store the <value> associated */
345 /* with extended syntax commands. If insufficient resources */
346 /* available, then report an internal memory error and abort. */
347 if (rvf_get_buf (mb_id, \
348 sizeof (T_ATP_NO_SUBPARAMETER), \
349 (void **) cmd_info_pp) == RVF_RED)
350 {
351 atp_error (ATP_ERROR_TX_MB_RED);
352 return (RV_MEMORY_ERR);
353 }
354
355 /* Get the characters that immediately follow <name>. "=?" is */
356 /* used to test whether the extended syntax command is */
357 /* implemented in the DCE (See ITU-T Recommendation V.250 ter */
358 /* page 9). */
359 memset ((void *) (*cmd_info_pp),
360 0x00,
361 sizeof (T_ATP_NO_SUBPARAMETER));
362 ATP_GET_OPERATOR (*text_pp,
363 &((*((T_ATP_NO_SUBPARAMETER **) cmd_info_pp))->extended_operator));
364 return (RV_OK);
365 }
366
367 /* Extended syntax command whose subparameter is a numeric constant. */
368 case ATP_SINGLE_EXTENDED_PARAM:
369 {
370
371 /* Allocate memory in order to store the <value> associated */
372 /* with extended syntax commands. If insufficient resources */
373 /* available, then report an internal memory error and abort. */
374 if (rvf_get_buf (mb_id, \
375 sizeof (T_ATP_SINGLE_SUBPARAMETER), \
376 (void **) cmd_info_pp) == RVF_RED)
377 {
378 atp_error (ATP_ERROR_TX_MB_RED);
379 return (RV_MEMORY_ERR);
380 }
381
382 /* Get the characters that immediately follow <name>. "=" is */
383 /* used to set the indicated extended syntax command to a new */
384 /* value (See ITU-T Recommendation V.250 ter page 8). Note that */
385 /* if no value is given, the extended syntax command specified */
386 /* may be set to 0. "?" is used to read the current value of */
387 /* the indicated extended syntax command (See ITU-T */
388 /* Recommendation V.250 ter page 9). "=?" is used to test */
389 /* whether the extended syntax command is implemented in the */
390 /* DCE. */
391 memset ((void *) (*cmd_info_pp),
392 0x00,
393 sizeof (T_ATP_SINGLE_SUBPARAMETER));
394 ATP_GET_VALUE (*text_pp,
395 &((*((T_ATP_SINGLE_SUBPARAMETER **) cmd_info_pp))->extended_operator),
396 &((*((T_ATP_SINGLE_SUBPARAMETER **) cmd_info_pp))->value),
397 termination_char);
398 return (RV_OK);
399 }
400
401 /* Keypad control command. */
402 case ATP_PLUS_CKPD_PARAM:
403 {
404
405 /* Allocate memory in order to store the <keys>,<time> and */
406 /* <pause> associated with +CKPD extended syntax command. If */
407 /* insufficient resources available, then report an internal */
408 /* memory error and abort. */
409 if (rvf_get_buf (mb_id, \
410 sizeof (T_ATP_PLUS_CKPD), \
411 (void **) cmd_info_pp) == RVF_RED)
412 {
413 atp_error (ATP_ERROR_TX_MB_RED);
414 return (RV_MEMORY_ERR);
415 }
416
417 /* Get the <keys>,<time> and <pause> of the keypad control */
418 /* command. Note that <keys> shall consist of a string constant */
419 /* and <time> and <pause> shall consist of numeric constants in */
420 /* tenths of a second (See ETS 300 916 (GSM 07.07) Version */
421 /* 5.8.1 page 62). "=?" is used to test whether the extended */
422 /* syntax command is implemented in the DCE. */
423 memset ((void *) (*cmd_info_pp),
424 0x00,
425 sizeof (T_ATP_PLUS_CKPD));
426 ATP_GET_CKPD_PARAM (*text_pp,
427 (*((T_ATP_PLUS_CKPD **) cmd_info_pp)),
428 termination_char);
429 return (RV_OK);
430 }
431
432 /* AT command undefined or not supported for now. */
433 default:
434 {
435 break;
436 }
437 }
438 return (RV_NOT_SUPPORTED);
439
440 } /**************** End of atp_get_custom_info_from_txt function ****************/
441
442
443 /********************************************************************************
444 * Function name : atp_translate_raw_data_to_cmd
445 *
446 * Description : Translate raw data into an interpreted command
447 *
448 * Parameters : dce_info_p = pointer on the port structure
449 * text_p = raw data containing the command (0-terminated)
450 * cmd_type = command type of the text
451 * cmd_type_p = type of the interpreted command
452 * cmd_nb_p = binary related code of the interpreted command
453 * skip_prefix = indicate whether the prefix shall be skipped in
454 * order to proceed the translation
455 * mb_id = memory bank used to get the custom command information
456 * buffer
457 * cmd_info_pp = pointer on the custom command information structure
458 *
459 * Return : RV_OK,
460 * RV_NOT_SUPPORTED if the command is not recognized,
461 * RV_INVALID_PARAMETER
462 *
463 * Note : A command line is made up of three elements: the prefix, the body,
464 * and the termination character. The command line prefix consists of
465 * the characters "AT" or "at", or, to repeat the execution of the
466 * previous command line, the characters "A/" or "a/". The body is
467 * made up of individual commands. Space characters are ignored and
468 * may be used freely for formatting purposes, unless they are embedded
469 * in numeric or string constants (See ITU-T Recommendation V.250 ter
470 * sections 5.4.2.1 or 5.4.2.2 on pages 6 and 7). The termination
471 * character may not appear in the body. The DCE shall be capable of
472 * accepting at least 40 characters in the body. Note that the
473 * termination character may be selected by a user option (parameter
474 * S3), the default being CR.
475 *
476 * History : 0.1 (25-August-2000) - Created
477 *
478 *********************************************************************************/
479 T_ATP_RET atp_translate_raw_data_to_cmd (T_ATP_PORT_STRUCT *port_p,
480 T_ATP_TXT_CMD *text_pp,
481 T_ATP_CMD_TYPE cmd_type,
482 T_ATP_CMD_TYPE *cmd_type_p,
483 T_ATP_CMD_NB *cmd_nb_p,
484 T_RVF_MB_ID mb_id,
485 T_ATP_CMD **cmd_info_pp)
486 {
487 /* Declare a local variable. */
488 BOOLEAN equal = FALSE;
489
490 /***************** atp_translate_raw_data_to_cmd function begins ****************/
491
492 /* Check to see if the text command line is valid. */
493 if ((text_pp == NULL) || (*text_pp == NULL))
494 {
495 return (RV_INVALID_PARAMETER);
496 }
497
498 /* Initialize information for AT commands do not expect any number or */
499 /* value. */
500 *cmd_info_pp = NULL;
501
502 /* DTE command lines (See ITU-T Recommendation V.250 ter page 4). By the */
503 /* way, note that the prefix consists of the characters "AT" or "at". */
504 if ((cmd_type == UNKNOWN) || (cmd_type == AT_CMD))
505 {
506
507 /* Declare a local block variable. */
508 UINT8 prefix_len = 0x00;
509
510 /* Check to see whether the prefix shall be skipped in order to proceed */
511 /* the translation. */
512 if ((port_p == NULL) || ((port_p->cmd_info).status == NOT_STARTED))
513 {
514 prefix_len = ATP_AT_PREFIX_LEN;
515 }
516
517 /* If the prefix is either "AT" or "at", then the DCE shall proceed the */
518 /* command line body (See ITU-T Recommendation V.250 ter page 4). */
519 ATP_MEM_I_CMP (ATP_AT_PREFIX,
520 *text_pp,
521 prefix_len,
522 &equal);
523 if (equal == TRUE)
524 {
525
526 /* Declare local block variables. */
527 const char *cmd_p = NULL;
528 UINT8 cmd_len = 0x00;
529
530 for (*cmd_nb_p = 0x00, \
531 *cmd_type_p = AT_CMD, \
532 equal = FALSE, \
533 *text_pp += prefix_len;
534 *cmd_nb_p < ATP_MAX_NB_OF_AT_COMMANDS;
535 (*cmd_nb_p)++)
536 {
537
538 /* If needed, skip this empty entry. */
539 if (ATP_AT_INFO[*cmd_nb_p][ATP_AT_PARAM_COLUMN] == ATP_CMD_NOT_DEFINED)
540 {
541 continue;
542 }
543
544 /* Get the length of the remainder. */
545 cmd_len = (UINT8) (ATP_AT_INFO[*cmd_nb_p + 0x01][ATP_AT_OFFSET_COLUMN] - ATP_AT_INFO[*cmd_nb_p][ATP_AT_OFFSET_COLUMN]);
546 cmd_p = &(ATP_AT_TXT_TABLE[ATP_AT_INFO[*cmd_nb_p][ATP_AT_OFFSET_COLUMN]]);
547 ATP_MEM_SP_I_CMP (cmd_p,
548 *text_pp,
549 &cmd_len,
550 &equal);
551
552 /* If both AT commands match, then get the custom information. */
553 if (equal == TRUE)
554 {
555 rvf_send_trace ("ATP : Translate an AT command from text to command ",
556 51,
557 NULL_PARAM,
558 RV_TRACE_LEVEL_DEBUG_LOW,
559 ATP_USE_ID);
560 *text_pp += cmd_len;
561 (void) atp_get_custom_info_from_txt (text_pp,
562 ATP_AT_INFO[*cmd_nb_p][ATP_AT_PARAM_COLUMN],
563 mb_id,
564 cmd_info_pp,
565 (const char) ((port_p == NULL) ? ('\x00') : ((port_p->dce_info_p)->cr_character)));
566 return (RV_OK);
567 }
568 }
569 return (RV_NOT_SUPPORTED);
570 }
571 }
572
573 /* DCE responses (See ITU-T Recommendation V.250 ter page 10). */
574 if ((cmd_type == UNKNOWN) || (cmd_type == RESULT_CODE) || \
575 (cmd_type == UNSOLICITED_RESULT))
576 {
577
578 /* Declare local block variables. */
579 const char *result_code_p = NULL;
580 UINT8 header_len = 0x00;
581 UINT8 result_code_len = 0x00;
582
583 /* If verbose responses are enabled, check to see whether leading <CR> */
584 /* and <LF> characters shall be skipped in order to proceed the */
585 /* translation. */
586 if ((port_p != NULL) && ((port_p->dce_info_p)->verbose_mode == ATP_VERBOSE_1))
587 {
588 equal = TRUE;
589 equal &= ((*text_pp)[0x00] == (port_p->dce_info_p)->cr_character);
590 equal &= ((*text_pp)[0x01] == (port_p->dce_info_p)->lf_character);
591
592 /* If leading characters do not match <CR><LF> headers of */
593 /* information responses, then abort (See ETS 300 916 (GSM 07.07) */
594 /* Version 4.1 page 13). */
595 if (equal == FALSE)
596 {
597 *cmd_type_p = UNKNOWN;
598 return (RV_NOT_SUPPORTED);
599 }
600 header_len = ATP_RESULT_CODE_HEADER_LEN;
601 }
602 for (*cmd_nb_p = 0x00, \
603 *cmd_type_p = RESULT_CODE, \
604 *text_pp += header_len;
605 *cmd_nb_p < ATP_MAX_NB_OF_RESULT_CODES;
606 (*cmd_nb_p)++)
607 {
608
609 /* If needed, skip this empty entry. */
610 if (ATP_RESULT_CODE_INFO[*cmd_nb_p][ATP_RESULT_PARAM_COLUMN] == ATP_RESULT_CODE_NOT_DEFINED)
611 {
612 continue;
613 }
614
615 /* If verbose responses are disabled, then get the length of the */
616 /* result code from the dedicated list. */
617 if ((port_p != NULL) && ((port_p->dce_info_p)->verbose_mode == ATP_VERBOSE_0))
618 {
619 result_code_len = (UINT8) (ATP_RESULT_CODE_INFO[*cmd_nb_p + 0x01][ATP_RESULT_OFFSET_V0_COLUMN] - ATP_RESULT_CODE_INFO[*cmd_nb_p][ATP_RESULT_OFFSET_V0_COLUMN]);
620 result_code_p = &(ATP_RESULT_CODE_TXT_TABLE_V0[ATP_RESULT_CODE_INFO[*cmd_nb_p][ATP_RESULT_OFFSET_V0_COLUMN]]);
621 }
622 else
623 {
624 result_code_len = (UINT8) (ATP_RESULT_CODE_INFO[*cmd_nb_p + 0x01][ATP_RESULT_OFFSET_V1_COLUMN] - ATP_RESULT_CODE_INFO[*cmd_nb_p][ATP_RESULT_OFFSET_V1_COLUMN]);
625 result_code_p = &(ATP_RESULT_CODE_TXT_TABLE_V1[ATP_RESULT_CODE_INFO[*cmd_nb_p][ATP_RESULT_OFFSET_V1_COLUMN]]);
626 }
627 ATP_MEM_I_CMP (result_code_p,
628 *text_pp,
629 result_code_len,
630 &equal);
631 if (equal == FALSE)
632 {
633 continue;
634 }
635 rvf_send_trace ("ATP : Translate a result from text to command ",
636 46,
637 NULL_PARAM,
638 RV_TRACE_LEVEL_DEBUG_LOW,
639 ATP_USE_ID);
640 *text_pp += result_code_len;
641 switch (ATP_RESULT_CODE_INFO[*cmd_nb_p][ATP_RESULT_PARAM_COLUMN])
642 {
643
644 /* Extended syntax result code. */
645 case ATP_EXTENDED_RESULT_CODE:
646 {
647
648 /* Allocate memory in order to store the <value> */
649 /* associated with extended syntax result codes. If */
650 /* insufficient resources available, then report an */
651 /* internal memory error and abort. */
652 if (rvf_get_buf (mb_id, \
653 sizeof (T_ATP_SINGLE_RESULT_CODE_VALUE), \
654 (void **) cmd_info_pp) == RVF_RED)
655 {
656 atp_error (ATP_ERROR_TX_MB_RED);
657 return (RV_MEMORY_ERR);
658 }
659
660 /* Get the value associated with the extended result */
661 /* codes (See Headset Specification, Section 4.7.3). */
662 memset ((void *) (*cmd_info_pp),
663 0x00,
664 sizeof (T_ATP_SINGLE_RESULT_CODE_VALUE));
665 ATP_GET_RESULT_CODE_VALUE (*text_pp,
666 &((*((T_ATP_SINGLE_RESULT_CODE_VALUE **) cmd_info_pp))->value));
667 break;
668 }
669
670 /* +CME ERROR: <error> and +CMS ERROR: <error> result codes. */
671 case ATP_PLUS_ERROR_RESULT_CODE:
672 {
673
674 /* Allocate memory in order to store the <error> */
675 /* associated with +CME ERROR or +CMS ERROR result */
676 /* codes. If insufficient resources available, then */
677 /* report an internal memory error and abort. */
678 if (rvf_get_buf (mb_id, \
679 sizeof (T_ATP_PLUS_ERROR_RESULT_CODE), \
680 (void **) cmd_info_pp) == RVF_RED)
681 {
682 atp_error (ATP_ERROR_TX_MB_RED);
683 return (RV_MEMORY_ERR);
684 }
685
686 /* Get the <error> associated with the +CME ERROR or */
687 /* +CMS ERROR result codes. */
688 memset ((void *) (*cmd_info_pp),
689 0x00,
690 sizeof (T_ATP_PLUS_ERROR_RESULT_CODE));
691 ATP_PLUS_ERROR_STRING (*text_pp,
692 ((T_ATP_PLUS_ERROR_RESULT_CODE *) (*cmd_info_pp))->error_p,
693 &(((T_ATP_PLUS_ERROR_RESULT_CODE *) (*cmd_info_pp))->error_length),
694 '\x00');
695 break;
696 }
697 default:
698 {
699
700 /* Check to see if any text is associated with the */
701 /* CONNECT result code. */
702 if (*cmd_nb_p == ATP_CONNECT_NB)
703 {
704
705 /* Declare a local block variable. */
706 UINT16 connect_text = 0x0000;
707
708 /* Get the <text> associated with the CONNECT */
709 /* result codes (See ITU-T Recommendation V.250 ter */
710 /* page 11). */
711 ATP_GET_CONNECT_TXT (*text_pp,
712 &connect_text);
713
714 /* If no <text> is associated with the CONNECT */
715 /* result code, then abort. */
716 if (connect_text == 0x0000)
717 {
718 break;
719 }
720
721 /* Otherwise, allocate memory in order to store the */
722 /* <text> associated with the CONNECT result code. */
723 /* If insufficient resources available, then report */
724 /* an internal memory error and abort. */
725 if (rvf_get_buf (mb_id, \
726 sizeof (T_ATP_CONNECT_TXT_PARAM), \
727 (void **) cmd_info_pp) == RVF_RED)
728 {
729 atp_error (ATP_ERROR_TX_MB_RED);
730 return (RV_MEMORY_ERR);
731 }
732
733 /* Return the <text> associated with the CONNECT */
734 /* result code. */
735 (*((T_ATP_CONNECT_TXT_PARAM **) cmd_info_pp))->value = connect_text;
736 *cmd_nb_p = ATP_CONNECT_TXT_NB;
737 }
738 break;
739 }
740 }
741 return (RV_OK);
742 }
743 }
744 *cmd_type_p = UNKNOWN;
745 return (RV_NOT_SUPPORTED);
746
747 } /**************** End of atp_translate_raw_data_to_cmd function ***************/
748
749
750 /********************************************************************************
751 * Function name : atp_translate_txt_to_cmd
752 *
753 * Description : Translate a text string into an interpreted command
754 *
755 * Parameters : text_p = text string containing the command (0-terminated)
756 * cmd_type = command type of the text
757 * cmd_type_p = type of the interpreted command
758 * cmd_nb_p = binary related code of the interpreted command
759 * mb_id = memory bank used to get the custom command information
760 * buffer
761 * cmd_info_pp = pointer on the custom command information structure
762 *
763 * Return : RV_OK,
764 * RV_NOT_SUPPORTED if the command is not recognized,
765 * RV_INVALID_PARAMETER
766 *
767 * History : 0.1 (25-August-2000) - Created
768 *
769 *********************************************************************************/
770 T_ATP_RET atp_translate_txt_to_cmd (T_ATP_TXT_CMD text_p,
771 T_ATP_CMD_TYPE cmd_type,
772 T_ATP_CMD_TYPE *cmd_type_p,
773 T_ATP_CMD_NB *cmd_nb_p,
774 T_RVF_MB_ID mb_id,
775 T_ATP_CMD **cmd_info_pp)
776 {
777 /* Declare a local variable. */
778 T_ATP_RET ret_status = RV_OK;
779
780 /******************* atp_translate_txt_to_cmd function begins *******************/
781
782 ret_status = atp_translate_raw_data_to_cmd (NULL,
783 &text_p,
784 cmd_type,
785 cmd_type_p,
786 cmd_nb_p,
787 mb_id,
788 cmd_info_pp);
789 return (ret_status);
790
791 } /****************** End of atp_translate_txt_to_cmd function ******************/
792
793
794 /********************************************************************************
795 * Function name : atp_interpret_raw_data
796 *
797 * Description : Fetch and interpret (if applicable and DCE mode) a new command
798 * from the raw data buffer stored available in port_structure
799 *
800 * Parameters : port_p = pointer on the port structure
801 * mb_id = memory bank which the text buffer should be counted on
802 * cmd_type_p = found command type (if UNKNOWN, should check text
803 * field)
804 * cmd_nb_p = found command number
805 * cmd_info_p = pointer on the custom command information structure
806 * text_pp = result of interpretation: contain next command to be
807 * sent by ATP in text format (0-terminated) or NULL if
808 * no command to be sent
809 * text_length_p = length of the text command, '\x00' not included
810 *
811 * Return : RV_MEMORY_ERR in case 'memory bank' get RED,
812 * RV_NOT_SUPPORTED if the buffer does not contain proper data,
813 * RV_OK otherwise
814 *
815 * Note : The first data that should be checked are:
816 * (port_p->cmd_info).cmd_txt_p[(port_p->cmd_info).next_position]
817 * if (port_p->cmd_info).status = NOT_STARTED, an 'AT' should be
818 * found
819 * if the function has processed all the chain, it should set state
820 * to FINISHED
821 * (port_p->cmd_info).next_position must be updated by the function
822 *
823 * History : 0.1 (25-August-2000) - Created
824 *
825 *********************************************************************************/
826 T_ATP_RET atp_interpret_raw_data (T_ATP_PORT_STRUCT *port_p,
827 T_RVF_MB_ID mb_id,
828 T_ATP_CMD_TYPE *cmd_type_p,
829 T_ATP_CMD_NB *cmd_nb_p,
830 T_ATP_CMD **cmd_info_pp,
831 T_ATP_TXT_CMD *text_pp,
832 UINT16 *text_length_p)
833 {
834 /* Declare local variables. */
835 T_ATP_RET ret_status = RV_OK;
836 T_ATP_TXT_CMD text_p = NULL;
837
838 /******************** atp_interpret_raw_data function begins ********************/
839
840 rvf_send_trace ("ATP : Interpret raw data ",
841 25,
842 NULL_PARAM,
843 RV_TRACE_LEVEL_DEBUG_LOW,
844 ATP_USE_ID);
845
846 *text_pp = NULL;
847
848 /* Interpret all AT commands or result codes. */
849 while (((port_p->cmd_info).status == NOT_STARTED) || \
850 (((port_p->cmd_info).status == ON_GOING) && \
851 ((port_p->cmd_info).cmd_txt_p[(port_p->cmd_info).next_position] != (port_p->dce_info_p)->cr_character) && \
852 ((port_p->cmd_info).next_position < (port_p->cmd_info).cmd_txt_length)))
853 {
854 text_p = &((port_p->cmd_info).cmd_txt_p[(port_p->cmd_info).next_position]);
855 ret_status = atp_translate_raw_data_to_cmd (port_p,
856 &text_p,
857 UNKNOWN,
858 cmd_type_p,
859 cmd_nb_p,
860 mb_id,
861 cmd_info_pp);
862
863 /* If any memory error occurred, then abort. */
864 if (ret_status == RV_MEMORY_ERR)
865 {
866 return (RV_MEMORY_ERR);
867 }
868
869 /* Backup the next character to be interpreted. */
870 (port_p->cmd_info).status = ON_GOING;
871 (port_p->cmd_info).next_position = (UINT16) (text_p - (port_p->cmd_info).cmd_txt_p);
872
873 /* Intrepret the extracted command. */
874 switch (*cmd_type_p)
875 {
876
877 /* Interpret the extracted AT command. */
878 case AT_CMD:
879 {
880
881 /* Interpret AT commands only if ATP is acting as a DCE. */
882 if (port_p->port_config != DCE_CONFIG)
883 {
884 break;
885 }
886
887 /* Set the result of interpretation to NULL. */
888 *text_pp = NULL;
889 switch (*cmd_nb_p)
890 {
891
892 /* Answer. Note that any additional commands that */
893 /* appear after A on the same command line are ignored */
894 /* (See ITU-T Recommendation V.250 ter page 35). */
895 case ATP_ATA_NB:
896
897 /* Dial. Note that all characters appearing on the same */
898 /* command line after D are considered part of the call */
899 /* addressing information to be signalled to the */
900 /* network, or modifiers used to control the signalling */
901 /* process, up to a semicolon character or the end of */
902 /* the command line (See ITU-T Recommendation V.250 ter */
903 /* page 31). Note also that the ITU-T Recommendation */
904 /* V.250 ter does not describe DCE behaviour in some */
905 /* situations. Thus, additional characters that appear */
906 /* on the same command line after a semicolon that */
907 /* terminates dial string are either ignored or */
908 /* processed as commands (See ITU-T Recommendation */
909 /* V.250 ter page 14). In our implementation, such */
910 /* additional characters are ignored. */
911 case ATP_ATD_NB:
912
913 /* Reset to default configuration. Note that any */
914 /* additional commands that appear on the same command */
915 /* line after Z are ignored (See ITU-T Recommendation */
916 /* V.250 ter page 15). */
917 case ATP_ATZ_NB:
918 {
919 (port_p->cmd_info).next_position = (port_p->cmd_info).cmd_txt_length;
920 break;
921 }
922
923 /* Command echo. */
924 case ATP_ATE_NB:
925 {
926
927 /* Check to see if the specified value is valid */
928 /* (See ITU-T Recommendation V.250 ter page */
929 /* 23). */
930 if (((*((T_ATP_ATE_PARAM **) cmd_info_pp))->number != ECHO_OFF) && \
931 ((*((T_ATP_ATE_PARAM **) cmd_info_pp))->number != ECHO_ON))
932 {
933 rvf_send_trace ("ATP : Command echo value invalid ",
934 33,
935 NULL_PARAM,
936 RV_TRACE_LEVEL_WARNING,
937 ATP_USE_ID);
938 rvf_free_buf (*cmd_info_pp);
939 *cmd_info_pp = NULL;
940 return (RV_NOT_SUPPORTED);
941 }
942 rvf_send_trace ("ATP : Command echo updated ",
943 27,
944 NULL_PARAM,
945 RV_TRACE_LEVEL_DEBUG_LOW,
946 ATP_USE_ID);
947 (port_p->dce_info_p)->echo_mode = (*((T_ATP_ATE_PARAM **) cmd_info_pp))->number;
948 *cmd_type_p = UNKNOWN;
949 rvf_free_buf (*cmd_info_pp);
950 *cmd_info_pp = NULL;
951
952 /* Interpret the next AT command or result code */
953 /* to come. */
954 continue;
955 }
956
957 /* Result code suppression. */
958 case ATP_ATQ_NB:
959 {
960
961 /* Check to see if the specified value is valid */
962 /* (See ITU-T Recommendation V.250 ter page */
963 /* 23). */
964 if (((*((T_ATP_ATQ_PARAM **) cmd_info_pp))->number != RESULT_CODE_ON) && \
965 ((*((T_ATP_ATQ_PARAM **) cmd_info_pp))->number != RESULT_CODE_OFF))
966 {
967 rvf_send_trace ("ATP : Result code suppression value invalid ",
968 44,
969 NULL_PARAM,
970 RV_TRACE_LEVEL_WARNING,
971 ATP_USE_ID);
972 rvf_free_buf (*cmd_info_pp);
973 *cmd_info_pp = NULL;
974 return (RV_NOT_SUPPORTED);
975 }
976 rvf_send_trace ("ATP : Result code suppression updated ",
977 38,
978 NULL_PARAM,
979 RV_TRACE_LEVEL_DEBUG_LOW,
980 ATP_USE_ID);
981 (port_p->dce_info_p)->result_code_mode = (*((T_ATP_ATQ_PARAM **) cmd_info_pp))->number;
982 *cmd_type_p = UNKNOWN;
983 rvf_free_buf (*cmd_info_pp);
984 *cmd_info_pp = NULL;
985
986 /* Interpret the next AT command or result code */
987 /* to come. */
988 continue;
989 }
990
991 /* DCE response format. */
992 case ATP_ATV_NB:
993 {
994
995 /* Check to see if the specified value is valid */
996 /* (See ITU-T Recommendation V.250 ter page */
997 /* 24). */
998 if (((*((T_ATP_ATV_PARAM **) cmd_info_pp))->number != ATP_VERBOSE_0) && \
999 ((*((T_ATP_ATV_PARAM **) cmd_info_pp))->number != ATP_VERBOSE_1))
1000 {
1001 rvf_send_trace ("ATP : DCE response format value invalid ",
1002 40,
1003 NULL_PARAM,
1004 RV_TRACE_LEVEL_WARNING,
1005 ATP_USE_ID);
1006 rvf_free_buf (*cmd_info_pp);
1007 *cmd_info_pp = NULL;
1008 return (RV_NOT_SUPPORTED);
1009 }
1010 rvf_send_trace ("ATP : DCE response format updated ",
1011 34,
1012 NULL_PARAM,
1013 RV_TRACE_LEVEL_DEBUG_LOW,
1014 ATP_USE_ID);
1015 (port_p->dce_info_p)->verbose_mode = (*((T_ATP_ATV_PARAM **) cmd_info_pp))->number;
1016 *cmd_type_p = UNKNOWN;
1017 rvf_free_buf (*cmd_info_pp);
1018 *cmd_info_pp = NULL;
1019
1020 /* Interpret the next AT command or result code */
1021 /* to come. */
1022 continue;
1023 }
1024
1025 /* Command line termination character. */
1026 case ATP_ATS3_NB:
1027 {
1028
1029 /* Check to see if the specified value is valid */
1030 /* (See ITU-T Recommendation V.250 ter pages 21 */
1031 /* and 22). */
1032 if ((((*((T_ATP_ATS3_PARAM **) cmd_info_pp))->s_operator != READ_S_PARAM) && \
1033 ((*((T_ATP_ATS3_PARAM **) cmd_info_pp))->s_operator != SET_S_PARAM)) || \
1034 ((*((T_ATP_ATS3_PARAM **) cmd_info_pp))->value > 0x007F))
1035 {
1036 rvf_send_trace ("ATP : Command line termination character invalid ",
1037 49,
1038 NULL_PARAM,
1039 RV_TRACE_LEVEL_WARNING,
1040 ATP_USE_ID);
1041 rvf_free_buf (*cmd_info_pp);
1042 *cmd_info_pp = NULL;
1043 return (RV_NOT_SUPPORTED);
1044 }
1045 rvf_send_trace ("ATP : Command line termination character updated ",
1046 49,
1047 NULL_PARAM,
1048 RV_TRACE_LEVEL_DEBUG_LOW,
1049 ATP_USE_ID);
1050
1051 /* Check to see if the S-parameter is requested */
1052 /* to be set to a new value. */
1053 if ((*((T_ATP_ATS3_PARAM **) cmd_info_pp))->s_operator == SET_S_PARAM)
1054 {
1055 (port_p->dce_info_p)->cr_character = (char) ((*((T_ATP_ATS3_PARAM **) cmd_info_pp))->value);
1056 *cmd_type_p = UNKNOWN;
1057 rvf_free_buf (*cmd_info_pp);
1058 *cmd_info_pp = NULL;
1059
1060 /* Interpret the next AT command or result */
1061 /* code to come. */
1062 continue;
1063 }
1064 break;
1065 }
1066
1067 /* Response formatting character. */
1068 case ATP_ATS4_NB:
1069 {
1070
1071 /* Check to see if the specified value is valid */
1072 /* (See ITU-T Recommendation V.250 ter page */
1073 /* 22). */
1074 if ((((*((T_ATP_ATS4_PARAM **) cmd_info_pp))->s_operator != READ_S_PARAM) && \
1075 ((*((T_ATP_ATS4_PARAM **) cmd_info_pp))->s_operator != SET_S_PARAM)) || \
1076 ((*((T_ATP_ATS4_PARAM **) cmd_info_pp))->value > 0x007F))
1077 {
1078 rvf_send_trace ("ATP : Response formatting character invalid ",
1079 44,
1080 NULL_PARAM,
1081 RV_TRACE_LEVEL_WARNING,
1082 ATP_USE_ID);
1083 rvf_free_buf (*cmd_info_pp);
1084 *cmd_info_pp = NULL;
1085 return (RV_NOT_SUPPORTED);
1086 }
1087 rvf_send_trace ("ATP : Response formatting character updated ",
1088 44,
1089 NULL_PARAM,
1090 RV_TRACE_LEVEL_DEBUG_LOW,
1091 ATP_USE_ID);
1092
1093 /* Check to see if the S-parameter is requested */
1094 /* to be set to a new value. */
1095 if ((*((T_ATP_ATS4_PARAM **) cmd_info_pp))->s_operator == SET_S_PARAM)
1096 {
1097 (port_p->dce_info_p)->lf_character = (char) ((*((T_ATP_ATS4_PARAM **) cmd_info_pp))->value);
1098 *cmd_type_p = UNKNOWN;
1099 rvf_free_buf (*cmd_info_pp);
1100 *cmd_info_pp = NULL;
1101
1102 /* Interpret the next AT command or result */
1103 /* code to come. */
1104 continue;
1105 }
1106 break;
1107 }
1108
1109 /* Command line editing character. */
1110 case ATP_ATS5_NB:
1111 {
1112
1113 /* Check to see if the specified value is valid */
1114 /* (See ITU-T Recommendation V.250 ter page */
1115 /* 22). */
1116 if ((((*((T_ATP_ATS5_PARAM **) cmd_info_pp))->s_operator != READ_S_PARAM) && \
1117 ((*((T_ATP_ATS5_PARAM **) cmd_info_pp))->s_operator != SET_S_PARAM)) || \
1118 ((*((T_ATP_ATS5_PARAM **) cmd_info_pp))->value > 0x007F))
1119 {
1120 rvf_send_trace ("ATP : Command line editing character invalid ",
1121 45,
1122 NULL_PARAM,
1123 RV_TRACE_LEVEL_WARNING,
1124 ATP_USE_ID);
1125 rvf_free_buf (*cmd_info_pp);
1126 *cmd_info_pp = NULL;
1127 return (RV_NOT_SUPPORTED);
1128 }
1129 rvf_send_trace ("ATP : Command line editing character updated ",
1130 45,
1131 NULL_PARAM,
1132 RV_TRACE_LEVEL_DEBUG_LOW,
1133 ATP_USE_ID);
1134
1135 /* Check to see if the S-parameter is requested */
1136 /* to be set to a new value. */
1137 if ((*((T_ATP_ATS5_PARAM **) cmd_info_pp))->s_operator == SET_S_PARAM)
1138 {
1139 (port_p->dce_info_p)->bs_character = (char) ((*((T_ATP_ATS5_PARAM **) cmd_info_pp))->value);
1140 *cmd_type_p = UNKNOWN;
1141 rvf_free_buf (*cmd_info_pp);
1142 *cmd_info_pp = NULL;
1143
1144 /* Interpret the next AT command or result */
1145 /* code to come. */
1146 continue;
1147 }
1148 break;
1149 }
1150
1151 /* AT command not recognized. */
1152 case ATP_MAX_NB_OF_AT_COMMANDS:
1153 {
1154
1155 /* Get the length of the AT command to be */
1156 /* returned, '\x00' not included. */
1157 ATP_GET_UNKNOWN_AT_CMD_LEN (text_p,
1158 text_length_p,
1159 (port_p->dce_info_p)->cr_character);
1160
1161 /* Allocate memory in order to return the AT */
1162 /* command ('\x00' included). Note that the */
1163 /* prefix must be taken into account. If */
1164 /* insufficient resources available, then */
1165 /* report an internal memory error and abort. */
1166 if (rvf_get_buf (mb_id, \
1167 ATP_AT_PREFIX_LEN + *text_length_p + 0x0001, \
1168 (void **) text_pp) == RVF_RED)
1169 {
1170 atp_error (ATP_ERROR_TX_MB_RED);
1171 ret_status = RV_MEMORY_ERR;
1172 break;
1173 }
1174
1175 /* Copy the prefix into the buffer (See ITU-T */
1176 /* Recommendation V.250 ter page 4). */
1177 memcpy ((void *) *text_pp,
1178 ATP_AT_PREFIX,
1179 ATP_AT_PREFIX_LEN);
1180
1181 /* Then, copy the command line body into the */
1182 /* buffer. */
1183 memcpy ((void *) &((*text_pp)[ATP_AT_PREFIX_LEN]),
1184 (void *) text_p,
1185 *text_length_p);
1186 (*text_pp)[*text_length_p + ATP_AT_PREFIX_LEN] = '\x00';
1187 text_p += *text_length_p;
1188 break;
1189 }
1190
1191 /* Other recognized AT commands. */
1192 default:
1193 {
1194 break;
1195 }
1196 }
1197
1198 /* If the extracted AT command is an extended syntax */
1199 /* command, then update the position of the next character */
1200 /* to be interpreted. */
1201 switch (ATP_AT_INFO[*cmd_nb_p][ATP_AT_PARAM_COLUMN])
1202 {
1203
1204 /* AT command undefined or not supported for now. */
1205 case ATP_CMD_NOT_DEFINED:
1206
1207 /* Extended syntax command does not expect any <value>. */
1208 case ATP_NO_EXTENDED_PARAM:
1209
1210 /* Extended syntax command whose subparameter is a */
1211 /* numeric constant. */
1212 case ATP_SINGLE_EXTENDED_PARAM:
1213
1214 /* Keypad control command. */
1215 case ATP_PLUS_CKPD_PARAM:
1216 {
1217 text_p += ((*text_p == (port_p->dce_info_p)->cr_character) ? (0x0000) : (0x0001));
1218 (port_p->cmd_info).next_position = (UINT16) (text_p - (port_p->cmd_info).cmd_txt_p);
1219 }
1220 default:
1221 {
1222 break;
1223 }
1224 }
1225 break;
1226 }
1227
1228 /* Return raw data as received. */
1229 case UNKNOWN:
1230 {
1231
1232 /* Get the length of raw data to be returned, '\x00' not */
1233 /* included. */
1234 ATP_GET_UNKNOWN_CMD_LEN (text_p,
1235 text_length_p,
1236 (port_p->dce_info_p)->cr_character);
1237
1238 /* Allocate memory in order to return raw data ('\x00' */
1239 /* included). If insufficient resources available, then */
1240 /* report an internal memory error and abort. */
1241 if (rvf_get_buf (mb_id, \
1242 *text_length_p + 0x0001, \
1243 (void **) text_pp) == RVF_RED)
1244 {
1245 atp_error (ATP_ERROR_TX_MB_RED);
1246 ret_status = RV_MEMORY_ERR;
1247 break;
1248 }
1249
1250 /* Copy raw data into the buffer. */
1251 memcpy ((void *) *text_pp,
1252 (void *) text_p,
1253 *text_length_p);
1254 (*text_pp)[*text_length_p] = '\x00';
1255 text_p += *text_length_p;
1256
1257 /* Backup the next character to be interpreted. */
1258 (port_p->cmd_info).next_position = (UINT16) (text_p - (port_p->cmd_info).cmd_txt_p);
1259 break;
1260 }
1261
1262 /* Else, result codes not supported. */
1263 case RESULT_CODE:
1264 case UNSOLICITED_RESULT:
1265 default:
1266 {
1267 break;
1268 }
1269 }
1270 break;
1271 }
1272
1273 /* Then, check to see whether the interpretation is over. */
1274 if (((port_p->cmd_info).cmd_txt_p[(port_p->cmd_info).next_position] == (port_p->dce_info_p)->cr_character) || \
1275 ((port_p->cmd_info).next_position >= (port_p->cmd_info).cmd_txt_length))
1276 {
1277 (port_p->cmd_info).status = FINISHED;
1278 }
1279 return (RV_OK);
1280
1281 } /******************* End of atp_interpret_raw_data function *******************/
1282
1283
1284 /********************************************************************************
1285 * Function name : atp_translate_cmd_to_txt
1286 *
1287 * Description : Translate a command in interpreted format to text format. Buffer
1288 * containing the command is assumed to be BTF buffer and is freed
1289 * by this function. Text buffer is a BTF buffer
1290 *
1291 * Parameters : cmd_type = type of the command (AT_CMD, RESULT_CODE and
1292 * UNSOLICITED_RESULT)
1293 * cmd_nb = binary related code
1294 * cmd_info_p = pointer on the custom command information structure
1295 * mb_id = memory bank used to get the text buffer
1296 * text_pp = pointer on the text chain (0-terminated)
1297 * text_length_p = length of the text chain, '\x00' not included
1298 *
1299 * Return : RV_OK,
1300 * RV_NOT_SUPPORTED if the command is not recognized
1301 *
1302 * History : 0.1 (25-August-2000) - Created
1303 *
1304 *********************************************************************************/
1305 T_ATP_RET atp_translate_cmd_to_txt (T_ATP_CMD_TYPE cmd_type,
1306 T_ATP_CMD_NB cmd_nb,
1307 T_ATP_CMD *cmd_info_p,
1308 T_RVF_MB_ID mb_id,
1309 T_ATP_TXT_CMD *text_pp,
1310 UINT16 *text_length_p)
1311 {
1312 /* Declare local variables. */
1313 const char *table = NULL;
1314 UINT16 offset = 0x0000;
1315 T_ATP_RET ret_status = RV_OK;
1316
1317 /******************* atp_translate_cmd_to_txt function begins *******************/
1318
1319 switch (cmd_type)
1320 {
1321
1322 /* Translate AT commands into text. */
1323 case AT_CMD:
1324 {
1325 rvf_send_trace ("ATP : Translate an AT command into text ",
1326 40,
1327 NULL_PARAM,
1328 RV_TRACE_LEVEL_DEBUG_LOW,
1329 ATP_USE_ID);
1330 table = ATP_AT_TXT_TABLE;
1331
1332 /* Get the related offset. */
1333 offset = ATP_AT_INFO[cmd_nb][ATP_AT_OFFSET_COLUMN];
1334
1335 /* Get the length of the AT command. */
1336 *text_length_p = (UINT16) (ATP_AT_PREFIX_LEN + \
1337 ATP_AT_INFO[cmd_nb + 0x01][ATP_AT_OFFSET_COLUMN] - ATP_AT_INFO[cmd_nb][ATP_AT_OFFSET_COLUMN]);
1338
1339 /* Get the related structure. */
1340 switch (ATP_AT_INFO[cmd_nb][ATP_AT_PARAM_COLUMN])
1341 {
1342
1343 /* Basic syntax command does not expect any <number>. */
1344 case ATP_NO_PARAM:
1345 {
1346
1347 /* Create a buffer and copy text string into it */
1348 /* ('\x00' included). If insufficient resources */
1349 /* available, then report an internal memory error */
1350 /* and abort. */
1351 if (rvf_get_buf (mb_id, \
1352 *text_length_p + 0x0001, \
1353 (void **) text_pp) == RVF_RED)
1354 {
1355 atp_error (ATP_ERROR_TX_MB_RED);
1356 ret_status = RV_MEMORY_ERR;
1357 break;
1358 }
1359
1360 /* Copy the command line prefix into the buffer. */
1361 memcpy ((void *) (*text_pp),
1362 ATP_AT_PREFIX,
1363 ATP_AT_PREFIX_LEN);
1364
1365 /* Copy the text into the buffer. */
1366 memcpy ((void *) &((*text_pp)[ATP_AT_PREFIX_LEN]),
1367 (void *) &(table[offset]),
1368 *text_length_p - ATP_AT_PREFIX_LEN);
1369 (*text_pp)[*text_length_p] = '\x00';
1370 break;
1371 }
1372
1373 /* Basic syntax command. */
1374 case ATP_BASIC_PARAM:
1375 {
1376
1377 /* Declare a local block variable. */
1378 T_ATP_BASIC_CMD *basic_cmd_param_p = (T_ATP_BASIC_CMD *) cmd_info_p;
1379
1380 /* Create a buffer and copy text string into it */
1381 /* ('\x00' included). If insufficient resources */
1382 /* available, then report an internal memory error */
1383 /* and abort. */
1384 if (rvf_get_buf (mb_id, \
1385 *text_length_p + MAX_BASIC_CMD_PARAM_LEN + 0x0001, \
1386 (void **) text_pp) == RVF_RED)
1387 {
1388 atp_error (ATP_ERROR_TX_MB_RED);
1389 ret_status = RV_MEMORY_ERR;
1390 break;
1391 }
1392
1393 /* Copy the command line prefix into the buffer. */
1394 memcpy ((void *) (*text_pp),
1395 ATP_AT_PREFIX,
1396 ATP_AT_PREFIX_LEN);
1397
1398 /* Copy the text into the buffer. */
1399 memcpy ((void *) &((*text_pp)[ATP_AT_PREFIX_LEN]),
1400 (void *) &(table[offset]),
1401 *text_length_p - ATP_AT_PREFIX_LEN);
1402
1403 /* If needed, copy the buffer describing the */
1404 /* command in interpreted format and free it. */
1405 if (basic_cmd_param_p != NULL)
1406 {
1407 *text_length_p = (UINT16) (*text_length_p + \
1408 dtoa (basic_cmd_param_p->number,
1409 &((*text_pp)[*text_length_p])));
1410 }
1411 (*text_pp)[*text_length_p] = '\x00';
1412 break;
1413 }
1414
1415 /* Dial. */
1416 case ATP_DIAL_PARAM:
1417 {
1418
1419 /* Declare local block variables. */
1420 UINT8 dial_param_length = 0x00;
1421 UINT8 dial_semicolon = DATA_CALL;
1422 T_ATP_DIAL *dial_param_p = (T_ATP_DIAL *) cmd_info_p;
1423
1424 /* If needed, take the buffer describing the */
1425 /* command in interpreted format into account. */
1426 if (dial_param_p != NULL)
1427 {
1428 dial_param_length = dial_param_p->dial_string_length;
1429 dial_semicolon = (UINT8) (dial_param_p->call_type);
1430 }
1431
1432 /* Create a buffer and copy text string into it */
1433 /* ('\x00' included). If insufficient resources */
1434 /* available, then report an internal memory error */
1435 /* and abort. */
1436 if (rvf_get_buf (mb_id, \
1437 *text_length_p + dial_param_length + dial_semicolon + 0x0001, \
1438 (void **) text_pp) == RVF_RED)
1439 {
1440 atp_error (ATP_ERROR_TX_MB_RED);
1441 ret_status = RV_MEMORY_ERR;
1442 break;
1443 }
1444
1445 /* Copy the command line prefix into the buffer. */
1446 memcpy ((void *) (*text_pp),
1447 ATP_AT_PREFIX,
1448 ATP_AT_PREFIX_LEN);
1449
1450 /* Copy the text into the buffer. */
1451 memcpy ((void *) &((*text_pp)[ATP_AT_PREFIX_LEN]),
1452 (void *) &(table[offset]),
1453 *text_length_p - ATP_AT_PREFIX_LEN);
1454
1455 /* If needed, copy the buffer describing the */
1456 /* command in interpreted format and free it. */
1457 if (dial_param_p != NULL)
1458 {
1459 memcpy ((void *) &((*text_pp)[*text_length_p]),
1460 (void *) (dial_param_p->dial_string_p),
1461 dial_param_length);
1462 if (dial_semicolon == VOICE_CALL)
1463 {
1464 (*text_pp)[*text_length_p + dial_param_length] = ';';
1465 }
1466 *text_length_p = (UINT16) (*text_length_p + \
1467 dial_param_length + dial_semicolon);
1468 }
1469 (*text_pp)[*text_length_p] = '\x00';
1470 break;
1471 }
1472
1473 /* S-parameter. */
1474 case ATP_S_PARAM:
1475 {
1476
1477 /* Declare a local block variable. */
1478 T_ATP_S_PARAM *s_param_p = (T_ATP_S_PARAM *) cmd_info_p;
1479
1480 /* Create a buffer and copy text string into it */
1481 /* ('\x00' included). If insufficient resources */
1482 /* available, then report an internal memory error */
1483 /* and abort. */
1484 if (rvf_get_buf (mb_id, \
1485 *text_length_p + MAX_S_PARAM_LEN + 0x0001,
1486 (void **) text_pp) == RVF_RED)
1487 {
1488 atp_error (ATP_ERROR_TX_MB_RED);
1489 ret_status = RV_MEMORY_ERR;
1490 break;
1491 }
1492
1493 /* Copy the command line prefix into the buffer. */
1494 memcpy ((void *) (*text_pp),
1495 ATP_AT_PREFIX,
1496 ATP_AT_PREFIX_LEN);
1497
1498 /* Copy the text into the buffer. */
1499 memcpy ((void *) &((*text_pp)[ATP_AT_PREFIX_LEN]),
1500 (void *) &(table[offset]),
1501 *text_length_p - ATP_AT_PREFIX_LEN);
1502
1503 /* If needed, copy the buffer describing the */
1504 /* command in interpreted format and free it. */
1505 if (s_param_p == NULL)
1506 {
1507 (*text_pp)[*text_length_p] = '\x00';
1508 break;
1509 }
1510 switch (s_param_p->s_operator)
1511 {
1512
1513 /* Parameter read command syntax. */
1514 case READ_S_PARAM:
1515 {
1516 (*text_pp)[(*text_length_p)++] = '?';
1517 (*text_pp)[*text_length_p] = '\x00';
1518 break;
1519 }
1520
1521 /* Parameter set command syntax. */
1522 case SET_S_PARAM:
1523 {
1524 (*text_pp)[(*text_length_p)++] = '=';
1525 *text_length_p = (UINT16) (*text_length_p + \
1526 dtoa (s_param_p->value,
1527 &((*text_pp)[*text_length_p])));
1528 (*text_pp)[*text_length_p] = '\x00';
1529 break;
1530 }
1531 default:
1532 {
1533 rvf_free_buf (*text_pp);
1534 *text_pp = NULL;
1535 ret_status = RV_NOT_SUPPORTED;
1536 break;
1537 }
1538 }
1539 break;
1540 }
1541
1542 /* Extended syntax command does not expect any <value>. */
1543 case ATP_NO_EXTENDED_PARAM:
1544 {
1545
1546 /* Declare a local block variable. */
1547 T_ATP_NO_SUBPARAMETER *extended_cmd_param_p = (T_ATP_NO_SUBPARAMETER *) cmd_info_p;
1548
1549 /* Create a buffer and copy text string into it */
1550 /* ('\x00' included). If insufficient resources */
1551 /* available, then report an internal memory error */
1552 /* and abort. */
1553 if (rvf_get_buf (mb_id, \
1554 *text_length_p + MAX_NO_SUBPARAMETER_LEN + 0x0001, \
1555 (void **) text_pp) == RVF_RED)
1556 {
1557 atp_error (ATP_ERROR_TX_MB_RED);
1558 ret_status = RV_MEMORY_ERR;
1559 break;
1560 }
1561
1562 /* Copy the command line prefix into the buffer. */
1563 memcpy ((void *) (*text_pp),
1564 ATP_AT_PREFIX,
1565 ATP_AT_PREFIX_LEN);
1566
1567 /* Copy the text into the buffer. */
1568 memcpy ((void *) &((*text_pp)[ATP_AT_PREFIX_LEN]),
1569 (void *) &(table[offset]),
1570 *text_length_p - ATP_AT_PREFIX_LEN);
1571
1572 /* If needed, copy the buffer describing the */
1573 /* command in interpreted format and free it. */
1574 if (extended_cmd_param_p == NULL)
1575 {
1576 (*text_pp)[*text_length_p] = '\x00';
1577 break;
1578 }
1579 switch (extended_cmd_param_p->extended_operator)
1580 {
1581
1582 /* No subparameter. */
1583 case NO_SUBPARAMETER:
1584 {
1585 (*text_pp)[*text_length_p] = '\x00';
1586 break;
1587 }
1588
1589 /* Action test command syntax. */
1590 case TEST_EXTENDED_CMD:
1591 {
1592 (*text_pp)[(*text_length_p)++] = '=';
1593 (*text_pp)[(*text_length_p)++] = '?';
1594 (*text_pp)[*text_length_p] = '\x00';
1595 break;
1596 }
1597 default:
1598 {
1599 rvf_free_buf (*text_pp);
1600 *text_pp = NULL;
1601 ret_status = RV_NOT_SUPPORTED;
1602 break;
1603 }
1604 }
1605 break;
1606 }
1607
1608 /* Extended syntax command whose subparameter is a numeric */
1609 /* constant. */
1610 case ATP_SINGLE_EXTENDED_PARAM:
1611 {
1612
1613 /* Declare a local block variable. */
1614 T_ATP_SINGLE_SUBPARAMETER *extended_cmd_param_p = (T_ATP_SINGLE_SUBPARAMETER *) cmd_info_p;
1615
1616 /* Create a buffer and copy text string into it */
1617 /* ('\x00' included). If insufficient resources */
1618 /* available, then report an internal memory error */
1619 /* and abort. */
1620 if (rvf_get_buf (mb_id, \
1621 *text_length_p + MAX_SINGLE_SUBPARAMETER_LEN + 0x0001, \
1622 (void **) text_pp) == RVF_RED)
1623 {
1624 atp_error (ATP_ERROR_TX_MB_RED);
1625 ret_status = RV_MEMORY_ERR;
1626 break;
1627 }
1628
1629 /* Copy the command line prefix into the buffer. */
1630 memcpy ((void *) (*text_pp),
1631 ATP_AT_PREFIX,
1632 ATP_AT_PREFIX_LEN);
1633
1634 /* Copy the text into the buffer. */
1635 memcpy ((void *) &((*text_pp)[ATP_AT_PREFIX_LEN]),
1636 (void *) &(table[offset]),
1637 *text_length_p - ATP_AT_PREFIX_LEN);
1638
1639 /* If needed, copy the buffer describing the */
1640 /* command in interpreted format and free it. */
1641 if (extended_cmd_param_p == NULL)
1642 {
1643 (*text_pp)[*text_length_p] = '\x00';
1644 break;
1645 }
1646 switch (extended_cmd_param_p->extended_operator)
1647 {
1648
1649 /* No subparameter. */
1650 case NO_SUBPARAMETER:
1651 {
1652 (*text_pp)[*text_length_p] = '\x00';
1653 break;
1654 }
1655
1656 /* Action test command syntax. */
1657 case TEST_EXTENDED_CMD:
1658 {
1659 (*text_pp)[(*text_length_p)++] = '=';
1660 }
1661
1662 /* Parameter read command syntax. */
1663 case READ_EXTENDED_CMD:
1664 {
1665 (*text_pp)[(*text_length_p)++] = '?';
1666 (*text_pp)[*text_length_p] = '\x00';
1667 break;
1668 }
1669
1670 /* Parameter set command syntax. */
1671 case SET_EXTENDED_CMD:
1672 {
1673 (*text_pp)[(*text_length_p)++] = '=';
1674 *text_length_p = (UINT16) (*text_length_p + \
1675 dtoa (extended_cmd_param_p->value,
1676 &((*text_pp)[*text_length_p])));
1677 (*text_pp)[*text_length_p] = '\x00';
1678 break;
1679 }
1680 default:
1681 {
1682 rvf_free_buf (*text_pp);
1683 *text_pp = NULL;
1684 ret_status = RV_NOT_SUPPORTED;
1685 break;
1686 }
1687 }
1688 break;
1689 }
1690
1691 /* Keypad control command. Note that <keys> is a string of */
1692 /* characters representing keys (See See ETS 300 916 (GSM */
1693 /* 07.07) Version 5.8.1 page 62). Colon character followed */
1694 /* by one character can be used to indicate a manufacturer */
1695 /* specific key not listed here. All characters from a */
1696 /* semicolon character to the next single semicolon */
1697 /* character are treated as alpha entries and are not */
1698 /* converted to key equivalents. All semicolon characters */
1699 /* inside alpha entries should be duplicated in the DTE. */
1700 /* Pause characters "W" and "w" can be used to pause */
1701 /* between key pressings for a time specified by <pause>. */
1702 case ATP_PLUS_CKPD_PARAM:
1703 {
1704
1705 /* Declare local block variables. */
1706 UINT8 nb_keypressed = 0x00;
1707 T_ATP_PLUS_CKPD *ckpd_param_p = (T_ATP_PLUS_CKPD *) cmd_info_p;
1708
1709 /* Create a buffer and copy text string into it */
1710 /* ('\x00' included). If insufficient resources */
1711 /* available, then report an internal memory error */
1712 /* and abort. */
1713 if (rvf_get_buf (mb_id, \
1714 *text_length_p + MAX_CKPD_PARAM_LEN + 0x0001, \
1715 (void **) text_pp) == RVF_RED)
1716 {
1717 atp_error (ATP_ERROR_TX_MB_RED);
1718 ret_status = RV_MEMORY_ERR;
1719 break;
1720 }
1721
1722 /* Copy the command line prefix into the buffer. */
1723 memcpy ((void *) (*text_pp),
1724 ATP_AT_PREFIX,
1725 ATP_AT_PREFIX_LEN);
1726
1727 /* Copy the text into the buffer. */
1728 memcpy ((void *) &((*text_pp)[ATP_AT_PREFIX_LEN]),
1729 (void *) &(table[offset]),
1730 *text_length_p - ATP_AT_PREFIX_LEN);
1731
1732 /* If needed, copy the buffer describing the */
1733 /* command in interpreted format and free it. */
1734 if (ckpd_param_p == NULL)
1735 {
1736 (*text_pp)[*text_length_p] = '\x00';
1737 break;
1738 }
1739 switch (ckpd_param_p->extended_operator)
1740 {
1741
1742 /* Action test command syntax. */
1743 case TEST_EXTENDED_CMD:
1744 {
1745 (*text_pp)[(*text_length_p)++] = '=';
1746 (*text_pp)[(*text_length_p)++] = '?';
1747 (*text_pp)[*text_length_p] = '\x00';
1748 break;
1749 }
1750
1751 /* Parameter set command syntax. */
1752 case SET_EXTENDED_CMD:
1753 {
1754 (*text_pp)[(*text_length_p)++] = '=';
1755 (*text_pp)[(*text_length_p)++] = '"';
1756
1757 /* Store each keypressed into the */
1758 /* buffer. */
1759 for (nb_keypressed = 0x00;
1760 nb_keypressed < ckpd_param_p->nb_keys;
1761 nb_keypressed++)
1762 {
1763 (*text_pp)[(*text_length_p)++] = ';';
1764 *text_length_p = (UINT16) (*text_length_p + \
1765 dtoa (ckpd_param_p->keys[nb_keypressed],
1766 &((*text_pp)[*text_length_p])));
1767 (*text_pp)[(*text_length_p)++] = ';';
1768 }
1769 (*text_pp)[(*text_length_p)++] = '"';
1770
1771 /* Store <time> subparameter into the */
1772 /* buffer. */
1773 (*text_pp)[(*text_length_p)++] = ',';
1774 if ((ckpd_param_p->pause != DEFAULT_TIME) || \
1775 (ckpd_param_p->pause != TIME_DO_NOT_CARE))
1776 {
1777 *text_length_p = (UINT16) (*text_length_p + \
1778 dtoa (ckpd_param_p->time,
1779 &((*text_pp)[*text_length_p])));
1780 }
1781
1782 /* Store <pause> subparameter into the */
1783 /* buffer. */
1784 (*text_pp)[(*text_length_p)++] = ',';
1785 if ((ckpd_param_p->pause != DEFAULT_PAUSE) || \
1786 (ckpd_param_p->pause != PAUSE_DO_NOT_CARE))
1787 {
1788 *text_length_p = (UINT16) (*text_length_p + \
1789 dtoa (ckpd_param_p->pause,
1790 &((*text_pp)[*text_length_p])));
1791 }
1792 (*text_pp)[*text_length_p] = '\x00';
1793 break;
1794 }
1795 default:
1796 {
1797 rvf_free_buf (*text_pp);
1798 *text_pp = NULL;
1799 ret_status = RV_NOT_SUPPORTED;
1800 break;
1801 }
1802 }
1803 break;
1804 }
1805 default:
1806 {
1807 rvf_send_trace ("ATP : Received an unknown command ",
1808 34,
1809 NULL_PARAM,
1810 RV_TRACE_LEVEL_WARNING,
1811 ATP_USE_ID);
1812 *text_pp = NULL;
1813 ret_status = RV_NOT_SUPPORTED;
1814 break;
1815 }
1816 }
1817 break;
1818 }
1819
1820 /* Translate DCE responses into text (See ITU-T Recommendation V.250 */
1821 /* ter page 10). */
1822 case RESULT_CODE:
1823 case UNSOLICITED_RESULT:
1824 {
1825 rvf_send_trace ("ATP : Translate a result into text ",
1826 35,
1827 NULL_PARAM,
1828 RV_TRACE_LEVEL_DEBUG_LOW,
1829 ATP_USE_ID);
1830 table = ATP_RESULT_CODE_TXT_TABLE_V1;
1831
1832 /* Get the related offset. */
1833 offset = ATP_RESULT_CODE_INFO[cmd_nb][ATP_RESULT_OFFSET_V1_COLUMN];
1834
1835 /* Get the length of the result code. */
1836 *text_length_p = (UINT16) (ATP_RESULT_CODE_INFO[cmd_nb + 0x01][ATP_RESULT_OFFSET_V1_COLUMN] - ATP_RESULT_CODE_INFO[cmd_nb][ATP_RESULT_OFFSET_V1_COLUMN]);
1837
1838 /* Get the related structure. */
1839 switch (ATP_RESULT_CODE_INFO[cmd_nb][ATP_RESULT_PARAM_COLUMN])
1840 {
1841
1842 /* Basic syntax result code. */
1843 case ATP_BASIC_RESULT_CODE:
1844 {
1845
1846 /* Create a buffer and copy text string into it */
1847 /* ('\x00' included). If insufficient resources */
1848 /* available, then report an internal memory error */
1849 /* and abort. */
1850 if (rvf_get_buf (mb_id, \
1851 *text_length_p + 0x0001, \
1852 (void **) text_pp) == RVF_RED)
1853 {
1854 atp_error (ATP_ERROR_TX_MB_RED);
1855 ret_status = RV_MEMORY_ERR;
1856 break;
1857 }
1858
1859 /* Copy text into the buffer. */
1860 memcpy ((void *) (*text_pp),
1861 (void *) &(table[offset]),
1862 *text_length_p);
1863 (*text_pp)[*text_length_p] = '\x00';
1864 break;
1865 }
1866
1867 /* Extended syntax result code. */
1868 case ATP_EXTENDED_RESULT_CODE:
1869 {
1870
1871 /* Declare a local block variable. */
1872 T_ATP_SINGLE_RESULT_CODE_VALUE *result_code_param_p = (T_ATP_SINGLE_RESULT_CODE_VALUE *) cmd_info_p;
1873
1874 /* Create a buffer and copy text string into it */
1875 /* ('=' and '\x00' included). If insufficient */
1876 /* resources available, then report an internal */
1877 /* memory error and abort. */
1878 if (rvf_get_buf (mb_id, \
1879 *text_length_p + MAX_SINGLE_RESULT_CODE_VALUE_LEN + 0x0002, \
1880 (void **) text_pp) == RVF_RED)
1881 {
1882 atp_error (ATP_ERROR_TX_MB_RED);
1883 ret_status = RV_MEMORY_ERR;
1884 break;
1885 }
1886
1887 /* Copy text into the buffer. */
1888 memcpy ((void *) (*text_pp),
1889 (void *) &(table[offset]),
1890 *text_length_p);
1891
1892 /* If needed, copy the buffer describing the */
1893 /* command in interpreted format and free it. */
1894 if (result_code_param_p != NULL)
1895 {
1896 (*text_pp)[(*text_length_p)++] = '=';
1897 *text_length_p = (UINT16) (*text_length_p + \
1898 dtoa (result_code_param_p->value,
1899 &((*text_pp)[*text_length_p])));
1900 }
1901 (*text_pp)[*text_length_p] = '\x00';
1902 break;
1903 }
1904
1905 /* CONNECT <text> result code. */
1906 case ATP_CONNECT_TXT_PARAM:
1907 {
1908
1909 /* Declare a local block variable. */
1910 T_ATP_CONNECT_TXT_PARAM *connect_txt_param_p = (T_ATP_CONNECT_TXT_PARAM *) cmd_info_p;
1911
1912 /* Create a buffer and copy text string into it */
1913 /* (' ' and '\x00' included). If insufficient */
1914 /* resources available, then report an internal */
1915 /* memory error and abort. */
1916 if (rvf_get_buf (mb_id, \
1917 *text_length_p + MAX_CONNECT_TXT_LEN + 0x0002, \
1918 (void **) text_pp) == RVF_RED)
1919 {
1920 atp_error (ATP_ERROR_TX_MB_RED);
1921 ret_status = RV_MEMORY_ERR;
1922 break;
1923 }
1924
1925 /* Copy text into the buffer. */
1926 memcpy ((void *) (*text_pp),
1927 (void *) &(table[offset]),
1928 *text_length_p);
1929
1930 /* If needed, copy the buffer describing the */
1931 /* command in interpreted format and free it. */
1932 if (connect_txt_param_p != NULL)
1933 {
1934 (*text_pp)[(*text_length_p)++] = ' ';
1935 *text_length_p = (UINT16) (*text_length_p + \
1936 dtoa (connect_txt_param_p->value,
1937 &((*text_pp)[*text_length_p])));
1938 }
1939 (*text_pp)[*text_length_p] = '\x00';
1940 break;
1941 }
1942
1943 /* +CME ERROR: <error> and +CMS ERROR: <error> result */
1944 /* codes. */
1945 case ATP_PLUS_ERROR_RESULT_CODE:
1946 {
1947
1948 /* Declare local block variables. */
1949 UINT8 error_length = 0x00;
1950 T_ATP_PLUS_ERROR_RESULT_CODE *plus_error_result_code_p = cmd_info_p;
1951
1952 /* If needed, take the buffer describing the */
1953 /* command in interpreted format into account. */
1954 if (plus_error_result_code_p != NULL)
1955 {
1956 error_length = plus_error_result_code_p->error_length;
1957 }
1958
1959 /* Create a buffer and copy text string into it */
1960 /* (' ' and '\x00' included). If insufficient */
1961 /* resources available, then report an internal */
1962 /* memory error and abort. */
1963 if (rvf_get_buf (mb_id, \
1964 *text_length_p + error_length + 0x0002, \
1965 (void **) text_pp) == RVF_RED)
1966 {
1967 atp_error (ATP_ERROR_TX_MB_RED);
1968 ret_status = RV_MEMORY_ERR;
1969 break;
1970 }
1971
1972 /* Copy the command line prefix into the buffer. */
1973 memcpy ((void *) (*text_pp),
1974 ATP_AT_PREFIX,
1975 ATP_AT_PREFIX_LEN);
1976
1977 /* Copy the text into the buffer. */
1978 memcpy ((void *) &((*text_pp)[ATP_AT_PREFIX_LEN]),
1979 (void *) &(table[offset]),
1980 *text_length_p - ATP_AT_PREFIX_LEN);
1981
1982 /* If needed, copy the buffer describing the */
1983 /* command in interpreted format and free it. */
1984 if (plus_error_result_code_p != NULL)
1985 {
1986 (*text_pp)[(*text_length_p)++] = ' ';
1987 memcpy ((void *) &((*text_pp)[*text_length_p]),
1988 (void *) (plus_error_result_code_p->error_p),
1989 error_length);
1990 *text_length_p = (UINT16) (*text_length_p + \
1991 error_length);
1992 }
1993 (*text_pp)[*text_length_p] = '\x00';
1994 break;
1995 }
1996 default:
1997 {
1998 rvf_send_trace ("ATP : Received an unknown command ",
1999 34,
2000 NULL_PARAM,
2001 RV_TRACE_LEVEL_WARNING,
2002 ATP_USE_ID);
2003 *text_pp = NULL;
2004 ret_status = RV_NOT_SUPPORTED;
2005 break;
2006 }
2007 }
2008 break;
2009 }
2010 default:
2011 {
2012 rvf_send_trace ("ATP : Received an unknown command ",
2013 34,
2014 NULL_PARAM,
2015 RV_TRACE_LEVEL_WARNING,
2016 ATP_USE_ID);
2017 *text_pp = NULL;
2018 ret_status = RV_NOT_SUPPORTED;
2019 break;
2020 }
2021 }
2022
2023 /* If needed, free the buffer describing the command in interpreted format. */
2024 if (cmd_info_p != NULL)
2025 {
2026 rvf_free_buf (cmd_info_p);
2027 cmd_info_p = NULL;
2028 }
2029 return (ret_status);
2030
2031 } /****************** End of atp_translate_cmd_to_txt function ******************/
2032
2033
2034 /********************************************************************************
2035 * Function name : atp_copy_buffer
2036 *
2037 * Description : Copy 'data size' bytes of 'in buffer' to 'out buffer'
2038 *
2039 * Parameters : in_buffer_p = buffer to copy from
2040 * out_buffer_p = new buffer
2041 * data_size = number of bytes to be copied
2042 *
2043 * Return : RV_OK
2044 *
2045 * History : 0.1 (05-May-2000) - Created
2046 *
2047 *********************************************************************************/
2048 T_ATP_RET atp_copy_buffer (UINT8 *in_buffer_p,
2049 UINT8 *out_buffer_p,
2050 UINT32 data_size)
2051 {
2052
2053 /************************ atp_copy_buffer function begins ***********************/
2054
2055 memcpy ((void *) out_buffer_p,
2056 (void *) in_buffer_p,
2057 data_size);
2058 return (RV_OK);
2059
2060 } /*********************** End of atp_copy_buffer function **********************/
2061
2062
2063 /********************************************************************************
2064 * Function name : atp_create_data_buffer_from_cmd
2065 *
2066 * Description : create a data buffer based on port features and on the command
2067 * which is interpreted or in text format
2068 *
2069 * Parameters : cmd_mode = interpreted or text
2070 * header = header size
2071 * trailer = trailer size
2072 * dce_info_p = pointer on the DCE information
2073 * mb_id = memory bank used to get the data buffer
2074 * cmd_type = type of the command
2075 * cmd_nb = related binary code of the command (not used if TXT
2076 * format)
2077 * text_p = pointer on the text string (0-terminated) (not used
2078 * if INTERPRETED format)
2079 * cmd_info_p = pointer on the custom command information structure
2080 * (not used if TXT format)
2081 * buffer_pp = pointer on the data buffer generated by the function
2082 * length_p = length of the data buffer
2083 *
2084 * Return : RV_OK,
2085 * RV_NOT_SUPPORTED if the command is not recognized
2086 *
2087 * History : 0.1 (01-March-2000) - Created
2088 *
2089 *********************************************************************************/
2090 T_ATP_RET atp_create_data_buffer_from_cmd (T_ATP_CMD_MODE cmd_mode,
2091 UINT16 header,
2092 UINT16 trailer,
2093 T_ATP_DCE_INFO *dce_info_p,
2094 T_RVF_MB_ID mb_id,
2095 T_ATP_CMD_TYPE cmd_type,
2096 T_ATP_CMD_NB cmd_nb,
2097 T_ATP_TXT_CMD text_p,
2098 T_ATP_CMD *cmd_info_p,
2099 T_ATP_BUFFER *buffer_pp,
2100 UINT16 *length_p)
2101 {
2102 /* Declare local variables. */
2103 UINT16 txt_length = 0x0000;
2104 T_ATP_BUFFER atp_buffer_p = NULL;
2105 T_ATP_TXT_CMD text_cmd_p = NULL;
2106
2107 /**************** atp_create_data_buffer_from_cmd function begins ***************/
2108
2109 /* Need to have the command type provided. */
2110 if (cmd_type == UNKNOWN)
2111 {
2112 return (RV_NOT_SUPPORTED);
2113 }
2114
2115 /* Get text version of the AT command and point on it via text_cmd_p. If */
2116 /* the command has been provided already in text format, then... */
2117 if (cmd_mode == TXT_MODE)
2118 {
2119 text_cmd_p = text_p;
2120
2121 /* The length does not include '\x00'. */
2122 txt_length = (UINT16) (strlen (text_cmd_p));
2123 }
2124 else
2125 {
2126
2127 /* Declare a local block variable. */
2128 T_ATP_RET ret_status = RV_OK;
2129
2130 /* Translate the command into text. */
2131 ret_status = atp_translate_cmd_to_txt (cmd_type,
2132 cmd_nb,
2133 cmd_info_p,
2134 mb_id,
2135 &text_cmd_p,
2136 &txt_length);
2137
2138 /* If any error occurred, then abort. */
2139 if (ret_status != RV_OK)
2140 {
2141 return (RV_NOT_SUPPORTED);
2142 }
2143 }
2144
2145 /* Create real buffer to send for a AT Command. */
2146 switch (dce_info_p->verbose_mode)
2147 {
2148
2149 /* Verbose responses enabled. */
2150 case ATP_VERBOSE_0:
2151 {
2152 switch (cmd_type)
2153 {
2154
2155 /* DCE responses (See ITU-T Recommendation V.250 ter page */
2156 /* 10). */
2157 case RESULT_CODE:
2158 case UNSOLICITED_RESULT:
2159 {
2160 *length_p = (UINT16) (trailer + header + 0x0002);
2161
2162 /* Create buffer and copy text string into it. If */
2163 /* insufficient resources available, then report an */
2164 /* internal memory error and abort. */
2165 if (rvf_get_buf (mb_id, \
2166 *length_p, \
2167 (void **) buffer_pp) == RVF_RED)
2168 {
2169 *length_p = 0x0000;
2170 atp_error (ATP_ERROR_TX_MB_RED);
2171 return (RV_MEMORY_ERR);
2172 }
2173 atp_buffer_p = *buffer_pp;
2174
2175 /* Add code. */
2176 atp_buffer_p[header] = (char) (cmd_nb + '0');
2177
2178 /* Add special characters. */
2179 atp_buffer_p[header + 0x0001] = dce_info_p->cr_character;
2180
2181 /* Release text buffer. */
2182 rvf_free_buf (text_cmd_p);
2183 return (RV_OK);
2184 }
2185 case PRELIMINARY_RESULT_CODE:
2186 {
2187
2188 /* Add 2 special characters <CR> and <LF>. */
2189 *length_p = (UINT16) (trailer + header + txt_length + 0x0002);
2190
2191 /* Create buffer and copy text string into it. If */
2192 /* insufficient resources available, then report an */
2193 /* internal memory error and abort. */
2194 if (rvf_get_buf (mb_id, \
2195 *length_p, \
2196 (void **) buffer_pp) == RVF_RED)
2197 {
2198 *length_p = 0x0000;
2199 atp_error (ATP_ERROR_TX_MB_RED);
2200 return (RV_MEMORY_ERR);
2201 }
2202 atp_buffer_p = *buffer_pp;
2203
2204 /* Copy text into the buffer. */
2205 memcpy ((void *) (atp_buffer_p + header),
2206 (void *) text_cmd_p,
2207 txt_length);
2208
2209 /* Add special characters. */
2210 atp_buffer_p[header + txt_length] = dce_info_p->cr_character;
2211 atp_buffer_p[header + txt_length + 0x0001] = dce_info_p->lf_character;
2212
2213 /* Release text buffer. */
2214 rvf_free_buf (text_cmd_p);
2215 return (RV_OK);
2216 }
2217 default:
2218 {
2219 break;
2220 }
2221 }
2222 }
2223
2224 /* Verbose responses disabled. */
2225 case ATP_VERBOSE_1:
2226 {
2227 switch (cmd_type)
2228 {
2229
2230 /* DTE command lines (See ITU-T Recommendation V.250 ter */
2231 /* page 4). */
2232 case AT_CMD:
2233 {
2234
2235 /* The buffer contains AT command and <CR> */
2236 /* character. */
2237 *length_p = (UINT16) (trailer + header + txt_length + 0x0001);
2238
2239 /* Create buffer and copy text string into it. If */
2240 /* insufficient resources available, then report an */
2241 /* internal memory error and abort. */
2242 if (rvf_get_buf (mb_id, \
2243 *length_p, \
2244 (void **) buffer_pp) == RVF_RED)
2245 {
2246 *length_p = 0x0000;
2247 atp_error (ATP_ERROR_TX_MB_RED);
2248 return (RV_MEMORY_ERR);
2249 }
2250 atp_buffer_p = *buffer_pp;
2251
2252 /* Copy text into the buffer. */
2253 memcpy ((void *) (atp_buffer_p + header),
2254 (void *) text_cmd_p,
2255 txt_length);
2256
2257 /* Add special characters. */
2258 atp_buffer_p[header + txt_length] = dce_info_p->cr_character;
2259
2260 /* Release text buffer. */
2261 rvf_free_buf (text_cmd_p);
2262 return (RV_OK);
2263 }
2264
2265 /* DCE responses (See ITU-T Recommendation V.250 ter page */
2266 /* 10). */
2267 case RESULT_CODE:
2268 case UNSOLICITED_RESULT:
2269 case PRELIMINARY_RESULT_CODE:
2270 {
2271
2272 /* Add 4 special characters <CR> and <LF> (twice). */
2273 *length_p = (UINT16) (trailer + header + txt_length + 0x0004);
2274
2275 /* Create buffer and copy text string into it. If */
2276 /* insufficient resources available, then report an */
2277 /* internal memory error and abort. */
2278 if (rvf_get_buf (mb_id, \
2279 *length_p, \
2280 (void **) buffer_pp) == RVF_RED)
2281 {
2282 *length_p = 0x0000;
2283 atp_error (ATP_ERROR_TX_MB_RED);
2284 return (RV_MEMORY_ERR);
2285 }
2286 atp_buffer_p = *buffer_pp;
2287
2288 /* Copy text into the buffer. */
2289 memcpy ((void *) (atp_buffer_p + header + 0x0002),
2290 (void *) text_cmd_p,
2291 txt_length);
2292
2293 /* Add special characters. */
2294 atp_buffer_p[header] = dce_info_p->cr_character;
2295 atp_buffer_p[header + 0x0001] = dce_info_p->lf_character;
2296 atp_buffer_p[header + txt_length + 0x0002] = dce_info_p->cr_character;
2297 atp_buffer_p[header + txt_length + 0x0003] = dce_info_p->lf_character;
2298
2299 /* Release text buffer. */
2300 rvf_free_buf (text_cmd_p);
2301 return (RV_OK);
2302 }
2303 default:
2304 {
2305 rvf_send_trace ("ATP : Tried to create a buffer for an unknown command ",
2306 54,
2307 NULL_PARAM,
2308 RV_TRACE_LEVEL_WARNING,
2309 ATP_USE_ID);
2310 *length_p = 0x0000;
2311 *buffer_pp = NULL;
2312 break;
2313 }
2314 }
2315 break;
2316 }
2317 default:
2318 {
2319 rvf_send_trace ("ATP : Verbose mode invalid ",
2320 27,
2321 NULL_PARAM,
2322 RV_TRACE_LEVEL_WARNING,
2323 ATP_USE_ID);
2324 *length_p = 0x0000;
2325 *buffer_pp = NULL;
2326 break;
2327 }
2328 }
2329 return (RV_NOT_SUPPORTED);
2330
2331 } /*************** End of atp_create_data_buffer_from_cmd function **************/
2332
2333
2334 /********************************************************************************
2335 * Function name : atp_copy_buffer_from_l2cap
2336 *
2337 * Description : Check the text command
2338 *
2339 * Parameters : l2cap_buffer_p = type is L2CAP_ACL_DATA
2340 * copy_buffer_p = pointer on the buffer to copy data in
2341 * buffer_length = data length to read
2342 *
2343 * Return : RV_OK if it fits
2344 *
2345 * Note : l2cap_buffer_p is not freed by this function !
2346 *
2347 * History : 0.1 (21-March-2000) - Created
2348 *
2349 *********************************************************************************/
2350 T_ATP_RET atp_copy_buffer_from_l2cap (void *l2cap_buffer_p,
2351 void *copy_buffer_p,
2352 UINT32 buffer_length,
2353 UINT32 offset)
2354 {
2355
2356 #ifdef BLUETOOTH
2357
2358 /* Declare local variables. */
2359 UINT16 nb_byte = 0x0000;
2360 T_RECV_DATA_ADDR acl_data_p = {NULL, \
2361 NULL};
2362
2363 /****************** atp_copy_buffer_from_l2cap function begins ******************/
2364
2365 rvf_send_trace ("ATP : Translate L2CAP buffer into a ATP buffer ",
2366 47,
2367 NULL_PARAM,
2368 RV_TRACE_LEVEL_DEBUG_LOW,
2369 ATP_USE_ID);
2370 l2cap_read_next_uint ((T_L2CAP_ACL_DATA *) l2cap_buffer_p,
2371 sizeof (UINT8),
2372 ((UINT8 *) copy_buffer_p),
2373 &acl_data_p,
2374 (UINT8) offset);
2375 for (nb_byte = 1;
2376 nb_byte < buffer_length;
2377 nb_byte++)
2378 {
2379 l2cap_read_next_uint ((T_L2CAP_ACL_DATA *) l2cap_buffer_p,
2380 sizeof (UINT8),
2381 ((UINT8 *) copy_buffer_p) + nb_byte,
2382 &acl_data_p,
2383 0x0000);
2384 }
2385 return (RV_OK);
2386 #else
2387 rvf_send_trace ("ATP : Tried to read buffer in L2CAP format whereas Bluetooth is not enabled ",
2388 76,
2389 NULL_PARAM,
2390 RV_TRACE_LEVEL_WARNING,
2391 ATP_USE_ID);
2392 return (RV_NOT_SUPPORTED);
2393 #endif
2394
2395 } /***************** End of atp_copy_buffer_from_l2cap function *****************/
2396
2397
2398 /********************************************************************************
2399 * Function name : atp_free_l2cap_buffer
2400 *
2401 * Description : Release a L2CAP buffer
2402 *
2403 * Parameter : l2cap_buffer_p = type is L2CAP_ACL_DATA
2404 *
2405 * Return : RV_OK if free is OK
2406 *
2407 * History : 0.1 (19-Dec-2001) - Created
2408 *
2409 *********************************************************************************/
2410 T_ATP_RET atp_free_l2cap_buffer (UINT8 *atp_buffer_p)
2411 {
2412
2413 /********************* atp_free_l2cap_buffer function begins ********************/
2414
2415 #ifdef BLUETOOTH
2416 return ((T_ATP_RET) (l2cap_free_data ((T_L2CAP_ACL_DATA *) atp_buffer_p)));
2417 #else
2418 rvf_send_trace ("ATP : Tried to read buffer in L2CAP format whereas Bluetooth is not enabled ",
2419 76,
2420 NULL_PARAM,
2421 RV_TRACE_LEVEL_WARNING,
2422 ATP_USE_ID);
2423 return (RV_NOT_SUPPORTED);
2424 #endif
2425
2426 } /******************** End of atp_free_l2cap_buffer function *******************/
2427
2428
2429 /********************************************************************************
2430 * Function name : atp_escape_sequence_process
2431 *
2432 * Description : This function is used to detect the escape sequence in the data
2433 * flow. This function should not be called if the port is not
2434 * configured in DCE mode. The escape sequence should start in a new
2435 * packet and the last character of the exit sequence should be the
2436 * last character of a packet. Note that each data buffer checked
2437 * that may be part of the escape sequence is temporarily stored so
2438 * that it can be sent to the SWE later on in case it was the escape
2439 * sequence.
2440 *
2441 * Parameters : port_p = structure of the port
2442 * atp_buffer_p = pointer on the buffer received by ATP (can be a
2443 * NORMAL data packet or a SEGMENTED data packet)
2444 * data_length = number of payload data in the packet pointed by
2445 * atp_buffer_p
2446 * packet_mode = indicates the mode of the data packet (NORMAL or
2447 * SEGMENTED)
2448 *
2449 * Return : ATP_ESCAPE_SEQUENCE_SUCCESS,
2450 * ATP_ESCAPE_SEQUENCE_FAILED otherwise
2451 *
2452 * History : 0.1 (06-Feb-2001) - Created
2453 *
2454 *********************************************************************************/
2455 T_ATP_ESCAPE_SEQUENCE_STATUS atp_escape_sequence_process (T_ATP_PORT_STRUCT *port_p,
2456 UINT8 *atp_buffer_p,
2457 UINT32 data_length,
2458 T_ATP_PACKET_MODE packet_mode)
2459 {
2460 /* Declare local variables. */
2461 UINT8 count = 0;
2462 UINT8 data_sequence[MAX_NB_OF_CHARACTER_FOR_END_SEQUENCE];
2463
2464 /****************** atp_escape_sequence_process function begins *****************/
2465
2466 /* Check the sequence. Indeed, there are data after the last character of */
2467 /* the escape sequence. */
2468 if (((port_p->dce_info_p)->nb_plus_received + data_length) > MAX_NB_OF_CHARACTER_FOR_END_SEQUENCE)
2469 {
2470 return (ATP_ESCAPE_SEQUENCE_FAILED);
2471 }
2472
2473 /* Get data from the buffer. */
2474 if (packet_mode == SEGMENTED_PACKET)
2475 {
2476 atp_copy_buffer_from_l2cap (atp_buffer_p,
2477 data_sequence,
2478 data_length,
2479 0);
2480 }
2481 else
2482 {
2483 memcpy (data_sequence,
2484 atp_buffer_p,
2485 data_length);
2486 }
2487
2488 /* Check every character. */
2489 for (count = 0;
2490 count < data_length;
2491 count++)
2492 {
2493 if (data_sequence[count] != (port_p->dce_info_p)->escape_sequence[count + (port_p->dce_info_p)->nb_plus_received])
2494 {
2495 return (ATP_ESCAPE_SEQUENCE_FAILED);
2496 }
2497 }
2498
2499 /* Keep temporarily the pointer on the buffer. */
2500 for (count = 0;
2501 (port_p->dce_info_p)->escape_sequence_tmp_buffer_p[count] != NULL;
2502 count++);
2503 (port_p->dce_info_p)->escape_sequence_tmp_buffer_p[count] = atp_buffer_p;
2504 (port_p->dce_info_p)->length_of_escape_sequence_tmp_buffer_p[count] = (UINT8) data_length;
2505 if (((port_p->dce_info_p)->nb_plus_received + data_length) != MAX_NB_OF_CHARACTER_FOR_END_SEQUENCE)
2506 {
2507 (port_p->dce_info_p)->nb_plus_received = (UINT8) ((port_p->dce_info_p)->nb_plus_received + data_length);
2508 return (ATP_ESCAPE_SEQUENCE_WAIT);
2509 }
2510
2511 /* Otherwise, all characters have been found. */
2512 return (ATP_ESCAPE_SEQUENCE_SUCCESS);
2513
2514 } /***************** End of atp_escape_sequence_process function ****************/
2515
2516
2517 /********************************************************************************
2518 * Function name : atp_pipe_extra_character
2519 *
2520 * Description : This function is called when it has been found that the escape
2521 * sequence search has failed and when other SWE is in copy mode.
2522 * In this case, data that has been received and that have not been
2523 * sent to the other SWE because we thought they may contain the
2524 * escape sequence must finally be sent.
2525 * For this reason, all the buffer to sent has been previously stored
2526 * in a temporary buffer called dce_info_p->escape_sequence_tmp_buffer_p.
2527 * This function pipes all this buffer into the data pipe of the SWE.
2528 * Note that such a complex mechanism is essentially due to the fact
2529 * that we may have to deal with L2CAP packet (SEGMENTED_MODE).
2530 *
2531 * Parameters : port_p = pointer on the port structure
2532 * other_port_info_p = pointer on the port information structure of
2533 * the SWE which will receive the data.
2534 *
2535 * Return : RV_OK
2536 *
2537 * History : 0.1 (01-March-2000) - Created
2538 *
2539 *********************************************************************************/
2540 T_ATP_RET atp_pipe_extra_character (T_ATP_PORT_STRUCT *port_p,
2541 T_ATP_PORT_END_STRUCT *other_port_info_p)
2542 {
2543 /* Declare local variables. */
2544 UINT8 count = 0;
2545 UINT8 nb_packet = 0;
2546 T_ATP_RX_PACKET *rx_packet_p = NULL;
2547
2548 /******************* atp_pipe_extra_character function begins *******************/
2549
2550 for (nb_packet = 0;
2551 ((port_p->dce_info_p)->escape_sequence_tmp_buffer_p[nb_packet] != NULL) && \
2552 (nb_packet < MAX_NB_OF_CHARACTER_FOR_END_SEQUENCE);
2553 nb_packet++);
2554 for (count = 0; count < nb_packet; count++)
2555 {
2556 if (rvf_get_buf (other_port_info_p->rx_mb, \
2557 sizeof (T_ATP_RX_PACKET), \
2558 (void **) &rx_packet_p) == RVF_RED)
2559 {
2560 atp_error_switch (ATP_ERROR_FAILED_TO_SEND_DATA,
2561 ATP_MEMORY_ERROR,NULL);
2562 return (RV_MEMORY_ERR);
2563 }
2564 rx_packet_p->first_byte = 0;
2565 rx_packet_p->last_byte = ((port_p->dce_info_p)->length_of_escape_sequence_tmp_buffer_p[count]) - 1;
2566 rx_packet_p->atp_buffer_p = (port_p->dce_info_p)->escape_sequence_tmp_buffer_p[count];
2567 rx_packet_p->next_byte_to_read = rx_packet_p->first_byte;
2568 rvf_enqueue (&(other_port_info_p->rx_queue),
2569 rx_packet_p);
2570 other_port_info_p->rx_data_left += (port_p->dce_info_p)->length_of_escape_sequence_tmp_buffer_p[count];
2571 }
2572 return (RV_OK);
2573
2574 } /****************** End of atp_pipe_extra_character function ******************/
2575
2576
2577 /********************************************************************************
2578 * Function name : atp_reset_escape_sequence
2579 *
2580 * Description : This function resets all internal values used by the algorithm
2581 * of escape sequence search (information stored in the dce_info_p
2582 * structure)
2583 *
2584 * Parameter : port_p = pointer on the port structure
2585 *
2586 * Return : RV_OK
2587 *
2588 * History : 0.1 (01-March-2000) - Created
2589 *
2590 *********************************************************************************/
2591 T_ATP_RET atp_reset_escape_sequence (T_ATP_PORT_STRUCT *port_p)
2592 {
2593 /* Declare local variables. */
2594 UINT8 count = 0;
2595 UINT8 *buffer_p = NULL;
2596
2597 /******************* atp_reset_escape_sequence function begins ******************/
2598
2599 (port_p->dce_info_p)->nb_plus_received = 0;
2600
2601 /* Clear pointers on temporary buffer containing potentially escape */
2602 /* sequence. */
2603 for (count = 0;
2604 count < MAX_NB_OF_CHARACTER_FOR_END_SEQUENCE;
2605 count++)
2606 {
2607 if ((buffer_p = (port_p->dce_info_p)->escape_sequence_tmp_buffer_p[count]) != NULL)
2608 {
2609
2610 #ifdef BLUETOOTH
2611
2612 /* Check if the buffer has been issued by SPP. Not very clean way to */
2613 /* check what is the packet mode. */
2614 if ((strcmp ((char *) atp_sw_entity_table_p[(port_p->port_info[0]).sw_id]->sw_entity_name, \
2615 ATP_SPP_NAME) == 0) || \
2616 (strcmp ((char *) atp_sw_entity_table_p[(port_p->port_info[1]).sw_id]->sw_entity_name, \
2617 ATP_SPP_NAME) == 0))
2618 {
2619
2620 /* Mode is SEGMENTED PACKET. */
2621 l2cap_free_data ((T_L2CAP_ACL_DATA *) buffer_p);
2622 }
2623 else
2624 {
2625
2626 /* Mode is NORMAL_PACKET. */
2627 rvf_free_buf (buffer_p);
2628 }
2629 #else
2630 rvf_free_buf (buffer_p);
2631 #endif
2632 (port_p->dce_info_p)->escape_sequence_tmp_buffer_p[count] = NULL;
2633 (port_p->dce_info_p)->length_of_escape_sequence_tmp_buffer_p[count] = 0;
2634 }
2635 }
2636 return (RV_OK);
2637
2638 } /****************** End of atp_reset_escape_sequence function ******************/