You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by we...@apache.org on 2016/04/12 20:01:00 UTC
incubator-mynewt-core git commit: Move connection request txd flag to
connection state machine
Repository: incubator-mynewt-core
Updated Branches:
refs/heads/develop 21d27e14a -> 9e1d390f6
Move connection request txd flag to connection state machine
This flag more correctly belongs in the connections state
machine as opposed to the mbuf header. We also need a ble
mbuf flag for upcoming encryption changes.
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/9e1d390f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/9e1d390f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/9e1d390f
Branch: refs/heads/develop
Commit: 9e1d390f65b75642b7e995887d00b33598109063
Parents: 21d27e1
Author: William San Filippo <wi...@runtime.io>
Authored: Tue Apr 12 10:58:32 2016 -0700
Committer: William San Filippo <wi...@runtime.io>
Committed: Tue Apr 12 11:00:52 2016 -0700
----------------------------------------------------------------------
apps/bletest/src/main.c | 12 ++++++++++--
net/nimble/controller/include/controller/ble_ll_conn.h | 11 ++++++-----
net/nimble/controller/src/ble_ll_conn.c | 13 ++++++-------
net/nimble/controller/src/ble_ll_ctrl.c | 4 ++--
4 files changed, 24 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9e1d390f/apps/bletest/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bletest/src/main.c b/apps/bletest/src/main.c
index 4c51add..13083ab 100755
--- a/apps/bletest/src/main.c
+++ b/apps/bletest/src/main.c
@@ -112,6 +112,7 @@ os_membuf_t g_mbuf_buffer[MBUF_MEMPOOL_SIZE];
#define BLETEST_CFG_CONN_PEER_ADDR_TYPE (BLE_HCI_CONN_PEER_ADDR_PUBLIC)
#define BLETEST_CFG_CONN_OWN_ADDR_TYPE (BLE_HCI_ADV_OWN_ADDR_PUBLIC)
#define BLETEST_CFG_CONCURRENT_CONNS (1)
+#define BLETEST_CFG_RAND_PKT_SIZE (1)
#define BLETEST_CFG_SUGG_DEF_TXOCTETS (251)
#define BLETEST_CFG_SUGG_DEF_TXTIME \
BLE_TX_DUR_USECS_M(BLETEST_CFG_SUGG_DEF_TXOCTETS + 4)
@@ -123,6 +124,7 @@ os_membuf_t g_mbuf_buffer[MBUF_MEMPOOL_SIZE];
/* BLETEST variables */
#undef BLETEST_ADV_PKT_NUM
+#define BLETEST_MAX_PKT_SIZE (247)
#define BLETEST_PKT_SIZE (247)
#define BLETEST_STACK_SIZE (256)
uint32_t g_next_os_time;
@@ -473,6 +475,7 @@ bletest_execute_initiator(void)
rc = host_hci_cmd_rd_rem_version(handle);
host_hci_outstanding_opcode = 0;
+ /* Ask for remote used features */
rc = host_hci_cmd_le_read_rem_used_feat(handle);
host_hci_outstanding_opcode = 0;
@@ -631,8 +634,14 @@ bletest_execute_advertiser(void)
om = bletest_get_packet();
if (om) {
/* set payload length */
+#if (BLETEST_CFG_RAND_PKT_SIZE == 1)
+ pktlen = rand() % (BLETEST_MAX_PKT_SIZE + 1);
+#else
pktlen = BLETEST_PKT_SIZE;
- om->om_len = BLETEST_PKT_SIZE + 4;
+
+#endif
+ /* Add header to length */
+ om->om_len = pktlen + 4;
/* Put the HCI header in the mbuf */
htole16(om->om_data, handle);
@@ -1070,4 +1079,3 @@ main(void)
return rc;
}
-
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9e1d390f/net/nimble/controller/include/controller/ble_ll_conn.h
----------------------------------------------------------------------
diff --git a/net/nimble/controller/include/controller/ble_ll_conn.h b/net/nimble/controller/include/controller/ble_ll_conn.h
index dad8356..2f2204a 100644
--- a/net/nimble/controller/include/controller/ble_ll_conn.h
+++ b/net/nimble/controller/include/controller/ble_ll_conn.h
@@ -72,14 +72,14 @@ union ble_ll_conn_sm_flags {
uint16_t slave_set_last_anchor:1;
uint16_t awaiting_host_reply:1;
uint16_t send_conn_upd_event:1;
- uint16_t conn_update_scheduled:1;
+ uint16_t conn_update_sched:1;
uint16_t host_expects_upd_event:1;
uint16_t version_ind_sent:1;
uint16_t rxd_version_ind:1;
uint16_t chanmap_update_scheduled:1;
uint16_t conn_empty_pdu_txd:1;
uint16_t last_txd_md:1;
- uint16_t reserved:1;
+ uint16_t conn_req_txd:1;
} cfbit;
uint16_t conn_flags;
} __attribute__((packed));
@@ -212,9 +212,10 @@ struct ble_ll_conn_sm
};
/* Flags */
-#define CONN_F_UPDATE_SCHED(csm) (csm->csmflags.cfbit.conn_update_scheduled)
-#define CONN_F_EMPTY_PDU_TXD(csm) (csm->csmflags.cfbit.conn_empty_pdu_txd)
-#define CONN_F_LAST_TXD_MD(csm) (csm->csmflags.cfbit.last_txd_md)
+#define CONN_F_UPDATE_SCHED(csm) ((csm)->csmflags.cfbit.conn_update_sched)
+#define CONN_F_EMPTY_PDU_TXD(csm) ((csm)->csmflags.cfbit.conn_empty_pdu_txd)
+#define CONN_F_LAST_TXD_MD(csm) ((csm)->csmflags.cfbit.last_txd_md)
+#define CONN_F_CONN_REQ_TXD(csm) ((csm)->csmflags.cfbit.conn_req_txd)
/*
* Given a handle, returns an active connection state machine (or NULL if the
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9e1d390f/net/nimble/controller/src/ble_ll_conn.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_conn.c b/net/nimble/controller/src/ble_ll_conn.c
index 189d739..4386353 100644
--- a/net/nimble/controller/src/ble_ll_conn.c
+++ b/net/nimble/controller/src/ble_ll_conn.c
@@ -1352,7 +1352,7 @@ ble_ll_conn_next_event(struct ble_ll_conn_sm *connsm)
itvl = connsm->conn_itvl * BLE_LL_CONN_ITVL_USECS;
latency = 1;
if (connsm->csmflags.cfbit.allow_slave_latency &&
- !connsm->csmflags.cfbit.conn_update_scheduled &&
+ !connsm->csmflags.cfbit.conn_update_sched &&
!connsm->csmflags.cfbit.chanmap_update_scheduled) {
if (connsm->csmflags.cfbit.pkt_rxd) {
latency += connsm->slave_latency;
@@ -1370,7 +1370,7 @@ ble_ll_conn_next_event(struct ble_ll_conn_sm *connsm)
* connection by the the transmit window offset. We also copy in the
* update parameters as they now should take effect.
*/
- if (connsm->csmflags.cfbit.conn_update_scheduled &&
+ if (connsm->csmflags.cfbit.conn_update_sched &&
(connsm->event_cntr == connsm->conn_update_req.instant)) {
/* Set flag so we send connection update event */
@@ -1400,7 +1400,7 @@ ble_ll_conn_next_event(struct ble_ll_conn_sm *connsm)
cputime_timer_start(&connsm->conn_spvn_timer, connsm->anchor_point+tmo);
/* Reset update scheduled flag */
- connsm->csmflags.cfbit.conn_update_scheduled = 0;
+ connsm->csmflags.cfbit.conn_update_sched = 0;
}
/*
@@ -1764,9 +1764,8 @@ ble_ll_init_rx_pkt_in(uint8_t *rxbuf, struct ble_mbuf_hdr *ble_hdr)
/* Get the connection state machine we are trying to create */
connsm = g_ble_ll_conn_create_sm;
- /* If we have sent a connect request, we need to enter CONNECTION state*/
- if (connsm && BLE_MBUF_HDR_CRC_OK(ble_hdr) &&
- (ble_hdr->rxinfo.flags & BLE_MBUF_HDR_F_CONN_REQ_TXD)) {
+ /* If we have sent a connect request, we need to enter CONNECTION state */
+ if (connsm && CONN_F_CONN_REQ_TXD(connsm)) {
/* Set address of advertiser to which we are connecting. */
if (ble_ll_scan_whitelist_enabled()) {
/*
@@ -1892,7 +1891,7 @@ ble_ll_init_rx_isr_end(struct os_mbuf *rxpdu, uint8_t crcok)
rc = ble_ll_conn_request_send(addr_type, adv_addr,
g_ble_ll_conn_create_sm->tx_win_off);
if (!rc) {
- ble_hdr->rxinfo.flags |= BLE_MBUF_HDR_F_CONN_REQ_TXD;
+ CONN_F_CONN_REQ_TXD(g_ble_ll_conn_create_sm) = 1;
STATS_INC(ble_ll_conn_stats, conn_req_txd);
}
} else {
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9e1d390f/net/nimble/controller/src/ble_ll_ctrl.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_ctrl.c b/net/nimble/controller/src/ble_ll_ctrl.c
index a7c2cd9..3f2dba5 100644
--- a/net/nimble/controller/src/ble_ll_ctrl.c
+++ b/net/nimble/controller/src/ble_ll_ctrl.c
@@ -486,7 +486,7 @@ ble_ll_ctrl_conn_upd_make(struct ble_ll_conn_sm *connsm, uint8_t *pyld,
htole16(pyld + 9, instant);
/* Set flag in state machine to denote we have scheduled an update */
- connsm->csmflags.cfbit.conn_update_scheduled = 1;
+ connsm->csmflags.cfbit.conn_update_sched = 1;
}
/**
@@ -558,7 +558,7 @@ ble_ll_ctrl_rx_conn_update(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
ble_ll_conn_timeout(connsm, BLE_ERR_INSTANT_PASSED);
rsp_opcode = BLE_ERR_MAX;
} else {
- connsm->csmflags.cfbit.conn_update_scheduled = 1;
+ connsm->csmflags.cfbit.conn_update_sched = 1;
}
return rsp_opcode;