component/bt : change gatt client arg to union

1. decrease the args memory occupy
2. change some macro name
This commit is contained in:
Tian Hao 2016-11-23 21:27:05 +08:00
parent 85aac3afa6
commit 225e31b6de
4 changed files with 392 additions and 185 deletions

View File

@ -60,7 +60,8 @@ esp_err_t esp_ble_gattc_app_register(uint16_t app_id)
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GATTC;
msg.act = BTC_GATTC_ACT_APP_REGISTER;
arg.app_id = app_id;
arg.app_reg.app_id = app_id;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
@ -84,7 +85,8 @@ esp_err_t esp_ble_gattc_app_unregister(esp_gatt_if_t gatt_if)
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GATTC;
msg.act = BTC_GATTC_ACT_APP_UNREGISTER;
arg.gatt_if = gatt_if;
arg.app_unreg.gatt_if = gatt_if;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
@ -110,9 +112,9 @@ esp_err_t esp_ble_gattc_open(esp_gatt_if_t gatt_if, esp_bd_addr_t remote_bda, bo
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GATTC;
msg.act = BTC_GATTC_ACT_OPEN;
arg.gatt_if = gatt_if;
memcpy(arg.remote_bda, remote_bda, ESP_BD_ADDR_LEN);
arg.is_direct = is_direct;
arg.open.gatt_if = gatt_if;
memcpy(arg.open.remote_bda, remote_bda, ESP_BD_ADDR_LEN);
arg.open.is_direct = is_direct;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
@ -136,7 +138,7 @@ esp_err_t esp_ble_gattc_close (uint16_t conn_id)
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GATTC;
msg.act = BTC_GATTC_ACT_CLOSE;
arg.conn_id = conn_id;
arg.close.conn_id = conn_id;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
@ -167,8 +169,8 @@ esp_err_t esp_ble_gattc_config_mtu (uint16_t conn_id, uint16_t mtu)
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GATTC;
msg.act = BTC_GATTC_ACT_CFG_MTU;
arg.conn_id = conn_id;
arg.mtu = mtu;
arg.cfg_mtu.conn_id = conn_id;
arg.cfg_mtu.mtu = mtu;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
@ -197,12 +199,12 @@ esp_err_t esp_ble_gattc_search_service(uint16_t conn_id, esp_bt_uuid_t *filter_u
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GATTC;
msg.act = BTC_GATTC_ACT_SEARCH_SERVICE;
arg.conn_id = conn_id;
arg.search_srvc.conn_id = conn_id;
if (filter_uuid) {
arg.have_uuid = true;
memcpy(&arg.uuid, filter_uuid, sizeof(esp_bt_uuid_t));
arg.search_srvc.filter_uuid_enable = true;
memcpy(&arg.search_srvc.filter_uuid, filter_uuid, sizeof(esp_bt_uuid_t));
} else {
arg.have_uuid = false;
arg.search_srvc.filter_uuid_enable = false;
}
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
@ -235,13 +237,15 @@ esp_err_t esp_ble_gattc_get_characteristic(uint16_t conn_id,
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GATTC;
arg.conn_id = conn_id;
memcpy(&arg.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
if (start_char_id) {
memcpy(&arg.char_id, start_char_id, sizeof(esp_gatt_id_t));
msg.act = BTC_GATTC_ACT_GET_NEXT_CHAR;
} else {
msg.act = BTC_GATTC_ACT_GET_FIRST_CHAR;
arg.get_next_char.conn_id = conn_id;
memcpy(&arg.get_next_char.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&arg.get_next_char.char_id, start_char_id, sizeof(esp_gatt_id_t));
msg.act = BTC_GATTC_ACT_GET_NEXT_CHAR;
} else {
arg.get_first_char.conn_id = conn_id;
memcpy(&arg.get_first_char.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
msg.act = BTC_GATTC_ACT_GET_FIRST_CHAR;
}
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
@ -274,15 +278,19 @@ esp_err_t esp_ble_gattc_get_descriptor(uint16_t conn_id,
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GATTC;
arg.conn_id = conn_id;
memcpy(&arg.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&arg.char_id, char_id, sizeof(esp_gatt_id_t));
if (start_descr_id) {
memcpy(&arg.descr_id, start_descr_id, sizeof(esp_gatt_id_t));
msg.act = BTC_GATTC_ACT_GET_NEXT_DESCR;
} else {
msg.act = BTC_GATTC_ACT_GET_FIRST_DESCR;
}
arg.get_next_descr.conn_id = conn_id;
memcpy(&arg.get_next_descr.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&arg.get_next_descr.char_id, char_id, sizeof(esp_gatt_id_t));
memcpy(&arg.get_next_descr.descr_id, start_descr_id, sizeof(esp_gatt_id_t));
msg.act = BTC_GATTC_ACT_GET_NEXT_DESCR;
} else {
arg.get_first_descr.conn_id = conn_id;
memcpy(&arg.get_first_descr.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&arg.get_first_descr.char_id, char_id, sizeof(esp_gatt_id_t));
msg.act = BTC_GATTC_ACT_GET_FIRST_DESCR;
}
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
@ -313,12 +321,15 @@ esp_err_t esp_ble_gattc_get_included_service(uint16_t conn_id,
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GATTC;
arg.conn_id = conn_id;
memcpy(&arg.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
if (start_incl_srvc_id) {
memcpy(&arg.start_service_id, start_incl_srvc_id, sizeof(esp_gatt_srvc_id_t));
arg.get_next_incl_srvc.conn_id = conn_id;
memcpy(&arg.get_next_incl_srvc.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&arg.get_next_incl_srvc.start_service_id, start_incl_srvc_id, sizeof(esp_gatt_srvc_id_t));
msg.act = BTC_GATTC_ACT_GET_NEXT_INCL_SERVICE;
} else {
arg.get_first_incl_srvc.conn_id = conn_id;
memcpy(&arg.get_first_incl_srvc.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
msg.act = BTC_GATTC_ACT_GET_FIRST_INCL_SERVICE;
}
@ -349,10 +360,11 @@ esp_err_t esp_ble_gattc_read_char (uint16_t conn_id, esp_gatt_srvc_id_t *srvc_id
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GATTC;
msg.act = BTC_GATTC_ACT_READ_CHAR;
arg.conn_id = conn_id;
memcpy(&arg.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&arg.char_id, char_id, sizeof(esp_gatt_id_t));
arg.auth_req = auth_req;
arg.read_char.conn_id = conn_id;
memcpy(&arg.read_char.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&arg.read_char.char_id, char_id, sizeof(esp_gatt_id_t));
arg.read_char.auth_req = auth_req;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
@ -382,11 +394,12 @@ esp_err_t esp_ble_gattc_read_char_descr (uint16_t conn_id,
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GATTC;
msg.act = BTC_GATTC_ACT_READ_CHAR_DESCR;
arg.conn_id = conn_id;
memcpy(&arg.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&arg.char_id, char_id, sizeof(esp_gatt_id_t));
memcpy(&arg.descr_id, descr_id, sizeof(esp_gatt_id_t));
arg.auth_req = auth_req;
arg.read_descr.conn_id = conn_id;
memcpy(&arg.read_descr.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&arg.read_descr.char_id, char_id, sizeof(esp_gatt_id_t));
memcpy(&arg.read_descr.descr_id, descr_id, sizeof(esp_gatt_id_t));
arg.read_descr.auth_req = auth_req;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
@ -418,13 +431,14 @@ esp_err_t esp_ble_gattc_write_char( uint16_t conn_id,
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GATTC;
msg.act = BTC_GATTC_ACT_WRITE_CHAR;
arg.conn_id = (uint16_t) conn_id;
memcpy(&arg.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&arg.char_id, char_id, sizeof(esp_gatt_id_t));
arg.value_len = value_len > ESP_GATT_MAX_ATTR_LEN ? ESP_GATT_MAX_ATTR_LEN : value_len;
memcpy(arg.value, value, arg.value_len);
arg.auth_req = auth_req;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
arg.write_char.conn_id = (uint16_t) conn_id;
memcpy(&arg.write_char.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&arg.write_char.char_id, char_id, sizeof(esp_gatt_id_t));
arg.write_char.value_len = value_len > ESP_GATT_MAX_ATTR_LEN ? ESP_GATT_MAX_ATTR_LEN : value_len;
arg.write_char.value = value;
arg.write_char.auth_req = auth_req;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), btc_gattc_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
/*******************************************************************************
@ -457,14 +471,15 @@ esp_err_t esp_ble_gattc_write_char_descr (uint16_t conn_id,
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GATTC;
msg.act = BTC_GATTC_ACT_WRITE_CHAR_DESCR;
arg.conn_id = (uint16_t) conn_id;
memcpy(&arg.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&arg.char_id, char_id, sizeof(esp_gatt_id_t));
memcpy(&arg.descr_id, descr_id, sizeof(esp_gatt_id_t));
arg.value_len = value_len > ESP_GATT_MAX_ATTR_LEN ? ESP_GATT_MAX_ATTR_LEN : value_len;
memcpy(arg.value, value, arg.value_len);
arg.auth_req = auth_req;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
arg.write_descr.conn_id = (uint16_t) conn_id;
memcpy(&arg.write_descr.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&arg.write_descr.char_id, char_id, sizeof(esp_gatt_id_t));
memcpy(&arg.write_descr.descr_id, descr_id, sizeof(esp_gatt_id_t));
arg.write_descr.value_len = value_len > ESP_GATT_MAX_ATTR_LEN ? ESP_GATT_MAX_ATTR_LEN : value_len;
arg.write_descr.value = value;
arg.write_descr.auth_req = auth_req;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), btc_gattc_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
/*******************************************************************************
@ -497,14 +512,15 @@ esp_err_t esp_ble_gattc_prepare_write(uint16_t conn_id,
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GATTC;
msg.act = BTC_GATTC_ACT_PREPARE_WRITE;
arg.conn_id = conn_id;
memcpy(&arg.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&arg.char_id, char_id, sizeof(esp_gatt_id_t));
arg.offset = offset;
arg.value_len = value_len > ESP_GATT_MAX_ATTR_LEN ? ESP_GATT_MAX_ATTR_LEN : value_len; // length check ?
memcpy(arg.value, value, arg.value_len);
arg.auth_req = auth_req;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
arg.prep_write.conn_id = conn_id;
memcpy(&arg.prep_write.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&arg.prep_write.char_id, char_id, sizeof(esp_gatt_id_t));
arg.prep_write.offset = offset;
arg.prep_write.value_len = value_len > ESP_GATT_MAX_ATTR_LEN ? ESP_GATT_MAX_ATTR_LEN : value_len; // length check ?
arg.prep_write.value = value;
arg.prep_write.auth_req = auth_req;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), btc_gattc_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
@ -529,8 +545,9 @@ esp_err_t esp_ble_gattc_execute_write (uint16_t conn_id, bool is_execute)
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GATTC;
msg.act = BTC_GATTC_ACT_EXECUTE_WRITE;
arg.conn_id = conn_id;
arg.is_execute = is_execute;
arg.exec_write.conn_id = conn_id;
arg.exec_write.is_execute = is_execute;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
@ -561,10 +578,11 @@ esp_gatt_status_t esp_ble_gattc_register_for_notify (esp_gatt_if_t gatt_if,
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GATTC;
msg.act = BTC_GATTC_ACT_REG_FOR_NOTIFY;
arg.gatt_if = gatt_if;
memcpy(&arg.remote_bda, &server_bda, sizeof(esp_bd_addr_t));
memcpy(&arg.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&arg.char_id, char_id, sizeof(esp_gatt_id_t));
arg.reg_for_notify.gatt_if = gatt_if;
memcpy(&arg.reg_for_notify.remote_bda, &server_bda, sizeof(esp_bd_addr_t));
memcpy(&arg.reg_for_notify.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&arg.reg_for_notify.char_id, char_id, sizeof(esp_gatt_id_t));
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
@ -595,10 +613,11 @@ esp_gatt_status_t esp_ble_gattc_unregister_for_notify (esp_gatt_if_t gatt_if,
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GATTC;
msg.act = BTC_GATTC_ACT_UNREG_FOR_NOTIFY;
arg.gatt_if = gatt_if;
memcpy(&arg.remote_bda, &server_bda, sizeof(esp_bd_addr_t));
memcpy(&arg.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&arg.char_id, char_id, sizeof(esp_gatt_id_t));
arg.unreg_for_notify.gatt_if = gatt_if;
memcpy(&arg.unreg_for_notify.remote_bda, &server_bda, sizeof(esp_bd_addr_t));
memcpy(&arg.unreg_for_notify.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&arg.unreg_for_notify.char_id, char_id, sizeof(esp_gatt_id_t));
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}

View File

@ -17,7 +17,7 @@
#define ESP_GATTC_SEARCH_RES_EVT 7 /* GATT discovery result event */
#define ESP_GATTC_READ_DESCR_EVT 8 /* GATT read characterisitc descriptor event */
#define ESP_GATTC_WRITE_DESCR_EVT 9 /* GATT write characteristic descriptor event */
#define ESP_GATTC_NOTIF_EVT 10 /* GATT attribute notification event */
#define ESP_GATTC_NOTIFY_EVT 10 /* GATT attribute notification event */
#define ESP_GATTC_PREP_WRITE_EVT 11 /* GATT prepare write event */
#define ESP_GATTC_EXEC_EVT 12 /* execute write complete event */
#define ESP_GATTC_ACL_EVT 13 /* ACL up event */
@ -45,7 +45,8 @@
#define ESP_GATTC_GET_CHAR_EVT 35 /* get characteristic event */
#define ESP_GATTC_GET_DESCR_EVT 36 /* get characteristic descriptor event */
#define ESP_GATTC_GET_INCL_SRVC_EVT 37 /* get included service event */
#define ESP_GATTC_REG_FOR_NOTIF_EVT 38 /* register for notification event */
#define ESP_GATTC_REG_FOR_NOTIFY_EVT 38 /* register for notification event */
#define ESP_GATTC_UNREG_FOR_NOTIFY_EVT 39 /* unregister for notification event */
#define ESP_GATT_DEF_BLE_MTU_SIZE 23
@ -175,13 +176,18 @@ typedef union {
} get_incl_srvc;
/* ESP_GATTC_REG_FOR_NOTIF_EVT, ESP_GATTC_UNREG_FOR_NOTIF_EVT */
struct gattc_reg_for_notif_evt_param {
uint16_t conn_id;
bool registered;
struct gattc_reg_for_notify_evt_param {
esp_gatt_status_t status;
esp_gatt_srvc_id_t srvc_id;
esp_gatt_id_t char_id;
} reg_for_notif;
} reg_for_notify;
struct gattc_unreg_for_notify_evt_param {
esp_gatt_status_t status;
esp_gatt_srvc_id_t srvc_id;
esp_gatt_id_t char_id;
} unreg_for_notify;
} esp_ble_gattc_cb_param_t;

View File

@ -24,6 +24,75 @@
#define BTC_GATTC_CB_TO_APP(_event, _param) ((esp_profile_cb_t )btc_profile_cb_get(BTC_PID_GATTC))(_event, _param)
void btc_gattc_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
{
btc_ble_gattc_args_t *dst = (btc_ble_gattc_args_t*) p_dest;
btc_ble_gattc_args_t *src = (btc_ble_gattc_args_t *)p_src;
switch (msg->act) {
case BTC_GATTC_ACT_WRITE_CHAR: {
dst->write_char.value = (uint8_t *)GKI_getbuf(src->write_char.value_len);
if (dst->write_char.value) {
memcpy(dst->write_char.value, src->write_char.value, src->write_char.value_len);
} else {
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
}
break;
}
case BTC_GATTC_ACT_WRITE_CHAR_DESCR: {
dst->write_descr.value = (uint8_t *)GKI_getbuf(src->write_descr.value_len);
if (dst->write_descr.value) {
memcpy(dst->write_descr.value, src->write_descr.value, src->write_descr.value_len);
} else {
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
}
break;
}
case BTC_GATTC_ACT_PREPARE_WRITE: {
dst->prep_write.value = (uint8_t *)GKI_getbuf(src->prep_write.value_len);
if (dst->prep_write.value) {
memcpy(dst->prep_write.value, src->prep_write.value, src->prep_write.value_len);
} else {
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
}
break;
}
default:
LOG_DEBUG("%s Unhandled deep copy %d\n", __func__, msg->act);
break;
}
}
void btc_gattc_arg_deep_free(btc_msg_t *msg)
{
btc_ble_gattc_args_t *arg = (btc_ble_gattc_args_t*)msg->arg;
switch (msg->act) {
case BTC_GATTC_ACT_WRITE_CHAR: {
if (arg->write_char.value) {
GKI_freebuf(arg->write_char.value);
}
break;
}
case BTC_GATTC_ACT_WRITE_CHAR_DESCR: {
if (arg->write_descr.value) {
GKI_freebuf(arg->write_descr.value);
}
break;
}
case BTC_GATTC_ACT_PREPARE_WRITE: {
if (arg->prep_write.value) {
GKI_freebuf(arg->prep_write.value);
}
break;
}
default:
LOG_DEBUG("%s Unhandled deep free %d\n", __func__, msg->act);
break;
}
}
// TODO: to be finished, used in deep-copying data from lower layer
static void btc_gattc_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
{
@ -64,41 +133,41 @@ static void btc_gattc_app_register(btc_ble_gattc_args_t *arg)
{
tBT_UUID app_uuid;
app_uuid.len = 2;
app_uuid.uu.uuid16 = arg->app_id;
app_uuid.uu.uuid16 = arg->app_reg.app_id;
BTA_GATTC_AppRegister(&app_uuid, btc_gattc_cback);
}
static void btc_gattc_app_unregister(btc_ble_gattc_args_t *arg)
{
BTA_GATTC_AppDeregister(arg->gatt_if);
BTA_GATTC_AppDeregister(arg->app_unreg.gatt_if);
}
static void btc_gattc_open(btc_ble_gattc_args_t *arg)
{
tBTA_GATT_TRANSPORT transport = BTA_GATT_TRANSPORT_LE;
BTA_GATTC_Open(arg->gatt_if, arg->remote_bda, arg->is_direct, transport);
BTA_GATTC_Open(arg->open.gatt_if, arg->open.remote_bda, arg->open.is_direct, transport);
}
static void btc_gattc_close(btc_ble_gattc_args_t *arg)
{
// TODO; Review this call of BTA_API, check the usage of BTA_GATTC_CancelOpen
BTA_GATTC_Close(arg->conn_id);
BTA_GATTC_Close(arg->close.conn_id);
}
static void btc_gattc_cfg_mtu(btc_ble_gattc_args_t *arg)
{
BTA_GATTC_ConfigureMTU (arg->conn_id, arg->mtu);
BTA_GATTC_ConfigureMTU (arg->cfg_mtu.conn_id, arg->cfg_mtu.mtu);
}
static void btc_gattc_search_service(btc_ble_gattc_args_t *arg)
{
tBT_UUID srvc_uuid;
if (arg->have_uuid) {
btc_to_bta_uuid(&srvc_uuid, &arg->uuid);
BTA_GATTC_ServiceSearchRequest(arg->conn_id, &srvc_uuid);
if (arg->search_srvc.filter_uuid_enable) {
btc_to_bta_uuid(&srvc_uuid, &arg->search_srvc.filter_uuid);
BTA_GATTC_ServiceSearchRequest(arg->search_srvc.conn_id, &srvc_uuid);
} else {
BTA_GATTC_ServiceSearchRequest(arg->conn_id, NULL);
BTA_GATTC_ServiceSearchRequest(arg->search_srvc.conn_id, NULL);
}
}
@ -111,18 +180,17 @@ static void btc_gattc_get_first_char(btc_ble_gattc_args_t *arg)
tBTA_GATT_SRVC_ID srvc_id;
esp_ble_gattc_cb_param_t param;
btc_to_bta_srvc_id(&srvc_id, &arg->service_id);
status = BTA_GATTC_GetFirstChar(arg->conn_id, &srvc_id, NULL,
btc_to_bta_srvc_id(&srvc_id, &arg->get_first_char.service_id);
status = BTA_GATTC_GetFirstChar(arg->get_first_char.conn_id, &srvc_id, NULL,
&out_char_id, &out_char_prop);
if (status == 0) {
bta_to_btc_gatt_id(&char_id, &out_char_id.char_id);
bta_to_btc_gatt_id(&char_id, &out_char_id.char_id);
}
memset(&param, 0, sizeof(esp_ble_gattc_cb_param_t));
param.get_char.conn_id = arg->conn_id;
param.get_char.conn_id = arg->get_first_char.conn_id;
param.get_char.status = status;
memcpy(&param.get_char.srvc_id, &arg->service_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&param.get_char.srvc_id, &arg->get_first_char.service_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&param.get_char.char_id, &char_id, sizeof(esp_gatt_id_t));
param.get_char.char_prop = out_char_prop;
BTC_GATTC_CB_TO_APP(ESP_GATTC_GET_CHAR_EVT, &param);
@ -136,10 +204,10 @@ static void btc_gattc_get_next_char(btc_ble_gattc_args_t *arg)
tBTA_GATTC_CHAR_ID out_char_id;
tBTA_GATT_CHAR_PROP out_char_prop;
esp_ble_gattc_cb_param_t param;
btc_to_bta_srvc_id(&in_char_id.srvc_id, &arg->service_id);
btc_to_bta_gatt_id(&in_char_id.char_id, &arg->char_id);
btc_to_bta_srvc_id(&in_char_id.srvc_id, &arg->get_next_char.service_id);
btc_to_bta_gatt_id(&in_char_id.char_id, &arg->get_next_char.char_id);
status = BTA_GATTC_GetNextChar(arg->conn_id, &in_char_id, NULL,
status = BTA_GATTC_GetNextChar(arg->get_next_char.conn_id, &in_char_id, NULL,
&out_char_id, &out_char_prop);
if (status == 0) {
@ -147,9 +215,9 @@ static void btc_gattc_get_next_char(btc_ble_gattc_args_t *arg)
}
memset(&param, 0, sizeof(esp_ble_gattc_cb_param_t));
param.get_char.conn_id = arg->conn_id;
param.get_char.conn_id = arg->get_next_char.conn_id;
param.get_char.status = status;
memcpy(&param.get_char.srvc_id, &arg->service_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&param.get_char.srvc_id, &arg->get_next_char.service_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&param.get_char.char_id, &char_id, sizeof(esp_gatt_id_t));
param.get_char.char_prop = out_char_prop;
BTC_GATTC_CB_TO_APP(ESP_GATTC_GET_CHAR_EVT, &param);
@ -163,21 +231,21 @@ static void btc_gattc_get_first_descr(btc_ble_gattc_args_t *arg)
tBTA_GATTC_CHAR_DESCR_ID out_char_descr_id;
esp_ble_gattc_cb_param_t param;
btc_to_bta_srvc_id(&in_char_id.srvc_id, &arg->service_id);
btc_to_bta_gatt_id(&in_char_id.char_id, &arg->char_id);
btc_to_bta_srvc_id(&in_char_id.srvc_id, &arg->get_first_descr.service_id);
btc_to_bta_gatt_id(&in_char_id.char_id, &arg->get_first_descr.char_id);
status = BTA_GATTC_GetFirstCharDescr(arg->conn_id, &in_char_id, NULL,
status = BTA_GATTC_GetFirstCharDescr(arg->get_first_descr.conn_id, &in_char_id, NULL,
&out_char_descr_id);
if (status == 0) {
bta_to_btc_gatt_id(&descr_id, &out_char_descr_id.descr_id);
bta_to_btc_gatt_id(&descr_id, &out_char_descr_id.descr_id);
}
memset(&param, 0, sizeof(esp_ble_gattc_cb_param_t));
param.get_descr.conn_id = arg->conn_id;
param.get_descr.conn_id = arg->get_first_descr.conn_id;
param.get_descr.status = status;
memcpy(&param.get_descr.srvc_id, &arg->service_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&param.get_descr.char_id, &arg->char_id, sizeof(esp_gatt_id_t));
memcpy(&param.get_descr.srvc_id, &arg->get_first_descr.service_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&param.get_descr.char_id, &arg->get_first_descr.char_id, sizeof(esp_gatt_id_t));
memcpy(&param.get_descr.descr_id, &descr_id, sizeof(esp_gatt_id_t));
BTC_GATTC_CB_TO_APP(ESP_GATTC_GET_DESCR_EVT, &param);
}
@ -190,21 +258,21 @@ static void btc_gattc_get_next_descr(btc_ble_gattc_args_t *arg)
tBTA_GATTC_CHAR_DESCR_ID out_char_descr_id;
esp_ble_gattc_cb_param_t param;
btc_to_bta_srvc_id(&in_char_descr_id.char_id.srvc_id, &arg->service_id);
btc_to_bta_gatt_id(&in_char_descr_id.char_id.char_id, &arg->char_id);
btc_to_bta_gatt_id(&in_char_descr_id.descr_id, &arg->descr_id);
btc_to_bta_srvc_id(&in_char_descr_id.char_id.srvc_id, &arg->get_next_descr.service_id);
btc_to_bta_gatt_id(&in_char_descr_id.char_id.char_id, &arg->get_next_descr.char_id);
btc_to_bta_gatt_id(&in_char_descr_id.descr_id, &arg->get_next_descr.descr_id);
status = BTA_GATTC_GetNextCharDescr(arg->conn_id, &in_char_descr_id
status = BTA_GATTC_GetNextCharDescr(arg->get_next_descr.conn_id, &in_char_descr_id
, NULL, &out_char_descr_id);
if (status == 0) {
bta_to_btc_gatt_id(&descr_id, &out_char_descr_id.descr_id);
}
memset(&param, 0, sizeof(esp_ble_gattc_cb_param_t));
param.get_descr.conn_id = arg->conn_id;
param.get_descr.conn_id = arg->get_next_descr.conn_id;
param.get_descr.status = status;
memcpy(&param.get_descr.srvc_id, &arg->service_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&param.get_descr.char_id, &arg->char_id, sizeof(esp_gatt_id_t));
memcpy(&param.get_descr.srvc_id, &arg->get_next_descr.service_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&param.get_descr.char_id, &arg->get_next_descr.char_id, sizeof(esp_gatt_id_t));
memcpy(&param.get_descr.descr_id, &descr_id, sizeof(esp_gatt_id_t));
BTC_GATTC_CB_TO_APP(ESP_GATTC_GET_DESCR_EVT, &param);
}
@ -217,17 +285,17 @@ static void btc_gattc_get_first_incl_service(btc_ble_gattc_args_t *arg)
tBTA_GATTC_INCL_SVC_ID out_incl_svc_id;
esp_ble_gattc_cb_param_t param;
btc_to_bta_srvc_id(&srvc_id, &arg->service_id);
btc_to_bta_srvc_id(&srvc_id, &arg->get_first_incl_srvc.service_id);
status = BTA_GATTC_GetFirstIncludedService(arg->conn_id, &srvc_id,
status = BTA_GATTC_GetFirstIncludedService(arg->get_first_incl_srvc.conn_id, &srvc_id,
NULL, &out_incl_svc_id);
bta_to_btc_srvc_id(&incl_srvc_id, &out_incl_svc_id.incl_svc_id);
memset(&param, 0, sizeof(esp_ble_gattc_cb_param_t));
param.get_incl_srvc.conn_id = arg->conn_id;
param.get_incl_srvc.conn_id = arg->get_first_incl_srvc.conn_id;
param.get_incl_srvc.status = status;
memcpy(&param.get_incl_srvc.srvc_id, &arg->service_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&param.get_incl_srvc.srvc_id, &arg->get_first_incl_srvc.service_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&param.get_incl_srvc.incl_srvc_id, &incl_srvc_id, sizeof(esp_gatt_srvc_id_t));
BTC_GATTC_CB_TO_APP(ESP_GATTC_GET_INCL_SRVC_EVT, &param);
}
@ -240,18 +308,18 @@ static void btc_gattc_get_next_incl_service(btc_ble_gattc_args_t *arg)
tBTA_GATTC_INCL_SVC_ID out_incl_svc_id;
esp_ble_gattc_cb_param_t param;
btc_to_bta_srvc_id(&in_incl_svc_id.srvc_id, &arg->service_id);
btc_to_bta_srvc_id(&in_incl_svc_id.incl_svc_id, &arg->start_service_id);
btc_to_bta_srvc_id(&in_incl_svc_id.srvc_id, &arg->get_next_incl_srvc.service_id);
btc_to_bta_srvc_id(&in_incl_svc_id.incl_svc_id, &arg->get_next_incl_srvc.start_service_id);
status = BTA_GATTC_GetNextIncludedService(arg->conn_id, &in_incl_svc_id,
status = BTA_GATTC_GetNextIncludedService(arg->get_next_incl_srvc.conn_id, &in_incl_svc_id,
NULL, &out_incl_svc_id);
bta_to_btc_srvc_id(&incl_srvc_id, &out_incl_svc_id.incl_svc_id);
memset(&param, 0, sizeof(esp_ble_gattc_cb_param_t));
param.get_incl_srvc.conn_id = arg->conn_id;
param.get_incl_srvc.conn_id = arg->get_next_incl_srvc.conn_id;
param.get_incl_srvc.status = status;
memcpy(&param.get_incl_srvc.srvc_id, &arg->service_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&param.get_incl_srvc.srvc_id, &arg->get_next_incl_srvc.service_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&param.get_incl_srvc.incl_srvc_id, &incl_srvc_id, sizeof(esp_gatt_srvc_id_t));
BTC_GATTC_CB_TO_APP(ESP_GATTC_GET_INCL_SRVC_EVT, &param);
}
@ -259,19 +327,19 @@ static void btc_gattc_get_next_incl_service(btc_ble_gattc_args_t *arg)
static void btc_gattc_read_char(btc_ble_gattc_args_t *arg)
{
tBTA_GATTC_CHAR_ID in_char_id;
btc_to_bta_srvc_id(&in_char_id.srvc_id, &arg->service_id);
btc_to_bta_gatt_id(&in_char_id.char_id, &arg->char_id);
BTA_GATTC_ReadCharacteristic(arg->conn_id, &in_char_id, arg->auth_req);
btc_to_bta_srvc_id(&in_char_id.srvc_id, &arg->read_char.service_id);
btc_to_bta_gatt_id(&in_char_id.char_id, &arg->read_char.char_id);
BTA_GATTC_ReadCharacteristic(arg->read_char.conn_id, &in_char_id, arg->read_char.auth_req);
}
static void btc_gattc_read_char_descr(btc_ble_gattc_args_t *arg)
{
tBTA_GATTC_CHAR_DESCR_ID in_char_descr_id;
btc_to_bta_srvc_id(&in_char_descr_id.char_id.srvc_id, &arg->service_id);
btc_to_bta_gatt_id(&in_char_descr_id.char_id.char_id, &arg->char_id);
btc_to_bta_gatt_id(&in_char_descr_id.descr_id, &arg->descr_id);
btc_to_bta_srvc_id(&in_char_descr_id.char_id.srvc_id, &arg->read_descr.service_id);
btc_to_bta_gatt_id(&in_char_descr_id.char_id.char_id, &arg->read_descr.char_id);
btc_to_bta_gatt_id(&in_char_descr_id.descr_id, &arg->read_descr.descr_id);
BTA_GATTC_ReadCharDescr(arg->conn_id, &in_char_descr_id, arg->auth_req);
BTA_GATTC_ReadCharDescr(arg->read_descr.conn_id, &in_char_descr_id, arg->read_descr.auth_req);
}
static void btc_gattc_write_char(btc_ble_gattc_args_t *arg)
@ -280,14 +348,14 @@ static void btc_gattc_write_char(btc_ble_gattc_args_t *arg)
tBTA_GATTC_CHAR_ID in_char_id;
tBTA_GATTC_WRITE_TYPE write_type = BTA_GATTC_TYPE_WRITE;
btc_to_bta_srvc_id(&in_char_id.srvc_id, &arg->service_id);
btc_to_bta_gatt_id(&in_char_id.char_id, &arg->char_id);
btc_to_bta_srvc_id(&in_char_id.srvc_id, &arg->write_char.service_id);
btc_to_bta_gatt_id(&in_char_id.char_id, &arg->write_char.char_id);
BTA_GATTC_WriteCharValue(arg->conn_id, &in_char_id,
BTA_GATTC_WriteCharValue(arg->write_char.conn_id, &in_char_id,
write_type,
arg->value_len,
arg->value,
arg->auth_req);
arg->write_char.value_len,
arg->write_char.value,
arg->write_char.auth_req);
}
static void btc_gattc_write_char_descr(btc_ble_gattc_args_t *arg)
@ -296,31 +364,35 @@ static void btc_gattc_write_char_descr(btc_ble_gattc_args_t *arg)
tBTA_GATTC_CHAR_DESCR_ID in_char_descr_id;
tBTA_GATT_UNFMT descr_val;
tBTA_GATTC_WRITE_TYPE write_type = BTA_GATTC_TYPE_WRITE;
btc_to_bta_srvc_id(&in_char_descr_id.char_id.srvc_id, &arg->service_id);
btc_to_bta_gatt_id(&in_char_descr_id.char_id.char_id, &arg->char_id);
btc_to_bta_gatt_id(&in_char_descr_id.descr_id, &arg->descr_id);
btc_to_bta_srvc_id(&in_char_descr_id.char_id.srvc_id, &arg->write_descr.service_id);
btc_to_bta_gatt_id(&in_char_descr_id.char_id.char_id, &arg->write_descr.char_id);
btc_to_bta_gatt_id(&in_char_descr_id.descr_id, &arg->write_descr.descr_id);
descr_val.len = arg->value_len;
descr_val.p_value = arg->value;
descr_val.len = arg->write_descr.value_len;
descr_val.p_value = arg->write_descr.value;
BTA_GATTC_WriteCharDescr(arg->conn_id, &in_char_descr_id,
BTA_GATTC_WriteCharDescr(arg->write_descr.conn_id, &in_char_descr_id,
write_type, &descr_val,
arg->auth_req);
arg->write_descr.auth_req);
}
static void btc_gattc_prepare_write(btc_ble_gattc_args_t *arg)
{
tBTA_GATTC_CHAR_ID in_char_id;
btc_to_bta_srvc_id(&in_char_id.srvc_id, &arg->service_id);
btc_to_bta_gatt_id(&in_char_id.char_id, &arg->char_id);
btc_to_bta_srvc_id(&in_char_id.srvc_id, &arg->prep_write.service_id);
btc_to_bta_gatt_id(&in_char_id.char_id, &arg->prep_write.char_id);
BTA_GATTC_PrepareWrite(arg->conn_id, &in_char_id, arg->offset, arg->value_len,
arg->value, arg->auth_req);
BTA_GATTC_PrepareWrite(arg->prep_write.conn_id,
&in_char_id,
arg->prep_write.offset,
arg->prep_write.value_len,
arg->prep_write.value,
arg->prep_write.auth_req);
}
static void btc_gattc_execute_wrtie(btc_ble_gattc_args_t *arg)
{
BTA_GATTC_ExecuteWrite(arg->conn_id, arg->is_execute);
BTA_GATTC_ExecuteWrite(arg->exec_write.conn_id, arg->exec_write.is_execute);
}
static void btc_gattc_reg_for_notify(btc_ble_gattc_args_t *arg)
@ -329,19 +401,18 @@ static void btc_gattc_reg_for_notify(btc_ble_gattc_args_t *arg)
tBTA_GATTC_CHAR_ID in_char_id;
esp_ble_gattc_cb_param_t param;
btc_to_bta_srvc_id(&in_char_id.srvc_id, &arg->service_id);
btc_to_bta_gatt_id(&in_char_id.char_id, &arg->char_id);
btc_to_bta_srvc_id(&in_char_id.srvc_id, &arg->reg_for_notify.service_id);
btc_to_bta_gatt_id(&in_char_id.char_id, &arg->reg_for_notify.char_id);
status = BTA_GATTC_RegisterForNotifications(arg->gatt_if,
arg->remote_bda, &in_char_id);
status = BTA_GATTC_RegisterForNotifications(arg->reg_for_notify.gatt_if,
arg->reg_for_notify.remote_bda,
&in_char_id);
memset(&param, 0, sizeof(esp_ble_gattc_cb_param_t));
param.reg_for_notif.conn_id = arg->conn_id;
param.reg_for_notif.status = status;
param.reg_for_notif.registered = true;
memcpy(&param.reg_for_notif.srvc_id, &arg->service_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&param.reg_for_notif.char_id, &arg->service_id, sizeof(esp_gatt_id_t));
BTC_GATTC_CB_TO_APP(ESP_GATTC_REG_FOR_NOTIF_EVT, &param);
param.reg_for_notify.status = status;
memcpy(&param.reg_for_notify.srvc_id, &arg->reg_for_notify.service_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&param.reg_for_notify.char_id, &arg->reg_for_notify.service_id, sizeof(esp_gatt_id_t));
BTC_GATTC_CB_TO_APP(ESP_GATTC_REG_FOR_NOTIFY_EVT, &param);
}
static void btc_gattc_unreg_for_notify(btc_ble_gattc_args_t *arg)
@ -350,19 +421,18 @@ static void btc_gattc_unreg_for_notify(btc_ble_gattc_args_t *arg)
tBTA_GATTC_CHAR_ID in_char_id;
esp_ble_gattc_cb_param_t param;
btc_to_bta_srvc_id(&in_char_id.srvc_id, &arg->service_id);
btc_to_bta_gatt_id(&in_char_id.char_id, &arg->char_id);
btc_to_bta_srvc_id(&in_char_id.srvc_id, &arg->unreg_for_notify.service_id);
btc_to_bta_gatt_id(&in_char_id.char_id, &arg->unreg_for_notify.char_id);
status = BTA_GATTC_DeregisterForNotifications(arg->gatt_if,
arg->remote_bda, &in_char_id);
status = BTA_GATTC_DeregisterForNotifications(arg->unreg_for_notify.gatt_if,
arg->unreg_for_notify.remote_bda,
&in_char_id);
memset(&param, 0, sizeof(esp_ble_gattc_cb_param_t));
param.reg_for_notif.conn_id = arg->conn_id;
param.reg_for_notif.status = status;
param.reg_for_notif.registered = false;
memcpy(&param.reg_for_notif.srvc_id, &arg->service_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&param.reg_for_notif.char_id, &arg->service_id, sizeof(esp_gatt_id_t));
BTC_GATTC_CB_TO_APP(ESP_GATTC_REG_FOR_NOTIF_EVT, &param);
param.unreg_for_notify.status = status;
memcpy(&param.unreg_for_notify.srvc_id, &arg->unreg_for_notify.service_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&param.unreg_for_notify.char_id, &arg->unreg_for_notify.service_id, sizeof(esp_gatt_id_t));
BTC_GATTC_CB_TO_APP(ESP_GATTC_UNREG_FOR_NOTIFY_EVT, &param);
}
void btc_gattc_call_handler(btc_msg_t *msg)
@ -432,8 +502,9 @@ void btc_gattc_call_handler(btc_msg_t *msg)
default:
LOG_ERROR("%s: Unhandled event (%d)!\n", __FUNCTION__, msg->act);
break;
}
btc_gattc_arg_deep_free(msg);
}
void btc_gattc_cb_handler(btc_msg_t *msg)
@ -523,7 +594,7 @@ void btc_gattc_cb_handler(btc_msg_t *msg)
param.notify.value_len = (notify->len > ESP_GATT_MAX_ATTR_LEN) ? \
ESP_GATT_MAX_ATTR_LEN : notify->len;
memcpy(&param.notify.value, notify->value, param.notify.value_len);
BTC_GATTC_CB_TO_APP(ESP_GATTC_NOTIF_EVT, &param);
BTC_GATTC_CB_TO_APP(ESP_GATTC_NOTIFY_EVT, &param);
if (notify->is_notify == FALSE) {
BTA_GATTC_SendIndConfirm(notify->conn_id, &notify->char_id);

View File

@ -7,7 +7,7 @@
#include "esp_gattc_api.h"
typedef enum {
BTC_GATTC_ACT_APP_REGISTER,
BTC_GATTC_ACT_APP_REGISTER = 0,
BTC_GATTC_ACT_APP_UNREGISTER,
BTC_GATTC_ACT_OPEN,
BTC_GATTC_ACT_CLOSE,
@ -31,26 +31,137 @@ typedef enum {
/* btc_ble_gattc_args_t */
typedef struct {
esp_gatt_if_t gatt_if; /* internal is server_if or client_if */
esp_gatt_srvc_id_t service_id;
esp_gatt_srvc_id_t start_service_id;
esp_gatt_id_t char_id;
esp_gatt_id_t descr_id;
esp_gatt_auth_req_t auth_req;
esp_bd_addr_t remote_bda;
esp_bt_uuid_t uuid;
bool have_uuid;
uint16_t app_id;
uint16_t conn_id;
uint16_t mtu;
uint16_t offset;
bool is_direct;
bool is_execute;
uint16_t value_len;
uint8_t value[ESP_GATT_MAX_ATTR_LEN];
//BTC_GATTC_ACT_APP_REGISTER,
struct app_reg_arg {
uint16_t app_id;
} app_reg;
//BTC_GATTC_ACT_APP_UNREGISTER,
struct app_unreg_arg {
esp_gatt_if_t gatt_if;
} app_unreg;
//BTC_GATTC_ACT_OPEN,
struct open_arg {
esp_gatt_if_t gatt_if;
esp_bd_addr_t remote_bda;
bool is_direct;
} open;
//BTC_GATTC_ACT_CLOSE,
struct close_arg {
uint16_t conn_id;
} close;
//BTC_GATTC_ACT_CFG_MTU,
struct cfg_mtu_arg {
uint16_t conn_id;
uint16_t mtu;
} cfg_mtu;
//BTC_GATTC_ACT_SEARCH_SERVICE,
struct search_srvc_arg {
uint16_t conn_id;
bool filter_uuid_enable;
esp_bt_uuid_t filter_uuid;
} search_srvc;
//BTC_GATTC_ACT_GET_FIRST_CHAR,
struct get_first_char_arg {
uint16_t conn_id;
esp_gatt_srvc_id_t service_id;
} get_first_char;
//BTC_GATTC_ACT_GET_NEXT_CHAR,
struct get_next_char_arg {
uint16_t conn_id;
esp_gatt_srvc_id_t service_id;
esp_gatt_id_t char_id;
} get_next_char;
//BTC_GATTC_ACT_GET_FIRST_DESCR,
struct get_first_descr_arg {
uint16_t conn_id;
esp_gatt_srvc_id_t service_id;
esp_gatt_id_t char_id;
} get_first_descr;
//BTC_GATTC_ACT_GET_NEXT_DESCR,
struct get_next_descr_arg {
uint16_t conn_id;
esp_gatt_srvc_id_t service_id;
esp_gatt_id_t char_id;
esp_gatt_id_t descr_id;
} get_next_descr;
//BTC_GATTC_ACT_GET_FIRST_INCL_SERVICE,
struct get_first_incl_srvc_arg {
uint16_t conn_id;
esp_gatt_srvc_id_t service_id;
} get_first_incl_srvc;
//BTC_GATTC_ACT_GET_NEXT_INCL_SERVICE,
struct get_next_incl_srvc_arg {
uint16_t conn_id;
esp_gatt_srvc_id_t service_id;
esp_gatt_srvc_id_t start_service_id;
} get_next_incl_srvc;
//BTC_GATTC_ACT_READ_CHAR,
struct read_char_arg {
uint16_t conn_id;
esp_gatt_srvc_id_t service_id;
esp_gatt_id_t char_id;
esp_gatt_auth_req_t auth_req;
} read_char;
//BTC_GATTC_ACT_READ_CHAR_DESCR,
struct read_descr_arg {
uint16_t conn_id;
esp_gatt_srvc_id_t service_id;
esp_gatt_id_t char_id;
esp_gatt_id_t descr_id;
esp_gatt_auth_req_t auth_req;
} read_descr;
//BTC_GATTC_ACT_WRITE_CHAR,
struct write_char_arg {
uint16_t conn_id;
uint16_t value_len;
esp_gatt_srvc_id_t service_id;
esp_gatt_id_t char_id;
uint8_t *value;
esp_gatt_auth_req_t auth_req;
} write_char;
//BTC_GATTC_ACT_WRITE_CHAR_DESCR,
struct write_descr_arg {
uint16_t conn_id;
uint16_t value_len;
esp_gatt_srvc_id_t service_id;
esp_gatt_id_t char_id;
esp_gatt_id_t descr_id;
uint8_t *value;
esp_gatt_auth_req_t auth_req;
} write_descr;
//BTC_GATTC_ACT_PREPARE_WRITE,
struct prep_write_arg {
uint16_t conn_id;
esp_gatt_srvc_id_t service_id;
esp_gatt_id_t char_id;
uint16_t offset;
uint16_t value_len;
uint8_t *value;
esp_gatt_auth_req_t auth_req;
} prep_write;
//BTC_GATTC_ACT_EXECUTE_WRITE,
struct exec_write_arg {
uint16_t conn_id;
bool is_execute;
} exec_write;
//BTC_GATTC_ACT_REG_FOR_NOTIFY,
struct reg_for_notify_arg {
esp_gatt_if_t gatt_if;
esp_bd_addr_t remote_bda;
esp_gatt_srvc_id_t service_id;
esp_gatt_id_t char_id;
} reg_for_notify;
//BTC_GATTC_ACT_UNREG_FOR_NOTIFY
struct unreg_for_notify_arg {
esp_gatt_if_t gatt_if;
esp_bd_addr_t remote_bda;
esp_gatt_srvc_id_t service_id;
esp_gatt_id_t char_id;
} unreg_for_notify;
} btc_ble_gattc_args_t;
void btc_gattc_call_handler(btc_msg_t *msg);
void btc_gattc_cb_handler(btc_msg_t *msg);
void btc_gattc_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
#endif /* __BTC_GATTC_H__ */