1/****************************************************************************** 2 * 3 * Copyright (c) 2014 The Android Open Source Project 4 * Copyright (C) 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/* ASCII character string of arguments to the AT command */ 25#define BTA_HF_CLIENT_AT_MAX_LEN 512 26 27/* AT command table element */ 28typedef struct 29{ 30 const char *p_cmd; /* AT command string */ 31 UINT8 arg_type; /* allowable argument type syntax */ 32 UINT8 fmt; /* whether arg is int or string */ 33 UINT8 min; /* minimum value for int arg */ 34 INT16 max; /* maximum value for int arg */ 35} tBTA_AG_AT_CMD; 36 37/* callback function executed when command is parsed */ 38typedef void (tBTA_AG_AT_CMD_CBACK)(void *p_user, UINT16 cmd, UINT8 arg_type, 39 char *p_arg, INT16 int_arg); 40 41/* callback function executed to send "ERROR" result code */ 42typedef void (tBTA_AG_AT_ERR_CBACK)(void *p_user, BOOLEAN unknown, char *p_arg); 43 44enum 45{ 46 BTA_HF_CLIENT_AT_NONE, 47 BTA_HF_CLIENT_AT_BRSF, 48 BTA_HF_CLIENT_AT_BAC, 49 BTA_HF_CLIENT_AT_CIND, 50 BTA_HF_CLIENT_AT_CIND_STATUS, 51 BTA_HF_CLIENT_AT_CMER, 52 BTA_HF_CLIENT_AT_CHLD, 53 BTA_HF_CLIENT_AT_CMEE, 54 BTA_HF_CLIENT_AT_BIA, 55 BTA_HF_CLIENT_AT_CLIP, 56 BTA_HF_CLIENT_AT_CCWA, 57 BTA_HF_CLIENT_AT_COPS, 58 BTA_HF_CLIENT_AT_CLCC, 59 BTA_HF_CLIENT_AT_BVRA, 60 BTA_HF_CLIENT_AT_VGS, 61 BTA_HF_CLIENT_AT_VGM, 62 BTA_HF_CLIENT_AT_ATD, 63 BTA_HF_CLIENT_AT_BLDN, 64 BTA_HF_CLIENT_AT_ATA, 65 BTA_HF_CLIENT_AT_CHUP, 66 BTA_HF_CLIENT_AT_BTRH, 67 BTA_HF_CLIENT_AT_VTS, 68 BTA_HF_CLIENT_AT_BCC, 69 BTA_HF_CLIENT_AT_BCS, 70 BTA_HF_CLIENT_AT_CNUM, 71 BTA_HF_CLIENT_AT_NREC, 72 BTA_HF_CLIENT_AT_BINP, 73}; 74 75typedef UINT8 tBTA_HF_CLIENT_AT_CMD; 76 77/* Maximum combined buffer for received AT events string */ 78#define BTA_HF_CLIENT_AT_PARSER_MAX_LEN 4096 79 80/* This structure holds prepared AT command queued for sending */ 81struct queued_at_cmd{ 82 tBTA_HF_CLIENT_AT_CMD cmd; 83 char buf[BTA_HF_CLIENT_AT_MAX_LEN]; 84 UINT16 buf_len; 85 struct queued_at_cmd *next; 86}; 87typedef struct queued_at_cmd tBTA_HF_CLIENT_AT_QCMD; 88 89/* Maximum number of indicators */ 90#define BTA_HF_CLIENT_AT_INDICATOR_COUNT 20 91 92/* AT command parsing control block */ 93typedef struct 94{ 95 char buf[BTA_HF_CLIENT_AT_PARSER_MAX_LEN + 1]; /* extra byte to always have \0 at the end */ 96 unsigned int offset; 97 tBTA_HF_CLIENT_AT_CMD current_cmd; 98 tBTA_HF_CLIENT_AT_QCMD *queued_cmd; 99 100 TIMER_LIST_ENT resp_timer; /* AT response timer */ 101 BOOLEAN resp_timer_on; /* TRUE if AT response timer is active */ 102 103 TIMER_LIST_ENT hold_timer; /* AT hold timer */ 104 BOOLEAN hold_timer_on; /* TRUE if AT hold timer is active */ 105 106 /* CIND: lookup table to store the sequence of incoming indicators and their values 107 so when their values come later, we know which value in sequence match certain indicator */ 108 int indicator_lookup[BTA_HF_CLIENT_AT_INDICATOR_COUNT]; 109 110} tBTA_HF_CLIENT_AT_CB; 111 112/***************************************************************************** 113** Functions 114*****************************************************************************/ 115 116void bta_hf_client_at_init(void); 117void bta_hf_client_at_reset(void); 118