Merge "Revert "libnewblue: Pass connection parameters to hci""
diff --git a/gatt.c b/gatt.c
index 09bca5e..e948079 100644
--- a/gatt.c
+++ b/gatt.c
@@ -1564,64 +1564,35 @@
  * FUNCTION: gattConnectionCreateOrLocate
  * USE:      Make a new gatt L2C connection or find an existing one
  * PARAMS:   to - whom to connect to
- *           connectParameters - parameters specified create connection details
  * RETURN:   connection struct or NULL
  * NOTES:    call with mGattLock held
  */
-static struct gattConnState* gattConnectionCreateOrLocate(
-    const struct bt_addr* to,
-    const l2cConnectParameters_t* connectParameters) {
-  struct gattConnState* gattConn;
+static struct gattConnState* gattConnectionCreateOrLocate(const struct bt_addr *to)
+{
+    struct gattConnState *gattConn;
+    bool connTrying;
 
-  gattConn = gattConnFindByAddr(to);
-  if (!gattConn) {
-    if (gattStateAllocLocked(0, (void**)&gattConn, to,
-                             GATT_CONN_STATE_CONNECTING) != SVC_ALLOC_SUCCESS)
-      logw(
-          "Failed to allocate a gatt connection instance for an outbound GATT "
-          "connection to " ADDRFMT "\n",
-          ADDRCONV(*to));
-    else {
-      bool connTrying;
-      if (BT_ADDR_IS_EDR(*to))
-        connTrying = l2cApiCreatePsmConnection(GATT_PSM, to, L2C_MAX_SAFE_MTU,
-                                               gattConnEvt, NULL, gattConn,
-                                               connectParameters);
-      else
-        connTrying = l2cApiCreateFixedChConnection(
-            GATT_FIXEDCH, to, gattConnEvt, NULL, gattConn, connectParameters);
+    gattConn = gattConnFindByAddr(to);
+    if (!gattConn) {
 
-      if (!connTrying) {
-        logw(
-            "Failed to attempt to establish an outbound GATT connection "
-            "to " ADDRFMT "\n",
-            ADDRCONV(*to));
-        gattConnStructDelete(gattConn);
-        gattConn = NULL;
-      }
+        if (gattStateAllocLocked(0, (void**)&gattConn, to, GATT_CONN_STATE_CONNECTING) != SVC_ALLOC_SUCCESS)
+            logw("Failed to allocate a gatt connection instance for an outbound GATT connection to "ADDRFMT"\n", ADDRCONV(*to));
+        else {
+
+            if (BT_ADDR_IS_EDR(*to))
+                connTrying = l2cApiCreatePsmConnection(GATT_PSM, to, L2C_MAX_SAFE_MTU, gattConnEvt, NULL, gattConn);
+            else
+                connTrying = l2cApiCreateFixedChConnection(GATT_FIXEDCH, to, gattConnEvt, NULL, gattConn);
+
+            if (!connTrying) {
+                logw("Failed to attempt to establish an outbound GATT connection to "ADDRFMT"\n", ADDRCONV(*to));
+                gattConnStructDelete(gattConn);
+                gattConn = NULL;
+            }
+        }
     }
-  }
 
-  return gattConn;
-}
-
-/*
- * FUNCTION: gattConnectParametersTol2cConnectParameters
- * USE:      Convert connection parameter structure from gatt to l2c format
- * PARAMS:   gattConnectParameters - Gatt formatted connection parameter
- *           l2cConnectParameters - L2C formatted connection parameter
- */
-static void gattConnectParametersTol2cConnectParameters(
-    const struct GattConnectParameters* gattConnectParameters,
-    l2cConnectParameters_t* l2cConnectParameters) {
-  l2cConnectParameters->scanInterval = gattConnectParameters->scan_interval;
-  l2cConnectParameters->scanWindow = gattConnectParameters->scan_window;
-  l2cConnectParameters->connectIntervalMin =
-      gattConnectParameters->connect_interval_min;
-  l2cConnectParameters->connectIntervalMax =
-      gattConnectParameters->connect_interval_max;
-  l2cConnectParameters->latency = gattConnectParameters->latency;
-  l2cConnectParameters->timeout = gattConnectParameters->timeout;
+    return gattConn;
 }
 
 /*
@@ -1629,7 +1600,6 @@
  * USE:      Make a new gatt client connection
  * PARAMS:   userData - caller's data which will be given with the callback
  *           to - whom to connect to
- *           connectParameters - parameters specified create connection details
  *           resultCbk - will be called with results
  * RETURN:   connection id or 0 on failure
  * NOTES:    the callback might be called before this func returnes (talk
@@ -1639,57 +1609,50 @@
  *           a mutex in callback, and also take it before calling this, do
  *           not release it till this func returns.
  */
-gatt_client_conn_t gattClientConnect(
-    void* userData,
-    const struct bt_addr* to,
-    const struct GattConnectParameters* connectParameters,
-    gattCliConnectResultCbk resultCbk) {
-  struct gattClientConnection* clicon;
-  struct gattConnState* inst;
-  gatt_client_conn_t ret = 0;
+gatt_client_conn_t gattClientConnect(void *userData, const struct bt_addr *to,
+                                     gattCliConnectResultCbk resultCbk)
+{
+    struct gattClientConnection *clicon;
+    struct gattConnState *inst;
+    gatt_client_conn_t ret = 0;
 
-  clicon = calloc(1, sizeof(struct gattClientConnection));
-  if (!clicon) {
-    loge("Out of memory allocating a client connection for GATT\n");
-    return 0;
-  }
+    clicon = calloc(1, sizeof(struct gattClientConnection));
+    if (!clicon) {
+        loge("Out of memory allocating a client connection for GATT\n");
+        return 0;
+    }
 
-  l2cConnectParameters_t l2cConnectParameters;
-  gattConnectParametersTol2cConnectParameters(connectParameters,
-                                              &l2cConnectParameters);
-  pthread_mutex_lock(&mGattLock);
-  inst = gattConnectionCreateOrLocate(to, &l2cConnectParameters);
-  if (!inst) {
-    logw(
-        "Failed to create an outbound GATT connection. Client connection "
-        "process will end\n");
-    goto out;
-  }
+    pthread_mutex_lock(&mGattLock);
+    inst = gattConnectionCreateOrLocate(to);
+    if (!inst) {
+        logw("Failed to create an outbound GATT connection. Client connection process will end\n");
+        goto out;
+    }
 
-  inst->numLocalUsers++;
-  clicon->next = mClientConns;
-  if (mClientConns)
-    mClientConns->prev = clicon;
-  mClientConns = clicon;
+    inst->numLocalUsers++;
+    clicon->next = mClientConns;
+    if (mClientConns)
+        mClientConns->prev = clicon;
+    mClientConns = clicon;
 
-  clicon->userData = userData;
-  clicon->gattConnId = inst->gattConnId;
-  clicon->connId = uniqGetNext();
-  clicon->connCbk = resultCbk;
+    clicon->userData = userData;
+    clicon->gattConnId = inst->gattConnId;
+    clicon->connId = uniqGetNext();
+    clicon->connCbk = resultCbk;
 
-  // call callback right away?
-  if (inst->state == GATT_CONN_STATE_RUNNING)
-    gattEnqueueCliConnStatusCall(clicon, GATT_CLI_STATUS_OK);
+    // call callback right away?
+    if (inst->state == GATT_CONN_STATE_RUNNING)
+        gattEnqueueCliConnStatusCall(clicon, GATT_CLI_STATUS_OK);
 
-  // success!
-  ret = clicon->connId;
-  pthread_mutex_unlock(&mGattLock);
-  return ret;
+    // success!
+    ret = clicon->connId;
+    pthread_mutex_unlock(&mGattLock);
+    return ret;
 
 out:
-  pthread_mutex_unlock(&mGattLock);
-  free(clicon);
-  return 0;
+    pthread_mutex_unlock(&mGattLock);
+    free(clicon);
+    return 0;
 }
 
 /*
diff --git a/gatt.h b/gatt.h
index 66ebf26..3119e45 100644
--- a/gatt.h
+++ b/gatt.h
@@ -159,14 +159,6 @@
     struct GattTraversedServiceInclSvc *inclSvcs;
 };
 
-struct GattConnectParameters {
-    uint16_t scan_interval;
-    uint16_t scan_window;
-    uint16_t connect_interval_min;
-    uint16_t connect_interval_max;
-    uint16_t latency;
-    uint16_t timeout;
-};
 
 /* gatt client callbacks */
 
@@ -209,11 +201,7 @@
 
 
 /* connection lifecycle */
-gatt_client_conn_t gattClientConnect(
-    void* userData,
-    const struct bt_addr* to,
-    const struct GattConnectParameters* connectParameters,
-    gattCliConnectResultCbk resultCbk) NEWBLUE_EXPORT;
+gatt_client_conn_t gattClientConnect(void *userData, const struct bt_addr *to, gattCliConnectResultCbk resultCbk) NEWBLUE_EXPORT;
 uint8_t gattClientDisconnect(gatt_client_conn_t conn) NEWBLUE_EXPORT; /* -> GATT_CLI_*, calls the gattCliConnectResultCbk passed to gattClientConnect() with GATT_CLI_OTHER_SIDE_DISC */
 
 /* cache maintenance */
diff --git a/hci.c b/hci.c
index 5ec57af..89ba774 100644
--- a/hci.c
+++ b/hci.c
@@ -4085,7 +4085,7 @@
  *           timeoutP - if not null, timeout to use. if null - stack picks
  * RETURN:   connectin handle if an attempt will be made to connect. 0 else
  */
-hci_conn_t hciConnect(const struct bt_addr* addr, const uint8_t* selfRandomAddr, uint16_t* scanIntervalP, uint16_t* scanWindowP, uint16_t* connIntervalMinP, uint16_t* connIntervalMaxP, uint16_t* latencyP, uint16_t* timeoutP)
+hci_conn_t hciConnect(const struct bt_addr* addr, const uint8_t *selfRandomAddr, uint16_t *scanIntervalP, uint16_t *scanWindowP, uint16_t *connIntervalMinP, uint16_t *connIntervalMaxP, uint16_t *latencyP, uint16_t *timeoutP)
 {
     uint32_t scanInterval, scanWindow, connIntervalMin, connIntervalMax, latency, timeout;
     hci_conn_t ret = 0;
diff --git a/hci.h b/hci.h
index ac4054f..1cb9b78 100644
--- a/hci.h
+++ b/hci.h
@@ -158,15 +158,6 @@
 #define HCI_NAME_REQ_STATUS_ERROR        1
 #define HCI_NAME_REQ_STATUS_COMPLETE     2
 
-struct hciConnectParameters {
-    uint16_t scanInterval;
-    uint16_t scanWindow;
-    uint16_t connectIntervalMin;
-    uint16_t connectIntervalMax;
-    uint16_t latency;
-    uint16_t timeout;
-};
-
 /* various callbacks - it is universally a bad idea to call back into hci from these, except otherwise noted funcs */
 /* rssi = 127 -> no RSSI */
 typedef void (*hciDeviceDiscoveredLeCbk)(void *cbkData, const struct bt_addr *addr, const struct bt_addr *resolvedAddr, int8_t rssi, uint8_t replyType, const void *eir, uint8_t eirLen);
@@ -201,14 +192,7 @@
 #define HCI_BOUNDARY_CONT       2
 
 /* connect */
-hci_conn_t hciConnect(const struct bt_addr* addr,
-                      const uint8_t* selfRandomAddr,
-                      uint16_t* scanIntervalP,
-                      uint16_t* scanWindowP,
-                      uint16_t* connIntervalMinP,
-                      uint16_t* connIntervalMaxP,
-                      uint16_t* latencyP,
-                      uint16_t* timeoutP);
+hci_conn_t hciConnect(const struct bt_addr* addr, const uint8_t *selfRandomAddr, uint16_t *scanIntervalP, uint16_t *scanWindowP, uint16_t *connIntervalMinP, uint16_t *connIntervalMaxP, uint16_t *latencyP, uint16_t *timeoutP);
 /* disconnect/cancel connection attempt */
 bool hciDisconnect(hci_conn_t aclConn);
 /* try to send data -> HCI_TX_SEND_*   boundary = HCI_BOUNDARY_* */
diff --git a/l2cap.c b/l2cap.c
index ccb607f..ed8cdbd 100644
--- a/l2cap.c
+++ b/l2cap.c
@@ -368,7 +368,7 @@
         } connUpdtCbk;
         struct {
             struct bt_addr addr;
-            l2cConnectParameters_t connectParameters;
+            //todo: more params for non-default conns?
         } linkOpen;
         struct {
             hci_conn_t aclConn;
@@ -902,36 +902,22 @@
  * FUNCTION: l2cSvcWorkScheduleAclLinkOpen
  * USE:      Schedule an ACL link open call to the lower layer
  * PARAMS:   addr - the address of peer to connect to
- *           connectParameters - parameters specified create connection details
  * RETURN:   false on immediate error
  * NOTES:    actual call will happen in the worker thread.
  */
-static bool l2cSvcWorkScheduleAclLinkOpen(
-    const struct bt_addr* addr,
-    const l2cConnectParameters_t* connectParameters) {
-  struct l2cSvcWork* w = l2cSvcWorkAlloc(L2C_WORK_ACL_LINK_OPEN, 0);
-  if (!w)
+static bool l2cSvcWorkScheduleAclLinkOpen(const struct bt_addr *addr)
+{
+    struct l2cSvcWork* w = l2cSvcWorkAlloc(L2C_WORK_ACL_LINK_OPEN, 0);
+    if (!w)
+        return false;
+
+    w->linkOpen.addr = *addr;
+    if (workQueuePut(mServiceWork, w))
+        return true;
+
+    loge("Failed to enqueue service work for ACL link open!\n");
+    free(w);
     return false;
-
-  w->linkOpen.addr = *addr;
-
-  // Check if upper level pass down a struct of connection parameters, if not
-  // use default instead.
-  if (!connectParameters) {
-    w->linkOpen.connectParameters = (l2cConnectParameters_t){
-        HCI_LE_CONN_SCAN_INTERVAL, HCI_LE_CONN_SCAN_WINDOW,
-        HCI_LE_CONN_INT_MIN,       HCI_LE_CONN_INT_MAX,
-        HCI_LE_CONN_LATENCY,       HCI_LE_CONN_TIMEOUT};
-  } else {
-    w->linkOpen.connectParameters = *connectParameters;
-  }
-
-  if (workQueuePut(mServiceWork, w))
-    return true;
-
-  loge("Failed to enqueue service work for ACL link open!\n");
-  free(w);
-  return false;
 }
 
 /*
@@ -5247,54 +5233,51 @@
  * FUNCTION: l2cCreateAndOpenNewAclConn
  * USE:      Request an ACL connection be created
  * PARAMS:   addr - the peer address
- *           connectParameters - parameters specified create connection details
  * RETURN:   true is it was requested. False on immediate error.
  * NOTES:    call with mConnsLock held
  */
-static struct l2cAclConn* l2cCreateAndOpenNewAclConn(
-    const struct bt_addr* addr,
-    const l2cConnectParameters_t* connectParameters) {
-  struct l2cAclConn* conn;
+static struct l2cAclConn* l2cCreateAndOpenNewAclConn(const struct bt_addr* addr)
+{
+    struct l2cAclConn *conn;
 
-  conn = l2cAclConnFindByAddr(addr);
-  if (conn) {
-    if (conn->state == L2C_ACL_STATE_TEARDOWN) {
-      logw("Asked to establish existing ACL conn as it goes down. Bad luck\n");
-      return NULL;
-    } else {
-      logw("Asked to establish existing ACL conn\n");
-      return conn;
+    conn = l2cAclConnFindByAddr(addr);
+    if (conn) {
+        if (conn->state == L2C_ACL_STATE_TEARDOWN) {
+            logw("Asked to establish existing ACL conn as it goes down. Bad luck\n");
+            return NULL;
+        } else {
+            logw("Asked to establish existing ACL conn\n");
+            return conn;
+        }
     }
-  }
 
-  conn = (struct l2cAclConn*)calloc(1, sizeof(struct l2cAclConn));
-  if (!conn) {
-    loge("Out of memory\n");
-    return NULL;
-  }
+    conn = (struct l2cAclConn*)calloc(1, sizeof(struct l2cAclConn));
+    if (!conn) {
+        loge("Out of memory\n");
+        return NULL;
+    }
 
-  memcpy(&conn->peerAddr, addr, sizeof(conn->peerAddr));
-  conn->handle = uniqGetNext();
-  conn->state = L2C_ACL_STATE_PENDING;
-  conn->prev = NULL;
-  conn->reassSg = NULL;
-  conn->sigMtu = L2C_MIN_SIG_MTU;
+    memcpy(&conn->peerAddr, addr, sizeof(conn->peerAddr));
+    conn->handle = uniqGetNext();
+    conn->state = L2C_ACL_STATE_PENDING;
+    conn->prev = NULL;
+    conn->reassSg = NULL;
+    conn->sigMtu = L2C_MIN_SIG_MTU;
 
-  if (!l2cSvcWorkScheduleAclLinkOpen(&conn->peerAddr, connectParameters)) {
-    free(conn);
-    conn = NULL;
-  } else {
-    conn->next = mAclConns;
-    if (mAclConns)
-      mAclConns->prev = conn;
-    mAclConns = conn;
-    conn->openTimer =
-        timerSet(L2C_ACL_LINK_UP_TIMEOUT, l2cAclLinkUpTimeout, conn->handle);
-    if (!conn->openTimer)
-      loge("Failed to set open timeout for ACL link\n");
-  }
+    if (!l2cSvcWorkScheduleAclLinkOpen(&conn->peerAddr)) {
+        free(conn);
+        conn = NULL;
+    } else {
+        conn->next = mAclConns;
+        if (mAclConns)
+            mAclConns->prev = conn;
+        mAclConns = conn;
+        conn->openTimer = timerSet(L2C_ACL_LINK_UP_TIMEOUT, l2cAclLinkUpTimeout, conn->handle);
+        if (!conn->openTimer)
+            loge("Failed to set open timeout for ACL link\n");
+    }
 
-  return conn;
+    return conn;
 }
 
 /*
@@ -5306,100 +5289,90 @@
  *           doneCbk - function to call when action completes
  *           userData - data to pass to stateCbk
  *           instance - data to pass to stateCbk
- *           connectParameters - parameters specified create connection details
  * RETURN:   true is a send was requested. False on immediate error.
  * NOTES:    callback may be called before this function returns, if
  *           true was returned, at least one call to the callback
  *           will happen
  */
-bool l2cApiCreatePsmConnection(
-    psm_t psm,
-    const struct bt_addr* addr,
-    uint16_t mtu,
-    l2cStateCbk stateCbk,
-    void* userData,
-    void* instance,
-    const l2cConnectParameters_t* connectParameters) {
-  struct l2cAclConn* aclConn;
-  struct l2cConn* conn = NULL;
-  bool ret = false;
+bool l2cApiCreatePsmConnection(psm_t psm, const struct bt_addr* addr, uint16_t mtu, l2cStateCbk stateCbk, void* userData, void* instance)
+{
+    struct l2cAclConn *aclConn;
+    struct l2cConn *conn = NULL;
+    bool ret = false;
 
-  if (!stateCbk) {
-    logw("Invalid stateCbk\n");
-    return false;
-  }
-
-  if (!l2cPsmValid(psm)) {
-    logw("Invalid PSM %d\n", psm);
-    return false;
-  }
-
-  if (BT_ADDR_IS_LE(*addr)) {
-    logw("Cannot create a PSM connection to an LE address\n");
-    return false;
-  }
-
-  pthread_mutex_lock(&mConnsLock);
-  aclConn = l2cAclConnFindByAddr(addr);
-  if (aclConn && aclConn->state == L2C_ACL_STATE_TEARDOWN) {
-    logw("Trying to open a connection over a going-down ACL link. Bad luck\n");
-    goto out;
-  } else if (!aclConn) {
-    logd("acl not found for connection requested, making one\n");
-    aclConn = l2cCreateAndOpenNewAclConn(addr, connectParameters);
-  }
-  if (!aclConn) {
-    loge("Failed to create/open/find ACL conn\n");
-    goto out;
-  }
-
-  conn = l2cNewConnStruct(L2C_CONN_STATE_CONN_WAIT, aclConn->handle, 0, 0, psm,
-                          mtu, true);
-  if (!conn) {
-    loge("Failed to allocate an L2C conn\n");
-    goto out;
-  }
-
-  /* create the conn */
-  conn->stateCbk = stateCbk;
-  conn->userData = userData;
-  conn->instance = instance;
-  conn->inUse = 1;
-
-  if (aclConn->conn == L2C_ACL_STATE_ESTABLISHED) {
-    uint8_t ident;
-    uint16_t localCh = l2cAclFreeCid(aclConn);
-
-    if (!localCh) {
-      logw("No free channels for acl " HCI_CONN_FMT "x\n",
-           HCI_CONN_CONV(aclConn->conn));
-      goto out;
+    if (!stateCbk) {
+        logw("Invalid stateCbk\n");
+        return false;
     }
 
-    ident = l2cSigSendConnectionReq(aclConn, psm, localCh);
-    if (!ident) {
-      l2cSvcWorkScheduleStateCallDirect(stateCbk, userData, instance,
-                                        L2C_STATE_CLOSED, NULL, 0);
-      loge("Failed to request opening of a psm channel\n");
-      goto out;
+    if (!l2cPsmValid(psm)) {
+        logw("Invalid PSM %d\n", psm);
+        return false;
     }
-    conn->localCh = localCh;
-    conn->state = L2C_CONN_STATE_TX_OPEN_TXED;
-    conn->ident = ident;
-    l2cAclDownTimerStop(aclConn);
-    l2cConnTimer(conn, L2C_L2CAP_OPEN_TIMEOUT);
-  }
-  conn->next = mConns;
-  if (mConns)
-    mConns->prev = conn;
-  mConns = conn;
-  ret = true;
+
+    if (BT_ADDR_IS_LE(*addr)) {
+        logw("Cannot create a PSM connection to an LE address\n");
+        return false;
+    }
+
+    pthread_mutex_lock(&mConnsLock);
+    aclConn = l2cAclConnFindByAddr(addr);
+    if (aclConn && aclConn->state == L2C_ACL_STATE_TEARDOWN) {
+        logw("Trying to open a connection over a going-down ACL link. Bad luck\n");
+        goto out;
+    } else if (!aclConn) {
+        logd("acl not found for connection requested, making one\n");
+        aclConn = l2cCreateAndOpenNewAclConn(addr);
+    }
+    if (!aclConn) {
+        loge("Failed to create/open/find ACL conn\n");
+        goto out;
+    }
+
+    conn = l2cNewConnStruct(L2C_CONN_STATE_CONN_WAIT, aclConn->handle, 0, 0, psm, mtu, true);
+    if (!conn) {
+        loge("Failed to allocate an L2C conn\n");
+        goto out;
+    }
+
+    /* create the conn */
+    conn->stateCbk = stateCbk;
+    conn->userData = userData;
+    conn->instance = instance;
+    conn->inUse = 1;
+
+    if (aclConn->conn == L2C_ACL_STATE_ESTABLISHED) {
+        uint8_t ident;
+        uint16_t localCh = l2cAclFreeCid(aclConn);
+
+        if (!localCh) {
+            logw("No free channels for acl "HCI_CONN_FMT"x\n", HCI_CONN_CONV(aclConn->conn));
+            goto out;
+        }
+
+        ident = l2cSigSendConnectionReq(aclConn, psm, localCh);
+        if (!ident) {
+            l2cSvcWorkScheduleStateCallDirect(stateCbk, userData, instance, L2C_STATE_CLOSED, NULL, 0);
+            loge("Failed to request opening of a psm channel\n");
+            goto out;
+        }
+        conn->localCh = localCh;
+        conn->state = L2C_CONN_STATE_TX_OPEN_TXED;
+        conn->ident = ident;
+        l2cAclDownTimerStop(aclConn);
+        l2cConnTimer(conn, L2C_L2CAP_OPEN_TIMEOUT);
+    }
+    conn->next = mConns;
+    if (mConns)
+        mConns->prev = conn;
+    mConns = conn;
+    ret = true;
 
 out:
-  pthread_mutex_unlock(&mConnsLock);
-  if (!ret && conn)
-    free(conn);
-  return ret;
+    pthread_mutex_unlock(&mConnsLock);
+    if (!ret && conn)
+        free(conn);
+    return ret;
 }
 
 /*
@@ -5410,89 +5383,80 @@
  *           stateCbk - function to call with state
  *           userData - data to pass to stateCbk
  *           instance - data to pass to stateCbk
- *           connectParameters - parameters specified create connection details
  * RETURN:   true is a send was requested. False on immediate error.
  * NOTES:    callback may be called before this function returns, if
  *           true was returned, at least one call to the callback
  *           will happen
  */
-bool l2cApiCreateFixedChConnection(
-    uint16_t chan,
-    const struct bt_addr* addr,
-    l2cStateCbk stateCbk,
-    void* userData,
-    void* instance,
-    const l2cConnectParameters_t* connectParameters) {
-  struct l2cAclConn* aclConn;
-  struct l2cConn* conn = NULL;
-  bool ret = false;
+bool l2cApiCreateFixedChConnection(uint16_t chan, const struct bt_addr* addr, l2cStateCbk stateCbk, void* userData, void* instance)
+{
+    struct l2cAclConn *aclConn;
+    struct l2cConn *conn = NULL;
+    bool ret = false;
 
-  if (chan == L2C_CH_SIGNALLING_EDR || chan == L2C_CH_CONNECTIONLESS ||
-      chan == L2C_CH_SIGNALLING_LE || !chan || chan >= L2C_NUM_FIXED_CHANNELS) {
-    logw("Invalid channel for creating a FixedCh connection\n");
-    return false;
-  }
+    if (chan == L2C_CH_SIGNALLING_EDR || chan == L2C_CH_CONNECTIONLESS ||
+        chan == L2C_CH_SIGNALLING_LE || !chan || chan >= L2C_NUM_FIXED_CHANNELS) {
+        logw("Invalid channel for creating a FixedCh connection\n");
+        return false;
+    }
 
-  if (!stateCbk) {
-    logw("Invalid stateCbk\n");
-    return false;
-  }
+    if (!stateCbk) {
+        logw("Invalid stateCbk\n");
+        return false;
+    }
 
-  pthread_mutex_lock(&mConnsLock);
-  aclConn = l2cAclConnFindByAddr(addr);
-  if (aclConn && aclConn->state == L2C_ACL_STATE_TEARDOWN) {
-    logw("Trying to open a connection over a going-down ACL link. Bad luck\n");
-    goto out;
-  } else if (!aclConn) {
-    logd("acl not found for connection requested, making one\n");
-    aclConn = l2cCreateAndOpenNewAclConn(addr, connectParameters);
-  }
-  if (!aclConn) {
-    loge("Failed to create/open/find ACL conn\n");
-    goto out;
-  }
+    pthread_mutex_lock(&mConnsLock);
+    aclConn = l2cAclConnFindByAddr(addr);
+    if (aclConn && aclConn->state == L2C_ACL_STATE_TEARDOWN) {
+        logw("Trying to open a connection over a going-down ACL link. Bad luck\n");
+        goto out;
+    } else if (!aclConn) {
+        logd("acl not found for connection requested, making one\n");
+        aclConn = l2cCreateAndOpenNewAclConn(addr);
+    }
+    if (!aclConn) {
+        loge("Failed to create/open/find ACL conn\n");
+        goto out;
+    }
 
-  /* check is same FixedCh already exists */
-  conn = mConns;
-  while (conn &&
-         (conn->acl != aclConn->handle || conn->psm || conn->localCh != chan))
-    conn = conn->next;
-  if (conn) {
-    logi("Ignoring attempt to open FixedCh %d conn when existing exists\n",
-         chan);
-    goto out;
-  }
+    /* check is same FixedCh already exists */
+    conn = mConns;
+    while(conn && (conn->acl != aclConn->handle || conn->psm || conn->localCh != chan))
+         conn = conn->next;
+    if (conn) {
+        logi("Ignoring attempt to open FixedCh %d conn when existing exists\n", chan);
+        goto out;
+    }
 
-  conn = l2cNewConnStruct(L2C_CONN_STATE_CONN_WAIT, aclConn->handle, chan, chan,
-                          0, 0, true);
-  if (!conn) {
-    loge("Failed to allocate an L2C conn\n");
-    return false;
-  }
+    conn = l2cNewConnStruct(L2C_CONN_STATE_CONN_WAIT, aclConn->handle, chan, chan, 0, 0, true);
+    if (!conn) {
+        loge("Failed to allocate an L2C conn\n");
+        return false;
+    }
 
-  /* create the conn */
-  conn->handle = uniqGetNext();
-  conn->stateCbk = stateCbk;
-  conn->userData = userData;
-  conn->instance = instance;
-  conn->inUse = 1;
+    /* create the conn */
+    conn->handle = uniqGetNext();
+    conn->stateCbk = stateCbk;
+    conn->userData = userData;
+    conn->instance = instance;
+    conn->inUse = 1;
 
-  if (aclConn->state == L2C_ACL_STATE_ESTABLISHED) {
-    l2cChannelReadyForData(aclConn, conn);
-    l2cAclDownTimerStop(aclConn);
-  }
+    if (aclConn->state == L2C_ACL_STATE_ESTABLISHED) {
+        l2cChannelReadyForData(aclConn, conn);
+        l2cAclDownTimerStop(aclConn);
+    }
 
-  conn->next = mConns;
-  if (mConns)
-    mConns->prev = conn;
-  mConns = conn;
-  ret = true;
+    conn->next = mConns;
+    if (mConns)
+        mConns->prev = conn;
+    mConns = conn;
+    ret = true;
 
 out:
-  pthread_mutex_unlock(&mConnsLock);
-  if (!ret && conn)
-    free(conn);
-  return ret;
+    pthread_mutex_unlock(&mConnsLock);
+    if (!ret && conn)
+        free(conn);
+    return ret;
 }
 
 /*
diff --git a/l2cap.h b/l2cap.h
index 59affe0..aa94128 100644
--- a/l2cap.h
+++ b/l2cap.h
@@ -43,8 +43,6 @@
 
 /* HIGHER LAYER INTERFACE API */
 
-/* connection parameters */
-typedef struct hciConnectParameters l2cConnectParameters_t;
 
 /* callbacks for connections */
 struct l2cEncrState {
@@ -120,23 +118,11 @@
 
 
 /* call this to connect to a remote PSM-based service Expect an MTU callback. */
-bool l2cApiCreatePsmConnection(psm_t psm,
-                               const struct bt_addr* addr,
-                               uint16_t mtu,
-                               l2cStateCbk stateCbk,
-                               void* userData,
-                               void* instance,
-                               const l2cConnectParameters_t* connectParameters);
+bool l2cApiCreatePsmConnection(psm_t psm, const struct bt_addr *addr, uint16_t mtu, l2cStateCbk stateCbk, void *userData, void *instance);
 
-/* call this to connect to a remote FixedCh service. Do not expect an MTU
- * callback. */
-bool l2cApiCreateFixedChConnection(
-    uint16_t chan,
-    const struct bt_addr* addr,
-    l2cStateCbk stateCbk,
-    void* userData,
-    void* instance,
-    const l2cConnectParameters_t* connectParameters);
+/* call this to connect to a remote FixedCh service. Do not expect an MTU callback. */
+bool l2cApiCreateFixedChConnection(uint16_t chan, const struct bt_addr *addr, l2cStateCbk stateCbk, void *userData, void *instance);
+
 
 /* call this to request a connection parameter update for a given connection */
 typedef void (*l2cConnUpdateDoneCbk)(void *userData, bool success);
diff --git a/sm.c b/sm.c
index 7b50e63..6fe97cc 100644
--- a/sm.c
+++ b/sm.c
@@ -3128,7 +3128,7 @@
     inst->peerKeyDistrReq = inst->myKeyDistrReq;
     inst->peerKeyDistr = inst->myKeyDistrReq;
 
-    if (!l2cApiCreateFixedChConnection(L2C_FIXED_CH_NUM_SM, addr, smFixedChState, NULL, inst, NULL)) {
+    if (!l2cApiCreateFixedChConnection(L2C_FIXED_CH_NUM_SM, addr, smFixedChState, NULL, inst)) {
         logw("%s(): Error creating a fixed channel l2cap connection\n", __func__);
         pairErr = SM_PAIR_ERR_L2C_CONN;
         goto fail;
diff --git a/test.c b/test.c
index 8d257cd..1b79ef1 100644
--- a/test.c
+++ b/test.c
@@ -136,12 +136,6 @@
 
 #define TEST_SCAN_INTERVAL              36
 #define TEST_SCAN_WINDOW                18
-#define TEST_CONN_SCAN_INTERVAL         24
-#define TEST_CONN_SCAN_WINDOW           6
-#define TEST_CONN_INT_MIN               10
-#define TEST_CONN_INT_MAX               20
-#define TEST_CONN_LATENCY               10
-#define TEST_CONN_TIMEOUT               83
 
 void logData(char* dst, const void *buf, uint8_t len)
 {
@@ -153,10 +147,6 @@
         sprintf(dst + strlen(dst), " %02X", data[i]);
 }
 
-static const struct GattConnectParameters mConnectParameters = {
-    TEST_CONN_SCAN_INTERVAL, TEST_CONN_SCAN_WINDOW, TEST_CONN_INT_MIN,
-    TEST_CONN_INT_MAX,       TEST_CONN_LATENCY,     TEST_CONN_TIMEOUT};
-
 static gatt_service_t mSvcTime = 0;
 static att_cid_t mConnTime = 0;
 static bool stopTimeService = false;
@@ -445,7 +435,7 @@
     gattSvcMiscInfoInit(miscInfoSvcStateCbk, miscInfoSvcRxCbk);
     btleHidInit(hidConnStateCbk, hidReportRxCbk);
 
-    con = gattClientConnect(NULL, connTo, &mConnectParameters, gattConnectedCbkHidTest);
+    con = gattClientConnect(NULL, connTo, gattConnectedCbkHidTest);
     if (!con)
         logw("Failed to try to form a GATT connection!\n");
     else {
@@ -1088,7 +1078,7 @@
             }
             else if (wantConnect) {
 
-                con = gattClientConnect(NULL, &connTo, &mConnectParameters, gattConnectedCbkGattEnum);
+                con = gattClientConnect(NULL, &connTo, gattConnectedCbkGattEnum);
                 if (!con)
                     logw("Failed to try to form a GATT connection!\n");
                 else {