mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
component bt: Change the battery function to the new API function
This commit is contained in:
parent
a0007ceb79
commit
bc604d14ff
@ -35,7 +35,7 @@
|
||||
|
||||
#define BT_BD_ADDR_STR "%02x:%02x:%02x:%02x:%02x:%02x"
|
||||
#define BT_BD_ADDR_HEX(addr) addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]
|
||||
tBTA_GATTS_IF server_if;
|
||||
esp_gatts_if_t server_if;
|
||||
|
||||
tBATTERY_CB battery_cb;
|
||||
tGATT_CHAR_PROP prop = GATT_CHAR_PROP_BIT_READ;
|
||||
@ -43,19 +43,19 @@ tBA_REG_INFO ba_reg_info;
|
||||
UINT8 attr_handle_bit = 0x00;
|
||||
|
||||
extern tDIS_CB dis_cb;
|
||||
tBT_UUID bas_uuid = {LEN_UUID_16, {UUID_SERVCLASS_BATTERY}};
|
||||
esp_bt_uuid_t bas_uuid = {LEN_UUID_16, {UUID_SERVCLASS_BATTERY}};
|
||||
/******************************************************************************
|
||||
** Function bas_gatts_callback
|
||||
**
|
||||
** Description battery service register callback function
|
||||
*******************************************************************************/
|
||||
static void bas_gatts_callback(tBTA_GATTS_EVT event, tBTA_GATTS* p_data)
|
||||
static void bas_gatts_callback(esp_gatts_evt_t event, tBTA_GATTS* p_data)
|
||||
{
|
||||
switch (event)
|
||||
{
|
||||
case BTA_GATTS_REG_EVT:
|
||||
case ESP_GATTS_REG_EVT:
|
||||
{
|
||||
tBTA_GATT_STATUS status = p_data->reg_oper.status;
|
||||
esp_gatt_status_t status = p_data->reg_oper.status;
|
||||
server_if = p_data->reg_oper.server_if;
|
||||
LOG_ERROR("BAS register completed: event=%d, status=%d, server_if=%d\n",
|
||||
event, status, server_if);
|
||||
@ -69,7 +69,7 @@ static void bas_gatts_callback(tBTA_GATTS_EVT event, tBTA_GATTS* p_data)
|
||||
break;
|
||||
|
||||
/*connect callback*/
|
||||
case BTA_GATTS_CONNECT_EVT:
|
||||
case ESP_GATTS_CONNECT_EVT:
|
||||
{
|
||||
LOG_ERROR("\ndevice is connected "BT_BD_ADDR_STR", server_if=%d,reason=0x%x,connect_id=%d\n",
|
||||
BT_BD_ADDR_HEX(p_data->conn.remote_bda), p_data->conn.server_if,
|
||||
@ -81,7 +81,7 @@ static void bas_gatts_callback(tBTA_GATTS_EVT event, tBTA_GATTS* p_data)
|
||||
break;
|
||||
|
||||
/*create service callback*/
|
||||
case BTA_GATTS_CREATE_EVT:
|
||||
case ESP_GATTS_CREATE_EVT:
|
||||
{
|
||||
LOG_ERROR("create service:server_if=%d,service_id=0x%x,service_uuid=0x%x\n",
|
||||
p_data->create.server_if, p_data->create.service_id,
|
||||
@ -103,7 +103,7 @@ static void bas_gatts_callback(tBTA_GATTS_EVT event, tBTA_GATTS* p_data)
|
||||
}
|
||||
break;
|
||||
|
||||
case BTA_GATTS_ADD_CHAR_EVT:
|
||||
case ESP_GATTS_ADD_CHAR_EVT:
|
||||
{
|
||||
LOG_ERROR("create characteristic:server_if=%d,service_id=0x%x,char_uuid=0x%x\n",
|
||||
p_data->add_result.server_if, p_data->add_result.service_id,
|
||||
@ -141,7 +141,7 @@ static void bas_gatts_callback(tBTA_GATTS_EVT event, tBTA_GATTS* p_data)
|
||||
}
|
||||
break;
|
||||
|
||||
case BTA_GATTS_ADD_CHAR_DESCR_EVT:
|
||||
case ESP_GATTS_ADD_CHAR_DESCR_EVT:
|
||||
{
|
||||
|
||||
LOG_ERROR("create descriptor:server_if=%d,service_id=0x%x,attr_id=0x%x,char_uuid=0x%x\n",
|
||||
@ -151,7 +151,7 @@ static void bas_gatts_callback(tBTA_GATTS_EVT event, tBTA_GATTS* p_data)
|
||||
}
|
||||
break;
|
||||
|
||||
case BTA_GATTS_START_EVT:
|
||||
case ESP_GATTS_START_EVT:
|
||||
{
|
||||
LOG_ERROR("start service:server_if=%d,service_id=0x%x\n", p_data->srvc_oper.server_if,
|
||||
p_data->srvc_oper.service_id);
|
||||
@ -164,7 +164,7 @@ static void bas_gatts_callback(tBTA_GATTS_EVT event, tBTA_GATTS* p_data)
|
||||
}
|
||||
break;
|
||||
|
||||
case BTA_GATTS_READ_EVT:
|
||||
case ESP_GATTS_READ_EVT:
|
||||
{
|
||||
UINT32 trans_id = p_data->req_data.trans_id;
|
||||
UINT16 conn_id = p_data->req_data.conn_id;
|
||||
@ -186,7 +186,7 @@ static void bas_gatts_callback(tBTA_GATTS_EVT event, tBTA_GATTS* p_data)
|
||||
}
|
||||
break;
|
||||
|
||||
case BTA_GATTS_WRITE_EVT:
|
||||
case ESP_GATTS_WRITE_EVT:
|
||||
{
|
||||
|
||||
UINT32 trans_id = p_data->req_data.trans_id;
|
||||
@ -199,7 +199,7 @@ static void bas_gatts_callback(tBTA_GATTS_EVT event, tBTA_GATTS* p_data)
|
||||
}
|
||||
break;
|
||||
|
||||
case BTA_GATTS_EXEC_WRITE_EVT:
|
||||
case ESP_GATTS_EXEC_WRITE_EVT:
|
||||
{
|
||||
UINT32 trans_id = p_data->req_data.trans_id;
|
||||
UINT16 conn_id = p_data->req_data.conn_id;
|
||||
@ -209,7 +209,7 @@ static void bas_gatts_callback(tBTA_GATTS_EVT event, tBTA_GATTS* p_data)
|
||||
}
|
||||
break;
|
||||
|
||||
case BTA_GATTS_MTU_EVT:
|
||||
case ESP_GATTS_MTU_EVT:
|
||||
{
|
||||
UINT32 trans_id = p_data->req_data.trans_id;
|
||||
UINT16 conn_id = p_data->req_data.conn_id;
|
||||
@ -219,7 +219,7 @@ static void bas_gatts_callback(tBTA_GATTS_EVT event, tBTA_GATTS* p_data)
|
||||
}
|
||||
break;
|
||||
|
||||
case BTA_GATTS_CONF_EVT:
|
||||
case ESP_GATTS_CFM_EVT:
|
||||
{
|
||||
|
||||
UINT32 trans_id = p_data->req_data.trans_id;
|
||||
@ -231,6 +231,7 @@ static void bas_gatts_callback(tBTA_GATTS_EVT event, tBTA_GATTS* p_data)
|
||||
|
||||
default:
|
||||
LOG_ERROR("unsettled event: %d\n", event);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
@ -243,7 +244,7 @@ static void bas_callback(UINT32 trans_id, UINT16 conn_id, UINT8 app_id,
|
||||
UINT8 event, tBA_WRITE_DATA *p_data)
|
||||
{
|
||||
tBA_RSP_DATA p_rsp;
|
||||
tGATT_STATUS st = GATT_SUCCESS;
|
||||
tGATT_STATUS st = ESP_GATT_OK;
|
||||
switch(event)
|
||||
{
|
||||
case BA_READ_LEVEL_REQ :
|
||||
@ -299,10 +300,10 @@ static void bas_callback(UINT32 trans_id, UINT16 conn_id, UINT8 app_id,
|
||||
void bas_s_read_attr_value(tGATTS_DATA *p_data, UINT32 trans_id, UINT16 conn_id)
|
||||
{
|
||||
|
||||
tBA_INST *p_inst = &battery_cb.battery_inst[0];
|
||||
UINT8 i;
|
||||
tGATT_STATUS st = GATT_NOT_FOUND;
|
||||
UINT16 handle = p_data->read_req.handle;
|
||||
tBA_INST *p_inst = &battery_cb.battery_inst[0];
|
||||
UINT8 i;
|
||||
esp_gatt_status_t st = ESP_GATT_NOT_FOUND;
|
||||
UINT16 handle = p_data->read_req.handle;
|
||||
|
||||
|
||||
for (i = 0; i < BA_MAX_INT_NUM; i ++, p_inst ++)
|
||||
@ -314,7 +315,7 @@ void bas_s_read_attr_value(tGATTS_DATA *p_data, UINT32 trans_id, UINT16 conn_id)
|
||||
handle == p_inst->pres_fmt_hdl)
|
||||
{
|
||||
if (p_data->read_req.is_long)
|
||||
st = GATT_NOT_LONG;
|
||||
st = ESP_GATT_NOT_LONG;
|
||||
|
||||
if (p_inst->p_cback)
|
||||
{
|
||||
@ -329,7 +330,7 @@ void bas_s_read_attr_value(tGATTS_DATA *p_data, UINT32 trans_id, UINT16 conn_id)
|
||||
(*p_inst->p_cback)(trans_id, conn_id, p_inst->app_id, p_inst->pending_evt, NULL);
|
||||
}
|
||||
else /* application is not registered */
|
||||
st = GATT_ERR_UNLIKELY;
|
||||
st = ESP_GATT_ERR_UNLIKELY;
|
||||
break;
|
||||
}
|
||||
/* else attribute not found */
|
||||
@ -343,12 +344,12 @@ void bas_s_read_attr_value(tGATTS_DATA *p_data, UINT32 trans_id, UINT16 conn_id)
|
||||
******************************************************************************/
|
||||
void bas_s_write_attr_value(tGATTS_DATA *p_data, UINT32 trans_id, UINT16 conn_id, BD_ADDR bd_addr)
|
||||
{
|
||||
tBA_WRITE_DATA cfg;
|
||||
UINT8 *p = p_data->write_req.value;
|
||||
tBA_INST *p_inst = &battery_cb.battery_inst[0];
|
||||
UINT8 i;
|
||||
tGATT_STATUS st = GATT_NOT_FOUND;
|
||||
UINT16 handle = p_data->write_req.handle;
|
||||
tBA_WRITE_DATA cfg;
|
||||
UINT8 *p = p_data->write_req.value;
|
||||
tBA_INST *p_inst = &battery_cb.battery_inst[0];
|
||||
UINT8 i;
|
||||
esp_gatt_status_t st = ESP_GATT_NOT_FOUND;
|
||||
UINT16 handle = p_data->write_req.handle;
|
||||
|
||||
|
||||
for (i = 0; i < BA_MAX_INT_NUM; i ++, p_inst ++)
|
||||
@ -366,7 +367,7 @@ void bas_s_write_attr_value(tGATTS_DATA *p_data, UINT32 trans_id, UINT16 conn_id
|
||||
(*p_inst->p_cback)(trans_id, conn_id, p_inst->app_id, p_inst->pending_evt, &cfg);
|
||||
}
|
||||
else /* all other handle is not writable */
|
||||
st = GATT_WRITE_NOT_PERMIT;
|
||||
st = ESP_GATT_WRITE_NOT_PERMIT;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -381,7 +382,7 @@ void bas_s_write_attr_value(tGATTS_DATA *p_data, UINT32 trans_id, UINT16 conn_id
|
||||
****************************************************************/
|
||||
void bas_register(void)
|
||||
{
|
||||
BTA_GATTS_AppRegister(&bas_uuid, bas_gatts_callback);
|
||||
esp_ble_gatts_app_register(&bas_uuid, bas_gatts_callback);
|
||||
|
||||
}
|
||||
/***************************************************************
|
||||
@ -410,7 +411,7 @@ void bas_init(tBTA_GATTS_IF gatt_if, UINT16 app_id)
|
||||
|
||||
LOG_ERROR("create battery service\n");
|
||||
LOG_ERROR("inst_id=%d\n", battery_cb.inst_id);
|
||||
BTA_GATTS_CreateService (gatt_if, &bas_uuid, battery_cb.inst_id ,
|
||||
esp_ble_gatts_create_srvc (gatt_if, &bas_uuid, battery_cb.inst_id ,
|
||||
BA_MAX_ATTR_NUM, ba_reg_info.is_pri);
|
||||
|
||||
battery_cb.inst_id ++;
|
||||
@ -432,7 +433,7 @@ void bas_AddChar(UINT16 service_id, tBT_UUID *char_uuid)
|
||||
if (ba_reg_info.ba_level_descr & BA_LEVEL_NOTIFY)
|
||||
prop |= GATT_CHAR_PROP_BIT_NOTIFY;
|
||||
attr_handle_bit = 0x01;
|
||||
BTA_GATTS_AddCharacteristic(service_id, char_uuid, BATTER_LEVEL_PERM, prop);
|
||||
esp_ble_gatts_add_char(service_id, char_uuid, BATTER_LEVEL_PERM, prop);
|
||||
|
||||
}
|
||||
|
||||
@ -468,7 +469,7 @@ void bas_AddCharDescr(UINT16 service_id, UINT16 attr_id)
|
||||
uuid.uu.uuid16 = GATT_UUID_CHAR_CLIENT_CONFIG;
|
||||
ba_reg_info.ba_level_descr &= 0xfe;
|
||||
attr_handle_bit = 0x02;
|
||||
BTA_GATTS_AddCharDescriptor(service_id, (GATT_PERM_READ|GATT_PERM_WRITE), &uuid);
|
||||
esp_ble_gatts_add_char_descr(service_id, (GATT_PERM_READ|GATT_PERM_WRITE), &uuid);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -476,7 +477,7 @@ void bas_AddCharDescr(UINT16 service_id, UINT16 attr_id)
|
||||
if (ba_reg_info.ba_level_descr & BA_LEVEL_PRE_FMT)
|
||||
{
|
||||
uuid.uu.uuid16 = GATT_UUID_CHAR_PRESENT_FORMAT;
|
||||
BTA_GATTS_AddCharDescriptor(service_id, GATT_PERM_READ, &uuid);
|
||||
esp_ble_gatts_add_char_descr(service_id, GATT_PERM_READ, &uuid);
|
||||
ba_reg_info.ba_level_descr &= 0xfd;
|
||||
attr_handle_bit = 0x04;
|
||||
return;
|
||||
@ -486,14 +487,14 @@ void bas_AddCharDescr(UINT16 service_id, UINT16 attr_id)
|
||||
{
|
||||
uuid.uu.uuid16 = GATT_UUID_RPT_REF_DESCR;
|
||||
ba_reg_info.ba_level_descr &= 0xfb;
|
||||
BTA_GATTS_AddCharDescriptor(service_id, GATT_PERM_READ, &uuid);
|
||||
esp_ble_gatts_add_char_descr(service_id, GATT_PERM_READ, &uuid);
|
||||
attr_handle_bit = 0x08;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
BTA_GATTS_StartService(service_id, ba_reg_info.transport);
|
||||
esp_ble_gatts_start_srvc(service_id);
|
||||
|
||||
}
|
||||
|
||||
@ -504,12 +505,12 @@ void bas_AddCharDescr(UINT16 service_id, UINT16 attr_id)
|
||||
** Description create battery service complete
|
||||
**
|
||||
****************************************************************/
|
||||
void bas_service_cmpl(UINT16 service_id, tBTA_GATT_STATUS status)
|
||||
void bas_service_cmpl(UINT16 service_id, esp_gatt_status_t status)
|
||||
{
|
||||
if(status != GATT_SUCCESS)
|
||||
if(status != ESP_GATT_OK)
|
||||
{
|
||||
battery_cb.inst_id --;
|
||||
BTA_GATTS_DeleteService(service_id);
|
||||
esp_ble_gatts_dele_srvc(service_id);
|
||||
}
|
||||
|
||||
}
|
||||
@ -521,7 +522,7 @@ void bas_service_cmpl(UINT16 service_id, tBTA_GATT_STATUS status)
|
||||
**
|
||||
*******************************************************************************/
|
||||
void Battery_Rsp (UINT32 trans_id, UINT16 conn_id, UINT8 app_id,
|
||||
tGATT_STATUS st, UINT8 event, tBA_RSP_DATA *p_rsp)
|
||||
esp_gatt_status_t st, UINT8 event, tBA_RSP_DATA *p_rsp)
|
||||
{
|
||||
tBA_INST *p_inst = &battery_cb.battery_inst[0];
|
||||
tGATTS_RSP rsp;
|
||||
@ -549,7 +550,7 @@ void Battery_Rsp (UINT32 trans_id, UINT16 conn_id, UINT8 app_id,
|
||||
rsp.attr_value.len = 2;
|
||||
pp = rsp.attr_value.value;
|
||||
UINT16_TO_STREAM(pp, p_rsp->clt_cfg);
|
||||
BTA_GATTS_SendRsp(conn_id, trans_id, st, &rsp);
|
||||
esp_ble_gatts_send_rsp(conn_id, trans_id, st, &rsp);
|
||||
//srvc_sr_rsp(p_inst->pending_clcb_idx, st, &rsp);
|
||||
break;
|
||||
|
||||
@ -558,12 +559,12 @@ void Battery_Rsp (UINT32 trans_id, UINT16 conn_id, UINT8 app_id,
|
||||
rsp.attr_value.len = 1;
|
||||
pp = rsp.attr_value.value;
|
||||
UINT8_TO_STREAM(pp, p_rsp->ba_level);
|
||||
BTA_GATTS_SendRsp(conn_id, trans_id, st, &rsp);
|
||||
esp_ble_gatts_send_rsp(conn_id, trans_id, st, &rsp);
|
||||
//srvc_sr_rsp(p_inst->pending_clcb_idx, st, &rsp);
|
||||
break;
|
||||
|
||||
case BA_WRITE_CLT_CFG_REQ:
|
||||
BTA_GATTS_SendRsp(conn_id, trans_id, st, NULL);
|
||||
esp_ble_gatts_send_rsp(conn_id, trans_id, st, NULL);
|
||||
//srvc_sr_rsp(p_inst->pending_clcb_idx, st, NULL);
|
||||
break;
|
||||
|
||||
@ -573,7 +574,7 @@ void Battery_Rsp (UINT32 trans_id, UINT16 conn_id, UINT8 app_id,
|
||||
pp = rsp.attr_value.value;
|
||||
UINT8_TO_STREAM(pp, p_rsp->rpt_ref.rpt_id);
|
||||
UINT8_TO_STREAM(pp, p_rsp->rpt_ref.rpt_type);
|
||||
BTA_GATTS_SendRsp(conn_id, trans_id, st, &rsp);
|
||||
esp_ble_gatts_send_rsp(conn_id, trans_id, st, &rsp);
|
||||
//srvc_sr_rsp(p_inst->pending_clcb_idx, st, &rsp);
|
||||
break;
|
||||
|
||||
@ -607,7 +608,7 @@ void Battery_Notify (UINT16 conn_id, UINT8 app_id, BD_ADDR remote_bda, UINT8 bat
|
||||
|
||||
if (i == BA_MAX_INT_NUM || p_inst->clt_cfg_hdl == 0)
|
||||
return;
|
||||
BTA_GATTS_HandleValueIndication(conn_id, p_inst->ba_level_hdl, 1, &battery_level, false);
|
||||
esp_ble_gatts_hdl_val_indica(conn_id, p_inst->ba_level_hdl, 1, &battery_level, false);
|
||||
//srvc_sr_notify(remote_bda, p_inst->ba_level_hdl, 1, &battery_level);
|
||||
|
||||
}
|
||||
|
@ -44,10 +44,10 @@
|
||||
#define STREAM_TO_UINT64(u64, p) {u64 = (((UINT64)(*(p))) + ((((UINT64)(*((p) + 1)))) << 8) + ((((UINT64)(*((p) + 2)))) << 16) + ((((UINT64)(*((p) + 3)))) << 24) \
|
||||
+ ((((UINT64)(*((p) + 4)))) << 32) + ((((UINT64)(*((p) + 5)))) << 40) + ((((UINT64)(*((p) + 6)))) << 48) + ((((UINT64)(*((p) + 7)))) << 56)); (p) += 8;}
|
||||
|
||||
tBT_UUID uuid = {LEN_UUID_16, {UUID_SERVCLASS_DEVICE_INFO}};
|
||||
UINT16 i = 0;
|
||||
tDIS_ATTR_MASK dis_mask;
|
||||
static const UINT16 dis_attr_uuid[DIS_MAX_CHAR_NUM] =
|
||||
esp_bt_uuid_t uuid = {LEN_UUID_16, {UUID_SERVCLASS_DEVICE_INFO}};
|
||||
UINT16 i = 0;
|
||||
tDIS_ATTR_MASK dis_mask;
|
||||
static const UINT16 dis_attr_uuid[DIS_MAX_CHAR_NUM] =
|
||||
{
|
||||
GATT_UUID_SYSTEM_ID,
|
||||
GATT_UUID_MODEL_NUMBER_STR,
|
||||
@ -106,12 +106,12 @@ BOOLEAN dis_valid_handle_range(UINT16 handle)
|
||||
**
|
||||
** Process write DIS attribute request.
|
||||
*******************************************************************************/
|
||||
UINT8 dis_write_attr_value(tGATT_WRITE_REQ * p_data, tGATT_STATUS *p_status)
|
||||
UINT8 dis_write_attr_value(tGATT_WRITE_REQ * p_data, esp_gatt_status_t *p_status)
|
||||
{
|
||||
UNUSED(p_data);
|
||||
|
||||
*p_status = GATT_WRITE_NOT_PERMIT;
|
||||
return GATT_SUCCESS;
|
||||
return ESP_GATT_OK;
|
||||
}
|
||||
/*******************************************************************************
|
||||
** DIS Attributes Database Server Request callback
|
||||
@ -127,7 +127,7 @@ void dis_s_read_attr_value (tGATTS_DATA *p_data, tGATT_VALUE *p_value, UINT32 tr
|
||||
tDIS_DB_ENTRY *p_db_attr = dis_cb.dis_attr;
|
||||
UINT8 *p = p_value->value, i, *pp;
|
||||
UINT16 offset = p_data->read_req.offset;
|
||||
tGATT_STATUS st = GATT_NOT_FOUND;
|
||||
tGATT_STATUS st = ESP_GATT_NOT_FOUND;
|
||||
UINT16 handle = p_data->read_req.handle;
|
||||
bool is_long = p_data->read_req.is_long;
|
||||
|
||||
@ -138,10 +138,10 @@ void dis_s_read_attr_value (tGATTS_DATA *p_data, tGATT_VALUE *p_value, UINT32 tr
|
||||
if ((p_db_attr->uuid == GATT_UUID_PNP_ID || p_db_attr->uuid == GATT_UUID_SYSTEM_ID)&&
|
||||
is_long == TRUE)
|
||||
{
|
||||
st = GATT_NOT_LONG;
|
||||
st = ESP_GATT_NOT_LONG;
|
||||
break;
|
||||
}
|
||||
st = GATT_SUCCESS;
|
||||
st = ESP_GATT_NOT_FOUND;
|
||||
|
||||
switch (p_db_attr->uuid)
|
||||
{
|
||||
@ -165,7 +165,7 @@ void dis_s_read_attr_value (tGATTS_DATA *p_data, tGATT_VALUE *p_value, UINT32 tr
|
||||
|
||||
if (offset > p_value->len)
|
||||
{
|
||||
st = GATT_INVALID_OFFSET;
|
||||
st = ESP_GATT_INVALID_OFFSET;
|
||||
break;
|
||||
}
|
||||
else
|
||||
@ -197,7 +197,7 @@ void dis_s_read_attr_value (tGATTS_DATA *p_data, tGATT_VALUE *p_value, UINT32 tr
|
||||
}
|
||||
tGATTS_RSP rsp;
|
||||
rsp.attr_value = *p_value;
|
||||
BTA_GATTS_SendRsp(conn_id, trans_id, st, &rsp);
|
||||
esp_ble_gatts_send_rsp(conn_id, trans_id, st, &rsp);
|
||||
|
||||
}
|
||||
|
||||
@ -209,7 +209,7 @@ void dis_s_read_attr_value (tGATTS_DATA *p_data, tGATT_VALUE *p_value, UINT32 tr
|
||||
** Description Initialize the Device Information Service Server.
|
||||
**
|
||||
*******************************************************************************/
|
||||
void DIS_Init (tBTA_GATTS_IF gatt_if, tDIS_ATTR_MASK dis_attr_mask)
|
||||
void DIS_Init (esp_gatts_if_t gatt_if, tDIS_ATTR_MASK dis_attr_mask)
|
||||
{
|
||||
|
||||
tGATT_STATUS status;
|
||||
@ -222,7 +222,7 @@ void DIS_Init (tBTA_GATTS_IF gatt_if, tDIS_ATTR_MASK dis_attr_mask)
|
||||
|
||||
memset(&dis_cb, 0, sizeof(tDIS_CB));
|
||||
|
||||
BTA_GATTS_CreateService (gatt_if , &uuid, 0, DIS_MAX_ATTR_NUM, TRUE);
|
||||
esp_ble_gatts_create_srvc (gatt_if , &uuid, 0, DIS_MAX_ATTR_NUM, TRUE);
|
||||
|
||||
}
|
||||
/*******************************************************************************
|
||||
@ -241,14 +241,14 @@ void dis_AddChar(UINT16 service_id)
|
||||
while(dis_mask != 0 && i < DIS_MAX_CHAR_NUM)
|
||||
{
|
||||
uuid.uu.uuid16 = p_db_attr->uuid = dis_attr_uuid[i];
|
||||
BTA_GATTS_AddCharacteristic(dis_cb.service_handle, &uuid, GATT_PERM_READ,
|
||||
esp_ble_gatts_add_char(dis_cb.service_handle, &uuid, GATT_PERM_READ,
|
||||
GATT_CHAR_PROP_BIT_READ);
|
||||
p_db_attr ++;
|
||||
i ++;
|
||||
dis_mask >>= 1;
|
||||
}
|
||||
/*start service*/
|
||||
BTA_GATTS_StartService(dis_cb.service_handle, GATT_TRANSPORT_LE_BR_EDR);
|
||||
esp_ble_gatts_start_srvc(dis_cb.service_handle);
|
||||
dis_cb.enabled = TRUE;
|
||||
}
|
||||
/*******************************************************************************
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "bt_target.h"
|
||||
#include "gatt_api.h"
|
||||
#include "gattdefs.h"
|
||||
#include "bt_app_api.h"
|
||||
|
||||
#define DIS_SUCCESS GATT_SUCCESS
|
||||
#define DIS_ILLEGAL_PARAM GATT_ILLEGAL_PARAMETER
|
||||
|
@ -1620,12 +1620,12 @@ UINT8 btm_ble_io_capabilities_req(tBTM_SEC_DEV_REC *p_dev_rec, tBTM_LE_IO_REQ *p
|
||||
p_data->resp_keys = 0;
|
||||
}
|
||||
|
||||
BTM_TRACE_DEBUG ("btm_ble_io_capabilities_req 3: auth_req:%d", p_data->auth_req);
|
||||
BTM_TRACE_DEBUG ("btm_ble_io_capabilities_req 4: i_keys=0x%x r_keys=0x%x",
|
||||
BTM_TRACE_DEBUG ("btm_ble_io_capabilities_req 3: auth_req:%d\n", p_data->auth_req);
|
||||
BTM_TRACE_DEBUG ("btm_ble_io_capabilities_req 4: i_keys=0x%x r_keys=0x%x\n",
|
||||
p_data->init_keys,
|
||||
p_data->resp_keys);
|
||||
|
||||
BTM_TRACE_DEBUG ("btm_ble_io_capabilities_req 5: p_data->io_cap = %d auth_req:%d",
|
||||
BTM_TRACE_DEBUG ("btm_ble_io_capabilities_req 5: p_data->io_cap = %d auth_req:%d\n",
|
||||
p_data->io_cap, p_data->auth_req);
|
||||
|
||||
/* remove MITM protection requirement if IO cap does not allow it */
|
||||
@ -1644,7 +1644,7 @@ UINT8 btm_ble_io_capabilities_req(tBTM_SEC_DEV_REC *p_dev_rec, tBTM_LE_IO_REQ *p
|
||||
p_data->resp_keys &= ~SMP_SEC_KEY_TYPE_LK;
|
||||
}
|
||||
|
||||
BTM_TRACE_DEBUG ("btm_ble_io_capabilities_req 6: IO_CAP:%d oob_data:%d auth_req:0x%02x",
|
||||
BTM_TRACE_DEBUG ("btm_ble_io_capabilities_req 6: IO_CAP:%d oob_data:%d auth_req:0x%02x\n",
|
||||
p_data->io_cap, p_data->oob_data, p_data->auth_req);
|
||||
}
|
||||
return callback_rc;
|
||||
@ -1663,7 +1663,7 @@ UINT8 btm_ble_io_capabilities_req(tBTM_SEC_DEV_REC *p_dev_rec, tBTM_LE_IO_REQ *p
|
||||
UINT8 btm_ble_br_keys_req(tBTM_SEC_DEV_REC *p_dev_rec, tBTM_LE_IO_REQ *p_data)
|
||||
{
|
||||
UINT8 callback_rc = BTM_SUCCESS;
|
||||
BTM_TRACE_DEBUG ("%s", __func__);
|
||||
BTM_TRACE_DEBUG ("%s\n", __func__);
|
||||
if (btm_cb.api.p_le_callback)
|
||||
{
|
||||
/* the callback function implementation may change the IO capability... */
|
||||
@ -1705,7 +1705,7 @@ static void btm_ble_resolve_random_addr_on_conn_cmpl(void * p_rec, void *p_data)
|
||||
|
||||
handle = HCID_GET_HANDLE (handle);
|
||||
|
||||
BTM_TRACE_EVENT ("%s", __func__);
|
||||
BTM_TRACE_EVENT ("%s\n", __func__);
|
||||
|
||||
if (match_rec)
|
||||
{
|
||||
|
@ -1447,7 +1447,7 @@ tBTM_STATUS BTM_SetEncryption (BD_ADDR bd_addr, tBT_TRANSPORT transport, tBTM_SE
|
||||
else
|
||||
{
|
||||
rc = BTM_WRONG_MODE;
|
||||
BTM_TRACE_WARNING("%s: cannot call btm_ble_set_encryption, p is NULL", __FUNCTION__);
|
||||
BTM_TRACE_WARNING("%s: cannot call btm_ble_set_encryption, p is NULL\n", __FUNCTION__);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user