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 2016/07/03 02:53:19 UTC

[2/2] incubator-mynewt-core git commit: BLE Host - unit tests for reading RSSI.

BLE Host - unit tests for reading RSSI.


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

Branch: refs/heads/develop
Commit: 127d42593fcffad2f8e7b9b419822bddcd97713d
Parents: 4129157
Author: Christopher Collins <cc...@apache.org>
Authored: Sat Jul 2 19:51:34 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Sat Jul 2 19:51:34 2016 -0700

----------------------------------------------------------------------
 net/nimble/host/src/test/ble_host_hci_test.c | 43 +++++++++++++++++++++++
 1 file changed, 43 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/127d4259/net/nimble/host/src/test/ble_host_hci_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_host_hci_test.c b/net/nimble/host/src/test/ble_host_hci_test.c
index d451e7a..52837bd 100644
--- a/net/nimble/host/src/test/ble_host_hci_test.c
+++ b/net/nimble/host/src/test/ble_host_hci_test.c
@@ -38,9 +38,52 @@ TEST_CASE(ble_host_hci_test_event_bad)
     TEST_ASSERT(rc == BLE_HS_ENOTSUP);
 }
 
+TEST_CASE(ble_host_hci_test_rssi)
+{
+    uint8_t params[BLE_HCI_READ_RSSI_ACK_PARAM_LEN];
+    uint16_t opcode;
+    int8_t rssi;
+    int rc;
+
+    opcode = host_hci_opcode_join(BLE_HCI_OGF_STATUS_PARAMS,
+                                  BLE_HCI_OCF_RD_RSSI);
+
+    /*** Success. */
+    /* Connection handle. */
+    htole16(params + 0, 1);
+
+    /* RSSI. */
+    params[2] = -8;
+
+    ble_hs_test_util_set_ack_params(opcode, 0, params, sizeof params);
+
+    rc = ble_hci_util_read_rssi(1, &rssi);
+    TEST_ASSERT_FATAL(rc == 0);
+    TEST_ASSERT(rssi == -8);
+
+    /*** Failure: incorrect connection handle. */
+    htole16(params + 0, 99);
+
+    ble_hs_test_util_set_ack_params(opcode, 0, params, sizeof params);
+
+    rc = ble_hci_util_read_rssi(1, &rssi);
+    TEST_ASSERT(rc == BLE_HS_ECONTROLLER);
+
+    /*** Failure: params too short. */
+    ble_hs_test_util_set_ack_params(opcode, 0, params, sizeof params - 1);
+    rc = ble_hci_util_read_rssi(1, &rssi);
+    TEST_ASSERT(rc == BLE_HS_ECONTROLLER);
+
+    /*** Failure: params too long. */
+    ble_hs_test_util_set_ack_params(opcode, 0, params, sizeof params + 1);
+    rc = ble_hci_util_read_rssi(1, &rssi);
+    TEST_ASSERT(rc == BLE_HS_ECONTROLLER);
+}
+
 TEST_SUITE(ble_host_hci_suite)
 {
     ble_host_hci_test_event_bad();
+    ble_host_hci_test_rssi();
 }
 
 int