#define HAL_EV_GATT_CLIENT_WATCH_NOTIFICATION 0XC7
struct hal_ev_gatt_client_watch_notification {
- int32_t client_if;
+ int32_t conn_id;
int32_t registered;
int32_t status;
int32_t is_primary;
DBG("sending the watch register notification event");
/* send the event */
memset(&ev, 0, sizeof(ev));
- ev.client_if = resp_data->conn_id; /* conn_id is saved with client_if */
+ ev.conn_id = resp_data->conn_id;
ev.registered = 1;
ev.status = resp_data->result;
return FALSE;
}
-static bt_status_t _hal_register_for_notification(int client_if,
+static bt_status_t _hal_register_for_notification(int conn_id,
bt_bdaddr_t *bd_addr, btgatt_srvc_id_t *srvc_id,
btgatt_gatt_id_t *char_id)
{
return BT_STATUS_FAIL;
}
- if (gattc_client->client_if != client_if) {
- ERR("could not find the gatt client for client id[%d]", client_if);
+ if (gattc_client->conn_id != conn_id) {
+ ERR("could not find the gatt client for client id[%d]", conn_id);
return BT_STATUS_FAIL;
}
g_clear_error(&error);
}
- resp_data->conn_id = gattc_client->client_if; /* saving client_if instead of conn_id */
+ resp_data->conn_id = gattc_client->conn_id;
resp_data->result = result;
memcpy(&resp_data->srvc_id, srvc_id, sizeof(btgatt_srvc_id_t));
memcpy(&resp_data->char_id, char_id, sizeof(btgatt_gatt_id_t));
* Register to receive notifications or indications for a given
* characteristic
*/
-bt_status_t btif_register_for_notification(int client_if,
+bt_status_t btif_register_for_notification(int conn_id,
const bt_bdaddr_t *bd_addr, btgatt_srvc_id_t *srvc_id,
btgatt_gatt_id_t *char_id)
{
CHECK_BTGATT_INIT();
- return _hal_register_for_notification(client_if, (bt_bdaddr_t *)bd_addr, srvc_id, char_id);
+ return _hal_register_for_notification(conn_id, (bt_bdaddr_t *)bd_addr, srvc_id, char_id);
}
static gboolean _hal_watch_deregister_notifi_cb(gpointer user_data)
DBG("sending the watch deregister notification event");
/* send the event */
memset(&ev, 0, sizeof(ev));
- ev.client_if = resp_data->conn_id; /* conn_id is saved with client_if */
+ ev.conn_id = resp_data->conn_id;
ev.registered = 0;
ev.status = resp_data->result;
return FALSE;
}
-static bt_status_t _hal_deregister_for_notification(int client_if,
+static bt_status_t _hal_deregister_for_notification(int conn_id,
bt_bdaddr_t *bd_addr, btgatt_srvc_id_t *srvc_id,
btgatt_gatt_id_t *char_id)
{
return BT_STATUS_FAIL;
}
- if (gattc_client->client_if != client_if) {
- ERR("could not find the gatt client for client id[%d]", client_if);
+ if (gattc_client->conn_id != conn_id) {
+ ERR("could not find the gatt client for client id[%d]", conn_id);
return BT_STATUS_FAIL;
}
result = BT_STATUS_FAIL;
}
- resp_data->conn_id = gattc_client->client_if; /* saving client_if instead of conn_id */
+ resp_data->conn_id = gattc_client->conn_id;
resp_data->result = result;
memcpy(&resp_data->srvc_id, srvc_id, sizeof(btgatt_srvc_id_t));
memcpy(&resp_data->char_id, char_id, sizeof(btgatt_gatt_id_t));
return BT_STATUS_SUCCESS;
}
/** Deregister a previous request for notifications/indications */
-bt_status_t btif_deregister_for_notification(int client_if,
+bt_status_t btif_deregister_for_notification(int conn_id,
const bt_bdaddr_t *bd_addr, btgatt_srvc_id_t *srvc_id,
btgatt_gatt_id_t *char_id)
{
CHECK_BTGATT_INIT();
- return _hal_deregister_for_notification(client_if, (bt_bdaddr_t *)bd_addr, srvc_id, char_id);
+ return _hal_deregister_for_notification(conn_id, (bt_bdaddr_t *)bd_addr, srvc_id, char_id);
}
/** Request RSSI for a given remote device */
gatt_char_id.inst_id = ev->inst_id;
if (bt_gatt_callbacks->client->register_for_notification_cb)
- bt_gatt_callbacks->client->register_for_notification_cb(ev->client_if,
+ bt_gatt_callbacks->client->register_for_notification_cb(ev->conn_id,
ev->registered, ev->status, &gatt_srvc_id, &gatt_char_id);
}
* Register to receive notifications or indications for a given
* characteristic
*/
- bt_status_t (*register_for_notification)(int client_if,
+ bt_status_t (*register_for_notification)(int conn_id,
const bt_bdaddr_t *bd_addr, btgatt_srvc_id_t *srvc_id,
btgatt_gatt_id_t *char_id);
/** Deregister a previous request for notifications/indications */
- bt_status_t (*deregister_for_notification)(int client_if,
+ bt_status_t (*deregister_for_notification)(int conn_id,
const bt_bdaddr_t *bd_addr, btgatt_srvc_id_t *srvc_id,
btgatt_gatt_id_t *char_id);
typedef struct {
oal_status_t status;
- int client_if;
+ int conn_id;
oal_gatt_id_t char_id;
oal_gatt_srvc_id_t srvc_id;
} event_gattc_regdereg_notify_t;
oal_status_t gattc_unregister_service_changed_cb(bt_address_t *device_address);
-oal_status_t gattc_register_for_notification(int client_id, bt_address_t * address,
+oal_status_t gattc_register_for_notification(int conn_id, bt_address_t * address,
oal_gatt_srvc_id_t *srvc_id, oal_gatt_id_t *char_id);
-oal_status_t gattc_deregister_for_notification(int client_id, bt_address_t * address,
+oal_status_t gattc_deregister_for_notification(int conn_id, bt_address_t * address,
oal_gatt_srvc_id_t *srvc_id, oal_gatt_id_t *char_id);
oal_status_t gatt_send_response_acquire(int conn_id, int trans_id,
send_event(OAL_EVENT_GATTC_DESC_SERACH_RESULT, event, sizeof(*event));
}
-static void cb_gattc_register_for_notification(int client_if, int registered, int status, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id)
+static void cb_gattc_register_for_notification(int conn_id, int registered, int status, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id)
{
char uuid_str1[2*BT_UUID_STRING_MAX];
char uuid_str2[2*BT_UUID_STRING_MAX];
- BT_INFO("BTGATT Client Register For Notification Callback, client_if:%d, status:%d, registered: %s",
- client_if, status, registered == 1 ? "REGISTERED" : "DEREGISTERED");
+ BT_INFO("BTGATT Client Register For Notification Callback, conn_id:%d, status:%d, registered: %s",
+ conn_id, status, registered == 1 ? "REGISTERED" : "DEREGISTERED");
uuid_to_stringname((oal_uuid_t *)&(srvc_id->id.uuid), uuid_str1);
uuid_to_stringname((oal_uuid_t *)&(char_id->uuid), uuid_str2);
BT_INFO("Service=> [%s], Inst_id [%u], Type [%s]", uuid_str1, srvc_id->id.inst_id, srvc_id->is_primary ? "Primary" : "Secondary");
event_gattc_regdereg_notify_t *event = g_new0(event_gattc_regdereg_notify_t, 1);
oal_event_t event_type = (registered == 1 ? OAL_EVENT_GATTC_NOTIFICATION_REGISTERED : OAL_EVENT_GATTC_NOTIFICATION_DEREGISTERED);
- event->client_if = client_if;
+ event->conn_id = conn_id;
event->status = convert_to_oal_status(status);
memcpy(&(event->srvc_id), srvc_id, sizeof(oal_gatt_srvc_id_t));
memcpy(&(event->char_id), char_id, sizeof(oal_gatt_id_t));
return OAL_STATUS_SUCCESS;
}
-oal_status_t gattc_register_for_notification(int client_id, bt_address_t * address,
+oal_status_t gattc_register_for_notification(int conn_id, bt_address_t * address,
oal_gatt_srvc_id_t *srvc_id, oal_gatt_id_t *char_id) {
int ret = OAL_STATUS_SUCCESS;
char uuid_str1[2*BT_UUID_STRING_MAX];
uuid_to_stringname(&(char_id->uuid), uuid_str2);
API_TRACE("Client Register Notification: [%s], Service_uuid: [%s], Char_uuid: [%s]", bdt_bd2str(address, &bdstr), uuid_str1, uuid_str2);
CHECK_OAL_GATT_ENABLED();
- CHECK_CLIENT_REGISTRATION(client_id);
+ CHECK_CLIENT_CONNECTION(conn_id);
- ret = gatt_api->client->register_for_notification(client_id, (bt_bdaddr_t *)address, (btgatt_srvc_id_t *)srvc_id, (btgatt_gatt_id_t *)char_id);
+ ret = gatt_api->client->register_for_notification(conn_id, (bt_bdaddr_t *)address, (btgatt_srvc_id_t *)srvc_id, (btgatt_gatt_id_t *)char_id);
if (ret != BT_STATUS_SUCCESS) {
BT_ERR("GATT client register notification failed: %s", status2string(ret));
return convert_to_oal_status(ret);
return OAL_STATUS_SUCCESS;
}
-oal_status_t gattc_deregister_for_notification(int client_id, bt_address_t * address,
+oal_status_t gattc_deregister_for_notification(int conn_id, bt_address_t * address,
oal_gatt_srvc_id_t *srvc_id, oal_gatt_id_t *char_id) {
int ret = OAL_STATUS_SUCCESS;
char uuid_str1[2*BT_UUID_STRING_MAX];
uuid_to_stringname(&(char_id->uuid), uuid_str2);
API_TRACE("Client Deregister Notification: [%s], Service_uuid: [%s], Char_uuid: [%s]", bdt_bd2str(address, &bdstr), uuid_str1, uuid_str2);
CHECK_OAL_GATT_ENABLED();
- CHECK_CLIENT_REGISTRATION(client_id);
+ CHECK_CLIENT_CONNECTION(conn_id);
- ret = gatt_api->client->deregister_for_notification(client_id, (bt_bdaddr_t *)address, (btgatt_srvc_id_t *)srvc_id, (btgatt_gatt_id_t *)char_id);
+ ret = gatt_api->client->deregister_for_notification(conn_id, (bt_bdaddr_t *)address, (btgatt_srvc_id_t *)srvc_id, (btgatt_gatt_id_t *)char_id);
if (ret != BT_STATUS_SUCCESS) {
BT_ERR("GATT client deregister notification failed: %s", status2string(ret));
return convert_to_oal_status(ret);
}
return NULL;
}
-
-static struct gatt_server_info_t *__bt_find_remote_gatt_server_info_from_client_if(int client_if)
-{
- GSList *l;
- struct gatt_server_info_t *info = NULL;
-
- for (l = gatt_server_info_list; l != NULL; l = g_slist_next(l)) {
- info = (struct gatt_server_info_t*)l->data;
- if (info == NULL)
- continue;
-
- if (info->client_id == client_if) {
- BT_INFO("Remote GATT server found addr[%s]", info->addr);
- return info;
- }
- }
- return NULL;
-}
#endif
-
-
-
#ifdef TIZEN_GATT_CLIENT
static void __bt_handle_gatt_server_connection_state(event_gatts_conn_t *event)
{
memset(¬if_info, 0x00, sizeof(bt_gatt_notif_reg_info_t));
BT_INFO("Client Interface [%d] status [%d]",
- event_data->client_if,
+ event_data->conn_id,
event_data->status);
/* Extract Address from conn_id of event data */
- conn_info = __bt_find_remote_gatt_server_info_from_client_if(
- event_data->client_if);
-
+ conn_info = __bt_find_remote_gatt_server_info_from_conn_id(event_data->conn_id);
if (!conn_info) {
BT_INFO("Connection Info is not present, return");
return;
}
- BT_INFO("Notification Registered for addr [%s]",
- conn_info->addr);
-
+ BT_INFO("Notification Registered for addr [%s]", conn_info->addr);
/* Fill svc informations in buffer */
memcpy(¬if_info.svc_uuid,
/* Register or unregister Notification characteristic */
if (is_notify)
- ret = gattc_register_for_notification(conn_info->client_id,
+ ret = gattc_register_for_notification(conn_info->connection_id,
(bt_address_t*)&(chr->device_address),
&srvc_id, &char_id);
else
- ret = gattc_deregister_for_notification(conn_info->client_id,
+ ret = gattc_deregister_for_notification(conn_info->connection_id,
(bt_address_t*)&(chr->device_address),
&srvc_id, &char_id);