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

Commit d4265ddc authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by Gerrit Code Review
Browse files

Merge "Move start advertise method to advertising interface (3/3)"

parents 9144b64c de8a9162
Loading
Loading
Loading
Loading
+0 −36
Original line number Diff line number Diff line
@@ -718,40 +718,4 @@ void BTA_GATTC_Refresh(const BD_ADDR remote_bda)
    bta_sys_sendmsg(p_buf);
}

/*******************************************************************************
**
** Function         BTA_GATTC_Listen
**
** Description      Start advertisement to listen for connection request for a GATT
**                  client application.
**
** Parameters       start: to start or stop listening for connection
**
** Returns          void
**
*******************************************************************************/
void BTA_GATTC_Listen(bool start, base::Callback<void(uint8_t /* status */)> cb)
{
    GATT_Listen(start);
    cb.Run(BTA_GATT_OK);
}

/*******************************************************************************
**
** Function         BTA_GATTC_Broadcast
**
** Description      Start broadcasting (non-connectable advertisements)
**
** Parameters       client_if: client interface.
**                  start: to start or stop listening for connection
**
** Returns          void
**
*******************************************************************************/
void BTA_GATTC_Broadcast(bool start, base::Callback<void(uint8_t /* status */)> cb)
{
    uint8_t status = BTM_BleBroadcast(start);
    cb.Run(status);
}

