bluetooth_gatt_server_indication_params_t *param);
static void __bt_remove_all_service_handles(int instance_id);
+static void __bt_free_service_info(bt_gatt_service_info_t *service_info);
+
+static int __bt_do_unregister_gatt_instance(int instance_id);
+static void __bt_service_reset_gatt_data(void);
#ifdef TIZEN_GATT_CLIENT
static void __bt_handle_client_instance_registered(event_gattc_register_t *data);
if (!strncasecmp(app->sender, name, strlen(name)) && app->is_initialized == TRUE) {
BT_DBG("Match found, name: %s", name);
- /* Unregister all service handles with stack */
- __bt_remove_all_service_handles(app->instance_id);
-
- /* If Advertising is enabled, stop it */
- if (app->adv_handle > 0) {
- BT_INFO("Stop advertising on instance ID [%d]", app->instance_id);
- /* Disable adv if running */
- BT_INFO("Disable Advertising Adv Handle [%d] sender [%s]",
- app->adv_handle, name);
- _bt_set_advertising(app->sender, app->adv_handle, FALSE, FALSE);
- }
+ /* TODO 1: If App has both GATT client / server role? */
+ /* TODO 2: Need to manage app info as list, not array.
+ This loop always run for MAX count if any apps are terminated.
+ */
/* Save instances of all apps that need to be unregistered */
- apps[app->instance_id] = 1;
+ if (app->instance_id != -1) {
+ /* GATT server */
+ /* Unregister all service handles with stack */
+ __bt_remove_all_service_handles(app->instance_id);
+
+ /* If Advertising is enabled, stop it */
+ if (app->adv_handle > 0) {
+ BT_INFO("Stop advertising on instance ID [%d]", app->instance_id);
+ /* Disable adv if running */
+ BT_INFO("Disable Advertising Adv Handle [%d] sender [%s]",
+ app->adv_handle, name);
+ _bt_set_advertising(app->sender, app->adv_handle, FALSE, FALSE);
+ }
+
+ apps[app->instance_id] = 1; /* App holds a GATT client Instance */
+ } else if (app->client_id != -1) {
+ /* GATT client */
+ apps[app->client_id] = 1; /* App holds a GATT server Instance */
+ }
}
}
for (k = 1; k < MAX_APPS_SUPPORTED; k++) {
if (apps[k] == 1) {
BT_INFO("Unregister app[%d]", k);
- /* Unregister server instance */
- __bt_unregister_gatt_server_instance(k);
+ /* Unregister client or server instance */
+ __bt_do_unregister_gatt_instance(k);
}
}
}
int _bt_gatt_init(void)
{
+ const char *stack_name = NULL;
+
BT_DBG("+");
if (OAL_STATUS_SUCCESS != gatt_enable()) {
/* Register gatt event handler */
_bt_service_register_event_handler_callback(BT_GATT_MODULE, __bt_gatt_event_handler);
-#ifdef TIZEN_GATT_CLIENT
- /*In bluedroid product, defacult gatt client is handled differently*/
- __bt_register_default_gatt_client();
-#endif
+
+ __bt_service_reset_gatt_data();
+
+ stack_name = oal_get_stack_name();
+
+ if (stack_name && g_strcmp0(stack_name, "bluez") == 0) {
+ /*In the platform, defacult gatt client should be registered */
+ __bt_register_default_gatt_client();
+ }
+
BT_DBG("-");
return BLUETOOTH_ERROR_NONE;
}
-static void __bt_service_reset_gatt_data()
+static void __bt_service_reset_gatt_data(void)
{
int k;
memset(numapps[k].scan_rsp.data, 0x00, BLUETOOTH_ADVERTISING_DATA_LENGTH_MAX);
numapps[k].adv_data_len = 0;
numapps[k].scan_rsp_len = 0;
+
+ /* GATT client */
+ numapps[k].client_id = -1;
+ memset(numapps[k].address.addr, 0x00, BLUETOOTH_ADDRESS_LENGTH);
+ numapps[k].is_watcher_enabled = FALSE;
}
}
void _bt_set_new_adv_data(bluetooth_advertising_data_t *adv, int len, int instance)
{
int k;
- BT_DBG("+");
+ BT_DBG("");
bt_service_app_info_t *info = NULL;
for (k = 1; k < MAX_APPS_SUPPORTED; k++) {
info = &numapps[k];
break;
}
}
- BT_DBG("-");
}
void _bt_set_new_scan_rsp_data(bluetooth_scan_resp_data_t *scan, int len, int instance)
{
int k;
- BT_DBG("+");
+ BT_DBG("");
bt_service_app_info_t *info = NULL;
for (k = 1; k < MAX_APPS_SUPPORTED; k++) {
info = &numapps[k];
break;
}
}
- BT_DBG("-");
}
void _bt_get_previous_adv_data(bluetooth_advertising_data_t *adv, int *len, int instance)
{
int k;
- BT_DBG("+");
bt_service_app_info_t *info = NULL;
for (k = 1; k < MAX_APPS_SUPPORTED; k++) {
void _bt_get_previous_scan_rsp_data(bluetooth_scan_resp_data_t *scan, int *len, int instance)
{
int k;
- BT_DBG("+");
+ BT_DBG("");
bt_service_app_info_t *info = NULL;
for (k = 1; k < MAX_APPS_SUPPORTED; k++) {
}
}
+static int __bt_do_unregister_gatt_instance(int instance_id)
+{
+ int ret = OAL_STATUS_SUCCESS;
+ int k;
+
+ BT_INFO("DeAllocate server or client instance ID [%d]", instance_id);
+
+ /* Reset data: instance_id parameter could be either for GATT Server or for GATT client */
+ for (k = 1; k < MAX_APPS_SUPPORTED; k++) {
+ if (numapps[k].instance_id == instance_id) {
+ BT_INFO("This is a GATT server app, unregister: Slot [%d] vacant", k);
+ numapps[k].is_initialized = FALSE;
+ numapps[k].instance_id = -1;
+ numapps[k].adv_handle = 0;
+ numapps[k].adv_instance = -1;
+ memset(numapps[k].sender, 0x00, sizeof(numapps[k].sender));
+ memset(numapps[k].uuid, 0x00, sizeof(numapps[k].uuid));
+ memset(numapps[k].adv_data.data, 0x00, BLUETOOTH_ADVERTISING_DATA_LENGTH_MAX);
+ memset(numapps[k].scan_rsp.data, 0x00, BLUETOOTH_ADVERTISING_DATA_LENGTH_MAX);
+ numapps[k].adv_data_len = 0;
+ numapps[k].scan_rsp_len = 0;
+
+ /* Its a GATT Server Instance */
+ ret = gatts_unregister(instance_id);
+ if (ret != OAL_STATUS_SUCCESS) {
+ BT_ERR("DeAllocate server instance with stack Fail ret: %d", ret);
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
+ break;
+ } else if (numapps[k].client_id == instance_id) {
+ BT_INFO("This is a GATT client app, unregister: Slot [%d] vacant", k);
+ numapps[k].client_id = -1;
+ numapps[k].is_initialized = FALSE;
+ memset(numapps[k].sender, 0x00, sizeof(numapps[k].sender));
+ memset(numapps[k].uuid, 0x00, sizeof(numapps[k].uuid));
+ memset(&numapps[k].address.addr, 0x00, sizeof(bluetooth_device_address_t));
+
+ /* Its a GATT Client Instance */
+ ret = gattc_deregister(instance_id);
+ if (ret != OAL_STATUS_SUCCESS) {
+ BT_ERR("DeAllocate GATT Client instance with stack Fail ret: %d", ret);
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
+ break;
+ }
+ }
+ return BLUETOOTH_ERROR_NONE;
+}
+
static int __bt_unregister_gatt_server_instance(int server_instance)
{
int ret = OAL_STATUS_SUCCESS;
GArray *out_param;
invocation_info_t *req_info = NULL;
ret_if(data == NULL);
- BT_DBG("+");
for (l = _bt_get_invocation_list(); l != NULL; ) {
req_info = l->data;
continue;
if (!g_strcmp0(info->addr, address)) {
- BT_INFO("Remote GATT client found addr[%s]", info->addr);
+ BT_DBG("Remote GATT client found addr[%s]", info->addr);
return info;
}
}
continue;
if (!g_strcmp0(info->addr, address)) {
- BT_INFO("Remote GATT Server found addr[%s]", info->addr);
+ BT_DBG("Remote GATT Server found addr[%s]", info->addr);
return info;
}
}
default:
break;
}
- BT_DBG("-");
}
int _bt_gatt_server_add_service(char *sender, int service_type,
#ifdef TIZEN_GATT_CLIENT
/* GATT Client utility static functions */
-static bt_gatt_service_info_list_t * __bt_get_service_info_list(int conn_id)
+static bt_gatt_service_info_list_t *__bt_get_service_info_list(int conn_id)
{
GSList *l;
bt_gatt_service_info_list_t *info = NULL;
for (l = list_gatt_info; l != NULL; l = g_slist_next(l)) {
- info = (bt_gatt_service_info_list_t*)l->data;
+ info = (bt_gatt_service_info_list_t *)l->data;
if (info == NULL)
continue;
return NULL;
}
-static bt_gatt_service_info_t* __bt_find_matching_service(
+static bt_gatt_service_info_t *__bt_find_matching_service(
bt_gatt_service_info_list_t *svc_list, oal_gatt_srvc_id_t *svc)
{
GSList *l;
bt_gatt_service_info_t *info = NULL;
for (l = svc_list->services; l != NULL; l = g_slist_next(l)) {
- info = (bt_gatt_service_info_t*)l->data;
+ info = (bt_gatt_service_info_t *)l->data;
if (info == NULL)
continue;
return NULL;
}
-static bt_gatt_char_info_t* __bt_find_matching_charc(
+static bt_gatt_char_info_t *__bt_find_matching_charc(
bt_gatt_service_info_t *svc_info, oal_gatt_id_t *charc)
{
GSList *l;
bt_gatt_char_info_t *info = NULL;
for (l = svc_info->chars; l != NULL; l = g_slist_next(l)) {
- info = (bt_gatt_char_info_t*)l->data;
+ info = (bt_gatt_char_info_t *)l->data;
if (info == NULL)
continue;
return NULL;
}
-static bt_gatt_descriptor_info_t* __bt_find_matching_desc(
+static bt_gatt_descriptor_info_t *__bt_find_matching_desc(
bt_gatt_char_info_t *char_info, oal_gatt_id_t *desc)
{
GSList *l;
bt_gatt_descriptor_info_t *info = NULL;
for (l = char_info->descs; l != NULL; l = g_slist_next(l)) {
- info = (bt_gatt_descriptor_info_t*)l->data;
+ info = (bt_gatt_descriptor_info_t *)l->data;
if (info == NULL)
continue;
service_uuid_t uuid;
struct gatt_server_info_t *conn_info = NULL;
- int count = 1;
+ int count = 0;
char uuid_string[BLUETOOTH_UUID_STRING_MAX];
conn_info = __bt_find_remote_gatt_server_info_from_conn_id(conn_id);
_bt_convert_addr_string_to_type(info->device_addr.addr, conn_info->addr);
svc_info_list = __bt_get_service_info_list(conn_id);
-
if (!svc_info_list)
return;
int count = 0;
char uuid_string[BLUETOOTH_UUID_STRING_MAX];
- BT_INFO("+");
-
conn_info = __bt_find_remote_gatt_server_info_from_conn_id(conn_id);
if (!conn_info)
return;
}
info->count = g_slist_length(svc_info->chars);
- BT_INFO("Total count of Characteristics [%d]", info->count);
for (l = svc_info->chars; l != NULL; l = g_slist_next(l)) {
char_info = (bt_gatt_char_info_t*)l->data;
/* Increment count of services browsed */
count++;
}
- BT_INFO("Total characteristics browsed [%d]", count);
+ BT_DBG("Total characteristics browsed [%d]", count);
}
static void __bt_build_descriptor_browse_info(int conn_id,
info->char_props_map = char_info->props;
info->count = g_slist_length(char_info->descs);
- BT_INFO("Total count of Descriptors [%d]", info->count);
if (!char_info->descs) {
BT_ERR("No Descriptors browsed for address [%s]", conn_info->addr);
BT_INFO("Total descriptors browsed [%d]", count);
}
-
-static void __bt_cleanup_remote_services(struct gatt_server_info_t *conn_info)
+static void __bt_free_service_info(bt_gatt_service_info_t *svc)
{
- GSList *l;
- GSList *ll;
- GSList *lll;
- GSList *llll;
-
- bt_gatt_service_info_list_t * svc_info_list = NULL;
- bt_gatt_service_info_t *svc = NULL;
+ GSList *ll, *lll, *llll;
bt_gatt_char_info_t *chr = NULL;
bt_gatt_descriptor_info_t *desc = NULL;
bt_gatt_included_service_info_t *incl_svc = NULL;
+ BT_DBG("Service info Is Prim[%d] Inst ID [%d]", svc->is_primary, svc->inst_id);
+ /* Delete all chars and its descriptors */
+ for (ll = svc->chars; ll != NULL; ) {
+ chr = (bt_gatt_char_info_t *)ll->data;
+ ll = g_slist_next(ll);
+ if (chr == NULL)
+ continue;
+
+ for (lll = chr->descs; lll != NULL; ) {
+ desc = (bt_gatt_descriptor_info_t *)lll->data;
+ lll = g_slist_next(lll);
+ if (desc == NULL)
+ continue;
+ chr->descs = g_slist_remove(chr->descs, desc);
+ g_free(desc);
+ }
+ svc->chars = g_slist_remove(svc->chars, chr);
+ g_free(chr);
+ }
+
+ /* Delete all included services */
+ for (llll = svc->included_svcs; llll != NULL; ) {
+ incl_svc = (bt_gatt_included_service_info_t *)llll->data;
+ llll = g_slist_next(llll);
+ if (incl_svc == NULL)
+ continue;
+ svc->included_svcs = g_slist_remove(svc->included_svcs, incl_svc);
+ g_free(incl_svc);
+ }
+}
+
+static void __bt_cleanup_remote_services(struct gatt_server_info_t *conn_info)
+{
+ bt_gatt_service_info_list_t *svc_info_list = NULL;
+ bt_gatt_service_info_t *svc = NULL;
+ GSList *l;
+
svc_info_list = __bt_get_service_info_list(conn_info->connection_id);
if (!svc_info_list) {
BT_INFO("Could not find Svc Info list for the connection ID [%d]",
}
BT_INFO("Start Cleanup of all services. Num Services [%d]", g_slist_length(svc_info_list->services));
- for (l = svc_info_list->services; l;) {
- svc = (bt_gatt_service_info_t*)l->data;
+ for (l = svc_info_list->services; l != NULL; ) {
+ svc = (bt_gatt_service_info_t *)l->data;
l = g_slist_next(l);
if (svc == NULL)
continue;
- BT_DBG("Service info Is Prim[%d] Inst ID [%d]",
- svc->is_primary, svc->inst_id);
- /* Delete all chars and its descriptors */
- for (ll = svc->chars; ll;) {
- chr = (bt_gatt_char_info_t*)ll->data;
- ll = g_slist_next(ll);
- if (chr == NULL)
- continue;
-
- for (lll = chr->descs; lll;) {
- desc = (bt_gatt_descriptor_info_t *)lll->data;
- lll = g_slist_next(lll);
- if (desc == NULL)
- continue;
- chr->descs = g_slist_remove(chr->descs, desc);
- g_free(desc);
- }
- svc->chars = g_slist_remove(svc->chars, chr);
- g_free(chr);
- }
-
- /* Delete all included services */
- for (llll = svc->included_svcs; llll;) {
- incl_svc = (bt_gatt_included_service_info_t*)llll->data;
- llll = g_slist_next(llll);
- if (incl_svc == NULL)
- continue;
-
- svc->included_svcs = g_slist_remove(svc->included_svcs, incl_svc);
- g_free(incl_svc);
- }
+ __bt_free_service_info(svc);
svc_info_list->services = g_slist_remove(svc_info_list->services, svc);
g_free(svc);
}
oal_uuid_t uuid;
/* App should ensure that it should not send */
- BT_INFO("###Check on which instance GATT Client instance can be initialized....");
+ BT_INFO("### Check on which instance GATT Client instance can be initialized....");
for (k = 1; k < MAX_APPS_SUPPORTED; k++) {
if (numapps[k].is_initialized == 1) {
BT_INFO("Instance ID [%d] is already in use..Check next slot",
/* Platform GATT client framwork does not use Default GATT client instance
This GATT client instance is never deregistred in the lifetime of bt-service */
- BT_INFO("Default UUID [%s] current registered uuid [%s]",
- DEFAULT_GATT_CLIENT_UUID, uuid_string);
if (g_strcmp0(uuid_string, DEFAULT_GATT_CLIENT_UUID) == 0) {
- BT_INFO("Default client Instance Registered [%s] Client instance [%d]",
- uuid_string, data->client_if);
+ BT_INFO("Default client Instance Registered");
gatt_default_client = data->client_if;
g_free(uuid_string);
return;
info = &numapps[k];
if (g_strcmp0(info->uuid, uuid_string) == 0) {
- BT_INFO("Found GATT client.. UUID [%s], sender [%s]", info->uuid, info->sender);
- BT_INFO("Slot [%d] occupied", k);
+ BT_INFO("Found GATT client.. sender [%s] Slot [%d] occupied", info->sender, k);
info->is_initialized = TRUE;
info->client_id = data->client_if;
__bt_gatt_handle_pending_request_info(BLUETOOTH_ERROR_NONE, BT_GATT_CLIENT_REGISTER,
static void __bt_handle_client_service_search_result(
event_gattc_service_result_t *event_data)
{
- BT_INFO("received the gatt service search result");
/* Pre: status is never fail from OAL */
/* Find service list from address */
bt_gatt_service_info_list_t *svc_info_list;
bt_gatt_service_info_t *svc_info;
- BT_INFO("Search Result: status [%d] conn_id [%d]",
- event_data->conn_status.status,
- event_data->conn_status.conn_id);
svc_info_list = __bt_get_service_info_list(event_data->conn_status.conn_id);
if (!svc_info_list) {
- BT_INFO("Service info list not present for this connection ID, means first time browse");
+ BT_DBG("Service info list not present for connection ID %d, means first time browse", event_data->conn_status.conn_id);
/* Means for this conn_id, no services are ever browsed, first time,
create service info list for this conn_id */
svc_info_list = g_malloc0(sizeof(bt_gatt_service_info_list_t));
svc_info_list->conn_id = event_data->conn_status.conn_id;
list_gatt_info = g_slist_append(list_gatt_info, svc_info_list);
- } else {
- BT_INFO("Service info list Already present for this connection ID, means not first time browse for this conn ID ");
}
/* send list and current service's uuid and instance id to find it */
in remote GATT device, update uuid info in svc info list structure, to be used when
search is completed */
if (!svc_info) {
- BT_INFO("Service Not found in svc info list for this connection ID");
if (svc_info_list->info.is_changed) {
- BT_INFO("Service Changed indication already found for this connection ID");
+ BT_DBG("Service Changed indication already found for connection ID %d", event_data->conn_status.conn_id);
memcpy(svc_info_list->info.uuid, event_data->srvc_id.id.uuid.uuid, BLUETOOTH_UUID_HEX_MAX_LEN);
}
/* Create and add new service in service list */
svc_info->inst_id = event_data->srvc_id.id.inst_id;
svc_info->is_primary = event_data->srvc_id.is_prmry;
svc_info_list->services = g_slist_append(svc_info_list->services, svc_info);
- BT_INFO("Service created and added in Svc info listf or this connection ID");
+ BT_DBG("Service created and added in Svc info list or connection ID %d", event_data->conn_status.conn_id);
} else {
- BT_INFO("Service Already found to be present inside the svc info list for this connection ID");
/* If returned matching service info, then just update service_rmeoved value inside it to 0 */
svc_info->is_removed = 0;
}
static void __bt_handle_client_service_search_completed(
event_gattc_conn_status_t *event_data)
{
- BT_INFO("+");
struct gatt_server_info_t *conn_info = NULL;
bt_gatt_service_info_list_t *svc_info_list;
bt_gatt_service_info_t *svc_info;
bt_gatt_char_info_t *char_info;
bt_char_browse_info_t browse_info;
- BT_INFO("Characteristic search result status [%d]",
- event_data->conn_status.status);
-
memset(&browse_info, 0x00, sizeof(bt_char_browse_info_t));
/* If success */
/* Find Matching char from service info in event */
char_info = __bt_find_matching_charc(svc_info, &event_data->char_id);
- if (char_info == NULL)
- BT_ERR("char_info is NULL");
/* If not found, then add new characteristic and return */
if (!char_info) {
- BT_INFO(" add new characteristic");
+ BT_DBG("Add new characteristic");
char_info = g_malloc0(sizeof(bt_gatt_char_info_t));
memcpy(char_info->uuid, event_data->char_id.uuid.uuid, BLUETOOTH_UUID_HEX_MAX_LEN);
svc_info->chars = g_slist_append(svc_info->chars, char_info);
} else {
/* If found, then return */
- BT_INFO("update char property as Characteristic browsed is already present");
+ BT_DBG("update char property as Characteristic browsed is already present");
char_info->props |= event_data->char_prop;
}
} else {
/* Find char list from service in event */
/* Find service list from address */
svc_info_list = __bt_get_service_info_list(event_data->conn_status.conn_id);
+ if (svc_info_list == NULL) {
+ BT_ERR("svc_info_list is NULL");
+ return;
+ }
/* Find service info from service in event */
svc_info = __bt_find_matching_service(svc_info_list, &event_data->srvc_id);
+ if (svc_info == NULL) {
+ BT_ERR("svc_info is NULL");
+ return;
+ }
/* Build char list from service in event */
__bt_build_char_browse_info(event_data->conn_status.conn_id,
if (event_data->conn_status.status == OAL_STATUS_SUCCESS) {
/* Find service list from address */
svc_info_list = __bt_get_service_info_list(event_data->conn_status.conn_id);
+ if (svc_info_list == NULL) {
+ BT_ERR("svc_info_list is NULL");
+ return;
+ }
+
svc_info = __bt_find_matching_service(svc_info_list, &event_data->srvc_id);
+ if (svc_info == NULL) {
+ BT_ERR("svc_info is NULL");
+ return;
+ }
+
char_info = __bt_find_matching_charc(svc_info, &event_data->char_id);
- desc_info = __bt_find_matching_desc(char_info, &event_data->descr_id);
+ if (char_info == NULL) {
+ BT_ERR("char_info is NULL");
+ return;
+ }
+ desc_info = __bt_find_matching_desc(char_info, &event_data->descr_id);
/* If not found, add new descriptor and return */
if (!desc_info) {
desc_info = g_malloc0(sizeof(bt_gatt_descriptor_info_t));
/* Find included service list from service in event */
/* Create response and return by sending event*/
svc_info_list = __bt_get_service_info_list(event_data->conn_status.conn_id);
+ if (svc_info_list == NULL) {
+ BT_ERR("svc_info_list is NULL");
+ return;
+ }
/* Find service info from service in event */
svc_info = __bt_find_matching_service(svc_info_list, &event_data->srvc_id);
+ if (svc_info == NULL) {
+ BT_ERR("svc_info is NULL");
+ return;
+ }
/* Find char info from char in event */
char_info = __bt_find_matching_charc(svc_info, &event_data->char_id);
+ if (char_info == NULL) {
+ BT_ERR("char_info is NULL");
+ return;
+ }
/* Build descriptor list from char in event */
__bt_build_descriptor_browse_info(event_data->conn_status.conn_id,
static void __bt_handle_client_service_changed_ind(event_gattc_service_changed_data *event_data)
{
+ bt_gatt_service_info_list_t *svc_info_list;
+ GSList *l;
+ bt_gatt_service_info_t *svc_info;
GVariant *param = NULL;
char *address_str = NULL;
char *uuid_str = NULL;
+ svc_info_list = __bt_get_service_info_list(event_data->conn_id);
+ if (svc_info_list == NULL) {
+ BT_ERR("svc_info_list is NULL");
+ return;
+ }
+
+ if (event_data->change_type) {
+ /* Add service UUID in list */
+ svc_info = g_malloc0(sizeof(bt_gatt_service_info_t));
+ memcpy(svc_info->uuid, event_data->uuid.uuid, BLUETOOTH_UUID_HEX_MAX_LEN);
+ svc_info->inst_id = event_data->inst_id;
+ svc_info->is_primary = 1; // TODO: Need to check is_primary is required or not
+ svc_info_list->services = g_slist_append(svc_info_list->services, svc_info);
+ BT_DBG("Service created and added in Svc info list or connection ID %d", event_data->conn_id);
+ } else {
+ /* Remove service UUID in list */
+ for (l = svc_info_list->services; l != NULL; l = g_slist_next(l)) {
+ svc_info = (bt_gatt_service_info_t *)l->data;
+ if (svc_info == NULL)
+ continue;
+
+ if (!memcmp(svc_info->uuid, event_data->uuid.uuid, BLUETOOTH_UUID_HEX_MAX_LEN)) {
+ svc_info_list->services = g_slist_remove(svc_info_list->services, svc_info);
+ __bt_free_service_info(svc_info);
+ break;
+ }
+ }
+ }
+
address_str = g_malloc0(BT_ADDRESS_STRING_SIZE);
uuid_str = g_malloc0(BT_UUID_STRING_MAX);
_bt_convert_addr_type_to_string(address_str, event_data->address.addr);
_bt_uuid_to_string(&event_data->uuid, uuid_str);
- param = g_variant_new("(iss)", event_data->change_type, address_str, uuid_str);
+ param = g_variant_new("(iiss)", event_data->inst_id, event_data->change_type, address_str, uuid_str);
_bt_send_event(BT_GATT_CLIENT_EVENT,
BLUETOOTH_EVENT_GATT_CLIENT_SERVICE_CHANGED,
param);
+ g_free(address_str);
+ g_free(uuid_str);
}
gboolean _bt_is_remote_gatt_device_connected(bluetooth_device_address_t *address)
char *addr;
struct gatt_server_info_t *conn_info = NULL;
gboolean connected = FALSE;
- BT_INFO("+");
addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
_bt_convert_addr_type_to_string(addr,
(unsigned char *)&(address->addr));
- BT_INFO("Check Connected or not for [%s]", addr);
+ BT_DBG("Check GATT connection status of [%s]", addr);
/* Check if device is already in connected list */
conn_info = _bt_find_remote_gatt_server_info(addr);
if (conn_info) {
- BT_INFO("Remote GATT Server device [%s] is Connected", conn_info->addr);
+ BT_DBG("Remote GATT Server device [%s] is Connected", conn_info->addr);
connected = TRUE;
} else {
struct gatt_client_info_t *client_info = NULL;
client_info = _bt_find_remote_gatt_client_info(addr);
if (client_info) {
- BT_INFO("Remote Client device [%s] is Connected", client_info->addr);
+ BT_DBG("Remote Client device [%s] is Connected", client_info->addr);
connected = TRUE;
} else {
BT_INFO("Remote GATT Client Device [%s] is not Connected", addr);
BT_CHECK_PARAMETER(address, return);
- BT_INFO("+");
-
addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
_bt_convert_addr_type_to_string(addr, address->addr);
BT_INFO("GATT Client connect request for address [%s] client instance [%d]",
return BLUETOOTH_ERROR_NOT_CONNECTED;
}
+ BT_INFO("Remove GATT server info from List..");
+ /* Remove all services from info list_gatt_info */
+ __bt_cleanup_remote_services(conn_info);
+
/* Send Primary Service Browsing request to stack */
ret = gattc_search_service(conn_info->connection_id, NULL);
if (ret != OAL_STATUS_SUCCESS) {
oal_gatt_srvc_id_t srvc_id;
int ret = OAL_STATUS_SUCCESS;
char *addr;
- BT_INFO("+");
/* Check if any app is already browsing characteristics of the same service on the same remote GATT Server */
req_info = _bt_get_request_info_data_from_function_name(BT_GATT_GET_SERVICE_PROPERTIES);
/* Check if remote GATT Server is connected or not */
conn_info = _bt_find_remote_gatt_server_info(addr);
if (conn_info) {
- BT_INFO("GATT Server [%s] is connected, conn Id [%d]",
+ BT_DBG("GATT Server [%s] is connected, conn Id [%d]",
conn_info->addr, conn_info->connection_id);
} else {
BT_ERR("GATT Server is not yet connected..");
BT_CHECK_PARAMETER(chr, return);
- BT_INFO("+");
-
/* Check if any app is already browsing descriptors of the same char of
particular service on the same remote GATT Server */
req_info = _bt_get_request_info_data_from_function_name(BT_GATT_GET_CHARACTERISTIC_PROPERTIES);
/* Check if remote GATT Server is connected or not */
conn_info = _bt_find_remote_gatt_server_info(addr);
if (conn_info) {
- BT_INFO("GATT Server [%s] is connected, conn Id [%d]",
+ BT_DBG("GATT Server [%s] is connected, conn Id [%d]",
conn_info->addr, conn_info->connection_id);
} else {
BT_ERR("GATT Server is not yet connected..");
BT_CHECK_PARAMETER(chr, return);
- BT_INFO("+");
-
/* Check if any app is already Reading characteristic of the same char of
particular service on the same remote GATT Server */
req_info = _bt_get_request_info_data_from_function_name(BT_GATT_READ_CHARACTERISTIC);
/* Check if remote GATT Server is connected or not */
conn_info = _bt_find_remote_gatt_server_info(addr);
if (conn_info) {
- BT_INFO("GATT Server [%s] is connected, conn Id [%d]",
+ BT_DBG("GATT Server [%s] is connected, conn Id [%d]",
conn_info->addr, conn_info->connection_id);
} else {
BT_ERR("GATT Server is not yet connected..");
BT_CHECK_PARAMETER(desc, return);
- BT_INFO("+");
-
/* Check if any app is already Reading descriptors of the same char of
particular service on the same remote GATT Server */
req_info = _bt_get_request_info_data_from_function_name(BT_GATT_READ_DESCRIPTOR_VALUE);
/* Check if remote GATT Server is connected or not */
conn_info = _bt_find_remote_gatt_server_info(addr);
if (conn_info) {
- BT_INFO("GATT Server [%s] is connected, conn Id [%d]",
+ BT_DBG("GATT Server [%s] is connected, conn Id [%d]",
conn_info->addr, conn_info->connection_id);
} else {
BT_ERR("GATT Server is not yet connected..");
BT_CHECK_PARAMETER(chr, return);
- BT_INFO("+");
-
addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
_bt_convert_addr_type_to_string(addr, chr->device_address.addr);
/* Check if remote GATT Server is connected or not */
conn_info = _bt_find_remote_gatt_server_info(addr);
if (conn_info) {
- BT_INFO("GATT Server [%s] is connected, conn Id [%d]",
+ BT_DBG("GATT Server [%s] is connected, conn Id [%d]",
conn_info->addr, conn_info->connection_id);
} else {
BT_ERR("GATT Server is not yet connected..");
BT_CHECK_PARAMETER(chr, return);
- BT_INFO("+");
-
addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
_bt_convert_addr_type_to_string(addr, chr->device_address.addr);
/* Check if remote GATT Server is connected or not */
conn_info = _bt_find_remote_gatt_server_info(addr);
if (conn_info) {
- BT_INFO("GATT Server [%s] is connected, conn Id [%d]",
+ BT_DBG("GATT Server [%s] is connected, conn Id [%d]",
conn_info->addr, conn_info->connection_id);
} else {
BT_ERR("GATT Server is not yet connected..");
int k;
bt_service_app_info_t *info = NULL;
- BT_INFO("Enable Servic changed Indication watcher [%d] for app [%s]",
- is_enabled, sender);
+ BT_INFO("%s Servic changed Indication watcher for app [%s]",
+ is_enabled ? "Enable":"Disable", sender);
for (k = 1; k < MAX_APPS_SUPPORTED; k++) {
info = &numapps[k];
if (g_strcmp0(sender, info->sender) == 0 &&
memcmp(info->address.addr, address->addr,
sizeof(bluetooth_device_address_t)) == 0) {
- BT_INFO("Found GATT client App.. UUID [%s], sender [%s]", info->uuid, info->sender);
+ BT_DBG("Found GATT client App.. [%s], sender [%s]", info->uuid, info->sender);
info->is_watcher_enabled = is_enabled;
}
}