Add internal API to set service persistence 86/294086/2 accepted/tizen/unified/20230718.162151
authorWootak Jung <wootak.jung@samsung.com>
Tue, 13 Jun 2023 04:13:59 +0000 (13:13 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Wed, 14 Jun 2023 07:33:06 +0000 (16:33 +0900)
Change-Id: Ic1a54af44ac3b2265f37db4c3a8545e189951a38
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
include/bluetooth_internal.h
src/bluetooth-gatt.c

index 5009f02..9e5103b 100644 (file)
@@ -5646,6 +5646,44 @@ int bt_adapter_le_remove_advertising_custom_name(bt_advertiser_h advertiser,
                bt_adapter_le_packet_type_e pkt_type);
 
 /**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE
+ * @brief Sets service to be persisted not removed.
+ * @since_tizen 8.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/bluetooth
+ *
+ * @param[in] uuid The UUID of service
+ *
+ * @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
+ * @retval #BT_ERROR_ALREADY_DONE Operation is already done
+ *
+ * @see bt_gatt_server_unset_service_persistence()
+ */
+int bt_gatt_server_set_service_persistence(const char *uuid);
+
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE
+ * @brief Unsets service persistence.
+ * @since_tizen 8.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/bluetooth
+ *
+ * @param[in] uuid The UUID of service
+ *
+ * @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
+ * @retval #BT_ERROR_SERVICE_NOT_FOUND Service not found
+ *
+ * @see bt_gatt_server_unset_service_persistence()
+ */
+int bt_gatt_server_unset_service_persistence(const char *uuid);
+
+/**
  * @}
  */
 
index 0f2a7c9..adcf1cf 100644 (file)
@@ -3676,6 +3676,60 @@ int bt_gatt_server_unset_att_mtu_changed_cb(bt_gatt_server_h server)
 
        return BT_ERROR_NONE;
 }
+
+int bt_gatt_server_set_service_persistence(const char *uuid)
+{
+       int error_code = BT_ERROR_NONE;
+       char *uuid128;
+
+       BT_CHECK_GATT_SERVER_SUPPORT();
+       BT_CHECK_INIT_STATUS();
+       BT_CHECK_INPUT_PARAMETER(uuid);
+
+       uuid128 = _bt_convert_uuid_to_uuid128(uuid);
+       if (uuid128 == NULL) {
+               BT_ERR("Wrong type of uuid: %s", uuid);
+               return BT_ERROR_INVALID_PARAMETER;
+       }
+
+       BT_INFO("Set service(%s) to be persisted not removed", uuid128);
+
+       error_code = _bt_get_error_code(bluetooth_gatt_server_set_service_persistence(uuid128));
+       if (error_code != BT_ERROR_NONE) { /* LCOV_EXCL_LINE */
+               BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), /* LCOV_EXCL_LINE */
+                               error_code); /* LCOV_EXCL_LINE */
+               return error_code; /* LCOV_EXCL_LINE */
+       }
+
+       return BT_ERROR_NONE;
+}
+
+int bt_gatt_server_unset_service_persistence(const char *uuid)
+{
+       int error_code = BT_ERROR_NONE;
+       char *uuid128;
+
+       BT_CHECK_GATT_SERVER_SUPPORT();
+       BT_CHECK_INIT_STATUS();
+       BT_CHECK_INPUT_PARAMETER(uuid);
+
+       uuid128 = _bt_convert_uuid_to_uuid128(uuid);
+       if (uuid128 == NULL) {
+               BT_ERR("Wrong type of uuid: %s", uuid);
+               return BT_ERROR_INVALID_PARAMETER;
+       }
+
+       BT_INFO("Unset service persistence: %s", uuid128);
+
+       error_code = _bt_get_error_code(bluetooth_gatt_server_unset_service_persistence(uuid128));
+       if (error_code != BT_ERROR_NONE) { /* LCOV_EXCL_LINE */
+               BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), /* LCOV_EXCL_LINE */
+                               error_code); /* LCOV_EXCL_LINE */
+               return error_code; /* LCOV_EXCL_LINE */
+       }
+
+       return BT_ERROR_NONE;
+}
 /* LCOV_EXCL_STOP */
 
 #ifdef TIZEN_GATT_CLIENT