static guint manager_id;
/* Global handles which needs to be incremented during each addition */
-static int gatt_service_handle = 10;
-static int gatt_char_handle = 20;
-static int gatt_desc_handle = 30;
+#define SERVICE_HANDLE_NUM 100
+#define CHAR_HANDLE_NUM 200
+#define DESC_HANDLE_NUM 300
+static int gatt_service_handle = SERVICE_HANDLE_NUM;
+static int gatt_char_handle = CHAR_HANDLE_NUM;
+static int gatt_desc_handle = DESC_HANDLE_NUM;
struct gatt_service_info {
gchar *serv_path;
hal_gatt_service_added *user_data = NULL;
DBG("Service add to DBUS slot [%d]", slot);
- node_info = __bt_gatt_create_method_node_info(
- service_introspection_xml);
-
- if (node_info == NULL)
- return BT_STATUS_FAIL;
-
DBG("Add new GATT Service: Current GATT Service handle [%d]", gatt_service_handle);
+ if (gatt_service_handle >= CHAR_HANDLE_NUM) {
+ ERR("Exceeded the number of service");
+ return BT_STATUS_FAIL;
+ }
path = g_strdup_printf("%s"GATT_SERV_OBJECT_PATH"%d", app_path, ++gatt_service_handle);
DBG("gatt service path is [%s]", path);
+ node_info = __bt_gatt_create_method_node_info(
+ service_introspection_xml);
+ if (node_info == NULL) {
+ g_free(path);
+ return BT_STATUS_FAIL;
+ }
+
object_id = g_dbus_connection_register_object(g_conn, path,
node_info->interfaces[0],
&serv_interface_vtable,
if (serv_info == NULL)
return BT_STATUS_FAIL;
- node_info = __bt_gatt_create_method_node_info(
- characteristics_introspection_xml);
-
- if (node_info == NULL)
- return BT_STATUS_FAIL;
-
DBG("Add new GATT characteristic: Current GATT char handle [%d]", gatt_char_handle);
+ if (gatt_char_handle >= DESC_HANDLE_NUM) {
+ ERR("Exceeded the number of characteristic");
+ return BT_STATUS_FAIL;
+ }
path = g_strdup_printf("%s/characteristic%d", serv_info->serv_path, ++gatt_char_handle);
DBG("gatt characteristic path is [%s]", path);
+ node_info = __bt_gatt_create_method_node_info(
+ characteristics_introspection_xml);
+ if (node_info == NULL) {
+ g_free(path);
+ return BT_STATUS_FAIL;
+ }
+
app_id = g_malloc0(sizeof(int));
*app_id = slot;