*/
int bt_passkey_confirmation_reply(bool confirmation_reply);
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE
+ * @brief Registers a callback function to be invoked when service is changed from a remote device(GATT server).
+ * @since_tizen 3.0
+ *
+ * @param[in] client The GATT client's handle
+ * @param[in] callback The callback to be invoked
+ * @param[in] user_data The user data to be passed to @a callback function
+ * @return 0 on success, otherwise a negative error value
+ * @retval #BT_ERROR_NONE Successful
+ * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #BT_ERROR_NOT_SUPPORTED Not supported
+ *
+ * @see bt_gatt_client_unset_service_changed_cb()
+ */
+int bt_gatt_client_set_service_changed_cb(bt_gatt_client_h client,
+ bt_gatt_client_service_changed_cb callback, void *user_data);
+
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE
+ * @brief Unregisters a callback function
+ * @since_tizen 3.0
+ *
+ * @param[in] client The GATT client's handle
+ * @return 0 on success, otherwise a negative error value
+ * @retval #BT_ERROR_NONE Successful
+ * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #BT_ERROR_NOT_SUPPORTED Not supported
+ *
+ * @see bt_gatt_client_unset_service_changed_cb()
+ */
+int bt_gatt_client_unset_service_changed_cb(bt_gatt_client_h client);
+
/**
* @ingroup CAPI_NETWORK_BLUETOOTH_HID_MODULE
* @brief Sends the custom event data.
return BT_ERROR_NONE;
}
+
+int bt_gatt_client_set_service_changed_cb(bt_gatt_client_h client,
+ bt_gatt_client_service_changed_cb callback, void *user_data)
+{
+ int ret;
+ bluetooth_device_address_t bd_addr = { {0,} };
+ bt_gatt_client_s *client_s = (bt_gatt_client_s *)client;
+
+ BT_CHECK_GATT_SUPPORT();
+ BT_CHECK_INIT_STATUS();
+ BT_CHECK_INPUT_PARAMETER(client);
+ BT_CHECK_INPUT_PARAMETER(callback);
+
+ if (client_s->service_changed_cb) {
+ BT_INFO("Already registered");
+ client_s->service_changed_cb = callback;
+ client_s->service_changed_user_data = user_data;
+ return BT_ERROR_NONE;
+ }
+
+ _bt_convert_address_to_hex(&bd_addr, client_s->remote_address);
+ ret = _bt_get_error_code(bluetooth_gatt_set_service_change_watcher(&bd_addr, TRUE));
+
+ if (ret == BT_ERROR_NONE) {
+ BT_INFO("Service Changed callback registered");
+ client_s->service_changed_cb = callback;
+ client_s->service_changed_user_data = user_data;
+ } else {
+ BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
+ }
+
+ return ret;
+}
+
+int bt_gatt_client_unset_service_changed_cb(bt_gatt_client_h client)
+{
+ int ret;
+ bluetooth_device_address_t bd_addr = { {0,} };
+ bt_gatt_client_s *client_s = (bt_gatt_client_s *)client;
+
+ BT_CHECK_GATT_SUPPORT();
+ BT_CHECK_INIT_STATUS();
+ BT_CHECK_INPUT_PARAMETER(client);
+
+ _bt_convert_address_to_hex(&bd_addr, client_s->remote_address);
+ ret = _bt_get_error_code(bluetooth_gatt_set_service_change_watcher(&bd_addr, FALSE));
+ if (ret == BT_ERROR_NONE) {
+ BT_INFO("Service Changed callback unregistered [%s]", client_s->remote_address);
+ client_s->service_changed_cb = NULL;
+ client_s->service_changed_user_data = NULL;
+ } else {
+ BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
+ }
+
+ return BT_ERROR_NONE;
+}
, BT_UNIT_TEST_FUNCTION_GATT_CLIENT_UNSET_CHAR_VALUE_CHANGED_CB},
{"bt_gatt_client_foreach_services"
, BT_UNIT_TEST_FUNCTION_GATT_CLIENT_FOREACH_SERVICES},
+ {"bt_gatt_client_set_service_changed_cb"
+ , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_SET_SERVICE_CHANGED_CB},
+ {"bt_gatt_client_unset_service_changed_cb"
+ , BT_UNIT_TEST_FUNCTION_GATT_CLIENT_UNSET_SERVICE_CHANGED_CB},
{"bt_gatt_server_initialize"
, BT_UNIT_TEST_FUNCTION_GATT_SERVER_INITIALIZE},
{"bt_gatt_server_deinitilaize"
}
}
+void __bt_gatt_client_service_changed_cb(bt_gatt_client_h c,
+ bt_gatt_client_service_change_type_e type,
+ const char *uuid, void *user_data)
+{
+ char *addr = NULL;
+ char *svc = NULL;
+ int ret;
+
+ ret = bt_gatt_client_get_remote_address(client, &addr);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("Cannot get remote address");
+
+ ret = bt_get_uuid_name(uuid, &svc);
+ if (ret != BT_ERROR_NONE)
+ svc = g_strdup(uuid);
+
+ TC_PRT("Remote deivce [%s] : %s is %s", addr, svc,
+ type == BT_GATT_CLIENT_SERVICE_ADDED ?
+ "Added" : "Removed");
+ g_free(svc);
+ g_free(addr);
+}
+
int __bt_gatt_client_set_value(char *type, char *value, bt_gatt_h h)
{
int ret;
TC_PRT("bt_gatt_client_foreach_services_by_uuid is failed");
break;
}
+ case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_SET_SERVICE_CHANGED_CB: {
+ ret = bt_gatt_client_set_service_changed_cb(client,
+ __bt_gatt_client_service_changed_cb, NULL);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("bt_gatt_client_set_service_changed_cb is failed");
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_UNSET_SERVICE_CHANGED_CB: {
+ ret = bt_gatt_client_unset_service_changed_cb(client);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("bt_gatt_client_unset_service_changed_cb is failed");
+ break;
+ }
case BT_UNIT_TEST_FUNCTION_GATT_SERVER_INITIALIZE: {
ret = bt_gatt_server_initialize();
BT_UNIT_TEST_FUNCTION_GATT_CLIENT_SET_CHAR_VALUE_CHANGED_CB,
BT_UNIT_TEST_FUNCTION_GATT_CLIENT_UNSET_CHAR_VALUE_CHANGED_CB,
BT_UNIT_TEST_FUNCTION_GATT_CLIENT_FOREACH_SERVICES,
+ BT_UNIT_TEST_FUNCTION_GATT_CLIENT_SET_SERVICE_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_GATT_CLIENT_UNSET_SERVICE_CHANGED_CB,
BT_UNIT_TEST_FUNCTION_GATT_SERVER_INITIALIZE,
BT_UNIT_TEST_FUNCTION_GATT_SERVER_DEINITIALIZE,
BT_UNIT_TEST_FUNCTION_GATT_SERVER_UNREGISTER_ALL_SERVICES,