You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2017/01/25 00:03:37 UTC
[1/4] incubator-mynewt-core git commit: Move endiannes related API
from ble.h to endian.h
Repository: incubator-mynewt-core
Updated Branches:
refs/heads/develop ab1cfd442 -> 4045e9612
Move endiannes related API from ble.h to endian.h
It makes more sense to have this API available for all components.
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/4045e961
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/4045e961
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/4045e961
Branch: refs/heads/develop
Commit: 4045e96124f2f1bea3fea4b6a68a590e0aa294ed
Parents: c78ed8a
Author: Szymon Janc <sz...@codecoup.pl>
Authored: Mon Jan 23 17:14:33 2017 +0100
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Jan 24 16:03:30 2017 -0800
----------------------------------------------------------------------
kernel/os/include/os/endian.h | 16 +++
kernel/os/src/endian.c | 218 ++++++++++++++++++++++++++++++++++
net/nimble/include/nimble/ble.h | 16 ---
net/nimble/src/util.c | 219 -----------------------------------
4 files changed, 234 insertions(+), 235 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4045e961/kernel/os/include/os/endian.h
----------------------------------------------------------------------
diff --git a/kernel/os/include/os/endian.h b/kernel/os/include/os/endian.h
index 8786f40..b8b39b5 100644
--- a/kernel/os/include/os/endian.h
+++ b/kernel/os/include/os/endian.h
@@ -202,6 +202,22 @@ extern "C" {
#endif
#endif
+
+void put_le16(void *buf, uint16_t x);
+void put_le32(void *buf, uint32_t x);
+void put_le64(void *buf, uint64_t x);
+uint16_t get_le16(const void *buf);
+uint32_t get_le32(const void *buf);
+uint64_t get_le64(const void *buf);
+void put_be16(void *buf, uint16_t x);
+void put_be32(void *buf, uint32_t x);
+void put_be64(void *buf, uint64_t x);
+uint16_t get_be16(const void *buf);
+uint32_t get_be32(const void *buf);
+uint64_t get_be64(const void *buf);
+void swap_in_place(void *buf, int len);
+void swap_buf(uint8_t *dst, const uint8_t *src, int len);
+
#ifdef __cplusplus
}
#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4045e961/kernel/os/src/endian.c
----------------------------------------------------------------------
diff --git a/kernel/os/src/endian.c b/kernel/os/src/endian.c
new file mode 100644
index 0000000..1311f43
--- /dev/null
+++ b/kernel/os/src/endian.c
@@ -0,0 +1,218 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 "os/endian.h"
+
+void
+put_le16(void *buf, uint16_t x)
+{
+ uint8_t *u8ptr;
+
+ u8ptr = buf;
+ u8ptr[0] = (uint8_t)x;
+ u8ptr[1] = (uint8_t)(x >> 8);
+}
+
+void
+put_le32(void *buf, uint32_t x)
+{
+ uint8_t *u8ptr;
+
+ u8ptr = buf;
+ u8ptr[0] = (uint8_t)x;
+ u8ptr[1] = (uint8_t)(x >> 8);
+ u8ptr[2] = (uint8_t)(x >> 16);
+ u8ptr[3] = (uint8_t)(x >> 24);
+}
+
+void
+put_le64(void *buf, uint64_t x)
+{
+ uint8_t *u8ptr;
+
+ u8ptr = buf;
+ u8ptr[0] = (uint8_t)x;
+ u8ptr[1] = (uint8_t)(x >> 8);
+ u8ptr[2] = (uint8_t)(x >> 16);
+ u8ptr[3] = (uint8_t)(x >> 24);
+ u8ptr[4] = (uint8_t)(x >> 32);
+ u8ptr[5] = (uint8_t)(x >> 40);
+ u8ptr[6] = (uint8_t)(x >> 48);
+ u8ptr[7] = (uint8_t)(x >> 56);
+}
+
+uint16_t
+get_le16(const void *buf)
+{
+ const uint8_t *u8ptr;
+ uint16_t x;
+
+ u8ptr = buf;
+ x = u8ptr[0];
+ x |= (uint16_t)u8ptr[1] << 8;
+
+ return x;
+}
+
+uint32_t
+get_le32(const void *buf)
+{
+ const uint8_t *u8ptr;
+ uint32_t x;
+
+ u8ptr = buf;
+ x = u8ptr[0];
+ x |= (uint32_t)u8ptr[1] << 8;
+ x |= (uint32_t)u8ptr[2] << 16;
+ x |= (uint32_t)u8ptr[3] << 24;
+
+ return x;
+}
+
+uint64_t
+get_le64(const void *buf)
+{
+ const uint8_t *u8ptr;
+ uint64_t x;
+
+ u8ptr = buf;
+ x = u8ptr[0];
+ x |= (uint64_t)u8ptr[1] << 8;
+ x |= (uint64_t)u8ptr[2] << 16;
+ x |= (uint64_t)u8ptr[3] << 24;
+ x |= (uint64_t)u8ptr[4] << 32;
+ x |= (uint64_t)u8ptr[5] << 40;
+ x |= (uint64_t)u8ptr[6] << 48;
+ x |= (uint64_t)u8ptr[7] << 56;
+
+ return x;
+}
+
+void
+put_be16(void *buf, uint16_t x)
+{
+ uint8_t *u8ptr;
+
+ u8ptr = buf;
+ u8ptr[0] = (uint8_t)(x >> 8);
+ u8ptr[1] = (uint8_t)x;
+}
+
+void
+put_be32(void *buf, uint32_t x)
+{
+ uint8_t *u8ptr;
+
+ u8ptr = buf;
+ u8ptr[0] = (uint8_t)(x >> 24);
+ u8ptr[1] = (uint8_t)(x >> 16);
+ u8ptr[2] = (uint8_t)(x >> 8);
+ u8ptr[3] = (uint8_t)x;
+}
+
+void
+put_be64(void *buf, uint64_t x)
+{
+ uint8_t *u8ptr;
+
+ u8ptr = buf;
+ u8ptr[0] = (uint8_t)(x >> 56);
+ u8ptr[1] = (uint8_t)(x >> 48);
+ u8ptr[2] = (uint8_t)(x >> 40);
+ u8ptr[3] = (uint8_t)(x >> 32);
+ u8ptr[4] = (uint8_t)(x >> 24);
+ u8ptr[5] = (uint8_t)(x >> 16);
+ u8ptr[6] = (uint8_t)(x >> 8);
+ u8ptr[7] = (uint8_t)x;
+}
+
+uint16_t
+get_be16(const void *buf)
+{
+ const uint8_t *u8ptr;
+ uint16_t x;
+
+ u8ptr = buf;
+ x = (uint16_t)u8ptr[0] << 8;
+ x |= u8ptr[1];
+
+ return x;
+}
+
+uint32_t
+get_be32(const void *buf)
+{
+ const uint8_t *u8ptr;
+ uint32_t x;
+
+ u8ptr = buf;
+ x = (uint32_t)u8ptr[0] << 24;
+ x |= (uint32_t)u8ptr[1] << 16;
+ x |= (uint32_t)u8ptr[2] << 8;
+ x |= u8ptr[3];
+
+ return x;
+}
+
+uint64_t
+get_be64(const void *buf)
+{
+ const uint8_t *u8ptr;
+ uint64_t x;
+
+ u8ptr = buf;
+ x = (uint64_t)u8ptr[0] << 56;
+ x |= (uint64_t)u8ptr[1] << 48;
+ x |= (uint64_t)u8ptr[2] << 40;
+ x |= (uint64_t)u8ptr[3] << 32;
+ x |= (uint64_t)u8ptr[4] << 24;
+ x |= (uint64_t)u8ptr[5] << 16;
+ x |= (uint64_t)u8ptr[6] << 8;
+ x |= u8ptr[7];
+
+ return x;
+}
+void
+swap_in_place(void *buf, int len)
+{
+ uint8_t *u8ptr;
+ uint8_t tmp;
+ int i;
+ int j;
+
+ u8ptr = buf;
+
+ for (i = 0, j = len - 1; i < j; i++, j--) {
+ tmp = u8ptr[i];
+
+ u8ptr[i] = u8ptr[j];
+ u8ptr[j] = tmp;
+ }
+}
+
+/* swap octets */
+void
+swap_buf(uint8_t *dst, const uint8_t *src, int len)
+{
+ int i;
+
+ for (i = 0; i < len; i++) {
+ dst[len - 1 - i] = src[i];
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4045e961/net/nimble/include/nimble/ble.h
----------------------------------------------------------------------
diff --git a/net/nimble/include/nimble/ble.h b/net/nimble/include/nimble/ble.h
index 4dfa336..c6c38ca 100644
--- a/net/nimble/include/nimble/ble.h
+++ b/net/nimble/include/nimble/ble.h
@@ -123,22 +123,6 @@ struct ble_mbuf_hdr
extern uint8_t g_dev_addr[BLE_DEV_ADDR_LEN];
extern uint8_t g_random_addr[BLE_DEV_ADDR_LEN];
-void put_le16(void *buf, uint16_t x);
-void put_le32(void *buf, uint32_t x);
-void put_le64(void *buf, uint64_t x);
-uint16_t get_le16(const void *buf);
-uint32_t get_le32(const void *buf);
-uint64_t get_le64(const void *buf);
-void put_be16(void *buf, uint16_t x);
-void put_be32(void *buf, uint32_t x);
-void put_be64(void *buf, uint64_t x);
-uint16_t get_be16(const void *buf);
-uint32_t get_be32(const void *buf);
-uint64_t get_be64(const void *buf);
-void swap_in_place(void *buf, int len);
-void swap_buf(uint8_t *dst, const uint8_t *src, int len);
-/* XXX */
-
/* BLE Error Codes (Core v4.2 Vol 2 part D) */
enum ble_error_codes
{
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4045e961/net/nimble/src/util.c
----------------------------------------------------------------------
diff --git a/net/nimble/src/util.c b/net/nimble/src/util.c
deleted file mode 100644
index 726a2a5..0000000
--- a/net/nimble/src/util.c
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 <stdint.h>
-#include "nimble/ble.h"
-
-void
-put_le16(void *buf, uint16_t x)
-{
- uint8_t *u8ptr;
-
- u8ptr = buf;
- u8ptr[0] = (uint8_t)x;
- u8ptr[1] = (uint8_t)(x >> 8);
-}
-
-void
-put_le32(void *buf, uint32_t x)
-{
- uint8_t *u8ptr;
-
- u8ptr = buf;
- u8ptr[0] = (uint8_t)x;
- u8ptr[1] = (uint8_t)(x >> 8);
- u8ptr[2] = (uint8_t)(x >> 16);
- u8ptr[3] = (uint8_t)(x >> 24);
-}
-
-void
-put_le64(void *buf, uint64_t x)
-{
- uint8_t *u8ptr;
-
- u8ptr = buf;
- u8ptr[0] = (uint8_t)x;
- u8ptr[1] = (uint8_t)(x >> 8);
- u8ptr[2] = (uint8_t)(x >> 16);
- u8ptr[3] = (uint8_t)(x >> 24);
- u8ptr[4] = (uint8_t)(x >> 32);
- u8ptr[5] = (uint8_t)(x >> 40);
- u8ptr[6] = (uint8_t)(x >> 48);
- u8ptr[7] = (uint8_t)(x >> 56);
-}
-
-uint16_t
-get_le16(const void *buf)
-{
- const uint8_t *u8ptr;
- uint16_t x;
-
- u8ptr = buf;
- x = u8ptr[0];
- x |= (uint16_t)u8ptr[1] << 8;
-
- return x;
-}
-
-uint32_t
-get_le32(const void *buf)
-{
- const uint8_t *u8ptr;
- uint32_t x;
-
- u8ptr = buf;
- x = u8ptr[0];
- x |= (uint32_t)u8ptr[1] << 8;
- x |= (uint32_t)u8ptr[2] << 16;
- x |= (uint32_t)u8ptr[3] << 24;
-
- return x;
-}
-
-uint64_t
-get_le64(const void *buf)
-{
- const uint8_t *u8ptr;
- uint64_t x;
-
- u8ptr = buf;
- x = u8ptr[0];
- x |= (uint64_t)u8ptr[1] << 8;
- x |= (uint64_t)u8ptr[2] << 16;
- x |= (uint64_t)u8ptr[3] << 24;
- x |= (uint64_t)u8ptr[4] << 32;
- x |= (uint64_t)u8ptr[5] << 40;
- x |= (uint64_t)u8ptr[6] << 48;
- x |= (uint64_t)u8ptr[7] << 56;
-
- return x;
-}
-
-void
-put_be16(void *buf, uint16_t x)
-{
- uint8_t *u8ptr;
-
- u8ptr = buf;
- u8ptr[0] = (uint8_t)(x >> 8);
- u8ptr[1] = (uint8_t)x;
-}
-
-void
-put_be32(void *buf, uint32_t x)
-{
- uint8_t *u8ptr;
-
- u8ptr = buf;
- u8ptr[0] = (uint8_t)(x >> 24);
- u8ptr[1] = (uint8_t)(x >> 16);
- u8ptr[2] = (uint8_t)(x >> 8);
- u8ptr[3] = (uint8_t)x;
-}
-
-void
-put_be64(void *buf, uint64_t x)
-{
- uint8_t *u8ptr;
-
- u8ptr = buf;
- u8ptr[0] = (uint8_t)(x >> 56);
- u8ptr[1] = (uint8_t)(x >> 48);
- u8ptr[2] = (uint8_t)(x >> 40);
- u8ptr[3] = (uint8_t)(x >> 32);
- u8ptr[4] = (uint8_t)(x >> 24);
- u8ptr[5] = (uint8_t)(x >> 16);
- u8ptr[6] = (uint8_t)(x >> 8);
- u8ptr[7] = (uint8_t)x;
-}
-
-uint16_t
-get_be16(const void *buf)
-{
- const uint8_t *u8ptr;
- uint16_t x;
-
- u8ptr = buf;
- x = (uint16_t)u8ptr[0] << 8;
- x |= u8ptr[1];
-
- return x;
-}
-
-uint32_t
-get_be32(const void *buf)
-{
- const uint8_t *u8ptr;
- uint32_t x;
-
- u8ptr = buf;
- x = (uint32_t)u8ptr[0] << 24;
- x |= (uint32_t)u8ptr[1] << 16;
- x |= (uint32_t)u8ptr[2] << 8;
- x |= u8ptr[3];
-
- return x;
-}
-
-uint64_t
-get_be64(const void *buf)
-{
- const uint8_t *u8ptr;
- uint64_t x;
-
- u8ptr = buf;
- x = (uint64_t)u8ptr[0] << 56;
- x |= (uint64_t)u8ptr[1] << 48;
- x |= (uint64_t)u8ptr[2] << 40;
- x |= (uint64_t)u8ptr[3] << 32;
- x |= (uint64_t)u8ptr[4] << 24;
- x |= (uint64_t)u8ptr[5] << 16;
- x |= (uint64_t)u8ptr[6] << 8;
- x |= u8ptr[7];
-
- return x;
-}
-void
-swap_in_place(void *buf, int len)
-{
- uint8_t *u8ptr;
- uint8_t tmp;
- int i;
- int j;
-
- u8ptr = buf;
-
- for (i = 0, j = len - 1; i < j; i++, j--) {
- tmp = u8ptr[i];
-
- u8ptr[i] = u8ptr[j];
- u8ptr[j] = tmp;
- }
-}
-
-/* swap octets */
-void
-swap_buf(uint8_t *dst, const uint8_t *src, int len)
-{
- int i;
-
- for (i = 0; i < len; i++) {
- dst[len - 1 - i] = src[i];
- }
-}
-
[3/4] incubator-mynewt-core git commit: nimble: Rename htol* and
htobe* functions
Posted by cc...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/host/src/ble_ibeacon.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_ibeacon.c b/net/nimble/host/src/ble_ibeacon.c
index a12731f..2deb854 100644
--- a/net/nimble/host/src/ble_ibeacon.c
+++ b/net/nimble/host/src/ble_ibeacon.c
@@ -56,8 +56,8 @@ ble_ibeacon_set_adv_data(void *uuid128, uint16_t major, uint16_t minor)
memcpy(buf + 4, uuid128, 16);
/** Version number. */
- htobe16(buf + 20, major);
- htobe16(buf + 22, minor);
+ put_be16(buf + 20, major);
+ put_be16(buf + 22, minor);
/** Last byte (tx power level) filled in after HCI exchange. */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/host/src/ble_l2cap.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_l2cap.c b/net/nimble/host/src/ble_l2cap.c
index 7f66b57..fc8ecb9 100644
--- a/net/nimble/host/src/ble_l2cap.c
+++ b/net/nimble/host/src/ble_l2cap.c
@@ -113,8 +113,8 @@ ble_l2cap_parse_hdr(struct os_mbuf *om, int off,
return BLE_HS_EMSGSIZE;
}
- l2cap_hdr->blh_len = le16toh(&l2cap_hdr->blh_len);
- l2cap_hdr->blh_cid = le16toh(&l2cap_hdr->blh_cid);
+ l2cap_hdr->blh_len = get_le16(&l2cap_hdr->blh_len);
+ l2cap_hdr->blh_cid = get_le16(&l2cap_hdr->blh_cid);
return 0;
}
@@ -124,8 +124,8 @@ ble_l2cap_prepend_hdr(struct os_mbuf *om, uint16_t cid, uint16_t len)
{
struct ble_l2cap_hdr hdr;
- htole16(&hdr.blh_len, len);
- htole16(&hdr.blh_cid, cid);
+ put_le16(&hdr.blh_len, len);
+ put_le16(&hdr.blh_cid, cid);
om = os_mbuf_prepend_pullup(om, sizeof hdr);
if (om == NULL) {
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/host/src/ble_sm_alg.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_sm_alg.c b/net/nimble/host/src/ble_sm_alg.c
index f8208b4..b850f24 100644
--- a/net/nimble/host/src/ble_sm_alg.c
+++ b/net/nimble/host/src/ble_sm_alg.c
@@ -405,7 +405,7 @@ ble_sm_alg_g2(uint8_t *u, uint8_t *v, uint8_t *x, uint8_t *y,
ble_sm_alg_log_buf("res", xs, 16);
- *passkey = be32toh(xs + 12) % 1000000;
+ *passkey = get_be32(xs + 12) % 1000000;
BLE_HS_LOG(DEBUG, " passkey=%u\n", *passkey);
return 0;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/host/src/ble_sm_cmd.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_sm_cmd.c b/net/nimble/host/src/ble_sm_cmd.c
index 67fa1b0..99fec05 100644
--- a/net/nimble/host/src/ble_sm_cmd.c
+++ b/net/nimble/host/src/ble_sm_cmd.c
@@ -360,8 +360,8 @@ ble_sm_master_id_parse(void *payload, int len, struct ble_sm_master_id *cmd)
u8ptr = payload;
- cmd->ediv = le16toh(u8ptr);
- cmd->rand_val = le64toh(u8ptr + 2);
+ cmd->ediv = get_le16(u8ptr);
+ cmd->rand_val = get_le64(u8ptr + 2);
}
void
@@ -374,8 +374,8 @@ ble_sm_master_id_write(void *payload, int len, struct ble_sm_master_id *cmd)
u8ptr = payload;
u8ptr[0] = BLE_SM_OP_MASTER_ID;
- htole16(u8ptr + 1, cmd->ediv);
- htole64(u8ptr + 3, cmd->rand_val);
+ put_le16(u8ptr + 1, cmd->ediv);
+ put_le64(u8ptr + 3, cmd->rand_val);
}
int
@@ -390,8 +390,8 @@ ble_sm_master_id_tx(uint16_t conn_handle, struct ble_sm_master_id *cmd)
}
txom->om_data[0] = BLE_SM_OP_MASTER_ID;
- htole16(txom->om_data + 1, cmd->ediv);
- htole64(txom->om_data + 3, cmd->rand_val);
+ put_le16(txom->om_data + 1, cmd->ediv);
+ put_le64(txom->om_data + 3, cmd->rand_val);
BLE_SM_LOG_CMD(1, "master id", conn_handle, ble_sm_master_id_log, cmd);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/host/src/ble_uuid.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_uuid.c b/net/nimble/host/src/ble_uuid.c
index 2399018..0a58a1a 100644
--- a/net/nimble/host/src/ble_uuid.c
+++ b/net/nimble/host/src/ble_uuid.c
@@ -55,11 +55,11 @@ ble_uuid_init_from_buf(ble_uuid_any_t *uuid, const void *buf, size_t len)
switch (len) {
case 2:
uuid->u.type = BLE_UUID_TYPE_16;
- uuid->u16.value = le16toh(buf);
+ uuid->u16.value = get_le16(buf);
return 0;
case 4:
uuid->u.type = BLE_UUID_TYPE_32;
- uuid->u32.value = le32toh(buf);
+ uuid->u32.value = get_le32(buf);
return 0;
case 16:
uuid->u.type = BLE_UUID_TYPE_128;
@@ -199,11 +199,11 @@ ble_uuid_flat(const ble_uuid_t *uuid, void *dst)
switch (uuid->type) {
case BLE_UUID_TYPE_16:
- htole16(dst, BLE_UUID16(uuid)->value);
+ put_le16(dst, BLE_UUID16(uuid)->value);
break;
case BLE_UUID_TYPE_32:
memcpy(dst, ble_uuid_base, 16);
- htole32(dst + 12, BLE_UUID32(uuid)->value);
+ put_le32(dst + 12, BLE_UUID32(uuid)->value);
break;
case BLE_UUID_TYPE_128:
memcpy(dst, BLE_UUID128(uuid)->value, 16);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/host/test/src/ble_att_clt_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/test/src/ble_att_clt_test.c b/net/nimble/host/test/src/ble_att_clt_test.c
index c34df53..3728557 100644
--- a/net/nimble/host/test/src/ble_att_clt_test.c
+++ b/net/nimble/host/test/src/ble_att_clt_test.c
@@ -126,7 +126,7 @@ TEST_CASE(ble_att_clt_test_rx_find_info)
ble_att_find_info_rsp_write(buf + off, sizeof buf - off, &rsp);
off += BLE_ATT_FIND_INFO_RSP_BASE_SZ;
- htole16(buf + off, 1);
+ put_le16(buf + off, 1);
off += 2;
memcpy(buf + off, uuid128_1, 16);
off += 16;
@@ -142,9 +142,9 @@ TEST_CASE(ble_att_clt_test_rx_find_info)
ble_att_find_info_rsp_write(buf + off, sizeof buf - off, &rsp);
off += BLE_ATT_FIND_INFO_RSP_BASE_SZ;
- htole16(buf + off, 2);
+ put_le16(buf + off, 2);
off += 2;
- htole16(buf + off, 0x000f);
+ put_le16(buf + off, 0x000f);
off += 2;
rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, BLE_L2CAP_CID_ATT,
@@ -158,14 +158,14 @@ TEST_CASE(ble_att_clt_test_rx_find_info)
ble_att_find_info_rsp_write(buf + off, sizeof buf - off, &rsp);
off += BLE_ATT_FIND_INFO_RSP_BASE_SZ;
- htole16(buf + off, 3);
+ put_le16(buf + off, 3);
off += 2;
- htole16(buf + off, 0x0010);
+ put_le16(buf + off, 0x0010);
off += 2;
- htole16(buf + off, 4);
+ put_le16(buf + off, 4);
off += 2;
- htole16(buf + off, 0x0011);
+ put_le16(buf + off, 0x0011);
off += 2;
rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, BLE_L2CAP_CID_ATT,
@@ -407,8 +407,8 @@ TEST_CASE(ble_att_clt_test_tx_read_mult)
TEST_ASSERT(om->om_len == BLE_ATT_READ_MULT_REQ_BASE_SZ + 4);
ble_att_read_mult_req_parse(om->om_data, om->om_len);
- TEST_ASSERT(le16toh(om->om_data + BLE_ATT_READ_MULT_REQ_BASE_SZ) == 1);
- TEST_ASSERT(le16toh(om->om_data + BLE_ATT_READ_MULT_REQ_BASE_SZ + 2) == 2);
+ TEST_ASSERT(get_le16(om->om_data + BLE_ATT_READ_MULT_REQ_BASE_SZ) == 1);
+ TEST_ASSERT(get_le16(om->om_data + BLE_ATT_READ_MULT_REQ_BASE_SZ + 2) == 2);
/*** Error: no handles. */
rc = ble_att_clt_tx_read_mult(conn_handle, NULL, 0);
@@ -425,7 +425,7 @@ TEST_CASE(ble_att_clt_test_rx_read_mult)
/*** Basic success. */
ble_att_read_mult_rsp_write(buf, sizeof buf);
- htole16(buf + BLE_ATT_READ_MULT_RSP_BASE_SZ + 0, 12);
+ put_le16(buf + BLE_ATT_READ_MULT_RSP_BASE_SZ + 0, 12);
rc = ble_hs_test_util_l2cap_rx_payload_flat(
conn_handle, BLE_L2CAP_CID_ATT, buf,
@@ -433,9 +433,9 @@ TEST_CASE(ble_att_clt_test_rx_read_mult)
TEST_ASSERT(rc == 0);
/*** Larger response. */
- htole16(buf + BLE_ATT_READ_MULT_RSP_BASE_SZ + 0, 12);
- htole16(buf + BLE_ATT_READ_MULT_RSP_BASE_SZ + 2, 43);
- htole16(buf + BLE_ATT_READ_MULT_RSP_BASE_SZ + 4, 91);
+ put_le16(buf + BLE_ATT_READ_MULT_RSP_BASE_SZ + 0, 12);
+ put_le16(buf + BLE_ATT_READ_MULT_RSP_BASE_SZ + 2, 43);
+ put_le16(buf + BLE_ATT_READ_MULT_RSP_BASE_SZ + 4, 91);
rc = ble_hs_test_util_l2cap_rx_payload_flat(
conn_handle, BLE_L2CAP_CID_ATT, buf,
BLE_ATT_READ_MULT_RSP_BASE_SZ + 6);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/host/test/src/ble_att_svr_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/test/src/ble_att_svr_test.c b/net/nimble/host/test/src/ble_att_svr_test.c
index 839b2b4..8ee9bc6 100644
--- a/net/nimble/host/test/src/ble_att_svr_test.c
+++ b/net/nimble/host/test/src/ble_att_svr_test.c
@@ -480,13 +480,13 @@ ble_att_svr_test_misc_verify_tx_find_type_value_rsp(
for (entry = entries; entry->first != 0; entry++) {
rc = os_mbuf_copydata(om, off, 2, &u16);
TEST_ASSERT(rc == 0);
- htole16(&u16, u16);
+ put_le16(&u16, u16);
TEST_ASSERT(u16 == entry->first);
off += 2;
rc = os_mbuf_copydata(om, off, 2, &u16);
TEST_ASSERT(rc == 0);
- htole16(&u16, u16);
+ put_le16(&u16, u16);
TEST_ASSERT(u16 == entry->last);
off += 2;
}
@@ -529,7 +529,7 @@ ble_att_svr_test_misc_verify_tx_read_type_rsp(
rc = os_mbuf_copydata(om, off, 2, &handle);
TEST_ASSERT(rc == 0);
- handle = le16toh(&handle);
+ handle = get_le16(&handle);
TEST_ASSERT(handle == entry->handle);
off += 2;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/host/test/src/ble_gap_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/test/src/ble_gap_test.c b/net/nimble/host/test/src/ble_gap_test.c
index d41ae74..7b3dd54 100644
--- a/net/nimble/host/test/src/ble_gap_test.c
+++ b/net/nimble/host/test/src/ble_gap_test.c
@@ -181,8 +181,8 @@ ble_gap_test_util_verify_tx_set_scan_params(uint8_t own_addr_type,
¶m_len);
TEST_ASSERT(param_len == BLE_HCI_SET_SCAN_PARAM_LEN);
TEST_ASSERT(param[0] == scan_type);
- TEST_ASSERT(le16toh(param + 1) == itvl);
- TEST_ASSERT(le16toh(param + 3) == scan_window);
+ TEST_ASSERT(get_le16(param + 1) == itvl);
+ TEST_ASSERT(get_le16(param + 3) == scan_window);
TEST_ASSERT(param[5] == own_addr_type);
TEST_ASSERT(param[6] == filter_policy);
}
@@ -223,7 +223,7 @@ ble_gap_test_util_verify_tx_disconnect(void)
BLE_HCI_OCF_DISCONNECT_CMD,
¶m_len);
TEST_ASSERT(param_len == BLE_HCI_DISCONNECT_CMD_LEN);
- TEST_ASSERT(le16toh(param + 0) == 2);
+ TEST_ASSERT(get_le16(param + 0) == 2);
TEST_ASSERT(param[2] == BLE_ERR_REM_USER_CONN_TERM);
}
@@ -286,13 +286,13 @@ ble_gap_test_util_verify_tx_update_conn(struct ble_gap_upd_params *params)
BLE_HCI_OCF_LE_CONN_UPDATE,
¶m_len);
TEST_ASSERT(param_len == BLE_HCI_CONN_UPDATE_LEN);
- TEST_ASSERT(le16toh(param + 0) == 2);
- TEST_ASSERT(le16toh(param + 2) == params->itvl_min);
- TEST_ASSERT(le16toh(param + 4) == params->itvl_max);
- TEST_ASSERT(le16toh(param + 6) == params->latency);
- TEST_ASSERT(le16toh(param + 8) == params->supervision_timeout);
- TEST_ASSERT(le16toh(param + 10) == params->min_ce_len);
- TEST_ASSERT(le16toh(param + 12) == params->max_ce_len);
+ TEST_ASSERT(get_le16(param + 0) == 2);
+ TEST_ASSERT(get_le16(param + 2) == params->itvl_min);
+ TEST_ASSERT(get_le16(param + 4) == params->itvl_max);
+ TEST_ASSERT(get_le16(param + 6) == params->latency);
+ TEST_ASSERT(get_le16(param + 8) == params->supervision_timeout);
+ TEST_ASSERT(get_le16(param + 10) == params->min_ce_len);
+ TEST_ASSERT(get_le16(param + 12) == params->max_ce_len);
}
static void
@@ -305,15 +305,15 @@ ble_gap_test_util_verify_tx_params_reply_pos(void)
BLE_HCI_OCF_LE_REM_CONN_PARAM_RR,
¶m_len);
TEST_ASSERT(param_len == BLE_HCI_CONN_PARAM_REPLY_LEN);
- TEST_ASSERT(le16toh(param + 0) == 2);
- TEST_ASSERT(le16toh(param + 2) == ble_gap_test_conn_self_params.itvl_min);
- TEST_ASSERT(le16toh(param + 4) == ble_gap_test_conn_self_params.itvl_max);
- TEST_ASSERT(le16toh(param + 6) == ble_gap_test_conn_self_params.latency);
- TEST_ASSERT(le16toh(param + 8) ==
+ TEST_ASSERT(get_le16(param + 0) == 2);
+ TEST_ASSERT(get_le16(param + 2) == ble_gap_test_conn_self_params.itvl_min);
+ TEST_ASSERT(get_le16(param + 4) == ble_gap_test_conn_self_params.itvl_max);
+ TEST_ASSERT(get_le16(param + 6) == ble_gap_test_conn_self_params.latency);
+ TEST_ASSERT(get_le16(param + 8) ==
ble_gap_test_conn_self_params.supervision_timeout);
- TEST_ASSERT(le16toh(param + 10) ==
+ TEST_ASSERT(get_le16(param + 10) ==
ble_gap_test_conn_self_params.min_ce_len);
- TEST_ASSERT(le16toh(param + 12) ==
+ TEST_ASSERT(get_le16(param + 12) ==
ble_gap_test_conn_self_params.max_ce_len);
}
@@ -327,7 +327,7 @@ ble_gap_test_util_verify_tx_params_reply_neg(uint8_t reason)
BLE_HCI_OCF_LE_REM_CONN_PARAM_NRR,
¶m_len);
TEST_ASSERT(param_len == BLE_HCI_CONN_PARAM_NEG_REPLY_LEN);
- TEST_ASSERT(le16toh(param + 0) == 2);
+ TEST_ASSERT(get_le16(param + 0) == 2);
TEST_ASSERT(param[2] == reason);
}
@@ -1533,8 +1533,8 @@ ble_gap_test_util_adv_verify_dflt_params(uint8_t own_addr_type,
TEST_ASSERT_FATAL(hci_buf != NULL);
TEST_ASSERT_FATAL(hci_param_len == BLE_HCI_SET_ADV_PARAM_LEN);
- hci_cmd.adv_itvl_min = le16toh(hci_buf + 0);
- hci_cmd.adv_itvl_max = le16toh(hci_buf + 2);
+ hci_cmd.adv_itvl_min = get_le16(hci_buf + 0);
+ hci_cmd.adv_itvl_max = get_le16(hci_buf + 2);
hci_cmd.adv_type = hci_buf[4];
hci_cmd.own_addr_type = hci_buf[5];
hci_cmd.peer_addr_type = hci_buf[6];
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/host/test/src/ble_gatt_disc_c_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/test/src/ble_gatt_disc_c_test.c b/net/nimble/host/test/src/ble_gatt_disc_c_test.c
index 7ecb48e..1752247 100644
--- a/net/nimble/host/test/src/ble_gatt_disc_c_test.c
+++ b/net/nimble/host/test/src/ble_gatt_disc_c_test.c
@@ -101,13 +101,13 @@ ble_gatt_disc_c_test_misc_rx_rsp_once(
}
}
- htole16(buf + off, chars[i].def_handle);
+ put_le16(buf + off, chars[i].def_handle);
off += 2;
buf[off] = chars[i].properties;
off++;
- htole16(buf + off, chars[i].val_handle);
+ put_le16(buf + off, chars[i].val_handle);
off += 2;
ble_uuid_flat(chars[i].uuid, buf + off);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/host/test/src/ble_gatt_disc_d_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/test/src/ble_gatt_disc_d_test.c b/net/nimble/host/test/src/ble_gatt_disc_d_test.c
index ce3fc4e..0b3dcc6 100644
--- a/net/nimble/host/test/src/ble_gatt_disc_d_test.c
+++ b/net/nimble/host/test/src/ble_gatt_disc_d_test.c
@@ -98,7 +98,7 @@ ble_gatt_disc_d_test_misc_rx_rsp_once(
break;
}
- htole16(buf + off, dscs[i].dsc_handle);
+ put_le16(buf + off, dscs[i].dsc_handle);
off += 2;
ble_uuid_flat(&dscs[i].dsc_uuid.u, buf + off);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/host/test/src/ble_gatt_disc_s_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/test/src/ble_gatt_disc_s_test.c b/net/nimble/host/test/src/ble_gatt_disc_s_test.c
index 8c8bf9a..0d75b6d 100644
--- a/net/nimble/host/test/src/ble_gatt_disc_s_test.c
+++ b/net/nimble/host/test/src/ble_gatt_disc_s_test.c
@@ -101,10 +101,10 @@ ble_gatt_disc_s_test_misc_rx_all_rsp_once(
}
}
- htole16(buf + off, services[i].start_handle);
+ put_le16(buf + off, services[i].start_handle);
off += 2;
- htole16(buf + off, services[i].end_handle);
+ put_le16(buf + off, services[i].end_handle);
off += 2;
ble_uuid_flat(services[i].uuid, buf + off);
@@ -169,10 +169,10 @@ ble_gatt_disc_s_test_misc_rx_uuid_rsp_once(
break;
}
- htole16(buf + off, services[i].start_handle);
+ put_le16(buf + off, services[i].start_handle);
off += 2;
- htole16(buf + off, services[i].end_handle);
+ put_le16(buf + off, services[i].end_handle);
off += 2;
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/host/test/src/ble_gatt_find_s_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/test/src/ble_gatt_find_s_test.c b/net/nimble/host/test/src/ble_gatt_find_s_test.c
index d8834f4..e6e0441 100644
--- a/net/nimble/host/test/src/ble_gatt_find_s_test.c
+++ b/net/nimble/host/test/src/ble_gatt_find_s_test.c
@@ -118,17 +118,17 @@ ble_gatt_find_s_test_misc_rx_read_type(
TEST_ASSERT_FATAL(off + rsp.batp_length <= sizeof buf);
- htole16(buf + off, entries[i].inc_handle);
+ put_le16(buf + off, entries[i].inc_handle);
off += 2;
- htole16(buf + off, entries[i].start_handle);
+ put_le16(buf + off, entries[i].start_handle);
off += 2;
- htole16(buf + off, entries[i].end_handle);
+ put_le16(buf + off, entries[i].end_handle);
off += 2;
if (entries[i].uuid->type == BLE_UUID_TYPE_16) {
- htole16(buf + off, ble_uuid_u16(entries[i].uuid));
+ put_le16(buf + off, ble_uuid_u16(entries[i].uuid));
off += 2;
}
}
@@ -182,7 +182,7 @@ ble_gatt_find_s_test_misc_verify_tx_read_type(uint16_t start_handle,
TEST_ASSERT(req.batq_start_handle == start_handle);
TEST_ASSERT(req.batq_end_handle == end_handle);
TEST_ASSERT(om->om_len == BLE_ATT_READ_TYPE_REQ_BASE_SZ + 2);
- uuid16 = le16toh(om->om_data + BLE_ATT_READ_TYPE_REQ_BASE_SZ);
+ uuid16 = get_le16(om->om_data + BLE_ATT_READ_TYPE_REQ_BASE_SZ);
TEST_ASSERT(uuid16 == BLE_ATT_UUID_INCLUDE);
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/host/test/src/ble_gatt_read_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/test/src/ble_gatt_read_test.c b/net/nimble/host/test/src/ble_gatt_read_test.c
index 54c8a56..835e256 100644
--- a/net/nimble/host/test/src/ble_gatt_read_test.c
+++ b/net/nimble/host/test/src/ble_gatt_read_test.c
@@ -225,7 +225,7 @@ ble_gatt_read_test_misc_uuid_rx_rsp_good(
}
prev_len = attrs[i].value_len;
- htole16(buf + off, attrs[i].handle);
+ put_le16(buf + off, attrs[i].handle);
off += 2;
memcpy(buf + off, attrs[i].value, attrs[i].value_len);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/host/test/src/ble_gatts_notify_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/test/src/ble_gatts_notify_test.c b/net/nimble/host/test/src/ble_gatts_notify_test.c
index 21f1afb..995520b 100644
--- a/net/nimble/host/test/src/ble_gatts_notify_test.c
+++ b/net/nimble/host/test/src/ble_gatts_notify_test.c
@@ -121,7 +121,7 @@ ble_gatts_notify_test_misc_read_notify(uint16_t conn_handle,
TEST_ASSERT_FATAL(om->om_len == 3);
TEST_ASSERT_FATAL(om->om_data[0] == BLE_ATT_OP_READ_RSP);
- flags = le16toh(om->om_data + 1);
+ flags = get_le16(om->om_data + 1);
return flags;
}
@@ -137,7 +137,7 @@ ble_gatts_notify_test_misc_try_enable_notify(uint16_t conn_handle,
req.bawq_handle = chr_def_handle + 2;
ble_att_write_req_write(buf, sizeof buf, &req);
- htole16(buf + BLE_ATT_WRITE_REQ_BASE_SZ, flags);
+ put_le16(buf + BLE_ATT_WRITE_REQ_BASE_SZ, flags);
rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, BLE_L2CAP_CID_ATT,
buf, sizeof buf);
if (fail) {
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/host/test/src/ble_hs_adv_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/test/src/ble_hs_adv_test.c b/net/nimble/host/test/src/ble_hs_adv_test.c
index b441a84..0a06374 100644
--- a/net/nimble/host/test/src/ble_hs_adv_test.c
+++ b/net/nimble/host/test/src/ble_hs_adv_test.c
@@ -33,7 +33,7 @@ ble_hs_adv_test_misc_verify_tx_adv_data_hdr(uint8_t *cmd, int data_len)
{
uint16_t opcode;
- opcode = le16toh(cmd + 0);
+ opcode = get_le16(cmd + 0);
TEST_ASSERT(BLE_HCI_OGF(opcode) == BLE_HCI_OGF_LE);
TEST_ASSERT(BLE_HCI_OCF(opcode) == BLE_HCI_OCF_LE_SET_ADV_DATA);
@@ -46,7 +46,7 @@ ble_hs_adv_test_misc_verify_tx_rsp_data_hdr(uint8_t *cmd, int data_len)
{
uint16_t opcode;
- opcode = le16toh(cmd + 0);
+ opcode = get_le16(cmd + 0);
TEST_ASSERT(BLE_HCI_OGF(opcode) == BLE_HCI_OGF_LE);
TEST_ASSERT(BLE_HCI_OCF(opcode) == BLE_HCI_OCF_LE_SET_SCAN_RSP_DATA);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/host/test/src/ble_hs_hci_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/test/src/ble_hs_hci_test.c b/net/nimble/host/test/src/ble_hs_hci_test.c
index 6d51346..67dadce 100644
--- a/net/nimble/host/test/src/ble_hs_hci_test.c
+++ b/net/nimble/host/test/src/ble_hs_hci_test.c
@@ -53,7 +53,7 @@ TEST_CASE(ble_hs_hci_test_rssi)
/*** Success. */
/* Connection handle. */
- htole16(params + 0, 1);
+ put_le16(params + 0, 1);
/* RSSI. */
params[2] = -8;
@@ -65,7 +65,7 @@ TEST_CASE(ble_hs_hci_test_rssi)
TEST_ASSERT(rssi == -8);
/*** Failure: incorrect connection handle. */
- htole16(params + 0, 99);
+ put_le16(params + 0, 99);
ble_hs_test_util_set_ack_params(opcode, 0, params, sizeof params);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/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 aa3b97d..919ec9b 100644
--- a/net/nimble/host/test/src/ble_hs_test_util.c
+++ b/net/nimble/host/test/src/ble_hs_test_util.c
@@ -268,7 +268,7 @@ ble_hs_test_util_build_cmd_complete(uint8_t *dst, int len,
dst[0] = BLE_HCI_EVCODE_COMMAND_COMPLETE;
dst[1] = 3 + param_len;
dst[2] = num_pkts;
- htole16(dst + 3, opcode);
+ put_le16(dst + 3, opcode);
}
void
@@ -282,7 +282,7 @@ ble_hs_test_util_build_cmd_status(uint8_t *dst, int len,
dst[1] = BLE_HCI_EVENT_CMD_STATUS_LEN;
dst[2] = status;
dst[3] = num_pkts;
- htole16(dst + 4, opcode);
+ put_le16(dst + 4, opcode);
}
#define BLE_HS_TEST_UTIL_PHONY_ACK_MAX 64
@@ -458,7 +458,7 @@ ble_hs_test_util_verify_tx_disconnect(uint16_t handle, uint8_t reason)
¶m_len);
TEST_ASSERT(param_len == BLE_HCI_DISCONNECT_CMD_LEN);
- TEST_ASSERT(le16toh(param + 0) == handle);
+ TEST_ASSERT(get_le16(param + 0) == handle);
TEST_ASSERT(param[2] == reason);
}
@@ -473,18 +473,18 @@ ble_hs_test_util_verify_tx_create_conn(const struct hci_create_conn *exp)
¶m_len);
TEST_ASSERT(param_len == BLE_HCI_CREATE_CONN_LEN);
- TEST_ASSERT(le16toh(param + 0) == exp->scan_itvl);
- TEST_ASSERT(le16toh(param + 2) == exp->scan_window);
+ TEST_ASSERT(get_le16(param + 0) == exp->scan_itvl);
+ TEST_ASSERT(get_le16(param + 2) == exp->scan_window);
TEST_ASSERT(param[4] == exp->filter_policy);
TEST_ASSERT(param[5] == exp->peer_addr_type);
TEST_ASSERT(memcmp(param + 6, exp->peer_addr, 6) == 0);
TEST_ASSERT(param[12] == exp->own_addr_type);
- TEST_ASSERT(le16toh(param + 13) == exp->conn_itvl_min);
- TEST_ASSERT(le16toh(param + 15) == exp->conn_itvl_max);
- TEST_ASSERT(le16toh(param + 17) == exp->conn_latency);
- TEST_ASSERT(le16toh(param + 19) == exp->supervision_timeout);
- TEST_ASSERT(le16toh(param + 21) == exp->min_ce_len);
- TEST_ASSERT(le16toh(param + 23) == exp->max_ce_len);
+ TEST_ASSERT(get_le16(param + 13) == exp->conn_itvl_min);
+ TEST_ASSERT(get_le16(param + 15) == exp->conn_itvl_max);
+ TEST_ASSERT(get_le16(param + 17) == exp->conn_latency);
+ TEST_ASSERT(get_le16(param + 19) == exp->supervision_timeout);
+ TEST_ASSERT(get_le16(param + 21) == exp->min_ce_len);
+ TEST_ASSERT(get_le16(param + 23) == exp->max_ce_len);
}
int
@@ -1101,7 +1101,7 @@ ble_hs_test_util_rx_att_read_mult_req(uint16_t conn_handle,
off = BLE_ATT_READ_MULT_REQ_BASE_SZ;
for (i = 0; i < num_handles; i++) {
- htole16(buf + off, handles[i]);
+ put_le16(buf + off, handles[i]);
off += 2;
}
@@ -1370,11 +1370,11 @@ ble_hs_test_util_rx_num_completed_pkts_event(
off = 3;
for (i = 0; i < num_entries; i++) {
- htole16(buf + off, entries[i].handle_id);
+ put_le16(buf + off, entries[i].handle_id);
off += 2;
}
for (i = 0; i < num_entries; i++) {
- htole16(buf + off, entries[i].num_pkts);
+ put_le16(buf + off, entries[i].num_pkts);
off += 2;
}
@@ -1391,7 +1391,7 @@ ble_hs_test_util_rx_disconn_complete_event(struct hci_disconn_complete *evt)
buf[0] = BLE_HCI_EVCODE_DISCONN_CMP;
buf[1] = BLE_HCI_EVENT_DISCONN_COMPLETE_LEN;
buf[2] = evt->status;
- htole16(buf + 3, evt->connection_handle);
+ put_le16(buf + 3, evt->connection_handle);
buf[5] = evt->reason;
ble_hs_test_util_rx_hci_evt(buf);
@@ -1407,7 +1407,7 @@ ble_hs_test_util_verify_tx_hci(uint8_t ogf, uint16_t ocf,
cmd = ble_hs_test_util_get_first_hci_tx();
TEST_ASSERT_FATAL(cmd != NULL);
- opcode = le16toh(cmd);
+ opcode = get_le16(cmd);
TEST_ASSERT(BLE_HCI_OGF(opcode) == ogf);
TEST_ASSERT(BLE_HCI_OCF(opcode) == ocf);
@@ -1569,7 +1569,7 @@ ble_hs_test_util_verify_tx_find_info_rsp(
TEST_ASSERT(rc == 0);
off += 2;
- handle = le16toh((void *)&handle);
+ handle = get_le16((void *)&handle);
TEST_ASSERT(handle == entry->handle);
if (entry->uuid->type == BLE_UUID_TYPE_16) {
@@ -1625,13 +1625,13 @@ ble_hs_test_util_verify_tx_read_group_type_rsp(
rc = os_mbuf_copydata(om, off, 2, &u16);
TEST_ASSERT(rc == 0);
- htole16(&u16, u16);
+ put_le16(&u16, u16);
TEST_ASSERT(u16 == entry->start_handle);
off += 2;
rc = os_mbuf_copydata(om, off, 2, &u16);
TEST_ASSERT(rc == 0);
- htole16(&u16, u16);
+ put_le16(&u16, u16);
TEST_ASSERT(u16 == entry->end_handle);
off += 2;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/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 2bfdff3..526436c 100644
--- a/net/nimble/host/test/src/ble_l2cap_test.c
+++ b/net/nimble/host/test/src/ble_l2cap_test.c
@@ -86,13 +86,13 @@ ble_l2cap_test_util_verify_tx_update_conn(
BLE_HCI_OCF_LE_CONN_UPDATE,
¶m_len);
TEST_ASSERT(param_len == BLE_HCI_CONN_UPDATE_LEN);
- TEST_ASSERT(le16toh(param + 0) == 2);
- TEST_ASSERT(le16toh(param + 2) == params->itvl_min);
- TEST_ASSERT(le16toh(param + 4) == params->itvl_max);
- TEST_ASSERT(le16toh(param + 6) == params->latency);
- TEST_ASSERT(le16toh(param + 8) == params->supervision_timeout);
- TEST_ASSERT(le16toh(param + 10) == params->min_ce_len);
- TEST_ASSERT(le16toh(param + 12) == params->max_ce_len);
+ TEST_ASSERT(get_le16(param + 0) == 2);
+ TEST_ASSERT(get_le16(param + 2) == params->itvl_min);
+ TEST_ASSERT(get_le16(param + 4) == params->itvl_max);
+ TEST_ASSERT(get_le16(param + 6) == params->latency);
+ TEST_ASSERT(get_le16(param + 8) == params->supervision_timeout);
+ TEST_ASSERT(get_le16(param + 10) == params->min_ce_len);
+ TEST_ASSERT(get_le16(param + 12) == params->max_ce_len);
}
static int
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/host/test/src/ble_sm_test_util.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/test/src/ble_sm_test_util.c b/net/nimble/host/test/src/ble_sm_test_util.c
index faa38ff..b3783a0 100644
--- a/net/nimble/host/test/src/ble_sm_test_util.c
+++ b/net/nimble/host/test/src/ble_sm_test_util.c
@@ -860,7 +860,7 @@ ble_sm_test_util_verify_tx_lt_key_req_reply(uint16_t conn_handle, uint8_t *stk)
BLE_HCI_OCF_LE_LT_KEY_REQ_REPLY,
¶m_len);
TEST_ASSERT(param_len == BLE_HCI_LT_KEY_REQ_REPLY_LEN);
- TEST_ASSERT(le16toh(param + 0) == conn_handle);
+ TEST_ASSERT(get_le16(param + 0) == conn_handle);
TEST_ASSERT(memcmp(param + 2, stk, 16) == 0);
}
@@ -874,7 +874,7 @@ ble_sm_test_util_verify_tx_lt_key_req_neg_reply(uint16_t conn_handle)
BLE_HCI_OCF_LE_LT_KEY_REQ_NEG_REPLY,
¶m_len);
TEST_ASSERT(param_len == BLE_HCI_LT_KEY_REQ_NEG_REPLY_LEN);
- TEST_ASSERT(le16toh(param + 0) == conn_handle);
+ TEST_ASSERT(get_le16(param + 0) == conn_handle);
}
static void
@@ -883,7 +883,7 @@ ble_sm_test_util_set_lt_key_req_neg_reply_ack(uint8_t status,
{
static uint8_t params[BLE_HCI_LT_KEY_REQ_NEG_REPLY_ACK_PARAM_LEN];
- htole16(params, conn_handle);
+ put_le16(params, conn_handle);
ble_hs_test_util_set_ack_params(
ble_hs_hci_util_opcode_join(BLE_HCI_OGF_LE,
BLE_HCI_OCF_LE_LT_KEY_REQ_NEG_REPLY),
@@ -895,7 +895,7 @@ ble_sm_test_util_set_lt_key_req_reply_ack(uint8_t status, uint16_t conn_handle)
{
static uint8_t params[BLE_HCI_LT_KEY_REQ_REPLY_ACK_PARAM_LEN];
- htole16(params, conn_handle);
+ put_le16(params, conn_handle);
ble_hs_test_util_set_ack_params(
ble_hs_hci_util_opcode_join(BLE_HCI_OGF_LE,
BLE_HCI_OCF_LE_LT_KEY_REQ_REPLY),
@@ -928,9 +928,9 @@ ble_sm_test_util_verify_tx_start_enc(uint16_t conn_handle,
BLE_HCI_OCF_LE_START_ENCRYPT,
¶m_len);
TEST_ASSERT(param_len == BLE_HCI_LE_START_ENCRYPT_LEN);
- TEST_ASSERT(le16toh(param + 0) == conn_handle);
- TEST_ASSERT(le64toh(param + 2) == random_number);
- TEST_ASSERT(le16toh(param + 10) == ediv);
+ TEST_ASSERT(get_le16(param + 0) == conn_handle);
+ TEST_ASSERT(get_le64(param + 2) == random_number);
+ TEST_ASSERT(get_le16(param + 10) == ediv);
TEST_ASSERT(memcmp(param + 12, ltk, 16) == 0);
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/include/nimble/ble.h
----------------------------------------------------------------------
diff --git a/net/nimble/include/nimble/ble.h b/net/nimble/include/nimble/ble.h
index 29f335c..4dfa336 100644
--- a/net/nimble/include/nimble/ble.h
+++ b/net/nimble/include/nimble/ble.h
@@ -123,30 +123,18 @@ struct ble_mbuf_hdr
extern uint8_t g_dev_addr[BLE_DEV_ADDR_LEN];
extern uint8_t g_random_addr[BLE_DEV_ADDR_LEN];
-#undef htole16
-#undef htole32
-#undef htole64
-#undef le16toh
-#undef le32toh
-#undef le64toh
-#undef htobe16
-#undef htobe32
-#undef htobe64
-#undef be16toh
-#undef be32toh
-#undef be64toh
-void htole16(void *buf, uint16_t x);
-void htole32(void *buf, uint32_t x);
-void htole64(void *buf, uint64_t x);
-uint16_t le16toh(const void *buf);
-uint32_t le32toh(const void *buf);
-uint64_t le64toh(const void *buf);
-void htobe16(void *buf, uint16_t x);
-void htobe32(void *buf, uint32_t x);
-void htobe64(void *buf, uint64_t x);
-uint16_t be16toh(const void *buf);
-uint32_t be32toh(const void *buf);
-uint64_t be64toh(const void *buf);
+void put_le16(void *buf, uint16_t x);
+void put_le32(void *buf, uint32_t x);
+void put_le64(void *buf, uint64_t x);
+uint16_t get_le16(const void *buf);
+uint32_t get_le32(const void *buf);
+uint64_t get_le64(const void *buf);
+void put_be16(void *buf, uint16_t x);
+void put_be32(void *buf, uint32_t x);
+void put_be64(void *buf, uint64_t x);
+uint16_t get_be16(const void *buf);
+uint32_t get_be32(const void *buf);
+uint64_t get_be64(const void *buf);
void swap_in_place(void *buf, int len);
void swap_buf(uint8_t *dst, const uint8_t *src, int len);
/* XXX */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/src/util.c
----------------------------------------------------------------------
diff --git a/net/nimble/src/util.c b/net/nimble/src/util.c
index 95cae67..726a2a5 100644
--- a/net/nimble/src/util.c
+++ b/net/nimble/src/util.c
@@ -20,7 +20,7 @@
#include "nimble/ble.h"
void
-htole16(void *buf, uint16_t x)
+put_le16(void *buf, uint16_t x)
{
uint8_t *u8ptr;
@@ -30,7 +30,7 @@ htole16(void *buf, uint16_t x)
}
void
-htole32(void *buf, uint32_t x)
+put_le32(void *buf, uint32_t x)
{
uint8_t *u8ptr;
@@ -42,7 +42,7 @@ htole32(void *buf, uint32_t x)
}
void
-htole64(void *buf, uint64_t x)
+put_le64(void *buf, uint64_t x)
{
uint8_t *u8ptr;
@@ -58,7 +58,7 @@ htole64(void *buf, uint64_t x)
}
uint16_t
-le16toh(const void *buf)
+get_le16(const void *buf)
{
const uint8_t *u8ptr;
uint16_t x;
@@ -71,7 +71,7 @@ le16toh(const void *buf)
}
uint32_t
-le32toh(const void *buf)
+get_le32(const void *buf)
{
const uint8_t *u8ptr;
uint32_t x;
@@ -86,7 +86,7 @@ le32toh(const void *buf)
}
uint64_t
-le64toh(const void *buf)
+get_le64(const void *buf)
{
const uint8_t *u8ptr;
uint64_t x;
@@ -105,7 +105,7 @@ le64toh(const void *buf)
}
void
-htobe16(void *buf, uint16_t x)
+put_be16(void *buf, uint16_t x)
{
uint8_t *u8ptr;
@@ -115,7 +115,7 @@ htobe16(void *buf, uint16_t x)
}
void
-htobe32(void *buf, uint32_t x)
+put_be32(void *buf, uint32_t x)
{
uint8_t *u8ptr;
@@ -127,7 +127,7 @@ htobe32(void *buf, uint32_t x)
}
void
-htobe64(void *buf, uint64_t x)
+put_be64(void *buf, uint64_t x)
{
uint8_t *u8ptr;
@@ -143,7 +143,7 @@ htobe64(void *buf, uint64_t x)
}
uint16_t
-be16toh(const void *buf)
+get_be16(const void *buf)
{
const uint8_t *u8ptr;
uint16_t x;
@@ -156,7 +156,7 @@ be16toh(const void *buf)
}
uint32_t
-be32toh(const void *buf)
+get_be32(const void *buf)
{
const uint8_t *u8ptr;
uint32_t x;
@@ -171,7 +171,7 @@ be32toh(const void *buf)
}
uint64_t
-be64toh(const void *buf)
+get_be64(const void *buf)
{
const uint8_t *u8ptr;
uint64_t x;
[4/4] incubator-mynewt-core git commit: nimble: Rename htol* and
htobe* functions
Posted by cc...@apache.org.
nimble: Rename htol* and htobe* functions
Use put_le*, get_le*, put_be* and get_be* names for functions
used to write and read non-hostbyte order data. Original names
were conflicting with functions typically provided in <endian.h>.
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/31f894b6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/31f894b6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/31f894b6
Branch: refs/heads/develop
Commit: 31f894b64da05d87cbadc29b7978df52e8128c0e
Parents: ab1cfd4
Author: Szymon Janc <sz...@codecoup.pl>
Authored: Fri Jan 20 13:54:44 2017 +0100
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Jan 24 16:03:30 2017 -0800
----------------------------------------------------------------------
apps/bletest/src/bletest_hci.c | 22 ++--
apps/bletest/src/main.c | 6 +-
apps/bletiny/src/main.c | 6 +-
hw/drivers/nimble/nrf51/src/ble_hw.c | 8 +-
hw/drivers/nimble/nrf52/src/ble_hw.c | 8 +-
net/nimble/controller/src/ble_ll.c | 4 +-
net/nimble/controller/src/ble_ll_adv.c | 6 +-
net/nimble/controller/src/ble_ll_conn.c | 16 +--
net/nimble/controller/src/ble_ll_conn_hci.c | 118 +++++++++----------
net/nimble/controller/src/ble_ll_ctrl.c | 116 +++++++++---------
net/nimble/controller/src/ble_ll_hci.c | 34 +++---
net/nimble/controller/src/ble_ll_hci_ev.c | 44 +++----
net/nimble/controller/src/ble_ll_resolv.c | 2 +-
net/nimble/controller/src/ble_ll_scan.c | 4 +-
.../host/services/gatt/src/ble_svc_gatt.c | 4 +-
net/nimble/host/src/ble_att_clt.c | 10 +-
net/nimble/host/src/ble_att_svr.c | 14 +--
net/nimble/host/src/ble_eddystone.c | 2 +-
net/nimble/host/src/ble_gattc.c | 12 +-
net/nimble/host/src/ble_gatts.c | 12 +-
net/nimble/host/src/ble_hs_adv.c | 12 +-
net/nimble/host/src/ble_hs_dbg.c | 72 +++++------
net/nimble/host/src/ble_hs_hci.c | 10 +-
net/nimble/host/src/ble_hs_hci_cmd.c | 100 ++++++++--------
net/nimble/host/src/ble_hs_hci_evt.c | 42 +++----
net/nimble/host/src/ble_hs_hci_util.c | 8 +-
net/nimble/host/src/ble_hs_startup.c | 2 +-
net/nimble/host/src/ble_ibeacon.c | 4 +-
net/nimble/host/src/ble_l2cap.c | 8 +-
net/nimble/host/src/ble_sm_alg.c | 2 +-
net/nimble/host/src/ble_sm_cmd.c | 12 +-
net/nimble/host/src/ble_uuid.c | 8 +-
net/nimble/host/test/src/ble_att_clt_test.c | 26 ++--
net/nimble/host/test/src/ble_att_svr_test.c | 6 +-
net/nimble/host/test/src/ble_gap_test.c | 40 +++----
net/nimble/host/test/src/ble_gatt_disc_c_test.c | 4 +-
net/nimble/host/test/src/ble_gatt_disc_d_test.c | 2 +-
net/nimble/host/test/src/ble_gatt_disc_s_test.c | 8 +-
net/nimble/host/test/src/ble_gatt_find_s_test.c | 10 +-
net/nimble/host/test/src/ble_gatt_read_test.c | 2 +-
.../host/test/src/ble_gatts_notify_test.c | 4 +-
net/nimble/host/test/src/ble_hs_adv_test.c | 4 +-
net/nimble/host/test/src/ble_hs_hci_test.c | 4 +-
net/nimble/host/test/src/ble_hs_test_util.c | 38 +++---
net/nimble/host/test/src/ble_l2cap_test.c | 14 +--
net/nimble/host/test/src/ble_sm_test_util.c | 14 +--
net/nimble/include/nimble/ble.h | 36 ++----
net/nimble/src/util.c | 24 ++--
48 files changed, 476 insertions(+), 488 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/apps/bletest/src/bletest_hci.c
----------------------------------------------------------------------
diff --git a/apps/bletest/src/bletest_hci.c b/apps/bletest/src/bletest_hci.c
index 528e888..86d2293 100755
--- a/apps/bletest/src/bletest_hci.c
+++ b/apps/bletest/src/bletest_hci.c
@@ -82,7 +82,7 @@ bletest_send_ltk_req_neg_reply(uint16_t handle)
sizeof(uint16_t), dst);
dst += BLE_HCI_CMD_HDR_LEN;
- htole16(dst, handle);
+ put_le16(dst, handle);
rc = ble_hs_hci_cmd_tx(buf, &ack_conn_handle, 2, &rsplen);
if (rc == 0) {
if (rsplen != 2) {
@@ -198,9 +198,9 @@ bletest_hci_le_set_datalen(uint16_t handle, uint16_t txoctets, uint16_t txtime)
BLE_HCI_SET_DATALEN_LEN, dst);
dst += BLE_HCI_CMD_HDR_LEN;
- htole16(dst, handle);
- htole16(dst + 2, txoctets);
- htole16(dst + 4, txtime);
+ put_le16(dst, handle);
+ put_le16(dst + 2, txoctets);
+ put_le16(dst + 4, txtime);
rc = ble_hs_hci_cmd_tx(buf, rspbuf, 2, &rsplen);
if (rc != 0) {
return rc;
@@ -224,8 +224,8 @@ bletest_hci_le_write_sugg_datalen(uint16_t txoctets, uint16_t txtime)
BLE_HCI_WR_SUGG_DATALEN_LEN, dst);
dst += BLE_HCI_CMD_HDR_LEN;
- htole16(dst, txoctets);
- htole16(dst + 2, txtime);
+ put_le16(dst, txoctets);
+ put_le16(dst + 2, txtime);
return ble_hs_hci_cmd_tx(buf, NULL, 0, NULL);
}
@@ -426,7 +426,7 @@ bletest_hci_le_read_rem_used_feat(uint16_t handle)
BLE_HCI_CONN_RD_REM_FEAT_LEN, dst);
dst += BLE_HCI_CMD_HDR_LEN;
- htole16(dst, handle);
+ put_le16(dst, handle);
return ble_hs_hci_cmd_tx(buf, NULL, 0, NULL);
}
@@ -477,8 +477,8 @@ bletest_hci_le_set_multi_adv_params(struct hci_multi_adv_params *adv,
}
dst[0] = BLE_HCI_MULTI_ADV_PARAMS;
- htole16(dst + 1, adv->adv_itvl_min);
- htole16(dst + 3, adv->adv_itvl_max);
+ put_le16(dst + 1, adv->adv_itvl_min);
+ put_le16(dst + 3, adv->adv_itvl_max);
dst[5] = adv->adv_type;
dst[6] = adv->own_addr_type;
memcpy(dst + 7, adv->own_addr, BLE_DEV_ADDR_LEN);
@@ -555,7 +555,7 @@ bletest_hci_rd_rem_version(uint16_t handle)
sizeof(uint16_t), dst);
dst += BLE_HCI_CMD_HDR_LEN;
- htole16(dst, handle);
+ put_le16(dst, handle);
return ble_hs_hci_cmd_tx(buf, NULL, 0, NULL);
}
@@ -588,7 +588,7 @@ bletest_hci_le_rd_chanmap(uint16_t handle)
BLE_HCI_RD_CHANMAP_LEN, dst);
dst += BLE_HCI_CMD_HDR_LEN;
- htole16(dst, handle);
+ put_le16(dst, handle);
rc = ble_hs_hci_cmd_tx(buf, rspbuf, BLE_HCI_RD_CHANMAP_RSP_LEN, &rsplen);
if (rc != 0) {
return rc;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/apps/bletest/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bletest/src/main.c b/apps/bletest/src/main.c
index 3010a3f..0f8546c 100755
--- a/apps/bletest/src/main.c
+++ b/apps/bletest/src/main.c
@@ -876,11 +876,11 @@ bletest_send_packet(uint16_t handle)
#endif
/* Put the HCI header in the mbuf */
- htole16(om->om_data, handle);
- htole16(om->om_data + 2, pktlen + 4);
+ put_le16(om->om_data, handle);
+ put_le16(om->om_data + 2, pktlen + 4);
/* Place L2CAP header in packet */
- htole16(om->om_data + 4, pktlen);
+ put_le16(om->om_data + 4, pktlen);
om->om_data[6] = 0;
om->om_data[7] = 0;
om->om_len = 8;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/apps/bletiny/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bletiny/src/main.c b/apps/bletiny/src/main.c
index 35c0dd2..6ce53ad 100755
--- a/apps/bletiny/src/main.c
+++ b/apps/bletiny/src/main.c
@@ -1061,8 +1061,8 @@ bletiny_tx_timer_cb(struct os_event *ev)
if (om) {
/* Put the HCI header in the mbuf */
om->om_len = len + 4;
- htole16(om->om_data, bletiny_tx_data.tx_handle);
- htole16(om->om_data + 2, len);
+ put_le16(om->om_data, bletiny_tx_data.tx_handle);
+ put_le16(om->om_data + 2, len);
dptr = om->om_data + 4;
/*
@@ -1070,7 +1070,7 @@ bletiny_tx_timer_cb(struct os_event *ev)
* The rest of the data gets filled with incrementing pattern starting
* from 0.
*/
- htole16(dptr, len - 4);
+ put_le16(dptr, len - 4);
dptr[2] = 0xff;
dptr[3] = 0xff;
dptr += 4;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/hw/drivers/nimble/nrf51/src/ble_hw.c
----------------------------------------------------------------------
diff --git a/hw/drivers/nimble/nrf51/src/ble_hw.c b/hw/drivers/nimble/nrf51/src/ble_hw.c
index cd5bf92..bbd2a50 100644
--- a/hw/drivers/nimble/nrf51/src/ble_hw.c
+++ b/hw/drivers/nimble/nrf51/src/ble_hw.c
@@ -86,8 +86,8 @@ ble_hw_whitelist_add(uint8_t *addr, uint8_t addr_type)
mask = 0x01;
for (i = 0; i < BLE_HW_WHITE_LIST_SIZE; ++i) {
if ((mask & g_ble_hw_whitelist_mask) == 0) {
- NRF_RADIO->DAB[i] = le32toh(addr);
- NRF_RADIO->DAP[i] = le16toh(addr + 4);
+ NRF_RADIO->DAB[i] = get_le32(addr);
+ NRF_RADIO->DAP[i] = get_le16(addr + 4);
if (addr_type == BLE_ADDR_TYPE_RANDOM) {
NRF_RADIO->DACNF |= (mask << 8);
}
@@ -118,8 +118,8 @@ ble_hw_whitelist_rmv(uint8_t *addr, uint8_t addr_type)
uint32_t mask;
/* Find first ununsed device address match element */
- dab = le32toh(addr);
- dap = le16toh(addr + 4);
+ dab = get_le32(addr);
+ dap = get_le16(addr + 4);
txadd = NRF_RADIO->DACNF >> 8;
mask = 0x01;
for (i = 0; i < BLE_HW_WHITE_LIST_SIZE; ++i) {
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/hw/drivers/nimble/nrf52/src/ble_hw.c
----------------------------------------------------------------------
diff --git a/hw/drivers/nimble/nrf52/src/ble_hw.c b/hw/drivers/nimble/nrf52/src/ble_hw.c
index 1924cb4..0962285 100644
--- a/hw/drivers/nimble/nrf52/src/ble_hw.c
+++ b/hw/drivers/nimble/nrf52/src/ble_hw.c
@@ -88,8 +88,8 @@ ble_hw_whitelist_add(uint8_t *addr, uint8_t addr_type)
mask = 0x01;
for (i = 0; i < BLE_HW_WHITE_LIST_SIZE; ++i) {
if ((mask & g_ble_hw_whitelist_mask) == 0) {
- NRF_RADIO->DAB[i] = le32toh(addr);
- NRF_RADIO->DAP[i] = le16toh(addr + 4);
+ NRF_RADIO->DAB[i] = get_le32(addr);
+ NRF_RADIO->DAP[i] = get_le16(addr + 4);
if (addr_type == BLE_ADDR_TYPE_RANDOM) {
NRF_RADIO->DACNF |= (mask << 8);
}
@@ -120,8 +120,8 @@ ble_hw_whitelist_rmv(uint8_t *addr, uint8_t addr_type)
uint32_t mask;
/* Find first ununsed device address match element */
- dab = le32toh(addr);
- dap = le16toh(addr + 4);
+ dab = get_le32(addr);
+ dap = get_le16(addr + 4);
txadd = NRF_RADIO->DACNF >> 8;
mask = 0x01;
for (i = 0; i < BLE_HW_WHITE_LIST_SIZE; ++i) {
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/controller/src/ble_ll.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll.c b/net/nimble/controller/src/ble_ll.c
index 40f4f17..6071d3c 100644
--- a/net/nimble/controller/src/ble_ll.c
+++ b/net/nimble/controller/src/ble_ll.c
@@ -575,8 +575,8 @@ ble_ll_tx_pkt_in(void)
STAILQ_REMOVE_HEAD(&g_ble_ll_data.ll_tx_pkt_q, omp_next);
/* Strip HCI ACL header to get handle and length */
- handle = le16toh(om->om_data);
- length = le16toh(om->om_data + 2);
+ handle = get_le16(om->om_data);
+ length = get_le16(om->om_data + 2);
os_mbuf_adj(om, sizeof(struct hci_data_hdr));
/* Do some basic error checking */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/controller/src/ble_ll_adv.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_adv.c b/net/nimble/controller/src/ble_ll_adv.c
index aee474f..bf62810 100644
--- a/net/nimble/controller/src/ble_ll_adv.c
+++ b/net/nimble/controller/src/ble_ll_adv.c
@@ -600,8 +600,8 @@ ble_ll_adv_set_adv_params(uint8_t *cmd, uint8_t instance, int is_multi)
}
/* Make sure intervals are OK (along with advertising type */
- adv_itvl_min = le16toh(cmd);
- adv_itvl_max = le16toh(cmd + 2);
+ adv_itvl_min = get_le16(cmd);
+ adv_itvl_max = get_le16(cmd + 2);
adv_type = cmd[4];
/*
@@ -1654,7 +1654,7 @@ ble_ll_adv_send_conn_comp_ev(struct ble_ll_conn_sm *connsm,
evbuf[2] = BLE_HCI_LE_SUBEV_ADV_STATE_CHG;
evbuf[3] = advsm->adv_instance;
evbuf[4] = 0x00; /* status code */
- htole16(evbuf + 5, connsm->conn_handle);
+ put_le16(evbuf + 5, connsm->conn_handle);
ble_ll_hci_event_send(evbuf);
}
#else
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/controller/src/ble_ll_conn.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_conn.c b/net/nimble/controller/src/ble_ll_conn.c
index db8f863..313e4fe 100644
--- a/net/nimble/controller/src/ble_ll_conn.c
+++ b/net/nimble/controller/src/ble_ll_conn.c
@@ -2042,7 +2042,7 @@ ble_ll_conn_req_pdu_update(struct os_mbuf *m, uint8_t *adva, uint8_t addr_type,
memcpy(dptr, addr, BLE_DEV_ADDR_LEN);
}
memcpy(dptr + BLE_DEV_ADDR_LEN, adva, BLE_DEV_ADDR_LEN);
- htole16(dptr + 20, txoffset);
+ put_le16(dptr + 20, txoffset);
/* Set BLE transmit header */
ble_hdr->txinfo.hdr_byte = hdr;
@@ -2601,8 +2601,8 @@ ble_ll_conn_rx_data_pdu(struct os_mbuf *rxpdu, struct ble_mbuf_hdr *hdr)
rxbuf = rxpdu->om_data;
acl_hdr = (acl_hdr << 12) | connsm->conn_handle;
- htole16(rxbuf, acl_hdr);
- htole16(rxbuf + 2, acl_len);
+ put_le16(rxbuf, acl_hdr);
+ put_le16(rxbuf + 2, acl_len);
ble_hci_trans_ll_acl_tx(rxpdu);
}
@@ -3076,16 +3076,16 @@ ble_ll_conn_slave_start(uint8_t *rxbuf, uint32_t conn_req_end, uint8_t pat,
dptr = rxbuf + BLE_LL_CONN_REQ_ADVA_OFF + BLE_DEV_ADDR_LEN;
/* Set connection state machine information */
- connsm->access_addr = le32toh(dptr);
+ connsm->access_addr = get_le32(dptr);
crcinit = dptr[6];
crcinit = (crcinit << 8) | dptr[5];
crcinit = (crcinit << 8) | dptr[4];
connsm->crcinit = crcinit;
connsm->tx_win_size = dptr[7];
- connsm->tx_win_off = le16toh(dptr + 8);
- connsm->conn_itvl = le16toh(dptr + 10);
- connsm->slave_latency = le16toh(dptr + 12);
- connsm->supervision_tmo = le16toh(dptr + 14);
+ connsm->tx_win_off = get_le16(dptr + 8);
+ connsm->conn_itvl = get_le16(dptr + 10);
+ connsm->slave_latency = get_le16(dptr + 12);
+ connsm->supervision_tmo = get_le16(dptr + 14);
memcpy(&connsm->chanmap, dptr + 16, BLE_LL_CONN_CHMAP_LEN);
connsm->hop_inc = dptr[21] & 0x1F;
connsm->master_sca = dptr[21] >> 5;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/controller/src/ble_ll_conn_hci.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_conn_hci.c b/net/nimble/controller/src/ble_ll_conn_hci.c
index 99b8665..3ed9147 100644
--- a/net/nimble/controller/src/ble_ll_conn_hci.c
+++ b/net/nimble/controller/src/ble_ll_conn_hci.c
@@ -136,15 +136,15 @@ ble_ll_conn_req_pdu_make(struct ble_ll_conn_sm *connsm)
dptr += (2 * BLE_DEV_ADDR_LEN);
/* Access address */
- htole32(dptr, connsm->access_addr);
+ put_le32(dptr, connsm->access_addr);
dptr[4] = (uint8_t)connsm->crcinit;
dptr[5] = (uint8_t)(connsm->crcinit >> 8);
dptr[6] = (uint8_t)(connsm->crcinit >> 16);
dptr[7] = connsm->tx_win_size;
- htole16(dptr + 8, connsm->tx_win_off);
- htole16(dptr + 10, connsm->conn_itvl);
- htole16(dptr + 12, connsm->slave_latency);
- htole16(dptr + 14, connsm->supervision_tmo);
+ put_le16(dptr + 8, connsm->tx_win_off);
+ put_le16(dptr + 10, connsm->conn_itvl);
+ put_le16(dptr + 12, connsm->slave_latency);
+ put_le16(dptr + 14, connsm->supervision_tmo);
memcpy(dptr + 16, &connsm->chanmap, BLE_LL_CONN_CHMAP_LEN);
dptr[21] = connsm->hop_inc | (connsm->master_sca << 5);
}
@@ -180,7 +180,7 @@ ble_ll_conn_comp_event_send(struct ble_ll_conn_sm *connsm, uint8_t status,
evbuf[3] = status;
if (connsm) {
- htole16(evbuf + 4, connsm->conn_handle);
+ put_le16(evbuf + 4, connsm->conn_handle);
evbuf[6] = connsm->conn_role - 1;
peer_addr_type = connsm->peer_addr_type;
@@ -219,9 +219,9 @@ ble_ll_conn_comp_event_send(struct ble_ll_conn_sm *connsm, uint8_t status,
evbuf[7] = peer_addr_type;
memcpy(evbuf + 8, connsm->peer_addr, BLE_DEV_ADDR_LEN);
- htole16(evdata, connsm->conn_itvl);
- htole16(evdata + 2, connsm->slave_latency);
- htole16(evdata + 4, connsm->supervision_tmo);
+ put_le16(evdata, connsm->conn_itvl);
+ put_le16(evdata + 2, connsm->slave_latency);
+ put_le16(evdata + 4, connsm->supervision_tmo);
evdata[6] = connsm->master_sca;
}
ble_ll_hci_event_send(evbuf);
@@ -273,8 +273,8 @@ ble_ll_conn_num_comp_pkts_event_send(struct ble_ll_conn_sm *connsm)
evbuf[0] = BLE_HCI_EVCODE_NUM_COMP_PKTS;
evbuf[1] = (2 * sizeof(uint16_t)) + 1;
evbuf[2] = 1;
- htole16(evbuf + 3, connsm->conn_handle);
- htole16(evbuf + 5, connsm->completed_pkts);
+ put_le16(evbuf + 3, connsm->conn_handle);
+ put_le16(evbuf + 5, connsm->completed_pkts);
ble_ll_hci_event_send(evbuf);
connsm->completed_pkts = 0;
}
@@ -307,8 +307,8 @@ ble_ll_conn_num_comp_pkts_event_send(struct ble_ll_conn_sm *connsm)
}
/* Add handle and complete packets */
- htole16(handle_ptr, connsm->conn_handle);
- htole16(comp_pkt_ptr, connsm->completed_pkts);
+ put_le16(handle_ptr, connsm->conn_handle);
+ put_le16(comp_pkt_ptr, connsm->completed_pkts);
connsm->completed_pkts = 0;
handle_ptr += sizeof(uint16_t);
comp_pkt_ptr += sizeof(uint16_t);
@@ -365,7 +365,7 @@ ble_ll_auth_pyld_tmo_event_send(struct ble_ll_conn_sm *connsm)
if (evbuf) {
evbuf[0] = BLE_HCI_EVCODE_AUTH_PYLD_TMO;
evbuf[1] = sizeof(uint16_t);
- htole16(evbuf + 2, connsm->conn_handle);
+ put_le16(evbuf + 2, connsm->conn_handle);
ble_ll_hci_event_send(evbuf);
}
}
@@ -391,7 +391,7 @@ ble_ll_disconn_comp_event_send(struct ble_ll_conn_sm *connsm, uint8_t reason)
evbuf[0] = BLE_HCI_EVCODE_DISCONN_CMP;
evbuf[1] = BLE_HCI_EVENT_DISCONN_COMPLETE_LEN;
evbuf[2] = BLE_ERR_SUCCESS;
- htole16(evbuf + 3, connsm->conn_handle);
+ put_le16(evbuf + 3, connsm->conn_handle);
evbuf[5] = reason;
ble_ll_hci_event_send(evbuf);
}
@@ -427,8 +427,8 @@ ble_ll_conn_create(uint8_t *cmdbuf)
/* Retrieve command data */
hcc = &ccdata;
- hcc->scan_itvl = le16toh(cmdbuf);
- hcc->scan_window = le16toh(cmdbuf + 2);
+ hcc->scan_itvl = get_le16(cmdbuf);
+ hcc->scan_window = get_le16(cmdbuf + 2);
/* Check interval and window */
if ((hcc->scan_itvl < BLE_HCI_SCAN_ITVL_MIN) ||
@@ -462,10 +462,10 @@ ble_ll_conn_create(uint8_t *cmdbuf)
}
/* Check connection interval, latency and supervision timeoout */
- hcc->conn_itvl_min = le16toh(cmdbuf + 13);
- hcc->conn_itvl_max = le16toh(cmdbuf + 15);
- hcc->conn_latency = le16toh(cmdbuf + 17);
- hcc->supervision_timeout = le16toh(cmdbuf + 19);
+ hcc->conn_itvl_min = get_le16(cmdbuf + 13);
+ hcc->conn_itvl_max = get_le16(cmdbuf + 15);
+ hcc->conn_latency = get_le16(cmdbuf + 17);
+ hcc->supervision_timeout = get_le16(cmdbuf + 19);
rc = ble_ll_conn_hci_chk_conn_params(hcc->conn_itvl_min,
hcc->conn_itvl_max,
hcc->conn_latency,
@@ -475,8 +475,8 @@ ble_ll_conn_create(uint8_t *cmdbuf)
}
/* Min/max connection event lengths */
- hcc->min_ce_len = le16toh(cmdbuf + 21);
- hcc->max_ce_len = le16toh(cmdbuf + 23);
+ hcc->min_ce_len = get_le16(cmdbuf + 21);
+ hcc->max_ce_len = get_le16(cmdbuf + 23);
if (hcc->min_ce_len > hcc->max_ce_len) {
return BLE_ERR_INV_HCI_CMD_PARMS;
}
@@ -521,12 +521,12 @@ ble_ll_conn_process_conn_params(uint8_t *cmdbuf, struct ble_ll_conn_sm *connsm)
/* Retrieve command data */
hcu = &connsm->conn_param_req;
hcu->handle = connsm->conn_handle;
- hcu->conn_itvl_min = le16toh(cmdbuf + 2);
- hcu->conn_itvl_max = le16toh(cmdbuf + 4);
- hcu->conn_latency = le16toh(cmdbuf + 6);
- hcu->supervision_timeout = le16toh(cmdbuf + 8);
- hcu->min_ce_len = le16toh(cmdbuf + 10);
- hcu->max_ce_len = le16toh(cmdbuf + 12);
+ hcu->conn_itvl_min = get_le16(cmdbuf + 2);
+ hcu->conn_itvl_max = get_le16(cmdbuf + 4);
+ hcu->conn_latency = get_le16(cmdbuf + 6);
+ hcu->supervision_timeout = get_le16(cmdbuf + 8);
+ hcu->min_ce_len = get_le16(cmdbuf + 10);
+ hcu->max_ce_len = get_le16(cmdbuf + 12);
/* Check that parameter values are in range */
rc = ble_ll_conn_hci_chk_conn_params(hcu->conn_itvl_min,
@@ -556,7 +556,7 @@ ble_ll_conn_hci_read_rem_features(uint8_t *cmdbuf)
struct ble_ll_conn_sm *connsm;
/* If no connection handle exit with error */
- handle = le16toh(cmdbuf);
+ handle = get_le16(cmdbuf);
connsm = ble_ll_conn_find_active_conn(handle);
if (!connsm) {
return BLE_ERR_UNK_CONN_ID;
@@ -601,7 +601,7 @@ ble_ll_conn_hci_update(uint8_t *cmdbuf)
*/
/* If no connection handle exit with error */
- handle = le16toh(cmdbuf);
+ handle = get_le16(cmdbuf);
connsm = ble_ll_conn_find_active_conn(handle);
if (!connsm) {
return BLE_ERR_UNK_CONN_ID;
@@ -654,12 +654,12 @@ ble_ll_conn_hci_update(uint8_t *cmdbuf)
/* Retrieve command data */
hcu = &connsm->conn_param_req;
hcu->handle = handle;
- hcu->conn_itvl_min = le16toh(cmdbuf + 2);
- hcu->conn_itvl_max = le16toh(cmdbuf + 4);
- hcu->conn_latency = le16toh(cmdbuf + 6);
- hcu->supervision_timeout = le16toh(cmdbuf + 8);
- hcu->min_ce_len = le16toh(cmdbuf + 10);
- hcu->max_ce_len = le16toh(cmdbuf + 12);
+ hcu->conn_itvl_min = get_le16(cmdbuf + 2);
+ hcu->conn_itvl_max = get_le16(cmdbuf + 4);
+ hcu->conn_latency = get_le16(cmdbuf + 6);
+ hcu->supervision_timeout = get_le16(cmdbuf + 8);
+ hcu->min_ce_len = get_le16(cmdbuf + 10);
+ hcu->max_ce_len = get_le16(cmdbuf + 12);
if (hcu->min_ce_len > hcu->max_ce_len) {
return BLE_ERR_INV_HCI_CMD_PARMS;
}
@@ -695,7 +695,7 @@ ble_ll_conn_hci_param_reply(uint8_t *cmdbuf, int positive_reply)
}
/* If no connection handle exit with error */
- handle = le16toh(cmdbuf);
+ handle = get_le16(cmdbuf);
/* If we dont have a handle we cant do anything */
connsm = ble_ll_conn_find_active_conn(handle);
@@ -796,7 +796,7 @@ ble_ll_conn_hci_disconnect_cmd(uint8_t *cmdbuf)
struct ble_ll_conn_sm *connsm;
/* Check for valid parameters */
- handle = le16toh(cmdbuf);
+ handle = get_le16(cmdbuf);
reason = cmdbuf[2];
rc = BLE_ERR_INV_HCI_CMD_PARMS;
@@ -855,7 +855,7 @@ ble_ll_conn_hci_rd_rem_ver_cmd(uint8_t *cmdbuf)
struct ble_ll_conn_sm *connsm;
/* Check for valid parameters */
- handle = le16toh(cmdbuf);
+ handle = get_le16(cmdbuf);
connsm = ble_ll_conn_find_active_conn(handle);
if (!connsm) {
return BLE_ERR_UNK_CONN_ID;
@@ -899,7 +899,7 @@ ble_ll_conn_hci_rd_rssi(uint8_t *cmdbuf, uint8_t *rspbuf, uint8_t *rsplen)
uint16_t handle;
struct ble_ll_conn_sm *connsm;
- handle = le16toh(cmdbuf);
+ handle = get_le16(cmdbuf);
connsm = ble_ll_conn_find_active_conn(handle);
if (!connsm) {
rssi = 127;
@@ -909,7 +909,7 @@ ble_ll_conn_hci_rd_rssi(uint8_t *cmdbuf, uint8_t *rspbuf, uint8_t *rsplen)
rc = BLE_ERR_SUCCESS;
}
- htole16(rspbuf, handle);
+ put_le16(rspbuf, handle);
rspbuf[2] = (uint8_t)rssi;
*rsplen = 3;
@@ -933,7 +933,7 @@ ble_ll_conn_hci_rd_chan_map(uint8_t *cmdbuf, uint8_t *rspbuf, uint8_t *rsplen)
uint16_t handle;
struct ble_ll_conn_sm *connsm;
- handle = le16toh(cmdbuf);
+ handle = get_le16(cmdbuf);
connsm = ble_ll_conn_find_active_conn(handle);
if (!connsm) {
rc = BLE_ERR_UNK_CONN_ID;
@@ -946,7 +946,7 @@ ble_ll_conn_hci_rd_chan_map(uint8_t *cmdbuf, uint8_t *rspbuf, uint8_t *rsplen)
rc = BLE_ERR_SUCCESS;
}
- htole16(rspbuf, handle);
+ put_le16(rspbuf, handle);
*rsplen = sizeof(uint16_t) + BLE_LL_CONN_CHMAP_LEN;
return rc;
}
@@ -991,13 +991,13 @@ ble_ll_conn_hci_set_data_len(uint8_t *cmdbuf, uint8_t *rspbuf, uint8_t *rsplen)
struct ble_ll_conn_sm *connsm;
/* Find connection */
- handle = le16toh(cmdbuf);
+ handle = get_le16(cmdbuf);
connsm = ble_ll_conn_find_active_conn(handle);
if (!connsm) {
rc = BLE_ERR_UNK_CONN_ID;
} else {
- txoctets = le16toh(cmdbuf + 2);
- txtime = le16toh(cmdbuf + 4);
+ txoctets = get_le16(cmdbuf + 2);
+ txtime = get_le16(cmdbuf + 4);
/* Make sure it is valid */
if (!ble_ll_chk_txrx_octets(txoctets) ||
@@ -1015,7 +1015,7 @@ ble_ll_conn_hci_set_data_len(uint8_t *cmdbuf, uint8_t *rspbuf, uint8_t *rsplen)
*/
}
- htole16(rspbuf, handle);
+ put_le16(rspbuf, handle);
*rsplen = sizeof(uint16_t);
return rc;
}
@@ -1036,7 +1036,7 @@ ble_ll_conn_hci_le_start_encrypt(uint8_t *cmdbuf)
uint16_t handle;
struct ble_ll_conn_sm *connsm;
- handle = le16toh(cmdbuf);
+ handle = get_le16(cmdbuf);
connsm = ble_ll_conn_find_active_conn(handle);
if (!connsm) {
rc = BLE_ERR_UNK_CONN_ID;
@@ -1051,8 +1051,8 @@ ble_ll_conn_hci_le_start_encrypt(uint8_t *cmdbuf)
rc = BLE_ERR_CMD_DISALLOWED;
} else {
/* Start the control procedure */
- connsm->enc_data.host_rand_num = le64toh(cmdbuf + 2);
- connsm->enc_data.enc_div = le16toh(cmdbuf + 10);
+ connsm->enc_data.host_rand_num = get_le64(cmdbuf + 2);
+ connsm->enc_data.enc_div = get_le16(cmdbuf + 10);
swap_buf(connsm->enc_data.enc_block.key, cmdbuf + 12, 16);
ble_ll_ctrl_proc_start(connsm, BLE_LL_CTRL_PROC_ENCRYPT);
rc = BLE_ERR_SUCCESS;
@@ -1080,7 +1080,7 @@ ble_ll_conn_hci_le_ltk_reply(uint8_t *cmdbuf, uint8_t *rspbuf, uint8_t ocf)
struct ble_ll_conn_sm *connsm;
/* Find connection handle */
- handle = le16toh(cmdbuf);
+ handle = get_le16(cmdbuf);
connsm = ble_ll_conn_find_active_conn(handle);
if (!connsm) {
rc = BLE_ERR_UNK_CONN_ID;
@@ -1109,7 +1109,7 @@ ble_ll_conn_hci_le_ltk_reply(uint8_t *cmdbuf, uint8_t *rspbuf, uint8_t ocf)
rc = BLE_ERR_SUCCESS;
ltk_key_cmd_complete:
- htole16(rspbuf, handle);
+ put_le16(rspbuf, handle);
return rc;
}
#endif
@@ -1130,16 +1130,16 @@ ble_ll_conn_hci_rd_auth_pyld_tmo(uint8_t *cmdbuf, uint8_t *rsp, uint8_t *rsplen)
uint16_t handle;
struct ble_ll_conn_sm *connsm;
- handle = le16toh(cmdbuf);
+ handle = get_le16(cmdbuf);
connsm = ble_ll_conn_find_active_conn(handle);
if (!connsm) {
rc = BLE_ERR_UNK_CONN_ID;
} else {
- htole16(rsp + 2, connsm->auth_pyld_tmo);
+ put_le16(rsp + 2, connsm->auth_pyld_tmo);
rc = BLE_ERR_SUCCESS;
}
- htole16(rsp, handle);
+ put_le16(rsp, handle);
*rsplen = BLE_HCI_RD_AUTH_PYLD_TMO_LEN;
return rc;
}
@@ -1163,7 +1163,7 @@ ble_ll_conn_hci_wr_auth_pyld_tmo(uint8_t *cmdbuf, uint8_t *rsp, uint8_t *rsplen)
rc = BLE_ERR_SUCCESS;
- handle = le16toh(cmdbuf);
+ handle = get_le16(cmdbuf);
connsm = ble_ll_conn_find_active_conn(handle);
if (!connsm) {
rc = BLE_ERR_UNK_CONN_ID;
@@ -1174,7 +1174,7 @@ ble_ll_conn_hci_wr_auth_pyld_tmo(uint8_t *cmdbuf, uint8_t *rsp, uint8_t *rsplen)
* The timeout is in units of 10 msecs. We need to make sure that the
* timeout is greater than or equal to connItvl * (1 + slaveLatency)
*/
- tmo = le16toh(cmdbuf + 2);
+ tmo = get_le16(cmdbuf + 2);
min_tmo = (uint32_t)connsm->conn_itvl * BLE_LL_CONN_ITVL_USECS;
min_tmo *= (connsm->slave_latency + 1);
min_tmo /= 10000;
@@ -1189,7 +1189,7 @@ ble_ll_conn_hci_wr_auth_pyld_tmo(uint8_t *cmdbuf, uint8_t *rsp, uint8_t *rsplen)
}
wr_auth_exit:
- htole16(rsp, handle);
+ put_le16(rsp, handle);
*rsplen = BLE_HCI_WR_AUTH_PYLD_TMO_LEN;
return rc;
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/controller/src/ble_ll_ctrl.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_ctrl.c b/net/nimble/controller/src/ble_ll_ctrl.c
index 4231e40..03f2836 100644
--- a/net/nimble/controller/src/ble_ll_ctrl.c
+++ b/net/nimble/controller/src/ble_ll_ctrl.c
@@ -118,10 +118,10 @@ ble_ll_ctrl_len_proc(struct ble_ll_conn_sm *connsm, uint8_t *dptr)
struct ble_ll_len_req ctrl_req;
/* Extract parameters and check if valid */
- ctrl_req.max_rx_bytes = le16toh(dptr);
- ctrl_req.max_rx_time = le16toh(dptr + 2);
- ctrl_req.max_tx_bytes = le16toh(dptr + 4);
- ctrl_req.max_tx_time = le16toh(dptr + 6);
+ ctrl_req.max_rx_bytes = get_le16(dptr);
+ ctrl_req.max_rx_time = get_le16(dptr + 2);
+ ctrl_req.max_tx_bytes = get_le16(dptr + 4);
+ ctrl_req.max_tx_time = get_le16(dptr + 6);
if (!ble_ll_ctrl_chk_supp_bytes(ctrl_req.max_rx_bytes) ||
!ble_ll_ctrl_chk_supp_bytes(ctrl_req.max_tx_bytes) ||
@@ -175,18 +175,18 @@ ble_ll_ctrl_conn_param_pdu_proc(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
/* Extract parameters and check if valid */
req = &connsm->conn_cp;
- req->interval_min = le16toh(dptr);
- req->interval_max = le16toh(dptr + 2);
- req->latency = le16toh(dptr + 4);
- req->timeout = le16toh(dptr + 6);
+ req->interval_min = get_le16(dptr);
+ req->interval_max = get_le16(dptr + 2);
+ req->latency = get_le16(dptr + 4);
+ req->timeout = get_le16(dptr + 6);
req->pref_periodicity = dptr[8];
- req->ref_conn_event_cnt = le16toh(dptr + 9);
- req->offset0 = le16toh(dptr + 11);
- req->offset1 = le16toh(dptr + 13);
- req->offset2 = le16toh(dptr + 15);
- req->offset3 = le16toh(dptr + 17);
- req->offset4 = le16toh(dptr + 19);
- req->offset5 = le16toh(dptr + 21);
+ req->ref_conn_event_cnt = get_le16(dptr + 9);
+ req->offset0 = get_le16(dptr + 11);
+ req->offset1 = get_le16(dptr + 13);
+ req->offset2 = get_le16(dptr + 15);
+ req->offset3 = get_le16(dptr + 17);
+ req->offset4 = get_le16(dptr + 19);
+ req->offset5 = get_le16(dptr + 21);
/* Check if parameters are valid */
ble_err = BLE_ERR_SUCCESS;
@@ -341,10 +341,10 @@ ble_ll_ctrl_proc_unk_rsp(struct ble_ll_conn_sm *connsm, uint8_t *dptr)
static void
ble_ll_ctrl_datalen_upd_make(struct ble_ll_conn_sm *connsm, uint8_t *dptr)
{
- htole16(dptr + 1, connsm->max_rx_octets);
- htole16(dptr + 3, connsm->max_rx_time);
- htole16(dptr + 5, connsm->max_tx_octets);
- htole16(dptr + 7, connsm->max_tx_time);
+ put_le16(dptr + 1, connsm->max_rx_octets);
+ put_le16(dptr + 3, connsm->max_rx_time);
+ put_le16(dptr + 5, connsm->max_tx_octets);
+ put_le16(dptr + 7, connsm->max_tx_time);
}
#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
@@ -505,14 +505,14 @@ ble_ll_ctrl_start_enc_send(struct ble_ll_conn_sm *connsm, uint8_t opcode)
static void
ble_ll_ctrl_enc_req_make(struct ble_ll_conn_sm *connsm, uint8_t *dptr)
{
- htole64(dptr, connsm->enc_data.host_rand_num);
- htole16(dptr + 8, connsm->enc_data.enc_div);
+ put_le64(dptr, connsm->enc_data.host_rand_num);
+ put_le16(dptr + 8, connsm->enc_data.enc_div);
#ifdef BLE_LL_ENCRYPT_USE_TEST_DATA
/* IV stored LSB to MSB, IVm is LSB, IVs is MSB */
- htole64(dptr + 10, g_bletest_SKDm);
+ put_le64(dptr + 10, g_bletest_SKDm);
swap_buf(connsm->enc_data.enc_block.plain_text + 8, dptr + 10, 8);
- htole32(dptr + 18, g_bletest_IVm);
+ put_le32(dptr + 18, g_bletest_IVm);
memcpy(connsm->enc_data.iv, dptr + 18, 4);
return;
#endif
@@ -591,16 +591,16 @@ ble_ll_ctrl_rx_enc_req(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
connsm->enc_data.tx_encrypted = 0;
/* Extract information from request */
- connsm->enc_data.host_rand_num = le64toh(dptr);
- connsm->enc_data.enc_div = le16toh(dptr + 8);
+ connsm->enc_data.host_rand_num = get_le64(dptr);
+ connsm->enc_data.enc_div = get_le16(dptr + 8);
#if BLE_LL_ENCRYPT_USE_TEST_DATA
swap_buf(connsm->enc_data.enc_block.plain_text + 8, dptr + 10, 8);
memcpy(connsm->enc_data.iv, dptr + 18, 4);
- htole64(rspdata, g_bletest_SKDs);
+ put_le64(rspdata, g_bletest_SKDs);
swap_buf(connsm->enc_data.enc_block.plain_text, rspdata, 8);
- htole32(rspdata + 8, g_bletest_IVs);
+ put_le32(rspdata + 8, g_bletest_IVs);
memcpy(connsm->enc_data.iv + 4, rspdata + 8, 4);
return BLE_LL_CTRL_ENC_RSP;
#endif
@@ -735,18 +735,18 @@ ble_ll_ctrl_conn_param_pdu_make(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
/* If we were passed in a request, we use the parameters from the request */
if (req) {
- htole16(dptr, req->interval_min);
- htole16(dptr + 2, req->interval_max);
- htole16(dptr + 4, req->latency);
- htole16(dptr + 6, req->timeout);
+ put_le16(dptr, req->interval_min);
+ put_le16(dptr + 2, req->interval_max);
+ put_le16(dptr + 4, req->latency);
+ put_le16(dptr + 6, req->timeout);
} else {
hcu = &connsm->conn_param_req;
/* The host should have provided the parameters! */
assert(hcu->handle != 0);
- htole16(dptr, hcu->conn_itvl_min);
- htole16(dptr + 2, hcu->conn_itvl_max);
- htole16(dptr + 4, hcu->conn_latency);
- htole16(dptr + 6, hcu->supervision_timeout);
+ put_le16(dptr, hcu->conn_itvl_min);
+ put_le16(dptr + 2, hcu->conn_itvl_max);
+ put_le16(dptr + 4, hcu->conn_latency);
+ put_le16(dptr + 6, hcu->supervision_timeout);
}
/* XXX: NOTE: if interval min and interval max are != to each
@@ -758,16 +758,16 @@ ble_ll_ctrl_conn_param_pdu_make(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
dptr[8] = 0;
/* XXX: deal with reference event count. what to put here? */
- htole16(dptr + 9, connsm->event_cntr);
+ put_le16(dptr + 9, connsm->event_cntr);
/* XXX: For now, dont use offsets */
offset = 0xFFFF;
- htole16(dptr + 11, offset);
- htole16(dptr + 13, offset);
- htole16(dptr + 15, offset);
- htole16(dptr + 17, offset);
- htole16(dptr + 19, offset);
- htole16(dptr + 21, offset);
+ put_le16(dptr + 11, offset);
+ put_le16(dptr + 13, offset);
+ put_le16(dptr + 15, offset);
+ put_le16(dptr + 17, offset);
+ put_le16(dptr + 19, offset);
+ put_le16(dptr + 21, offset);
}
static void
@@ -778,8 +778,8 @@ ble_ll_ctrl_version_ind_make(struct ble_ll_conn_sm *connsm, uint8_t *pyld)
/* Fill out response */
pyld[0] = BLE_HCI_VER_BCS_4_2;
- htole16(pyld + 1, MYNEWT_VAL(BLE_LL_MFRG_ID));
- htole16(pyld + 3, BLE_LL_SUB_VERS_NR);
+ put_le16(pyld + 1, MYNEWT_VAL(BLE_LL_MFRG_ID));
+ put_le16(pyld + 3, BLE_LL_SUB_VERS_NR);
}
/**
@@ -797,7 +797,7 @@ ble_ll_ctrl_chanmap_req_make(struct ble_ll_conn_sm *connsm, uint8_t *pyld)
/* Place instant into request */
connsm->chanmap_instant = connsm->event_cntr + connsm->slave_latency + 6 + 1;
- htole16(pyld + BLE_LL_CONN_CHMAP_LEN, connsm->chanmap_instant);
+ put_le16(pyld + BLE_LL_CONN_CHMAP_LEN, connsm->chanmap_instant);
/* Set scheduled flag */
connsm->csmflags.cfbit.chanmap_update_scheduled = 1;
@@ -878,11 +878,11 @@ ble_ll_ctrl_conn_upd_make(struct ble_ll_conn_sm *connsm, uint8_t *pyld,
/* XXX: make sure this works for the connection parameter request proc. */
pyld[0] = req->winsize;
- htole16(pyld + 1, req->winoffset);
- htole16(pyld + 3, req->interval);
- htole16(pyld + 5, req->latency);
- htole16(pyld + 7, req->timeout);
- htole16(pyld + 9, instant);
+ put_le16(pyld + 1, req->winoffset);
+ put_le16(pyld + 3, req->interval);
+ put_le16(pyld + 5, req->latency);
+ put_le16(pyld + 7, req->timeout);
+ put_le16(pyld + 9, instant);
/* Set flag in state machine to denote we have scheduled an update */
connsm->csmflags.cfbit.conn_update_sched = 1;
@@ -984,11 +984,11 @@ ble_ll_ctrl_rx_conn_update(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
/* Retrieve parameters */
reqdata = &connsm->conn_update_req;
reqdata->winsize = dptr[0];
- reqdata->winoffset = le16toh(dptr + 1);
- reqdata->interval = le16toh(dptr + 3);
- reqdata->latency = le16toh(dptr + 5);
- reqdata->timeout = le16toh(dptr + 7);
- reqdata->instant = le16toh(dptr + 9);
+ reqdata->winoffset = get_le16(dptr + 1);
+ reqdata->interval = get_le16(dptr + 3);
+ reqdata->latency = get_le16(dptr + 5);
+ reqdata->timeout = get_le16(dptr + 7);
+ reqdata->instant = get_le16(dptr + 9);
/* XXX: validate them at some point. If they dont check out, we
return the unknown response */
@@ -1176,8 +1176,8 @@ ble_ll_ctrl_rx_version_ind(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
/* Process the packet */
connsm->vers_nr = dptr[0];
- connsm->comp_id = le16toh(dptr + 1);
- connsm->sub_vers_nr = le16toh(dptr + 3);
+ connsm->comp_id = get_le16(dptr + 1);
+ connsm->sub_vers_nr = get_le16(dptr + 3);
connsm->csmflags.cfbit.rxd_version_ind = 1;
rsp_opcode = BLE_ERR_MAX;
@@ -1210,7 +1210,7 @@ ble_ll_ctrl_rx_chanmap_req(struct ble_ll_conn_sm *connsm, uint8_t *dptr)
/* If instant is in the past, we have to end the connection */
if (connsm->conn_role == BLE_LL_CONN_ROLE_SLAVE) {
- instant = le16toh(dptr + BLE_LL_CONN_CHMAP_LEN);
+ instant = get_le16(dptr + BLE_LL_CONN_CHMAP_LEN);
conn_events = (instant - connsm->event_cntr) & 0xFFFF;
if (conn_events >= 32767) {
ble_ll_conn_timeout(connsm, BLE_ERR_INSTANT_PASSED);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/controller/src/ble_ll_hci.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_hci.c b/net/nimble/controller/src/ble_ll_hci.c
index e7480a1..336cd03 100644
--- a/net/nimble/controller/src/ble_ll_hci.c
+++ b/net/nimble/controller/src/ble_ll_hci.c
@@ -102,7 +102,7 @@ ble_ll_hci_send_noop(void)
evbuf[0] = BLE_HCI_EVCODE_COMMAND_COMPLETE;
evbuf[1] = 3;
evbuf[2] = ble_ll_hci_get_num_cmd_pkts();
- htole16(evbuf + 3, opcode);
+ put_le16(evbuf + 3, opcode);
ble_ll_hci_event_send(evbuf);
rc = BLE_ERR_SUCCESS;
} else {
@@ -184,10 +184,10 @@ ble_ll_hci_rd_local_version(uint8_t *rspbuf, uint8_t *rsplen)
/* Place the data packet length and number of packets in the buffer */
rspbuf[0] = BLE_HCI_VER_BCS_4_2;
- htole16(rspbuf + 1, hci_rev);
+ put_le16(rspbuf + 1, hci_rev);
rspbuf[3] = BLE_LMP_VER_BCS_4_2;
- htole16(rspbuf + 4, mfrg);
- htole16(rspbuf + 6, lmp_subver);
+ put_le16(rspbuf + 4, mfrg);
+ put_le16(rspbuf + 6, lmp_subver);
*rsplen = BLE_HCI_RD_LOC_VER_INFO_RSPLEN;
return BLE_ERR_SUCCESS;
}
@@ -284,7 +284,7 @@ static int
ble_ll_hci_le_read_bufsize(uint8_t *rspbuf, uint8_t *rsplen)
{
/* Place the data packet length and number of packets in the buffer */
- htole16(rspbuf, g_ble_ll_data.ll_acl_pkt_size);
+ put_le16(rspbuf, g_ble_ll_data.ll_acl_pkt_size);
rspbuf[2] = g_ble_ll_data.ll_num_acl_pkts;
*rsplen = BLE_HCI_RD_BUF_SIZE_RSPLEN;
return BLE_ERR_SUCCESS;
@@ -314,8 +314,8 @@ ble_ll_hci_le_wr_sugg_data_len(uint8_t *cmdbuf)
uint16_t tx_time;
/* Get suggested octets and time */
- tx_oct = le16toh(cmdbuf);
- tx_time = le16toh(cmdbuf + 2);
+ tx_oct = get_le16(cmdbuf);
+ tx_time = get_le16(cmdbuf + 2);
/* If valid, write into suggested and change connection initial times */
if (ble_ll_chk_txrx_octets(tx_oct) && ble_ll_chk_txrx_time(tx_time)) {
@@ -348,8 +348,8 @@ static int
ble_ll_hci_le_rd_sugg_data_len(uint8_t *rspbuf, uint8_t *rsplen)
{
/* Place the data packet length and number of packets in the buffer */
- htole16(rspbuf, g_ble_ll_conn_params.sugg_tx_octets);
- htole16(rspbuf + 2, g_ble_ll_conn_params.sugg_tx_time);
+ put_le16(rspbuf, g_ble_ll_conn_params.sugg_tx_octets);
+ put_le16(rspbuf + 2, g_ble_ll_conn_params.sugg_tx_time);
*rsplen = BLE_HCI_RD_SUGG_DATALEN_RSPLEN;
return BLE_ERR_SUCCESS;
}
@@ -368,10 +368,10 @@ static int
ble_ll_hci_le_rd_max_data_len(uint8_t *rspbuf, uint8_t *rsplen)
{
/* Place the data packet length and number of packets in the buffer */
- htole16(rspbuf, g_ble_ll_conn_params.supp_max_tx_octets);
- htole16(rspbuf + 2, g_ble_ll_conn_params.supp_max_tx_time);
- htole16(rspbuf + 4, g_ble_ll_conn_params.supp_max_rx_octets);
- htole16(rspbuf + 6, g_ble_ll_conn_params.supp_max_rx_time);
+ put_le16(rspbuf, g_ble_ll_conn_params.supp_max_tx_octets);
+ put_le16(rspbuf + 2, g_ble_ll_conn_params.supp_max_tx_time);
+ put_le16(rspbuf + 4, g_ble_ll_conn_params.supp_max_rx_octets);
+ put_le16(rspbuf + 6, g_ble_ll_conn_params.supp_max_rx_time);
*rsplen = BLE_HCI_RD_MAX_DATALEN_RSPLEN;
return BLE_ERR_SUCCESS;
}
@@ -411,7 +411,7 @@ ble_ll_hci_le_read_supp_states(uint8_t *rspbuf, uint8_t *rsplen)
/* Add list of supported states. */
supp_states = ble_ll_read_supp_states();
- htole64(rspbuf, supp_states);
+ put_le64(rspbuf, supp_states);
*rsplen = BLE_HCI_RD_SUPP_STATES_RSPLEN;
return BLE_ERR_SUCCESS;
}
@@ -1000,7 +1000,7 @@ ble_ll_hci_cmd_proc(struct os_event *ev)
assert(cmdbuf != NULL);
/* Get the opcode from the command buffer */
- opcode = le16toh(cmdbuf);
+ opcode = get_le16(cmdbuf);
ocf = BLE_HCI_OCF(opcode);
ogf = BLE_HCI_OGF(opcode);
@@ -1039,7 +1039,7 @@ ble_ll_hci_cmd_proc(struct os_event *ev)
cmdbuf[0] = BLE_HCI_EVCODE_COMMAND_COMPLETE;
cmdbuf[1] = 4 + rsplen;
cmdbuf[2] = ble_ll_hci_get_num_cmd_pkts();
- htole16(cmdbuf + 3, opcode);
+ put_le16(cmdbuf + 3, opcode);
cmdbuf[5] = (uint8_t)rc;
} else {
/* Create a command status event */
@@ -1048,7 +1048,7 @@ ble_ll_hci_cmd_proc(struct os_event *ev)
cmdbuf[1] = 4;
cmdbuf[2] = (uint8_t)rc;
cmdbuf[3] = ble_ll_hci_get_num_cmd_pkts();
- htole16(cmdbuf + 4, opcode);
+ put_le16(cmdbuf + 4, opcode);
}
/* Count commands and those in error */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/controller/src/ble_ll_hci_ev.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_hci_ev.c b/net/nimble/controller/src/ble_ll_hci_ev.c
index 15b54ed..c3e003a 100644
--- a/net/nimble/controller/src/ble_ll_hci_ev.c
+++ b/net/nimble/controller/src/ble_ll_hci_ev.c
@@ -48,11 +48,11 @@ ble_ll_hci_ev_datalen_chg(struct ble_ll_conn_sm *connsm)
evbuf[0] = BLE_HCI_EVCODE_LE_META;
evbuf[1] = BLE_HCI_LE_DATA_LEN_CHG_LEN;
evbuf[2] = BLE_HCI_LE_SUBEV_DATA_LEN_CHG;
- htole16(evbuf + 3, connsm->conn_handle);
- htole16(evbuf + 5, connsm->eff_max_tx_octets);
- htole16(evbuf + 7, connsm->eff_max_tx_time);
- htole16(evbuf + 9, connsm->eff_max_rx_octets);
- htole16(evbuf + 11, connsm->eff_max_rx_time);
+ put_le16(evbuf + 3, connsm->conn_handle);
+ put_le16(evbuf + 5, connsm->eff_max_tx_octets);
+ put_le16(evbuf + 7, connsm->eff_max_tx_time);
+ put_le16(evbuf + 9, connsm->eff_max_rx_octets);
+ put_le16(evbuf + 11, connsm->eff_max_rx_time);
ble_ll_hci_event_send(evbuf);
}
}
@@ -75,11 +75,11 @@ ble_ll_hci_ev_rem_conn_parm_req(struct ble_ll_conn_sm *connsm,
evbuf[0] = BLE_HCI_EVCODE_LE_META;
evbuf[1] = BLE_HCI_LE_REM_CONN_PARM_REQ_LEN;
evbuf[2] = BLE_HCI_LE_SUBEV_REM_CONN_PARM_REQ;
- htole16(evbuf + 3, connsm->conn_handle);
- htole16(evbuf + 5, cp->interval_min);
- htole16(evbuf + 7, cp->interval_max);
- htole16(evbuf + 9, cp->latency);
- htole16(evbuf + 11, cp->timeout);
+ put_le16(evbuf + 3, connsm->conn_handle);
+ put_le16(evbuf + 5, cp->interval_min);
+ put_le16(evbuf + 7, cp->interval_max);
+ put_le16(evbuf + 9, cp->latency);
+ put_le16(evbuf + 11, cp->timeout);
ble_ll_hci_event_send(evbuf);
}
}
@@ -103,10 +103,10 @@ ble_ll_hci_ev_conn_update(struct ble_ll_conn_sm *connsm, uint8_t status)
evbuf[1] = BLE_HCI_LE_CONN_UPD_LEN;
evbuf[2] = BLE_HCI_LE_SUBEV_CONN_UPD_COMPLETE;
evbuf[3] = status;
- htole16(evbuf + 4, connsm->conn_handle);
- htole16(evbuf + 6, connsm->conn_itvl);
- htole16(evbuf + 8, connsm->slave_latency);
- htole16(evbuf + 10, connsm->supervision_tmo);
+ put_le16(evbuf + 4, connsm->conn_handle);
+ put_le16(evbuf + 6, connsm->conn_itvl);
+ put_le16(evbuf + 8, connsm->slave_latency);
+ put_le16(evbuf + 10, connsm->supervision_tmo);
ble_ll_hci_event_send(evbuf);
}
}
@@ -134,7 +134,7 @@ ble_ll_hci_ev_encrypt_chg(struct ble_ll_conn_sm *connsm, uint8_t status)
evbuf[0] = evcode;
evbuf[1] = evlen;
evbuf[2] = status;
- htole16(evbuf + 3, connsm->conn_handle);
+ put_le16(evbuf + 3, connsm->conn_handle);
if (evcode == BLE_HCI_EVCODE_ENCRYPT_CHG) {
if (status == BLE_ERR_SUCCESS) {
evbuf[5] = 0x01;
@@ -165,9 +165,9 @@ ble_ll_hci_ev_ltk_req(struct ble_ll_conn_sm *connsm)
evbuf[0] = BLE_HCI_EVCODE_LE_META;
evbuf[1] = BLE_HCI_LE_LT_KEY_REQ_LEN;
evbuf[2] = BLE_HCI_LE_SUBEV_LT_KEY_REQ;
- htole16(evbuf + 3, connsm->conn_handle);
- htole64(evbuf + 5, connsm->enc_data.host_rand_num);
- htole16(evbuf + 13, connsm->enc_data.enc_div);
+ put_le16(evbuf + 3, connsm->conn_handle);
+ put_le64(evbuf + 5, connsm->enc_data.host_rand_num);
+ put_le16(evbuf + 13, connsm->enc_data.enc_div);
ble_ll_hci_event_send(evbuf);
}
rc = 0;
@@ -196,7 +196,7 @@ ble_ll_hci_ev_rd_rem_used_feat(struct ble_ll_conn_sm *connsm, uint8_t status)
evbuf[1] = BLE_HCI_LE_RD_REM_USED_FEAT_LEN;
evbuf[2] = BLE_HCI_LE_SUBEV_RD_REM_USED_FEAT;
evbuf[3] = status;
- htole16(evbuf + 4, connsm->conn_handle);
+ put_le16(evbuf + 4, connsm->conn_handle);
memset(evbuf + 6, 0, BLE_HCI_RD_LOC_SUPP_FEAT_RSPLEN);
evbuf[6] = connsm->common_features;
ble_ll_hci_event_send(evbuf);
@@ -215,10 +215,10 @@ ble_ll_hci_ev_rd_rem_ver(struct ble_ll_conn_sm *connsm, uint8_t status)
evbuf[0] = BLE_HCI_EVCODE_RD_REM_VER_INFO_CMP;
evbuf[1] = BLE_HCI_EVENT_RD_RM_VER_LEN;
evbuf[2] = status;
- htole16(evbuf + 3, connsm->conn_handle);
+ put_le16(evbuf + 3, connsm->conn_handle);
evbuf[5] = connsm->vers_nr;
- htole16(evbuf + 6, connsm->comp_id);
- htole16(evbuf + 8, connsm->sub_vers_nr);
+ put_le16(evbuf + 6, connsm->comp_id);
+ put_le16(evbuf + 8, connsm->sub_vers_nr);
ble_ll_hci_event_send(evbuf);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/controller/src/ble_ll_resolv.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_resolv.c b/net/nimble/controller/src/ble_ll_resolv.c
index 65a581e..012afc5 100644
--- a/net/nimble/controller/src/ble_ll_resolv.c
+++ b/net/nimble/controller/src/ble_ll_resolv.c
@@ -356,7 +356,7 @@ ble_ll_resolv_set_rpa_tmo(uint8_t *cmdbuf)
{
uint16_t tmo_secs;
- tmo_secs = le16toh(cmdbuf);
+ tmo_secs = get_le16(cmdbuf);
if (!((tmo_secs > 0) && (tmo_secs <= 0xA1B8))) {
return BLE_ERR_INV_HCI_CMD_PARMS;
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/controller/src/ble_ll_scan.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_scan.c b/net/nimble/controller/src/ble_ll_scan.c
index c79b88e..be06030 100644
--- a/net/nimble/controller/src/ble_ll_scan.c
+++ b/net/nimble/controller/src/ble_ll_scan.c
@@ -1221,8 +1221,8 @@ ble_ll_scan_set_scan_params(uint8_t *cmd)
/* Get the scan interval and window */
scan_type = cmd[0];
- scan_itvl = le16toh(cmd + 1);
- scan_window = le16toh(cmd + 3);
+ scan_itvl = get_le16(cmd + 1);
+ scan_window = get_le16(cmd + 3);
own_addr_type = cmd[5];
filter_policy = cmd[6];
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/host/services/gatt/src/ble_svc_gatt.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/gatt/src/ble_svc_gatt.c b/net/nimble/host/services/gatt/src/ble_svc_gatt.c
index 8b7139d..78b4a06 100644
--- a/net/nimble/host/services/gatt/src/ble_svc_gatt.c
+++ b/net/nimble/host/services/gatt/src/ble_svc_gatt.c
@@ -71,8 +71,8 @@ ble_svc_gatt_access(uint16_t conn_handle, uint16_t attr_handle,
return BLE_HS_ENOMEM;
}
- htole16(u8p + 0, ble_svc_gatt_start_handle);
- htole16(u8p + 2, ble_svc_gatt_end_handle);
+ put_le16(u8p + 0, ble_svc_gatt_start_handle);
+ put_le16(u8p + 2, ble_svc_gatt_end_handle);
return 0;
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/host/src/ble_att_clt.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_att_clt.c b/net/nimble/host/src/ble_att_clt.c
index 8b3a95d..e167576 100644
--- a/net/nimble/host/src/ble_att_clt.c
+++ b/net/nimble/host/src/ble_att_clt.c
@@ -259,7 +259,7 @@ ble_att_clt_parse_find_info_entry(struct os_mbuf **rxom, uint8_t rsp_format,
return rc;
}
- idata->attr_handle = le16toh((*rxom)->om_data);
+ idata->attr_handle = get_le16((*rxom)->om_data);
switch (rsp_format) {
case BLE_ATT_FIND_INFO_RSP_FORMAT_16BIT:
@@ -496,7 +496,7 @@ ble_att_clt_parse_read_type_adata(struct os_mbuf **om, int data_len,
return rc;
}
- adata->att_handle = le16toh((*om)->om_data + 0);
+ adata->att_handle = get_le16((*om)->om_data + 0);
adata->value_len = data_len - BLE_ATT_READ_TYPE_ADATA_BASE_SZ;
adata->value = (*om)->om_data + BLE_ATT_READ_TYPE_ADATA_BASE_SZ;
@@ -681,7 +681,7 @@ ble_att_clt_build_read_mult_req(const uint16_t *att_handles,
goto err;
}
- htole16(buf, att_handles[i]);
+ put_le16(buf, att_handles[i]);
}
*out_txom = txom;
@@ -809,8 +809,8 @@ ble_att_clt_parse_read_group_type_adata(
return rc;
}
- adata->att_handle = le16toh((*om)->om_data + 0);
- adata->end_group_handle = le16toh((*om)->om_data + 2);
+ adata->att_handle = get_le16((*om)->om_data + 0);
+ adata->end_group_handle = get_le16((*om)->om_data + 2);
adata->value_len = data_len - BLE_ATT_READ_GROUP_TYPE_ADATA_BASE_SZ;
adata->value = (*om)->om_data + BLE_ATT_READ_GROUP_TYPE_ADATA_BASE_SZ;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/host/src/ble_att_svr.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_att_svr.c b/net/nimble/host/src/ble_att_svr.c
index 332f097..c2097e1 100644
--- a/net/nimble/host/src/ble_att_svr.c
+++ b/net/nimble/host/src/ble_att_svr.c
@@ -842,7 +842,7 @@ ble_att_svr_fill_info(struct ble_att_find_info_req *req, struct os_mbuf *om,
goto done;
}
- htole16(buf + 0, ha->ha_handle_id);
+ put_le16(buf + 0, ha->ha_handle_id);
ble_uuid_flat(ha->ha_uuid, buf + 2);
@@ -992,14 +992,14 @@ ble_att_svr_fill_type_value_entry(struct os_mbuf *om, uint16_t first,
return 0;
}
- htole16(&u16, first);
+ put_le16(&u16, first);
rc = os_mbuf_append(om, &u16, 2);
if (rc != 0) {
*out_att_err = BLE_ATT_ERR_INSUFFICIENT_RES;
return BLE_HS_ENOMEM;
}
- htole16(&u16, last);
+ put_le16(&u16, last);
rc = os_mbuf_append(om, &u16, 2);
if (rc != 0) {
*out_att_err = BLE_ATT_ERR_INSUFFICIENT_RES;
@@ -1359,7 +1359,7 @@ ble_att_svr_build_read_type_rsp(uint16_t conn_handle,
goto done;
}
- htole16(dptr + 0, entry->ha_handle_id);
+ put_le16(dptr + 0, entry->ha_handle_id);
memcpy(dptr + 2, buf, attr_len);
entry_written = 1;
}
@@ -1619,7 +1619,7 @@ ble_att_svr_build_read_mult_rsp(uint16_t conn_handle,
/* Extract the 16-bit handle and strip it from the front of the
* mbuf.
*/
- handle = le16toh((*rxom)->om_data);
+ handle = get_le16((*rxom)->om_data);
os_mbuf_adj(*rxom, 2);
rc = ble_att_svr_read_handle(conn_handle, handle, 0, txom, att_err);
@@ -1735,8 +1735,8 @@ ble_att_svr_read_group_type_entry_write(struct os_mbuf *om, uint16_t mtu,
return BLE_HS_ENOMEM;
}
- htole16(buf + 0, start_group_handle);
- htole16(buf + 2, end_group_handle);
+ put_le16(buf + 0, start_group_handle);
+ put_le16(buf + 2, end_group_handle);
ble_uuid_flat(service_uuid, buf + 4);
return 0;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/host/src/ble_eddystone.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_eddystone.c b/net/nimble/host/src/ble_eddystone.c
index a924d40..e1d8ec8 100644
--- a/net/nimble/host/src/ble_eddystone.c
+++ b/net/nimble/host/src/ble_eddystone.c
@@ -45,7 +45,7 @@ static uint8_t ble_eddystone_svc_data[BLE_EDDYSTONE_MAX_SVC_DATA_LEN];
static void *
ble_eddystone_set_svc_data_base(uint8_t frame_type)
{
- htole16(ble_eddystone_svc_data, BLE_EDDYSTONE_SERVICE_UUID);
+ put_le16(ble_eddystone_svc_data, BLE_EDDYSTONE_SERVICE_UUID);
ble_eddystone_svc_data[2] = frame_type;
return ble_eddystone_svc_data + BLE_EDDYSTONE_SVC_DATA_BASE_SZ;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/host/src/ble_gattc.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_gattc.c b/net/nimble/host/src/ble_gattc.c
index 8b12d18..d3a2270 100644
--- a/net/nimble/host/src/ble_gattc.c
+++ b/net/nimble/host/src/ble_gattc.c
@@ -2003,14 +2003,14 @@ ble_gattc_find_inc_svcs_rx_adata(struct ble_gattc_proc *proc,
switch (adata->value_len) {
case BLE_GATTS_INC_SVC_LEN_NO_UUID:
- proc->find_inc_svcs.cur_start = le16toh(adata->value + 0);
- proc->find_inc_svcs.cur_end = le16toh(adata->value + 2);
+ proc->find_inc_svcs.cur_start = get_le16(adata->value + 0);
+ proc->find_inc_svcs.cur_end = get_le16(adata->value + 2);
call_cb = 0;
break;
case BLE_GATTS_INC_SVC_LEN_UUID:
- service.start_handle = le16toh(adata->value + 0);
- service.end_handle = le16toh(adata->value + 2);
+ service.start_handle = get_le16(adata->value + 0);
+ service.end_handle = get_le16(adata->value + 2);
ble_uuid_init_from_buf(&service.uuid, adata->value + 4, 2);
break;
@@ -2264,7 +2264,7 @@ ble_gattc_disc_all_chrs_rx_adata(struct ble_gattc_proc *proc,
}
chr.properties = adata->value[0];
- chr.val_handle = le16toh(adata->value + 1);
+ chr.val_handle = get_le16(adata->value + 1);
if (adata->att_handle <= proc->disc_all_chrs.prev_handle) {
/* Peer sent characteristics out of order; terminate procedure. */
@@ -2510,7 +2510,7 @@ ble_gattc_disc_chr_uuid_rx_adata(struct ble_gattc_proc *proc,
}
chr.properties = adata->value[0];
- chr.val_handle = le16toh(adata->value + 1);
+ chr.val_handle = get_le16(adata->value + 1);
if (adata->att_handle <= proc->disc_chr_uuid.prev_handle) {
/* Peer sent characteristics out of order; terminate procedure. */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/host/src/ble_gatts.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_gatts.c b/net/nimble/host/src/ble_gatts.c
index aa09fe7..ae9f3fb 100644
--- a/net/nimble/host/src/ble_gatts.c
+++ b/net/nimble/host/src/ble_gatts.c
@@ -121,8 +121,8 @@ ble_gatts_inc_access(uint16_t conn_handle, uint16_t attr_handle,
if (buf == NULL) {
return BLE_ATT_ERR_INSUFFICIENT_RES;
}
- htole16(buf + 0, entry->handle);
- htole16(buf + 2, entry->end_group_handle);
+ put_le16(buf + 0, entry->handle);
+ put_le16(buf + 2, entry->end_group_handle);
/* Only include the service UUID if it has a 16-bit representation. */
uuid16 = ble_uuid_u16(entry->svc->uuid);
@@ -131,7 +131,7 @@ ble_gatts_inc_access(uint16_t conn_handle, uint16_t attr_handle,
if (buf == NULL) {
return BLE_ATT_ERR_INSUFFICIENT_RES;
}
- htole16(buf, uuid16);
+ put_le16(buf, uuid16);
}
return 0;
@@ -246,7 +246,7 @@ ble_gatts_chr_def_access(uint16_t conn_handle, uint16_t attr_handle,
buf[0] = ble_gatts_chr_properties(chr);
/* The value attribute is always immediately after the declaration. */
- htole16(buf + 1, attr_handle + 1);
+ put_le16(buf + 1, attr_handle + 1);
buf = os_mbuf_extend(*om, ble_uuid_length(chr->uuid));
if (buf == NULL) {
@@ -666,7 +666,7 @@ ble_gatts_clt_cfg_access_locked(struct ble_hs_conn *conn, uint16_t attr_handle,
if (buf == NULL) {
return BLE_ATT_ERR_INSUFFICIENT_RES;
}
- htole16(buf, clt_cfg->flags & ~BLE_GATTS_CLT_CFG_F_RESERVED);
+ put_le16(buf, clt_cfg->flags & ~BLE_GATTS_CLT_CFG_F_RESERVED);
break;
case BLE_GATT_ACCESS_OP_WRITE_DSC:
@@ -678,7 +678,7 @@ ble_gatts_clt_cfg_access_locked(struct ble_hs_conn *conn, uint16_t attr_handle,
om = os_mbuf_pullup(om, 2);
BLE_HS_DBG_ASSERT(om != NULL);
- flags = le16toh(om->om_data);
+ flags = get_le16(om->om_data);
if ((flags & ~clt_cfg->allowed) != 0) {
return BLE_ATT_ERR_REQ_NOT_SUPPORTED;
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/host/src/ble_hs_adv.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_adv.c b/net/nimble/host/src/ble_hs_adv.c
index 8b790cc..729887f 100644
--- a/net/nimble/host/src/ble_hs_adv.c
+++ b/net/nimble/host/src/ble_hs_adv.c
@@ -79,7 +79,7 @@ ble_hs_adv_set_array16(uint8_t type, uint8_t num_elems, const uint16_t *elems,
}
for (i = 0; i < num_elems; i++) {
- htole16(dst + *dst_len, elems[i]);
+ put_le16(dst + *dst_len, elems[i]);
*dst_len += sizeof elems[i];
}
@@ -100,7 +100,7 @@ ble_hs_adv_set_array32(uint8_t type, uint8_t num_elems, const uint32_t *elems,
}
for (i = 0; i < num_elems; i++) {
- htole32(dst + *dst_len, elems[i]);
+ put_le32(dst + *dst_len, elems[i]);
*dst_len += sizeof elems[i];
}
@@ -374,7 +374,7 @@ ble_hs_adv_parse_uuids16(struct ble_hs_adv_fields *adv_fields,
adv_fields->num_uuids16 = data_len / 2;
for (i = 0; i < adv_fields->num_uuids16; i++) {
- adv_fields->uuids16[i] = le16toh(data + i * 2);
+ adv_fields->uuids16[i] = get_le16(data + i * 2);
}
return 0;
@@ -394,7 +394,7 @@ ble_hs_adv_parse_uuids32(struct ble_hs_adv_fields *adv_fields,
adv_fields->num_uuids32 = data_len / 4;
for (i = 0; i < adv_fields->num_uuids32; i++) {
- adv_fields->uuids32[i] = le32toh(data + i * 4);
+ adv_fields->uuids32[i] = get_le32(data + i * 4);
}
return 0;
@@ -540,7 +540,7 @@ ble_hs_adv_parse_one_field(struct ble_hs_adv_fields *adv_fields,
if (data_len != BLE_HS_ADV_APPEARANCE_LEN) {
return BLE_HS_EBADDATA;
}
- adv_fields->appearance = le16toh(data);
+ adv_fields->appearance = get_le16(data);
adv_fields->appearance_is_present = 1;
break;
@@ -548,7 +548,7 @@ ble_hs_adv_parse_one_field(struct ble_hs_adv_fields *adv_fields,
if (data_len != BLE_HS_ADV_ADV_ITVL_LEN) {
return BLE_HS_EBADDATA;
}
- adv_fields->adv_itvl = le16toh(data);
+ adv_fields->adv_itvl = get_le16(data);
adv_fields->adv_itvl_is_present = 1;
break;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/host/src/ble_hs_dbg.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_dbg.c b/net/nimble/host/src/ble_hs_dbg.c
index cff3d99..77c84f1 100644
--- a/net/nimble/host/src/ble_hs_dbg.c
+++ b/net/nimble/host/src/ble_hs_dbg.c
@@ -45,7 +45,7 @@ ble_hs_dbg_le_event_disp(uint8_t subev, uint8_t len, uint8_t *evdata)
if (status == BLE_ERR_SUCCESS) {
BLE_HS_LOG(DEBUG, "LE connection complete. handle=%u role=%u "
"paddrtype=%u addr=%x.%x.%x.%x.%x.%x ",
- le16toh(evdata + 1), evdata[3], evdata[4],
+ get_le16(evdata + 1), evdata[3], evdata[4],
evdata[10], evdata[9], evdata[8], evdata[7],
evdata[6], evdata[5]);
@@ -61,8 +61,8 @@ ble_hs_dbg_le_event_disp(uint8_t subev, uint8_t len, uint8_t *evdata)
evdata += 12;
}
BLE_HS_LOG(DEBUG, "itvl=%u latency=%u spvn_tmo=%u mca=%u\n",
- le16toh(evdata), le16toh(evdata + 2),
- le16toh(evdata + 4), evdata[6]);
+ get_le16(evdata), get_le16(evdata + 2),
+ get_le16(evdata + 4), evdata[6]);
} else {
BLE_HS_LOG(DEBUG, "LE connection complete. FAIL (status=%u)\n",
status);
@@ -100,8 +100,8 @@ ble_hs_dbg_le_event_disp(uint8_t subev, uint8_t len, uint8_t *evdata)
if (status == BLE_ERR_SUCCESS) {
BLE_HS_LOG(DEBUG, "LE Connection Update Complete. handle=%u "
"itvl=%u latency=%u timeout=%u\n",
- le16toh(evdata + 1), le16toh(evdata + 3),
- le16toh(evdata + 5), le16toh(evdata + 7));
+ get_le16(evdata + 1), get_le16(evdata + 3),
+ get_le16(evdata + 5), get_le16(evdata + 7));
} else {
BLE_HS_LOG(DEBUG, "LE Connection Update Complete. FAIL "
"(status=%u)\n", status);
@@ -111,23 +111,23 @@ ble_hs_dbg_le_event_disp(uint8_t subev, uint8_t len, uint8_t *evdata)
case BLE_HCI_LE_SUBEV_DATA_LEN_CHG:
BLE_HS_LOG(DEBUG, "LE Data Length Change. handle=%u max_tx_bytes=%u "
"max_tx_time=%u max_rx_bytes=%u max_rx_time=%u\n",
- le16toh(evdata), le16toh(evdata + 2),
- le16toh(evdata + 4), le16toh(evdata + 6),
- le16toh(evdata + 8));
+ get_le16(evdata), get_le16(evdata + 2),
+ get_le16(evdata + 4), get_le16(evdata + 6),
+ get_le16(evdata + 8));
break;
case BLE_HCI_LE_SUBEV_REM_CONN_PARM_REQ:
BLE_HS_LOG(DEBUG, "LE Remote Connection Parameter Request. handle=%u "
"min_itvl=%u max_itvl=%u latency=%u timeout=%u\n",
- le16toh(evdata), le16toh(evdata + 2),
- le16toh(evdata + 4), le16toh(evdata + 6),
- le16toh(evdata + 8));
+ get_le16(evdata), get_le16(evdata + 2),
+ get_le16(evdata + 4), get_le16(evdata + 6),
+ get_le16(evdata + 8));
break;
case BLE_HCI_LE_SUBEV_RD_REM_USED_FEAT:
status = evdata[0];
if (status == BLE_ERR_SUCCESS) {
BLE_HS_LOG(DEBUG, "LE Remote Used Features. handle=%u feat=",
- le16toh(evdata + 1));
+ get_le16(evdata + 1));
for (i = 0; i < BLE_HCI_RD_LOC_SUPP_FEAT_RSPLEN; ++i) {
BLE_HS_LOG(DEBUG, "%02x ", evdata[3 + i]);
}
@@ -140,8 +140,8 @@ ble_hs_dbg_le_event_disp(uint8_t subev, uint8_t len, uint8_t *evdata)
case BLE_HCI_LE_SUBEV_LT_KEY_REQ:
BLE_HS_LOG(DEBUG, "LE LTK Req. handle=%u rand=%lx%lx encdiv=%u\n",
- le16toh(evdata), le32toh(evdata + 6),
- le32toh(evdata + 2), le16toh(evdata + 10));
+ get_le16(evdata), get_le32(evdata + 6),
+ get_le32(evdata + 2), get_le16(evdata + 10));
break;
default:
@@ -165,7 +165,7 @@ ble_hs_dbg_disconn_comp_disp(uint8_t *evdata, uint8_t len)
uint16_t handle;
status = evdata[0];
- handle = le16toh(evdata + 1);
+ handle = get_le16(evdata + 1);
/* Ignore reason if status is not success */
if (status != BLE_ERR_SUCCESS) {
reason = 0;
@@ -190,7 +190,7 @@ ble_hs_dbg_encrypt_chg_disp(uint8_t *evdata, uint8_t len)
uint16_t handle;
status = evdata[0];
- handle = le16toh(evdata + 1);
+ handle = get_le16(evdata + 1);
/* Ignore reason if status is not success */
if (status != BLE_ERR_SUCCESS) {
@@ -215,7 +215,7 @@ ble_hs_dbg_encrypt_refresh_disp(uint8_t *evdata, uint8_t len)
uint16_t handle;
status = evdata[0];
- handle = le16toh(evdata + 1);
+ handle = get_le16(evdata + 1);
BLE_HS_LOG(DEBUG, "Encrypt key refresh: status=%u handle=%u\n",
status, handle);
@@ -232,8 +232,8 @@ ble_hs_dbg_rd_rem_ver_disp(uint8_t *evdata, uint8_t len)
{
BLE_HS_LOG(DEBUG, "Remote Version Info: status=%u handle=%u vers_nr=%u "
"compid=%u subver=%u\n",
- evdata[0], le16toh(evdata + 1), evdata[3],
- le16toh(evdata + 4), le16toh(evdata + 6));
+ evdata[0], get_le16(evdata + 1), evdata[3],
+ get_le16(evdata + 4), get_le16(evdata + 6));
}
/**
@@ -265,9 +265,9 @@ ble_hs_dbg_num_comp_pkts_disp(uint8_t *evdata, uint8_t len)
handle_ptr = evdata + 1;
pkt_ptr = handle_ptr + (2 * handles);
while (handles) {
- handle = le16toh(handle_ptr);
+ handle = get_le16(handle_ptr);
handle_ptr += 2;
- pkts = le16toh(pkt_ptr);
+ pkts = get_le16(pkt_ptr);
pkt_ptr += 2;
BLE_HS_LOG(DEBUG, "handle:%u pkts:%u\n", handle, pkts);
--handles;
@@ -292,7 +292,7 @@ ble_hs_dbg_auth_pyld_tmo_disp(uint8_t *evdata, uint8_t len)
}
- handle = le16toh(evdata);
+ handle = get_le16(evdata);
BLE_HS_LOG(DEBUG, "AuthPyldTmo: handle=%u\n", handle);
}
@@ -311,8 +311,8 @@ ble_hs_dbg_cmd_comp_info_params(uint8_t status, uint8_t ocf, uint8_t *evdata)
case BLE_HCI_OCF_IP_RD_LOCAL_VER:
BLE_HS_LOG(DEBUG, "hci_ver=%u hci_rev=%u lmp_ver=%u mfrg=%u "
"lmp_subver=%u",
- evdata[0], le16toh(evdata + 1), evdata[3],
- le16toh(evdata + 4), le16toh(evdata + 6));
+ evdata[0], get_le16(evdata + 1), evdata[3],
+ get_le16(evdata + 4), get_le16(evdata + 6));
break;
case BLE_HCI_OCF_IP_RD_LOC_SUPP_CMD:
BLE_HS_LOG(DEBUG, "supp_cmds=");
@@ -326,7 +326,7 @@ ble_hs_dbg_cmd_comp_info_params(uint8_t status, uint8_t ocf, uint8_t *evdata)
break;
case BLE_HCI_OCF_IP_RD_LOC_SUPP_FEAT:
BLE_HS_LOG(DEBUG, "supp_feat=0x%lx%08lx",
- le32toh(evdata + 4), le32toh(evdata));
+ get_le32(evdata + 4), get_le32(evdata));
break;
case BLE_HCI_OCF_IP_RD_BD_ADDR:
BLE_HS_LOG(DEBUG, "bd_addr=%x:%x:%x:%x:%x:%x",
@@ -354,7 +354,7 @@ ble_hs_dbg_cmd_complete_disp(uint8_t *evdata, uint8_t len)
}
cmd_pkts = evdata[0];
- opcode = le16toh(evdata + 1);
+ opcode = get_le16(evdata + 1);
ogf = BLE_HCI_OGF(opcode);
ocf = BLE_HCI_OCF(opcode);
@@ -379,7 +379,7 @@ ble_hs_dbg_cmd_complete_disp(uint8_t *evdata, uint8_t len)
case BLE_HCI_OGF_STATUS_PARAMS:
switch (ocf) {
case BLE_HCI_OCF_RD_RSSI:
- BLE_HS_LOG(DEBUG, "handle=%u rssi=%d", le16toh(evdata),
+ BLE_HS_LOG(DEBUG, "handle=%u rssi=%d", get_le16(evdata),
(int8_t)evdata[2]);
break;
default:
@@ -390,17 +390,17 @@ ble_hs_dbg_cmd_complete_disp(uint8_t *evdata, uint8_t len)
switch (ocf) {
case BLE_HCI_OCF_LE_RD_CHAN_MAP:
BLE_HS_LOG(DEBUG, "handle=%u chanmap=%x.%x.%x.%x.%x",
- le16toh(evdata), evdata[2], evdata[3], evdata[4],
+ get_le16(evdata), evdata[2], evdata[3], evdata[4],
evdata[5], evdata[6]);
break;
case BLE_HCI_OCF_LE_RD_MAX_DATA_LEN:
BLE_HS_LOG(DEBUG, "txoct=%u txtime=%u rxoct=%u rxtime=%u",
- le16toh(evdata), le16toh(evdata + 2),
- le16toh(evdata + 4), le16toh(evdata + 6));
+ get_le16(evdata), get_le16(evdata + 2),
+ get_le16(evdata + 4), get_le16(evdata + 6));
break;
case BLE_HCI_OCF_LE_RD_SUPP_STATES:
- BLE_HS_LOG(DEBUG, "states=0x%lx%08lx", le32toh(evdata + 4),
- le32toh(evdata));
+ BLE_HS_LOG(DEBUG, "states=0x%lx%08lx", get_le32(evdata + 4),
+ get_le32(evdata));
break;
case BLE_HCI_OCF_LE_ENCRYPT:
BLE_HS_LOG(DEBUG, "encdata=0x%02x%02x%02x%02x%02x%02x%02x%02x",
@@ -417,13 +417,13 @@ ble_hs_dbg_cmd_complete_disp(uint8_t *evdata, uint8_t len)
evdata[4], evdata[5], evdata[6], evdata[7]);
break;
case BLE_HCI_OCF_LE_RD_SUGG_DEF_DATA_LEN:
- BLE_HS_LOG(DEBUG, "txoct=%u txtime=%u", le16toh(evdata),
- le16toh(evdata + 2));
+ BLE_HS_LOG(DEBUG, "txoct=%u txtime=%u", get_le16(evdata),
+ get_le16(evdata + 2));
break;
case BLE_HCI_OCF_LE_LT_KEY_REQ_REPLY:
case BLE_HCI_OCF_LE_LT_KEY_REQ_NEG_REPLY:
case BLE_HCI_OCF_LE_SET_DATA_LEN:
- BLE_HS_LOG(DEBUG, "handle=%u", le16toh(evdata));
+ BLE_HS_LOG(DEBUG, "handle=%u", get_le16(evdata));
break;
default:
break;
@@ -444,7 +444,7 @@ ble_hs_dbg_cmd_status_disp(uint8_t *evdata, uint8_t len)
uint8_t ocf;
uint16_t opcode;
- opcode = le16toh(evdata + 2);
+ opcode = get_le16(evdata + 2);
ogf = BLE_HCI_OGF(opcode);
ocf = BLE_HCI_OCF(opcode);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/host/src/ble_hs_hci.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_hci.c b/net/nimble/host/src/ble_hs_hci.c
index 33b77a0..fff8d92 100644
--- a/net/nimble/host/src/ble_hs_hci.c
+++ b/net/nimble/host/src/ble_hs_hci.c
@@ -92,7 +92,7 @@ ble_hs_hci_rx_cmd_complete(uint8_t event_code, uint8_t *data, int len,
}
num_pkts = data[2];
- opcode = le16toh(data + 3);
+ opcode = get_le16(data + 3);
params = data + 5;
/* XXX: Process num_pkts field. */
@@ -135,7 +135,7 @@ ble_hs_hci_rx_cmd_status(uint8_t event_code, uint8_t *data, int len,
status = data[2];
num_pkts = data[3];
- opcode = le16toh(data + 4);
+ opcode = get_le16(data + 4);
/* XXX: Process num_pkts field. */
(void)num_pkts;
@@ -255,7 +255,7 @@ ble_hs_hci_cmd_tx(void *cmd, void *evt_buf, uint8_t evt_buf_len,
uint16_t opcode;
int rc;
- opcode = le16toh(cmd);
+ opcode = get_le16(cmd);
BLE_HS_DBG_ASSERT(ble_hs_hci_ack == NULL);
ble_hs_hci_lock();
@@ -381,7 +381,7 @@ ble_hs_hci_acl_hdr_prepend(struct os_mbuf *om, uint16_t handle,
hci_hdr.hdh_handle_pb_bc =
ble_hs_hci_util_handle_pb_bc_join(handle, pb_flag, 0);
- htole16(&hci_hdr.hdh_len, OS_MBUF_PKTHDR(om)->omp_len);
+ put_le16(&hci_hdr.hdh_len, OS_MBUF_PKTHDR(om)->omp_len);
om2 = os_mbuf_prepend(om, sizeof hci_hdr);
if (om2 == NULL) {
@@ -397,7 +397,7 @@ ble_hs_hci_acl_hdr_prepend(struct os_mbuf *om, uint16_t handle,
memcpy(om->om_data, &hci_hdr, sizeof hci_hdr);
BLE_HS_LOG(DEBUG, "host tx hci data; handle=%d length=%d\n", handle,
- le16toh(&hci_hdr.hdh_len));
+ get_le16(&hci_hdr.hdh_len));
return om;
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/host/src/ble_hs_hci_cmd.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_hci_cmd.c b/net/nimble/host/src/ble_hs_hci_cmd.c
index 3cc3b98..d20baf9 100644
--- a/net/nimble/host/src/ble_hs_hci_cmd.c
+++ b/net/nimble/host/src/ble_hs_hci_cmd.c
@@ -55,7 +55,7 @@ ble_hs_hci_cmd_write_hdr(uint8_t ogf, uint16_t ocf, uint8_t len, void *buf)
u8ptr = buf;
opcode = (ogf << 10) | ocf;
- htole16(u8ptr, opcode);
+ put_le16(u8ptr, opcode);
u8ptr[2] = len;
}
@@ -68,7 +68,7 @@ ble_hs_hci_cmd_send(uint8_t ogf, uint16_t ocf, uint8_t len, const void *cmddata)
buf = ble_hci_trans_buf_alloc(BLE_HCI_TRANS_BUF_CMD);
BLE_HS_DBG_ASSERT(buf != NULL);
- htole16(buf, ogf << 10 | ocf);
+ put_le16(buf, ogf << 10 | ocf);
buf[2] = len;
if (len != 0) {
memcpy(buf + BLE_HCI_CMD_HDR_LEN, cmddata, len);
@@ -117,7 +117,7 @@ ble_hs_hci_cmd_send_buf(void *buf)
u8ptr = buf;
- opcode = le16toh(u8ptr + 0);
+ opcode = get_le16(u8ptr + 0);
len = u8ptr[2];
rc = ble_hs_hci_cmd_send(BLE_HCI_OGF(opcode), BLE_HCI_OCF(opcode), len,
@@ -208,8 +208,8 @@ ble_hs_hci_cmd_body_le_set_adv_params(const struct hci_adv_params *adv,
}
}
- htole16(dst, adv->adv_itvl_min);
- htole16(dst + 2, adv->adv_itvl_max);
+ put_le16(dst, adv->adv_itvl_min);
+ put_le16(dst + 2, adv->adv_itvl_max);
dst[4] = adv->adv_type;
dst[5] = adv->own_addr_type;
dst[6] = adv->peer_addr_type;
@@ -343,7 +343,7 @@ ble_hs_hci_cmd_build_le_set_scan_rsp_data(const uint8_t *data, uint8_t len,
static void
ble_hs_hci_cmd_body_set_event_mask(uint64_t event_mask, uint8_t *dst)
{
- htole64(dst, event_mask);
+ put_le64(dst, event_mask);
}
void
@@ -379,7 +379,7 @@ ble_hs_hci_cmd_build_set_event_mask2(uint64_t event_mask,
static void
ble_hs_hci_cmd_body_disconnect(uint16_t handle, uint8_t reason, uint8_t *dst)
{
- htole16(dst + 0, handle);
+ put_le16(dst + 0, handle);
dst[2] = reason;
}
@@ -414,7 +414,7 @@ ble_hs_hci_cmd_disconnect(uint16_t handle, uint8_t reason)
static void
ble_hs_hci_cmd_body_le_set_event_mask(uint64_t event_mask, uint8_t *dst)
{
- htole64(dst, event_mask);
+ put_le64(dst, event_mask);
}
void
@@ -527,8 +527,8 @@ ble_hs_hci_cmd_body_le_set_scan_params(
}
dst[0] = scan_type;
- htole16(dst + 1, scan_itvl);
- htole16(dst + 3, scan_window);
+ put_le16(dst + 1, scan_itvl);
+ put_le16(dst + 3, scan_window);
dst[5] = own_addr_type;
dst[6] = filter_policy;
@@ -642,18 +642,18 @@ ble_hs_hci_cmd_body_le_create_connection(const struct hci_create_conn *hcc,
return BLE_ERR_INV_HCI_CMD_PARMS;
}
- htole16(cmd + 0, hcc->scan_itvl);
- htole16(cmd + 2, hcc->scan_window);
+ put_le16(cmd + 0, hcc->scan_itvl);
+ put_le16(cmd + 2, hcc->scan_window);
cmd[4] = hcc->filter_policy;
cmd[5] = hcc->peer_addr_type;
memcpy(cmd + 6, hcc->peer_addr, BLE_DEV_ADDR_LEN);
cmd[12] = hcc->own_addr_type;
- htole16(cmd + 13, hcc->conn_itvl_min);
- htole16(cmd + 15, hcc->conn_itvl_max);
- htole16(cmd + 17, hcc->conn_latency);
- htole16(cmd + 19, hcc->supervision_timeout);
- htole16(cmd + 21, hcc->min_ce_len);
- htole16(cmd + 23, hcc->max_ce_len);
+ put_le16(cmd + 13, hcc->conn_itvl_min);
+ put_le16(cmd + 15, hcc->conn_itvl_max);
+ put_le16(cmd + 17, hcc->conn_latency);
+ put_le16(cmd + 19, hcc->supervision_timeout);
+ put_le16(cmd + 21, hcc->min_ce_len);
+ put_le16(cmd + 23, hcc->max_ce_len);
return 0;
}
@@ -778,13 +778,13 @@ ble_hs_hci_cmd_body_le_conn_update(const struct hci_conn_update *hcu,
uint8_t *dst)
{
/* XXX: add parameter checking later */
- htole16(dst + 0, hcu->handle);
- htole16(dst + 2, hcu->conn_itvl_min);
- htole16(dst + 4, hcu->conn_itvl_max);
- htole16(dst + 6, hcu->conn_latency);
- htole16(dst + 8, hcu->supervision_timeout);
- htole16(dst + 10, hcu->min_ce_len);
- htole16(dst + 12, hcu->max_ce_len);
+ put_le16(dst + 0, hcu->handle);
+ put_le16(dst + 2, hcu->conn_itvl_min);
+ put_le16(dst + 4, hcu->conn_itvl_max);
+ put_le16(dst + 6, hcu->conn_latency);
+ put_le16(dst + 8, hcu->supervision_timeout);
+ put_le16(dst + 10, hcu->min_ce_len);
+ put_le16(dst + 12, hcu->max_ce_len);
return 0;
}
@@ -834,7 +834,7 @@ static void
ble_hs_hci_cmd_body_le_lt_key_req_reply(const struct hci_lt_key_req_reply *hkr,
uint8_t *dst)
{
- htole16(dst + 0, hkr->conn_handle);
+ put_le16(dst + 0, hkr->conn_handle);
memcpy(dst + 2, hkr->long_term_key, sizeof hkr->long_term_key);
}
@@ -878,20 +878,20 @@ ble_hs_hci_cmd_build_le_lt_key_req_neg_reply(uint16_t conn_handle,
BLE_HCI_LT_KEY_REQ_NEG_REPLY_LEN, dst);
dst += BLE_HCI_CMD_HDR_LEN;
- htole16(dst + 0, conn_handle);
+ put_le16(dst + 0, conn_handle);
}
static void
ble_hs_hci_cmd_body_le_conn_param_reply(const struct hci_conn_param_reply *hcr,
uint8_t *dst)
{
- htole16(dst + 0, hcr->handle);
- htole16(dst + 2, hcr->conn_itvl_min);
- htole16(dst + 4, hcr->conn_itvl_max);
- htole16(dst + 6, hcr->conn_latency);
- htole16(dst + 8, hcr->supervision_timeout);
- htole16(dst + 10, hcr->min_ce_len);
- htole16(dst + 12, hcr->max_ce_len);
+ put_le16(dst + 0, hcr->handle);
+ put_le16(dst + 2, hcr->conn_itvl_min);
+ put_le16(dst + 4, hcr->conn_itvl_max);
+ put_le16(dst + 6, hcr->conn_latency);
+ put_le16(dst + 8, hcr->supervision_timeout);
+ put_le16(dst + 10, hcr->min_ce_len);
+ put_le16(dst + 12, hcr->max_ce_len);
}
void
@@ -914,13 +914,13 @@ ble_hs_hci_cmd_le_conn_param_reply(const struct hci_conn_param_reply *hcr)
uint8_t cmd[BLE_HCI_CONN_PARAM_REPLY_LEN];
int rc;
- htole16(cmd + 0, hcr->handle);
- htole16(cmd + 2, hcr->conn_itvl_min);
- htole16(cmd + 4, hcr->conn_itvl_max);
- htole16(cmd + 6, hcr->conn_latency);
- htole16(cmd + 8, hcr->supervision_timeout);
- htole16(cmd + 10, hcr->min_ce_len);
- htole16(cmd + 12, hcr->max_ce_len);
+ put_le16(cmd + 0, hcr->handle);
+ put_le16(cmd + 2, hcr->conn_itvl_min);
+ put_le16(cmd + 4, hcr->conn_itvl_max);
+ put_le16(cmd + 6, hcr->conn_latency);
+ put_le16(cmd + 8, hcr->supervision_timeout);
+ put_le16(cmd + 10, hcr->min_ce_len);
+ put_le16(cmd + 12, hcr->max_ce_len);
rc = ble_hs_hci_cmd_le_send(BLE_HCI_OCF_LE_REM_CONN_PARAM_RR,
BLE_HCI_CONN_PARAM_REPLY_LEN, cmd);
@@ -931,7 +931,7 @@ static void
ble_hs_hci_cmd_body_le_conn_param_neg_reply(
const struct hci_conn_param_neg_reply *hcn, uint8_t *dst)
{
- htole16(dst + 0, hcn->handle);
+ put_le16(dst + 0, hcn->handle);
dst[2] = hcn->reason;
}
@@ -983,9 +983,9 @@ static void
ble_hs_hci_cmd_body_le_start_encrypt(const struct hci_start_encrypt *cmd,
uint8_t *dst)
{
- htole16(dst + 0, cmd->connection_handle);
- htole64(dst + 2, cmd->random_number);
- htole16(dst + 10, cmd->encrypted_diversifier);
+ put_le16(dst + 0, cmd->connection_handle);
+ put_le64(dst + 2, cmd->random_number);
+ put_le16(dst + 10, cmd->encrypted_diversifier);
memcpy(dst + 12, cmd->long_term_key, sizeof cmd->long_term_key);
}
@@ -1018,7 +1018,7 @@ ble_hs_hci_cmd_build_le_start_encrypt(const struct hci_start_encrypt *cmd,
static void
ble_hs_hci_cmd_body_read_rssi(uint16_t handle, uint8_t *dst)
{
- htole16(dst, handle);
+ put_le16(dst, handle);
}
void
@@ -1052,9 +1052,9 @@ ble_hs_hci_cmd_body_set_data_len(uint16_t connection_handle,
return BLE_HS_EINVAL;
}
- htole16(dst + 0, connection_handle);
- htole16(dst + 2, tx_octets);
- htole16(dst + 4, tx_time);
+ put_le16(dst + 0, connection_handle);
+ put_le16(dst + 2, tx_octets);
+ put_le16(dst + 4, tx_time);
return 0;
}
@@ -1315,7 +1315,7 @@ ble_hs_hci_cmd_body_set_resolv_priv_addr_timeout(uint16_t timeout,
return BLE_ERR_INV_HCI_CMD_PARMS;
}
- htole16(dst, timeout);
+ put_le16(dst, timeout);
return 0;
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/host/src/ble_hs_hci_evt.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_hci_evt.c b/net/nimble/host/src/ble_hs_hci_evt.c
index 362b3c2..546e38b 100644
--- a/net/nimble/host/src/ble_hs_hci_evt.c
+++ b/net/nimble/host/src/ble_hs_hci_evt.c
@@ -139,7 +139,7 @@ ble_hs_hci_evt_disconn_complete(uint8_t event_code, uint8_t *data, int len)
}
evt.status = data[2];
- evt.connection_handle = le16toh(data + 3);
+ evt.connection_handle = get_le16(data + 3);
evt.reason = data[5];
ble_gap_rx_disconn_complete(&evt);
@@ -157,7 +157,7 @@ ble_hs_hci_evt_encrypt_change(uint8_t event_code, uint8_t *data, int len)
}
evt.status = data[2];
- evt.connection_handle = le16toh(data + 3);
+ evt.connection_handle = get_le16(data + 3);
evt.encryption_enabled = data[5];
ble_sm_enc_change_rx(&evt);
@@ -190,7 +190,7 @@ ble_hs_hci_evt_enc_key_refresh(uint8_t event_code, uint8_t *data, int len)
}
evt.status = data[2];
- evt.connection_handle = le16toh(data + 3);
+ evt.connection_handle = get_le16(data + 3);
ble_sm_enc_key_refresh_rx(&evt);
@@ -219,8 +219,8 @@ ble_hs_hci_evt_num_completed_pkts(uint8_t event_code, uint8_t *data, int len)
off++;
for (i = 0; i < num_handles; i++) {
- handle = le16toh(data + off + 2 * i);
- num_pkts = le16toh(data + off + 2 * num_handles + 2 * i);
+ handle = get_le16(data + off + 2 * i);
+ num_pkts = get_le16(data + off + 2 * num_handles + 2 * i);
/* XXX: Do something with these values. */
(void)handle;
@@ -273,7 +273,7 @@ ble_hs_hci_evt_le_conn_complete(uint8_t subevent, uint8_t *data, int len)
evt.subevent_code = data[0];
evt.status = data[1];
- evt.connection_handle = le16toh(data + 2);
+ evt.connection_handle = get_le16(data + 2);
evt.role = data[4];
evt.peer_addr_type = data[5];
memcpy(evt.peer_addr, data + 6, BLE_DEV_ADDR_LEN);
@@ -289,9 +289,9 @@ ble_hs_hci_evt_le_conn_complete(uint8_t subevent, uint8_t *data, int len)
memset(evt.peer_rpa, 0, BLE_DEV_ADDR_LEN);
}
- evt.conn_itvl = le16toh(data + 12 + extended_offset);
- evt.conn_latency = le16toh(data + 14 + extended_offset);
- evt.supervision_timeout = le16toh(data + 16 + extended_offset);
+ evt.conn_itvl = get_le16(data + 12 + extended_offset);
+ evt.conn_latency = get_le16(data + 14 + extended_offset);
+ evt.supervision_timeout = get_le16(data + 16 + extended_offset);
evt.master_clk_acc = data[18 + extended_offset];
if (evt.status == 0) {
@@ -480,10 +480,10 @@ ble_hs_hci_evt_le_conn_upd_complete(uint8_t subevent, uint8_t *data, int len)
evt.subevent_code = data[0];
evt.status = data[1];
- evt.connection_handle = le16toh(data + 2);
- evt.conn_itvl = le16toh(data + 4);
- evt.conn_latency = le16toh(data + 6);
- evt.supervision_timeout = le16toh(data + 8);
+ evt.connection_handle = get_le16(data + 2);
+ evt.conn_itvl = get_le16(data + 4);
+ evt.conn_latency = get_le16(data + 6);
+ evt.supervision_timeout = get_le16(data + 8);
if (evt.status == 0) {
if (evt.conn_itvl < BLE_HCI_CONN_ITVL_MIN ||
@@ -518,9 +518,9 @@ ble_hs_hci_evt_le_lt_key_req(uint8_t subevent, uint8_t *data, int len)
}
evt.subevent_code = data[0];
- evt.connection_handle = le16toh(data + 1);
- evt.random_number = le64toh(data + 3);
- evt.encrypted_diversifier = le16toh(data + 11);
+ evt.connection_handle = get_le16(data + 1);
+ evt.random_number = get_le64(data + 3);
+ evt.encrypted_diversifier = get_le16(data + 11);
ble_sm_ltk_req_rx(&evt);
@@ -537,11 +537,11 @@ ble_hs_hci_evt_le_conn_parm_req(uint8_t subevent, uint8_t *data, int len)
}
evt.subevent_code = data[0];
- evt.connection_handle = le16toh(data + 1);
- evt.itvl_min = le16toh(data + 3);
- evt.itvl_max = le16toh(data + 5);
- evt.latency = le16toh(data + 7);
- evt.timeout = le16toh(data + 9);
+ evt.connection_handle = get_le16(data + 1);
+ evt.itvl_min = get_le16(data + 3);
+ evt.itvl_max = get_le16(data + 5);
+ evt.latency = get_le16(data + 7);
+ evt.timeout = get_le16(data + 9);
if (evt.itvl_min < BLE_HCI_CONN_ITVL_MIN ||
evt.itvl_max > BLE_HCI_CONN_ITVL_MAX ||
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/host/src/ble_hs_hci_util.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_hci_util.c b/net/nimble/host/src/ble_hs_hci_util.c
index 2b3ffd3..e143e19 100644
--- a/net/nimble/host/src/ble_hs_hci_util.c
+++ b/net/nimble/host/src/ble_hs_hci_util.c
@@ -113,7 +113,7 @@ ble_hs_hci_util_read_rssi(uint16_t conn_handle, int8_t *out_rssi)
return BLE_HS_ECONTROLLER;
}
- params_conn_handle = le16toh(params + 0);
+ params_conn_handle = get_le16(params + 0);
if (params_conn_handle != conn_handle) {
return BLE_HS_ECONTROLLER;
}
@@ -167,7 +167,7 @@ ble_hs_hci_util_set_data_len(uint16_t conn_handle, uint16_t tx_octets,
return BLE_HS_ECONTROLLER;
}
- params_conn_handle = le16toh(params + 0);
+ params_conn_handle = get_le16(params + 0);
if (params_conn_handle != conn_handle) {
return BLE_HS_ECONTROLLER;
}
@@ -189,8 +189,8 @@ ble_hs_hci_util_data_hdr_strip(struct os_mbuf *om,
/* Strip HCI ACL data header from the front of the packet. */
os_mbuf_adj(om, BLE_HCI_DATA_HDR_SZ);
- out_hdr->hdh_handle_pb_bc = le16toh(&out_hdr->hdh_handle_pb_bc);
- out_hdr->hdh_len = le16toh(&out_hdr->hdh_len);
+ out_hdr->hdh_handle_pb_bc = get_le16(&out_hdr->hdh_handle_pb_bc);
+ out_hdr->hdh_len = get_le16(&out_hdr->hdh_len);
return 0;
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/31f894b6/net/nimble/host/src/ble_hs_startup.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_startup.c b/net/nimble/host/src/ble_hs_startup.c
index 20e5c48..f7d5956 100644
--- a/net/nimble/host/src/ble_hs_startup.c
+++ b/net/nimble/host/src/ble_hs_startup.c
@@ -67,7 +67,7 @@ ble_hs_startup_le_read_buf_sz_tx(void)
return BLE_HS_ECONTROLLER;
}
- pktlen = le16toh(ack_params + 0);
+ pktlen = get_le16(ack_params + 0);
max_pkts = ack_params[2];
rc = ble_hs_hci_set_buf_sz(pktlen, max_pkts);
[2/4] incubator-mynewt-core git commit: Add support for endianness
convertion function in endian.h
Posted by cc...@apache.org.
Add support for endianness convertion function in endian.h
Those macros implement interfaces to convert values between host and
big-/little-endian byte order as defined in standard endian.h header.
Also make exisiting hton* and ntoh* macros use same helpers as above
funtions.
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/c78ed8a3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/c78ed8a3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/c78ed8a3
Branch: refs/heads/develop
Commit: c78ed8a3f43119eff3d488ed44af544d8735c1ec
Parents: 31f894b
Author: Szymon Janc <sz...@codecoup.pl>
Authored: Fri Jan 20 19:36:55 2017 +0100
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Jan 24 16:03:30 2017 -0800
----------------------------------------------------------------------
kernel/os/include/os/endian.h | 143 ++++++++++++++++++++++++++++++++-----
1 file changed, 126 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c78ed8a3/kernel/os/include/os/endian.h
----------------------------------------------------------------------
diff --git a/kernel/os/include/os/endian.h b/kernel/os/include/os/endian.h
index 959d74c..8786f40 100644
--- a/kernel/os/include/os/endian.h
+++ b/kernel/os/include/os/endian.h
@@ -26,6 +26,33 @@
extern "C" {
#endif
+/* Internal helpers */
+#ifndef __bswap_64
+#define __bswap_64(x) ((uint64_t) \
+ ((((x) & 0xff00000000000000ull) >> 56) | \
+ (((x) & 0x00ff000000000000ull) >> 40) | \
+ (((x) & 0x0000ff0000000000ull) >> 24) | \
+ (((x) & 0x000000ff00000000ull) >> 8) | \
+ (((x) & 0x00000000ff000000ull) << 8) | \
+ (((x) & 0x0000000000ff0000ull) << 24) | \
+ (((x) & 0x000000000000ff00ull) << 40) | \
+ (((x) & 0x00000000000000ffull) << 56)))
+#endif
+
+#ifndef __bswap_32
+#define __bswap_32(x) ((uint32_t) \
+ ((((x) & 0xff000000) >> 24) | \
+ (((x) & 0x00ff0000) >> 8) | \
+ (((x) & 0x0000ff00) << 8) | \
+ (((x) & 0x000000ff) << 24)))
+#endif
+
+#ifndef __bswap_16
+#define __bswap_16(x) ((uint16_t) \
+ ((((x) & 0xff00) >> 8) | \
+ (((x) & 0x00ff) << 8)))
+#endif
+
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#ifndef ntohll
@@ -52,18 +79,58 @@ extern "C" {
#define htons(x) ((uint16_t)(x))
#endif
+#ifndef htobe16
+#define htobe16(x) ((uint16_t)(x))
+#endif
+
+#ifndef htole16
+#define htole16(x) __bswap_16 (x)
+#endif
+
+#ifndef be16toh
+#define be16toh(x) ((uint16_t)(x))
+#endif
+
+#ifndef le16toh
+#define le16toh(x) __bswap_16 (x)
+#endif
+
+#ifndef htobe32
+#define htobe32(x) ((uint32_t)(x))
+#endif
+
+#ifndef htole32
+#define htole32(x) __bswap_32 (x)
+#endif
+
+#ifndef be32toh
+#define be32toh(x) ((uint32_t)(x))
+#endif
+
+#ifndef le32toh
+#define le32toh(x) __bswap_32 (x)
+#endif
+
+#ifndef htobe64
+#define htobe64(x) ((uint64_t)(x))
+#endif
+
+#ifndef htole64
+#define htole64(x) __bswap_64 (x)
+#endif
+
+#ifndef be64toh
+#define be64toh(x) ((uint64_t)(x))
+#endif
+
+#ifndef le64toh
+#define le64toh(x) __bswap_64 (x)
+#endif
+
#else
#ifndef ntohll
-#define ntohll(x) ((uint64_t) \
- ((((x) & 0xff00000000000000ull) >> 56) | \
- (((x) & 0x00ff000000000000ull) >> 40) | \
- (((x) & 0x0000ff0000000000ull) >> 24) | \
- (((x) & 0x000000ff00000000ull) >> 8) | \
- (((x) & 0x00000000ff000000ull) << 8) | \
- (((x) & 0x0000000000ff0000ull) << 24) | \
- (((x) & 0x000000000000ff00ull) << 40) | \
- (((x) & 0x00000000000000ffull) << 56)))
+#define ntohll(x) __bswap_64(x)
#endif
#ifndef htonll
@@ -71,11 +138,7 @@ extern "C" {
#endif
#ifndef ntohl
-#define ntohl(x) ((uint32_t) \
- ((((x) & 0xff000000) >> 24) | \
- (((x) & 0x00ff0000) >> 8) | \
- (((x) & 0x0000ff00) << 8) | \
- (((x) & 0x000000ff) << 24)))
+#define ntohl(x) __bswap_32(x)
#endif
#ifndef htonl
@@ -83,15 +146,61 @@ extern "C" {
#endif
#ifndef htons
-#define htons(x) ((uint16_t) \
- ((((x) & 0xff00) >> 8) | \
- (((x) & 0x00ff) << 8)))
+#define htons(x) __bswap_16(x)
#endif
#ifndef ntohs
#define ntohs htons
#endif
+#ifndef htobe16
+#define htobe16(x) __bswap_16(x)
+#endif
+
+#ifndef htole16
+#define htole16(x) ((uint16_t)(x))
+#endif
+
+#ifndef be16toh
+#define be16toh(x) __bswap_16(x)
+#endif
+
+#ifndef le16toh
+#define le16toh(x) ((uint16_t)(x))
+#endif
+
+#ifndef htobe32
+#define htobe32(x) __bswap_32(x)
+#endif
+
+#ifndef htole32
+#define htole32(x) ((uint32_t)(x))
+#endif
+
+#ifndef be32toh
+#define be32toh(x) __bswap_32(x)
+#endif
+
+#ifndef le32toh
+#define le32toh(x) ((uint32_t)(x))
+#endif
+
+#ifndef htobe64
+#define htobe64(x) __builtin_bswap64(x)
+#endif
+
+#ifndef htole64
+#define htole64(x) ((uint64_t)(x))
+#endif
+
+#ifndef be64toh
+#define be64toh(x) __builtin_bswap64(x)
+#endif
+
+#ifndef le64toh
+#define le64toh(x) ((uint64_t)(x))
+#endif
+
#endif
#ifdef __cplusplus
}