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/22 04:01:39 UTC
[1/4] incubator-mynewt-larva git commit: Add some dead code for
connecting to 2 devs.
Repository: incubator-mynewt-larva
Updated Branches:
refs/heads/master 2b2118b37 -> cc5b7b724
Add some dead code for connecting to 2 devs.
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/70a08713
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/70a08713
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/70a08713
Branch: refs/heads/master
Commit: 70a08713146fc39840b380ca4284c58a7d9278a2
Parents: 2b2118b
Author: Christopher Collins <cc...@gmail.com>
Authored: Mon Dec 21 18:11:27 2015 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Mon Dec 21 18:11:27 2015 -0800
----------------------------------------------------------------------
project/hostctlrtest/src/main.c | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/70a08713/project/hostctlrtest/src/main.c
----------------------------------------------------------------------
diff --git a/project/hostctlrtest/src/main.c b/project/hostctlrtest/src/main.c
index 4382323..92320d0 100755
--- a/project/hostctlrtest/src/main.c
+++ b/project/hostctlrtest/src/main.c
@@ -57,12 +57,10 @@ 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;
-#if HOSTCTLRTEST_CFG_ROLE == HOSTCTLRTEST_ROLE_ADVERTISER
static uint8_t hostctlrtest_slv_addr[6] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06};
-//static uint8_t hostctlrtest_slv_addr[6] = {0x82, 0x6a, 0xd0, 0x48, 0xb4, 0xb0};
-#endif
#if HOSTCTLRTEST_CFG_ROLE == HOSTCTLRTEST_ROLE_INITIATOR
static uint8_t hostctlrtest_mst_addr[6] = {0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a};
+//static uint8_t hostctlrtest_slv2_addr[6] = {0x82, 0x6a, 0xd0, 0x48, 0xb4, 0xb0};
#endif
/* Create a mbuf pool of BLE mbufs */
@@ -321,8 +319,22 @@ hostctlrtest_on_connect(struct ble_gap_conn_event *event, void *arg)
event->conn.peer_addr[4], event->conn.peer_addr[5]);
#if HOSTCTLRTEST_CFG_ROLE == HOSTCTLRTEST_ROLE_INITIATOR
- ble_gatt_disc_all_services(event->conn.handle, hostctlrtest_on_disc_s,
- NULL);
+ if (event->conn.status == 0) {
+ ble_gatt_disc_all_services(event->conn.handle,
+ hostctlrtest_on_disc_s, NULL);
+#if 0
+ int rc;
+ if (memcmp(event->conn.peer_addr, hostctlrtest_slv_addr) == 0) {
+ console_printf("CONNECTING TO DEVICE 2\n");
+ rc = ble_gap_conn_direct_connect(BLE_HCI_ADV_PEER_ADDR_PUBLIC,
+ hostctlrtest_slv2_addr);
+ if (rc != 0) {
+ console_printf("FAILED CONNECT; rc=%d\n", rc);
+ }
+ }
+#endif
+ }
+
break;
case BLE_GAP_CONN_EVENT_TYPE_ADV_RPT:
@@ -376,9 +388,9 @@ hostctlrtest_task_handler(void *arg)
NULL, 0);
#else
console_printf("INITIATOR\n");
- rc = ble_gap_conn_disc(20000, BLE_GAP_DISC_MODE_GEN);
- //rc = ble_gap_conn_direct_connect(BLE_HCI_ADV_PEER_ADDR_PUBLIC,
- // hostctlrtest_slv_addr);
+ //rc = ble_gap_conn_disc(20000, BLE_GAP_DISC_MODE_GEN);
+ rc = ble_gap_conn_direct_connect(BLE_HCI_ADV_PEER_ADDR_PUBLIC,
+ hostctlrtest_slv_addr);
#endif
assert(rc == 0);
[2/4] incubator-mynewt-larva git commit: Add ability to stop
advertising.
Posted by cc...@apache.org.
Add ability to stop advertising.
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/52d8fdfc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/52d8fdfc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/52d8fdfc
Branch: refs/heads/master
Commit: 52d8fdfc69bb2e7c2b568ac9ffd14b7d57b7947a
Parents: 70a0871
Author: Christopher Collins <cc...@gmail.com>
Authored: Mon Dec 21 18:39:34 2015 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Mon Dec 21 18:39:34 2015 -0800
----------------------------------------------------------------------
net/nimble/host/include/host/ble_gap.h | 6 +++
net/nimble/host/include/host/ble_hs.h | 1 +
net/nimble/host/src/ble_gap_conn.c | 67 +++++++++++++++++++++++++++++
3 files changed, 74 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/52d8fdfc/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 d81f1d1..1e4adbe 100644
--- a/net/nimble/host/include/host/ble_gap.h
+++ b/net/nimble/host/include/host/ble_gap.h
@@ -25,6 +25,7 @@ struct hci_le_conn_complete;
#define BLE_GAP_CONN_EVENT_TYPE_ADV_RPT 2
#define BLE_GAP_CONN_EVENT_TYPE_SCAN_DONE 3
#define BLE_GAP_CONN_EVENT_TYPE_TERMINATE 4
+#define BLE_GAP_CONN_EVENT_TYPE_ADV_DONE 5
struct ble_gap_conn_connect_rpt {
uint16_t handle;
@@ -49,6 +50,10 @@ struct ble_gap_conn_terminate_rpt {
uint8_t reason;
};
+struct ble_gap_conn_adv_done {
+ uint8_t status;
+};
+
struct ble_gap_conn_event {
uint8_t type;
@@ -56,6 +61,7 @@ struct ble_gap_conn_event {
struct ble_gap_conn_connect_rpt conn;
struct ble_gap_conn_adv_rpt adv;
struct ble_gap_conn_terminate_rpt term;
+ struct ble_gap_conn_adv_done adv_done;
};
};
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/52d8fdfc/net/nimble/host/include/host/ble_hs.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/ble_hs.h b/net/nimble/host/include/host/ble_hs.h
index 6081e4a..f18692a 100644
--- a/net/nimble/host/include/host/ble_hs.h
+++ b/net/nimble/host/include/host/ble_hs.h
@@ -31,6 +31,7 @@
#define BLE_HS_EBADDATA 10
#define BLE_HS_EOS 11
#define BLE_HS_ECONGESTED 12
+#define BLE_HS_ECONTROLLER 13
struct ble_hs_cfg {
uint16_t max_outstanding_pkts_per_conn;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/52d8fdfc/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 cb64e1f..57ad710 100644
--- a/net/nimble/host/src/ble_gap_conn.c
+++ b/net/nimble/host/src/ble_gap_conn.c
@@ -200,6 +200,17 @@ ble_gap_conn_notify_terminate(uint16_t handle, uint8_t status, uint8_t reason)
}
static void
+ble_gap_conn_notify_adv_done(uint8_t status)
+{
+ struct ble_gap_conn_event event;
+
+ event.type = BLE_GAP_CONN_EVENT_TYPE_ADV_DONE;
+ event.adv_done.status = status;
+
+ ble_gap_conn_call_cb(&event);
+}
+
+static void
ble_gap_conn_master_reset_state(void)
{
ble_gap_conn_master_state = BLE_GAP_CONN_STATE_IDLE;
@@ -511,6 +522,55 @@ ble_gap_conn_slave_timer_exp(void *arg)
}
/*****************************************************************************
+ * $stop advertise *
+ *****************************************************************************/
+
+static void
+ble_gap_conn_adv_ack_disable(struct ble_hci_ack *ack, void *arg)
+{
+ if (ack->bha_status == BLE_ERR_SUCCESS) {
+ /* Advertising should now be aborted. */
+ ble_gap_conn_slave_reset_state();
+ ble_gap_conn_notify_adv_done(0);
+ }
+}
+
+static int
+ble_gap_conn_adv_disable_tx(void *arg)
+{
+ int rc;
+
+ ble_hci_ack_set_callback(ble_gap_conn_adv_ack_disable, NULL);
+ rc = host_hci_cmd_le_set_adv_enable(0);
+ if (rc != BLE_ERR_SUCCESS) {
+ ble_gap_conn_notify_adv_done(BLE_HS_ECONTROLLER);
+ return 1;
+ }
+
+ return 0;
+}
+
+static int
+ble_gap_conn_adv_stop(void)
+{
+ int rc;
+
+ /* Do nothing if advertising is already disabled. */
+ if (ble_gap_conn_s_conn_mode == BLE_GAP_CONN_MODE_NULL &&
+ ble_gap_conn_s_disc_mode == BLE_GAP_DISC_MODE_NULL) {
+
+ return BLE_HS_EALREADY;
+ }
+
+ rc = ble_hci_sched_enqueue(ble_gap_conn_adv_disable_tx, NULL);
+ if (rc != 0) {
+ return rc;
+ }
+
+ return 0;
+}
+
+/*****************************************************************************
* $advertise *
*****************************************************************************/
@@ -787,6 +847,13 @@ ble_gap_conn_advertise(uint8_t discoverable_mode, uint8_t connectable_mode,
{
int rc;
+ if (discoverable_mode == BLE_GAP_DISC_MODE_NULL ||
+ connectable_mode == BLE_GAP_DISC_MODE_NULL) {
+
+ rc = ble_gap_conn_adv_stop();
+ return rc;
+ }
+
if (discoverable_mode >= BLE_GAP_DISC_MODE_MAX ||
connectable_mode >= BLE_GAP_CONN_MODE_MAX) {
[4/4] incubator-mynewt-larva git commit: Add ability to cancel a
connection in progress.
Posted by cc...@apache.org.
Add ability to cancel a connection in progress.
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/cc5b7b72
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/cc5b7b72
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/cc5b7b72
Branch: refs/heads/master
Commit: cc5b7b724c1f064ae05a25977dffd44e24ca163f
Parents: 36945a7
Author: Christopher Collins <cc...@gmail.com>
Authored: Mon Dec 21 19:00:49 2015 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Mon Dec 21 19:00:49 2015 -0800
----------------------------------------------------------------------
net/nimble/host/include/host/ble_gap.h | 1 +
net/nimble/host/include/host/host_hci.h | 1 +
net/nimble/host/src/ble_gap_conn.c | 45 ++++++++++++++++++++++++++++
net/nimble/host/src/host_hci_cmd.c | 10 +++++++
4 files changed, 57 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/cc5b7b72/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 1e4adbe..4523025 100644
--- a/net/nimble/host/include/host/ble_gap.h
+++ b/net/nimble/host/include/host/ble_gap.h
@@ -84,5 +84,6 @@ 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);
int ble_gap_conn_direct_connect(int addr_type, uint8_t *addr);
int ble_gap_conn_terminate(uint16_t handle);
+int ble_gap_conn_cancel(void);
#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/cc5b7b72/net/nimble/host/include/host/host_hci.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/host_hci.h b/net/nimble/host/include/host/host_hci.h
index dde0f3f..31cc70c 100644
--- a/net/nimble/host/include/host/host_hci.h
+++ b/net/nimble/host/include/host/host_hci.h
@@ -45,6 +45,7 @@ int host_hci_cmd_le_add_to_whitelist(uint8_t *addr, uint8_t addr_type);
int host_hci_cmd_le_rmv_from_whitelist(uint8_t *addr, uint8_t addr_type);
int host_hci_cmd_reset(void);
int host_hci_cmd_read_adv_pwr(void);
+int host_hci_cmd_le_create_conn_cancel(void);
int host_hci_set_buf_size(uint16_t pktlen, uint8_t max_pkts);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/cc5b7b72/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 8e7bb1a..2797949 100644
--- a/net/nimble/host/src/ble_gap_conn.c
+++ b/net/nimble/host/src/ble_gap_conn.c
@@ -1173,6 +1173,51 @@ ble_gap_conn_terminate(uint16_t handle)
}
/*****************************************************************************
+ * $cancel *
+ *****************************************************************************/
+
+static void
+ble_gap_conn_cancel_ack(struct ble_hci_ack *ack, void *arg)
+{
+ if (ack->bha_status != 0) {
+ /* XXX: This may be ambiguous to the application. */
+ ble_gap_conn_notify_connect(BLE_HS_ECONTROLLER, NULL);
+ }
+}
+
+static int
+ble_gap_conn_cancel_tx(void *arg)
+{
+ int rc;
+
+ ble_hci_ack_set_callback(ble_gap_conn_cancel_ack, arg);
+
+ rc = host_hci_cmd_le_create_conn_cancel();
+ if (rc != 0) {
+ return 1;
+ }
+
+ return 0;
+}
+
+int
+ble_gap_conn_cancel(void)
+{
+ int rc;
+
+ if (!ble_gap_conn_master_in_progress()) {
+ return BLE_HS_EALREADY;
+ }
+
+ rc = ble_hci_sched_enqueue(ble_gap_conn_cancel_tx, NULL);
+ if (rc != 0) {
+ return rc;
+ }
+
+ return 0;
+}
+
+/*****************************************************************************
* $init *
*****************************************************************************/
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/cc5b7b72/net/nimble/host/src/host_hci_cmd.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/host_hci_cmd.c b/net/nimble/host/src/host_hci_cmd.c
index ab98071..530b9f9 100644
--- a/net/nimble/host/src/host_hci_cmd.c
+++ b/net/nimble/host/src/host_hci_cmd.c
@@ -510,3 +510,13 @@ host_hci_cmd_read_adv_pwr(void)
NULL);
return rc;
}
+
+int
+host_hci_cmd_le_create_conn_cancel(void)
+{
+ int rc;
+
+ rc = host_hci_cmd_send(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_CREATE_CONN_CANCEL,
+ 0, NULL);
+ return rc;
+}
[3/4] incubator-mynewt-larva git commit: Reset FSM when the connect
procedure completes.
Posted by cc...@apache.org.
Reset FSM when the connect procedure completes.
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/36945a71
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/36945a71
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/36945a71
Branch: refs/heads/master
Commit: 36945a713c6a081775320bea788dfe5d1059b968
Parents: 52d8fdf
Author: Christopher Collins <cc...@gmail.com>
Authored: Mon Dec 21 18:43:50 2015 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Mon Dec 21 18:43:50 2015 -0800
----------------------------------------------------------------------
net/nimble/host/src/ble_gap_conn.c | 45 +++++++++++++++++++--------------
1 file changed, 26 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/36945a71/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 57ad710..8e7bb1a 100644
--- a/net/nimble/host/src/ble_gap_conn.c
+++ b/net/nimble/host/src/ble_gap_conn.c
@@ -438,25 +438,6 @@ ble_gap_conn_rx_conn_complete(struct hci_le_conn_complete *evt)
}
/* This event refers to a new connection. */
- switch (evt->role) {
- case BLE_HCI_LE_CONN_COMPLETE_ROLE_MASTER:
- rc = ble_gap_conn_accept_master_conn(evt->peer_addr_type,
- evt->peer_addr);
- break;
-
- case BLE_HCI_LE_CONN_COMPLETE_ROLE_SLAVE:
- rc = ble_gap_conn_accept_slave_conn(evt->peer_addr_type,
- evt->peer_addr);
- break;
-
- default:
- assert(0);
- rc = -1;
- break;
- }
- if (rc != 0) {
- return BLE_HS_ENOENT;
- }
if (evt->status != BLE_ERR_SUCCESS) {
switch (evt->role) {
@@ -476,6 +457,32 @@ ble_gap_conn_rx_conn_complete(struct hci_le_conn_complete *evt)
return 0;
}
+ switch (evt->role) {
+ case BLE_HCI_LE_CONN_COMPLETE_ROLE_MASTER:
+ rc = ble_gap_conn_accept_master_conn(evt->peer_addr_type,
+ evt->peer_addr);
+ if (rc == 0) {
+ ble_gap_conn_master_reset_state();
+ } else {
+ return BLE_HS_ENOENT;
+ }
+ break;
+
+ case BLE_HCI_LE_CONN_COMPLETE_ROLE_SLAVE:
+ rc = ble_gap_conn_accept_slave_conn(evt->peer_addr_type,
+ evt->peer_addr);
+ if (rc == 0) {
+ ble_gap_conn_slave_reset_state();
+ } else {
+ return BLE_HS_ENOENT;
+ }
+ break;
+
+ default:
+ assert(0);
+ break;
+ }
+
conn = ble_hs_conn_alloc();
if (conn == NULL) {
/* XXX: Ensure this never happens. */