BT_INFO("BTGATT SERVER CONNECTION connnected:%d, conn_id:%d server_if:%d", connected, conn_id, server_if);
event_gatts_conn_t *event = g_new0(event_gatts_conn_t, 1);
- for (ins_id = 1 ; ins_id <= NUM_SERVER_INST ; ins_id++) {
- if ((gatt_servers[ins_id - 1].server_id == server_if)) {
- event->server_inst = ins_id;
- break;
- } else {
- BT_INFO("Server ID:%d recevied server Id:%d\n", gatt_servers[ins_id - 1].server_id, server_if);
+ if (connected == TRUE) {
+ for (ins_id = 1 ; ins_id <= NUM_SERVER_INST ; ins_id++) {
+ if ((gatt_servers[ins_id - 1].server_id == server_if)) {
+ event->server_inst = ins_id;
+ break;
+ } else {
+ BT_INFO("Server ID:%d recevied server Id:%d\n", gatt_servers[ins_id - 1].server_id, server_if);
+ }
}
- }
- if (ins_id == NUM_SERVER_INST+1) {
- BT_WARN("Incorrect Server Interface received: %d\n", server_if);
- g_free(event);
- return;
+ if (ins_id == NUM_SERVER_INST+1) {
+ BT_WARN("Incorrect Server Interface received: %d\n", server_if);
+ g_free(event);
+ return;
+ }
+ } else {
+ /* server_inst is not required in disconnected case */
}
memcpy(event->address.addr, bda->address, BT_ADDRESS_BYTES_NUM);
event->conn_id = conn_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);