static gboolean cur_adv_state[NUM_SERVER_INST];
static gatt_server_t gatt_servers[NUM_SERVER_INST];
-static int default_client_id = -1;
-static int pending_gattc_req = OAL_REQ_NONE;
-
/* Forward declarations of GATT Server callbacks */
static void cb_gatts_register_app(int status, int server_if, bt_uuid_t *uuid);
static void cb_gatts_multi_adv_enable(int server_if, int status);
bool need_rsp, bool is_prep, uint8_t* value);
static void cb_gatts_response_confirmation(int status, int handle);
+static void cb_gatts_acquire_write(int fd, int conn_id, int trans_id, int attr_handle, bt_bdaddr_t*);
+static void cb_gatts_acquire_notify(int fd, int conn_id, int trans_id, int attr_handle);
+
static void cb_indication_confirmation(int conn_id, int trans_id, int attr_handle, bt_bdaddr_t *bda);
static void cb_gatts_connection(int conn_id, int server_if, int connected, bt_bdaddr_t *bda);
/*TODO GATT Server callbacks will be implemented in subsequent patches */
static const btgatt_server_callbacks_t btgatt_server_callbacks = {
- cb_gatts_register_app,
- cb_gatts_connection,
- cb_gatts_service_added,
- cb_gatts_included_service_added,
- cb_gatts_characteristic_added,
- cb_gatts_descriptor_added,
- cb_gatts_service_started,
- cb_gatts_service_stopped,
- cb_gatts_service_deleted,
- cb_indication_confirmation,
- cb_gatts_request_read,
- cb_gatts_request_write,
- NULL, /*cb_gatts_request_exec_write,*/
- cb_gatts_response_confirmation,
- cb_gatts_listen,
- cb_gatts_multi_adv_enable,
- cb_gatts_multi_adv_update,
- cb_gatts_multi_adv_set_inst_data,
- cb_gatts_multi_adv_disable,
- cb_gatts_mtu_changed,
+ .register_server_cb = cb_gatts_register_app,
+ .connection_cb = cb_gatts_connection,
+ .service_added_cb = cb_gatts_service_added,
+ .included_service_added_cb = cb_gatts_included_service_added,
+ .characteristic_added_cb = cb_gatts_characteristic_added,
+ .descriptor_added_cb = cb_gatts_descriptor_added,
+ .service_started_cb = cb_gatts_service_started,
+ .service_stopped_cb = cb_gatts_service_stopped,
+ .service_deleted_cb = cb_gatts_service_deleted,
+ .indication_confirmation_cb = cb_indication_confirmation,
+ .request_read_cb = cb_gatts_request_read,
+ .request_write_cb = cb_gatts_request_write,
+ .request_exec_write_cb = NULL,
+ .response_confirmation_cb = cb_gatts_response_confirmation,
+ .listen_cb = cb_gatts_listen,
+ .multi_adv_enable_cb = cb_gatts_multi_adv_enable,
+ .multi_adv_update_cb = cb_gatts_multi_adv_update,
+ .multi_adv_data_cb = cb_gatts_multi_adv_set_inst_data,
+ .multi_adv_disable_cb = cb_gatts_multi_adv_disable,
+ .mtu_changed_cb = cb_gatts_mtu_changed,
#ifdef TIZEN_BT_HAL
- cb_notifcation_changed,
+ .notif_enabled_cb = cb_notifcation_changed,
#endif
+ .request_acquire_write_cb = cb_gatts_acquire_write,
+ .request_acquire_notify_cb = cb_gatts_acquire_notify
};
/* Forward declaration for GATT client callbacks */
static void cb_gattc_read_descriptor(int conn_id, int status, btgatt_read_params_t *p_data);
static void cb_gattc_write_characteristic(int conn_id, int status, btgatt_write_params_t *p_data);
static void cb_gattc_write_descriptor(int conn_id, int status, btgatt_write_params_t *p_data);
+static void cb_gattc_register_for_notification(int conn_id, int registered, int status,
+ btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id);
+static void cb_gattc_notify(int conn_id, btgatt_notify_params_t *p_data);
+static void cb_gattc_service_changed(bt_bdaddr_t *bd_addr, int change_type, uint8_t *uuid);
+static void cb_gattc_configure_mtu_cmpl(int conn_id, int status, int mtu);
/*TODO GATT CLient callbacks will be implemented in subsequent patches */
static const btgatt_client_callbacks_t btgatt_client_callbacks = {
- cb_gattc_register_app,
- cb_gattc_scan_result,
- cb_gattc_connection, /*cb_gattc_connection*/
- cb_gattc_disconnect, /*cb_gattc_disconnect*/
- cb_gattc_search_complete, /*cb_gattc_search_complete*/
- cb_gattc_search_result, /*cb_gattc_search_result*/
- cb_gattc_get_characteristics, /*cb_gattc_get_characteristics*/
- cb_gattc_get_descriptor, /*cb_gattc_get_descriptor*/
- NULL, /*cb_gattc_get_included_service*/
- NULL, /*cb_gattc_register_for_notification*/
- NULL, /*cb_gattc_notify*/
- cb_gattc_read_characteristic, /*cb_gattc_read_characteristic*/
- cb_gattc_write_characteristic, /*cb_gattc_write_characteristic*/
- cb_gattc_read_descriptor, /*cb_gattc_read_descriptor*/
- cb_gattc_write_descriptor, /*cb_gattc_write_descriptor*/
- NULL, /*cb_gattc_execute_write*/
- NULL, /*cb_gattc_remote_rssi*/
- NULL, /*cb_gattc_configure_mtu_cmpl*/
+ .register_client_cb = cb_gattc_register_app,
+ .scan_result_cb = cb_gattc_scan_result,
+ .open_cb = cb_gattc_connection,
+ .close_cb = cb_gattc_disconnect,
+ .search_complete_cb = cb_gattc_search_complete,
+ .search_result_cb = cb_gattc_search_result,
+ .get_characteristic_cb = cb_gattc_get_characteristics,
+ .get_descriptor_cb = cb_gattc_get_descriptor,
+ .get_included_service_cb = NULL,
+ .register_for_notification_cb = cb_gattc_register_for_notification,
+ .notify_cb = cb_gattc_notify,
+ .service_changed_cb = cb_gattc_service_changed,
+ .read_characteristic_cb = cb_gattc_read_characteristic,
+ .write_characteristic_cb = cb_gattc_write_characteristic,
+ .read_descriptor_cb = cb_gattc_read_descriptor,
+ .write_descriptor_cb = cb_gattc_write_descriptor,
+ .execute_write_cb = NULL,
+ .read_remote_rssi_cb = NULL,
+ .configure_mtu_cb = cb_gattc_configure_mtu_cmpl,
#ifdef PLATFORM_ANDROID_HAL
- NULL, /*cb_scan_filter_cfg*/
- NULL, /*cb_scan_filter_param*/
- NULL, /*cb_scan_filter_status*/
- NULL, /*cb_congestion*/
- NULL, /*cb_batchscan_cfg_storag*/
- NULL, /*cb_batchscan_enb_disable*/
- NULL, /*cb_batchscan_reports*/
- NULL, /*cb_batchscan_threshold*/
- NULL, /*cb_track_adv_event*/
+ .scan_filter_cfg_cb = NULL,
+ .scan_filter_param_cb = NULL,
+ .scan_filter_status_cb = NULL,
+ .congestion_cb = NULL,
+ .batchscan_cfg_storage_cb = NULL,
+ .batchscan_enb_disable_cb = NULL,
+ .batchscan_reports_cb = NULL,
+ .batchscan_threshold_cb = NULL,
+ .track_adv_event_cb = NULL,
#endif
};
return OAL_STATUS_SUCCESS;
}
+oal_status_t gatts_set_filter_policy(int filter_policy)
+{
+ int ret = OAL_STATUS_SUCCESS;
+
+ CHECK_OAL_GATT_ENABLED();
+
+ /* send the filter_policy value to the HAL Layer */
+ ret = gatt_api->server->set_filter_policy(filter_policy);
+
+ if (ret != BT_STATUS_SUCCESS) {
+ BT_ERR("set_filter_policy failed: %d",ret);
+ return convert_to_oal_status(ret);
+ }
+
+ return OAL_STATUS_SUCCESS;
+}
+
oal_status_t gatts_multi_adv_update(int instance_id,
int min_intv, int max_intv,
int adv_type, int chnl_map,
adv_setup.timeout_s = adv_param_setup->timeout_s;
adv_setup.server_if = gatt_servers[instance_id - 1].server_id;
- if (adv_setup.manufacturer_data_len > 0 && adv_setup.manufacturer_data != NULL) {
- BT_INFO("Manufacture data.....\n");
- PRINT_ADV_DATA(adv_setup.manufacturer_data_len, adv_setup.manufacturer_data, adv_setup.set_scan_rsp);
- }
- if (adv_setup.service_uuid_len > 0 && adv_setup.service_uuid != NULL) {
- BT_INFO("Service uuid.....\n");
- PRINT_ADV_DATA(adv_setup.service_uuid_len, adv_setup.service_uuid, FALSE);
+ ret = gatt_api->server->multi_adv_set_inst_data(adv_setup);
+ if (ret != BT_STATUS_SUCCESS) {
+ BT_ERR("GATT Set Multi advertising data failed: %s", status2string(ret));
+ gatt_servers[instance_id - 1].state = GATT_INS_DISABLED;
+ return convert_to_oal_status(ret);
}
+ return OAL_STATUS_SUCCESS;
+}
+oal_status_t gatts_disconnect(int instance_id, bt_address_t *device_address, int conn_id)
+{
+ int ret = OAL_STATUS_SUCCESS;
+ bdstr_t bdstr;
- ret = gatt_api->server->multi_adv_set_inst_data(adv_setup);
+ API_TRACE("Server Disonnect: instance_id = %d, conn_id = %d", instance_id, conn_id);
+ CHECK_OAL_GATT_ENABLED();
+ CHECK_SERVER_INSTANCE(instance_id);
+ CHECK_SERVER_REGISTRATION(instance_id);
+
+ API_TRACE("[%s]", bdt_bd2str(device_address, &bdstr));
+
+ ret = gatt_api->server->disconnect(gatt_servers[instance_id - 1].server_id, (bt_bdaddr_t *) device_address, conn_id);
if (ret != BT_STATUS_SUCCESS) {
- BT_ERR("GATT Set Multi advertising data failed: %s", status2string(ret));
- gatt_servers[instance_id - 1].state = GATT_INS_DISABLED;
+ BT_ERR("GATT Server disconnect failed: %s", status2string(ret));
return convert_to_oal_status(ret);
}
return OAL_STATUS_SUCCESS;
}
+
/************************************GATT Server Functions*************************************/
/*Server Callbacks*/
static void cb_gatts_register_app(int status, int server_if, bt_uuid_t *uuid)
cur_adv_state[event->server_inst - 1] = new_state;
} else {
BT_ERR("Invalid Callback...");
+ g_free(event);
return;
}
ret = gatt_api->server->get_att_mtu(conn_id, mtu);
if (ret != BT_STATUS_SUCCESS) {
- BT_ERR("GATT MTU Size failed, status: %d", status2string(ret));
+ BT_ERR("GATT MTU Size failed, status: %s", status2string(ret));
return convert_to_oal_status(ret);
}
BT_INFO("Current ATT MTU Size: %d", *mtu);
return OAL_STATUS_SUCCESS;
}
+oal_status_t gatt_send_response_acquire(int conn_id, int trans_id,
+ int status, int fd, int mtu , void * fdlist)
+{
+ int ret = OAL_STATUS_SUCCESS;
+
+ API_TRACE("Server Send Response : ConnId = %d, TransId = %d, %d", conn_id, trans_id, fd);
+ CHECK_OAL_GATT_ENABLED();
+
+ ret = gatt_api->server->send_response_acquire(conn_id, trans_id, status, fd, mtu, fdlist);
+ if (ret != BT_STATUS_SUCCESS) {
+ BT_ERR("GATT Server Send Response failed: %s", status2string(ret));
+ return convert_to_oal_status(ret);
+ }
+ return OAL_STATUS_SUCCESS;
+}
oal_status_t gatts_add_service(int instance_id, oal_gatt_srvc_id_t *gatt_serv_id,
int num_handles)
{
{
int ret = OAL_STATUS_SUCCESS;
- API_TRACE("Server Update Value: Ins_id = [%d], att handle = [%d] data len [%d]",
- ins_id, value->handle, value->len);
-
CHECK_OAL_GATT_ENABLED();
CHECK_SERVER_INSTANCE(ins_id);
return OAL_STATUS_INVALID_PARAM;
}
+ API_TRACE("Server Update Value: Ins_id = [%d], att handle = [%d] data len [%d]",
+ ins_id, value->handle, value->len);
+
ret = gatt_api->server->update_att_value(gatt_servers[ins_id - 1].server_id,
(int)value->handle, (int)value->len, (char*)value->value);
event_gatts_conn_t *event = g_new0(event_gatts_conn_t, 1);
for (ins_id = 1 ; ins_id <= NUM_SERVER_INST ; ins_id++) {
- if ((gatt_servers[ins_id - 1].server_id == server_if) &&
- (gatt_servers[ins_id - 1].state == GATT_INS_ENABLED)) {
+ if ((gatt_servers[ins_id - 1].server_id == server_if)) {
event->server_inst = ins_id;
break;
} else {
memcpy(event->address.addr, bda->address, BT_ADDRESS_BYTES_NUM);
event->conn_id = conn_id;
event_type = ((connected == TRUE) ? OAL_EVENT_GATTS_CONNECTION_COMPLETED : OAL_EVENT_GATTS_DISCONNECTION_COMPLETED);
+ event->status = OAL_STATUS_SUCCESS;
send_event(event_type, event, sizeof(event_gatts_conn_t));
}
send_event(OAL_EVENT_GATTS_REQUEST_WRITE, event, sizeof(event_gatts_srvc_write_attr_t));
}
+static void cb_gatts_acquire_write(int mtu, int conn_id, int trans_id, int attr_handle , bt_bdaddr_t *bda)
+
+{
+ BT_INFO("BTGATT SERVER REQUEST ACQUIRE WRITE conn_id:%d", conn_id);
+
+ event_gatts_srvc_acquire_attr_t* event = g_new0(event_gatts_srvc_acquire_attr_t, 1);
+
+ event->attr_trans.attr_handle = attr_handle;
+ event->attr_trans.conn_id = conn_id;
+ event->attr_trans.trans_id = trans_id;
+ event->mtu = mtu;
+ memcpy(event->address.addr, bda->address, BT_ADDRESS_BYTES_NUM);
+
+ send_event(OAL_EVENT_GATTS_REQUEST_ACQUIRE_WRITE, event, sizeof(event_gatts_srvc_acquire_attr_t));
+}
+
+static void cb_gatts_acquire_notify(int mtu, int conn_id, int trans_id, int attr_handle)
+{
+ BT_INFO("BTGATT SERVER REQUEST ACQUIRE NOTIFY conn_id:%d", conn_id);
+
+ event_gatts_srvc_acquire_attr_t* event = g_new0(event_gatts_srvc_acquire_attr_t, 1);
+
+ event->attr_trans.attr_handle = attr_handle;
+ event->attr_trans.conn_id = conn_id;
+ event->attr_trans.trans_id = trans_id;
+ event->mtu = mtu;
+
+ send_event(OAL_EVENT_GATTS_REQUEST_ACQUIRE_NOTIFY, event, sizeof(event_gatts_srvc_acquire_attr_t));
+
+}
+
static void cb_gatts_response_confirmation(int status, int handle)
{
BT_INFO("BTGATT SERVER RESPONSE CONFIRMATION CB, status:%d, handle:%d", status, handle);
char uuid_str[BT_UUID_STRING_MAX];
event_gattc_register_t *event;
- BT_INFO("+");
-
/* Check if GATT client registered for Default GATT client UUID */
uuid_to_string((service_uuid_t *)app_uuid, uuid_str);
- BT_INFO("UUID:%s", uuid_str);
- BT_INFO("BTGATT CLIENT REGISTER APP CB, status:%d, clientIf:%d", status, clientIf);
+ BT_INFO("GATT CLIENT REGISTER APP CB, status:%d, clientIf:%d, %s", status, clientIf, uuid_str);
event = g_new0(event_gattc_register_t, 1);
event->client_if = clientIf;
event->status = (status == 0 ? OAL_STATUS_SUCCESS : OAL_STATUS_INTERNAL_ERROR);
BT_INFO("BTGATT Client Service Search Result cb, conn_id:%d", conn_id);
uuid_to_stringname((oal_uuid_t *)&(srvc_id->id.uuid), uuid_str);
- BT_INFO("Service=> UUID: [%s], Inst_id: [%u], Type: [%s]",
+ BT_INFO("Service=> [%s], Inst_id [%u], Type [%s]",
uuid_str, srvc_id->id.inst_id, srvc_id->is_primary ? "Primary" : "Secondary");
event_gattc_service_result_t *event = g_new0(event_gattc_service_result_t, 1);
char uuid_str1[2*BT_UUID_STRING_MAX];
char uuid_str2[2*BT_UUID_STRING_MAX];
char str[50];
+
BT_INFO("BTGATT Client Get Characteristic Callback, conn_id:%d, status:%d", conn_id, status);
uuid_to_stringname((oal_uuid_t *)&(srvc_id->id.uuid), uuid_str1);
- BT_INFO("Service=> UUID: [%s], Inst_id: [%u], Type: [%s]",
+ BT_INFO("Service=> [%s], Inst_id [%u], Type [%s]",
uuid_str1, srvc_id->id.inst_id, srvc_id->is_primary ? "Primary" : "Secondary");
event_gattc_characteristic_result_t *event = g_new0(event_gattc_characteristic_result_t, 1);
if (status == 0) {
uuid_to_stringname((oal_uuid_t *)&(char_id->uuid), uuid_str2);
- BT_INFO("Charac=> UUID: [%s], Inst_id: [%u], Prop: [%s]",
+ BT_INFO("Charac => [%s], Inst_id [%u], Prop [%s]",
uuid_str2, char_id->inst_id, char_prop_to_string(char_prop, str));
event->char_prop = char_prop;
memcpy(&(event->char_id), char_id, sizeof(oal_gatt_id_t));
BT_INFO("BTGATT Client Get Descriptor Callback, conn_id:%d, status:%d", conn_id, status);
uuid_to_stringname((oal_uuid_t *)&(srvc_id->id.uuid), uuid_str1);
uuid_to_stringname((oal_uuid_t *)&(char_id->uuid), uuid_str2);
- BT_INFO("Service=> UUID: [%s], Inst_id: [%u], Type: [%s]",
+ BT_INFO("Service=> [%s], Inst_id [%u], Type [%s]",
uuid_str1, srvc_id->id.inst_id, srvc_id->is_primary ? "Primary" : "Secondary");
- BT_INFO("Charac=> UUID: [%s], Inst_id: [%u]", uuid_str2, char_id->inst_id);
+ BT_INFO("Charac => [%s], Inst_id [%u]", uuid_str2, char_id->inst_id);
event_gattc_descriptor_result_t *event = g_new0(event_gattc_descriptor_result_t, 1);
event->conn_status.conn_id = conn_id;
if (status == 0) {
uuid_to_stringname((oal_uuid_t *)&(descr_id->uuid), uuid_str3);
- BT_INFO("Desc=> UUID: [%s], Inst_id: [%u]", uuid_str3, descr_id->inst_id);
+ BT_INFO("Desc => [%s], Inst_id [%u]", uuid_str3, descr_id->inst_id);
memcpy(&(event->descr_id), descr_id, sizeof(oal_gatt_id_t));
}
send_event(OAL_EVENT_GATTC_DESC_SERACH_RESULT, event, sizeof(*event));
}
+static void cb_gattc_register_for_notification(int client_if, int registered, int status, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id)
+{
+ char uuid_str1[2*BT_UUID_STRING_MAX];
+ char uuid_str2[2*BT_UUID_STRING_MAX];
+ BT_INFO("BTGATT Client Register For Notification Callback, client_if:%d, status:%d, registered: %s",
+ client_if, status, registered == 1 ? "REGISTERED" : "DEREGISTERED");
+ uuid_to_stringname((oal_uuid_t *)&(srvc_id->id.uuid), uuid_str1);
+ uuid_to_stringname((oal_uuid_t *)&(char_id->uuid), uuid_str2);
+ BT_INFO("Service=> [%s], Inst_id [%u], Type [%s]", uuid_str1, srvc_id->id.inst_id, srvc_id->is_primary ? "Primary" : "Secondary");
+ BT_INFO("Charac => [%s], Inst_id [%u]", uuid_str2, char_id->inst_id);
+
+ event_gattc_regdereg_notify_t *event = g_new0(event_gattc_regdereg_notify_t, 1);
+ oal_event_t event_type = (registered == 1 ? OAL_EVENT_GATTC_NOTIFICATION_REGISTERED : OAL_EVENT_GATTC_NOTIFICATION_DEREGISTERED);
+ event->client_if = client_if;
+ event->status = convert_to_oal_status(status);
+ memcpy(&(event->srvc_id), srvc_id, sizeof(oal_gatt_srvc_id_t));
+ memcpy(&(event->char_id), char_id, sizeof(oal_gatt_id_t));
+
+ send_event(event_type, event, sizeof(*event));
+}
+
+static void cb_gattc_notify(int conn_id, btgatt_notify_params_t *p_data)
+{
+ bdstr_t bdstr;
+ char uuid_str1[2*BT_UUID_STRING_MAX];
+ char uuid_str2[2*BT_UUID_STRING_MAX];
+
+ BT_INFO("BTGATT Client Notify Callback, conn_id:%d", conn_id);
+ BT_INFO("Server Address:[%s], is_notify:[%d], len:[%d]",
+ bdt_bd2str((bt_address_t *)&(p_data->bda), &bdstr), p_data->is_notify, p_data->len);
+
+ uuid_to_stringname((oal_uuid_t *)&(p_data->srvc_id.id.uuid), uuid_str1);
+ uuid_to_stringname((oal_uuid_t *)&(p_data->char_id.uuid), uuid_str2);
+
+ BT_INFO("Service=> [%s], Inst_id [%u], Type [%s]",
+ uuid_str1, p_data->srvc_id.id.inst_id, p_data->srvc_id.is_primary ? "Primary" : "Secondary");
+ BT_INFO("Charac => [%s], Inst_id [%u]", uuid_str2, p_data->char_id.inst_id);
+
+ if (p_data->len > 0) {
+ char *data = NULL;
+ data = g_malloc(3*p_data->len+1);
+ if (!data) {
+ BT_ERR("memory allocation failed");
+ return;
+ }
+
+ convert_hex_2_str((unsigned char *)p_data->value, p_data->len, data);
+ BT_INFO("Notified Data: [%s]", data);
+
+ event_gattc_notify_data *event = g_new0(event_gattc_notify_data, 1);
+ memcpy(event->address.addr, p_data->bda.address, BT_ADDRESS_BYTES_NUM);
+ event->is_notify = p_data->is_notify;
+ event->data_len = p_data->len;
+ memcpy(event->data, p_data->value, event->data_len);
+ memcpy(&(event->char_id), &(p_data->char_id), sizeof(oal_gatt_id_t));
+ memcpy(&(event->srvc_id), &(p_data->srvc_id), sizeof(oal_gatt_srvc_id_t));
+
+ send_event_bda_trace(OAL_EVENT_GATTC_NOTIFY_DATA, event, sizeof(*event), (bt_address_t *)&p_data->bda);
+ g_free(data);
+ }
+}
+
+static void cb_gattc_service_changed(bt_bdaddr_t *bd_addr, int change_type, uint8_t *uuid)
+{
+ event_gattc_service_changed_data *event = g_new0(event_gattc_service_changed_data, 1);
+
+ memcpy(event->address.addr, bd_addr->address, 6);
+ event->change_type = change_type;
+ memcpy(event->uuid.uuid, uuid, sizeof(event->uuid.uuid));
+
+ send_event_bda_trace(OAL_EVENT_GATTC_SERVICE_CHANGED_IND, event, sizeof(*event), (bt_address_t *)bd_addr);
+}
+
static void cb_gattc_read_characteristic(int conn_id, int status, btgatt_read_params_t *p_data)
{
char uuid_str1[2*BT_UUID_STRING_MAX];
if (status == 0) {
uuid_to_stringname((oal_uuid_t *)&(p_data->srvc_id.id.uuid), uuid_str1);
uuid_to_stringname((oal_uuid_t *)&(p_data->char_id.uuid), uuid_str2);
- BT_INFO("Service=> UUID: [%s], Inst_id: [%u], Type: [%s]", uuid_str1,
+ BT_INFO("Service=> [%s], Inst_id [%u], Type [%s]", uuid_str1,
p_data->srvc_id.id.inst_id, p_data->srvc_id.is_primary ? "Primary" : "Secondary");
- BT_INFO("Charac=> UUID: [%s], Inst_id: [%u]", uuid_str2, p_data->char_id.inst_id);
- BT_INFO("Len: %u, value_type: %u", p_data->value.len, p_data->value_type);
+ BT_INFO("Charac => [%s], Inst_id [%u]", uuid_str2, p_data->char_id.inst_id);
+ BT_DBG("Len: %u, value_type: %u", p_data->value.len, p_data->value_type);
if (p_data->value.len > 0 && event->value_type == GATTC_READ_VALUE_TYPE_VALUE) {
char *data = NULL;
data = g_malloc(3*p_data->value.len+1);
return;
}
convert_hex_2_str((unsigned char *)p_data->value.value, p_data->value.len, data);
- BT_INFO("Read Data: [%s]", data);
+ BT_DBG("Read Data: [%s]", data);
event->data_len = p_data->value.len;
memcpy(&(event->data), &(p_data->value.value), event->data_len);
g_free(data);
if (status == 0) {
uuid_to_stringname((oal_uuid_t *)&(p_data->srvc_id.id.uuid), uuid_str1);
uuid_to_stringname((oal_uuid_t *)&(p_data->char_id.uuid), uuid_str2);
- BT_INFO("Service=> UUID: [%s], Inst_id: [%u], Type: [%s]", uuid_str1,
+ BT_INFO("Service=> [%s], Inst_id [%u], Type [%s]", uuid_str1,
p_data->srvc_id.id.inst_id, p_data->srvc_id.is_primary ? "Primary" : "Secondary");
- BT_INFO("Charac=> UUID: [%s], Inst_id: [%u]", uuid_str2, p_data->char_id.inst_id);
+ BT_INFO("Charac => [%s], Inst_id [%u]", uuid_str2, p_data->char_id.inst_id);
}
send_event(OAL_EVENT_GATTC_WRITE_CHARAC, event, sizeof(*event));
}
uuid_to_stringname((oal_uuid_t *)&(p_data->srvc_id.id.uuid), uuid_str1);
uuid_to_stringname((oal_uuid_t *)&(p_data->char_id.uuid), uuid_str2);
uuid_to_stringname((oal_uuid_t *)&(p_data->descr_id.uuid), uuid_str3);
- BT_INFO("Service=> UUID: [%s], Inst_id: [%u], Type: [%s]", uuid_str1,
+ BT_INFO("Service=> [%s], Inst_id [%u], Type [%s]", uuid_str1,
p_data->srvc_id.id.inst_id, p_data->srvc_id.is_primary ? "Primary" : "Secondary");
- BT_INFO("Charac=> UUID: [%s], Inst_id: [%u]", uuid_str2, p_data->char_id.inst_id);
- BT_INFO("Desc=> UUID: [%s], Inst_id: [%u]", uuid_str3, p_data->descr_id.inst_id);
+ BT_INFO("Charac => [%s], Inst_id [%u]", uuid_str2, p_data->char_id.inst_id);
+ BT_INFO("Desc => [%s], Inst_id [%u]", uuid_str3, p_data->descr_id.inst_id);
}
send_event(OAL_EVENT_GATTC_WRITE_DESCR, event, sizeof(*event));
}
uuid_to_stringname((oal_uuid_t *)&(p_data->srvc_id.id.uuid), uuid_str1);
uuid_to_stringname((oal_uuid_t *)&(p_data->char_id.uuid), uuid_str2);
uuid_to_stringname((oal_uuid_t *)&(p_data->descr_id.uuid), uuid_str3);
- BT_INFO("Service=> UUID: [%s], Inst_id: [%u], Type: [%s]", uuid_str1,
+ BT_INFO("Service=> [%s], Inst_id [%u], Type [%s]", uuid_str1,
p_data->srvc_id.id.inst_id, p_data->srvc_id.is_primary ? "Primary" : "Secondary");
- BT_INFO("Charac=> UUID: [%s], Inst_id: [%u]", uuid_str2, p_data->char_id.inst_id);
- BT_INFO("Desc=> UUID: [%s], Inst_id: [%u]", uuid_str3, p_data->descr_id.inst_id);
- BT_INFO("Len: %u, value_type: %u", p_data->value.len, p_data->value_type);
+ BT_INFO("Charac => [%s], Inst_id [%u]", uuid_str2, p_data->char_id.inst_id);
+ BT_INFO("Desc => [%s], Inst_id [%u]", uuid_str3, p_data->descr_id.inst_id);
+ BT_DBG("Len: %u, value_type: %u", p_data->value.len, p_data->value_type);
if (p_data->value.len > 0 && event->value_type == GATTC_READ_VALUE_TYPE_VALUE) {
char *data = NULL;
data = g_malloc(3*p_data->value.len+1);
return;
}
convert_hex_2_str((unsigned char *)p_data->value.value, p_data->value.len, data);
- BT_INFO("Read Data: [%s]", data);
+ BT_DBG("Read Data: [%s]", data);
event->data_len = p_data->value.len;
memcpy(&(event->data), &(p_data->value.value), event->data_len);
g_free(data);
send_event(OAL_EVENT_GATTC_READ_DESCR, event, sizeof(*event));
}
-
-/* Register default gatt client to be used in LE scan etc. */
-static oal_status_t __register_default_gatt_client(void)
-{
- bt_uuid_t uuid;
- int ret;
-
- API_TRACE("GATT client register");
- CHECK_OAL_GATT_ENABLED();
-
- if (default_client_id >= 0) {
- BT_ERR("Client Already registered");
- return OAL_STATUS_ALREADY_DONE;
- }
-
- string_to_uuid(DEFAULT_GATT_CLIENT_UUID, (service_uuid_t *)&uuid);
- ret = gatt_api->client->register_client(&uuid);
- if (ret != BT_STATUS_SUCCESS) {
- BT_ERR("GATT client register failed: %s", status2string(ret));
- return convert_to_oal_status(ret);
- }
-
- return OAL_STATUS_SUCCESS;
-}
-
oal_status_t gattc_start_le_discovery(int client_id)
{
BT_ERR("Error:Start LE Discovery failed: %s", status2string(ret));
return convert_to_oal_status(ret);
}
- send_event(OAL_EVENT_BLE_DISCOVERY_STARTED, NULL, 0);
return OAL_STATUS_SUCCESS;
}
if (ret != BT_STATUS_SUCCESS) {
BT_ERR("Error:Stop LE Discovery failed: %s", status2string(ret));
return convert_to_oal_status(ret);
- } else
- send_event(OAL_EVENT_BLE_DISCOVERY_STOPPED, NULL, 0);
+ }
return OAL_STATUS_SUCCESS;
}
return OAL_STATUS_SUCCESS;
}
+
+static void cb_gattc_configure_mtu_cmpl(int conn_id, int status, int mtu)
+{
+ event_gattc_mtu_configured_t *event;
+ BT_INFO("BTGATT Client configure mtu complete Callback, conn_id: %d, status: %d, mtu: %d",
+ conn_id, status, mtu);
+ event = g_new0(event_gattc_mtu_configured_t, 1);
+ event->conn_id = conn_id;
+ event->mtu = mtu;
+ event->status = convert_to_oal_status(status);
+ send_event(OAL_EVENT_GATTC_MTU_EXCHANGE_COMPLETED, event, sizeof(*event));
+}
+
/************************************ GATT Client ***********************************/
oal_status_t gattc_register(oal_uuid_t* client_uuid)
{
return OAL_STATUS_SUCCESS;
}
+oal_status_t gattc_register_for_notification(int client_id, bt_address_t * address,
+ oal_gatt_srvc_id_t *srvc_id, oal_gatt_id_t *char_id) {
+ int ret = OAL_STATUS_SUCCESS;
+ char uuid_str1[2*BT_UUID_STRING_MAX];
+ char uuid_str2[2*BT_UUID_STRING_MAX];
+ bdstr_t bdstr;
+
+ OAL_CHECK_PARAMETER(address, return);
+ OAL_CHECK_PARAMETER(srvc_id, return);
+ OAL_CHECK_PARAMETER(char_id, return);
+ uuid_to_stringname(&(srvc_id->id.uuid), uuid_str1);
+ uuid_to_stringname(&(char_id->uuid), uuid_str2);
+ API_TRACE("Client Register Notification: [%s], Service_uuid: [%s], Char_uuid: [%s]", bdt_bd2str(address, &bdstr), uuid_str1, uuid_str2);
+ CHECK_OAL_GATT_ENABLED();
+ CHECK_CLIENT_REGISTRATION(client_id);
+
+ ret = gatt_api->client->register_for_notification(client_id, (bt_bdaddr_t *)address, (btgatt_srvc_id_t *)srvc_id, (btgatt_gatt_id_t *)char_id);
+ if (ret != BT_STATUS_SUCCESS) {
+ BT_ERR("GATT client register notification failed: %s", status2string(ret));
+ return convert_to_oal_status(ret);
+ }
+
+ return OAL_STATUS_SUCCESS;
+}
+
+oal_status_t gattc_deregister_for_notification(int client_id, bt_address_t * address,
+ oal_gatt_srvc_id_t *srvc_id, oal_gatt_id_t *char_id) {
+ int ret = OAL_STATUS_SUCCESS;
+ char uuid_str1[2*BT_UUID_STRING_MAX];
+ char uuid_str2[2*BT_UUID_STRING_MAX];
+ bdstr_t bdstr;
+
+ OAL_CHECK_PARAMETER(address, return);
+ OAL_CHECK_PARAMETER(srvc_id, return);
+ OAL_CHECK_PARAMETER(char_id, return);
+ uuid_to_stringname(&(srvc_id->id.uuid), uuid_str1);
+ uuid_to_stringname(&(char_id->uuid), uuid_str2);
+ API_TRACE("Client Deregister Notification: [%s], Service_uuid: [%s], Char_uuid: [%s]", bdt_bd2str(address, &bdstr), uuid_str1, uuid_str2);
+ CHECK_OAL_GATT_ENABLED();
+ CHECK_CLIENT_REGISTRATION(client_id);
+
+ ret = gatt_api->client->deregister_for_notification(client_id, (bt_bdaddr_t *)address, (btgatt_srvc_id_t *)srvc_id, (btgatt_gatt_id_t *)char_id);
+ if (ret != BT_STATUS_SUCCESS) {
+ BT_ERR("GATT client deregister notification failed: %s", status2string(ret));
+ return convert_to_oal_status(ret);
+ }
+
+ return OAL_STATUS_SUCCESS;
+}
+
+
oal_status_t gattc_read_characteristic(int conn_id, oal_gatt_srvc_id_t *srvc_id,
oal_gatt_id_t *char_id, oal_gatt_auth_req_t auth_req)
{
return OAL_STATUS_SUCCESS;
}
+oal_status_t gattc_acquire_notify(int conn_id, oal_gatt_srvc_id_t *srvc_id,
+ oal_gatt_id_t *char_id, int *fd, int *mtu)
+{
+ int ret = OAL_STATUS_SUCCESS;
+ char uuid_str1[2*BT_UUID_STRING_MAX];
+ char uuid_str2[2*BT_UUID_STRING_MAX];
+ OAL_CHECK_PARAMETER(srvc_id, return);
+ OAL_CHECK_PARAMETER(char_id, return);
+ uuid_to_stringname(&(srvc_id->id.uuid), uuid_str1);
+ uuid_to_stringname(&(char_id->uuid), uuid_str2);
+ API_TRACE("Client Write Characteristic: Service_uuid: [%s], Char_uuid: [%s]", uuid_str1, uuid_str2);
+ CHECK_OAL_GATT_ENABLED();
+ CHECK_CLIENT_CONNECTION(conn_id);
+
+ ret = gatt_api->client->acquire_notify(conn_id, (btgatt_srvc_id_t *)srvc_id,
+ (btgatt_gatt_id_t *)char_id, fd, mtu);
+ if (ret != BT_STATUS_SUCCESS) {
+ BT_ERR("GATT client write characteristic failed: %s", status2string(ret));
+ return convert_to_oal_status(ret);
+ }
+
+ return OAL_STATUS_SUCCESS;
+}
+
+oal_status_t gattc_acquire_write(int conn_id, oal_gatt_srvc_id_t *srvc_id,
+ oal_gatt_id_t *char_id, oal_gatt_auth_req_t auth_req , int *fd, int*mtu)
+{
+ int ret = OAL_STATUS_SUCCESS;
+ char uuid_str1[2*BT_UUID_STRING_MAX];
+ char uuid_str2[2*BT_UUID_STRING_MAX];
+ OAL_CHECK_PARAMETER(srvc_id, return);
+ OAL_CHECK_PARAMETER(char_id, return);
+ uuid_to_stringname(&(srvc_id->id.uuid), uuid_str1);
+ uuid_to_stringname(&(char_id->uuid), uuid_str2);
+ API_TRACE("Client Write Characteristic: Service_uuid: [%s], Char_uuid: [%s]", uuid_str1, uuid_str2);
+ CHECK_OAL_GATT_ENABLED();
+ CHECK_CLIENT_CONNECTION(conn_id);
+
+ ret = gatt_api->client->acquire_write(conn_id, (btgatt_srvc_id_t *)srvc_id,
+ (btgatt_gatt_id_t *)char_id, auth_req, fd, mtu);
+ if (ret != BT_STATUS_SUCCESS) {
+ BT_ERR("GATT client write characteristic failed: %s", status2string(ret));
+ return convert_to_oal_status(ret);
+ }
+
+ return OAL_STATUS_SUCCESS;
+}
+
oal_status_t gattc_write_characteristic(int conn_id, oal_gatt_srvc_id_t *srvc_id,
oal_gatt_id_t *char_id, oal_gatt_write_type_t write_type,
int len, oal_gatt_auth_req_t auth_req, char* data)
}
return OAL_STATUS_SUCCESS;
}
+
+oal_status_t gattc_unregister_scan_filter(int slot_id)
+{
+ int ret;
+ int client_if = 0;
+
+ API_TRACE("");
+ CHECK_OAL_GATT_ENABLED();
+
+ BT_INFO("Remove Scan filter Slot ID is: [%d]", slot_id);
+
+ ret = gatt_api->client->scan_filter_clear(client_if, slot_id);
+ if (ret != BT_STATUS_SUCCESS) {
+ BT_ERR("error: %s", status2string(ret));
+ return convert_to_oal_status(ret);
+ }
+ return OAL_STATUS_SUCCESS;
+}
+
+oal_status_t gattc_enable_scan_filter(int client_if)
+{
+ int ret;
+
+ API_TRACE("");
+ CHECK_OAL_GATT_ENABLED();
+
+ BT_INFO("Enable Scan filter. Client If: %d", client_if);
+
+ ret = gatt_api->client->scan_filter_enable(client_if, TRUE);
+ if (ret != BT_STATUS_SUCCESS) {
+ BT_ERR("error: %s", status2string(ret));
+ return convert_to_oal_status(ret);
+ }
+ return OAL_STATUS_SUCCESS;
+}
+
+oal_status_t gattc_disable_scan_filter(int client_if)
+{
+ int ret;
+
+ API_TRACE("");
+ CHECK_OAL_GATT_ENABLED();
+
+ BT_INFO("Disable Scan filter. Client If: %d", client_if);
+
+ ret = gatt_api->client->scan_filter_enable(client_if, FALSE);
+ if (ret != BT_STATUS_SUCCESS) {
+ BT_ERR("error: %s", status2string(ret));
+ return convert_to_oal_status(ret);
+ }
+ return OAL_STATUS_SUCCESS;
+}
+
+oal_status_t gattc_register_scan_filter(oal_ble_scan_filter_t* filter_data)
+{
+ int ret;
+ int client_info = 0;
+ int action = 0;
+ int company_id = 0;
+ int company_id_mask = 0;
+ int address_type = 0;
+ int feature_selection = 0;
+
+ oal_ble_scan_filter_param_setup_t scan_filter_setup = {.list_logic_type = 0,
+ .filt_logic_type = 1,
+ .rssi_high_thres = -127,
+ .rssi_low_thres = -127,
+ .dely_mode = 0,
+ .found_timeout = 0,
+ .lost_timeout = 0,
+ .found_timeout_cnt = 0
+ };
+
+ OAL_CHECK_PARAMETER(filter_data, return);
+ API_TRACE();
+ CHECK_OAL_GATT_ENABLED();
+
+ if (filter_data->added_features & OAL_BLE_SCAN_FILTER_FEATURE_DEVICE_ADDRESS){
+ bdstr_t bdstr;
+ BT_INFO("OAL_BLE_SCAN_FILTER_FEATURE_DEVICE_ADDRESS is being added");
+ BT_INFO("BT remote Device address is %s", bdt_bd2str(filter_data->device_address, &bdstr));
+ ret = gatt_api->client->scan_filter_add_remove(client_info,
+ action,
+ OAL_BLE_SCAN_FILTER_FEATURE_DEVICE_ADDRESS,
+ filter_data->slot_id,
+ company_id,
+ company_id_mask,
+ NULL,
+ NULL,
+ (bt_bdaddr_t*)filter_data->device_address,
+ address_type,
+ 0,
+ NULL,
+ 0,
+ NULL
+ );
+ if (ret != BT_STATUS_SUCCESS){
+ BT_ERR("error: %s", status2string(ret));
+ BT_INFO("unregistering already set filter features.");
+ gatt_api->client->scan_filter_clear(client_info, filter_data->slot_id);
+ return convert_to_oal_status(ret);
+ }
+
+ feature_selection |= OAL_BLE_SCAN_FILTER_FEATURE_DEVICE_ADDRESS;
+ }
+ if (filter_data->added_features & OAL_BLE_SCAN_FILTER_FEATURE_DEVICE_NAME){
+ ret = gatt_api->client->scan_filter_add_remove(client_info,
+ action,
+ OAL_BLE_SCAN_FILTER_FEATURE_DEVICE_NAME,
+ filter_data->slot_id,
+ company_id,
+ company_id_mask,
+ NULL,
+ NULL,
+ NULL,
+ address_type,
+ 0,
+ filter_data->device_name, // device_name as p_data in HAL
+ 0,
+ NULL
+ );
+ if (ret != BT_STATUS_SUCCESS){
+ BT_ERR("error: %s", status2string(ret));
+ BT_INFO("unregistering already set filter features.");
+ gatt_api->client->scan_filter_clear(client_info, filter_data->slot_id);
+ return convert_to_oal_status(ret);
+ }
+
+ feature_selection |= OAL_BLE_SCAN_FILTER_FEATURE_DEVICE_NAME;
+ }
+ if (filter_data->added_features & OAL_BLE_SCAN_FILTER_FEATURE_SERVICE_UUID){
+ BT_INFO("OAL_BLE_SCAN_FILTER_FEATURE_SERVICE_UUID is being added");
+ char uuid_str1[2*BT_UUID_STRING_MAX];
+ char uuid_str2[2*BT_UUID_STRING_MAX];
+
+ uuid_to_stringname((service_uuid_t*)filter_data->service_uuid, uuid_str1);
+ uuid_to_stringname((service_uuid_t*)filter_data->service_uuid_mask, uuid_str2);
+
+ BT_INFO("Service UUID is [%s] and Service UUID mask is [%s]", uuid_str1, uuid_str2);
+ ret = gatt_api->client->scan_filter_add_remove(client_info,
+ action,
+ OAL_BLE_SCAN_FILTER_FEATURE_SERVICE_UUID,
+ filter_data->slot_id,
+ company_id,
+ company_id_mask,
+ (bt_uuid_t*)filter_data->service_uuid,
+ (bt_uuid_t*)filter_data->service_uuid_mask,
+ NULL,
+ address_type,
+ filter_data->service_uuid_len, // service_uuid_len as data_len in HAL
+ NULL,
+ filter_data->service_uuid_mask_len,
+ NULL
+ );
+ if (ret != BT_STATUS_SUCCESS){
+ BT_ERR("error: %s", status2string(ret));
+ BT_INFO("unregistering already set filter features.");
+ gatt_api->client->scan_filter_clear(client_info, filter_data->slot_id);
+ return convert_to_oal_status(ret);
+ }
+
+ feature_selection |= OAL_BLE_SCAN_FILTER_FEATURE_SERVICE_UUID;
+ }
+ if (filter_data->added_features & OAL_BLE_SCAN_FILTER_FEATURE_SERVICE_SOLICITATION_UUID){
+ BT_INFO("OAL_BLE_SCAN_FILTER_FEATURE_SERVICE_SOLICITATION_UUID is being added");
+ char uuid_str1[2*BT_UUID_STRING_MAX];
+ char uuid_str2[2*BT_UUID_STRING_MAX];
+ uuid_to_stringname((service_uuid_t*)filter_data->service_solicitation_uuid, uuid_str1);
+ uuid_to_stringname((service_uuid_t*)filter_data->service_solicitation_uuid_mask, uuid_str2);
+ BT_INFO("Service Solicitation UUID is [%s] and Service Solicitation UUID mask is [%s]", uuid_str1, uuid_str2);
+ ret = gatt_api->client->scan_filter_add_remove(client_info,
+ action,
+ OAL_BLE_SCAN_FILTER_FEATURE_SERVICE_SOLICITATION_UUID,
+ filter_data->slot_id,
+ company_id,
+ company_id_mask,
+ (bt_uuid_t*)filter_data->service_solicitation_uuid,
+ (bt_uuid_t*)filter_data->service_solicitation_uuid_mask,
+ NULL,
+ address_type,
+ filter_data->service_solicitation_uuid_len, // service_solicitation_uuid_len as data_len in HAL
+ NULL,
+ filter_data->service_solicitation_uuid_mask_len,
+ NULL
+ );
+ if (ret != BT_STATUS_SUCCESS){
+ BT_ERR("error: %s", status2string(ret));
+ BT_INFO("unregistering already set filter features.");
+ gatt_api->client->scan_filter_clear(client_info, filter_data->slot_id);
+ return convert_to_oal_status(ret);
+ }
+
+ feature_selection |= OAL_BLE_SCAN_FILTER_FEATURE_SERVICE_SOLICITATION_UUID;
+ }
+ if (filter_data->added_features & OAL_BLE_SCAN_FILTER_FEATURE_SERVICE_DATA){
+ ret = gatt_api->client->scan_filter_add_remove(client_info,
+ action,
+ OAL_BLE_SCAN_FILTER_FEATURE_SERVICE_DATA,
+ filter_data->slot_id,
+ company_id,
+ company_id_mask,
+ NULL,
+ NULL,
+ NULL,
+ address_type,
+ filter_data->service_data_len, //service_data_len as data_len in HAL
+ (char*)filter_data->service_data,
+ filter_data->service_data_mask_len,
+ (char*)filter_data->service_data_mask
+ );
+ if (ret != BT_STATUS_SUCCESS){
+ BT_ERR("error: %s", status2string(ret));
+ BT_INFO("unregistering already set filter features.");
+ gatt_api->client->scan_filter_clear(client_info, filter_data->slot_id);
+ return convert_to_oal_status(ret);
+ }
+
+ feature_selection |= OAL_BLE_SCAN_FILTER_FEATURE_SERVICE_DATA;
+ }
+ if (filter_data->added_features & OAL_BLE_SCAN_FILTER_FEATURE_MANUFACTURER_DATA){
+ ret = gatt_api->client->scan_filter_add_remove(client_info,
+ action,
+ OAL_BLE_SCAN_FILTER_FEATURE_MANUFACTURER_DATA,
+ filter_data->slot_id,
+ filter_data->manufacturer_id,
+ company_id_mask,
+ NULL,
+ NULL,
+ NULL,
+ address_type,
+ filter_data->manufacturer_data_len, //manufacturer_data_len as data_len in HAL
+ (char*)filter_data->manufacturer_data,
+ filter_data->manufacturer_data_mask_len,
+ (char*)filter_data->manufacturer_data_mask
+ );
+ feature_selection |= OAL_BLE_SCAN_FILTER_FEATURE_MANUFACTURER_DATA;
+ if (ret != BT_STATUS_SUCCESS){
+ BT_ERR("error: %s", status2string(ret));
+ BT_INFO("unregistering already set filter features.");
+ gatt_api->client->scan_filter_clear(client_info, filter_data->slot_id);
+ return convert_to_oal_status(ret);
+ }
+
+ feature_selection |= OAL_BLE_SCAN_FILTER_FEATURE_MANUFACTURER_DATA;
+ }
+
+ BT_DBG("Filter selection 0x%.2x", feature_selection);
+
+ ret = gatt_api->client->scan_filter_param_setup(client_info, action, filter_data->slot_id, feature_selection,
+ scan_filter_setup.list_logic_type, scan_filter_setup.filt_logic_type,
+ scan_filter_setup.rssi_high_thres, scan_filter_setup.rssi_low_thres,
+ scan_filter_setup.dely_mode, scan_filter_setup.found_timeout,
+ scan_filter_setup.lost_timeout, scan_filter_setup.found_timeout_cnt);
+ if (ret != BT_STATUS_SUCCESS){
+ BT_ERR("error: %s", status2string(ret));
+ return convert_to_oal_status(ret);
+ }
+ return OAL_STATUS_SUCCESS;
+}
+
+oal_status_t gattc_configure_mtu(int conn_id, int mtu)
+{
+ int ret;
+
+ API_TRACE("Configure MTU Size: [%d]", mtu);
+ CHECK_OAL_GATT_ENABLED();
+ CHECK_CLIENT_CONNECTION(conn_id);
+
+ /* To prevent crash in case other libraries not support this api */
+ if (gatt_api->client->configure_mtu == NULL) {
+ BT_WARN("configure_mtu is NULL");
+ return OAL_STATUS_NOT_SUPPORT;
+ }
+
+ ret = gatt_api->client->configure_mtu(conn_id, mtu);
+ if (ret != BT_STATUS_SUCCESS) {
+ BT_ERR("Gatt client configure_mtu error: %s", status2string(ret));
+ return convert_to_oal_status(ret);
+ }
+ return OAL_STATUS_SUCCESS;
+}
+
+oal_status_t gattc_add_connection_info(bt_address_t *device_address, int conn_id, int server_inst_id)
+{
+ int ret = OAL_STATUS_SUCCESS;
+ bdstr_t bdstr;
+
+ OAL_CHECK_PARAMETER(device_address, return);
+ API_TRACE("Add connection info: [%s]", bdt_bd2str(device_address, &bdstr));
+ CHECK_OAL_GATT_ENABLED();
+ CHECK_SERVER_INSTANCE(server_inst_id);
+ CHECK_SERVER_REGISTRATION(server_inst_id);
+
+ ret = gatt_api->client->add_connection_info((bt_bdaddr_t *)device_address, conn_id, server_inst_id);
+ if (ret != BT_STATUS_SUCCESS) {
+ BT_ERR("GATT connection info add failed: %s", status2string(ret));
+ return convert_to_oal_status(ret);
+ }
+ return OAL_STATUS_SUCCESS;
+}
+