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/12/24 00:34:34 UTC

[5/6] incubator-mynewt-larva git commit: Use a different set of op codes for ATT callbacks.

Use a different set of op codes for ATT callbacks.


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/51bd2b46
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/51bd2b46
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/51bd2b46

Branch: refs/heads/master
Commit: 51bd2b46d2e44f76c42e932a7a66bf0d0ccc9461
Parents: 936b9e8
Author: Christopher Collins <cc...@gmail.com>
Authored: Wed Dec 23 14:31:12 2015 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Wed Dec 23 15:33:49 2015 -0800

----------------------------------------------------------------------
 net/nimble/host/include/host/ble_att.h      |  3 +++
 net/nimble/host/src/ble_att_svr.c           | 12 ++++++------
 net/nimble/host/src/ble_gatts.c             |  2 +-
 net/nimble/host/src/test/ble_att_svr_test.c | 13 ++++++-------
 project/hostctlrtest/src/main.c             |  4 ++--
 5 files changed, 18 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/51bd2b46/net/nimble/host/include/host/ble_att.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/ble_att.h b/net/nimble/host/include/host/ble_att.h
index 6522f0d..52046c5 100644
--- a/net/nimble/host/include/host/ble_att.h
+++ b/net/nimble/host/include/host/ble_att.h
@@ -77,6 +77,9 @@ union ble_att_svr_access_ctxt {
 #define HA_FLAG_AUTHENTICATION_REQ          (1 << 4)
 #define HA_FLAG_AUTHORIZATION_REQ           (1 << 5)
 
+#define BLE_ATT_ACCESS_OP_READ              1
+#define BLE_ATT_ACCESS_OP_WRITE             2
+
 /**
  * Handles a host attribute request.
  *

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/51bd2b46/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 17393f8..932e064 100644
--- a/net/nimble/host/src/ble_att_svr.c
+++ b/net/nimble/host/src/ble_att_svr.c
@@ -785,7 +785,7 @@ ble_att_svr_fill_type_value(struct ble_att_find_type_value_req *req,
             uuid16 = ble_hs_uuid_16bit(ha->ha_uuid);
             if (uuid16 == req->bavq_attr_type) {
                 rc = ha->ha_cb(ha->ha_handle_id, ha->ha_uuid,
-                               BLE_ATT_OP_READ_REQ, &arg, ha->ha_cb_arg);
+                               BLE_ATT_ACCESS_OP_READ, &arg, ha->ha_cb_arg);
                 if (rc != 0) {
                     rc = BLE_HS_EAPP;
                     goto done;
@@ -1010,7 +1010,7 @@ ble_att_svr_tx_read_type_rsp(struct ble_hs_conn *conn,
             entry->ha_handle_id <= req->batq_end_handle) {
 
             rc = entry->ha_cb(entry->ha_handle_id, entry->ha_uuid,
-                              BLE_ATT_OP_READ_REQ, &arg, entry->ha_cb_arg);
+                              BLE_ATT_ACCESS_OP_READ, &arg, entry->ha_cb_arg);
             if (rc != 0) {
                 *att_err = BLE_ATT_ERR_UNLIKELY;
                 *err_handle = entry->ha_handle_id;
@@ -1233,7 +1233,7 @@ ble_att_svr_rx_read(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
     }
 
     rc = entry->ha_cb(entry->ha_handle_id, entry->ha_uuid,
-                      BLE_ATT_OP_READ_REQ, &arg, entry->ha_cb_arg);
+                      BLE_ATT_ACCESS_OP_READ, &arg, entry->ha_cb_arg);
     if (rc != 0) {
         att_err = BLE_ATT_ERR_UNLIKELY;
         err_handle = req.barq_handle;
@@ -1275,7 +1275,7 @@ ble_att_svr_service_uuid(struct ble_att_svr_entry *entry, uint16_t *uuid16,
     int rc;
 
     rc = entry->ha_cb(entry->ha_handle_id, entry->ha_uuid,
-                      BLE_ATT_OP_READ_REQ, &arg, entry->ha_cb_arg);
+                      BLE_ATT_ACCESS_OP_READ, &arg, entry->ha_cb_arg);
     if (rc != 0) {
         return rc;
     }
@@ -1651,7 +1651,7 @@ ble_att_svr_rx_write(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
     os_mbuf_copydata(*rxom, 0, arg.ahc_write.attr_len,
                      arg.ahc_write.attr_data);
     att_err = entry->ha_cb(entry->ha_handle_id, entry->ha_uuid,
-                           BLE_ATT_OP_WRITE_REQ, &arg, entry->ha_cb_arg);
+                           BLE_ATT_ACCESS_OP_WRITE, &arg, entry->ha_cb_arg);
     if (att_err != 0) {
         err_handle = req.bawq_handle;
         rc = BLE_HS_EAPP;
@@ -1818,7 +1818,7 @@ ble_att_svr_prep_write(struct ble_att_svr_conn *basc, uint16_t *err_handle)
             arg.ahc_write.attr_data = ble_att_svr_flat_buf;
             arg.ahc_write.attr_len = buf_off;
             rc = attr->ha_cb(attr->ha_handle_id, attr->ha_uuid,
-                             BLE_ATT_OP_WRITE_REQ, &arg, attr->ha_cb_arg);
+                             BLE_ATT_ACCESS_OP_WRITE, &arg, attr->ha_cb_arg);
             if (rc != 0) {
                 *err_handle = entry->bape_handle;
                 return BLE_ATT_ERR_UNLIKELY;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/51bd2b46/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 7740610..3c71ba1 100644
--- a/net/nimble/host/src/ble_gatts.c
+++ b/net/nimble/host/src/ble_gatts.c
@@ -36,7 +36,7 @@ ble_gatts_svc_access(uint16_t handle_id, uint8_t *uuid128, uint8_t op,
 {
     const struct ble_gatt_svc_def *svc;
 
-    assert(op == BLE_ATT_OP_READ_REQ);
+    assert(op == BLE_ATT_ACCESS_OP_READ);
 
     svc = arg;
     ctxt->ahc_read.attr_data = svc->uuid128;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/51bd2b46/net/nimble/host/src/test/ble_att_svr_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_att_svr_test.c b/net/nimble/host/src/test/ble_att_svr_test.c
index 45720fe..3562210 100644
--- a/net/nimble/host/src/test/ble_att_svr_test.c
+++ b/net/nimble/host/src/test/ble_att_svr_test.c
@@ -63,7 +63,7 @@ ble_att_svr_test_misc_attr_fn_r_1(uint16_t handle_id, uint8_t *uuid128,
                                   void *arg)
 {
     switch (op) {
-    case BLE_ATT_OP_READ_REQ:
+    case BLE_ATT_ACCESS_OP_READ:
         ctxt->ahc_read.attr_data = ble_att_svr_test_attr_r_1;
         ctxt->ahc_read.attr_len = ble_att_svr_test_attr_r_1_len;
         return 0;
@@ -80,7 +80,7 @@ ble_att_svr_test_misc_attr_fn_r_2(uint16_t handle_id, uint8_t *uuid128,
                                   void *arg)
 {
     switch (op) {
-    case BLE_ATT_OP_READ_REQ:
+    case BLE_ATT_ACCESS_OP_READ:
         ctxt->ahc_read.attr_data = ble_att_svr_test_attr_r_2;
         ctxt->ahc_read.attr_len = ble_att_svr_test_attr_r_2_len;
         return 0;
@@ -124,7 +124,7 @@ ble_att_svr_test_misc_attr_fn_r_group(uint16_t handle_id, uint8_t *uuid128,
 
     static uint8_t zeros[14];
 
-    if (op != BLE_ATT_OP_READ_REQ) {
+    if (op != BLE_ATT_ACCESS_OP_READ) {
         return -1;
     }
 
@@ -227,7 +227,7 @@ ble_att_svr_test_misc_attr_fn_w_1(uint16_t handle_id, uint8_t *uuid128,
                                   void *arg)
 {
     switch (op) {
-    case BLE_ATT_OP_WRITE_REQ:
+    case BLE_ATT_ACCESS_OP_WRITE:
         memcpy(ble_att_svr_test_attr_w_1, ctxt->ahc_write.attr_data,
                ctxt->ahc_write.attr_len);
         ble_att_svr_test_attr_w_1_len = ctxt->ahc_write.attr_len;
@@ -245,7 +245,7 @@ ble_att_svr_test_misc_attr_fn_w_2(uint16_t handle_id, uint8_t *uuid128,
                                   void *arg)
 {
     switch (op) {
-    case BLE_ATT_OP_WRITE_REQ:
+    case BLE_ATT_ACCESS_OP_WRITE:
         memcpy(ble_att_svr_test_attr_w_2, ctxt->ahc_write.attr_data,
                ctxt->ahc_write.attr_len);
         ble_att_svr_test_attr_w_2_len = ctxt->ahc_write.attr_len;
@@ -292,8 +292,7 @@ ble_att_svr_test_misc_verify_tx_err_rsp(struct ble_l2cap_chan *chan,
     TEST_ASSERT(rsp.baep_error_code == error_code);
 
     /* Remove the error response from the buffer. */
-    os_mbuf_adj(ble_hs_test_util_prev_tx,
-                BLE_ATT_ERROR_RSP_SZ);
+    os_mbuf_adj(ble_hs_test_util_prev_tx, BLE_ATT_ERROR_RSP_SZ);
 }
 
 static void

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/51bd2b46/project/hostctlrtest/src/main.c
----------------------------------------------------------------------
diff --git a/project/hostctlrtest/src/main.c b/project/hostctlrtest/src/main.c
index be88129..87051a9 100755
--- a/project/hostctlrtest/src/main.c
+++ b/project/hostctlrtest/src/main.c
@@ -204,11 +204,11 @@ static uint16_t hostctlrtest_data2_handle;
 
 static int
 hostctlrtest_attr_cb(uint16_t handle_id, uint8_t *uuid128, uint8_t op,
-                     union ble_att_svr_handle_ctxt *ctxt, void *arg)
+                     union ble_att_svr_access_ctxt *ctxt, void *arg)
 {
     static uint8_t buf[128];
 
-    assert(op == BLE_ATT_OP_READ_REQ);
+    assert(op == BLE_ATT_ACCESS_OP_READ);
 
     if (handle_id == hostctlrtest_service_handle) {
         console_printf("reading service declaration");