Skip to content

Commit

Permalink
service: Add services removed/added handlers
Browse files Browse the repository at this point in the history
Change-Id: Ida3f232b4e77bfb95dec78ea4af7677c9c12b411
  • Loading branch information
Jakub Pawlowski authored and Andre Eisenbach committed Feb 18, 2016
1 parent 0b60bb0 commit 0bd8fa5
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
2 changes: 2 additions & 0 deletions service/gatt_server_old.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,8 @@ const btgatt_client_callbacks_t gatt_client_callbacks = {
nullptr, /* track_adv_event_cb; */
nullptr, /* scan_parameter_setup_completed_cb; */
nullptr, /* get_gatt_db_cb; */
nullptr, /* services_removed_cb */
nullptr, /* services_added_cb */
};

const btgatt_callbacks_t gatt_callbacks = {
Expand Down
39 changes: 39 additions & 0 deletions service/hal/bluetooth_gatt_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,27 @@ void GetGattDbCallback(int conn_id, btgatt_db_element_t *db, int size) {
GetGattDbCallback(g_interface, conn_id, db, size));
}

void ServicesRemovedCallback(int conn_id, uint16_t start_handle, uint16_t end_handle) {
shared_lock<shared_timed_mutex> lock(g_instance_lock);
VLOG(2) << __func__ << " - conn_id: " << conn_id
<< " start_handle: " << start_handle
<< " end_handle: " << end_handle;
VERIFY_INTERFACE_OR_RETURN();

FOR_EACH_CLIENT_OBSERVER(
ServicesRemovedCallback(g_interface, conn_id, start_handle, end_handle));
}

void ServicesAddedCallback(int conn_id, btgatt_db_element_t *added, int added_count) {
shared_lock<shared_timed_mutex> lock(g_instance_lock);
VLOG(2) << __func__ << " - conn_id: " << conn_id
<< " added_count: " << added_count;
VERIFY_INTERFACE_OR_RETURN();

FOR_EACH_CLIENT_OBSERVER(
ServicesAddedCallback(g_interface, conn_id, added, added_count));
}

void RegisterServerCallback(int status, int server_if, bt_uuid_t* app_uuid) {
shared_lock<shared_timed_mutex> lock(g_instance_lock);
VLOG(2) << __func__ << " - status: " << status << " server_if: " << server_if;
Expand Down Expand Up @@ -459,6 +480,8 @@ const btgatt_client_callbacks_t gatt_client_callbacks = {
nullptr, // track_adv_event_cb
nullptr, // scan_parameter_setup_completed_cb
GetGattDbCallback,
ServicesRemovedCallback,
ServicesAddedCallback,
};

const btgatt_server_callbacks_t gatt_server_callbacks = {
Expand Down Expand Up @@ -713,6 +736,22 @@ void BluetoothGattInterface::ClientObserver::GetGattDbCallback(
// Do nothing.
}

void BluetoothGattInterface::ClientObserver::ServicesRemovedCallback(
BluetoothGattInterface* /* gatt_iface */,
int /* conn_id */,
uint16_t /* start_handle */,
uint16_t /* end_handle */) {
// Do nothing.
}

void BluetoothGattInterface::ClientObserver::ServicesAddedCallback(
BluetoothGattInterface* /* gatt_iface */,
int /* conn_id */,
btgatt_db_element_t* /* added */,
int /* added_count */) {
// Do nothing.
}

void BluetoothGattInterface::ServerObserver::RegisterServerCallback(
BluetoothGattInterface* /* gatt_iface */,
int /* status */,
Expand Down
12 changes: 12 additions & 0 deletions service/hal/bluetooth_gatt_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,18 @@ class BluetoothGattInterface {
int conn_id,
btgatt_db_element_t* gatt_db,
int size);

virtual void ServicesRemovedCallback(
BluetoothGattInterface* gatt_iface,
int conn_id,
uint16_t start_handle,
uint16_t end_handle);

virtual void ServicesAddedCallback(
BluetoothGattInterface* gatt_iface,
int conn_id,
btgatt_db_element_t *added,
int added_count);
};

// The standard BT-GATT server callback interface.
Expand Down

0 comments on commit 0bd8fa5

Please sign in to comment.