Bluetooth: Add check given services is register API

Add API for chech given services is register.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
diff --git a/include/bluetooth/gatt.h b/include/bluetooth/gatt.h
index e648257..cdd58ca 100644
--- a/include/bluetooth/gatt.h
+++ b/include/bluetooth/gatt.h
@@ -362,13 +362,21 @@
 int bt_gatt_service_register(struct bt_gatt_service *svc);
 
 /** @brief Unregister GATT service.
- * *
+ *
  *  @param svc Service to be unregistered.
  *
  *  @return 0 in case of success or negative value in case of error.
  */
 int bt_gatt_service_unregister(struct bt_gatt_service *svc);
 
+/** @brief Check if GATT service is registered.
+ *
+ *  @param svc Service to be checked.
+ *
+ *  @return true if registered or false if not register.
+ */
+bool bt_gatt_service_is_registered(const struct bt_gatt_service *svc);
+
 enum {
 	BT_GATT_ITER_STOP = 0,
 	BT_GATT_ITER_CONTINUE,
diff --git a/subsys/bluetooth/host/gatt.c b/subsys/bluetooth/host/gatt.c
index e874e14..c455cb3 100644
--- a/subsys/bluetooth/host/gatt.c
+++ b/subsys/bluetooth/host/gatt.c
@@ -1323,6 +1323,24 @@
 
 	return 0;
 }
+
+bool bt_gatt_service_is_registered(const struct bt_gatt_service *svc)
+{
+	bool registered = false;
+	sys_snode_t *node;
+
+	k_sched_lock();
+	SYS_SLIST_FOR_EACH_NODE(&db, node) {
+		if (&svc->node == node) {
+			registered = true;
+			break;
+		}
+	}
+
+	k_sched_unlock();
+
+	return registered;
+}
 #endif /* CONFIG_BT_GATT_DYNAMIC_DB */
 
 ssize_t bt_gatt_attr_read(struct bt_conn *conn, const struct bt_gatt_attr *attr,