1/****************************************************************************** 2 * 3 * Copyright (C) 2010-2012 Broadcom Corporation 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ******************************************************************************/ 18 19/****************************************************************************** 20 * 21 * This is the implementation file for the GATT call-in functions. 22 * 23 ******************************************************************************/ 24 25#include "bt_target.h" 26 27#if defined(BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE) 28 29#include <string.h> 30 31#include "bta_api.h" 32#include "bta_sys.h" 33#include "bta_gattc_ci.h" 34#include "gki.h" 35#include "utl.h" 36 37/******************************************************************************* 38** 39** Function bta_gattc_ci_cache_open 40** 41** Description This function sends an event to indicate server cache open 42** completed. 43** 44** Parameters server_bda - server BDA of this cache. 45** status - BTA_GATT_OK if full buffer of data, 46** BTA_GATT_FAIL if an error has occurred. 47** 48** Returns void 49** 50*******************************************************************************/ 51void bta_gattc_ci_cache_open(BD_ADDR server_bda, UINT16 evt, tBTA_GATT_STATUS status, 52 UINT16 conn_id) 53{ 54 tBTA_GATTC_CI_EVT *p_evt; 55 UNUSED(server_bda); 56 57 if ((p_evt = (tBTA_GATTC_CI_EVT *) GKI_getbuf(sizeof(tBTA_GATTC_CI_EVT))) != NULL) 58 { 59 p_evt->hdr.event = evt; 60 p_evt->hdr.layer_specific = conn_id; 61 62 p_evt->status = status; 63 bta_sys_sendmsg(p_evt); 64 } 65} 66 67/******************************************************************************* 68** 69** Function bta_gattc_ci_cache_load 70** 71** Description This function sends an event to BTA indicating the phone has 72** load the servere cache and ready to send it to the stack. 73** 74** Parameters server_bda - server BDA of this cache. 75** num_bytes_read - number of bytes read into the buffer 76** specified in the read callout-function. 77** status - BTA_GATT_OK if full buffer of data, 78** BTA_GATT_FAIL if an error has occurred. 79** 80** Returns void 81** 82*******************************************************************************/ 83void bta_gattc_ci_cache_load(BD_ADDR server_bda, UINT16 evt, UINT16 num_attr, 84 tBTA_GATTC_NV_ATTR *p_attr, tBTA_GATT_STATUS status, 85 UINT16 conn_id) 86{ 87 tBTA_GATTC_CI_LOAD *p_evt; 88 UNUSED(server_bda); 89 90 if ((p_evt = (tBTA_GATTC_CI_LOAD *) GKI_getbuf(sizeof(tBTA_GATTC_CI_LOAD))) != NULL) 91 { 92 memset(p_evt, 0, sizeof(tBTA_GATTC_CI_LOAD)); 93 94 p_evt->hdr.event = evt; 95 p_evt->hdr.layer_specific = conn_id; 96 97 p_evt->status = status; 98 p_evt->num_attr = (num_attr > BTA_GATTC_NV_LOAD_MAX) ? BTA_GATTC_NV_LOAD_MAX : num_attr; 99 100 if (p_evt->num_attr > 0 && p_attr != NULL) 101 { 102 memcpy(p_evt->attr, p_attr, p_evt->num_attr * sizeof(tBTA_GATTC_NV_ATTR)); 103 } 104 105 bta_sys_sendmsg(p_evt); 106 } 107} 108 109/******************************************************************************* 110** 111** Function bta_gattc_ci_cache_save 112** 113** Description This function sends an event to BTA indicating the phone has 114** save the servere cache. 115** 116** Parameters server_bda - server BDA of this cache. 117** evt - callin event code. 118** status - BTA_GATT_OK if full buffer of data, 119** BTA_GATT_ERROR if an error has occurred. 120*8 conn_id - for this NV operation for. 121** 122** Returns void 123** 124*******************************************************************************/ 125void bta_gattc_ci_cache_save(BD_ADDR server_bda, UINT16 evt, tBTA_GATT_STATUS status, 126 UINT16 conn_id) 127{ 128 tBTA_GATTC_CI_EVT *p_evt; 129 UNUSED(server_bda); 130 131 if ((p_evt = (tBTA_GATTC_CI_EVT *) GKI_getbuf(sizeof(tBTA_GATTC_CI_EVT))) != NULL) 132 { 133 p_evt->hdr.event = evt; 134 p_evt->hdr.layer_specific = conn_id; 135 136 p_evt->status = status; 137 bta_sys_sendmsg(p_evt); 138 } 139} 140#endif /* BTA_GATT_INCLUDED */ 141