1 /******************************************************************************
2  *
3  *  Copyright (c) 2014 The Android Open Source Project
4  *  Copyright 2003-2012 Broadcom Corporation
5  *
6  *  Licensed under the Apache License, Version 2.0 (the "License");
7  *  you may not use this file except in compliance with the License.
8  *  You may obtain a copy of the License at:
9  *
10  *  http://www.apache.org/licenses/LICENSE-2.0
11  *
12  *  Unless required by applicable law or agreed to in writing, software
13  *  distributed under the License is distributed on an "AS IS" BASIS,
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *  See the License for the specific language governing permissions and
16  *  limitations under the License.
17  *
18  ******************************************************************************/
19 
20 /*****************************************************************************
21  *  Data types
22  ****************************************************************************/
23 
24 #include <cstdint>
25 
26 #include "osi/include/alarm.h"
27 
28 /* ASCII character string of arguments to the AT command */
29 #define BTA_HF_CLIENT_AT_MAX_LEN 512
30 
31 typedef uint8_t tBTA_HF_CLIENT_AT_CMD;
32 
33 /* Maximum combined buffer for received AT events string */
34 #define BTA_HF_CLIENT_AT_PARSER_MAX_LEN 4096
35 
36 /* This structure holds prepared AT command queued for sending */
37 struct queued_at_cmd {
38   tBTA_HF_CLIENT_AT_CMD cmd;
39   char buf[BTA_HF_CLIENT_AT_MAX_LEN];
40   uint16_t buf_len;
41   struct queued_at_cmd* next;
42 };
43 typedef struct queued_at_cmd tBTA_HF_CLIENT_AT_QCMD;
44 
45 /* Maximum number of indicators */
46 #define BTA_HF_CLIENT_AT_INDICATOR_COUNT 20
47 
48 /* AT command parsing control block */
49 typedef struct {
50   char buf[BTA_HF_CLIENT_AT_PARSER_MAX_LEN + 1]; /* extra byte to always have \0 at the end */
51   unsigned int offset;
52   tBTA_HF_CLIENT_AT_CMD current_cmd;
53   tBTA_HF_CLIENT_AT_QCMD* queued_cmd;
54   alarm_t* resp_timer; /* AT response timer */
55   alarm_t* hold_timer; /* AT hold timer */
56 
57   /* CIND: lookup table to store the sequence of incoming indicators and their
58      values
59      so when their values come later, we know which value in sequence match
60      certain indicator */
61   int indicator_lookup[BTA_HF_CLIENT_AT_INDICATOR_COUNT];
62 } tBTA_HF_CLIENT_AT_CB;
63