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 <ccollins47...@gmail.com> Authored: Thu Nov 19 13:08:05 2015 -0800 Committer: Christopher Collins <ccollins47...@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