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 2015/11/19 23:45:04 UTC

[1/2] incubator-mynewt-larva git commit: att find type value parse / write cmds.

Repository: incubator-mynewt-larva
Updated Branches:
  refs/heads/master 03abc47b0 -> 95ec4cafe


att find type value parse / write cmds.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/e52f4631
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/e52f4631
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/e52f4631

Branch: refs/heads/master
Commit: e52f46315d36bc29e2ab538a99e4d9a78b632f23
Parents: 03abc47
Author: Christopher Collins <cc...@gmail.com>
Authored: Thu Nov 19 13:08:05 2015 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Thu Nov 19 13:08:05 2015 -0800

----------------------------------------------------------------------
 net/nimble/host/src/ble_hs_att_cmd.c | 44 +++++++++++++++++++++++++++++++
 net/nimble/host/src/ble_hs_att_cmd.h | 31 ++++++++++++++++++++++
 net/nimble/host/src/ble_l2cap.h      |  2 +-
 3 files changed, 76 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/e52f4631/net/nimble/host/src/ble_hs_att_cmd.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_att_cmd.c b/net/nimble/host/src/ble_hs_att_cmd.c
index d547f3d..f811100 100644
--- a/net/nimble/host/src/ble_hs_att_cmd.c
+++ b/net/nimble/host/src/ble_hs_att_cmd.c
@@ -190,6 +190,50 @@ ble_hs_att_find_info_rsp_write(void *payload, int len,
 }
 
 int
