Return-Path: X-Original-To: apmail-mynewt-commits-archive@minotaur.apache.org Delivered-To: apmail-mynewt-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EDF1818655 for ; Tue, 19 Jan 2016 01:35:27 +0000 (UTC) Received: (qmail 7313 invoked by uid 500); 19 Jan 2016 01:35:27 -0000 Delivered-To: apmail-mynewt-commits-archive@mynewt.apache.org Received: (qmail 7285 invoked by uid 500); 19 Jan 2016 01:35:27 -0000 Mailing-List: contact commits-help@mynewt.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@mynewt.incubator.apache.org Delivered-To: mailing list commits@mynewt.incubator.apache.org Received: (qmail 7276 invoked by uid 99); 19 Jan 2016 01:35:27 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Jan 2016 01:35:27 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 64747C2DA6 for ; Tue, 19 Jan 2016 01:35:27 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.78 X-Spam-Level: * X-Spam-Status: No, score=1.78 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id hry-0_OgnSOe for ; Tue, 19 Jan 2016 01:35:20 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with SMTP id 2564F212B4 for ; Tue, 19 Jan 2016 01:35:20 +0000 (UTC) Received: (qmail 7176 invoked by uid 99); 19 Jan 2016 01:35:20 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Jan 2016 01:35:20 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id C70FFE00FF; Tue, 19 Jan 2016 01:35:19 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ccollins@apache.org To: commits@mynewt.incubator.apache.org Date: Tue, 19 Jan 2016 01:35:19 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/3] incubator-mynewt-larva git commit: Some miscellaneous renaming. Repository: incubator-mynewt-larva Updated Branches: refs/heads/master b6e2b5ffa -> caecf1dab Some miscellaneous renaming. 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/9927c14f Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/9927c14f Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/9927c14f Branch: refs/heads/master Commit: 9927c14f09e680a42e225e4dd0beea54f2533889 Parents: b6e2b5f Author: Christopher Collins Authored: Fri Jan 15 17:02:21 2016 -0800 Committer: Christopher Collins Committed: Mon Jan 18 17:33:14 2016 -0800 ---------------------------------------------------------------------- net/nimble/host/include/host/ble_gap.h | 6 +-- net/nimble/host/src/ble_gap_conn.c | 53 +++++++++++++------- net/nimble/host/src/ble_hs_adv.h | 1 + net/nimble/host/src/test/ble_gap_test.c | 26 +++++----- net/nimble/host/src/test/ble_hs_adv_test.c | 62 ++++++++++++++++++++++-- net/nimble/host/src/test/ble_hs_conn_test.c | 4 +- net/nimble/host/src/test/ble_hs_test_util.c | 2 +- net/nimble/host/src/test/ble_os_test.c | 11 ++--- project/centtest/src/main.c | 13 +++-- project/prphtest/src/main.c | 12 ++++- 10 files changed, 138 insertions(+), 52 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/9927c14f/net/nimble/host/include/host/ble_gap.h ---------------------------------------------------------------------- diff --git a/net/nimble/host/include/host/ble_gap.h b/net/nimble/host/include/host/ble_gap.h index 5b7412b..3ea6644 100644 --- a/net/nimble/host/include/host/ble_gap.h +++ b/net/nimble/host/include/host/ble_gap.h @@ -25,7 +25,7 @@ struct hci_le_conn_complete; #define BLE_GAP_EVENT_CONN 0 #define BLE_GAP_EVENT_CANCEL_FAILURE 1 -#define BLE_GAP_EVENT_TERM 2 +#define BLE_GAP_EVENT_TERM_FAILURE 2 #define BLE_GAP_EVENT_DISC_SUCCESS 3 #define BLE_GAP_EVENT_DISC_FINISHED 4 #define BLE_GAP_EVENT_ADV_FINISHED 5 @@ -76,8 +76,8 @@ int ble_gap_conn_adv_stop(void); int ble_gap_conn_set_adv_fields(struct ble_hs_adv_fields *adv_fields); int ble_gap_conn_disc(uint32_t duration_ms, uint8_t discovery_mode, ble_gap_disc_fn *cb, void *cb_arg); -int ble_gap_conn_direct_connect(int addr_type, uint8_t *addr, - ble_gap_conn_fn *cb, void *cb_arg); +int ble_gap_conn_initiate(int addr_type, uint8_t *addr, + ble_gap_conn_fn *cb, void *cb_arg); int ble_gap_conn_terminate(uint16_t handle); int ble_gap_conn_cancel(void); int ble_gap_conn_wl_set(struct ble_gap_white_entry *white_list, http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/9927c14f/net/nimble/host/src/ble_gap_conn.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/src/ble_gap_conn.c b/net/nimble/host/src/ble_gap_conn.c index bdcebae..731bdcc 100644 --- a/net/nimble/host/src/ble_gap_conn.c +++ b/net/nimble/host/src/ble_gap_conn.c @@ -248,9 +248,9 @@ ble_gap_conn_notify_connect(int status, struct ble_hs_conn *conn) } static void -ble_gap_conn_notify_term(int status, struct ble_hs_conn *conn) +ble_gap_conn_notify_term_failure(int status, struct ble_hs_conn *conn) { - ble_gap_conn_call_conn_cb(conn, BLE_GAP_EVENT_TERM, status); + ble_gap_conn_call_conn_cb(conn, BLE_GAP_EVENT_TERM_FAILURE, status); } static void @@ -312,7 +312,7 @@ ble_gap_conn_notify_master_term_failure(int status, uint16_t conn_handle) return; } - ble_gap_conn_notify_term(status, conn); + ble_gap_conn_notify_term_failure(status, conn); } static void @@ -417,7 +417,7 @@ ble_gap_conn_rx_disconn_complete(struct hci_disconn_complete *evt) if (conn == NULL) { return; } - ble_gap_conn_notify_term(0, conn); + ble_gap_conn_call_conn_cb(conn, BLE_GAP_EVENT_CONN, BLE_HS_ENOTCONN); ble_hs_conn_remove(conn); ble_hs_conn_free(conn); } else { @@ -637,13 +637,29 @@ ble_gap_conn_rx_conn_complete(struct hci_le_conn_complete *evt) if (evt->status != BLE_ERR_SUCCESS) { status = BLE_HS_HCI_ERR(evt->status); + /* Some error codes need special handling. */ + switch (evt->status) { + case BLE_ERR_DIR_ADV_TMO: + if (ble_gap_conn_slave_in_progress()) { + ble_gap_conn_slave_failed(BLE_GAP_EVENT_ADV_FINISHED, 0); + } + return 0; + + default: + break; + } + switch (evt->role) { case BLE_HCI_LE_CONN_COMPLETE_ROLE_MASTER: - ble_gap_conn_master_failed(status); + if (ble_gap_conn_master_in_progress()) { + ble_gap_conn_master_failed(status); + } break; case BLE_HCI_LE_CONN_COMPLETE_ROLE_SLAVE: - ble_gap_conn_notify_slave_conn_failure(status); + if (ble_gap_conn_slave_in_progress()) { + ble_gap_conn_notify_slave_conn_failure(status); + } break; default: @@ -1071,6 +1087,8 @@ ble_gap_conn_adv_data_tx(void *arg) break; } + flags |= BLE_HS_ADV_F_BREDR_UNSUP; + /* Encode the flags AD field if it is nonzero. */ adv_data_len = ble_gap_conn_slave.adv_data_len; if (flags != 0) { @@ -1436,7 +1454,7 @@ ble_gap_conn_disc(uint32_t duration_ms, uint8_t discovery_mode, } /***************************************************************************** - * $direct connection establishment procedure * + * $connection establishment procedures * *****************************************************************************/ /** @@ -1444,7 +1462,7 @@ ble_gap_conn_disc(uint32_t duration_ms, uint8_t discovery_mode, * while a master connection is being established. */ static void -ble_gap_conn_direct_connect_ack(struct ble_hci_ack *ack, void *arg) +ble_gap_conn_create_ack(struct ble_hci_ack *ack, void *arg) { assert(ble_gap_conn_master.op == BLE_GAP_CONN_OP_M_CONN); assert(ble_gap_conn_master.state == BLE_GAP_CONN_STATE_M_UNACKED); @@ -1458,7 +1476,7 @@ ble_gap_conn_direct_connect_ack(struct ble_hci_ack *ack, void *arg) } static int -ble_gap_conn_direct_connect_tx(void *arg) +ble_gap_conn_create_tx(void *arg) { struct hci_create_conn hcc; int rc; @@ -1488,7 +1506,7 @@ ble_gap_conn_direct_connect_tx(void *arg) hcc.max_ce_len = 0x0300; // XXX ble_gap_conn_master.state = BLE_GAP_CONN_STATE_M_UNACKED; - ble_hci_ack_set_callback(ble_gap_conn_direct_connect_ack, NULL); + ble_hci_ack_set_callback(ble_gap_conn_create_ack, NULL); rc = host_hci_cmd_le_create_connection(&hcc); if (rc != 0) { @@ -1504,17 +1522,18 @@ ble_gap_conn_direct_connect_tx(void *arg) * vol. 3, part C, section 9.3.8. * * @param addr_type The peer's address type; one of: - * o BLE_HCI_ADV_PEER_ADDR_PUBLIC - * o BLE_HCI_ADV_PEER_ADDR_RANDOM - * o BLE_HCI_ADV_PEER_ADDR_PUBLIC_IDENT - * o BLE_HCI_ADV_PEER_ADDR_RANDOM_IDENT + * o BLE_HCI_CONN_PEER_ADDR_PUBLIC + * o BLE_HCI_CONN_PEER_ADDR_RANDOM + * o BLE_HCI_CONN_PEER_ADDR_PUBLIC_IDENT + * o BLE_HCI_CONN_PEER_ADDR_RANDOM_IDENT + * o BLE_GAP_ADDR_TYPE_WL * @param addr The address of the peer to connect to. * * @return 0 on success; nonzero on failure. */ int -ble_gap_conn_direct_connect(int addr_type, uint8_t *addr, - ble_gap_conn_fn *cb, void *cb_arg) +ble_gap_conn_initiate(int addr_type, uint8_t *addr, + ble_gap_conn_fn *cb, void *cb_arg) { int rc; @@ -1540,7 +1559,7 @@ ble_gap_conn_direct_connect(int addr_type, uint8_t *addr, } rc = ble_gap_conn_master_enqueue(BLE_GAP_CONN_STATE_M_PENDING, 0, - ble_gap_conn_direct_connect_tx, NULL); + ble_gap_conn_create_tx, NULL); if (rc != 0) { return rc; } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/9927c14f/net/nimble/host/src/ble_hs_adv.h ---------------------------------------------------------------------- diff --git a/net/nimble/host/src/ble_hs_adv.h b/net/nimble/host/src/ble_hs_adv.h index 376e9a3..9bd7540 100644 --- a/net/nimble/host/src/ble_hs_adv.h +++ b/net/nimble/host/src/ble_hs_adv.h @@ -46,6 +46,7 @@ struct ble_hs_adv { #define BLE_HS_ADV_FLAGS_LEN 1 #define BLE_HS_ADV_F_DISC_LTD 0x01 #define BLE_HS_ADV_F_DISC_GEN 0x02 +#define BLE_HS_ADV_F_BREDR_UNSUP 0x04 int ble_hs_adv_set_flat(uint8_t type, int data_len, void *data, uint8_t *dst, uint8_t *dst_len, uint8_t max_len); http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/9927c14f/net/nimble/host/src/test/ble_gap_test.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/src/test/ble_gap_test.c b/net/nimble/host/src/test/ble_gap_test.c index 4c12e60..a64e257 100644 --- a/net/nimble/host/src/test/ble_gap_test.c +++ b/net/nimble/host/src/test/ble_gap_test.c @@ -394,7 +394,7 @@ TEST_CASE(ble_gap_test_case_conn_wl_bad_args) TEST_ASSERT(!ble_gap_conn_wl_busy()); /*** White-list-using connection in progress. */ - rc = ble_gap_conn_direct_connect(BLE_GAP_ADDR_TYPE_WL, NULL, + rc = ble_gap_conn_initiate(BLE_GAP_ADDR_TYPE_WL, NULL, ble_gap_test_util_connect_cb, NULL); TEST_ASSERT(rc == 0); TEST_ASSERT(ble_gap_conn_wl_busy()); @@ -515,7 +515,7 @@ TEST_CASE(ble_gap_test_case_conn_disc_bad_args) TEST_ASSERT(rc == BLE_HS_EINVAL); /*** Master operation already in progress. */ - rc = ble_gap_conn_direct_connect(BLE_GAP_ADDR_TYPE_WL, NULL, + rc = ble_gap_conn_initiate(BLE_GAP_ADDR_TYPE_WL, NULL, ble_gap_test_util_connect_cb, NULL); rc = ble_gap_conn_disc(0, BLE_GAP_DISC_MODE_GEN, ble_gap_test_util_disc_cb, NULL); @@ -640,7 +640,7 @@ TEST_CASE(ble_gap_test_case_conn_dir_good) TEST_ASSERT(!ble_gap_conn_master_in_progress()); - rc = ble_gap_conn_direct_connect(BLE_ADDR_TYPE_PUBLIC, peer_addr, + rc = ble_gap_conn_initiate(BLE_ADDR_TYPE_PUBLIC, peer_addr, ble_gap_test_util_connect_cb, NULL); TEST_ASSERT(rc == 0); @@ -683,19 +683,19 @@ TEST_CASE(ble_gap_test_case_conn_dir_bad_args) TEST_ASSERT(!ble_gap_conn_master_in_progress()); /*** Invalid address type. */ - rc = ble_gap_conn_direct_connect(5, ((uint8_t[]){ 1, 2, 3, 4, 5, 6 }), + rc = ble_gap_conn_initiate(5, ((uint8_t[]){ 1, 2, 3, 4, 5, 6 }), ble_gap_test_util_connect_cb, NULL); TEST_ASSERT(rc == BLE_HS_EINVAL); TEST_ASSERT(!ble_gap_conn_master_in_progress()); /*** Connection already in progress. */ - rc = ble_gap_conn_direct_connect(BLE_ADDR_TYPE_PUBLIC, + rc = ble_gap_conn_initiate(BLE_ADDR_TYPE_PUBLIC, ((uint8_t[]){ 1, 2, 3, 4, 5, 6 }), ble_gap_test_util_connect_cb, NULL); TEST_ASSERT(rc == 0); TEST_ASSERT(ble_gap_conn_master_in_progress()); - rc = ble_gap_conn_direct_connect(BLE_ADDR_TYPE_PUBLIC, + rc = ble_gap_conn_initiate(BLE_ADDR_TYPE_PUBLIC, ((uint8_t[]){ 2, 3, 4, 5, 6, 7 }), ble_gap_test_util_connect_cb, NULL); TEST_ASSERT(rc == BLE_HS_EALREADY); @@ -712,7 +712,7 @@ TEST_CASE(ble_gap_test_case_conn_dir_bad_addr) TEST_ASSERT(!ble_gap_conn_master_in_progress()); - rc = ble_gap_conn_direct_connect(BLE_ADDR_TYPE_PUBLIC, peer_addr, + rc = ble_gap_conn_initiate(BLE_ADDR_TYPE_PUBLIC, peer_addr, ble_gap_test_util_connect_cb, NULL); TEST_ASSERT(rc == 0); @@ -767,8 +767,8 @@ ble_gap_test_util_conn_cancel(uint8_t *peer_addr, int cmd_fail_idx, cmd_idx = 0; /* Begin creating a connection. */ - rc = ble_gap_conn_direct_connect(BLE_ADDR_TYPE_PUBLIC, peer_addr, - ble_gap_test_util_connect_cb, NULL); + rc = ble_gap_conn_initiate(BLE_ADDR_TYPE_PUBLIC, peer_addr, + ble_gap_test_util_connect_cb, NULL); TEST_ASSERT(rc == 0); TEST_ASSERT(ble_gap_conn_master_in_progress()); @@ -926,8 +926,8 @@ TEST_CASE(ble_gap_test_case_conn_terminate_good) ble_gap_test_util_terminate(peer_addr, -1, 0); - TEST_ASSERT(ble_gap_test_conn_event == BLE_GAP_EVENT_TERM); - TEST_ASSERT(ble_gap_test_conn_status == 0); + TEST_ASSERT(ble_gap_test_conn_event == BLE_GAP_EVENT_CONN); + TEST_ASSERT(ble_gap_test_conn_status == BLE_HS_ENOTCONN); TEST_ASSERT(ble_gap_test_conn_desc.conn_handle == 2); TEST_ASSERT(ble_gap_test_conn_desc.peer_addr_type == BLE_ADDR_TYPE_PUBLIC); TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_addr, peer_addr, 6) == 0); @@ -967,7 +967,7 @@ TEST_CASE(ble_gap_test_case_conn_terminate_ctlr_fail) evt.reason = 0; ble_gap_conn_rx_disconn_complete(&evt); - TEST_ASSERT(ble_gap_test_conn_event == BLE_GAP_EVENT_TERM); + TEST_ASSERT(ble_gap_test_conn_event == BLE_GAP_EVENT_TERM_FAILURE); TEST_ASSERT(ble_gap_test_conn_status == BLE_HS_HCI_ERR(BLE_ERR_UNSUPPORTED)); TEST_ASSERT(ble_gap_test_conn_desc.conn_handle == 2); @@ -985,7 +985,7 @@ TEST_CASE(ble_gap_test_case_conn_terminate_hci_fail) ble_gap_test_util_terminate(peer_addr, 0, BLE_ERR_REPEATED_ATTEMPTS); - TEST_ASSERT(ble_gap_test_conn_event == BLE_GAP_EVENT_TERM); + TEST_ASSERT(ble_gap_test_conn_event == BLE_GAP_EVENT_TERM_FAILURE); TEST_ASSERT(ble_gap_test_conn_status == BLE_HS_HCI_ERR(BLE_ERR_REPEATED_ATTEMPTS)); TEST_ASSERT(ble_gap_test_conn_desc.conn_handle == 2); http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/9927c14f/net/nimble/host/src/test/ble_hs_adv_test.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/src/test/ble_hs_adv_test.c b/net/nimble/host/src/test/ble_hs_adv_test.c index 8da913b..de52a52 100644 --- a/net/nimble/host/src/test/ble_hs_adv_test.c +++ b/net/nimble/host/src/test/ble_hs_adv_test.c @@ -127,10 +127,15 @@ ble_hs_adv_test_misc_tx_and_verify_data(uint8_t disc_mode, TEST_CASE(ble_hs_adv_test_case_flags) { - /* No flags. */ + /* Default flags. */ ble_hs_adv_test_misc_tx_and_verify_data(BLE_GAP_DISC_MODE_NON, (struct ble_hs_adv_test_field[]) { { + .type = BLE_HS_ADV_TYPE_FLAGS, + .val = (uint8_t[]){ BLE_HS_ADV_F_BREDR_UNSUP }, + .val_len = 1, + }, + { .type = BLE_HS_ADV_TYPE_TX_PWR_LEVEL, .val = (uint8_t[]){ 0x00 }, .val_len = 1, @@ -138,12 +143,14 @@ TEST_CASE(ble_hs_adv_test_case_flags) { 0 }, }); - /* Flags = limited discoverable. */ + /* Flags |= limited discoverable. */ ble_hs_adv_test_misc_tx_and_verify_data(BLE_GAP_DISC_MODE_LTD, (struct ble_hs_adv_test_field[]) { { .type = BLE_HS_ADV_TYPE_FLAGS, - .val = (uint8_t[]){ BLE_HS_ADV_F_DISC_LTD }, + .val = (uint8_t[]) { + BLE_HS_ADV_F_DISC_LTD | BLE_HS_ADV_F_BREDR_UNSUP + }, .val_len = 1, }, { .type = BLE_HS_ADV_TYPE_TX_PWR_LEVEL, @@ -158,7 +165,9 @@ TEST_CASE(ble_hs_adv_test_case_flags) (struct ble_hs_adv_test_field[]) { { .type = BLE_HS_ADV_TYPE_FLAGS, - .val = (uint8_t[]){ BLE_HS_ADV_F_DISC_GEN }, + .val = (uint8_t[]) { + BLE_HS_ADV_F_DISC_GEN | BLE_HS_ADV_F_BREDR_UNSUP + }, .val_len = 1, }, { .type = BLE_HS_ADV_TYPE_TX_PWR_LEVEL, @@ -190,6 +199,11 @@ TEST_CASE(ble_hs_adv_test_case_user) .val_len = 6, }, { + .type = BLE_HS_ADV_TYPE_FLAGS, + .val = (uint8_t[]){ BLE_HS_ADV_F_BREDR_UNSUP }, + .val_len = 1, + }, + { .type = BLE_HS_ADV_TYPE_TX_PWR_LEVEL, .val = (uint8_t[]){ 0x00 }, .val_len = 1, @@ -213,6 +227,11 @@ TEST_CASE(ble_hs_adv_test_case_user) .val_len = 6, }, { + .type = BLE_HS_ADV_TYPE_FLAGS, + .val = (uint8_t[]){ BLE_HS_ADV_F_BREDR_UNSUP }, + .val_len = 1, + }, + { .type = BLE_HS_ADV_TYPE_TX_PWR_LEVEL, .val = (uint8_t[]){ 0x00 }, .val_len = 1, @@ -236,6 +255,11 @@ TEST_CASE(ble_hs_adv_test_case_user) .val_len = 8, }, { + .type = BLE_HS_ADV_TYPE_FLAGS, + .val = (uint8_t[]){ BLE_HS_ADV_F_BREDR_UNSUP }, + .val_len = 1, + }, + { .type = BLE_HS_ADV_TYPE_TX_PWR_LEVEL, .val = (uint8_t[]){ 0x00 }, .val_len = 1, @@ -259,6 +283,11 @@ TEST_CASE(ble_hs_adv_test_case_user) .val_len = 8, }, { + .type = BLE_HS_ADV_TYPE_FLAGS, + .val = (uint8_t[]){ BLE_HS_ADV_F_BREDR_UNSUP }, + .val_len = 1, + }, + { .type = BLE_HS_ADV_TYPE_TX_PWR_LEVEL, .val = (uint8_t[]){ 0x00 }, .val_len = 1, @@ -288,6 +317,11 @@ TEST_CASE(ble_hs_adv_test_case_user) .val_len = 16, }, { + .type = BLE_HS_ADV_TYPE_FLAGS, + .val = (uint8_t[]){ BLE_HS_ADV_F_BREDR_UNSUP }, + .val_len = 1, + }, + { .type = BLE_HS_ADV_TYPE_TX_PWR_LEVEL, .val = (uint8_t[]){ 0x00 }, .val_len = 1, @@ -317,6 +351,11 @@ TEST_CASE(ble_hs_adv_test_case_user) .val_len = 16, }, { + .type = BLE_HS_ADV_TYPE_FLAGS, + .val = (uint8_t[]){ BLE_HS_ADV_F_BREDR_UNSUP }, + .val_len = 1, + }, + { .type = BLE_HS_ADV_TYPE_TX_PWR_LEVEL, .val = (uint8_t[]){ 0x00 }, .val_len = 1, @@ -340,6 +379,11 @@ TEST_CASE(ble_hs_adv_test_case_user) .val_len = 6, }, { + .type = BLE_HS_ADV_TYPE_FLAGS, + .val = (uint8_t[]){ BLE_HS_ADV_F_BREDR_UNSUP }, + .val_len = 1, + }, + { .type = BLE_HS_ADV_TYPE_TX_PWR_LEVEL, .val = (uint8_t[]){ 0x00 }, .val_len = 1, @@ -363,6 +407,11 @@ TEST_CASE(ble_hs_adv_test_case_user) .val_len = 6, }, { + .type = BLE_HS_ADV_TYPE_FLAGS, + .val = (uint8_t[]){ BLE_HS_ADV_F_BREDR_UNSUP }, + .val_len = 1, + }, + { .type = BLE_HS_ADV_TYPE_TX_PWR_LEVEL, .val = (uint8_t[]){ 0x00 }, .val_len = 1, @@ -385,6 +434,11 @@ TEST_CASE(ble_hs_adv_test_case_user) .val_len = 1, }, { + .type = BLE_HS_ADV_TYPE_FLAGS, + .val = (uint8_t[]){ BLE_HS_ADV_F_BREDR_UNSUP }, + .val_len = 1, + }, + { .type = BLE_HS_ADV_TYPE_TX_PWR_LEVEL, .val = (uint8_t[]){ 0x00 }, .val_len = 1, http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/9927c14f/net/nimble/host/src/test/ble_hs_conn_test.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/src/test/ble_hs_conn_test.c b/net/nimble/host/src/test/ble_hs_conn_test.c index f7db96d..deeb903 100644 --- a/net/nimble/host/src/test/ble_hs_conn_test.c +++ b/net/nimble/host/src/test/ble_hs_conn_test.c @@ -45,7 +45,7 @@ TEST_CASE(ble_hs_conn_test_direct_connect_success) TEST_ASSERT(ble_hs_conn_first() == NULL); /* Initiate connection. */ - rc = ble_gap_conn_direct_connect(0, addr, NULL, NULL); + rc = ble_gap_conn_initiate(0, addr, NULL, NULL); TEST_ASSERT(rc == 0); ble_hci_sched_wakeup(); @@ -92,7 +92,7 @@ TEST_CASE(ble_hs_conn_test_direct_connect_hci_errors) TEST_ASSERT(ble_hs_conn_first() == NULL); /* Initiate connection. */ - rc = ble_gap_conn_direct_connect(0, addr, NULL, NULL); + rc = ble_gap_conn_initiate(0, addr, NULL, NULL); TEST_ASSERT(rc == 0); ble_hci_sched_wakeup(); http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/9927c14f/net/nimble/host/src/test/ble_hs_test_util.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/src/test/ble_hs_test_util.c b/net/nimble/host/src/test/ble_hs_test_util.c index 9c1364b..4775451 100644 --- a/net/nimble/host/src/test/ble_hs_test_util.c +++ b/net/nimble/host/src/test/ble_hs_test_util.c @@ -68,7 +68,7 @@ ble_hs_test_util_create_conn(uint16_t handle, uint8_t *addr, struct ble_hs_conn *conn; int rc; - rc = ble_gap_conn_direct_connect(0, addr, cb, cb_arg); + rc = ble_gap_conn_initiate(0, addr, cb, cb_arg); TEST_ASSERT(rc == 0); ble_hci_sched_wakeup(); http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/9927c14f/net/nimble/host/src/test/ble_os_test.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/src/test/ble_os_test.c b/net/nimble/host/src/test/ble_os_test.c index c2b06ef..b03ce71 100644 --- a/net/nimble/host/src/test/ble_os_test.c +++ b/net/nimble/host/src/test/ble_os_test.c @@ -104,7 +104,7 @@ ble_gap_direct_connect_test_task_handler(void *arg) TEST_ASSERT(ble_hs_conn_first() == NULL); /* Initiate a direct connection. */ - ble_gap_conn_direct_connect(0, addr, + ble_gap_conn_initiate(0, addr, ble_gap_direct_connect_test_connect_cb, &cb_called); TEST_ASSERT(ble_hs_conn_first() == NULL); @@ -230,11 +230,10 @@ ble_gap_terminate_cb(int event, int status, { int *disconn_handle; - if (event == BLE_GAP_EVENT_CONN) { + TEST_ASSERT_FATAL(event == BLE_GAP_EVENT_CONN); + if (status == 0) { return; } - TEST_ASSERT_FATAL(event == BLE_GAP_EVENT_TERM); - TEST_ASSERT_FATAL(status == 0); disconn_handle = arg; *disconn_handle = desc->conn_handle; @@ -268,7 +267,7 @@ ble_gap_terminate_test_task_handler(void *arg) TEST_ASSERT(!ble_gap_conn_master_in_progress()); /* Create two direct connections. */ - ble_gap_conn_direct_connect(0, addr1, ble_gap_terminate_cb, + ble_gap_conn_initiate(0, addr1, ble_gap_terminate_cb, &disconn_handle); ble_os_test_misc_rx_le_ack(BLE_HCI_OCF_LE_CREATE_CONN, 0); memset(&conn_evt, 0, sizeof conn_evt); @@ -279,7 +278,7 @@ ble_gap_terminate_test_task_handler(void *arg) rc = ble_gap_conn_rx_conn_complete(&conn_evt); TEST_ASSERT(rc == 0); - ble_gap_conn_direct_connect(0, addr2, ble_gap_terminate_cb, + ble_gap_conn_initiate(0, addr2, ble_gap_terminate_cb, &disconn_handle); ble_os_test_misc_rx_le_ack(BLE_HCI_OCF_LE_CREATE_CONN, 0); memset(&conn_evt, 0, sizeof conn_evt); http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/9927c14f/project/centtest/src/main.c ---------------------------------------------------------------------- diff --git a/project/centtest/src/main.c b/project/centtest/src/main.c index 46ff65c..fc86a3c 100755 --- a/project/centtest/src/main.c +++ b/project/centtest/src/main.c @@ -51,7 +51,12 @@ uint8_t g_random_addr[BLE_DEV_ADDR_LEN]; uint8_t g_host_adv_data[BLE_HCI_MAX_ADV_DATA_LEN]; uint8_t g_host_adv_len; -static uint8_t centtest_slv_addr[6] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06}; +/* Mynewt test device. */ +//static uint8_t centtest_slv_addr[6] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06}; + +/* TI SensorTag. */ +static uint8_t centtest_slv_addr[6] = {0x82, 0x6a, 0xd0, 0x48, 0xb4, 0xb0}; + static uint8_t centtest_mst_addr[6] = {0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a}; /* Create a mbuf pool of BLE mbufs */ @@ -219,9 +224,9 @@ centtest_task_handler(void *arg) g_next_os_time = os_time_get(); //rc = ble_gap_conn_disc(20000, BLE_GAP_DISC_MODE_GEN); - rc = ble_gap_conn_direct_connect(BLE_HCI_ADV_PEER_ADDR_PUBLIC, - centtest_slv_addr, - centtest_on_connect, NULL); + rc = ble_gap_conn_initiate(BLE_HCI_ADV_PEER_ADDR_PUBLIC, + centtest_slv_addr, + centtest_on_connect, NULL); assert(rc == 0); while (1) { http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/9927c14f/project/prphtest/src/main.c ---------------------------------------------------------------------- diff --git a/project/prphtest/src/main.c b/project/prphtest/src/main.c index df7f4c6..aa9035a 100755 --- a/project/prphtest/src/main.c +++ b/project/prphtest/src/main.c @@ -201,7 +201,7 @@ prphtest_on_connect(int event, int status, struct ble_gap_conn_desc *desc, { switch (event) { case BLE_GAP_EVENT_CONN: - console_printf("connection complete; handle=%d status=%d " + console_printf("connection event; handle=%d status=%d " "peer_addr=%02x:%02x:%02x:%02x:%02x:%02x\n", desc->conn_handle, status, desc->peer_addr[0], desc->peer_addr[1], @@ -244,10 +244,18 @@ prphtest_task_handler(void *arg) fields.name = (uint8_t *)"nimble"; fields.name_len = 6; fields.name_is_complete = 1; + + fields.uuids16 = (uint16_t[]) { PRPHTEST_SVC1_UUID, PRPHTEST_SVC2_UUID }; + fields.num_uuids16 = 2; + fields.uuids16_is_complete = 1; + + fields.le_role = 0; + fields.le_role_is_present = 1; + rc = ble_gap_conn_set_adv_fields(&fields); assert(rc == 0); - rc = ble_gap_conn_advertise(BLE_GAP_DISC_MODE_NON, BLE_GAP_CONN_MODE_UND, + rc = ble_gap_conn_adv_start(BLE_GAP_DISC_MODE_GEN, BLE_GAP_CONN_MODE_UND, NULL, 0, prphtest_on_connect, NULL); assert(rc == 0);