

dir: esp/esp-idf/components/bt/host/bluedroid/bta/hf_client/include/bta_hf_client_at.h

file: bta_hf_client_at.h

add enum 
	BTA_HF_CLIENT_AT_APPLE  --- (73)
	BTA_HF_CLIENT_AT_BATT --- (74)
	
---------------------------------------------------

dir: esp/esp-idf/components/bt/host/bluedroid/bta/include/bta/bta_hf_client_api.h

file: bta_hf_client_api.h

define marcos
	#define BTA_HF_CLIENT_AT_CMD_APPLE  16    --- (147)
	#define BTA_HF_CLIENT_AT_CMD_BATT	17	  --- (148)
	
--------------------------------------------------
	
dir: esp/esp-idf/components/bt/host/bluedroid/bta/hf_client/include/bta_hf_client_int.h

file: bta_hf_client_int.h

add extern function declaration

	extern void bta_hf_client_send_at_apple(void); --- (270)
	extern void bta_hf_client_send_at_batt(UINT32 val); --- (271)
	
----------------------------------------------------
	
dir: esp/esp-idf/components/bt/host/bluedroid/bta/hf_client/bta_hf_client_at.c

file: bta_hf_client_at.c
	
add function defination

	void bta_hf_client_send_at_apple(void) --- (1642)
	{
	    char *buf;

	    APPL_TRACE_DEBUG("%s", __FUNCTION__);

	    buf = "AT+XAPL=ABCD-1234-0100,10\r";

	    bta_hf_client_send_at(BTA_HF_CLIENT_AT_APPLE, buf, strlen(buf));
	}

	void bta_hf_client_send_at_batt(UINT32 val) --- (1653)
	{
	    char *buf = osi_malloc(BTA_HF_CLIENT_AT_MAX_LEN);
	    int at_len;

	    if (buf == NULL) {
	        APPL_TRACE_ERROR("No mem %s", __FUNCTION__);
	        return;
	    }
	    APPL_TRACE_DEBUG("%s", __FUNCTION__);

		at_len = snprintf(buf, BTA_HF_CLIENT_AT_MAX_LEN, "AT+IPHONEACCEV=1,1,%u\r",val);

	    bta_hf_client_send_at(BTA_HF_CLIENT_AT_BATT, buf, at_len);
	    osi_free(buf);
	}

---------------------------------------------------

dir: esp/esp-idf/components/bt/host/bluedroid/bta/hf_client/bta_hf_client_cmd.c

file: bta_hf_client_cmd.c

add switch statement cases to send particular command on event

	case BTA_HF_CLIENT_AT_CMD_APPLE:   --- (80)
		bta_hf_client_send_at_apple();
		break;
	case BTA_HF_CLIENT_AT_CMD_BATT: --- (83)
		bta_hf_client_send_at_batt(p_val->uint32_val1);
		break;
		
--------------------------------------------------
These functions are used in user code to enable and send battery data
--------------------------------------------------

dir: esp/esp-idf/components/bt/host/bluedroid/api/include/api/esp_hf_client_api.h

file: esp_hf_client_api.h

function declaration 
	esp_err_t esp_hf_client_enable_apple_cmd(void);   --- (500)
	esp_err_t esp_hf_client_send_batt(uint32_t val);  --- (501)
	
--------------------------------------------------
dir: esp/esp-idf/components/bt/host/bluedroid/api/esp_hf_client_api.c

file: esp_hf_client_api.c

function defination
	esp_err_t esp_hf_client_enable_apple_cmd(void)  ---- (329)
	{
	    if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
	        return ESP_ERR_INVALID_STATE;
	    }

	    btc_msg_t msg;

	    msg.sig = BTC_SIG_API_CALL;
	    msg.pid = BTC_PID_HF_CLIENT;
	    msg.act = BTC_HF_CLIENT_SEND_APPLE_EVT;

	    /* Switch to BTC context */
	    bt_status_t stat = btc_transfer_context(&msg, NULL, 0, NULL);
	    return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
	}


	esp_err_t esp_hf_client_send_batt(uint32_t val)  ----  (347)
	{
	    if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
	        return ESP_ERR_INVALID_STATE;
	    }

	    btc_msg_t msg;
	    btc_hf_client_args_t arg;

	    msg.sig = BTC_SIG_API_CALL;
	    msg.pid = BTC_PID_HF_CLIENT;
	    msg.act = BTC_HF_CLIENT_SEND_BATT_EVT;


	    memset(&arg, 0, sizeof(btc_hf_client_args_t));
	    arg.apple_batt.val = val;

	    /* Switch to BTC context */
	    bt_status_t stat = btc_transfer_context(&msg, &arg, sizeof(btc_hf_client_args_t), NULL);
	    return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
	}
	