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 = {
.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 = NULL,
+ .configure_mtu_cb = cb_gattc_configure_mtu_cmpl,
#ifdef PLATFORM_ANDROID_HAL
.scan_filter_cfg_cb = NULL,
.scan_filter_param_cb = NULL,
}
}
+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)
{
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 convert_to_oal_status(ret);
}
- feature_selection |= OAL_BLE_SCAN_FILTER_FEATURE_DEVICE_ADDRESS;
+ 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");
return convert_to_oal_status(ret);
}
- feature_selection |= OAL_BLE_SCAN_FILTER_FEATURE_DEVICE_ADDRESS;
+ 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");
return convert_to_oal_status(ret);
}
- feature_selection |= OAL_BLE_SCAN_FILTER_FEATURE_DEVICE_ADDRESS;
+ 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,
return convert_to_oal_status(ret);
}
- feature_selection |= OAL_BLE_SCAN_FILTER_FEATURE_DEVICE_ADDRESS;
+ 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,
return convert_to_oal_status(ret);
}
- feature_selection |= OAL_BLE_SCAN_FILTER_FEATURE_DEVICE_ADDRESS;
+ feature_selection |= OAL_BLE_SCAN_FILTER_FEATURE_MANUFACTURER_DATA;
}
BT_DBG("Filter selection 0x%.2x", feature_selection);
}
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;
+}
+