Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 91fde05c authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

service: MTU changed callback for GATT server

Change-Id: I8431e970004f9b96cc40c3a5ca7878815d4d53bb
parent 05e78f44
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -404,6 +404,14 @@ void IndicationSentCallback(int conn_id, int status) {
      g_interface, conn_id, status));
}

void MtuChangedCallback(int conn_id, int mtu) {
  shared_lock<shared_timed_mutex> lock(g_instance_lock);
  VLOG(2) << __func__ << " - conn_id: " << conn_id << " mtu: " << mtu;
  VERIFY_INTERFACE_OR_RETURN();

  FOR_EACH_SERVER_OBSERVER(MtuChangedCallback(g_interface, conn_id, mtu));
}

// The HAL Bluetooth GATT client interface callbacks. These signal a mixture of
// GATT client-role and GAP events.
const btgatt_client_callbacks_t gatt_client_callbacks = {
@@ -458,7 +466,7 @@ const btgatt_server_callbacks_t gatt_server_callbacks = {
    ResponseConfirmationCallback,
    IndicationSentCallback,
    nullptr,  // congestion_cb
    nullptr,  // mtu_changed_cb
    MtuChangedCallback,
};

const btgatt_callbacks_t gatt_callbacks = {
@@ -804,6 +812,13 @@ void BluetoothGattInterface::ServerObserver::IndicationSentCallback(
  // Do nothing.
}

void BluetoothGattInterface::ServerObserver::MtuChangedCallback(
    BluetoothGattInterface* /* gatt_iface */,
    int /* conn_id */,
    int /* mtu */) {
  // Do nothing.
}

// static
bool BluetoothGattInterface::Initialize() {
  unique_lock<shared_timed_mutex> lock(g_instance_lock);
+2 −1
Original line number Diff line number Diff line
@@ -207,7 +207,8 @@ class BluetoothGattInterface {
    virtual void IndicationSentCallback(
        BluetoothGattInterface* gatt_iface, int conn_id, int status);

    // TODO(armansito): Complete the list of callbacks.
    virtual void MtuChangedCallback(
        BluetoothGattInterface* gatt_iface, int conn_id, int mtu);
  };

  // Initialize and clean up the BluetoothInterface singleton. Returns false if