#endif /* BTA_GATT_INCLUDED */
+0 −30
Original line number Diff line number Diff line
@@ -922,36 +922,6 @@ extern void BTA_GATTC_ReadMultiple(uint16_t conn_id, tBTA_GATTC_MULTI *p_read_mu
*******************************************************************************/
extern void BTA_GATTC_Refresh(const BD_ADDR remote_bda);


/*******************************************************************************
**
** Function         BTA_GATTC_Listen
**
** Description      Start advertisement to listen for connection request.
**
** Parameters       client_if: server interface.
**                  start: to start or stop listening for connection
**
** Returns          void
**
*******************************************************************************/
extern void BTA_GATTC_Listen(bool start, base::Callback<void(uint8_t /* status */)> cb);

/*******************************************************************************
**
** Function         BTA_GATTC_Broadcast
**
** Description      Start broadcasting (non-connectable advertisements)
**
** Parameters       client_if: client interface.
**                  start: to start or stop listening for connection
**
** Returns          void
**
*******************************************************************************/
extern void BTA_GATTC_Broadcast(bool start, base::Callback<void(uint8_t /* status */)> cb);


/*******************************************************************************
**
** Function         BTA_GATTC_ConfigureMTU
+15 −0
Original line number Diff line number Diff line
@@ -127,6 +127,21 @@ class BleAdvertiserInterfaceImpl : public BleAdvertiserInterface {
    }
  }

  void EnableCb(BleAdvertiserCb cb, uint8_t status) {
    LOG(INFO) << __func__ << " status: " << +status;
    do_in_jni_thread(Bind(cb, status));
  }

  void Enable(bool start, BleAdvertiserCb cb) override {
#if (defined(BLE_PERIPHERAL_MODE_SUPPORT) && \
     (BLE_PERIPHERAL_MODE_SUPPORT == true))
    do_in_jni_thread(Bind(&GATT_Listen, start));
#else
    do_in_jni_thread(Bind(&BTM_BleBroadcast, start));
#endif
    cb.Run(BT_STATUS_SUCCESS);
  }

  void MultiAdvSetParametersCb(BleAdvertiserCb cb, uint8_t status) {
    LOG(INFO) << __func__ << " status: " << +status ;
    do_in_jni_thread(Bind(cb, status));
+0 −16
Original line number Diff line number Diff line
@@ -328,21 +328,6 @@ bt_status_t btif_gattc_close(int client_if, const bt_bdaddr_t* bd_addr,
      Bind(&btif_gattc_close_impl, client_if, base::Owned(address), conn_id));
}

void btif_gattc_listen_cb(int client_if, uint8_t status)
{
  HAL_CBACK(bt_gatt_callbacks, client->listen_cb, status, client_if);
}

bt_status_t btif_gattc_listen(int client_if, bool start) {
  CHECK_BTGATT_INIT();
#if (defined(BLE_PERIPHERAL_MODE_SUPPORT) && \
     (BLE_PERIPHERAL_MODE_SUPPORT == true))
  return do_in_jni_thread(Bind(&BTA_GATTC_Listen, start, base::Bind(&btif_gattc_listen_cb, client_if)));
#else
  return do_in_jni_thread(Bind(&BTA_GATTC_Broadcast, start, base::Bind(&btif_gattc_listen_cb, client_if)));
#endif
}

bt_status_t btif_gattc_refresh(int client_if, const bt_bdaddr_t* bd_addr) {
  CHECK_BTGATT_INIT();
  // Closure will own this value and free it.
@@ -561,7 +546,6 @@ const btgatt_client_interface_t btgattClientInterface = {
    btif_gattc_unregister_app,
    btif_gattc_open,
    btif_gattc_close,
    btif_gattc_listen,
    btif_gattc_refresh,
    btif_gattc_search_service,
    btif_gattc_read_char,
+11 −13
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <unistd.h>

#include <base/bind.h>
#include <algorithm>
#include <array>
#include <condition_variable>
@@ -335,6 +336,13 @@ void ConnectionCallback(int conn_id, int server_if, int connected,
  }
}

void EnableAdvertisingCallback(uint8_t status) {
  LOG_INFO(LOG_TAG, "%s: status:%d", __func__, status);
  // This terminates a Start call.
  std::lock_guard<std::mutex> lock(g_internal->lock);
  g_internal->api_synchronize.notify_one();
}

void RegisterClientCallback(int status, int client_if, bt_uuid_t *app_uuid) {
  LOG_INFO(LOG_TAG, "%s: status:%d client_if:%d uuid[0]:%u", __func__, status,
      client_if, app_uuid->uu[0]);
@@ -344,11 +352,9 @@ void RegisterClientCallback(int status, int client_if, bt_uuid_t *app_uuid) {
  g_internal->gatt->advertiser->SetData(false, {/*TODO: put inverval 2,2 here*/});

  // TODO(icoolidge): Deprecated, use multi-adv interface.
  // This calls back to ListenCallback.
  bt_status_t btstat = g_internal->gatt->client->listen(client_if, true);
  if (btstat != BT_STATUS_SUCCESS) {
    LOG_ERROR(LOG_TAG, "Failed to start listening");
  }
  // This calls back to EnableAdvertisingCallback.
  g_internal->gatt->advertiser->Enable(true,
                                       base::Bind(&EnableAdvertisingCallback));
}

void RegisterScannerCallback(int status, int scanner_id, bt_uuid_t *app_uuid) {
@@ -356,13 +362,6 @@ void RegisterScannerCallback(int status, int scanner_id, bt_uuid_t *app_uuid) {
      scanner_id, app_uuid->uu[0]);
}

void ListenCallback(int status, int client_if) {
  LOG_INFO(LOG_TAG, "%s: status:%d client_if:%d", __func__, status, client_if);
  // This terminates a Start call.
  std::lock_guard<std::mutex> lock(g_internal->lock);
  g_internal->api_synchronize.notify_one();
}

void ServiceStoppedCallback(int status, int server_if, int srvc_handle) {
  LOG_INFO(LOG_TAG, "%s: status:%d server_if:%d srvc_handle:%d", __func__,
      status, server_if, srvc_handle);
@@ -435,7 +434,6 @@ const btgatt_client_callbacks_t gatt_client_callbacks = {
    nullptr, /* write_descriptor_cb; */
    nullptr, /* execute_write_cb; */
    nullptr, /* read_remote_rssi_cb; */
    ListenCallback,
    nullptr, /* configure_mtu_cb; */
    nullptr, /* congestion_cb; */
    nullptr, /* get_gatt_db_cb; */
Loading