You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2017/03/06 21:19:01 UTC
[25/50] incubator-mynewt-core git commit: nimble/l2cap: Remove not
needed function ble_l2cap_sig_init_cmd
nimble/l2cap: Remove not needed function ble_l2cap_sig_init_cmd
After refactor this function is not needed anymore in the host code.
The only user of it is unitest and this patch fixes that.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/d9f788b4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/d9f788b4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/d9f788b4
Branch: refs/heads/master
Commit: d9f788b49df395538cc2081eabe38161a3165ca7
Parents: ba9de55
Author: \u0141ukasz Rymanowski <lu...@codecoup.pl>
Authored: Tue Feb 28 13:23:41 2017 +0100
Committer: \u0141ukasz Rymanowski <lu...@codecoup.pl>
Committed: Fri Mar 3 12:40:42 2017 +0100
----------------------------------------------------------------------
net/nimble/host/src/ble_l2cap_sig_cmd.c | 34 ----------------------
net/nimble/host/test/src/ble_hs_test_util.c | 22 ++++-----------
net/nimble/host/test/src/ble_l2cap_test.c | 36 ++++++------------------
3 files changed, 13 insertions(+), 79 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d9f788b4/net/nimble/host/src/ble_l2cap_sig_cmd.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_l2cap_sig_cmd.c b/net/nimble/host/src/ble_l2cap_sig_cmd.c
index e6a7209..4381be5 100644
--- a/net/nimble/host/src/ble_l2cap_sig_cmd.c
+++ b/net/nimble/host/src/ble_l2cap_sig_cmd.c
@@ -21,40 +21,6 @@
#include "ble_hs_priv.h"
int
-ble_l2cap_sig_init_cmd(uint8_t op, uint8_t id, uint8_t payload_len,
- struct os_mbuf **out_om, void **out_payload_buf)
-{
- struct ble_l2cap_sig_hdr hdr;
- struct os_mbuf *txom;
- void *v;
-
- *out_om = NULL;
- *out_payload_buf = NULL;
-
- txom = ble_hs_mbuf_l2cap_pkt();
- if (txom == NULL) {
- return BLE_HS_ENOMEM;
- }
-
- v = os_mbuf_extend(txom, BLE_L2CAP_SIG_HDR_SZ + payload_len);
- if (v == NULL) {
- os_mbuf_free(txom);
- return BLE_HS_ENOMEM;
- }
-
- hdr.op = op;
- hdr.identifier = id;
- hdr.length = TOFROMLE16(payload_len);
-
- ble_l2cap_sig_hdr_write(v, BLE_L2CAP_SIG_HDR_SZ, &hdr);
-
- *out_om = txom;
- *out_payload_buf = (uint8_t *)v + BLE_L2CAP_SIG_HDR_SZ;
-
- return 0;
-}
-
-int
ble_l2cap_sig_tx(uint16_t conn_handle, struct os_mbuf *txom)
{
struct ble_l2cap_chan *chan;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d9f788b4/net/nimble/host/test/src/ble_hs_test_util.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/test/src/ble_hs_test_util.c b/net/nimble/host/test/src/ble_hs_test_util.c
index ceabd1c..0dc1b18 100644
--- a/net/nimble/host/test/src/ble_hs_test_util.c
+++ b/net/nimble/host/test/src/ble_hs_test_util.c
@@ -1820,36 +1820,24 @@ ble_l2cap_sig_update_rsp_parse(void *payload, int len,
dst->result = le16toh(src->result);
}
-static void
-ble_l2cap_test_update_rsp_write(void *payload, int len,
- struct ble_l2cap_sig_update_rsp *src)
-{
- struct ble_l2cap_sig_update_rsp *dst = payload;
-
- BLE_HS_DBG_ASSERT(len >= BLE_L2CAP_SIG_UPDATE_RSP_SZ);
- dst->result = htole16(src->result);
-}
-
int
ble_hs_test_util_rx_l2cap_update_rsp(uint16_t conn_handle,
uint8_t id, uint16_t result)
{
- struct ble_l2cap_sig_update_rsp rsp;
+ struct ble_l2cap_sig_update_rsp *rsp;
struct hci_data_hdr hci_hdr;
struct os_mbuf *om;
- void *v;
int rc;
hci_hdr = BLE_HS_TEST_UTIL_L2CAP_HCI_HDR(
2, BLE_HCI_PB_FIRST_FLUSH,
BLE_L2CAP_HDR_SZ + BLE_L2CAP_SIG_HDR_SZ + BLE_L2CAP_SIG_UPDATE_RSP_SZ);
- rc = ble_l2cap_sig_init_cmd(BLE_L2CAP_SIG_OP_UPDATE_RSP, id,
- BLE_L2CAP_SIG_UPDATE_RSP_SZ, &om, &v);
- TEST_ASSERT_FATAL(rc == 0);
+ rsp = ble_l2cap_sig_cmd_get(BLE_L2CAP_SIG_OP_UPDATE_RSP, id,
+ BLE_L2CAP_SIG_UPDATE_RSP_SZ, &om);
+ TEST_ASSERT_FATAL(rsp != NULL);
- rsp.result = result;
- ble_l2cap_test_update_rsp_write(v, BLE_L2CAP_SIG_UPDATE_RSP_SZ, &rsp);
+ rsp->result = htole16(result);
rc = ble_hs_test_util_l2cap_rx_first_frag(conn_handle, BLE_L2CAP_CID_SIG,
&hci_hdr, om);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d9f788b4/net/nimble/host/test/src/ble_l2cap_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/test/src/ble_l2cap_test.c b/net/nimble/host/test/src/ble_l2cap_test.c
index 2958a6c..9c11607 100644
--- a/net/nimble/host/test/src/ble_l2cap_test.c
+++ b/net/nimble/host/test/src/ble_l2cap_test.c
@@ -44,46 +44,26 @@ ble_l2cap_test_util_init(void)
}
static void
-ble_l2cap_test_update_req_swap(struct ble_l2cap_sig_update_req *dst,
- struct ble_l2cap_sig_update_req *src)
-{
- dst->itvl_min = le16toh(src->itvl_min);
- dst->itvl_max = le16toh(src->itvl_max);
- dst->slave_latency = le16toh(src->slave_latency);
- dst->timeout_multiplier = le16toh(src->timeout_multiplier);
-}
-
-static void
-ble_l2cap_test_update_req_write(void *payload, int len,
- struct ble_l2cap_sig_update_req *src)
-{
- BLE_HS_DBG_ASSERT(len >= BLE_L2CAP_SIG_UPDATE_REQ_SZ);
- ble_l2cap_test_update_req_swap(payload, src);
-}
-
-static void
ble_l2cap_test_util_rx_update_req(uint16_t conn_handle, uint8_t id,
struct ble_l2cap_sig_update_params *params)
{
- struct ble_l2cap_sig_update_req req;
+ struct ble_l2cap_sig_update_req *req;
struct hci_data_hdr hci_hdr;
struct os_mbuf *om;
- void *v;
int rc;
hci_hdr = BLE_HS_TEST_UTIL_L2CAP_HCI_HDR(
2, BLE_HCI_PB_FIRST_FLUSH,
BLE_L2CAP_HDR_SZ + BLE_L2CAP_SIG_HDR_SZ + BLE_L2CAP_SIG_UPDATE_REQ_SZ);
- rc = ble_l2cap_sig_init_cmd(BLE_L2CAP_SIG_OP_UPDATE_REQ, id,
- BLE_L2CAP_SIG_UPDATE_REQ_SZ, &om, &v);
- TEST_ASSERT_FATAL(rc == 0);
+ req = ble_l2cap_sig_cmd_get(BLE_L2CAP_SIG_OP_UPDATE_REQ, id,
+ BLE_L2CAP_SIG_UPDATE_REQ_SZ, &om);
+ TEST_ASSERT_FATAL(req != NULL);
- req.itvl_min = params->itvl_min;
- req.itvl_max = params->itvl_max;
- req.slave_latency = params->slave_latency;
- req.timeout_multiplier = params->timeout_multiplier;
- ble_l2cap_test_update_req_write(v, BLE_L2CAP_SIG_UPDATE_REQ_SZ, &req);
+ req->itvl_min = htole16(params->itvl_min);
+ req->itvl_max = htole16(params->itvl_max);
+ req->slave_latency = htole16(params->slave_latency);
+ req->timeout_multiplier = htole16(params->timeout_multiplier);
ble_hs_test_util_set_ack(
ble_hs_hci_util_opcode_join(BLE_HCI_OGF_LE,