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

Commit 84e7cdda authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by Andre Eisenbach
Browse files

Remove dead code from GAP

Test: none
Change-Id: I23badbf73420e4af26e6d84f7b04fcd56100b122
parent 78b0878d
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -102,7 +102,6 @@ cc_library_static {
        "gap/gap_api.cc",
        "gap/gap_ble.cc",
        "gap/gap_conn.cc",
        "gap/gap_utils.cc",
        "gatt/att_protocol.cc",
        "gatt/gatt_api.cc",
        "gatt/gatt_attr.cc",
+0 −1
Original line number Diff line number Diff line
@@ -81,7 +81,6 @@ static_library("stack") {
    "gap/gap_api.cc",
    "gap/gap_ble.cc",
    "gap/gap_conn.cc",
    "gap/gap_utils.cc",
    "gatt/att_protocol.cc",
    "gatt/gatt_api.cc",
    "gatt/gatt_attr.cc",
+1 −26
Original line number Diff line number Diff line
@@ -24,28 +24,8 @@
#include "gap_api.h"
#include "gatt_api.h"
#include "osi/include/fixed_queue.h"
#define GAP_MAX_BLOCKS 2 /* Concurrent GAP commands pending at a time*/
/* Define the Generic Access Profile control structure */
typedef struct {
  void* p_data;             /* Pointer to any data returned in callback */
  tGAP_CALLBACK* gap_cback; /* Pointer to users callback function */
  tGAP_CALLBACK* gap_inq_rslt_cback; /* Used for inquiry results */
  uint16_t event;                    /* Passed back in the callback */
  uint8_t index; /* Index of this control block and callback */
  bool in_use;   /* True when structure is allocated */
} tGAP_INFO;

/* The control block for FindAddrByName (Only 1 active at a time) */
typedef struct {
  tGAP_CALLBACK* p_cback;
  /* Pointer to the current inquiry database entry */
  tBTM_INQ_INFO* p_cur_inq;
  tGAP_FINDADDR_RESULTS results;
  bool in_use;
} tGAP_FINDADDR_CB;

/* Define the GAP Connection Control Block.
*/
/* Define the GAP Connection Control Block */
typedef struct {
#define GAP_CCB_STATE_IDLE 0
#define GAP_CCB_STATE_LISTENING 1
@@ -125,12 +105,7 @@ typedef struct {
} tGAP_CLCB;

typedef struct {
  tGAP_INFO blk[GAP_MAX_BLOCKS];
  tBTM_CMPL_CB* btm_cback[GAP_MAX_BLOCKS];
  uint8_t trace_level;
  tGAP_FINDADDR_CB
      findaddr_cb; /* Contains the control block for finding a device addr */
  tBTM_INQ_INFO* cur_inqptr;

#if (GAP_CONN_INCLUDED == TRUE)
  tGAP_CONN conn;

system/stack/gap/gap_utils.cc

deleted100644 → 0
+0 −129
Original line number Diff line number Diff line
/******************************************************************************
 *
 *  Copyright (C) 2009-2013 Broadcom Corporation
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at:
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 ******************************************************************************/

#include <string.h>
#include "bt_target.h"
#include "bt_utils.h"
#include "gap_int.h"

/*******************************************************************************
 *
 * Function         gap_allocate_cb
 *
 * Description      Look through the GAP Control Blocks for a free one.
 *
 * Returns          Pointer to the control block or NULL if not found
 *
 ******************************************************************************/
tGAP_INFO* gap_allocate_cb(void) {
  tGAP_INFO* p_cb = &gap_cb.blk[0];
  uint8_t x;

  for (x = 0; x < GAP_MAX_BLOCKS; x++, p_cb++) {
    if (!p_cb->in_use) {
      memset(p_cb, 0, sizeof(tGAP_INFO));

      p_cb->in_use = true;
      p_cb->index = x;
      p_cb->p_data = (void*)NULL;
      return (p_cb);
    }
  }

  /* If here, no free control blocks found */
  return (NULL);
}

/*******************************************************************************
 *
 * Function         gap_free_cb
 *
 * Description      Release GAP control block.
 *
 * Returns          Pointer to the control block or NULL if not found
 *
 ******************************************************************************/
void gap_free_cb(tGAP_INFO* p_cb) {
  if (p_cb) {
    p_cb->gap_cback = NULL;
    p_cb->in_use = false;
  }
}

/*******************************************************************************
 *
 * Function         gap_is_service_busy
 *
 * Description      Look through the GAP Control Blocks that are in use
 *                  and check to see if the event waiting for is the command
 *                  requested.
 *
 * Returns          true if already in use
 *                  false if not busy
 *
 ******************************************************************************/
bool gap_is_service_busy(uint16_t request) {
  tGAP_INFO* p_cb = &gap_cb.blk[0];
  uint8_t x;

  for (x = 0; x < GAP_MAX_BLOCKS; x++, p_cb++) {
    if (p_cb->in_use && p_cb->event == request) return (true);
  }

  /* If here, service is not busy */
  return (false);
}

/*******************************************************************************
 *
 * Function         gap_convert_btm_status
 *
 * Description      Converts a BTM error status into a GAP error status
 *
 *
 * Returns          GAP_UNKNOWN_BTM_STATUS is returned if not recognized
 *
 ******************************************************************************/
uint16_t gap_convert_btm_status(tBTM_STATUS btm_status) {
  switch (btm_status) {
    case BTM_SUCCESS:
      return (BT_PASS);

    case BTM_CMD_STARTED:
      return (GAP_CMD_INITIATED);

    case BTM_BUSY:
      return (GAP_ERR_BUSY);

    case BTM_MODE_UNSUPPORTED:
    case BTM_ILLEGAL_VALUE:
      return (GAP_ERR_ILL_PARM);

    case BTM_WRONG_MODE:
      return (GAP_DEVICE_NOT_UP);

    case BTM_UNKNOWN_ADDR:
      return (GAP_BAD_BD_ADDR);

    case BTM_DEVICE_TIMEOUT:
      return (GAP_ERR_TIMEOUT);

    default:
      return (GAP_ERR_PROCESSING);
  }
}