+ble_hs_att_find_type_value_req_parse(
+    void *payload, int len, struct ble_hs_att_find_type_value_req *req)
+{
+    uint8_t *u8ptr;
+
+    if (len < BLE_HS_ATT_FIND_TYPE_VALUE_REQ_MIN_SZ) {
+        return EMSGSIZE;
+    }
+
+    u8ptr = payload;
+
+    req->bhavq_op = u8ptr[0];
+    req->bhavq_start_handle = le16toh(u8ptr + 1);
+    req->bhavq_end_handle = le16toh(u8ptr + 3);
+    req->bhavq_attr_type = le16toh(u8ptr + 5);
+
+    if (req->bhavq_op != BLE_HS_ATT_OP_FIND_TYPE_VALUE_REQ) {
+        return EINVAL;
+    }
+
+    return 0;
+}
+
+int
+ble_hs_att_find_type_value_req_write(
+    void *payload, int len, struct ble_hs_att_find_type_value_req *req)
+{
+    uint8_t *u8ptr;
+
+    if (len < BLE_HS_ATT_FIND_TYPE_VALUE_REQ_MIN_SZ) {
+        return EMSGSIZE;
+    }
+
+    u8ptr = payload;
+
+    u8ptr[0] = req->bhavq_op;
+    htole16(u8ptr + 1, req->bhavq_start_handle);
+    htole16(u8ptr + 3, req->bhavq_end_handle);
+    htole16(u8ptr + 5, req->bhavq_attr_type);
+
+    return 0;
+}
+
+int
 ble_hs_att_read_req_parse(void *payload, int len,
                           struct ble_hs_att_read_req *req)
 {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/e52f4631/net/nimble/host/src/ble_hs_att_cmd.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_att_cmd.h b/net/nimble/host/src/ble_hs_att_cmd.h
index 5694057..ba950a9 100644
--- a/net/nimble/host/src/ble_hs_att_cmd.h
+++ b/net/nimble/host/src/ble_hs_att_cmd.h
@@ -22,6 +22,8 @@ struct ble_l2cap_chan;
 #define BLE_HS_ATT_OP_MTU_RSP               0x03
 #define BLE_HS_ATT_OP_FIND_INFO_REQ         0x04
 #define BLE_HS_ATT_OP_FIND_INFO_RSP         0x05
+#define BLE_HS_ATT_OP_FIND_TYPE_VALUE_REQ   0x06
+#define BLE_HS_ATT_OP_FIND_TYPE_VALUE_RSP   0x07
 #define BLE_HS_ATT_OP_READ_REQ              0x0a
 #define BLE_HS_ATT_OP_READ_RSP              0x0b
 #define BLE_HS_ATT_OP_WRITE_REQ             0x12
@@ -90,6 +92,31 @@ struct ble_hs_att_find_info_rsp {
  * | Parameter                          | Size (octets)     |
  * +------------------------------------+-------------------+
  * | Attribute Opcode                   | 1                 |
+ * | Starting Handle                    | 2                 |
+ * | Ending Handle                      | 2                 |
+ * | Attribute Type                     | 2                 |
+ * | Attribute Value                    | 0 to (ATT_MTU-7)  |
+ */
+#define BLE_HS_ATT_FIND_TYPE_VALUE_REQ_MIN_SZ   7
+struct ble_hs_att_find_type_value_req {
+    uint8_t bhavq_op;
+    uint16_t bhavq_start_handle;
+    uint16_t bhavq_end_handle;
+    uint16_t bhavq_attr_type;
+};
+
+/**
+ * | Parameter                          | Size (octets)     |
+ * +------------------------------------+-------------------+
+ * | Attribute Opcode                   | 1                 |
+ * | Information Data                   | 4 to (ATT_MTU-1)  |
+ */
+#define BLE_HS_ATT_FIND_TYPE_VALUE_RSP_MIN_SZ   1
+
+/**
+ * | Parameter                          | Size (octets)     |
+ * +------------------------------------+-------------------+
+ * | Attribute Opcode                   | 1                 |
  * | Attribute Handle                   | 2                 |
  */
 #define BLE_HS_ATT_READ_REQ_SZ              3
@@ -137,6 +164,10 @@ int ble_hs_att_find_info_rsp_parse(void *payload, int len,
                                    struct ble_hs_att_find_info_rsp *rsp);
 int ble_hs_att_find_info_rsp_write(void *payload, int len,
                                    struct ble_hs_att_find_info_rsp *rsp);
+int ble_hs_att_find_type_value_req_parse(
+    void *payload, int len, struct ble_hs_att_find_type_value_req *req);
+int ble_hs_att_find_type_value_req_write(
+    void *payload, int len, struct ble_hs_att_find_type_value_req *req);
 int ble_hs_att_read_req_parse(void *payload, int len,
                               struct ble_hs_att_read_req *req);
 int ble_hs_att_read_req_write(void *payload, int len,

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/e52f4631/net/nimble/host/src/ble_l2cap.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_l2cap.h b/net/nimble/host/src/ble_l2cap.h
index f6cd5cc..0cad13f 100644
--- a/net/nimble/host/src/ble_l2cap.h
+++ b/net/nimble/host/src/ble_l2cap.h
@@ -23,8 +23,8 @@
 struct ble_hs_conn;
 struct hci_data_hdr;
 
-#define BLE_L2CAP_CID_SIG   1
 #define BLE_L2CAP_CID_ATT   4
+#define BLE_L2CAP_CID_SIG   5
 
 #define BLE_L2CAP_HDR_SZ    4
 


[2/2] incubator-mynewt-larva git commit: Change byte-swapping fns to use void pointers.

Posted by cc...@apache.org.
Change byte-swapping fns to use void pointers.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/95ec4caf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/95ec4caf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/95ec4caf

Branch: refs/heads/master
Commit: 95ec4cafea82a954c0a87ff23fb9b56142dc0429
Parents: e52f463
Author: Christopher Collins <cc...@gmail.com>
Authored: Thu Nov 19 14:43:44 2015 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Thu Nov 19 14:43:44 2015 -0800

----------------------------------------------------------------------
 net/nimble/include/nimble/ble.h | 12 +++---
 net/nimble/src/util.c           | 84 +++++++++++++++++++++---------------
 2 files changed, 55 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/95ec4caf/net/nimble/include/nimble/ble.h
----------------------------------------------------------------------
diff --git a/net/nimble/include/nimble/ble.h b/net/nimble/include/nimble/ble.h
index 71229f2..e7d5c2f 100644
--- a/net/nimble/include/nimble/ble.h
+++ b/net/nimble/include/nimble/ble.h
@@ -62,12 +62,12 @@ 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 htole16(uint8_t *buf, uint16_t x);
-void htole32(uint8_t *buf, uint32_t x);
-void htole64(uint8_t *buf, uint64_t x);
-uint16_t le16toh(uint8_t *buf);
-uint32_t le32toh(uint8_t *buf);
-uint64_t le64toh(uint8_t *buf);
+void htole16(void *buf, uint16_t x);
+void htole32(void *buf, uint32_t x);
+void htole64(void *buf, uint64_t x);
+uint16_t le16toh(void *buf);
+uint32_t le32toh(void *buf);
+uint64_t le64toh(void *buf);
 /* XXX */
 
 /* BLE Error Codes (Core v4.2 Vol 2 part D) */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/95ec4caf/net/nimble/src/util.c
----------------------------------------------------------------------
diff --git a/net/nimble/src/util.c b/net/nimble/src/util.c
index 98948a4..d67cead 100644
--- a/net/nimble/src/util.c
+++ b/net/nimble/src/util.c
@@ -17,72 +17,86 @@
 #include "nimble/ble.h"
 
 void
-htole16(uint8_t *buf, uint16_t x)
+htole16(void *buf, uint16_t x)
 {
-    buf[0] = (uint8_t)x;
-    buf[1] = (uint8_t)(x >> 8);
+    uint8_t *u8ptr;
+
+    u8ptr = buf;
+    u8ptr[0] = (uint8_t)x;
+    u8ptr[1] = (uint8_t)(x >> 8);
 }
 
 void
-htole32(uint8_t *buf, uint32_t x)
+htole32(void *buf, uint32_t x)
 {
-    buf[0] = (uint8_t)x;
-    buf[1] = (uint8_t)(x >> 8);
-    buf[2] = (uint8_t)(x >> 16);
-    buf[3] = (uint8_t)(x >> 24);
+    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
-htole64(uint8_t *buf, uint64_t x)
+htole64(void *buf, uint64_t x)
 {
-    buf[0] = (uint8_t)x;
-    buf[1] = (uint8_t)(x >> 8);
-    buf[2] = (uint8_t)(x >> 16);
-    buf[3] = (uint8_t)(x >> 24);
-    buf[4] = (uint8_t)(x >> 32);
-    buf[5] = (uint8_t)(x >> 40);
-    buf[6] = (uint8_t)(x >> 48);
-    buf[7] = (uint8_t)(x >> 56);
+    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
-le16toh(uint8_t *buf)
+le16toh(void *buf)
 {
     uint16_t x;
+    uint8_t *u8ptr;
 
-    x = buf[0];
-    x |= (uint16_t)buf[1] << 8;
+    u8ptr = buf;
+    x = u8ptr[0];
+    x |= (uint16_t)u8ptr[1] << 8;
 
     return x;
 }
 
 uint32_t
-le32toh(uint8_t *buf)
+le32toh(void *buf)
 {
     uint32_t x;
+    uint8_t *u8ptr;
 
-    x = buf[0];
-    x |= (uint32_t)buf[1] << 8;
-    x |= (uint32_t)buf[2] << 16;
-    x |= (uint32_t)buf[3] << 24;
+    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
-le64toh(uint8_t *buf)
+le64toh(void *buf)
 {
     uint64_t x;
+    uint8_t *u8ptr;
 
-    x = buf[0];
-    x |= (uint64_t)buf[1] << 8;
-    x |= (uint64_t)buf[2] << 16;
-    x |= (uint64_t)buf[3] << 24;
-    x |= (uint64_t)buf[4] << 32;
-    x |= (uint64_t)buf[5] << 40;
-    x |= (uint64_t)buf[6] << 48;
-    x |= (uint64_t)buf[7] << 54;
+    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] << 54;
 
     return x;
 }
-