Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 56e711b8f -> ac1496259


nimble: fix execute write flags

Changed the definition and interpretation of exec write flags
to similar to Bluez.


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

Branch: refs/heads/develop
Commit: 48bce399c8eda704abe2d81d3c0f038ca8d61241
Parents: aa27be5
Author: Michał Narajowski <[email protected]>
Authored: Tue Dec 20 15:24:35 2016 +0100
Committer: Michał Narajowski <[email protected]>
Committed: Fri Dec 30 11:21:42 2016 +0100

----------------------------------------------------------------------
 net/nimble/host/src/ble_att_clt.c              |  4 ----
 net/nimble/host/src/ble_att_cmd_priv.h         |  4 ++--
 net/nimble/host/src/ble_att_svr.c              |  2 +-
 net/nimble/host/src/ble_gattc.c                |  8 ++++----
 net/nimble/host/test/src/ble_att_clt_test.c    |  8 ++++----
 net/nimble/host/test/src/ble_att_svr_test.c    | 20 ++++++++++----------
 net/nimble/host/test/src/ble_gatt_write_test.c | 10 +++++-----
 7 files changed, 26 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/48bce399/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 d703cb4..e7cd69c 100644
--- a/net/nimble/host/src/ble_att_clt.c
+++ b/net/nimble/host/src/ble_att_clt.c
@@ -1048,10 +1048,6 @@ ble_att_clt_tx_exec_write(uint16_t conn_handle,
     struct os_mbuf *txom;
     int rc;
 
-    if ((req->baeq_flags & BLE_ATT_EXEC_WRITE_F_RESERVED) != 0) {
-        return BLE_HS_EINVAL;
-    }
-
     rc = ble_att_clt_init_req(BLE_ATT_EXEC_WRITE_REQ_SZ, &txom);
     if (rc != 0) {
         return rc;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/48bce399/net/nimble/host/src/ble_att_cmd_priv.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_att_cmd_priv.h 
b/net/nimble/host/src/ble_att_cmd_priv.h
index f954340..356b566 100644
--- a/net/nimble/host/src/ble_att_cmd_priv.h
+++ b/net/nimble/host/src/ble_att_cmd_priv.h
@@ -269,8 +269,8 @@ struct ble_att_exec_write_req {
     uint8_t baeq_flags;
 } __attribute__((packed));
 
-#define BLE_ATT_EXEC_WRITE_F_CONFIRM    0x01
-#define BLE_ATT_EXEC_WRITE_F_RESERVED   0xfe
+#define BLE_ATT_EXEC_WRITE_F_CANCEL     0x00
+#define BLE_ATT_EXEC_WRITE_F_EXECUTE    0x01
 
 /**
  * | Parameter                          | Size (octets)     |

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/48bce399/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 656d432..3d85bd1 100644
--- a/net/nimble/host/src/ble_att_svr.c
+++ b/net/nimble/host/src/ble_att_svr.c
@@ -2577,7 +2577,7 @@ done:
         SLIST_INIT(&conn->bhc_att_svr.basc_prep_list);
         ble_hs_unlock();
 
-        if (req.baeq_flags & BLE_ATT_EXEC_WRITE_F_CONFIRM) {
+        if (req.baeq_flags) {
             /* Perform attribute writes. */
             att_err = ble_att_svr_prep_write(conn_handle, &prep_list,
                                              &err_handle);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/48bce399/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 6eb0606..c99facc 100644
--- a/net/nimble/host/src/ble_gattc.c
+++ b/net/nimble/host/src/ble_gattc.c
@@ -3919,7 +3919,7 @@ ble_gattc_write_long_tx(struct ble_gattc_proc *proc)
                         proc->write_long.attr.offset);
 
     if (write_len <= 0) {
-        exec_req.baeq_flags = BLE_ATT_EXEC_WRITE_F_CONFIRM;
+        exec_req.baeq_flags = BLE_ATT_EXEC_WRITE_F_EXECUTE;
         rc = ble_att_clt_tx_exec_write(proc->conn_handle, &exec_req);
         goto done;
     }
@@ -3988,7 +3988,7 @@ ble_gattc_write_long_err(struct ble_gattc_proc *proc, int 
status,
         proc->write_long.attr.offset <
             OS_MBUF_PKTLEN(proc->write_long.attr.om)) {
 
-        exec_req.baeq_flags = 0;
+        exec_req.baeq_flags = BLE_ATT_EXEC_WRITE_F_CANCEL;
         ble_att_clt_tx_exec_write(proc->conn_handle, &exec_req);
     }
 
@@ -4224,7 +4224,7 @@ ble_gattc_write_reliable_tx(struct ble_gattc_proc *proc)
     attr_idx = proc->write_reliable.cur_attr;
 
     if (attr_idx >= proc->write_reliable.num_attrs) {
-        exec_req.baeq_flags = BLE_ATT_EXEC_WRITE_F_CONFIRM;
+        exec_req.baeq_flags = BLE_ATT_EXEC_WRITE_F_EXECUTE;
         rc = ble_att_clt_tx_exec_write(proc->conn_handle, &exec_req);
         goto done;
     }
@@ -4303,7 +4303,7 @@ ble_gattc_write_reliable_err(struct ble_gattc_proc *proc, 
int status,
     if (proc->write_reliable.cur_attr > 0 &&
         proc->write_reliable.cur_attr < proc->write_reliable.num_attrs) {
 
-        exec_req.baeq_flags = 0;
+        exec_req.baeq_flags = BLE_ATT_EXEC_WRITE_F_CANCEL;
         ble_att_clt_tx_exec_write(proc->conn_handle, &exec_req);
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/48bce399/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 a260a75..c34df53 100644
--- a/net/nimble/host/test/src/ble_att_clt_test.c
+++ b/net/nimble/host/test/src/ble_att_clt_test.c
@@ -516,13 +516,13 @@ TEST_CASE(ble_att_clt_test_tx_exec_write)
     conn_handle = ble_att_clt_test_misc_init();
 
     /*** Success. */
-    ble_att_clt_test_misc_exec_good(0);
-    ble_att_clt_test_misc_exec_good(BLE_ATT_EXEC_WRITE_F_CONFIRM);
+    ble_att_clt_test_misc_exec_good(BLE_ATT_EXEC_WRITE_F_CANCEL);
+    ble_att_clt_test_misc_exec_good(BLE_ATT_EXEC_WRITE_F_EXECUTE);
 
-    /*** Error: invalid flags value. */
+    /*** Success: nonzero == execute. */
     req.baeq_flags = 0x02;
     rc = ble_att_clt_tx_exec_write(conn_handle, &req);
-    TEST_ASSERT(rc == BLE_HS_EINVAL);
+    TEST_ASSERT(rc == 0);
 }
 
 TEST_CASE(ble_att_clt_test_tx_mtu)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/48bce399/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 d2fbe63..25b6a1d 100644
--- a/net/nimble/host/test/src/ble_att_svr_test.c
+++ b/net/nimble/host/test/src/ble_att_svr_test.c
@@ -1623,7 +1623,7 @@ TEST_CASE(ble_att_svr_test_prep_write)
         0xabae, BLE_ATT_F_WRITE, 6, ble_att_svr_test_misc_attr_fn_w_fail);
 
     /*** Empty write succeeds. */
-    ble_att_svr_test_misc_exec_write(conn_handle, BLE_ATT_EXEC_WRITE_F_CONFIRM,
+    ble_att_svr_test_misc_exec_write(conn_handle, BLE_ATT_EXEC_WRITE_F_EXECUTE,
                                      0, 0);
 
     /*** Empty cancel succeeds. */
@@ -1657,7 +1657,7 @@ TEST_CASE(ble_att_svr_test_prep_write)
 
     /*** Failure for write starting at nonzero offset. */
     ble_att_svr_test_misc_prep_write(conn_handle, 1, 1, data, 10, 0);
-    ble_att_svr_test_misc_exec_write(conn_handle, BLE_ATT_EXEC_WRITE_F_CONFIRM,
+    ble_att_svr_test_misc_exec_write(conn_handle, BLE_ATT_EXEC_WRITE_F_EXECUTE,
                                      BLE_ATT_ERR_INVALID_OFFSET, 1);
     ble_att_svr_test_misc_verify_w_1(NULL, 0);
 
@@ -1669,7 +1669,7 @@ TEST_CASE(ble_att_svr_test_prep_write)
     /*** Failure for write with gap. */
     ble_att_svr_test_misc_prep_write(conn_handle, 1, 0, data, 10, 0);
     ble_att_svr_test_misc_prep_write(conn_handle, 1, 11, data, 10, 0);
-    ble_att_svr_test_misc_exec_write(conn_handle, BLE_ATT_EXEC_WRITE_F_CONFIRM,
+    ble_att_svr_test_misc_exec_write(conn_handle, BLE_ATT_EXEC_WRITE_F_EXECUTE,
                                      BLE_ATT_ERR_INVALID_OFFSET, 1);
     ble_att_svr_test_misc_verify_w_1(NULL, 0);
 
@@ -1683,14 +1683,14 @@ TEST_CASE(ble_att_svr_test_prep_write)
     ble_att_svr_test_misc_prep_write(conn_handle, 1, 0, data, 200, 0);
     ble_att_svr_test_misc_prep_write(conn_handle, 1, 200, data + 200, 200, 0);
     ble_att_svr_test_misc_prep_write(conn_handle, 1, 400, data + 400, 200, 0);
-    ble_att_svr_test_misc_exec_write(conn_handle, BLE_ATT_EXEC_WRITE_F_CONFIRM,
+    ble_att_svr_test_misc_exec_write(conn_handle, BLE_ATT_EXEC_WRITE_F_EXECUTE,
                                      BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN, 1);
     ble_att_svr_test_misc_verify_w_1(NULL, 0);
 
     /*** Successful two part write. */
     ble_att_svr_test_misc_prep_write(conn_handle, 1, 0, data, 20, 0);
     ble_att_svr_test_misc_prep_write(conn_handle, 1, 20, data + 20, 20, 0);
-    ble_att_svr_test_misc_exec_write(conn_handle, BLE_ATT_EXEC_WRITE_F_CONFIRM,
+    ble_att_svr_test_misc_exec_write(conn_handle, BLE_ATT_EXEC_WRITE_F_EXECUTE,
                                      0, 0);
     ble_att_svr_test_misc_verify_w_1(data, 40);
 
@@ -1698,7 +1698,7 @@ TEST_CASE(ble_att_svr_test_prep_write)
     ble_att_svr_test_misc_prep_write(conn_handle, 1, 0, data, 35, 0);
     ble_att_svr_test_misc_prep_write(conn_handle, 1, 35, data + 35, 43, 0);
     ble_att_svr_test_misc_prep_write(conn_handle, 1, 78, data + 78, 1, 0);
-    ble_att_svr_test_misc_exec_write(conn_handle, BLE_ATT_EXEC_WRITE_F_CONFIRM,
+    ble_att_svr_test_misc_exec_write(conn_handle, BLE_ATT_EXEC_WRITE_F_EXECUTE,
                                      0, 0);
     ble_att_svr_test_misc_verify_w_1(data, 79);
 
@@ -1707,7 +1707,7 @@ TEST_CASE(ble_att_svr_test_prep_write)
     ble_att_svr_test_misc_prep_write(conn_handle, 1, 7, data + 7, 10, 0);
     ble_att_svr_test_misc_prep_write(conn_handle, 2, 0, data, 20, 0);
     ble_att_svr_test_misc_prep_write(conn_handle, 2, 20, data + 20, 10, 0);
-    ble_att_svr_test_misc_exec_write(conn_handle, BLE_ATT_EXEC_WRITE_F_CONFIRM,
+    ble_att_svr_test_misc_exec_write(conn_handle, BLE_ATT_EXEC_WRITE_F_EXECUTE,
                                      0, 0);
     ble_att_svr_test_misc_verify_w_1(data, 17);
     ble_att_svr_test_misc_verify_w_2(data, 30);
@@ -1717,7 +1717,7 @@ TEST_CASE(ble_att_svr_test_prep_write)
     ble_att_svr_test_misc_prep_write(conn_handle, 1, 5, data + 5, 2, 0);
     ble_att_svr_test_misc_prep_write(conn_handle, 2, 0, data, 11, 0);
     ble_att_svr_test_misc_prep_write(conn_handle, 2, 12, data + 11, 19, 0);
-    ble_att_svr_test_misc_exec_write(conn_handle, BLE_ATT_EXEC_WRITE_F_CONFIRM,
+    ble_att_svr_test_misc_exec_write(conn_handle, BLE_ATT_EXEC_WRITE_F_EXECUTE,
                                      BLE_ATT_ERR_INVALID_OFFSET, 2);
     ble_att_svr_test_misc_verify_w_1(data, 17);
     ble_att_svr_test_misc_verify_w_2(data, 30);
@@ -1727,7 +1727,7 @@ TEST_CASE(ble_att_svr_test_prep_write)
     ble_att_svr_test_misc_prep_write(conn_handle, 2, 0, data, 18, 0);
     ble_att_svr_test_misc_prep_write(conn_handle, 1, 9, data + 9, 3, 0);
     ble_att_svr_test_misc_prep_write(conn_handle, 2, 18, data + 18, 43, 0);
-    ble_att_svr_test_misc_exec_write(conn_handle, BLE_ATT_EXEC_WRITE_F_CONFIRM,
+    ble_att_svr_test_misc_exec_write(conn_handle, BLE_ATT_EXEC_WRITE_F_EXECUTE,
                                      0, 0);
     ble_att_svr_test_misc_verify_w_1(data, 12);
     ble_att_svr_test_misc_verify_w_2(data, 61);
@@ -1736,7 +1736,7 @@ TEST_CASE(ble_att_svr_test_prep_write)
     ble_att_svr_test_misc_prep_write(conn_handle, 6, 0, data, 35, 0);
     ble_att_svr_test_misc_prep_write(conn_handle, 6, 35, data + 35, 43, 0);
     ble_att_svr_test_misc_prep_write(conn_handle, 6, 78, data + 78, 1, 0);
-    ble_att_svr_test_misc_exec_write(conn_handle, BLE_ATT_EXEC_WRITE_F_CONFIRM,
+    ble_att_svr_test_misc_exec_write(conn_handle, BLE_ATT_EXEC_WRITE_F_EXECUTE,
                                      BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN, 6);
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/48bce399/net/nimble/host/test/src/ble_gatt_write_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/test/src/ble_gatt_write_test.c 
b/net/nimble/host/test/src/ble_gatt_write_test.c
index 33456c8..d3b77d2 100644
--- a/net/nimble/host/test/src/ble_gatt_write_test.c
+++ b/net/nimble/host/test/src/ble_gatt_write_test.c
@@ -161,7 +161,7 @@ ble_gatt_write_test_misc_long_good(int attr_len)
     }
 
     /* Verify execute write request sent. */
-    ble_hs_test_util_verify_tx_exec_write(BLE_ATT_EXEC_WRITE_F_CONFIRM);
+    ble_hs_test_util_verify_tx_exec_write(BLE_ATT_EXEC_WRITE_F_EXECUTE);
 
     /* Receive Exec Write response. */
     ble_hs_test_util_tx_all();
@@ -351,7 +351,7 @@ ble_gatt_write_test_misc_reliable_good(
     }
 
     /* Verify execute write request sent. */
-    ble_hs_test_util_verify_tx_exec_write(BLE_ATT_EXEC_WRITE_F_CONFIRM);
+    ble_hs_test_util_verify_tx_exec_write(BLE_ATT_EXEC_WRITE_F_EXECUTE);
 
     /* Receive Exec Write response. */
     ble_hs_test_util_tx_all();
@@ -611,7 +611,7 @@ TEST_CASE(ble_gatt_write_test_long_queue_full)
     TEST_ASSERT(ble_gatt_write_test_error.att_handle == 100);
 
     /* Verify clear queue command got sent. */
-    ble_hs_test_util_verify_tx_exec_write(0);
+    ble_hs_test_util_verify_tx_exec_write(BLE_ATT_EXEC_WRITE_F_CANCEL);
 }
 
 TEST_CASE(ble_gatt_write_test_long_oom)
@@ -699,7 +699,7 @@ TEST_CASE(ble_gatt_write_test_long_oom)
     ble_hs_test_util_tx_all();
 
     /* Verify execute write request sent. */
-    ble_hs_test_util_verify_tx_exec_write(BLE_ATT_EXEC_WRITE_F_CONFIRM);
+    ble_hs_test_util_verify_tx_exec_write(BLE_ATT_EXEC_WRITE_F_EXECUTE);
 
     /* Receive Exec Write response. */
     ble_hs_test_util_tx_all();
@@ -799,7 +799,7 @@ TEST_CASE(ble_gatt_write_test_reliable_oom)
     ble_hs_test_util_tx_all();
 
     /* Verify execute write request sent. */
-    ble_hs_test_util_verify_tx_exec_write(BLE_ATT_EXEC_WRITE_F_CONFIRM);
+    ble_hs_test_util_verify_tx_exec_write(BLE_ATT_EXEC_WRITE_F_EXECUTE);
 
     /* Receive Exec Write response. */
     ble_hs_test_util_tx_all();

Reply via email to