gboolean is_watcher_enabled;
} bt_service_app_info_t;
+typedef struct {
+ char sender[BT_SENDER_MAX_LENGTH];
+ int svc_handle;
+ int char_handle;
+ int desc_handle;
+} bt_service_server_info_t;
+
/* GATT Server Request Info Structure */
struct gatt_server_req_info {
int connection_id; /* This value will uniquely identify a GATT client-server connection */
}
break;
}
- case BT_GATT_SERVER_ADD_SERVICE:
- case BT_GATT_SERVER_ADD_DESCRIPTOR:
+ case BT_GATT_SERVER_ADD_SERVICE: {
+ bt_service_server_info_t *param = (bt_service_server_info_t *)data;
+ int handle = param->svc_handle;
+
+ if (!g_strcmp0(req_info->sender, param->sender) && handle > 0) {
+ BT_DBG("GATT Server app [%s] added service handle [%d] Reply DBUS",
+ req_info->sender, handle);
+
+ out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
+ g_array_append_vals(out_param, &handle, sizeof(int));
+ _bt_service_method_return(req_info->context, out_param, result);
+
+ _bt_free_info_from_invocation_list(req_info);
+ g_array_free(out_param, TRUE);
+ }
+ break;
+ }
+ case BT_GATT_SERVER_ADD_DESCRIPTOR: {
+ bt_service_server_info_t *param = (bt_service_server_info_t *)data;
+ int handle = param->desc_handle;
+
+ if (!g_strcmp0(req_info->sender, param->sender) && handle > 0) {
+ BT_DBG("GATT Server app [%s] added descriptor handle [%d] Reply DBUS",
+ req_info->sender, handle);
+
+ out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
+ g_array_append_vals(out_param, &handle, sizeof(int));
+ _bt_service_method_return(req_info->context, out_param, result);
+
+ _bt_free_info_from_invocation_list(req_info);
+ g_array_free(out_param, TRUE);
+ }
+ break;
+ }
case BT_GATT_SERVER_ADD_CHARACTERISTIC: {
- int *handle = (int*)data;
- BT_DBG("Characteristic added: Handle [%d]", *handle);
- out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
+ bt_service_server_info_t *param = (bt_service_server_info_t *)data;
+ int handle = param->char_handle;
- g_array_append_vals(out_param, handle, sizeof(int));
- _bt_service_method_return(req_info->context, out_param, result);
+ if (!g_strcmp0(req_info->sender, param->sender) && handle > 0) {
+ BT_DBG("GATT Server app [%s] added characteristic handle [%d] Reply DBUS",
+ req_info->sender, handle);
- _bt_free_info_from_invocation_list(req_info);
- g_array_free(out_param, TRUE);
+ out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
+ g_array_append_vals(out_param, &handle, sizeof(int));
+ _bt_service_method_return(req_info->context, out_param, result);
+
+ _bt_free_info_from_invocation_list(req_info);
+ g_array_free(out_param, TRUE);
+ }
break;
}
#endif
info = &numapps[k];
if (info->instance_id == event->gatt_srvc_stat.server_inst) {
- BT_INFO("numapps[%d] Found GATT Server.. UUID [%s], sender [%s]", k, info->uuid, info->sender);
+ bt_service_server_info_t server_info;
+ BT_INFO("numapps[%d] Found GATT Server.. UUID [%s], svc_handle [%d] sender [%s]",
+ k, info->uuid, svc_handle, info->sender);
+
+ g_strlcpy(server_info.sender, info->sender, sizeof(info->sender));
+ server_info.svc_handle = svc_handle;
+ server_info.char_handle = -1;
+ server_info.desc_handle = -1;
+
__bt_gatt_handle_pending_request_info(result, BT_GATT_SERVER_ADD_SERVICE,
- (int*)&svc_handle, sizeof(int));
+ (void *)&server_info, sizeof(bt_service_server_info_t));
/* Add Service Handle */
if (svc_handle > 0) {
info = &numapps[k];
if (info->instance_id == event->gatt_srvc_stat.server_inst) {
- BT_INFO("Found GATT Server.. UUID [%s], sender [%s]", info->uuid, info->sender);
+ bt_service_server_info_t server_info;
+ BT_INFO("numapps[%d] Found GATT Server.. UUID [%s], char_handle [%d] sender [%s]",
+ k, info->uuid, char_handle, info->sender);
+
+ g_strlcpy(server_info.sender, info->sender, sizeof(info->sender));
+ server_info.svc_handle = -1;
+ server_info.char_handle = char_handle;
+ server_info.desc_handle = -1;
+
__bt_gatt_handle_pending_request_info(result, BT_GATT_SERVER_ADD_CHARACTERISTIC,
- (int*)&char_handle, sizeof(int));
+ (void *)&server_info, sizeof(bt_service_server_info_t));
break;
}
}
info = &numapps[k];
if (info->instance_id == event->gatt_srvc_stat.server_inst) {
- BT_INFO("Found GATT Server.. UUID [%s], sender [%s]", info->uuid, info->sender);
+ bt_service_server_info_t server_info ;
+ BT_INFO("numapps[%d] Found GATT Server.. UUID [%s], desc_handle [%d] sender [%s]",
+ k, info->uuid, desc_handle, info->sender);
+
+ g_strlcpy(server_info.sender, info->sender, sizeof(info->sender));
+ server_info.svc_handle = -1;
+ server_info.char_handle = -1;
+ server_info.desc_handle = desc_handle;
+
__bt_gatt_handle_pending_request_info(result, BT_GATT_SERVER_ADD_DESCRIPTOR,
- (int*)&desc_handle, sizeof(int));
+ (void *)&server_info, sizeof(bt_service_server_info_t));
break;
}
}
oal_uuid_t uuid = {{0} };
- BT_INFO("Char UUID [%s] Instance ID [%d]", char_uuid, param->instance_id);
+ BT_INFO("Char UUID [%s] Instance ID [%d] service handle [%d] uuid [%s]",
+ char_uuid, param->instance_id, param->service_handle, char_uuid);
_bt_string_to_uuid(char_uuid, (service_uuid_t*)&uuid);
BT_INFO("Char permission From API [0x%x]", param->permissions);